protected function atompubPrepare() { $this->_profile = Profile::getKV('id', $this->trimmed('profile')); if (!$this->_profile instanceof Profile) { // TRANS: Client exception. throw new ClientException(_('No such profile.'), 404); } $this->_memberships = Group_member::byMember($this->_profile->id, $this->offset, $this->limit); return true; }
/** * For initializing members of the class. * * @param array $argarray misc. arguments * * @return boolean true */ function prepare($argarray) { parent::prepare($argarray); $profileId = $this->trimmed('profile'); $this->_profile = Profile::staticGet('id', $profileId); if (empty($this->_profile)) { // TRANS: Client exception. throw new ClientException(_('No such profile.'), 404); } $offset = ($this->page - 1) * $this->count; $limit = $this->count + 1; $this->_memberships = Group_member::byMember($this->_profile->id, $offset, $limit); return true; }
function dumpGroups($user, $dir) { common_log(LOG_INFO, 'dumping memberships of ' . $user->nickname . ' to directory ' . $dir); $page = 1; do { $mem = Group_member::byMember($user->id, ($page - 1) * GROUPS_PER_PAGE, GROUPS_PER_PAGE + 1); while ($mem->fetch()) { try { $fname = $dir . '/' . common_date_iso8601($mem->created) . '-membership-' . $mem->group_id . '.atom'; $act = $mem->asActivity(); $data = $act->asString(false, false, false); common_log(LOG_INFO, 'dumping membership in ' . $mem->group_id . ' to file ' . $fname); file_put_contents($fname, $data); $data = null; } catch (Exception $e) { common_log(LOG_ERR, "Error backing up membership in " . $mem->group_id . ": " . $e->getMessage()); continue; } } $page++; } while ($mem->N > GROUPS_PER_PAGE); }