Exemple #1
0
 /**
  * Returns a subordinate user by ID.
  *
  * @param string|int $userId The subordinate user's ID or full login name.
  * @param PropelPDO $con Optional. The database connection to use.
  *     Default is NULL.
  * @throws Exception
  * @return User
  */
 public function getSubordinate($userId, PropelPDO $con = null)
 {
     $query = new UserQuery();
     $user = is_numeric($userId) ? $query->findOneById($userId, $con) : $query->findOneByFQN($userId, $con);
     if ($user === null) {
         throw new Exception('Invalid user ID ' . $userId . '.');
     }
     $thisAccountId = (string) $this->getAccountId();
     if ($thisAccountId === '' or (string) $user->getAccountId() !== $thisAccountId or !$this->isAdmin() and (string) $user->getDomainId() !== (string) $this->getManagerOf()) {
         throw new Exception('The selected user #' . $userId . ' (account #' . $user->getAccountId() . ') is not assigned to user "' . $this->getFQN($con) . '" (account #' . $thisAccountId . ').');
     }
     return $user;
 }