]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - classes/Notice.php
bookmarklet is now part of Bookmark plugin
[quix0rs-gnu-social.git] / classes / Notice.php
index 60958c9e6a25e0557d378a748dec005d1b60d3d6..adcc25973c5a093b8a24462f0d61bd97181a4945 100644 (file)
@@ -87,7 +87,7 @@ class Notice extends Managed_DataObject
 
     public static function schemaDef()
     {
-        return array(
+        $def = array(
             'fields' => array(
                 'id' => array('type' => 'serial', 'not null' => true, 'description' => 'unique identifier'),
                 'profile_id' => array('type' => 'int', 'not null' => true, 'description' => 'who made the update'),
@@ -109,8 +109,7 @@ class Notice extends Managed_DataObject
                 'object_type' => array('type' => 'varchar', 'length' => 255, 'description' => 'URI representing activity streams object type', 'default' => 'http://activitystrea.ms/schema/1.0/note'),
                 'verb' => array('type' => 'varchar', 'length' => 255, 'description' => 'URI representing activity streams verb', 'default' => 'http://activitystrea.ms/schema/1.0/post'),
                 'scope' => array('type' => 'int',
-                                 'default' => '1',
-                                 'description' => 'bit map for distribution scope; 0 = everywhere; 1 = this server only; 2 = addressees; 4 = followers'),
+                                 'description' => 'bit map for distribution scope; 0 = everywhere; 1 = this server only; 2 = addressees; 4 = followers; null = default'),
             ),
             'primary key' => array('id'),
             'unique keys' => array(
@@ -128,11 +127,14 @@ class Notice extends Managed_DataObject
                 'notice_created_idx' => array('created'),
                 'notice_replyto_idx' => array('reply_to'),
                 'notice_repeatof_idx' => array('repeat_of'),
-            ),
-            'fulltext indexes' => array(
-                'content' => array('content'),
             )
         );
+
+        if (common_config('search', 'type') == 'fulltext') {
+            $def['fulltext indexes'] = array('content' => array('content'));
+        }
+
+        return $def;
     }
     
        function multiGet($kc, $kvs, $skipNulls=true)
@@ -505,7 +507,7 @@ class Notice extends Managed_DataObject
         if (empty($verb)) {
             if (!empty($notice->repeat_of)) {
                 $notice->verb        = ActivityVerb::SHARE;
-                $notice->object_type = ActivityVerb::ACTIVITY;
+                $notice->object_type = ActivityObject::ACTIVITY;
             } else {
                 $notice->verb        = ActivityVerb::POST;
             }
@@ -1585,8 +1587,10 @@ class Notice extends Managed_DataObject
 
             if (!empty($this->repeat_of)) {
                 $repeat = Notice::staticGet('id', $this->repeat_of);
-                $ctx->forwardID  = $repeat->uri;
-                $ctx->forwardUrl = $repeat->bestUrl();
+                if (!empty($repeat)) {
+                    $ctx->forwardID  = $repeat->uri;
+                    $ctx->forwardUrl = $repeat->bestUrl();
+                }
             }
 
             $act->context = $ctx;
@@ -2371,9 +2375,15 @@ class Notice extends Managed_DataObject
 
     protected function _inScope($profile)
     {
+        if (!is_null($this->scope)) {
+            $scope = $this->scope;
+        } else {
+            $scope = self::defaultScope();
+        }
+
         // If there's no scope, anyone (even anon) is in scope.
 
-        if ($this->scope == 0) {
+        if ($scope == 0) {
             return true;
         }
 
@@ -2391,7 +2401,7 @@ class Notice extends Managed_DataObject
 
         // Only for users on this site
 
-        if ($this->scope & Notice::SITE_SCOPE) {
+        if ($scope & Notice::SITE_SCOPE) {
             $user = $profile->getUser();
             if (empty($user)) {
                 return false;
@@ -2400,7 +2410,7 @@ class Notice extends Managed_DataObject
 
         // Only for users mentioned in the notice
 
-        if ($this->scope & Notice::ADDRESSEE_SCOPE) {
+        if ($scope & Notice::ADDRESSEE_SCOPE) {
 
                        $repl = Reply::pkeyGet(array('notice_id' => $this->id,
                                                                                 'profile_id' => $profile->id));
@@ -2412,7 +2422,7 @@ class Notice extends Managed_DataObject
 
         // Only for members of the given group
 
-        if ($this->scope & Notice::GROUP_SCOPE) {
+        if ($scope & Notice::GROUP_SCOPE) {
 
             // XXX: just query for the single membership
 
@@ -2434,7 +2444,7 @@ class Notice extends Managed_DataObject
 
         // Only for followers of the author
 
-        if ($this->scope & Notice::FOLLOWER_SCOPE) {
+        if ($scope & Notice::FOLLOWER_SCOPE) {
             $author = $this->getProfile();
             if (!Subscription::exists($profile, $author)) {
                 return false;