Пример #1
0
 /**
  * Filter the query by a related User object
  *
  * @param   User|PropelObjectCollection $user  the related object to use as filter
  * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
  *
  * @return                 AccountQuery The current query, for fluid interface
  * @throws PropelException - if the provided filter is invalid.
  */
 public function filterByUser($user, $comparison = null)
 {
     if ($user instanceof User) {
         return $this->addUsingAlias(AccountPeer::ID, $user->getAccountId(), $comparison);
     } elseif ($user instanceof PropelObjectCollection) {
         return $this->useUserQuery()->filterByPrimaryKeys($user->getPrimaryKeys())->endUse();
     } else {
         throw new PropelException('filterByUser() only accepts arguments of type User or PropelCollection');
     }
 }
Пример #2
0
 protected function getUser(User $queryUser, $userId = null)
 {
     if ((string) $userId === '' or (int) $queryUser->getId() === (int) $userId) {
         return $queryUser;
     }
     $query = UserQuery::create()->filterByAccountId($queryUser->getAccountId());
     if ($queryUser->isAdmin()) {
     } elseif ($queryUser->getManagerOf()) {
         $query->filterByDomainId($queryUser->getDomainId());
     } else {
         throw new Exception('User #' . $userId . ' not found.');
     }
     $user = $query->findOneById($userId);
     if ($user === null) {
         throw new Exception('User #' . $userId . ' not found.');
     }
     return $user;
 }
Пример #3
0
 /**
  * Finds the first open clocking.
  *
  * A clocking is considered open only if start and end dates are equal and
  * if it does not have a whole-day clocking type.
  *
  * @param User $authUser The {@link User} object to use for authentication.
  * @param User $user Optional. The {@link User} object. If NULL, the
  *     authenticated user will be used. Default is NULL.
  * @param Clocking $currentClocking Optional. The reference clocking to
  *     exclude from the search. Default is NULL.
  * @param PropelPDO $con Optional. The database connection to use.
  *     Default is NULL.
  * @return Clocking|null
  */
 private function getOpenClocking(User $authUser, User $user = null, Clocking $currentClocking = null, PropelPDO $con = null)
 {
     $query = self::createClockingQuery($authUser)->joinClockingType()->filterByFrozen(0)->filterByDeleted(0, Criteria::EQUAL)->add(ClockingTypePeer::WHOLE_DAY, 0)->add(ClockingPeer::START, ClockingPeer::START . '=' . ClockingPeer::END, Criteria::CUSTOM)->having('NOT Booked');
     // Ignore entries assigned to transactions
     if ($currentClocking !== null) {
         $query->filterById($currentClocking->getId(), Criteria::NOT_EQUAL);
     }
     if ($user !== null) {
         if (!$authUser->isAdmin() and (string) $user->getAccountId() !== (string) $authUser->getAccountId()) {
             throw new Exception('User "' . $authUser->getFQN($con) . '" does not have administrative privileges to access data of user #' . $user->getId() . '.');
         }
         $query->filterByUserRelatedByUserId($user);
     }
     return $query->findOne($con);
 }