diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/action.php | 15 | ||||
-rw-r--r-- | lib/blockform.php | 99 | ||||
-rw-r--r-- | lib/deleteuserform.php | 79 | ||||
-rw-r--r-- | lib/mail.php | 19 | ||||
-rw-r--r-- | lib/oauthstore.php | 4 | ||||
-rw-r--r-- | lib/profileactionform.php | 187 | ||||
-rw-r--r-- | lib/profileformaction.php | 139 | ||||
-rw-r--r-- | lib/right.php | 10 | ||||
-rw-r--r-- | lib/router.php | 5 | ||||
-rw-r--r-- | lib/sandboxform.php | 80 | ||||
-rw-r--r-- | lib/silenceform.php | 80 | ||||
-rw-r--r-- | lib/subs.php | 4 | ||||
-rw-r--r-- | lib/unblockform.php | 98 | ||||
-rw-r--r-- | lib/unsandboxform.php | 82 | ||||
-rw-r--r-- | lib/unsilenceform.php | 80 | ||||
-rw-r--r-- | lib/userprofile.php | 47 |
16 files changed, 844 insertions, 184 deletions
diff --git a/lib/action.php b/lib/action.php index b5cf3240c..4c1e73564 100644 --- a/lib/action.php +++ b/lib/action.php @@ -986,6 +986,18 @@ class Action extends HTMLOutputter // lawsuit function selfUrl() { + list($action, $args) = $this->returnToArgs(); + return common_local_url($action, $args); + } + + /** + * Returns arguments sufficient for re-constructing URL + * + * @return array two elements: action, other args + */ + + function returnToArgs() + { $action = $this->trimmed('action'); $args = $this->args; unset($args['action']); @@ -998,8 +1010,7 @@ class Action extends HTMLOutputter // lawsuit foreach (array_keys($_COOKIE) as $cookie) { unset($args[$cookie]); } - - return common_local_url($action, $args); + return array($action, $args); } /** diff --git a/lib/blockform.php b/lib/blockform.php index 4820d09af..b6652b1f6 100644 --- a/lib/blockform.php +++ b/lib/blockform.php @@ -32,8 +32,6 @@ if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); } -require_once INSTALLDIR.'/lib/form.php'; - /** * Form for blocking a user * @@ -47,109 +45,38 @@ require_once INSTALLDIR.'/lib/form.php'; * @see UnblockForm */ -class BlockForm extends Form +class BlockForm extends ProfileActionForm { /** - * Profile of user to block - */ - - var $profile = null; - - /** - * Return-to args - */ - - var $args = null; - - /** - * Constructor + * Action this form provides * - * @param HTMLOutputter $out output channel - * @param Profile $profile profile of user to block - * @param array $args return-to args + * @return string Name of the action, lowercased. */ - function __construct($out=null, $profile=null, $args=null) + function target() { - parent::__construct($out); - - $this->profile = $profile; - $this->args = $args; + return 'block'; } /** - * ID of the form - * - * @return int ID of the form - */ - - function id() - { - return 'block-' . $this->profile->id; - } - - - /** - * class of the form - * - * @return string class of the form - */ - - function formClass() - { - return 'form_user_block'; - } - - - /** - * Action of the form - * - * @return string URL of the action - */ - - function action() - { - return common_local_url('block'); - } - - - /** - * Legend of the Form - * - * @return void - */ - function formLegend() - { - $this->out->element('legend', null, _('Block this user')); - } - - - /** - * Data elements of the form + * Title of the form * - * @return void + * @return string Title of the form, internationalized */ - function formData() + function title() { - $this->out->hidden('blockto-' . $this->profile->id, - $this->profile->id, - 'blockto'); - if ($this->args) { - foreach ($this->args as $k => $v) { - $this->out->hidden('returnto-' . $k, $v); - } - } + return _('Block'); } /** - * Action elements + * Description of the form * - * @return void + * @return string description of the form, internationalized */ - function formActions() + function description() { - $this->out->submit('submit', _('Block'), 'submit', null, _('Block this user')); + return _('Block this user'); } } diff --git a/lib/deleteuserform.php b/lib/deleteuserform.php new file mode 100644 index 000000000..09ea8f68d --- /dev/null +++ b/lib/deleteuserform.php @@ -0,0 +1,79 @@ +<?php +/** + * StatusNet, the distributed open-source microblogging tool + * + * Form for deleting a user + * + * PHP version 5 + * + * LICENCE: This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * @category Form + * @package StatusNet + * @author Evan Prodromou <evan@status.net> + * @copyright 2009 StatusNet, Inc. + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + */ + +if (!defined('STATUSNET')) { + exit(1); +} + +/** + * Form for deleting a user + * + * @category Form + * @package StatusNet + * @author Evan Prodromou <evan@status.net> + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + * + */ + +class DeleteUserForm extends ProfileActionForm +{ + /** + * Action this form provides + * + * @return string Name of the action, lowercased. + */ + + function target() + { + return 'deleteuser'; + } + + /** + * Title of the form + * + * @return string Title of the form, internationalized + */ + + function title() + { + return _('Delete'); + } + + /** + * Description of the form + * + * @return string description of the form, internationalized + */ + + function description() + { + return _('Delete this user'); + } +} diff --git a/lib/mail.php b/lib/mail.php index 5218059e9..dffac3262 100644 --- a/lib/mail.php +++ b/lib/mail.php @@ -216,7 +216,8 @@ function mail_subscribe_notify($listenee, $listener) function mail_subscribe_notify_profile($listenee, $other) { - if ($listenee->email && $listenee->emailnotifysub) { + if ($other->hasRight(Right::EMAILONSUBSCRIBE) && + $listenee->email && $listenee->emailnotifysub) { // use the recipient's localization common_init_locale($listenee->language); @@ -545,6 +546,10 @@ function mail_notify_message($message, $from=null, $to=null) function mail_notify_fave($other, $user, $notice) { + if (!$user->hasRight(Right::EMAILONFAVE)) { + return; + } + $profile = $user->getProfile(); $bestname = $profile->getBestName(); @@ -594,10 +599,14 @@ function mail_notify_attn($user, $notice) $sender = $notice->getProfile(); + if (!$sender->hasRight(Right::EMAILONREPLY)) { + return; + } + $bestname = $sender->getBestName(); common_init_locale($user->language); - + if ($notice->conversation != $notice->id) { $conversationEmailText = "The full conversation can be read here:\n\n". "\t%5\$s\n\n "; @@ -607,9 +616,9 @@ function mail_notify_attn($user, $notice) $conversationEmailText = "%5\$s"; $conversationUrl = null; } - + $subject = sprintf(_('%s (@%s) sent a notice to your attention'), $bestname, $sender->nickname); - + $body = sprintf(_("%1\$s (@%9\$s) just sent a notice to your attention (an '@-reply') on %2\$s.\n\n". "The notice is here:\n\n". "\t%3\$s\n\n" . @@ -635,7 +644,7 @@ function mail_notify_attn($user, $notice) array('nickname' => $user->nickname)),//%7 common_local_url('emailsettings'), //%8 $sender->nickname); //%9 - + common_init_locale(); mail_to_user($user, $subject, $body); } diff --git a/lib/oauthstore.php b/lib/oauthstore.php index a4ea5ad4d..b04bcbb8b 100644 --- a/lib/oauthstore.php +++ b/lib/oauthstore.php @@ -462,6 +462,10 @@ class StatusNetOAuthDataStore extends OAuthDataStore $subscribed = $this->_getAnyProfile($subscribed_user_uri); $subscriber = $this->_getAnyProfile($subscriber_uri); + if (!$subscriber->hasRight(Right::SUBSCRIBE)) { + return _('You have been banned from subscribing.'); + } + $sub->subscribed = $subscribed->id; $sub->subscriber = $subscriber->id; diff --git a/lib/profileactionform.php b/lib/profileactionform.php new file mode 100644 index 000000000..24d4595c0 --- /dev/null +++ b/lib/profileactionform.php @@ -0,0 +1,187 @@ +<?php +/** + * StatusNet, the distributed open-source microblogging tool + * + * Superclass for forms that operate on a profile + * + * PHP version 5 + * + * LICENCE: This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * @category Form + * @package StatusNet + * @author Evan Prodromou <evan@status.net> + * @copyright 2009 StatusNet, Inc. + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + */ + +if (!defined('STATUSNET')) { + exit(1); +} + +/** + * Superclass for forms that operate on a profile + * + * Certain forms (block, silence, userflag, sandbox, delete) work on + * a single profile and work almost the same. So, this form extracts + * a lot of the common code to simplify those forms. + * + * @category Form + * @package StatusNet + * @author Evan Prodromou <evan@status.net> + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + */ + +class ProfileActionForm extends Form +{ + /** + * Profile of user to act on + */ + + var $profile = null; + + /** + * Return-to args + */ + + var $args = null; + + /** + * Constructor + * + * @param HTMLOutputter $out output channel + * @param Profile $profile profile of user to act on + * @param array $args return-to args + */ + + function __construct($out=null, $profile=null, $args=null) + { + parent::__construct($out); + + $this->profile = $profile; + $this->args = $args; + } + + /** + * ID of the form + * + * @return int ID of the form + */ + + function id() + { + return $this->target() . '-' . $this->profile->id; + } + + /** + * class of the form + * + * @return string class of the form + */ + + function formClass() + { + return 'form_user_'.$this->target(); + } + + /** + * Action of the form + * + * @return string URL of the action + */ + + function action() + { + return common_local_url($this->target()); + } + + /** + * Legend of the Form + * + * @return void + */ + + function formLegend() + { + $this->out->element('legend', null, $this->description()); + } + + /** + * Data elements of the form + * + * @return void + */ + + function formData() + { + $action = $this->target(); + + $this->out->hidden($action.'to-' . $this->profile->id, + $this->profile->id, + 'profileid'); + + if ($this->args) { + foreach ($this->args as $k => $v) { + $this->out->hidden('returnto-' . $k, $v); + } + } + } + + /** + * Action elements + * + * @return void + */ + + function formActions() + { + $this->out->submit('submit', $this->title(), 'submit', + null, $this->description()); + } + + /** + * Action this form targets + * + * @return string Name of the action, lowercased. + */ + + function target() + { + return null; + } + + /** + * Title of the form + * + * @return string Title of the form, internationalized + */ + + function title() + { + return null; + } + + /** + * Description of the form + * + * @return string description of the form, internationalized + */ + + function description() + { + return null; + } +} diff --git a/lib/profileformaction.php b/lib/profileformaction.php new file mode 100644 index 000000000..8cb5f6a93 --- /dev/null +++ b/lib/profileformaction.php @@ -0,0 +1,139 @@ +<?php +/** + * Superclass for actions that operate on a user + * + * PHP version 5 + * + * StatusNet - the distributed open-source microblogging tool + * Copyright (C) 2009, StatusNet, Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * @category Action + * @package StatusNet + * @author Evan Prodromou <evan@status.net> + * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3 + * @link http://status.net/ + */ + +if (!defined('STATUSNET') && !defined('LACONICA')) { + exit(1); +} + +/** + * Superclass for actions that operate on a user + * + * @category Action + * @package StatusNet + * @author Evan Prodromou <evan@status.net> + * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3 + * @link http://status.net/ + */ + +class ProfileFormAction extends Action +{ + var $profile = null; + + /** + * Take arguments for running + * + * @param array $args $_REQUEST args + * + * @return boolean success flag + */ + + function prepare($args) + { + parent::prepare($args); + + $this->checkSessionToken(); + + if (!common_logged_in()) { + $this->clientError(_('Not logged in.')); + return false; + } + + $id = $this->trimmed('profileid'); + + if (!$id) { + $this->clientError(_('No profile specified.')); + return false; + } + + $this->profile = Profile::staticGet('id', $id); + + if (!$this->profile) { + $this->clientError(_('No profile with that ID.')); + return false; + } + + return true; + } + + /** + * Handle request + * + * Shows a page with list of favorite notices + * + * @param array $args $_REQUEST args; handled in prepare() + * + * @return void + */ + + function handle($args) + { + parent::handle($args); + + if ($_SERVER['REQUEST_METHOD'] == 'POST') { + $this->handlePost(); + $this->returnToArgs(); + } + } + + /** + * Return to the calling page based on hidden arguments + * + * @return void + */ + + function returnToArgs() + { + foreach ($this->args as $k => $v) { + if ($k == 'returnto-action') { + $action = $v; + } else if (substr($k, 0, 9) == 'returnto-') { + $args[substr($k, 9)] = $v; + } + } + + if ($action) { + common_redirect(common_local_url($action, $args), 303); + } else { + $this->clientError(_("No return-to arguments")); + } + } + + /** + * handle a POST request + * + * sub-classes should overload this request + * + * @return void + */ + + function handlePost() + { + $this->serverError(_("unimplemented method")); + } +} diff --git a/lib/right.php b/lib/right.php index 4fc981af0..5e66eae0e 100644 --- a/lib/right.php +++ b/lib/right.php @@ -47,5 +47,15 @@ class Right { const DELETEOTHERSNOTICE = 'deleteothersnotice'; const CONFIGURESITE = 'configuresite'; + const DELETEUSER = 'deleteuser'; + const SILENCEUSER = 'silenceuser'; + const SANDBOXUSER = 'sandboxuser'; + const NEWNOTICE = 'newnotice'; + const PUBLICNOTICE = 'publicnotice'; + const NEWMESSAGE = 'newmessage'; + const SUBSCRIBE = 'subscribe'; + const EMAILONREPLY = 'emailonreply'; + const EMAILONSUBSCRIBE = 'emailonsubscribe'; + const EMAILONFAVE = 'emailonfave'; } diff --git a/lib/router.php b/lib/router.php index bad3decad..53f30dd3e 100644 --- a/lib/router.php +++ b/lib/router.php @@ -96,7 +96,10 @@ class Router 'unsubscribe', 'confirmaddress', 'recoverpassword', 'invite', 'favor', 'disfavor', 'sup', 'block', 'unblock', 'subedit', - 'groupblock', 'groupunblock'); + 'groupblock', 'groupunblock', + 'sandbox', 'unsandbox', + 'silence', 'unsilence', + 'deleteuser'); foreach ($main as $a) { $m->connect('main/'.$a, array('action' => $a)); diff --git a/lib/sandboxform.php b/lib/sandboxform.php new file mode 100644 index 000000000..7a98e0a5f --- /dev/null +++ b/lib/sandboxform.php @@ -0,0 +1,80 @@ +<?php +/** + * StatusNet, the distributed open-source microblogging tool + * + * Form for sandboxing a user + * + * PHP version 5 + * + * LICENCE: This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * @category Form + * @package StatusNet + * @author Evan Prodromou <evan@status.net> + * @copyright 2009 StatusNet, Inc. + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + */ + +if (!defined('STATUSNET')) { + exit(1); +} + +/** + * Form for sandboxing a user + * + * @category Form + * @package StatusNet + * @author Evan Prodromou <evan@status.net> + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + * + * @see UnSandboxForm + */ + +class SandboxForm extends ProfileActionForm +{ + /** + * Action this form provides + * + * @return string Name of the action, lowercased. + */ + + function target() + { + return 'sandbox'; + } + + /** + * Title of the form + * + * @return string Title of the form, internationalized + */ + + function title() + { + return _('Sandbox'); + } + + /** + * Description of the form + * + * @return string description of the form, internationalized + */ + + function description() + { + return _('Sandbox this user'); + } +} diff --git a/lib/silenceform.php b/lib/silenceform.php new file mode 100644 index 000000000..9673fa120 --- /dev/null +++ b/lib/silenceform.php @@ -0,0 +1,80 @@ +<?php +/** + * StatusNet, the distributed open-source microblogging tool + * + * Form for silencing a user + * + * PHP version 5 + * + * LICENCE: This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * @category Form + * @package StatusNet + * @author Evan Prodromou <evan@status.net> + * @copyright 2009 StatusNet, Inc. + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + */ + +if (!defined('STATUSNET')) { + exit(1); +} + +/** + * Form for silencing a user + * + * @category Form + * @package StatusNet + * @author Evan Prodromou <evan@status.net> + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + * + * @see UnSilenceForm + */ + +class SilenceForm extends ProfileActionForm +{ + /** + * Action this form provides + * + * @return string Name of the action, lowercased. + */ + + function target() + { + return 'silence'; + } + + /** + * Title of the form + * + * @return string Title of the form, internationalized + */ + + function title() + { + return _('Silence'); + } + + /** + * Description of the form + * + * @return string description of the form, internationalized + */ + + function description() + { + return _('Silence this user'); + } +} diff --git a/lib/subs.php b/lib/subs.php index 2f0f97049..2fc3160de 100644 --- a/lib/subs.php +++ b/lib/subs.php @@ -44,6 +44,10 @@ function subs_subscribe_user($user, $other_nickname) function subs_subscribe_to($user, $other) { + if (!$user->hasRight(Right::SUBSCRIBE)) { + return _('You have been banned from subscribing.'); + } + if ($user->isSubscribed($other)) { return _('Already subscribed!'); } diff --git a/lib/unblockform.php b/lib/unblockform.php index f1343757c..4fe28b21a 100644 --- a/lib/unblockform.php +++ b/lib/unblockform.php @@ -28,12 +28,10 @@ * @link http://status.net/ */ -if (!defined('STATUSNET') && !defined('LACONICA')) { +if (!defined('STATUSNET')) { exit(1); } -require_once INSTALLDIR.'/lib/form.php'; - /** * Form for unblocking a user * @@ -47,106 +45,38 @@ require_once INSTALLDIR.'/lib/form.php'; * @see BlockForm */ -class UnblockForm extends Form +class UnblockForm extends ProfileActionForm { /** - * Profile of user to unblock - */ - - var $profile = null; - - /** - * Return-to args - */ - - var $args = null; - - /** - * Constructor - * - * @param HTMLOutputter $out output channel - * @param Profile $profile profile of user to unblock - * @param array $args return-to args - */ - - function __construct($out=null, $profile=null, $args=null) - { - parent::__construct($out); - - $this->profile = $profile; - $this->args = $args; - } - - /** - * ID of the form - * - * @return int ID of the form - */ - - function id() - { - return 'unblock-' . $this->profile->id; - } - - /** - * class of the form + * Action this form provides * - * @return string class of the form + * @return string Name of the action, lowercased. */ - function formClass() + function target() { - return 'form_user_unblock'; + return 'unblock'; } /** - * Action of the form - * - * @return string URL of the action - */ - - function action() - { - return common_local_url('unblock'); - } - - /** - * Legend of the Form - * - * @return void - */ - function formLegend() - { - $this->out->element('legend', null, _('Unblock this user')); - } - - - /** - * Data elements of the form + * Title of the form * - * @return void + * @return string Title of the form, internationalized */ - function formData() + function title() { - $this->out->hidden('unblockto-' . $this->profile->id, - $this->profile->id, - 'unblockto'); - if ($this->args) { - foreach ($this->args as $k => $v) { - $this->out->hidden('returnto-' . $k, $v); - } - } + return _('Unblock'); } /** - * Action elements + * Description of the form * - * @return void + * @return string description of the form, internationalized */ - function formActions() + function description() { - $this->out->submit('submit', _('Unblock'), 'submit', null, _('Unblock this user')); + return _('Unlock this user'); } } diff --git a/lib/unsandboxform.php b/lib/unsandboxform.php new file mode 100644 index 000000000..a77634244 --- /dev/null +++ b/lib/unsandboxform.php @@ -0,0 +1,82 @@ +<?php +/** + * StatusNet, the distributed open-source microblogging tool + * + * Form for unsandboxing a user + * + * PHP version 5 + * + * LICENCE: This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * @category Form + * @package StatusNet + * @author Evan Prodromou <evan@status.net> + * @copyright 2009 StatusNet, Inc. + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + */ + +if (!defined('STATUSNET')) { + exit(1); +} + +/** + * Form for unsandboxing a user + * + * Removes the "sandboxed" role for a user. + * + * @category Form + * @package StatusNet + * @author Evan Prodromou <evan@status.net> + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + * + * @see UnSandboxForm + */ + +class UnsandboxForm extends ProfileActionForm +{ + /** + * Action this form provides + * + * @return string Name of the action, lowercased. + */ + + function target() + { + return 'unsandbox'; + } + + /** + * Title of the form + * + * @return string Title of the form, internationalized + */ + + function title() + { + return _('Unsandbox'); + } + + /** + * Description of the form + * + * @return string description of the form, internationalized + */ + + function description() + { + return _('Unsandbox this user'); + } +} diff --git a/lib/unsilenceform.php b/lib/unsilenceform.php new file mode 100644 index 000000000..ac02b8b6c --- /dev/null +++ b/lib/unsilenceform.php @@ -0,0 +1,80 @@ +<?php +/** + * StatusNet, the distributed open-source microblogging tool + * + * Form for unsilencing a user + * + * PHP version 5 + * + * LICENCE: This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * @category Form + * @package StatusNet + * @author Evan Prodromou <evan@status.net> + * @copyright 2009 StatusNet, Inc. + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + */ + +if (!defined('STATUSNET')) { + exit(1); +} + +/** + * Form for unsilencing a user + * + * @category Form + * @package StatusNet + * @author Evan Prodromou <evan@status.net> + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + * + * @see SilenceForm + */ + +class UnSilenceForm extends ProfileActionForm +{ + /** + * Action this form provides + * + * @return string Name of the action, lowercased. + */ + + function target() + { + return 'unsilence'; + } + + /** + * Title of the form + * + * @return string Title of the form, internationalized + */ + + function title() + { + return _('Unsilence'); + } + + /** + * Description of the form + * + * @return string description of the form, internationalized + */ + + function description() + { + return _('Unsilence this user'); + } +} diff --git a/lib/userprofile.php b/lib/userprofile.php index 4f9d4984f..ee205af85 100644 --- a/lib/userprofile.php +++ b/lib/userprofile.php @@ -283,22 +283,57 @@ class UserProfile extends Widget } } + // return-to args, so we don't have to keep re-writing them + + list($action, $r2args) = $this->out->returnToArgs(); + + // push the action into the list + + $r2args['action'] = $action; + // block/unblock $blocked = $cur->hasBlocked($this->profile); $this->out->elementStart('li', 'entity_block'); if ($blocked) { - $ubf = new UnblockForm($this->out, $this->profile, - array('action' => 'showstream', - 'nickname' => $this->profile->nickname)); + $ubf = new UnblockForm($this->out, $this->profile, $r2args); $ubf->show(); } else { - $bf = new BlockForm($this->out, $this->profile, - array('action' => 'showstream', - 'nickname' => $this->profile->nickname)); + $bf = new BlockForm($this->out, $this->profile, $r2args); $bf->show(); } $this->out->elementEnd('li'); + + if ($cur->hasRight(Right::SANDBOXUSER)) { + $this->out->elementStart('li', 'entity_sandbox'); + if ($this->user->isSandboxed()) { + $usf = new UnSandboxForm($this->out, $this->profile, $r2args); + $usf->show(); + } else { + $sf = new SandboxForm($this->out, $this->profile, $r2args); + $sf->show(); + } + $this->out->elementEnd('li'); + } + + if ($cur->hasRight(Right::SILENCEUSER)) { + $this->out->elementStart('li', 'entity_silence'); + if ($this->user->isSilenced()) { + $usf = new UnSilenceForm($this->out, $this->profile, $r2args); + $usf->show(); + } else { + $sf = new SilenceForm($this->out, $this->profile, $r2args); + $sf->show(); + } + $this->out->elementEnd('li'); + } + + if ($cur->hasRight(Right::DELETEUSER)) { + $this->out->elementStart('li', 'entity_delete'); + $df = new DeleteUserForm($this->out, $this->profile, $r2args); + $df->show(); + $this->out->elementEnd('li'); + } } } |