public function getPersonData(UserId $userId, GroupId $groupId, $fields, $appId, SecurityToken $token) { $allData = XmlStateFileFetcher::get()->getAppData(); $data = array(); $ids = array(); switch ($groupId->getType()) { case 'self': $ids[] = $userId->getUserId($token); break; 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; default: return new ResponseItem(NOT_IMPLEMENTED, "We don't support fetching data in batches yet", null); break; } foreach ($ids as $id) { if (isset($allData[$id])) { $allPersonData = $allData[$id]; $personData = array(); foreach (array_keys($allPersonData) as $key) { if (in_array($key, $fields) || $fields[0] == "*") { $personData[$key] = $allPersonData[$key]; } } $data[$id] = $personData; } } return new ResponseItem(null, null, RestFulCollection::createFromEntry($data)); }
public function getLogged(PDO $db, $cookie) { $user = new User(); $usermapper = new UserMapper($db); $userid = new UserId(); $user_id = $userid->Logged($user, $usermapper, $cookie); return $user_id; }
/** * @param UserId $userId * @return bool */ public function equals(UserId $userId) { if ($this->value === $userId->getValue()) { return true; } else { return false; } }
public function getPersonData(UserId $userId, GroupId $groupId, $fields, $appId, SecurityToken $token) { $ids = array(); switch ($groupId->getType()) { case 'self': $ids[] = $userId->getUserId($token); break; case 'all': case 'friends': $friendIds = espritDBFetcher::get()->getFriendIds($userId->getUserId($token)); if (is_array($friendIds) && count($friendIds)) { $ids = $friendIds; } break; default: return new ResponseItem(NOT_IMPLEMENTED, "We don't support fetching data in batches yet", null); break; } $data = espritDBFetcher::get()->getAppData($ids, $fields, $appId); return new ResponseItem(null, null, RestFulCollection::createFromEntry($data)); }
public function updatePersonData(UserId $userId, GroupId $groupId, $appId, $fields, $values, SecurityToken $token) { if ($userId->getUserId($token) == null) { throw new SocialSpiException("Unknown person id.", ResponseError::$NOT_FOUND); } foreach ($fields as $key) { if (!self::isValidKey($key)) { throw new SocialSpiException("The person app data key had invalid characters", ResponseError::$BAD_REQUEST); } } switch ($groupId->getType()) { case 'self': foreach ($fields as $key) { $value = isset($values[$key]) ? $values[$key] : null; if (!ATutorDbFetcher::get()->setAppData($userId->getUserId($token), $key, $value, $token->getAppId())) { throw new SocialSpiException("Internal server error", ResponseError::$INTERNAL_ERROR); } } break; default: throw new SocialSpiException("We don't support updating data in batches yet", ResponseError::$NOT_IMPLEMENTED); break; } }
public function getUsers() { $ids = $this->getListParameter(self::$USER_ID); if (empty($ids)) { if ($this->token->getViewerId() != null) { // Assume @me $ids = array("@me"); } else { throw new IllegalArgumentException("No userId provided and viewer not available"); } } $userIds = array(); foreach ($ids as $id) { $userIds[] = UserId::fromJson($id); } return $userIds; }
public function updatePersonData(UserId $userId, GroupId $groupId, $appId, $fields, $values, SecurityToken $token) { $db = $this->getDb(); foreach ($fields as $key => $present) { if (!$this->isValidKey($present)) { throw new SocialSpiException("The person app data key had invalid characters", ResponseError::$BAD_REQUEST); } } $allData = $this->getAllData(); $tmpUserId = $userId->getUserId($token); $person = isset($allData[$tmpUserId]) ? $allData[$tmpUserId] : array(); switch ($groupId->getType()) { case 'self': foreach ($fields as $key => $present) { $value = isset($values[$present]) ? @$values[$present] : null; $person[$present] = $value; } break; default: throw new SocialSpiException("We don't support updating data in batches yet", ResponseError::$NOT_IMPLEMENTED); break; } $allData[$userId->getUserId($token)] = $person; $db[self::$DATA_TABLE] = $allData; $this->saveDb($db); return null; }
if (empty($_FILES['img']['tmp_name'])) { $app->redirect('insert'); } elseif (!empty($_FILES['img']['tmp_name'])) { //getting file by $_POST $filepost = new FilePost(); $generateToken = new Token(); $array = $filepost->postFile($generateToken, $_POST, $_FILES); //var_dump($filepost->postFile($generateToken, $_POST, $_FILES)); //var_dump($array); $cookiecheck = new Cookie(); //setting cookie $cookie = $cookiecheck->getCookie($app); $db = $app->db; $user = new User(); $usermapper = new UserMapper($db); $userid = new UserId(); $user_id = $userid->checkId($user, $usermapper, $cookie); //saving file in DB $foo = new Foo(); $regExp = new RegExp(); $token = $regExp->match($array['token']); $foo->public = $regExp->match($array['public']); $foo->terminate = $array['terminate']; $foo->user_id = $regExp->match($user_id); $foo->path = $regExp->match($array['filename']); // $foo->cookie = $cookie; $foo->token = $regExp->match($token); $foo->filesize = $regExp->match($array['filesize']); $mapper = new FooMapper($db); $mapper->save($foo); //setting unique token
/** * Tests UserId->fromJson() */ public function testFromJson() { $json = 'jsonid'; $fromJson = $this->UserId->fromJson($json); $this->assertEquals('userId', $fromJson->getType()); }
public function getNativeUserFromUId(UserId $uid) { try { $userlogin = $uid->id(); // $parts=Intuitel::getIDFactory()->getIdParts($uid); $user_details = get_complete_user_data('username', $userlogin); if ($user_details) { return $user_details; } else { throw new UnknownUserException("User {$uid->id} is unknown."); } } catch (UnknownIDException $ex) { throw new UnknownUserException("User {$uid->id} is unknown." . $ex->getMessage()); } }
public function getUser() { return isset($this->parameters[self::$USER_ID]) ? UserId::fromJson($this->parameters[self::$USER_ID]) : false; }
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()); }
/** * Fetch groups for a list of ids. * @param UserId $userId The user id to perform the action for * @param GroupId $groupId Optional grouping ID * @param SecurityToken $token The SecurityToken for this request * @return ResponseItem Response item with the error code set if there was a problem */ function getPersonGroups($userId, GroupId $groupId, SecurityToken $token) { $groupId = $groupId->getGroupId(); if ($groupId && $groupId === 'self') { $groupId = null; } return $this->_getSocialData()->getGroupsForPerson($userId->getUserId($token), $groupId, isset($_REQUEST['vo']) ? $_REQUEST['vo'] : null, isset($_REQUEST['sp-entity-id']) ? $_REQUEST['sp-entity-id'] : null); }
/** * To update Person AppData * * @param * $userId for who data is to be updated * @param * $groupId of the user * @param * $appId to which all Appdata belongs to * @param * $feilds array of Appdata needs to be updated * @param * $values array of new Appdata values needs to be saved * @param * $token security token for validation */ public function updatePersonData(UserId $userId, GroupId $groupId, $appId, $fields, $values, SecurityToken $token) { foreach ($fields as $key) { if (!self::isValidKey($key)) { throw new SocialSpiException("The person app data key had invalid characters", ResponseError::$BAD_REQUEST); } } switch ($groupId->getType()) { case 'self': foreach ($fields as $key) { $value = isset($values[$key]) ? $values[$key] : null; if (!ShindigIntegratorDbFetcher::get()->setAppData($userId->getUserId($token), $key, $value, $appId)) { throw new SocialSpiException("Internal server error", ResponseError::$INTERNAL_ERROR); } } break; default: throw new SocialSpiException("Not Implemented", ResponseError::$NOT_IMPLEMENTED); break; } return null; }
public function updatePersonData(UserId $userId, GroupId $groupId, $appId, $fields, $values, SecurityToken $token) { if ($userId->getUserId($token) == null) { throw new SocialSpiException("Unknown person id", ResponseError::$NOT_FOUND); } foreach ($fields as $key) { if (!preg_match('/[\\w\\-\\.]+/', $key)) { throw new SocialSpiException("The person app data key had invalid characters", ResponseError::$BAD_REQUEST); } } if ($groupId->getType() != 'self') { throw new SocialSpiException("We don't support updating data in batches yet", ResponseError::$NOT_IMPLEMENTED); } $targetUserId = $userId->getUserId($token); $member = Doctrine::getTable('Member')->find($targetUserId); if (!$member) { throw new SocialSpiException("Bad Request", ResponseError::$BAD_REQUEST); } $application = Doctrine::getTable('Application')->find($appId); if (!$application) { throw new SocialSpiException("Bad Request", ResponseError::$BAD_REQUEST); } if ($token->getOwnerId() == $targetUserId || $token->getViewerId() == $targetUserId) { $memberApplication = Doctrine::getTable('MemberApplication')->findOneByApplicationAndMember($application, $member); if (!$memberApplication) { throw new SocialSpiException("Unauthorized", ResponseError::$UNAUTHORIZED); } foreach ($fields as $name) { $value = isset($values[$name]) ? $values[$name] : null; $persistentData = $application->getPersistentData($targetUserId, $name); if (!$persistentData) { $persistentData = new ApplicationPersistentData(); $persistentData->setApplication($application); $persistentData->setMember($member); $persistentData->setName($name); } $persistentData->setValue($value); $persistentData->save(); } } else { throw new SocialSpiException("Unauthorized", ResponseError::$UNAUTHORIZED); } }