Merge branch 'mods_can_delete_others_notices_branch' into 'nightly'

moderators can delete others' notices using the api



See merge request !112
This commit is contained in:
mmn 2016-02-28 18:19:11 +00:00
commit 065f707bd7

View File

@ -69,6 +69,7 @@ class ApiStatusesDestroyAction extends ApiAuthAction
parent::prepare($args); parent::prepare($args);
$this->user = $this->auth_user; $this->user = $this->auth_user;
$this->profile = $this->auth_user->getProfile();
$this->notice_id = (int)$this->trimmed('id'); $this->notice_id = (int)$this->trimmed('id');
if (empty($notice_id)) { if (empty($notice_id)) {
@ -122,7 +123,7 @@ class ApiStatusesDestroyAction extends ApiAuthAction
return; return;
} }
if ($this->user->id == $this->notice->profile_id) { if ($this->user->id == $this->notice->profile_id || $this->profile->hasRight(Right::DELETEOTHERSNOTICE)) {
if (Event::handle('StartDeleteOwnNotice', array($this->user, $this->notice))) { if (Event::handle('StartDeleteOwnNotice', array($this->user, $this->notice))) {
$this->notice->deleteAs($this->scoped); $this->notice->deleteAs($this->scoped);
Event::handle('EndDeleteOwnNotice', array($this->user, $this->notice)); Event::handle('EndDeleteOwnNotice', array($this->user, $this->notice));