summaryrefslogtreecommitdiff
path: root/actions
diff options
context:
space:
mode:
Diffstat (limited to 'actions')
-rw-r--r--actions/deletenotice.php114
-rw-r--r--actions/nudge.php2
-rw-r--r--actions/showstream.php22
-rw-r--r--actions/subscribe.php5
-rw-r--r--actions/unsubscribe.php5
5 files changed, 113 insertions, 35 deletions
diff --git a/actions/deletenotice.php b/actions/deletenotice.php
index bae0eac1b..efef95441 100644
--- a/actions/deletenotice.php
+++ b/actions/deletenotice.php
@@ -1,9 +1,12 @@
<?php
-/*
- * Laconica - a distributed open-source microblogging tool
- * Copyright (C) 2008, Controlez-Vous, Inc.
+/**
+ * Laconica, the distributed open-source microblogging tool
*
- * This program is free software: you can redistribute it and/or modify
+ * Class for deleting a notice
+ *
+ * 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.
@@ -15,49 +18,99 @@
*
* 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 Personal
+ * @package Laconica
+ * @author Evan Prodromou <evan@controlyourself.ca>
+ * @author Sarven Capadisli <csarven@controlyourself.ca>
+ * @copyright 2008 Control Yourself, Inc.
+ * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
+ * @link http://laconi.ca/
*/
-if (!defined('LACONICA')) { exit(1); }
+if (!defined('LACONICA')) {
+ exit(1);
+}
-require_once(INSTALLDIR.'/lib/deleteaction.php');
+require_once INSTALLDIR.'/lib/deleteaction.php';
class DeletenoticeAction extends DeleteAction
{
+ var $error = null;
+
function handle($args)
{
parent::handle($args);
- # XXX: Ajax!
+ // XXX: Ajax!
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
- $this->delete_notice();
+ $this->deleteNotice();
} else if ($_SERVER['REQUEST_METHOD'] == 'GET') {
- $this->show_form();
+ $this->showForm();
}
}
- function get_instructions()
+ /**
+ * Show the page notice
+ *
+ * Shows instructions for the page
+ *
+ * @return void
+ */
+
+ function showPageNotice()
{
- return _('You are about to permanently delete a notice. Once this is done, it cannot be undone.');
+ $instr = $this->getInstructions();
+ $output = common_markup_to_html($instr);
+
+ $this->elementStart('div', 'instructions');
+ $this->raw($output);
+ $this->elementEnd('div');
}
- function get_title()
+ function getInstructions()
+ {
+ return _('You are about to permanently delete a notice. ' .
+ 'Once this is done, it cannot be undone.');
+ }
+
+ function title()
{
return _('Delete notice');
}
- function show_form($error=null)
+ /**
+ * Wrapper for showing a page
+ *
+ * Stores an error and shows the page
+ *
+ * @param string $error Error, if any
+ *
+ * @return void
+ */
+
+ function showForm($error = null)
{
- $user = common_current_user();
+ $this->error = $error;
+ $this->showPage();
+ }
+
+ /**
+ * Insert delete notice form into the content
+ *
+ * @return void
+ */
- common_show_header($this->get_title(), array($this, 'show_header'), $error,
- array($this, 'show_top'));
+ function showContent()
+ {
$this->elementStart('form', array('id' => 'notice_delete_form',
'method' => 'post',
'action' => common_local_url('deletenotice')));
$this->hidden('token', common_session_token());
$this->hidden('notice', $this->trimmed('notice'));
$this->elementStart('p');
- $this->element('span', array('id' => 'confirmation_text'), _('Are you sure you want to delete this notice?'));
+ $this->element('span', array('id' => 'confirmation_text'),
+ _('Are you sure you want to delete this notice?'));
$this->element('input', array('id' => 'submit_no',
'name' => 'submit',
@@ -69,33 +122,38 @@ class DeletenoticeAction extends DeleteAction
'value' => _('Yes')));
$this->elementEnd('p');
$this->elementEnd('form');
- common_show_footer();
}
- function delete_notice()
+ function deleteNotice()
{
- # CSRF protection
+ // CSRF protection
$token = $this->trimmed('token');
+
if (!$token || $token != common_session_token()) {
- $this->show_form(_('There was a problem with your session token. Try again, please.'));
+ $this->showForm(_('There was a problem with your session token. ' .
+ ' Try again, please.'));
return;
}
- $url = common_get_returnto();
+
+ $url = common_get_returnto();
$confirmed = $this->trimmed('submit');
+
if ($confirmed == _('Yes')) {
- $user = common_current_user();
- $notice_id = $this->trimmed('notice');
- $notice = Notice::staticGet($notice_id);
+
$replies = new Reply;
- $replies->get('notice_id', $notice_id);
+ $replies->get('notice_id', $this->notice->id);
+
+ common_dequeue_notice($this->notice);
- common_dequeue_notice($notice);
if (common_config('memcached', 'enabled')) {
$notice->blowSubsCache();
}
+
$replies->delete();
- $notice->delete();
+ $this->notice->delete();
+
} else {
+
if ($url) {
common_set_returnto(null);
} else {
diff --git a/actions/nudge.php b/actions/nudge.php
index bb80ce357..456106459 100644
--- a/actions/nudge.php
+++ b/actions/nudge.php
@@ -88,7 +88,7 @@ class NudgeAction extends Action
$this->notify($user, $other);
if ($this->boolean('ajax')) {
- common_start_html('text/xml;charset=utf-8', true);
+ $this->startHTML('text/xml;charset=utf-8', true);
$this->elementStart('head');
$this->element('title', null, _('Nudge sent'));
$this->elementEnd('head');
diff --git a/actions/showstream.php b/actions/showstream.php
index 3882af845..76249d14d 100644
--- a/actions/showstream.php
+++ b/actions/showstream.php
@@ -326,7 +326,25 @@ class ShowstreamAction extends Action
}
$this->elementEnd('li');
- common_profile_new_message_nudge($cur, $this->user, $this->profile);
+// common_profile_new_message_nudge($cur, $this->user, $this->profile);
+
+ $user = User::staticGet('id', $this->profile->id);
+ if ($cur && $cur->id != $user->id && $cur->mutuallySubscribed($user)) {
+ $this->elementStart('li', array('id' => 'user_send-a-message'));
+ $this->element('a', array('href' => common_local_url('newmessage', array('to' => $user->id)),
+ 'title' => _('Send a direct message to this user')),
+ _('Message'));
+ $this->elementEnd('li');
+
+ if ($user->email && $user->emailnotifynudge) {
+ $this->elementStart('li', array('id' => 'user_nudge'));
+ $nf = new NudgeForm($this, $user);
+ $nf->show();
+ $this->elementEnd('li');
+ }
+ }
+
+
if ($cur && $cur->id != $this->profile->id) {
$blocked = $cur->hasBlocked($this->profile);
@@ -349,7 +367,7 @@ class ShowstreamAction extends Action
$url = common_local_url('remotesubscribe',
array('nickname' => $this->profile->nickname));
$this->element('a', array('href' => $url,
- 'id' => 'remotesubscribe'),
+ 'id' => 'user_subscribe_remote'),
_('Subscribe'));
}
diff --git a/actions/subscribe.php b/actions/subscribe.php
index b6f03f0f1..171332734 100644
--- a/actions/subscribe.php
+++ b/actions/subscribe.php
@@ -64,12 +64,13 @@ class SubscribeAction extends Action
}
if ($this->boolean('ajax')) {
- common_start_html('text/xml;charset=utf-8', true);
+ $this->startHTML('text/xml;charset=utf-8', true);
$this->elementStart('head');
$this->element('title', null, _('Subscribed'));
$this->elementEnd('head');
$this->elementStart('body');
- common_unsubscribe_form($other->getProfile());
+ $unsubscribe = new UnsubscribeForm($this, $other->getProfile());
+ $unsubscribe->show();
$this->elementEnd('body');
$this->elementEnd('html');
} else {
diff --git a/actions/unsubscribe.php b/actions/unsubscribe.php
index 32511a4b4..f9dd6f821 100644
--- a/actions/unsubscribe.php
+++ b/actions/unsubscribe.php
@@ -66,12 +66,13 @@ class UnsubscribeAction extends Action
}
if ($this->boolean('ajax')) {
- common_start_html('text/xml;charset=utf-8', true);
+ $this->startHTML('text/xml;charset=utf-8', true);
$this->elementStart('head');
$this->element('title', null, _('Unsubscribed'));
$this->elementEnd('head');
$this->elementStart('body');
- common_subscribe_form($other);
+ $subscribe = new SubscribeForm($this, $other);
+ $subscribe->show();
$this->elementEnd('body');
$this->elementEnd('html');
} else {