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('admin/yammer',
38 array('action' => 'yammeradminpanel'));
39 $m->connect('admin/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 $schema->ensureTable(strtolower($table), $table::schemaDef());
76 * If the plugin's installed, this should be accessible to admins.
78 function onAdminPanelCheck($name, &$isOK)
80 if ($name == 'yammer') {
89 * Add the Yammer admin panel to the list...
91 function onEndAdminPanelNav($nav)
93 if (AdminPanelAction::canAdmin('yammer')) {
94 $action_name = $nav->action->trimmed('action');
96 $nav->out->menuItem(common_local_url('yammeradminpanel'),
99 $action_name == 'yammeradminpanel',
100 'nav_yammer_admin_panel');
107 * Automatically load the actions and libraries used by the plugin
109 * @param Class $cls the class
111 * @return boolean hook return
114 function onAutoload($cls)
116 $base = dirname(__FILE__);
117 $lower = strtolower($cls);
119 case 'sn_yammerclient':
120 case 'yammerimporter':
122 case 'yammerauthinitform':
123 case 'yammerauthverifyform':
124 case 'yammerprogressform':
125 case 'yammerqueuehandler':
126 require_once "$base/lib/$lower.php";
128 case 'yammeradminpanelaction':
129 $crop = substr($lower, 0, strlen($lower) - strlen('action'));
130 require_once "$base/actions/$crop.php";
133 case 'yammer_notice_stub':
134 case 'yammer_common':
137 case 'yammer_notice':
138 require_once "$base/classes/$cls.php";