]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - classes/Group_member.php
add URI members to social activity classes
[quix0rs-gnu-social.git] / classes / Group_member.php
index 5385e0f4874133d4ad2da47c798cac374204dce3..a553af3475a4fc7aa59b7b3d29b289bb760692d4 100644 (file)
@@ -12,6 +12,7 @@ class Group_member extends Memcached_DataObject
     public $group_id;                        // int(4)  primary_key not_null
     public $profile_id;                      // int(4)  primary_key not_null
     public $is_admin;                        // tinyint(1)
+    public $uri;                             // varchar(255)
     public $created;                         // datetime()   not_null
     public $modified;                        // timestamp()   not_null default_CURRENT_TIMESTAMP
 
@@ -43,6 +44,7 @@ class Group_member extends Memcached_DataObject
         $member->group_id   = $group_id;
         $member->profile_id = $profile_id;
         $member->created    = common_sql_now();
+        $member->uri        = self::newURI($profile_id, $group_id, $member->created);
 
         $result = $member->insert();
 
@@ -134,10 +136,7 @@ class Group_member extends Memcached_DataObject
 
         $act = new Activity();
 
-        $act->id = TagURI::mint('join:%d:%d:%s',
-                                $member->id,
-                                $group->id,
-                                common_date_iso8601($this->created));
+        $act->id = $this->getURI();
 
         $act->actor     = ActivityObject::fromProfile($member);
         $act->verb      = ActivityVerb::JOIN;
@@ -171,4 +170,21 @@ class Group_member extends Memcached_DataObject
     {
         mail_notify_group_join($this->getGroup(), $this->getMember());
     }
+
+    function getURI()
+    {
+        if (!empty($this->uri)) {
+            return $this->uri;
+        } else {
+            return self::newURI($this->member_id, $this->group_id, $this->created);
+        }
+    }
+
+    static function newURI($member_id, $group_id, $created)
+    {
+        return TagURI::mint('join:%d:%d:%s',
+                            $member_id,
+                            $group_id,
+                            common_date_iso8601($created));
+    }
 }