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
52 $schema->ensureTable('user_flag_profile',
53 array(new ColumnDef('profile_id', 'integer', null,
55 new ColumnDef('user_id', 'integer', null,
57 new ColumnDef('created', 'datetime', null,
59 new ColumnDef('cleared', 'datetime', null,
65 function onInitializePlugin()
67 // XXX: do something here?
71 function onRouterInitialized($m) {
72 $m->connect('main/flag/profile', array('action' => 'flagprofile'));
73 $m->connect('admin/profile/flag', array('action' => 'adminprofileflag'));
77 function onAutoload($cls)
81 case 'FlagprofileAction':
82 case 'AdminprofileflagAction':
83 require_once(INSTALLDIR.'/plugins/UserFlag/' . strtolower(mb_substr($cls, 0, -6)) . '.php');
85 case 'FlagProfileForm':
86 require_once(INSTALLDIR.'/plugins/UserFlag/' . strtolower($cls . '.php'));
88 case 'User_flag_profile':
89 require_once(INSTALLDIR.'/plugins/UserFlag/'.$cls.'.php');
96 function onEndProfilePageActionsElements(&$action, $profile)
98 $user = common_current_user();
100 if (!empty($user) && ($user->id != $profile->id)) {
102 $action->elementStart('li', 'entity_flag');
104 if (User_flag_profile::exists($profile->id, $user->id)) {
105 $action->element('p', 'flagged', _('Flagged'));
107 $form = new FlagProfileForm($action, $profile,
108 array('action' => 'showstream',
109 'nickname' => $profile->nickname));
113 $action->elementEnd('li');
119 function onEndProfileListItemActionElements($item)
121 $user = common_current_user();
125 list($action, $args) = $item->action->returnToArgs();
127 $args['action'] = $action;
129 $form = new FlagProfileForm($item->action, $item->profile, $args);
131 $item->action->elementStart('li', 'entity_flag');
133 $item->action->elementEnd('li');
139 function onEndShowStatusNetStyles($action)
141 $action->cssLink(common_path('plugins/UserFlag/userflag.css'),
142 null, 'screen, projection, tv');
146 function onEndShowScripts($action)
148 $action->elementStart('script', array('type' => 'text/javascript'));
149 $action->raw('/*<![CDATA[*/ if ($(".form_entity_flag").length > 0) { SN.U.FormXHR($(".form_entity_flag")); } /*]]>*/');
150 $action->elementEnd('script');