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/>.
20 if (!defined('STATUSNET')) {
25 * Some UI extras for now...
27 * @package ModPlusPlugin
28 * @maintainer Brion Vibber <brion@status.net>
30 class ModPlusPlugin extends Plugin
32 function onPluginVersion(&$versions)
34 $versions[] = array('name' => 'ModPlus',
35 'version' => STATUSNET_VERSION,
36 'author' => 'Brion Vibber',
37 'homepage' => 'http://status.net/wiki/Plugin:ModPlus',
39 _m('UI extensions for profile moderation actions.'));
45 * Load JS at runtime if we're logged in.
47 * @param Action $action
48 * @return boolean hook result
50 function onEndShowScripts($action)
52 $user = common_current_user();
54 $action->script($this->path('modplus.js'));
59 function onEndShowStatusNetStyles($action) {
60 $action->cssLink($this->path('modplus.css'));
67 * Loads our classes if they're requested.
69 * @param string $cls Class requested
71 * @return boolean hook return
73 function onAutoload($cls)
77 case 'RemoteprofileAction':
78 case 'RemoteProfileAction':
79 require_once dirname(__FILE__) . '/remoteprofileaction.php';
87 * Add ModPlus-related paths to the router table
89 * Hook for RouterInitialized event.
91 * @param Net_URL_Mapper $m URL mapper
93 * @return boolean hook return
95 function onStartInitializeRouter($m)
97 $m->connect('user/remote/:id',
98 array('action' => 'remoteprofile'),
99 array('id' => '[\d]+'));
105 * Add per-profile info popup menu for author on notice lists.
107 * @param NoticeListItem $item
108 * @return boolean hook value
110 function onStartShowNoticeItem($item)
112 $this->showProfileOptions($item->out, $item->profile);
117 * Add per-profile info popup menu on profile lists.
119 * @param ProfileListItem $item
121 function onStartProfileListItemProfile($item)
123 $this->showProfileOptions($item->out, $item->profile);
128 * Build common remote-profile options structure.
129 * Currently only adds output for remote profiles, nothing for local users.
131 * @param HTMLOutputter $out
132 * @param Profile $profile (may also be an ArrayWrapper... sigh)
134 protected function showProfileOptions(HTMLOutputter $out, $profile)
136 $isRemote = !(User::staticGet('id', $profile->id));
138 $target = common_local_url('remoteprofile', array('id' => $profile->id));
139 $label = _m('Remote profile options...');
140 $out->elementStart('div', 'remote-profile-options');
141 $out->element('a', array('href' => $target), $label);
142 $out->elementEnd('div');