123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133 |
- <?php
- if (!defined('STATUSNET') && !defined('LACONICA')) {
- exit(1);
- }
- require_once INSTALLDIR.'/lib/mail.php';
- class NudgeAction extends Action
- {
-
- function handle()
- {
- parent::handle();
- if (!common_logged_in()) {
-
- $this->clientError(_('Not logged in.'));
- }
- $user = common_current_user();
- $other = User::getKV('nickname', $this->arg('nickname'));
- if ($_SERVER['REQUEST_METHOD'] != 'POST') {
- common_redirect(common_local_url('showstream',
- array('nickname' => $other->nickname)));
- }
-
- $token = $this->trimmed('token');
- if (!$token || $token != common_session_token()) {
-
- $this->clientError(_('There was a problem with your session token. Try again, please.'));
- }
- if (!$other->email || !$other->emailnotifynudge) {
-
- $this->clientError(_('This user doesn\'t allow nudges or hasn\'t confirmed or set their email address yet.'));
- }
- $this->notify($user, $other);
- if ($this->boolean('ajax')) {
- $this->startHTML('text/xml;charset=utf-8');
- $this->elementStart('head');
-
- $this->element('title', null, _('Nudge sent'));
- $this->elementEnd('head');
- $this->elementStart('body');
-
- $this->element('p', array('id' => 'nudge_response'), _('Nudge sent!'));
- $this->elementEnd('body');
- $this->endHTML();
- } else {
-
- common_redirect(common_local_url('showstream',
- array('nickname' => $other->nickname)),
- 303);
- }
- }
-
- function notify($user, $other)
- {
- if ($other->id != $user->id) {
- if ($other->email && $other->emailnotifynudge) {
- mail_notify_nudge($user, $other);
- }
-
-
- }
- }
- function isReadOnly($args)
- {
- return true;
- }
- }
|