コード例 #1
0
 public function retrieveLastRelationsByUserId(IUser $user, $limit)
 {
     try {
         $transferObject = new Relation();
         $query = 'SELECT sourceId, targetId FROM relation WHERE (sourceId = :sourceid OR targetId = :targetid) AND (state != "pending") ORDER BY date DESC LIMIT :limit';
         $stmt = $this->dao->prepare($query);
         $result = $this->dao->execute($stmt, array('sourceid' => $user->getId(), 'targetId' => $user->getId(), 'limit' => $limit));
         $result = $stmt->fetchAll(PDO::FETCH_ASSOC);
         $toReturn = array();
         foreach ($result as $entry) {
             $toReturn[] = $user->getId() == $entry['sourceId'] ? $entry['targetId'] : $entry['sourceId'];
         }
         return $toReturn;
     } catch (Exception $e) {
         throw new EyePeopleException($e->getMessage());
     }
 }
コード例 #2
0
 /**
  * Gets a list of workgroups where the user is included.
  *
  * @param IUser $user
  * @return array(IWorkgroup)
  * @throws EyeUMException User not found.
  */
 public function getAllWorkgroupsByUser(IUser $user)
 {
     // check existence
     $this->getUserById($user->getId());
     try {
         $refAssignation = $this->getNewUserWorkgroupAssignationInstance();
         $refAssignation->setUserId($user->getId());
         $assignations = $this->getAllUserWorkgroupAssignations($refAssignation);
         $return = array();
         foreach ($assignations as $assignation) {
             $return[$assignation->getWorkgroupId()] = $this->getWorkgroupById($assignation->getWorkgroupId());
         }
         return $return;
     } catch (Exception $e) {
         throw new EyeUMException('Unable to retrieve all the workgroups from user ' . $user->getName() . '.', 0, $e);
     }
 }
コード例 #3
0
 public function setUser(IUser $user)
 {
     $this->pdo->exec("update oauth_token set user_id = '" . $user->getId() . "' where id = " . $this->id);
     $this->user = $user;
 }