]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - classes/Group_member.php
Merge branch 'master' into social-master
[quix0rs-gnu-social.git] / classes / Group_member.php
index 2ad6589a3c555313e35364e32d070f7888928477..14f417758da21890fecf21a944cdc77891c3beb8 100644 (file)
@@ -16,9 +16,6 @@ class Group_member extends Managed_DataObject
     public $created;                         // datetime()   not_null
     public $modified;                        // timestamp()   not_null default_CURRENT_TIMESTAMP
 
-    /* Static get */
-    function staticGet($k,$v=NULL) { return Memcached_DataObject::staticGet('Group_member',$k,$v); }
-
     /* the code above is auto generated do not remove the tag below */
     ###END_AUTOCODE
 
@@ -45,15 +42,12 @@ class Group_member extends Managed_DataObject
                 // @fixme probably we want a (profile_id, created) index here?
                 'group_member_profile_id_idx' => array('profile_id'),
                 'group_member_created_idx' => array('created'),
+                'group_member_profile_id_created_idx' => array('profile_id', 'created'),
+                'group_member_group_id_created_idx' => array('group_id', 'created'),
             ),
         );
     }
 
-    function pkeyGet($kv)
-    {
-        return Memcached_DataObject::pkeyGet('Group_member', $kv);
-    }
-
     /**
      * Method to add a user to a group.
      * In most cases, you should call Profile->joinGroup() instead.
@@ -107,7 +101,7 @@ class Group_member extends Managed_DataObject
 
     function getMember()
     {
-        $member = Profile::staticGet('id', $this->profile_id);
+        $member = Profile::getKV('id', $this->profile_id);
 
         if (empty($member)) {
             // TRANS: Exception thrown providing an invalid profile ID.
@@ -120,7 +114,7 @@ class Group_member extends Managed_DataObject
 
     function getGroup()
     {
-        $group  = User_group::staticGet('id', $this->group_id);
+        $group  = User_group::getKV('id', $this->group_id);
 
         if (empty($group)) {
             // TRANS: Exception thrown providing an invalid group ID.
@@ -159,13 +153,22 @@ class Group_member extends Managed_DataObject
     function asActivity()
     {
         $member = $this->getMember();
+
+        if (!$member) {
+            throw new Exception("No such member: " . $this->profile_id);
+        }
+
         $group  = $this->getGroup();
 
+        if (!$group) {
+            throw new Exception("No such group: " . $this->group_id);
+        }
+
         $act = new Activity();
 
         $act->id = $this->getURI();
 
-        $act->actor     = ActivityObject::fromProfile($member);
+        $act->actor     = $member->asActivityObject();
         $act->verb      = ActivityVerb::JOIN;
         $act->objects[] = ActivityObject::fromGroup($group);
 
@@ -203,14 +206,14 @@ class Group_member extends Managed_DataObject
         if (!empty($this->uri)) {
             return $this->uri;
         } else {
-            return self::newURI($this->member_id, $this->group_id, $this->created);
+            return self::newURI($this->profile_id, $this->group_id, $this->created);
         }
     }
 
-    static function newURI($member_id, $group_id, $created)
+    static function newURI($profile_id, $group_id, $created)
     {
         return TagURI::mint('join:%d:%d:%s',
-                            $member_id,
+                            $profile_id,
                             $group_id,
                             common_date_iso8601($created));
     }