/** * get a Person By Id * @param type $id : is the mongoId of the person * @return type */ public static function getById($id) { $person = PHDB::findOneById(self::COLLECTION, $id); if (empty($person)) { //TODO Sylvain - Find a way to manage inconsistente data //throw new CTKException("The person id ".$id." is unkown : contact your admin"); } else { $person["publicURL"] = '/person/public/id/' . $id; if (!empty($person["birthDate"])) { date_default_timezone_set('UTC'); $person["birthDate"] = date('Y-m-d H:i:s', $person["birthDate"]->sec); } } return $person; }
public function run() { try { $person = PHDB::findOneById(Person::COLLECTION, Yii::app()->session['userId'], array("tags", "activeTags", "address", "scope")); $scopes = array(); if (isset($person["address"]["codeInsee"])) { $scopes["codeInsee"] = $person["address"]["codeInsee"]; } if (isset($person["address"]["postalCode"])) { $scopes["codePostal"] = $person["address"]["postalCode"]; } if (isset($person["address"]["region"])) { $scopes["region"] = $person["address"]["region"]; } //TODO : fetch all ascopes in all ressources Orga, people //related scopes list $res = array("result" => true, "tags" => $person["tags"], "scopes" => $scopes); } catch (CTKException $e) { $res = array("result" => false, "msg" => $e->getMessage()); } Rest::json($res); exit; }