/** * Save author name and details * * @return void */ public function saveauthorTask() { // Check for request forgeries Request::checkToken(['get', 'post']); // Incoming $author = Request::getInt('author', 0); $id = Request::getInt('id', 0); $version = Request::getVar('version', ''); $firstName = Request::getVar('firstName', '', 'post'); $lastName = Request::getVar('lastName', '', 'post'); $org = Request::getVar('organization', '', 'post'); // Set redirect URL $url = Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller . '&task=edit' . '&id[]=' . $id . '&version=' . $version, false); // Load publication model $model = new Models\Publication($id, $version); if (!$model->exists()) { App::redirect($url, Lang::txt('COM_PUBLICATIONS_NOT_FOUND'), 'error'); return; } // Load publication project $model->project(); // Get language file Lang::load('plg_projects_publications'); // Save via block $blocksModel = new Models\Blocks($this->database); $block = $blocksModel->loadBlock('authors'); if ($author) { $block->saveItem(NULL, 0, $model, User::get('id'), 0, $author); } else { $block->addItem(NULL, 0, $model, User::get('id')); } if ($block->getError()) { App::redirect($url, $block->getError(), 'error'); return; } else { // Update DOI in case changes if ($model->version->doi) { // Get DOI service $doiService = new Models\Doi($model); // Get updated authors $authors = $model->table('Author')->getAuthors($model->version->id); $doiService->set('authors', $authors); // Update DOI if (preg_match("/" . $doiService->_configs->shoulder . "/", $model->version->get('doi'))) { $doiService->update($model->version->get('doi'), true); } } // Redirect back to publication App::redirect($url, Lang::txt('COM_PUBLICATIONS_SUCCESS_SAVED_AUTHOR')); return; } }
/** * Transfer content from one version to another * * @param object $old Transfer from version record * @param object $new Transfer to version record * @return boolean */ public function transfer($pub, $old, $new) { // Get blocks model $blocksModel = new Blocks($this->_db); foreach ($pub->_curationModel->_progress->blocks as $blockId => $block) { $parentBlock = $blocksModel->getBlockProperty($block->name, '_parentname'); if (in_array($parentBlock, array('content', 'authors'))) { $blocksModel->transferData($parentBlock, $block->manifest, $pub, $old, $new); } } // Set error if ($blocksModel->getError()) { $this->setError($blocksModel->getError()); } return true; }