示例#1
0
 /**
  * Resets all references to other model objects or collections of model objects.
  *
  * This method is a user-space workaround for PHP's inability to garbage collect
  * objects with circular references (even in PHP 5.3). This is currently necessary
  * when using Propel in certain daemon or large-volumne/high-memory operations.
  *
  * @param boolean $deep Whether to also clear the references on all referrer objects.
  */
 public function clearAllReferences($deep = false)
 {
     if ($deep && !$this->alreadyInClearAllReferencesDeep) {
         $this->alreadyInClearAllReferencesDeep = true;
         if ($this->aClocking instanceof Persistent) {
             $this->aClocking->clearAllReferences($deep);
         }
         if ($this->aTransaction instanceof Persistent) {
             $this->aTransaction->clearAllReferences($deep);
         }
         $this->alreadyInClearAllReferencesDeep = false;
     }
     // if ($deep)
     $this->aClocking = null;
     $this->aTransaction = null;
 }
示例#2
0
 private function importClockings(Status $logger, array $clockingTypeMap, array $usersByName, PDO $source, PropelPDO $dest)
 {
     $statement = $source->query('SELECT * FROM ext_clockings_clockings');
     $logger->info($statement->rowCount());
     if (!$dest->beginTransaction()) {
         throw new Exception('Could not start transaction.');
     }
     $clockingDataByOldID = array();
     try {
         while (is_array($row = $statement->fetch(PDO::FETCH_ASSOC))) {
             $oldId = $row['ID'];
             $authUserName = $row['creator'];
             $userName = $row['username'];
             if (empty($usersByName[$userName])) {
                 $logger->info('Clocking with old ID #' . $oldId . ' references unknown user "' . $userName . '".');
                 continue;
             }
             $type = $row['type'];
             if (!isset($clockingTypeMap[$type])) {
                 $logger->info('Clocking with old ID #' . $oldId . ' references unknown type ' . $type . '.');
                 continue;
             }
             $clockingType = $clockingTypeMap[$type];
             $start = (int) $row['start'];
             $end = (int) $row['end'];
             if ($clockingType->getWholeDay()) {
                 $start = strtotime('today', $start);
                 $end = strtotime('today', $end);
             }
             $clocking = new Clocking();
             $clocking->setUserRelatedByCreatorId($usersByName[$authUserName])->setUserRelatedByUserId($usersByName[$userName])->setClockingType($clockingType)->setApprovalStatus($this->getApprovalStatus($row))->setStart($start)->setEnd($end)->setBreaktime((int) round($row['break'] * 60))->setCreationdate((int) $row['creationdate'])->setLastChanged((int) $row['changed'])->setComment($row['comment'])->setDeleted($row['visibility'])->save($dest);
             $clockingDataByOldID[$oldId] = new ClockingData($clocking, $row);
         }
     } catch (Exception $e) {
         $dest->rollBack();
         $statement->closeCursor();
         $statement = null;
         throw $e;
     }
     if (!$dest->commit()) {
         throw new Exception('Could not commit transaction.');
     }
     $statement->closeCursor();
     $statement = null;
     return $clockingDataByOldID;
 }
示例#3
0
 /**
  * Filter the query by a related Clocking object
  *
  * @param   Clocking|PropelObjectCollection $clocking  the related object to use as filter
  * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
  *
  * @return                 UserQuery The current query, for fluid interface
  * @throws PropelException - if the provided filter is invalid.
  */
 public function filterByClockingRelatedByUserId($clocking, $comparison = null)
 {
     if ($clocking instanceof Clocking) {
         return $this->addUsingAlias(UserPeer::ID, $clocking->getUserId(), $comparison);
     } elseif ($clocking instanceof PropelObjectCollection) {
         return $this->useClockingRelatedByUserIdQuery()->filterByPrimaryKeys($clocking->getPrimaryKeys())->endUse();
     } else {
         throw new PropelException('filterByClockingRelatedByUserId() only accepts arguments of type Clocking or PropelCollection');
     }
 }
 /**
  * Filter the query by a related Clocking object
  *
  * @param   Clocking|PropelObjectCollection $clocking The related object(s) to use as filter
  * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
  *
  * @return                 TransactionClockingQuery The current query, for fluid interface
  * @throws PropelException - if the provided filter is invalid.
  */
 public function filterByClocking($clocking, $comparison = null)
 {
     if ($clocking instanceof Clocking) {
         return $this->addUsingAlias(TransactionClockingPeer::CLOCKING_ID, $clocking->getId(), $comparison);
     } elseif ($clocking instanceof PropelObjectCollection) {
         if (null === $comparison) {
             $comparison = Criteria::IN;
         }
         return $this->addUsingAlias(TransactionClockingPeer::CLOCKING_ID, $clocking->toKeyValue('PrimaryKey', 'Id'), $comparison);
     } else {
         throw new PropelException('filterByClocking() only accepts arguments of type Clocking or PropelCollection');
     }
 }
