From 604ed1fd9a25825aff16a0e7f63279c069881eaa Mon Sep 17 00:00:00 2001 From: Mikael Nordfeldth Date: Thu, 10 Sep 2015 15:55:37 +0200 Subject: [PATCH] Prepare for ActivityModerationPlugin --- classes/Deleted_notice.php | 15 +++------------ classes/Notice.php | 8 ++++++++ lib/activityverb.php | 2 +- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/classes/Deleted_notice.php b/classes/Deleted_notice.php index a9167f19a4..23bbea1bab 100644 --- a/classes/Deleted_notice.php +++ b/classes/Deleted_notice.php @@ -17,30 +17,21 @@ * along with this program. If not, see . */ -if (!defined('STATUSNET')) { - exit(1); -} +if (!defined('GNUSOCIAL')) { exit(1); } /** - * Table Definition for notice + * Table Definition for deleted_notice */ -require_once INSTALLDIR.'/classes/Memcached_DataObject.php'; class Deleted_notice extends Managed_DataObject { - ###START_AUTOCODE - /* the code below is auto generated do not remove the above tag */ - - public $__table = 'deleted_notice'; // table name + public $__table = 'deleted_notice'; // table name public $id; // int(4) primary_key not_null public $profile_id; // int(4) not_null public $uri; // varchar(191) unique_key not 255 because utf8mb4 takes more space public $created; // datetime() not_null public $deleted; // datetime() not_null - /* the code above is auto generated do not remove the tag below */ - ###END_AUTOCODE - public static function schemaDef() { return array( diff --git a/classes/Notice.php b/classes/Notice.php index 0d0933115e..41c4544cf2 100644 --- a/classes/Notice.php +++ b/classes/Notice.php @@ -158,6 +158,14 @@ class Notice extends Managed_DataObject $this->_profile[$this->profile_id] = $profile; } + public function deleteAs(Profile $actor) + { + if ($this->getProfile()->sameAs($actor) || $actor->hasRight(Right::DELETEOTHERSNOTICE)) { + return $this->delete(); + } + throw new AuthorizationException('You are not allowed to delete other user\'s notices'); + } + function delete($useWhere=false) { // For auditing purposes, save a record that the notice diff --git a/lib/activityverb.php b/lib/activityverb.php index dc6f9c93f4..187962d617 100644 --- a/lib/activityverb.php +++ b/lib/activityverb.php @@ -54,9 +54,9 @@ class ActivityVerb const FRIEND = 'http://activitystrea.ms/schema/1.0/make-friend'; const JOIN = 'http://activitystrea.ms/schema/1.0/join'; const TAG = 'http://activitystrea.ms/schema/1.0/tag'; + const DELETE = 'delete'; // the url part is not used anymore, and this feature is new enough to avoid problems with legacy nodes if used without http://... // Custom OStatus verbs for the flipside until they're standardized - const DELETE = 'http://ostatus.org/schema/1.0/unfollow'; const UNFAVORITE = 'http://activitystrea.ms/schema/1.0/unfavorite'; const UNLIKE = 'http://activitystrea.ms/schema/1.0/unlike'; // This is a synonym of unfavorite const UNFOLLOW = 'http://ostatus.org/schema/1.0/unfollow'; -- 2.39.2