]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - plugins/ModPlus/ModPlusPlugin.php
Merge branch '0.9.x' into merge
[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('STATUSNET')) {
21     exit(1);
22 }
23
24 /**
25  * Some UI extras for now...
26  *
27  * @package ModPlusPlugin
28  * @maintainer Brion Vibber <brion@status.net>
29  */
30 class ModPlusPlugin extends Plugin
31 {
32     function onPluginVersion(&$versions)
33     {
34         $versions[] = array('name' => 'ModPlus',
35                             'version' => STATUSNET_VERSION,
36                             'author' => 'Brion Vibber',
37                             'homepage' => 'http://status.net/wiki/Plugin:ModPlus',
38                             'rawdescription' =>
39                             _m('UI extensions for profile moderation actions.'));
40
41         return true;
42     }
43
44     /**
45      * Load JS at runtime if we're logged in.
46      *
47      * @param Action $action
48      * @return boolean hook result
49      */
50     function onEndShowScripts($action)
51     {
52         $user = common_current_user();
53         if ($user) {
54             $action->script('plugins/ModPlus/modplus.js');
55         }
56         return true;
57     }
58
59     function onEndShowStatusNetStyles($action) {
60         $action->cssLink('plugins/ModPlus/modplus.css');
61         return true;
62     }
63
64     /**
65      * Autoloader
66      *
67      * Loads our classes if they're requested.
68      *
69      * @param string $cls Class requested
70      *
71      * @return boolean hook return
72      */
73     function onAutoload($cls)
74     {
75         switch ($cls)
76         {
77         case 'RemoteprofileAction':
78         case 'RemoteProfileAction':
79             require_once dirname(__FILE__) . '/remoteprofileaction.php';
80             return false;
81         default:
82             return true;
83         }
84     }
85
86     /**
87      * Add OpenID-related paths to the router table
88      *
89      * Hook for RouterInitialized event.
90      *
91      * @param Net_URL_Mapper $m URL mapper
92      *
93      * @return boolean hook return
94      */
95     function onStartInitializeRouter($m)
96     {
97         $m->connect('user/remote/:id',
98                 array('action' => 'remoteprofile'),
99                 array('id' => '[\d]+'));
100
101         return true;
102     }
103
104     function onStartShowNoticeItem($item)
105     {
106         $profile = $item->profile;
107         $isRemote = !(User::staticGet('id', $profile->id));
108         if ($isRemote) {
109             $target = common_local_url('remoteprofile', array('id' => $profile->id));
110             $label = _m('Remote profile options...');
111             $item->out->elementStart('div', 'remote-profile-options');
112             $item->out->element('a', array('href' => $target), $label);
113             $item->out->elementEnd('div');
114         }
115     }
116 }