Deleted_notice is pluginified, don't call directly from core
This commit is contained in:
parent
45dd343126
commit
adba38ce20
@ -74,16 +74,21 @@ class ApiStatusesShowAction extends ApiPrivateAuthAction
|
|||||||
|
|
||||||
$this->notice_id = (int)$this->trimmed('id');
|
$this->notice_id = (int)$this->trimmed('id');
|
||||||
|
|
||||||
$this->notice = Notice::getKV('id', $this->notice_id);
|
$this->notice = null;
|
||||||
if (!$this->notice instanceof Notice) {
|
try {
|
||||||
$deleted = Deleted_notice::getKV('id', $this->notice_id);
|
$this->notice = Notice::getByID($this->notice_id);
|
||||||
if ($deleted instanceof Deleted_notice) {
|
} catch (NoResultException $e) {
|
||||||
|
// No such notice was found, maybe it was deleted?
|
||||||
|
$deleted = null;
|
||||||
|
Event::handle('IsNoticeDeleted', array($this->notice_id, &$deleted));
|
||||||
|
if ($deleted === true) {
|
||||||
// TRANS: Client error displayed trying to show a deleted notice.
|
// TRANS: Client error displayed trying to show a deleted notice.
|
||||||
$this->clientError(_('Notice deleted.'), 410);
|
throw new ClientException(_('Notice deleted.'), 410);
|
||||||
}
|
}
|
||||||
// TRANS: Client error displayed trying to show a non-existing notice.
|
// TRANS: Client error displayed trying to show a non-existing notice.
|
||||||
$this->clientError(_('No such notice.'), 404);
|
throw new ClientException(_('No such notice.'), 404);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$this->notice->inScope($this->scoped)) {
|
if (!$this->notice->inScope($this->scoped)) {
|
||||||
// TRANS: Client exception thrown when trying a view a notice the user has no access to.
|
// TRANS: Client exception thrown when trying a view a notice the user has no access to.
|
||||||
throw new ClientException(_('Access restricted.'), 403);
|
throw new ClientException(_('Access restricted.'), 403);
|
||||||
|
@ -113,20 +113,22 @@ class ShownoticeAction extends ManagedAction
|
|||||||
{
|
{
|
||||||
$id = $this->arg('notice');
|
$id = $this->arg('notice');
|
||||||
|
|
||||||
$notice = Notice::getKV('id', $id);
|
$notice = null;
|
||||||
if ($notice instanceof Notice) {
|
try {
|
||||||
|
$notice = Notice::getByID($id);
|
||||||
// Alright, got it!
|
// Alright, got it!
|
||||||
return $notice;
|
return $notice;
|
||||||
}
|
} catch (NoResultException $e) {
|
||||||
|
// Hm, not found.
|
||||||
// Did we use to have it, and it got deleted?
|
$deleted = null;
|
||||||
$deleted = Deleted_notice::getKV('id', $id);
|
Event::handle('IsNoticeDeleted', array($id, &$deleted));
|
||||||
if ($deleted instanceof Deleted_notice) {
|
if ($deleted === true) {
|
||||||
// TRANS: Client error displayed trying to show a deleted notice.
|
// TRANS: Client error displayed trying to show a deleted notice.
|
||||||
$this->clientError(_('Notice deleted.'), 410);
|
throw new ClientException(_('Notice deleted.'), 410);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// TRANS: Client error displayed trying to show a non-existing notice.
|
// TRANS: Client error displayed trying to show a non-existing notice.
|
||||||
$this->clientError(_('No such notice.'), 404);
|
throw new ClientException(_('No such notice.'), 404);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -46,6 +46,18 @@ class ActivityModerationPlugin extends ActivityVerbHandlerPlugin
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function onIsNoticeDeleted($id, &$deleted)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$found = Deleted_notice::getByID($id);
|
||||||
|
$deleted = ($found instanceof Deleted_notice);
|
||||||
|
} catch (NoResultException $e) {
|
||||||
|
$deleted = false;
|
||||||
|
}
|
||||||
|
// return true (continue event) if $deleted is false, return false (stop event) if deleted notice was found
|
||||||
|
return !$deleted;
|
||||||
|
}
|
||||||
|
|
||||||
protected function getActionTitle(ManagedAction $action, $verb, Notice $target, Profile $scoped)
|
protected function getActionTitle(ManagedAction $action, $verb, Notice $target, Profile $scoped)
|
||||||
{
|
{
|
||||||
// FIXME: switch based on action type
|
// FIXME: switch based on action type
|
||||||
|
Loading…
Reference in New Issue
Block a user