/** * Save changes to article. * @param $request Request * @return int the article ID */ function execute(&$request) { $articleDao =& DAORegistry::getDAO('ArticleDAO'); $article =& $this->article; $articleSitesData = $this->getData('articleSites'); $articleSites = $article->getArticleSites(); import('classes.journal.TrialSite'); import('classes.article.ArticleSite'); // Remove deleted article sites foreach ($articleSites as $articleSite) { $isPresent = false; foreach ($articleSitesData as $articleSiteData) { if (!empty($articleSiteData['id'])) { if ($articleSite->getId() == $articleSiteData['id']) { $isPresent = true; } } } if (!$isPresent) { $article->removeArticleSite($articleSite->getId()); } unset($isPresent); unset($articleSite); } // Update / Insters article sites foreach ($articleSitesData as $articleSiteData) { if (isset($articleSiteData['id'])) { $articleSite = $article->getArticleSite($articleSiteData['id']); $isExistingSite = true; } else { $articleSite = new ArticleSite(); $isExistingSite = false; } $articleSite->setArticleId($article->getId()); if ($articleSiteData['siteSelect'] == "OTHER") { $trialSite = new TrialSite(); $trialSite->setName($articleSiteData['siteName']); $trialSite->setAddress($articleSiteData['siteAddress']); $trialSite->setCity($articleSiteData['siteCity']); $trialSite->setRegion($articleSiteData['siteRegion']); $trialSite->setLicensure($articleSiteData['siteLicensure']); $trialSite->setAccreditation($articleSiteData['siteAccreditation']); $articleSite->setSiteId($this->trialSiteDao->insertTrialSite($trialSite)); } else { $articleSite->setSiteId($articleSiteData['siteSelect']); } $articleSite->setAuthority($articleSiteData['authority']); $articleSite->setERCId($articleSiteData['erc']); $articleSite->setPrimaryPhone($articleSiteData['primaryPhone']); $articleSite->setSecondaryPhone($articleSiteData['secondaryPhone']); $articleSite->setFax($articleSiteData['fax']); $articleSite->setEmail($articleSiteData['email']); $articleSite->setSubjectsNumber($articleSiteData['subjectsNumber']); $investigatorsData = $articleSiteData['investigators']; $investigators = $articleSite->getInvestigators(); // Remove deleted investigators foreach ($investigators as $investigator) { $isPresent = false; foreach ($investigatorsData as $investigatorData) { if (!empty($investigatorData['id'])) { if ($investigator->getId() == $investigatorData['id']) { $isPresent = true; } } } if (!$isPresent) { $articleSite->removeInvestigator($investigator->getId()); } unset($isPresent); unset($investigator); } // Update / Insert Investigators $investigatorIterator = 1; foreach ($investigatorsData as $investigatorData) { if (isset($investigatorData['id'])) { $investigator = $articleSite->getInvestigator($investigatorData['id']); } else { $investigator = new Author(); } if ($isExistingSite) { $investigator->setSiteId($articleSite->getId()); } if ($investigatorIterator == 1) { $investigator->setPrimaryContact(1); } $investigator->setSequence($investigatorIterator); $investigator->setFirstName($investigatorData['firstName']); $investigator->setLastName($investigatorData['lastName']); $investigator->setExpertise($investigatorData['expertise']); $investigator->setPrimaryPhoneNumber($investigatorData['iPrimaryPhone']); $investigator->setSecondaryPhoneNumber($investigatorData['iSecondaryPhone']); $investigator->setFaxNumber($investigatorData['iFax']); $investigator->setEmail($investigatorData['iEmail']); $articleSite->addInvestigator($investigator); $investigatorIterator++; } $article->addArticleSite($articleSite); } //update step if ($article->getSubmissionProgress() <= $this->step) { $article->stampStatusModified(); $article->setSubmissionProgress($this->step + 1); } elseif ($article->getSubmissionProgress() == 9) { $article->setSubmissionProgress(8); } parent::execute(); // Save the article $articleDao->updateArticle($article); return $this->articleId; }
/** * Internal function to return an articleSite object from a row. * @param $row array * @return articleSite ArticleSite */ function &_returnArticleSiteFromRow(&$row) { $articleSite = new ArticleSite(); $articleSite->setId($row['article_site_id']); $articleSite->setArticleId($row['article_id']); $articleSite->setSiteId($row['site_id']); $articleSite->setAuthority($row['approving_authority']); $articleSite->setERCId($row['approving_erc']); $articleSite->setPrimaryPhone($row['primary_phone']); $articleSite->setSecondaryPhone($row['secondary_phone']); $articleSite->setFax($row['fax']); $articleSite->setEmail($row['email']); $articleSite->setSubjectsNumber($row['subjects_number']); $articleSite->setInvestigators($this->investigatorDao->getAuthorsByArticleSite($row['article_site_id'])); HookRegistry::call('ArticleSiteDAO::_returnArticleSiteFromRow', array(&$articleSite, &$row)); return $articleSite; }