]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - classes/Notice.php
fixup bad class constant in Notice
[quix0rs-gnu-social.git] / classes / Notice.php
index f7daf708e8eb27438e0011031b72df1ea81af860..adcc25973c5a093b8a24462f0d61bd97181a4945 100644 (file)
@@ -87,12 +87,12 @@ 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'),
                 'uri' => array('type' => 'varchar', 'length' => 255, 'description' => 'universally unique identifier, usually a tag URI'),
-                'content' => array('type' => 'text', 'description' => 'update content'),
+                'content' => array('type' => 'text', 'description' => 'update content', 'collate' => 'utf8_general_ci'),
                 'rendered' => array('type' => 'text', 'description' => 'HTML version of the content'),
                 'url' => array('type' => 'varchar', 'length' => 255, 'description' => 'URL of any attachment (image, video, bookmark, whatever)'),
                 'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
@@ -107,9 +107,9 @@ class Notice extends Managed_DataObject
                 'location_ns' => array('type' => 'int', 'description' => 'namespace for location'),
                 'repeat_of' => array('type' => 'int', 'description' => 'notice this is a repeat of'),
                 '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(
@@ -127,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)
@@ -504,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;
             }
@@ -1584,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;
@@ -2370,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;
         }
 
@@ -2390,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;
@@ -2399,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));
@@ -2411,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
 
@@ -2433,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;
@@ -2623,7 +2634,7 @@ class Notice extends Managed_DataObject
         return $this->_faves;
     }
 
-    function _setFaves(&$faves)
+    function _setFaves($faves)
     {
         $this->_faves = $faves;
     }
@@ -2642,7 +2653,7 @@ class Notice extends Managed_DataObject
         }
         foreach ($notices as $notice) {
                $faves = $faveMap[$notice->id];
-            $notice->_setFaves(&$faves);
+            $notice->_setFaves($faves);
         }
     }
 
@@ -2672,7 +2683,7 @@ class Notice extends Managed_DataObject
         return $this->_repeats;
     }
 
-    function _setRepeats(&$repeats)
+    function _setRepeats($repeats)
     {
         $this->_repeats = $repeats;
     }
@@ -2683,7 +2694,7 @@ class Notice extends Managed_DataObject
         $repeatMap = Memcached_DataObject::listGet('Notice', 'repeat_of', $ids);
         foreach ($notices as $notice) {
                $repeats = $repeatMap[$notice->id];
-            $notice->_setRepeats(&$repeats);
+            $notice->_setRepeats($repeats);
         }
     }
 }