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(); }
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(); }
/** * @param array $ancestors * * @return bool */ public function remove(array $ancestors = array()) { $filename = $this->get('path') . $this->get('file'); if ($this->prepareSource()) { $this->mediaSource->removeObject($filename); if (!empty($this->mediaSource->errors['file'])) { $this->xpdo->log(xPDO::LOG_LEVEL_ERROR, '[Uploadify] Could not remove file at "' . $filename . '": ' . $this->mediaSource->errors['file']); } } $children = $this->xpdo->getIterator('uFile', array('parent' => $this->get('id'))); /** @var uFile $child */ foreach ($children as $child) { $child->remove(); } return parent::remove($ancestors); }