X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=classes%2FGroup_member.php;h=3abb7681e8e5517d67a00693b90ce85f8fe45203;hb=refs%2Fheads%2Fupstream-changes%2Fgoogle-analytics-removal;hp=390651e9019ab9f78a962c5bc23c6930fa74bf16;hpb=1a9a8ea73032b0ded09a8ea9a4c0511401507090;p=quix0rs-gnu-social.git diff --git a/classes/Group_member.php b/classes/Group_member.php index 390651e901..3abb7681e8 100644 --- a/classes/Group_member.php +++ b/classes/Group_member.php @@ -12,7 +12,7 @@ class Group_member extends Managed_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 $uri; // varchar(191) not 255 because utf8mb4 takes more space public $created; // datetime() not_null public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP @@ -26,7 +26,7 @@ class Group_member extends Managed_DataObject 'group_id' => array('type' => 'int', 'not null' => true, 'description' => 'foreign key to user_group'), 'profile_id' => array('type' => 'int', 'not null' => true, 'description' => 'foreign key to profile table'), 'is_admin' => array('type' => 'int', 'size' => 'tiny', 'default' => 0, 'description' => 'is this user an admin?'), - 'uri' => array('type' => 'varchar', 'length' => 255, 'description' => 'universal identifier'), + 'uri' => array('type' => 'varchar', 'length' => 191, 'description' => 'universal identifier'), 'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'), 'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'), ), @@ -48,11 +48,6 @@ class Group_member extends Managed_DataObject ); } - 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. @@ -70,7 +65,9 @@ class Group_member extends Managed_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); + $member->uri = self::newUri(Profile::getByID($profile_id), + User_group::getByID($group_id), + $member->created); $result = $member->insert(); @@ -106,7 +103,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. @@ -119,7 +116,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. @@ -171,9 +168,9 @@ class Group_member extends Managed_DataObject $act = new Activity(); - $act->id = $this->getURI(); + $act->id = $this->getUri(); - $act->actor = ActivityObject::fromProfile($member); + $act->actor = $member->asActivityObject(); $act->verb = ActivityVerb::JOIN; $act->objects[] = ActivityObject::fromGroup($group); @@ -206,20 +203,8 @@ class Group_member extends Managed_DataObject mail_notify_group_join($this->getGroup(), $this->getMember()); } - function getURI() - { - if (!empty($this->uri)) { - return $this->uri; - } else { - return self::newURI($this->profile_id, $this->group_id, $this->created); - } - } - - static function newURI($profile_id, $group_id, $created) + function getUri() { - return TagURI::mint('join:%d:%d:%s', - $profile_id, - $group_id, - common_date_iso8601($created)); + return $this->uri ?: self::newUri($this->getMember(), $this->getGroup()->getProfile(), $this->created); } }