Esempio n. 1
0
 public function process()
 {
     /* get base paths and sanitize incoming paths */
     $directory = rawurldecode($this->getProperty('directory', ''));
     $directory = ltrim(strip_tags(str_replace(array('../', './'), '', $directory)), '/');
     $name = $this->getProperty('name');
     $name = ltrim(strip_tags(str_replace(array('../', './'), '', $name)), '/');
     $loaded = $this->getSource();
     if (!$this->source instanceof modMediaSource) {
         return $loaded;
     }
     if (!$this->source->checkPolicy('create')) {
         return $this->failure($this->modx->lexicon('permission_denied'));
     }
     $path = $this->source->createObject($directory, $name, $this->getProperty('content'));
     if (empty($path)) {
         $msg = '';
         $errors = $this->source->getErrors();
         foreach ($errors as $k => $msg) {
             $this->addFieldError($k, $msg);
         }
         return $this->failure($msg);
     }
     return $this->success('', array('file' => $directory . ltrim($name, '/')));
 }
Esempio n. 2
0
 /**
  * Handle the response from the source
  * @param string $response
  * @return array|string
  */
 public function handleResponse($response)
 {
     if (empty($response)) {
         $msg = '';
         $errors = $this->source->getErrors();
         foreach ($errors as $k => $msg) {
             $this->modx->error->addField($k, $msg);
         }
         return $this->failure($msg);
     }
     return $this->success();
 }
Esempio n. 3
0
 public function process()
 {
     if (!$this->getSource()) {
         return $this->failure($this->modx->lexicon('permission_denied'));
     }
     $this->source->setRequestProperties($this->getProperties());
     $this->source->initialize();
     $success = $this->source->createContainer($this->getProperty('name'), $this->getProperty('parent'));
     if (empty($success)) {
         $msg = '';
         $errors = $this->source->getErrors();
         foreach ($errors as $k => $msg) {
             $this->modx->error->addField($k, $msg);
         }
         return $this->failure($msg);
     }
     return $this->success();
 }
Esempio n. 4
0
 public function process()
 {
     /* get base paths and sanitize incoming paths */
     $filePath = rawurldecode($this->getProperty('file', ''));
     $loaded = $this->getSource();
     if (!$this->source instanceof modMediaSource) {
         return $loaded;
     }
     $path = $this->source->updateObject($filePath, $this->getProperty('content'));
     if (empty($path)) {
         $msg = '';
         $errors = $this->source->getErrors();
         foreach ($errors as $k => $msg) {
             $this->addFieldError($k, $msg);
         }
         return $this->failure($msg);
     }
     return $this->success('', array('file' => $path));
 }
Esempio n. 5
0
 public function process()
 {
     /* format filename */
     $file = rawurldecode($this->getProperty('file', ''));
     $source = $this->getSource();
     if ($source !== true) {
         return $source;
     }
     $this->source = $this->getProperty('source', 1);
     $fileArray = $this->source->getObjectContents($file);
     if (empty($fileArray)) {
         $msg = '';
         $errors = $this->source->getErrors();
         foreach ($errors as $k => $msg) {
             $this->addFieldError($k, $msg);
         }
         return $this->failure($msg);
     }
     return $this->success('', $fileArray);
 }
Esempio n. 6
0
 public function process()
 {
     $file = $this->getProperty('file');
     if (empty($file)) {
         return $this->modx->error->failure($this->modx->lexicon('file_err_ns'));
     }
     $loaded = $this->getSource();
     if (!$this->source instanceof modMediaSource) {
         return $loaded;
     }
     if (!$this->source->checkPolicy('remove')) {
         return $this->failure($this->modx->lexicon('permission_denied'));
     }
     $success = $this->source->removeObject($file);
     if (empty($success)) {
         $errors = $this->source->getErrors();
         $msg = implode("\n", $errors);
         return $this->failure($msg);
     }
     return $this->success();
 }
Esempio n. 7
0
 public function process()
 {
     $file = $this->getProperty('file');
     if (empty($file)) {
         return $this->modx->error->failure($this->modx->lexicon('file_err_ns'));
     }
     $loaded = $this->getSource();
     if (!$this->source instanceof modMediaSource) {
         return $loaded;
     }
     $success = $this->source->removeObject($file);
     if (empty($success)) {
         $msg = '';
         $errors = $this->source->getErrors();
         foreach ($errors as $k => $msg) {
             $this->addFieldError($k, $msg);
         }
         return $this->failure();
     }
     return $this->success();
 }
Esempio n. 8
0
 public function process()
 {
     if (!$this->validate()) {
         return $this->failure();
     }
     $oldFile = $this->getProperty('path');
     $loaded = $this->getSource();
     if (!$this->source instanceof modMediaSource) {
         return $loaded;
     }
     $success = $this->source->renameObject($oldFile, $this->getProperty('name'));
     if (empty($success)) {
         $msg = '';
         $errors = $this->source->getErrors();
         foreach ($errors as $k => $msg) {
             $this->addFieldError($k, $msg);
         }
         return $this->failure($msg);
     }
     return $this->success();
 }
Esempio n. 9
0
 public function process()
 {
     /* format filename */
     $file = rawurldecode($this->getProperty('file', ''));
     $loaded = $this->getSource();
     if ($loaded !== true) {
         return $loaded;
     }
     if (!$this->source->checkPolicy('delete')) {
         return $this->failure($this->modx->lexicon('permission_denied'));
     }
     $fileArray = $this->source->getObjectContents($file);
     if (empty($fileArray)) {
         $msg = '';
         $errors = $this->source->getErrors();
         foreach ($errors as $k => $msg) {
             $this->addFieldError($k, $msg);
         }
         return $this->failure($msg);
     }
     return $this->success('', $fileArray);
 }