function initGroupMemberURI() { printfnq("Ensuring all group memberships have a URI..."); $mem = new Group_member(); $mem->whereAdd('uri IS NULL'); if ($mem->find()) { while ($mem->fetch()) { try { $mem->decache(); $mem->query(sprintf('update group_member set uri = "%s" ' . 'where profile_id = %d ' . 'and group_id = %d ', Group_member::newURI($mem->profile_id, $mem->group_id, $mem->created), $mem->profile_id, $mem->group_id)); } catch (Exception $e) { common_log(LOG_ERR, "Error updated membership URI: " . $e->getMessage()); } } } printfnq("DONE.\n"); }
function getGroups() { $groups = array(); $gm = new Group_member(); $gm->profile_id = $this->user->id; if (!empty($this->after)) { $gm->whereAdd("created > '" . common_sql_date($this->after) . "'"); } if ($gm->find()) { while ($gm->fetch()) { $groups[] = clone $gm; } } return $groups; }
function getGroups($offset = 0, $limit = PROFILES_PER_PAGE) { $ids = array(); $keypart = sprintf('profile:groups:%d', $this->id); $idstring = self::cacheGet($keypart); if ($idstring !== false) { $ids = explode(',', $idstring); } else { $gm = new Group_member(); $gm->profile_id = $this->id; if ($gm->find()) { while ($gm->fetch()) { $ids[] = $gm->group_id; } } self::cacheSet($keypart, implode(',', $ids)); } if (!is_null($offset) && !is_null($limit)) { $ids = array_slice($ids, $offset, $limit); } try { return User_group::multiGet('id', $ids); } catch (NoResultException $e) { return null; // throw exception when we handle it everywhere } }
function getGroups($offset = 0, $limit = PROFILES_PER_PAGE) { $ids = array(); $keypart = sprintf('profile:groups:%d', $this->id); $idstring = self::cacheGet($keypart); if ($idstring !== false) { $ids = explode(',', $idstring); } else { $gm = new Group_member(); $gm->profile_id = $this->id; //harrie //$gm->is_admin = '1'; //echo '<pre>'; //var_dump($gm); //exit('111'); if ($gm->find()) { while ($gm->fetch()) { $ids[] = $gm->group_id; } } self::cacheSet($keypart, implode(',', $ids)); } $groups = array(); foreach ($ids as $id) { $group = User_group::staticGet('id', $id); if (!empty($group)) { $groups[] = $group; } } return new ArrayWrapper($groups); }
function getGroups() { $groups = array(); $gm = new Group_member(); $gm->profile_id = $this->user->id; if ($gm->find()) { while ($gm->fetch()) { $groups[] = clone $gm; } } return $groups; }
function getMemberIDs($offset = 0, $limit = null) { $gm = new Group_member(); $gm->selectAdd(); $gm->selectAdd('profile_id'); $gm->group_id = $this->id; $gm->orderBy('created DESC'); if (!is_null($limit)) { $gm->limit($offset, $limit); } $ids = array(); if ($gm->find()) { while ($gm->fetch()) { $ids[] = $gm->profile_id; } } return $ids; }
function blowGroupCache($blowLast = false) { $cache = common_memcache(); if ($cache) { $group_inbox = new Group_inbox(); $group_inbox->notice_id = $this->id; if ($group_inbox->find()) { while ($group_inbox->fetch()) { $cache->delete(common_cache_key('group:notices:' . $group_inbox->group_id)); if ($blowLast) { $cache->delete(common_cache_key('group:notices:' . $group_inbox->group_id . ';last')); } $member = new Group_member(); $member->group_id = $group_inbox->group_id; if ($member->find()) { while ($member->fetch()) { $cache->delete(common_cache_key('user:notices_with_friends:' . $member->profile_id)); if ($blowLast) { $cache->delete(common_cache_key('user:notices_with_friends:' . $member->profile_id . ';last')); } } } } } $group_inbox->free(); unset($group_inbox); } }