示例#5
0
 public static function fromClocking(Clocking $clocking, PropelPDO $con = null)
 {
     return array('Id' => $clocking->getId(), 'UserId' => $clocking->getUserId(), 'TypeId' => $clocking->getTypeId(), 'Creationdate' => $clocking->getCreationdate(), 'LastChanged' => $clocking->getLastChanged(), 'Start' => $clocking->getStart('U'), 'End' => $clocking->getEnd('U'), 'Breaktime' => $clocking->getBreaktime(), 'Comment' => $clocking->getComment(), 'ApprovalStatus' => $clocking->getApprovalStatus(), 'Deleted' => $clocking->getDeleted(), 'Frozen' => $clocking->getFrozen());
 }
示例#6
0
 /**
  * Exclude object from result
  *
  * @param   Clocking $clocking Object to remove from the list of results
  *
  * @return ClockingQuery The current query, for fluid interface
  */
 public function prune($clocking = null)
 {
     if ($clocking) {
         $this->addUsingAlias(ClockingPeer::ID, $clocking->getId(), Criteria::NOT_EQUAL);
     }
     return $this;
 }
示例#7
0
 /**
  * @param	Clocking $clocking The clocking object to add.
  */
 protected function doAddClocking($clocking)
 {
     $this->collClockings[] = $clocking;
     $clocking->setClockingType($this);
 }
示例#8
0
 /**
  * Adds an object to the instance pool.
  *
  * Propel keeps cached copies of objects in an instance pool when they are retrieved
  * from the database.  In some cases -- especially when you override doSelect*()
  * methods in your stub classes -- you may need to explicitly add objects
  * to the cache in order to ensure that the same objects are always returned by doSelect*()
  * and retrieveByPK*() calls.
  *
  * @param      Clocking $obj A Clocking object.
  * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
  */
 public static function addInstanceToPool($obj, $key = null)
 {
     if (Propel::isInstancePoolingEnabled()) {
         if ($key === null) {
             $key = (string) $obj->getId();
         }
         // if key === null
         ClockingPeer::$instances[$key] = $obj;
     }
 }
示例#9
0
文件: clocking.php 项目: dapepe/tymio
 /**
  * Checks whether the clocking's start and end dates are within the time limit.
  * Throws an exception if the time limit is exceeded.
  *
  * @return void
  * @see pastGraceTimeExceeded()
  */
 private function validateTimeLimits(Account $account, User $authUser, Clocking $clocking, PropelPDO $con = null)
 {
     $type = $clocking->getClockingType($con);
     if ($type === null) {
         throw new Exception('Could not get clocking type with ID #' . $clocking->getTypeId() . ' for clocking #' . $clocking->getId() . '.');
     }
     // Check time limit in seconds
     $propertyName = KeyReplace::replace(self::PROPERTY_CLOCKING_TIME_LIMIT, array('type' => $type->getIdentifier()));
     $domain = $authUser->getDomain($con);
     $lastChanged = $clocking->getLastChanged('U');
     $end = $clocking->getEnd('U');
     // Check clocking-type-specific limit first, fall back to default
     $editTimeLimit = PropertyPeer::get($propertyName, $account, $domain, $authUser, $con);
     if ($editTimeLimit === null) {
         $editTimeLimit = PropertyPeer::get(self::PROPERTY_CLOCKING_TIME_LIMIT_DEFAULT, $account, $domain, $authUser, $con);
     }
     $errorData = array('changed' => $lastChanged, 'end' => $end, 'limit' => $editTimeLimit);
     if ($editTimeLimit !== null and !is_numeric($editTimeLimit)) {
         throw new APIException(self::ERROR_TIME_LIMIT, 'Invalid non-numeric value ' . json_encode($editTimeLimit) . ' encountered for property "' . $propertyName . '".', $errorData);
     }
     $minTimeAllowed = time() - $editTimeLimit;
     $result = ((double) $end > $minTimeAllowed and ($clocking->isNew() or (double) $lastChanged > $minTimeAllowed));
     if ($result) {
         return;
     }
     throw new APIException(self::ERROR_TIME_LIMIT, 'Clocking cannot be edited any more after ' . round($editTimeLimit / 3600.0, 2) . ' hours.', $errorData);
 }