X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=classes%2FUser_group.php;h=0b83cfd47dfe2ee93a97c8ab53d2d3fb5ea94dfe;hb=f7d69c38af60fbc984743d20340bd0fd02fd6d77;hp=7240e27037b32c91a6b6ba37a01e566fbb93b850;hpb=1883da64185022866572f9eb27938b4cc7724328;p=quix0rs-gnu-social.git diff --git a/classes/User_group.php b/classes/User_group.php index 7240e27037..0b83cfd47d 100644 --- a/classes/User_group.php +++ b/classes/User_group.php @@ -91,7 +91,7 @@ class User_group extends Memcached_DataObject return Notice::getStreamByIds($ids); } - function _streamDirect($offset, $limit, $since_id, $max_id, $since) + function _streamDirect($offset, $limit, $since_id, $max_id) { $inbox = new Group_inbox(); @@ -108,10 +108,6 @@ class User_group extends Memcached_DataObject $inbox->whereAdd('notice_id <= ' . $max_id); } - if (!is_null($since)) { - $inbox->whereAdd('created > \'' . date('Y-m-d H:i:s', $since) . '\''); - } - $inbox->orderBy('notice_id DESC'); if (!is_null($offset)) { @@ -158,6 +154,21 @@ class User_group extends Memcached_DataObject return $members; } + function getMemberCount() + { + // XXX: WORM cache this + + $members = $this->getMembers(); + $member_count = 0; + + /** $member->count() doesn't work. */ + while ($members->fetch()) { + $member_count++; + } + + return $member_count; + } + function getAdmins($offset=0, $limit=null) { $qry = @@ -283,12 +294,26 @@ class User_group extends Memcached_DataObject return true; } - static function getForNickname($nickname) + static function getForNickname($nickname, $profile=null) { $nickname = common_canonical_nickname($nickname); - $group = User_group::staticGet('nickname', $nickname); + + // Are there any matching remote groups this profile's in? + if ($profile) { + $group = $profile->getGroups(); + while ($group->fetch()) { + if ($group->nickname == $nickname) { + // @fixme is this the best way? + return clone($group); + } + } + } + + // If not, check local groups. + + $group = Local_group::staticGet('nickname', $nickname); if (!empty($group)) { - return $group; + return User_group::staticGet('id', $group->group_id); } $alias = Group_alias::staticGet('alias', $nickname); if (!empty($alias)) { @@ -361,16 +386,15 @@ class User_group extends Memcached_DataObject if ($source) { $xs->elementStart('source'); + $xs->element('id', null, $this->permalink()); $xs->element('title', null, $profile->nickname . " - " . common_config('site', 'name')); $xs->element('link', array('href' => $this->permalink())); - } - - if ($source) { + $xs->element('updated', null, $this->modified); $xs->elementEnd('source'); } $xs->element('title', null, $this->nickname); - $xs->element('summary', null, $this->description); + $xs->element('summary', null, common_xml_safe_str($this->description)); $xs->element('link', array('rel' => 'alternate', 'href' => $this->permalink())); @@ -380,7 +404,11 @@ class User_group extends Memcached_DataObject $xs->element('published', null, common_date_w3dtf($this->created)); $xs->element('updated', null, common_date_w3dtf($this->modified)); - $xs->element('content', array('type' => 'html'), $this->description); + $xs->element( + 'content', + array('type' => 'html'), + common_xml_safe_str($this->description) + ); $xs->elementEnd('entry'); @@ -446,6 +474,11 @@ class User_group extends Memcached_DataObject $group->query('BEGIN'); + if (empty($uri)) { + // fill in later... + $uri = null; + } + $group->nickname = $nickname; $group->fullname = $fullname; $group->homepage = $homepage; @@ -459,6 +492,7 @@ class User_group extends Memcached_DataObject if (!$result) { common_log_db_error($group, 'INSERT', __FILE__); + // TRANS: Server exception thrown when creating a group failed. throw new ServerException(_('Could not create group.')); } @@ -468,13 +502,15 @@ class User_group extends Memcached_DataObject $result = $group->update($orig); if (!$result) { common_log_db_error($group, 'UPDATE', __FILE__); - throw new ServerException(_('Could not set group uri.')); + // TRANS: Server exception thrown when updating a group URI failed. + throw new ServerException(_('Could not set group URI.')); } } $result = $group->setAliases($aliases); if (!$result) { + // TRANS: Server exception thrown when creating group aliases failed. throw new ServerException(_('Could not create aliases.')); } @@ -489,6 +525,7 @@ class User_group extends Memcached_DataObject if (!$result) { common_log_db_error($member, 'INSERT', __FILE__); + // TRANS: Server exception thrown when setting group membership failed. throw new ServerException(_('Could not set group membership.')); } @@ -503,6 +540,7 @@ class User_group extends Memcached_DataObject if (!$result) { common_log_db_error($local_group, 'INSERT', __FILE__); + // TRANS: Server exception thrown when saving local group information failed. throw new ServerException(_('Could not save local group info.')); } }