X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=plugins%2FGroupPrivateMessage%2FGroup_message.php;h=05fcdc5c43aa56cb8b7862a4ad79831f7b941fb6;hb=2a4dc77a633cc78907934fd93200ac16d55be78e;hp=f8c0c707c3f97e17782df24dc81f0c74e5788a81;hpb=061c8d959ba8351b145a27690d5a4caa477915ca;p=quix0rs-gnu-social.git diff --git a/plugins/GroupPrivateMessage/Group_message.php b/plugins/GroupPrivateMessage/Group_message.php index f8c0c707c3..05fcdc5c43 100644 --- a/plugins/GroupPrivateMessage/Group_message.php +++ b/plugins/GroupPrivateMessage/Group_message.php @@ -44,8 +44,7 @@ require_once INSTALLDIR . '/classes/Memcached_DataObject.php'; * * @see DB_DataObject */ - -class Group_message extends Memcached_DataObject +class Group_message extends Managed_DataObject { public $__table = 'group_message'; // table name public $id; // char(36) primary_key not_null @@ -57,22 +56,6 @@ class Group_message extends Memcached_DataObject public $url; public $created; - /** - * Get an instance by key - * - * This is a utility method to get a single instance with a given key value. - * - * @param string $k Key to use to lookup (usually 'user_id' for this class) - * @param mixed $v Value to lookup - * - * @return Group_message object found, or null for no hits - * - */ - function staticGet($k, $v=null) - { - return Memcached_DataObject::staticGet('Group_message', $k, $v); - } - /** * return table definition for DB_DataObject * @@ -123,7 +106,9 @@ class Group_message extends Memcached_DataObject { if (!$user->hasRight(Right::NEWMESSAGE)) { // XXX: maybe break this out into a separate right - throw new Exception(sprintf(_('User %s not allowed to send private messages.'), + // TRANS: Exception thrown when trying to send group private message without having the right to do that. + // TRANS: %s is a user nickname. + throw new Exception(sprintf(_m('User %s is not allowed to send private messages.'), $user->nickname)); } @@ -134,6 +119,8 @@ class Group_message extends Memcached_DataObject // We use the same limits as for 'regular' private messages. if (Message::contentTooLong($text)) { + // TRANS: Exception thrown when trying to send group private message that is too long. + // TRANS: %d is the maximum meggage length. throw new Exception(sprintf(_m('That\'s too long. Maximum message size is %d character.', 'That\'s too long. Maximum message size is %d characters.', Message::maxContent()), @@ -143,7 +130,7 @@ class Group_message extends Memcached_DataObject // Valid! Let's do this thing! $gm = new Group_message(); - + $gm->id = UUID::gen(); $gm->uri = common_local_url('showgroupmessage', array('id' => $gm->id)); $gm->from_profile = $user->id; @@ -164,8 +151,8 @@ class Group_message extends Memcached_DataObject function distribute() { - $group = User_group::staticGet('id', $this->to_group); - + $group = User_group::getKV('id', $this->to_group); + $member = $group->getMembers(); while ($member->fetch()) { @@ -175,18 +162,20 @@ class Group_message extends Memcached_DataObject function getGroup() { - $group = User_group::staticGet('id', $this->to_group); + $group = User_group::getKV('id', $this->to_group); if (empty($group)) { - throw new ServerException(_('No group for group message')); + // TRANS: Exception thrown when trying to send group private message to a non-existing group. + throw new ServerException(_m('No group for group message.')); } return $group; } function getSender() { - $sender = Profile::staticGet('id', $this->from_profile); + $sender = Profile::getKV('id', $this->from_profile); if (empty($sender)) { - throw new ServerException(_('No sender for group message')); + // TRANS: Exception thrown when trying to send group private message without having a sender. + throw new ServerException(_m('No sender for group message.')); } return $sender; } @@ -204,5 +193,4 @@ class Group_message extends Memcached_DataObject return $gm; } - }