4 * User by ID action class.
10 * @author Evan Prodromou <evan@status.net>
11 * @author Robin Millette <millette@status.net>
12 * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
13 * @link http://status.net/
15 * StatusNet - the distributed open-source microblogging tool
16 * Copyright (C) 2008, 2009, StatusNet, Inc.
18 * This program is free software: you can redistribute it and/or modify
19 * it under the terms of the GNU Affero General Public License as published by
20 * the Free Software Foundation, either version 3 of the License, or
21 * (at your option) any later version.
23 * This program is distributed in the hope that it will be useful,
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 * GNU Affero General Public License for more details.
28 * You should have received a copy of the GNU Affero General Public License
29 * along with this program. If not, see <http://www.gnu.org/licenses/>.
32 if (!defined('STATUSNET') && !defined('LACONICA')) {
36 require_once INSTALLDIR.'/lib/mail.php';
39 * Nudge a user action class.
43 * @author Evan Prodromou <evan@status.net>
44 * @author Robin Millette <millette@status.net>
45 * @author Sarven Capadisli <csarven@status.net>
46 * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
47 * @link http://status.net/
49 class NudgeAction extends Action
54 * @param array $args array of arguments
58 function handle($args)
60 parent::handle($args);
62 if (!common_logged_in()) {
63 // TRANS: Error message displayed when trying to perform an action that requires a logged in user.
64 $this->clientError(_('Not logged in.'));
68 $user = common_current_user();
69 $other = User::staticGet('nickname', $this->arg('nickname'));
71 if ($_SERVER['REQUEST_METHOD'] != 'POST') {
72 common_redirect(common_local_url('showstream',
73 array('nickname' => $other->nickname)));
78 $token = $this->trimmed('token');
80 if (!$token || $token != common_session_token()) {
81 // TRANS: Client error displayed when the session token does not match or is not given.
82 $this->clientError(_('There was a problem with your session token. Try again, please.'));
86 if (!$other->email || !$other->emailnotifynudge) {
87 // TRANS: Client error displayed trying to nudge a user that cannot be nudged.
88 $this->clientError(_('This user doesn\'t allow nudges or hasn\'t confirmed or set their email address yet.'));
92 $this->notify($user, $other);
94 if ($this->boolean('ajax')) {
95 $this->startHTML('text/xml;charset=utf-8');
96 $this->elementStart('head');
97 // TRANS: Page title after sending a nudge.
98 $this->element('title', null, _('Nudge sent'));
99 $this->elementEnd('head');
100 $this->elementStart('body');
101 // TRANS: Confirmation text after sending a nudge.
102 $this->element('p', array('id' => 'nudge_response'), _('Nudge sent!'));
103 $this->elementEnd('body');
104 $this->elementEnd('html');
106 // display a confirmation to the user
107 common_redirect(common_local_url('showstream',
108 array('nickname' => $other->nickname)),
114 * Do the actual notification
116 * @param class $user nudger
117 * @param class $other nudgee
121 function notify($user, $other)
123 if ($other->id != $user->id) {
124 if ($other->email && $other->emailnotifynudge) {
125 mail_notify_nudge($user, $other);
128 // XXX: notify by SMS
132 function isReadOnly($args)