// @todo FIXME: documentation needed.
class DeletenoticeAction extends FormAction
{
- protected $form = 'deletenotice';
-
protected $notice = null;
protected function doPreparation()
{
- $this->notice = Notice::getByID($this->int('notice'));
+ $this->notice = Notice::getByID($this->trimmed('notice'));
- if ($this->notice->profile_id != $this->scoped->getID() &&
+ if (!$this->scoped->sameAs($this->notice->getProfile()) &&
!$this->scoped->hasRight(Right::DELETEOTHERSNOTICE)) {
// TRANS: Error message displayed trying to delete a notice that was not made by the current user.
$this->clientError(_('Cannot delete this notice.'));
{
if ($this->arg('yes')) {
if (Event::handle('StartDeleteOwnNotice', array($this->scoped->getUser(), $this->notice))) {
- $this->notice->delete();
+ $this->notice->deleteAs($this->scoped);
Event::handle('EndDeleteOwnNotice', array($this->scoped->getUser(), $this->notice));
}
- }
-
- $url = common_get_returnto();
-
- if ($url) {
- common_set_returnto(null);
} else {
- $url = common_local_url('public');
+ common_redirect(common_get_returnto(), 303);
}
- common_redirect($url, 303);
+ common_redirect(common_local_url('top'), 303);
}
}