]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - plugins/ModPlus/ModPlusPlugin.php
XSS vulnerability when remote-subscribing
[quix0rs-gnu-social.git] / plugins / ModPlus / ModPlusPlugin.php
1 <?php
2 /*
3  * StatusNet - the distributed open-source microblogging tool
4  * Copyright (C) 2010, StatusNet, Inc.
5  *
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.
10  *
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.
15  *
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/>.
18  */
19
20 if (!defined('GNUSOCIAL')) { exit(1); }
21
22 /**
23  * Some UI extras for now...
24  *
25  * @package ModPlusPlugin
26  * @maintainer Brion Vibber <brion@status.net>
27  */
28 class ModPlusPlugin extends Plugin
29 {
30     function onPluginVersion(array &$versions)
31     {
32         $versions[] = array('name' => 'ModPlus',
33                             'version' => GNUSOCIAL_VERSION,
34                             'author' => 'Brion Vibber',
35                             'homepage' => 'http://status.net/wiki/Plugin:ModPlus',
36                             'rawdescription' =>
37                             // TRANS: Plugin description.
38                             _m('UI extension for profile moderation actions.'));
39
40         return true;
41     }
42
43     /**
44      * Load JS at runtime.
45      *
46      * @param Action $action
47      * @return boolean hook result
48      */
49     function onEndShowScripts(Action $action)
50     {
51         $action->script($this->path('js/modplus.js'));
52         return true;
53     }
54
55     public function onEndShowStylesheets(Action $action) {
56         $action->cssLink($this->path('css/modplus.css'));
57         return true;
58     }
59
60     /**
61      * Add per-profile info popup menu for author on notice lists.
62      *
63      * @param NoticeListItem $item
64      * @return boolean hook value
65      */
66     function onEndShowNoticeItemAuthor(Profile $profile, HTMLOutputter $out)
67     {
68         $this->showProfileOptions($out, $profile);
69         return true;
70     }
71
72     /**
73      * Add per-profile info popup menu on profile lists.
74      *
75      * @param ProfileListItem $item
76      */
77     function onStartProfileListItemProfile($item)
78     {
79         $this->showProfileOptions($item->out, $item->profile->getProfile());
80         return true;
81     }
82
83     /**
84      * Build common remote-profile options structure.
85      * Currently only adds output for remote profiles, nothing for local users.
86      *
87      * @param HTMLOutputter $out
88      * @param Profile $profile
89      */
90     protected function showProfileOptions(HTMLOutputter $out, Profile $profile)
91     {
92         if (!$profile->isGroup() && !$profile->isLocal()) {
93             $target = common_local_url('userbyid', array('id' => $profile->getID()));
94             // TRANS: Label for access to remote profile options.
95             $label = _m('Remote profile options...');
96             $out->elementStart('div', 'remote-profile-options');
97             $out->element('a', array('href' => $target), $label);
98             $out->elementEnd('div');
99         }
100     }
101 }