3 * StatusNet - the distributed open-source microblogging tool
4 * Copyright (C) 2010, StatusNet, Inc.
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Affero General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Affero General Public License for more details.
16 * You should have received a copy of the GNU Affero General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21 * @package YammerImportPlugin
22 * @maintainer Brion Vibber <brion@status.net>
25 if (!defined('STATUSNET')) { exit(1); }
27 class YammerImportPlugin extends Plugin
30 * Hook for RouterInitialized event.
32 * @param Net_URL_Mapper $m path-to-action mapper
33 * @return boolean hook return
35 function onRouterInitialized($m)
37 $m->connect('panel/yammer',
38 array('action' => 'yammeradminpanel'));
39 $m->connect('panel/yammer/auth',
40 array('action' => 'yammerauth'));
45 * Set up queue handlers for import processing
46 * @param QueueManager $qm
47 * @return boolean hook return
49 function onEndInitializeQueueManager(QueueManager $qm)
51 $qm->connect('yammer', 'YammerQueueHandler');
57 * Set up all our tables...
59 function onCheckSchema()
61 $schema = Schema::get();
63 $tables = array('Yammer_state',
67 'Yammer_notice_stub');
68 foreach ($tables as $table) {
69 $schemaDef = call_user_func(array($table, 'schemaDef'));
70 $schema->ensureTable(strtolower($table), $schemaDef);
77 * If the plugin's installed, this should be accessible to admins.
79 function onAdminPanelCheck($name, &$isOK)
81 if ($name == 'yammer') {
90 * Add the Yammer admin panel to the list...
92 function onEndAdminPanelNav($nav)
94 if (AdminPanelAction::canAdmin('yammer')) {
95 $action_name = $nav->action->trimmed('action');
97 $nav->out->menuItem(common_local_url('yammeradminpanel'),
100 $action_name == 'yammeradminpanel',
101 'nav_yammer_admin_panel');
108 * Automatically load the actions and libraries used by the plugin
110 * @param Class $cls the class
112 * @return boolean hook return
115 function onAutoload($cls)
117 $base = dirname(__FILE__);
118 $lower = strtolower($cls);
120 case 'sn_yammerclient':
121 case 'yammerimporter':
123 case 'yammerapikeyform':
124 case 'yammerauthinitform':
125 case 'yammerauthverifyform':
126 case 'yammerprogressform':
127 case 'yammerqueuehandler':
128 require_once "$base/lib/$lower.php";
130 case 'yammeradminpanelaction':
131 $crop = substr($lower, 0, strlen($lower) - strlen('action'));
132 require_once "$base/actions/$crop.php";
135 case 'yammer_notice_stub':
136 case 'yammer_common':
139 case 'yammer_notice':
140 require_once "$base/classes/$cls.php";