protected function _ENV($elem) { $key = (string) $elem['KEY']; switch ($elem['TYPE']) { case 'tymio': switch ($key) { case 'API_URL': return $this->getApiUrl(); default: return null; } case 'server': return isset($_SERVER[$key]) ? $_SERVER[$key] : null; case 'property': default: $userId = (string) $elem['USER']; $user = $this->getUser($this->user, $userId); return $key === '' ? PropertyPeer::getAll($this->account, null, $user) : PropertyPeer::get($key, $this->account, null, $user); } }
/** * 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); }