/** * Save changes to article. * @param $request PKPRequest * @return int the article ID */ function execute(&$request) { $articleDao =& DAORegistry::getDAO('ArticleDAO'); $article =& $this->article; // Retrieve the previous citation list for comparison. $previousRawCitationList = $article->getCitations(); /////////////////////////////////////////// ////////////// Update Authors ///////////// /////////////////////////////////////////// $authors = $this->getData('authors'); for ($i = 0, $count = count($authors); $i < $count; $i++) { if ($authors[$i]['authorId'] > 0) { // Update an existing author $author =& $article->getAuthor($authors[$i]['authorId']); $isExistingAuthor = true; } else { // Create a new author $author = new Author(); $isExistingAuthor = false; } if ($author != null) { $author->setSubmissionId($article->getId()); if (isset($authors[$i]['firstName'])) { $author->setFirstName($authors[$i]['firstName']); } if (isset($authors[$i]['middleName'])) { $author->setMiddleName($authors[$i]['middleName']); } if (isset($authors[$i]['lastName'])) { $author->setLastName($authors[$i]['lastName']); } if (isset($authors[$i]['affiliation'])) { $author->setAffiliation($authors[$i]['affiliation']); } if (isset($authors[$i]['phone'])) { $author->setPhoneNumber($authors[$i]['phone']); } if (isset($authors[$i]['email'])) { $author->setEmail($authors[$i]['email']); } $author->setPrimaryContact($this->getData('primaryContact') == $i ? 1 : 0); $author->setSequence($authors[$i]['seq']); if ($isExistingAuthor == false) { $article->addAuthor($author); } } unset($author); } // Remove deleted authors $deletedAuthors = explode(':', $this->getData('deletedAuthors')); for ($i = 0, $count = count($deletedAuthors); $i < $count; $i++) { $article->removeAuthor($deletedAuthors[$i]); } /////////////////////////////////////////// //////////// Update Abstract(s) /////////// /////////////////////////////////////////// import('classes.article.ProposalAbstract'); $journal = Request::getJournal(); $abstracts = $this->getData('abstracts'); foreach ($journal->getSupportedLocaleNames() as $localeKey => $localeValue) { if ($abstracts[$localeKey]['abstractId'] > 0) { $abstract = $article->getAbstractByLocale($localeKey); $isExistingAbstract = true; } else { $abstract = new ProposalAbstract(); $isExistingAbstract = false; } if ($abstract != null) { $abstract->setArticleId($article->getId()); $abstract->setLocale($localeKey); $abstract->setScientificTitle($abstracts[$localeKey]['scientificTitle']); $abstract->setPublicTitle($abstracts[$localeKey]['publicTitle']); $abstract->setBackground($abstracts[$localeKey]['background']); $abstract->setObjectives($abstracts[$localeKey]['objectives']); $abstract->setStudyMethods($abstracts[$localeKey]['studyMethods']); $abstract->setExpectedOutcomes($abstracts[$localeKey]['expectedOutcomes']); $abstract->setKeywords($abstracts[$localeKey]['keywords']); if ($isExistingAbstract == false) { $article->addAbstract($abstract); } } unset($abstract); } /////////////////////////////////////////// ///////// Update Proposal Details ///////// /////////////////////////////////////////// $proposalDetailsData = $this->getData('proposalDetails'); import('classes.article.ProposalDetails'); $proposalDetails = new ProposalDetails(); $institutionDao =& DAORegistry::getDAO('InstitutionDAO'); import('classes.journal.Institution'); $proposalDetails->setArticleId($article->getId()); $proposalDetails->setStudentResearch($proposalDetailsData['studentInitiatedResearch']); $proposalDetails->setStartDate($proposalDetailsData['startDate']); $proposalDetails->setEndDate($proposalDetailsData['endDate']); if ($proposalDetailsData['keyImplInstitution'] == "OTHER") { $institution = new Institution(); $institution->setInstitutionName($proposalDetailsData['otherInstitutionName']); $institution->setInstitutionAcronym($proposalDetailsData['otherInstitutionAcronym']); $institution->setInstitutionType($proposalDetailsData['otherInstitutionType']); $institution->setInstitutionInternational($proposalDetailsData['international']); if ($proposalDetailsData['international'] == INSTITUTION_NATIONAL) { $institution->setInstitutionLocation($proposalDetailsData['locationCountry']); } elseif ($proposalDetailsData['international'] == INSTITUTION_INTERNATIONAL) { $institution->setInstitutionLocation($proposalDetailsData['locationInternational']); } $institutionId = $institutionDao->insertInstitution($institution); $proposalDetails->setKeyImplInstitution($institutionId); unset($institution); } else { $proposalDetails->setKeyImplInstitution($proposalDetailsData['keyImplInstitution']); } $proposalDetails->setMultiCountryResearch($proposalDetailsData['multiCountryResearch']); if ($proposalDetailsData['multiCountryResearch'] == PROPOSAL_DETAIL_YES) { $countriesArray = $proposalDetailsData['countries']; $countries = implode(",", $countriesArray); $proposalDetails->setCountries($countries); } $proposalDetails->setNationwide($proposalDetailsData['nationwide']); if ($proposalDetailsData['nationwide'] != PROPOSAL_DETAIL_YES) { $geoAreasArray = $proposalDetailsData['geoAreas']; $proposalDetails->setGeoAreasFromArray($geoAreasArray); } $researchDomainsArray = $proposalDetailsData['researchDomains']; $proposalDetails->setResearchDomainsFromArray($researchDomainsArray); $researchFieldsArray = $proposalDetailsData['researchFields']; foreach ($researchFieldsArray as $i => $field) { if ($field == "OTHER") { $otherField = $proposalDetailsData['otherResearchField']; if ($otherField != "") { $researchFieldsArray[$i] = "Other (" . $otherField . ")"; } } } $proposalDetails->setResearchFieldsFromArray($researchFieldsArray); $proposalDetails->setHumanSubjects($proposalDetailsData['withHumanSubjects']); if ($proposalDetailsData['withHumanSubjects'] == PROPOSAL_DETAIL_YES) { $proposalTypesArray = $proposalDetailsData['proposalTypes']; foreach ($proposalTypesArray as $i => $type) { if ($type == "OTHER") { $otherType = $proposalDetailsData['otherProposalType']; if ($otherType != "") { $proposalTypesArray[$i] = "Other (" . $otherType . ")"; } } } $proposalDetails->setProposalTypesFromArray($proposalTypesArray); } $proposalDetails->setDataCollection($proposalDetailsData['dataCollection']); if ($proposalDetailsData['reviewedByOtherErc'] == PROPOSAL_DETAIL_YES) { $proposalDetails->setCommitteeReviewed($proposalDetailsData['otherErcDecision']); } else { $proposalDetails->setCommitteeReviewed(PROPOSAL_DETAIL_NO); } // Update or insert student research import('classes.article.StudentResearch'); $studentResearchInfo = new StudentResearch(); $studentResearchInfo->setArticleId($article->getId()); $studentResearchData = $this->getData('studentResearch'); $studentResearchInfo->setInstitution($studentResearchData['studentInstitution']); $studentResearchInfo->setDegree($studentResearchData['academicDegree']); $studentResearchInfo->setSupervisorName($studentResearchData['supervisorName']); $studentResearchInfo->setSupervisorEmail($studentResearchData['supervisorEmail']); $proposalDetails->setStudentResearchInfo($studentResearchInfo); $article->setProposalDetails($proposalDetails); /////////////////////////////////////////// //////// Update Sources of Monetary /////// /////////////////////////////////////////// $sources = $article->getSources(); $sourcesData = $this->getData('sources'); //Remove sources foreach ($sources as $source) { $isPresent = false; foreach ($sourcesData as $sourceData) { if (!empty($sourceData['sourceId'])) { if ($source->getSourceId() == $sourceData['sourceId']) { $isPresent = true; } } } if (!$isPresent) { $article->removeSource($source->getSourceId()); } unset($source); } for ($i = 0, $count = count($sourcesData); $i < $count; $i++) { if (!empty($sourcesData[$i]['sourceId'])) { // Update an existing source $source =& $article->getSource($sourcesData[$i]['sourceId']); $isExistingSource = true; } else { // Create a new source $source = new ProposalSource(); $isExistingSource = false; } if ($source != null) { $source->setArticleId($article->getId()); if ($sourcesData[$i]['institution'] == "OTHER") { $institution = new Institution(); $institution->setInstitutionName($sourcesData[$i]['otherInstitutionName']); $institution->setInstitutionAcronym($sourcesData[$i]['otherInstitutionAcronym']); $institution->setInstitutionType($sourcesData[$i]['otherInstitutionType']); $institution->setInstitutionInternational($sourcesData[$i]['international']); if ($sourcesData[$i]['international'] == INSTITUTION_NATIONAL) { $institution->setInstitutionLocation($sourcesData[$i]['locationCountry']); } elseif ($proposalDetailsData['international'] == INSTITUTION_INTERNATIONAL) { $institution->setInstitutionLocation($sourcesData[$i]['locationInternational']); } $institutionId = $institutionDao->insertInstitution($institution); $source->setInstitutionId($institutionId); unset($institution); } elseif ($sourcesData[$i]['institution'] == "KII") { $source->setInstitutionId($proposalDetails->getKeyImplInstitution()); } else { $source->setInstitutionId($sourcesData[$i]['institution']); } $source->setSourceAmount($sourcesData[$i]['amount']); if (!$isExistingSource) { $article->addSource($source); } } unset($source); } /////////////////////////////////////////// ///////////// Risk Assessment ///////////// /////////////////////////////////////////// import('classes.article.RiskAssessment'); $riskAssessment = new RiskAssessment(); $riskAssessmentData = $this->getData('riskAssessment'); $riskAssessment->setArticleId($article->getId()); $riskAssessment->setIdentityRevealed($riskAssessmentData['identityRevealed']); $riskAssessment->setUnableToConsent($riskAssessmentData['unableToConsent']); $riskAssessment->setUnder18($riskAssessmentData['under18']); $riskAssessment->setDependentRelationship($riskAssessmentData['dependentRelationship']); $riskAssessment->setEthnicMinority($riskAssessmentData['ethnicMinority']); $riskAssessment->setImpairment($riskAssessmentData['impairment']); $riskAssessment->setPregnant($riskAssessmentData['pregnant']); $riskAssessment->setNewTreatment($riskAssessmentData['newTreatment']); $riskAssessment->setBioSamples($riskAssessmentData['bioSamples']); $riskAssessment->setExportHumanTissue($riskAssessmentData['exportHumanTissue']); $riskAssessment->setExportReason($riskAssessmentData['exportReason']); $riskAssessment->setRadiation($riskAssessmentData['radiation']); $riskAssessment->setDistress($riskAssessmentData['distress']); $riskAssessment->setInducements($riskAssessmentData['inducements']); $riskAssessment->setSensitiveInfo($riskAssessmentData['sensitiveInfo']); $riskAssessment->setReproTechnology($riskAssessmentData['reproTechnology']); $riskAssessment->setGenetic($riskAssessmentData['genetic']); $riskAssessment->setStemCell($riskAssessmentData['stemCell']); $riskAssessment->setBiosafety($riskAssessmentData['biosafety']); $riskAssessment->setRiskLevel($riskAssessmentData['riskLevel']); $riskAssessment->setListRisks($riskAssessmentData['listRisks']); $riskAssessment->setHowRisksMinimized($riskAssessmentData['howRisksMinimized']); $riskAssessment->setRisksToTeam(isset($riskAssessmentData['risksToTeam']) ? 1 : 0); $riskAssessment->setRisksToSubjects(isset($riskAssessmentData['risksToSubjects']) ? 1 : 0); $riskAssessment->setRisksToCommunity(isset($riskAssessmentData['risksToCommunity']) ? 1 : 0); $riskAssessment->setBenefitsToParticipants(isset($riskAssessmentData['benefitsToParticipants']) ? 1 : 0); $riskAssessment->setKnowledgeOnCondition(isset($riskAssessmentData['knowledgeOnCondition']) ? 1 : 0); $riskAssessment->setKnowledgeOnDisease(isset($riskAssessmentData['knowledgeOnDisease']) ? 1 : 0); $riskAssessment->setMultiInstitutions($riskAssessmentData['multiInstitutions']); $riskAssessment->setConflictOfInterest($riskAssessmentData['conflictOfInterest']); $article->setRiskAssessment($riskAssessment); parent::execute(); // Save the article $articleDao->updateArticle($article); // Update references list if it changed. $citationDao =& DAORegistry::getDAO('CitationDAO'); $rawCitationList = $article->getCitations(); if ($previousRawCitationList != $rawCitationList) { $citationDao->importCitations($request, ASSOC_TYPE_ARTICLE, $article->getId(), $rawCitationList); } }
/** * Internal function to return a Institution object from a row. * @param $row array * @return Section */ function &_returnInstitutionFromRow(&$row) { $institution = new Institution(); $institution->setInstitutionId($row['institution_id']); $institution->setInstitutionType($row['type']); $institution->setInstitutionInternational($row['international']); $institution->setInstitutionLocation($row['location']); $institution->setInstitutionName($row['name']); $institution->setInstitutionAcronym($row['acronym']); HookRegistry::call('InstitutionDAO::_returnInstitutionFromRow', array(&$institution, &$row)); return $institution; }
/** * Save changes to article. * @param $request Request * @return int the article ID */ function execute(&$request) { $articleDao =& DAORegistry::getDAO('ArticleDAO'); $articleDetailsDao =& DAORegistry::getDAO('ArticleDetailsDAO'); $institutionDao =& DAORegistry::getDAO('InstitutionDAO'); import('classes.journal.Institution'); $article =& $this->article; $fundingSourcesData = $this->getData('fundingSources'); $fundingSources = $article->getArticleFundingSources(); $primarySponsorData = $this->getData('primarySponsor'); $secondarySponsorsData = $this->getData('secondarySponsors'); $secondarySponsors = $article->getArticleSecondarySponsors(); $details = $article->getArticleDetails(); $CROsData = $this->getData('CROs'); $CROs = $article->getArticleCROs(); $newInstitutions = array(); // Remove deleted funding sources foreach ($fundingSources as $fundingSource) { $isPresent = false; foreach ($fundingSourcesData as $fundingSourceData) { if (!empty($fundingSourceData['id'])) { if ($fundingSource->getId() == $fundingSourceData['id']) { $isPresent = true; } } } if (!$isPresent) { $article->removeArticleFundingSource($fundingSource->getId()); } unset($isPresent); unset($fundingSource); } // Update / Insert funding sources foreach ($fundingSourcesData as $fundingSourceData) { if (isset($fundingSourceData['id'])) { $articleSource = $article->getArticleFundingSource($fundingSourceData['id']); } else { $articleSource = new ArticleSponsor(); } $articleSource->setArticleId($article->getId()); $articleSource->setType(ARTICLE_SPONSOR_TYPE_FUNDING); if ($fundingSourceData['institutionId'] == 'OTHER') { $institution = new Institution(); $institution->setInstitutionName($fundingSourceData['name']); $institution->setInstitutionAcronym($fundingSourceData['acronym']); $institution->setInstitutionType($fundingSourceData['type']); $institution->setInstitutionInternational($fundingSourceData['location']); if ($fundingSourceData['location'] == INSTITUTION_NATIONAL) { $institution->setInstitutionLocation($fundingSourceData['locationCountry']); } elseif ($fundingSourceData['location'] == INSTITUTION_INTERNATIONAL) { $institution->setInstitutionLocation($fundingSourceData['locationInternational']); } $institutionId = $institutionDao->insertInstitution($institution); $articleSource->setInstitutionId($institutionId); $fundingSourceData['institutionId'] = $institutionId; array_push($newInstitutions, $fundingSourceData); unset($institution); } else { $articleSource->setInstitutionId($fundingSourceData['institutionId']); } $article->addArticleFundingSource($articleSource); unset($articleSource); } if (isset($primarySponsorData['id'])) { $primarySponsor = $article->getArticlePrimarySponsor(); } else { $primarySponsor = new ArticleSponsor(); } $primarySponsor->setArticleId($article->getId()); $primarySponsor->setType(ARTICLE_SPONSOR_TYPE_PRIMARY); if ($primarySponsorData['institutionId'] == 'OTHER') { $found = false; foreach ($newInstitutions as $newInstitution) { if ($newInstitution['name'] == $primarySponsorData['name'] || $newInstitution['acronym'] == $primarySponsorData['acronym']) { $found = $newInstitution['institutionId']; } } if (!$found) { $institution = new Institution(); $institution->setInstitutionName($primarySponsorData['name']); $institution->setInstitutionAcronym($primarySponsorData['acronym']); $institution->setInstitutionType($primarySponsorData['type']); $institution->setInstitutionInternational($primarySponsorData['location']); if ($primarySponsorData['location'] == INSTITUTION_NATIONAL) { $institution->setInstitutionLocation($primarySponsorData['locationCountry']); } elseif ($primarySponsorData['location'] == INSTITUTION_INTERNATIONAL) { $institution->setInstitutionLocation($primarySponsorData['locationInternational']); } $institutionId = $institutionDao->insertInstitution($institution); $primarySponsor->setInstitutionId($institutionId); $primarySponsorData['institutionId'] = $institutionId; array_push($newInstitutions, $primarySponsorData); unset($institution); } else { $primarySponsor->setInstitutionId($found); } } else { $primarySponsor->setInstitutionId($primarySponsorData['institutionId']); } $article->setArticlePrimarySponsor($primarySponsor); // Remove deleted secondary sponsors foreach ($secondarySponsors as $secondarySponsor) { $isPresent = false; foreach ($secondarySponsorsData as $secondarySponsorData) { if (!empty($secondarySponsorData['id'])) { if ($secondarySponsor->getId() == $secondarySponsorData['id']) { $isPresent = true; } } } if (!$isPresent) { $article->removeArticleSecondarySponsor($secondarySponsor->getId()); } unset($isPresent); unset($secondarySponsor); } // Update / Insert secondary sponsors foreach ($secondarySponsorsData as $secondarySponsorData) { if (isset($secondarySponsorData['id'])) { $secondarySponsor = $article->getArticleSecondarySponsor($secondarySponsorData['id']); } else { $secondarySponsor = new ArticleSponsor(); } $secondarySponsor->setArticleId($article->getId()); $secondarySponsor->setType(ARTICLE_SPONSOR_TYPE_SECONDARY); if ($secondarySponsorData['ssInstitutionId'] == 'OTHER') { $found = false; foreach ($newInstitutions as $newInstitution) { if ($newInstitution['name'] == $secondarySponsorData['ssName'] || $newInstitution['acronym'] == $secondarySponsorData['ssAcronym']) { $found = $newInstitution['institutionId']; } } if (!$found) { $institution = new Institution(); $institution->setInstitutionName($secondarySponsorData['ssName']); $institution->setInstitutionAcronym($secondarySponsorData['ssAcronym']); $institution->setInstitutionType($secondarySponsorData['ssType']); $institution->setInstitutionInternational($secondarySponsorData['ssLocation']); if ($secondarySponsorData['ssLocation'] == INSTITUTION_NATIONAL) { $institution->setInstitutionLocation($secondarySponsorData['ssLocationCountry']); } elseif ($secondarySponsorData['ssLocation'] == INSTITUTION_INTERNATIONAL) { $institution->setInstitutionLocation($secondarySponsorData['ssLocationInternational']); } $institutionId = $institutionDao->insertInstitution($institution); $secondarySponsor->setInstitutionId($institutionId); $primarySponsorData['institutionId'] = $institutionId; array_push($newInstitutions, array('institutionId' => $institutionId, 'name' => $secondarySponsorData['ssName'], 'acronym' => $secondarySponsorData['ssAcronym'])); unset($institution); } else { $secondarySponsor->setInstitutionId($found); } } else { $secondarySponsor->setInstitutionId($secondarySponsorData['ssInstitutionId']); } $article->addArticleSecondarySponsor($secondarySponsor); unset($secondarySponsor); } $details->setCROInvolved($this->getData('croInvolved')); $articleDetailsDao->updateArticleDetails($details); // Remove deleted CROs foreach ($CROs as $CRO) { $isPresent = false; foreach ($CROsData as $CROData) { if (!empty($CROData['id'])) { if ($CRO->getId() == $CROData['id']) { $isPresent = true; } } } if (!$isPresent) { $article->removeArticleCRO($CRO->getId()); } unset($isPresent); unset($CRO); } // Update / Insert CROs if ($details->getCROInvolved() == ARTICLE_DETAIL_YES) { foreach ($CROsData as $CROData) { if (isset($CROData['id'])) { $CRO = $article->getArticleCRO($CROData['id']); } else { $CRO = new ArticleCRO(); } $CRO->setArticleId($article->getId()); $CRO->setName($CROData['croName']); $CRO->setInternational($CROData['croLocation']); if ($CROData['croLocation'] == CRO_NATIONAL) { $CRO->setLocation($CROData['croLocationCountry']); } elseif ($CROData['croLocation'] == CRO_INTERNATIONAL) { $CRO->setLocation($CROData['croLocationInternational']); } $CRO->setCity($CROData['city']); $CRO->setAddress($CROData['address']); $CRO->setPrimaryPhone($CROData['primaryPhone']); $CRO->setSecondaryPhone($CROData['secondaryPhone']); $CRO->setFax($CROData['fax']); $CRO->setEmail($CROData['email']); $article->addArticleCRO($CRO); unset($CRO); } } //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; }
/** * Save institution. */ function execute() { $institutionDao =& DAORegistry::getDAO('InstitutionDAO'); if (isset($this->institutionId)) { $institution =& $institutionDao->getInstitutionById($this->institutionId); } if (!isset($institution)) { $institution = new Institution(); } $institution->setInstitutionName($this->getData('name')); $institution->setInstitutionAcronym($this->getData('acronym')); $international = $this->getData('international'); $institution->setInstitutionInternational($international); if ($international == INSTITUTION_NATIONAL) { $institution->setInstitutionLocation($this->getData('locationCountry')); } elseif ($international == INSTITUTION_INTERNATIONAL) { $institution->setInstitutionLocation($this->getData('locationInternational')); } $institution->setInstitutionType($this->getData('type')); if ($institution->getInstitutionId() != null) { $institutionDao->updateInstitution($institution); } else { $institutionDao->insertInstitution($institution); } }