. * * @category SocialBookmark * @package StatusNet * @author Evan Prodromou * @copyright 2010 StatusNet, Inc. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0 * @link http://status.net/ */ if (!defined('STATUSNET')) { exit(1); } /** * Bookmark plugin main class * * @category Bookmark * @package StatusNet * @author Brion Vibber * @author Evan Prodromou * @copyright 2010 StatusNet, Inc. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0 * @link http://status.net/ */ class BookmarkPlugin extends Plugin { /** * Database schema setup * * @see Schema * @see ColumnDef * * @return boolean hook value; true means continue processing, false means stop. */ function onCheckSchema() { $schema = Schema::get(); // For storing user-submitted flags on profiles $schema->ensureTable('notice_bookmark', array(new ColumnDef('notice_id', 'integer', null, true, 'PRI'), new ColumnDef('title', 'varchar', 255), new ColumnDef('description', 'text'))); return true; } function onNoticeDeleteRelated($notice) { $nb = Notice_bookmark::staticGet('notice_id', $notice->id); if (!empty($nb)) { $nb->delete(); } return true; } /** * Load related modules when needed * * @param string $cls Name of the class to be loaded * * @return boolean hook value; true means continue processing, false means stop. */ function onAutoload($cls) { $dir = dirname(__FILE__); switch ($cls) { case 'NewbookmarkAction': include_once $dir.'/newbookmark.php'; return false; case 'Notice_bookmark': include_once $dir.'/'.$cls.'.php'; return false; case 'BookmarkForm': include_once $dir.'/'.strtolower($cls).'.php'; return false; default: return true; } } /** * Map URLs to actions * * @param Net_URL_Mapper $m path-to-action mapper * * @return boolean hook value; true means continue processing, false means stop. */ function onRouterInitialized($m) { $m->connect('main/bookmark/new', array('action' => 'newbookmark'), array('id' => '[0-9]+')); return true; } function onPluginVersion(&$versions) { $versions[] = array('name' => 'Sample', 'version' => STATUSNET_VERSION, 'author' => 'Evan Prodromou', 'homepage' => 'http://status.net/wiki/Plugin:Bookmark', 'rawdescription' => _m('Simple extension for supporting bookmarks.')); return true; } }