2008-07-16 12:20:45 +09:00
|
|
|
<?php
|
2009-01-21 15:20:17 +09:00
|
|
|
/**
|
2009-08-26 07:12:20 +09:00
|
|
|
* StatusNet, the distributed open-source microblogging tool
|
2008-07-16 12:20:45 +09:00
|
|
|
*
|
2009-01-21 15:20:17 +09:00
|
|
|
* Class for deleting a notice
|
|
|
|
*
|
|
|
|
* PHP version 5
|
|
|
|
*
|
|
|
|
* LICENCE: This program is free software: you can redistribute it and/or modify
|
2008-07-16 12:20:45 +09:00
|
|
|
* 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/>.
|
2009-01-21 15:20:17 +09:00
|
|
|
*
|
|
|
|
* @category Personal
|
2009-08-26 07:12:20 +09:00
|
|
|
* @package StatusNet
|
2009-08-26 07:19:04 +09:00
|
|
|
* @author Evan Prodromou <evan@status.net>
|
|
|
|
* @author Sarven Capadisli <csarven@status.net>
|
2009-08-26 07:12:20 +09:00
|
|
|
* @copyright 2008 StatusNet, Inc.
|
2009-01-21 15:20:17 +09:00
|
|
|
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
2009-08-26 07:16:46 +09:00
|
|
|
* @link http://status.net/
|
2008-07-16 12:20:45 +09:00
|
|
|
*/
|
|
|
|
|
2015-07-10 07:52:22 +09:00
|
|
|
if (!defined('GNUSOCIAL')) { exit(1); }
|
2008-07-16 12:20:45 +09:00
|
|
|
|
2010-11-02 00:26:23 +09:00
|
|
|
// @todo FIXME: documentation needed.
|
2015-07-10 07:52:22 +09:00
|
|
|
class DeletenoticeAction extends FormAction
|
2008-12-24 04:49:23 +09:00
|
|
|
{
|
2015-07-10 07:52:22 +09:00
|
|
|
protected $form = 'deletenotice';
|
2009-09-28 10:10:17 +09:00
|
|
|
|
2015-07-10 07:52:22 +09:00
|
|
|
protected $notice = null;
|
2010-10-09 02:33:43 +09:00
|
|
|
|
2015-07-10 07:52:22 +09:00
|
|
|
protected function doPreparation()
|
2008-12-24 04:33:23 +09:00
|
|
|
{
|
2015-07-10 07:52:22 +09:00
|
|
|
$this->notice = Notice::getByID($this->int('notice'));
|
2009-09-28 10:10:17 +09:00
|
|
|
|
2015-07-10 07:52:22 +09:00
|
|
|
if ($this->notice->profile_id != $this->scoped->getID() &&
|
|
|
|
!$this->scoped->hasRight(Right::DELETEOTHERSNOTICE)) {
|
2010-11-02 00:26:23 +09:00
|
|
|
// TRANS: Error message displayed trying to delete a notice that was not made by the current user.
|
2015-07-10 07:52:22 +09:00
|
|
|
$this->clientError(_('Cannot delete this notice.'));
|
2009-09-28 10:10:17 +09:00
|
|
|
}
|
2008-07-16 12:20:45 +09:00
|
|
|
|
2015-07-10 07:52:22 +09:00
|
|
|
$this->formOpts['notice'] = $this->notice;
|
2008-12-24 04:19:07 +09:00
|
|
|
}
|
2008-07-16 12:20:45 +09:00
|
|
|
|
2009-01-21 15:20:17 +09:00
|
|
|
function getInstructions()
|
|
|
|
{
|
2010-11-02 00:26:23 +09:00
|
|
|
// TRANS: Instructions for deleting a notice.
|
2009-01-21 15:20:17 +09:00
|
|
|
return _('You are about to permanently delete a notice. ' .
|
2009-01-25 03:12:47 +09:00
|
|
|
'Once this is done, it cannot be undone.');
|
2009-01-21 15:20:17 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
function title()
|
2008-12-24 04:33:23 +09:00
|
|
|
{
|
2010-11-02 00:26:23 +09:00
|
|
|
// TRANS: Page title when deleting a notice.
|
2008-12-24 04:19:07 +09:00
|
|
|
return _('Delete notice');
|
|
|
|
}
|
2008-07-16 12:20:45 +09:00
|
|
|
|
2015-07-10 07:52:22 +09:00
|
|
|
protected function doPost()
|
2009-01-21 15:20:17 +09:00
|
|
|
{
|
2009-01-25 03:38:40 +09:00
|
|
|
if ($this->arg('yes')) {
|
2015-07-10 07:52:22 +09:00
|
|
|
if (Event::handle('StartDeleteOwnNotice', array($this->scoped->getUser(), $this->notice))) {
|
2010-09-09 05:37:12 +09:00
|
|
|
$this->notice->delete();
|
2015-07-10 07:52:22 +09:00
|
|
|
Event::handle('EndDeleteOwnNotice', array($this->scoped->getUser(), $this->notice));
|
2010-09-09 05:37:12 +09:00
|
|
|
}
|
2009-01-25 03:38:40 +09:00
|
|
|
}
|
2009-01-21 15:20:17 +09:00
|
|
|
|
2009-01-25 03:38:40 +09:00
|
|
|
$url = common_get_returnto();
|
2009-01-21 15:20:17 +09:00
|
|
|
|
2009-01-25 03:38:40 +09:00
|
|
|
if ($url) {
|
|
|
|
common_set_returnto(null);
|
|
|
|
} else {
|
|
|
|
$url = common_local_url('public');
|
2008-12-24 04:19:07 +09:00
|
|
|
}
|
2009-01-25 03:38:40 +09:00
|
|
|
|
2009-04-02 04:30:59 +09:00
|
|
|
common_redirect($url, 303);
|
2008-12-24 04:19:07 +09:00
|
|
|
}
|
2008-07-16 12:20:45 +09:00
|
|
|
}
|