示例#1
0
文件: broker.php 项目: samj1912/repo
 public function remove($key)
 {
     if ($this->fast_cache->remove($key)) {
         return true;
     }
     return $this->slow_cache->remove($key);
 }
示例#2
0
 public function import()
 {
     if (!$this->isValid()) {
         return false;
     }
     $numofcomponents = count($this->calobject->getComponents());
     if ($this->overwrite) {
         foreach (OC_Calendar_Object::all($this->id) as $obj) {
             OC_Calendar_Object::delete($obj['id']);
         }
     }
     foreach ($this->calobject->getComponents() as $object) {
         if (!$object instanceof Sabre\VObject\Component\VEvent && !$object instanceof Sabre\VObject\Component\VJournal && !$object instanceof Sabre\VObject\Component\VTodo) {
             continue;
         }
         if (!is_null($object->DTSTART)) {
             $dtend = OC_Calendar_Object::getDTEndFromVEvent($object);
             if ($object->DTEND) {
                 $object->DTEND->setDateTime($dtend->getDateTime(), $object->DTSTART->getDateType());
             }
         }
         $vcalendar = $this->createVCalendar($object->serialize());
         $insertid = OC_Calendar_Object::add($this->id, $vcalendar);
         $this->abscount++;
         if ($this->isDuplicate($insertid)) {
             OC_Calendar_Object::delete($insertid);
         } else {
             $this->count++;
         }
         $this->updateProgress(intval($this->abscount / $numofcomponents * 100));
     }
     \OC\Cache::remove($this->progresskey);
     return true;
 }
示例#3
0
 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())));
     }
 }