]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - classes/Notice.php
Merge branch '1.0.x' of gitorious.org:statusnet/mainline into 1.0.x
[quix0rs-gnu-social.git] / classes / Notice.php
index fd92cfe9e66f837f1e39e67663710de9c230f69b..60958c9e6a25e0557d378a748dec005d1b60d3d6 100644 (file)
@@ -72,6 +72,7 @@ class Notice extends Managed_DataObject
     public $location_id;                     // int(4)
     public $location_ns;                     // int(4)
     public $repeat_of;                       // int(4)
+    public $verb;                            // varchar(255)
     public $object_type;                     // varchar(255)
     public $scope;                           // int(4)
 
@@ -91,7 +92,7 @@ class Notice extends Managed_DataObject
                 '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'),
@@ -106,6 +107,7 @@ 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'),
@@ -313,6 +315,7 @@ class Notice extends Managed_DataObject
      *                           notice in place of extracting links from content
      *              boolean 'distribute' whether to distribute the notice, default true
      *              string 'object_type' URL of the associated object type (default ActivityObject::NOTE)
+     *              string 'verb' URL of the associated verb (default ActivityVerb::POST)
      *              int 'scope' Scope bitmask; default to SITE_SCOPE on private sites, 0 otherwise
      *
      * @fixme tag override
@@ -326,7 +329,9 @@ class Notice extends Managed_DataObject
                           'reply_to' => null,
                           'repeat_of' => null,
                           'scope' => null,
-                          'distribute' => true);
+                          'distribute' => true,
+                          'object_type' => null,
+                          'verb' => null);
 
         if (!empty($options) && is_array($options)) {
             $options = array_merge($defaults, $options);
@@ -497,6 +502,17 @@ class Notice extends Managed_DataObject
             $notice->rendered = common_render_content($final, $notice);
         }
 
+        if (empty($verb)) {
+            if (!empty($notice->repeat_of)) {
+                $notice->verb        = ActivityVerb::SHARE;
+                $notice->object_type = ActivityVerb::ACTIVITY;
+            } else {
+                $notice->verb        = ActivityVerb::POST;
+            }
+        } else {
+            $notice->verb = $verb;
+        }
+
         if (empty($object_type)) {
             $notice->object_type = (empty($notice->reply_to)) ? ActivityObject::NOTE : ActivityObject::COMMENT;
         } else {
@@ -1493,18 +1509,13 @@ class Notice extends Managed_DataObject
             $act->actor            = ActivityObject::fromProfile($profile);
             $act->actor->extra[]   = $profile->profileInfo($cur);
 
-            if ($this->repeat_of) {
+            $act->verb = $this->verb;
 
+            if ($this->repeat_of) {
                 $repeated = Notice::staticGet('id', $this->repeat_of);
-
-                $act->verb             = ActivityVerb::SHARE;
-                $act->objects[]        = $repeated->asActivity($cur);
-
+                $act->objects[] = $repeated->asActivity($cur);
             } else {
-
-                $act->verb             = ActivityVerb::POST;
-                $act->objects[]        = ActivityObject::fromNotice($this);
-
+                $act->objects[] = ActivityObject::fromNotice($this);
             }
 
             // XXX: should this be handled by default processing for object entry?
@@ -2613,7 +2624,7 @@ class Notice extends Managed_DataObject
         return $this->_faves;
     }
 
-    function _setFaves(&$faves)
+    function _setFaves($faves)
     {
         $this->_faves = $faves;
     }
@@ -2632,7 +2643,7 @@ class Notice extends Managed_DataObject
         }
         foreach ($notices as $notice) {
                $faves = $faveMap[$notice->id];
-            $notice->_setFaves(&$faves);
+            $notice->_setFaves($faves);
         }
     }
 
@@ -2662,7 +2673,7 @@ class Notice extends Managed_DataObject
         return $this->_repeats;
     }
 
-    function _setRepeats(&$repeats)
+    function _setRepeats($repeats)
     {
         $this->_repeats = $repeats;
     }
@@ -2673,7 +2684,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);
         }
     }
 }