/** * Edit document page action * * @param void * @return void */ function edit() { $this->wireframe->print_button = false; if ($this->active_document->isNew()) { $this->httpError(HTTP_ERR_NOT_FOUND); } // if if (!$this->active_document->canEdit($this->logged_user)) { $this->httpError(HTTP_ERR_FORBIDDEN); } // if $document_data = $this->request->post('document'); if (!is_array($document_data)) { $document_data = array('name' => $this->active_document->getName(), 'body' => $this->active_document->getBody(), 'category_id' => $this->active_document->getCategoryId(), 'visibility' => $this->active_document->getVisibility()); } // if $this->smarty->assign('document_data', $document_data); if ($this->request->isSubmitted()) { db_begin_work(); $old_name = $this->active_document->getName(); $this->active_document->setAttributes($document_data); $save = $this->active_document->save(); if ($save && !is_error($save)) { db_commit(); flash_success('Document ":document_name" has been updated', array('document_name' => $old_name)); $this->redirectTo('documents'); } else { db_rollback(); $this->smarty->assign('errors', $save); } // if } // if }