/** * Delete * (array)ids * * @throws App_Exception_FileIsNotWritable * @throws App_Exception_Forbidden */ public function deleteAction() { $files = App_Model_File::fetchAll(['user' => (string) $this->user->id, 'identity' => ['$in' => $this->getParam('ids')]]); foreach ($files as $file) { $this->storage->delete($file); } }
/** * Authorize user by token * * @throws App_Exception_Forbidden */ public function init() { parent::init(); $this->user = App_Model_User::fetchOne(['tokens' => ['$in' => [$this->getRequest()->getHeader('x-auth')]]]); if (!$this->user) { throw new App_Exception_Forbidden(); } $config = Zend_Registry::get('config'); App_Service_Storage::setConfig($config['storage']); App_Service_Storage::setUser($this->user); }
/** * @param App_Model_File $file * @return string * * @throws App_Exception_Forbidden */ public function getUrl(App_Model_File $file) { $storage = new App_Service_Storage(); return $storage->getUrl($file); }
/** * @param App_Model_User $user */ public static function setUser(App_Model_User $user) { self::$_user = $user; }