public function updatePersonData($id, $key, $value, $token) { if (!BasicDataService::isValidKey($key)) { return new ResponseItem(BAD_REQUEST, "The person data key had invalid characters", null); } XmlStateFileFetcher::get()->setAppData($id, $key, $value); return new ResponseItem(null, null, array()); }
public function createActivity($personId, $activity, $token) { // TODO: Validate the activity and do any template expanding $activity->setUserId($personId); $activity->setPostedTime(time()); XmlStateFileFetcher::get()->createActivity($personId, $activity); return new ResponseItem(null, null, array()); }
public function updatePersonData(UserID $userId, GroupId $groupId, $fields, $values, $appId, SecurityToken $token) { foreach ($fields as $key) { if (!BasicAppDataService::isValidKey($key)) { return new ResponseItem(BAD_REQUEST, "The person app data key had invalid characters", null); } } switch ($groupId->getType()) { case 'self': foreach ($fields as $key) { $value = isset($values[$key]) ? @$values[$key] : null; XmlStateFileFetcher::get()->setAppData($userId->getUserId($token), $key, $value); } break; default: return new ResponseItem(NOT_IMPLEMENTED, "We don't support updating data in batches yet", null); break; } return new ResponseItem(null, null, array()); }
public function getIds($idSpec, $token) { error_log("getIds call for {$idSpec} api_key=" . $token->getAppId() . " owner=" . $token->getOwnerId()); $friendIds = XmlStateFileFetcher::get()->getFriendIds(); $ids = array(); switch ($idSpec->getType()) { case 'OWNER': $ids[] = $token->getOwnerId(); break; case 'VIEWER': $ids[] = $token->getViewerId(); break; case 'OWNER_FRIENDS': $ids = $friendIds[$token->getOwnerId()]; break; case 'VIEWER_FRIENDS': $ids = $friendIds[$token->getViewerId()]; break; case 'USER_IDS': $ids = $idSpec->fetchUserIds(); break; } return $ids; }
public function createActivity(UserId $userId, $activity, SecurityToken $token) { // TODO: Validate the activity and do any template expanding XmlStateFileFetcher::get()->createActivity($userId->getUserId($token), $activity, $token->getAppId()); return new ResponseItem(null, null, array()); }
public function getPeople($userId, $groupId, $sortOrder, $filter, $first, $max, $profileDetails, $networkDistance, SecurityToken $token) { $ids = array(); $group = is_object($groupId) ? $groupId->getType() : ''; switch ($group) { case 'all': case 'friends': $friendIds = XmlStateFileFetcher::get()->getFriendIds(); if (is_array($friendIds) && count($friendIds) && isset($friendIds[$userId->getUserId($token)])) { $ids = $friendIds[$userId->getUserId($token)]; } break; case 'self': default: $ids[] = $userId->getUserId($token); break; } $allPeople = XmlStateFileFetcher::get()->getAllPeople(); if (!$token->isAnonymous() && $filter == "hasApp") { $appId = $token->getAppId(); $peopleWithApp = XmlStateFileFetcher::get()->getPeopleWithApp($appId); } $people = array(); foreach ($ids as $id) { if ($filter == "hasApp" && !in_array($id, $peopleWithApp)) { continue; } $person = null; if (is_array($allPeople) && isset($allPeople[$id])) { $person = $allPeople[$id]; if (!$token->isAnonymous() && $id == $token->getViewerId()) { $person->setIsViewer(true); } if (!$token->isAnonymous() && $id == $token->getOwnerId()) { $person->setIsOwner(true); } if (is_array($profileDetails) && count($profileDetails) && !in_array('all', $profileDetails)) { $newPerson = array(); $newPerson['isOwner'] = $person->isOwner; $newPerson['isViewer'] = $person->isViewer; $newPerson['name'] = $person->name; foreach ($profileDetails as $field) { if (isset($person->{$field}) && !isset($newPerson[$field])) { $newPerson[$field] = $person->{$field}; } } $person = $newPerson; } $people[] = $person; } } if ($sortOrder == 'name') { usort($people, array($this, 'comparator')); } //TODO: The samplecontainer doesn't support any filters yet. We should fix this. $totalSize = count($people); $last = $first + $max; $last = min($last, $totalSize); if ($first !== false && $first != null && $last) { $people = array_slice($people, $first, $last); } $collection = new RestfulCollection($people, $first, $totalSize); return new ResponseItem(null, null, $collection); }