]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Prepare for ActivityModerationPlugin
authorMikael Nordfeldth <mmn@hethane.se>
Thu, 10 Sep 2015 13:55:37 +0000 (15:55 +0200)
committerMikael Nordfeldth <mmn@hethane.se>
Thu, 10 Sep 2015 13:55:37 +0000 (15:55 +0200)
classes/Deleted_notice.php
classes/Notice.php
lib/activityverb.php

index a9167f19a48ee2c5069123567562dfcc13d1e70f..23bbea1bab4525279740bdd6b679e31c23f68352 100644 (file)
  * along with this program.     If not, see <http://www.gnu.org/licenses/>.
  */
 
-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(
index 0d0933115e74615ac24f73ccfec7fe79592b2719..41c4544cf2fc69efc5ce84c43fbbea11729b2f5a 100644 (file)
@@ -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
index dc6f9c93f4719b50b733c021ff1b83ed08613084..187962d617e6f442bee041fb60258a5390ff8ac4 100644 (file)
@@ -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';