3 * Laconica, the distributed open-source microblogging tool
5 * Class for deleting a notice
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@controlyourself.ca>
25 * @author Sarven Capadisli <csarven@controlyourself.ca>
26 * @copyright 2008 Control Yourself, Inc.
27 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
28 * @link http://laconi.ca/
31 if (!defined('LACONICA')) {
35 require_once INSTALLDIR.'/lib/deleteaction.php';
37 class DeletenoticeAction extends DeleteAction
41 function handle($args)
43 parent::handle($args);
46 if ($_SERVER['REQUEST_METHOD'] == 'POST') {
47 $this->deleteNotice();
48 } else if ($_SERVER['REQUEST_METHOD'] == 'GET') {
54 * Show the page notice
56 * Shows instructions for the page
61 function showPageNotice()
63 $instr = $this->getInstructions();
64 $output = common_markup_to_html($instr);
66 $this->elementStart('div', 'instructions');
68 $this->elementEnd('div');
71 function getInstructions()
73 return _('You are about to permanently delete a notice. ' .
74 'Once this is done, it cannot be undone.');
79 return _('Delete notice');
83 * Wrapper for showing a page
85 * Stores an error and shows the page
87 * @param string $error Error, if any
92 function showForm($error = null)
94 $this->error = $error;
99 * Insert delete notice form into the content
104 function showContent()
106 $this->elementStart('form', array('id' => 'notice_delete_form',
108 'action' => common_local_url('deletenotice')));
109 $this->hidden('token', common_session_token());
110 $this->hidden('notice', $this->trimmed('notice'));
111 $this->elementStart('p');
112 $this->element('span', array('id' => 'confirmation_text'),
113 _('Are you sure you want to delete this notice?'));
115 $this->element('input', array('id' => 'submit_no',
118 'value' => _('No')));
119 $this->element('input', array('id' => 'submit_yes',
122 'value' => _('Yes')));
123 $this->elementEnd('p');
124 $this->elementEnd('form');
127 function deleteNotice()
130 $token = $this->trimmed('token');
132 if (!$token || $token != common_session_token()) {
133 $this->showForm(_('There was a problem with your session token. ' .
134 ' Try again, please.'));
138 $url = common_get_returnto();
139 $confirmed = $this->trimmed('submit');
141 if ($confirmed == _('Yes')) {
143 $replies = new Reply;
144 $replies->get('notice_id', $this->notice->id);
146 common_dequeue_notice($this->notice);
148 if (common_config('memcached', 'enabled')) {
149 $notice->blowSubsCache();
153 $this->notice->delete();
158 common_set_returnto(null);
160 $url = common_local_url('public');
163 common_redirect($url);