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()); }
/** * 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 ClockingTypeQuery 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(ClockingTypePeer::ID, $clocking->getTypeId(), $comparison); } elseif ($clocking instanceof PropelObjectCollection) { return $this->useClockingQuery()->filterByPrimaryKeys($clocking->getPrimaryKeys())->endUse(); } else { throw new PropelException('filterByClocking() only accepts arguments of type Clocking or PropelCollection'); } }
/** * 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); }