/** * prepare long running request * - execution time * - session write close * * @param integer $executionTime * @return integer old max execution time */ protected function _longRunningRequest($executionTime = 0) { if (Tinebase_Core::isLogLevel(Zend_Log::INFO)) { Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__ . ' Close session to allow other requests and set max execution time to ' . $executionTime); } $oldMaxExcecutionTime = Tinebase_Core::setExecutionLifeTime($executionTime); Tinebase_Session::writeClose(true); return $oldMaxExcecutionTime; }
/** * downloads an image/thumbnail at a given size * * @param unknown_type $application * @param string $id * @param string $location * @param int $width * @param int $height * @param int $ratiomode */ public function getImage($application, $id, $location, $width, $height, $ratiomode) { $this->checkAuth(); // close session to allow other requests Tinebase_Session::writeClose(true); $clientETag = null; $ifModifiedSince = null; if (isset($_SERVER['If_None_Match'])) { $clientETag = trim($_SERVER['If_None_Match'], '"'); $ifModifiedSince = trim($_SERVER['If_Modified_Since'], '"'); } elseif (isset($_SERVER['HTTP_IF_NONE_MATCH']) && isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])) { $clientETag = trim($_SERVER['HTTP_IF_NONE_MATCH'], '"'); $ifModifiedSince = trim($_SERVER['HTTP_IF_MODIFIED_SINCE'], '"'); } if ($application == 'Tinebase' && $location == 'tempFile') { $tempFile = Tinebase_TempFile::getInstance()->getTempFile($id); $imgInfo = Tinebase_ImageHelper::getImageInfoFromBlob(file_get_contents($tempFile->path)); $image = new Tinebase_Model_Image($imgInfo + array('application' => $application, 'id' => $id, 'location' => $location)); } else { $image = Tinebase_Controller::getInstance()->getImage($application, $id, $location); } $serverETag = sha1($image->blob . $width . $height . $ratiomode); // cache for 3600 seconds $maxAge = 3600; header('Cache-Control: private, max-age=' . $maxAge); header("Expires: " . gmdate('D, d M Y H:i:s', Tinebase_DateTime::now()->addSecond($maxAge)->getTimestamp()) . " GMT"); // overwrite Pragma header from session header("Pragma: cache"); // if the cache id is still valid if ($clientETag == $serverETag) { header("Last-Modified: " . $ifModifiedSince); header("HTTP/1.0 304 Not Modified"); header('Content-Length: 0'); } else { #$cache = Tinebase_Core::getCache(); #if ($cache->test($serverETag) === true) { # $image = $cache->load($serverETag); #} else { if ($width != -1 && $height != -1) { Tinebase_ImageHelper::resize($image, $width, $height, $ratiomode); } # $cache->save($image, $serverETag); #} header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); header('Content-Type: ' . $image->mime); header('Etag: "' . $serverETag . '"'); flush(); die($image->blob); } }
/** * update user credential cache * * - fires Tinebase_Event_User_ChangeCredentialCache * * @param string $password * @return array */ public function updateCredentialCache($password) { $oldCredentialCache = Tinebase_Core::getUserCredentialCache(); $credentialCache = Tinebase_Auth_CredentialCache::getInstance()->cacheCredentials(Tinebase_Core::getUser()->accountLoginName, $password); Tinebase_Core::set(Tinebase_Core::USERCREDENTIALCACHE, $credentialCache); $success = $this->_setCredentialCacheCookie(); if ($success) { // close session to allow other requests Tinebase_Session::writeClose(true); $event = new Tinebase_Event_User_ChangeCredentialCache($oldCredentialCache); Tinebase_Event::fireEvent($event); } return array('success' => $success); }
/** * update flags * - use session/writeClose to allow following requests * * @param string $folderId id of active folder * @param integer $time update time in seconds * @return array */ public function updateFlags($folderId, $time) { // close session to allow other requests Tinebase_Session::writeClose(true); $folder = Felamimail_Controller_Cache_Message::getInstance()->updateFlags($folderId, $time); return $this->_recordToJson($folder); }