Exemplo n.º 1
0
 /**
  * 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);
     }
 }
Exemplo n.º 2
0
 /**
  * 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);
 }
Exemplo n.º 3
0
 /**
  * @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);
 }
Exemplo n.º 4
0
 /**
  * @param App_Model_User $user
  */
 public static function setUser(App_Model_User $user)
 {
     self::$_user = $user;
 }