3 * StatusNet, the distributed open-source microblogging tool
5 * Allows users to flag content and accounts as offensive/spam/whatever
9 * LICENCE: This program is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU Affero General Public License as published by
11 * the Free Software Foundation, either version 3 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU Affero General Public License for more details.
19 * You should have received a copy of the GNU Affero General Public License
20 * along with this program. If not, see <http://www.gnu.org/licenses/>.
24 * @author Evan Prodromou <evan@status.net>
25 * @copyright 2009 StatusNet, Inc.
26 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
27 * @link http://status.net/
30 if (!defined('STATUSNET') && !defined('LACONICA')) {
35 * Allows users to flag content and accounts as offensive/spam/whatever
39 * @author Evan Prodromou <evan@status.net>
40 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
41 * @link http://status.net/
44 class UserFlagPlugin extends Plugin
46 function onCheckSchema()
48 $schema = Schema::get();
50 // For storing user-submitted flags on profiles
51 $schema->ensureDataObject('User_flag_profile');
56 function onInitializePlugin()
58 // XXX: do something here?
62 function onRouterInitialized(&$m) {
63 $m->connect('main/flag/profile', array('action' => 'flagprofile'));
64 $m->connect('admin/profile/flag', array('action' => 'adminprofileflag'));
68 function onAutoload($cls)
72 case 'FlagprofileAction':
73 case 'AdminprofileflagAction':
74 require_once(INSTALLDIR.'/plugins/UserFlag/' . strtolower(mb_substr($cls, 0, -6)) . '.php');
76 case 'FlagProfileForm':
77 require_once(INSTALLDIR.'/plugins/UserFlag/' . strtolower($cls . '.php'));
79 case 'User_flag_profile':
80 require_once(INSTALLDIR.'/plugins/UserFlag/'.$cls.'.php');
87 function onEndProfilePageActionsElements(&$action, $profile)
89 $user = common_current_user();
93 $action->elementStart('li', 'entity_flag');
95 if (User_flag_profile::exists($profile->id, $user->id)) {
96 $action->element('p', 'flagged', _('Flagged'));
98 $form = new FlagProfileForm($action, $profile,
99 array('action' => 'showstream',
100 'nickname' => $profile->nickname));
104 $action->elementEnd('li');
110 function onEndProfileListItemActionElements($item)
112 $user = common_current_user();
116 list($action, $args) = $item->action->returnToArgs();
118 $args['action'] = $action;
120 $form = new FlagProfileForm($item->action, $item->profile, $args);
128 function onEndShowStatusNetStyles($action)
130 $action->elementStart('style', array('type' => 'text/css'));
131 $action->raw('.entity_flag input, .entity_flag p {'.
132 ' background:url('.common_path('plugins/UserFlag/flag.gif').') 5px 5px no-repeat;'.
134 $action->elementEnd('style');
139 function onEndShowScripts($action)
141 $action->elementStart('script', array('type' => 'text/javascript'));
142 $action->raw('/*<![CDATA[*/ SN.U.FormXHR($(".form_entity_flag")); /*]]>*/');
143 $action->elementEnd('script');