/** * @param array $data * @param Form $form * @param HTTPRequest $request * @return DBHTMLText */ public function doEdit(array $data, Form $form, HTTPRequest $request) { // Check form field state if ($this->parent->isDisabled() || $this->parent->isReadonly()) { return $this->httpError(403); } // Check item permissions $item = $this->getItem(); if (!$item) { return $this->httpError(404); } if ($item instanceof Folder) { return $this->httpError(403); } if (!$item->canEdit()) { return $this->httpError(403); } $form->saveInto($item); $item->write(); $form->sessionMessage(_t('UploadField.Saved', 'Saved'), 'good'); return $this->edit($request); }
/** * @param array $data * @param Form $form * @param SS_HTTPRequest $request */ public function doEdit(array $data, Form $form, SS_HTTPRequest $request) { // Check form field state if ($this->parent->isDisabled() || $this->parent->isReadonly()) { return $this->httpError(403); } // Check item permissions $item = $this->getItem(); if (!$item) { return $this->httpError(404); } if (!$item->canEdit()) { return $this->httpError(403); } // Only allow actions on files in the managed relation (if one exists) $items = $this->parent->getItems(); if ($this->parent->managesRelation() && !$items->byID($item->ID)) { return $this->httpError(403); } $form->saveInto($item); $item->write(); $form->sessionMessage(_t('UploadField.Saved', 'Saved'), 'good'); return $this->edit($request); }