public function get($key) { if ($r = $this->fast_cache->get($key)) { return $r; } return $this->slow_cache->get($key); }
<?php /** * Copyright (c) 2012 Georg Ehrke <ownclouddev at georgswebsite dot de> * This file is licensed under the Affero General Public License version 3 or * later. * See the COPYING-README file. */ OCP\JSON::checkLoggedIn(); OCP\App::checkAppEnabled('calendar'); OCP\JSON::callCheck(); session_write_close(); if (isset($_POST['progresskey']) && isset($_POST['getprogress'])) { echo OCP\JSON::success(array('percent' => \OC\Cache::get($_POST['progresskey']))); exit; } $file = \OC\Files\Filesystem::file_get_contents($_POST['path'] . '/' . $_POST['file']); if (!$file) { OCP\JSON::error(array('error' => '404')); } $file = Sabre\VObject\StringUtil::convertToUTF8($file); $import = new OC_Calendar_Import($file); $import->setUserID(OCP\User::getUser()); $import->setTimeZone(OC_Calendar_App::$tz); $import->enableProgressCache(); $import->setProgresskey($_POST['progresskey']); if (!$import->isValid()) { OCP\JSON::error(array('error' => 'notvalid')); exit; } $newcal = false;
public static function postCroppedAvatar($args) { \OC_JSON::checkLoggedIn(); \OC_JSON::callCheck(); $user = \OC_User::getUser(); if (isset($_POST['crop'])) { $crop = $_POST['crop']; } else { $l = new \OC_L10n('core'); \OC_JSON::error(array("data" => array("message" => $l->t("No crop data provided")))); return; } $tmpavatar = \OC\Cache::get('tmpavatar'); if (is_null($tmpavatar)) { $l = new \OC_L10n('core'); \OC_JSON::error(array("data" => array("message" => $l->t("No temporary profile picture available, try again")))); return; } $image = new \OC_Image($tmpavatar); $image->crop($crop['x'], $crop['y'], $crop['w'], $crop['h']); try { $avatar = new \OC_Avatar($user); $avatar->set($image->data()); // Clean up \OC\Cache::remove('tmpavatar'); \OC_JSON::success(); } catch (\Exception $e) { \OC_JSON::error(array("data" => array("message" => $e->getMessage()))); } }