Exemple #1
0
 function saveSettings($args, $request)
 {
     $this->validate();
     // Bring in the comments constants.
     $commentDao = DAORegistry::getDao('CommentDAO');
     $journal = $request->getJournal();
     if ($journal) {
         $rtDao = DAORegistry::getDAO('RTDAO');
         $rt = $rtDao->getJournalRTByJournal($journal);
         if ($request->getUserVar('version') == '') {
             $rt->setVersion(null);
         } else {
             $rt->setVersion($request->getUserVar('version'));
         }
         $rt->setEnabled($request->getUserVar('enabled') == true);
         $rt->setAbstract($request->getUserVar('abstract') == true);
         $rt->setCaptureCite($request->getUserVar('captureCite') == true);
         $rt->setViewMetadata($request->getUserVar('viewMetadata') == true);
         $rt->setSupplementaryFiles($request->getUserVar('supplementaryFiles') == true);
         $rt->setPrinterFriendly($request->getUserVar('printerFriendly') == true);
         $rt->setDefineTerms($request->getUserVar('defineTerms') == true);
         $rt->setEmailAuthor($request->getUserVar('emailAuthor') == true);
         $rt->setEmailOthers($request->getUserVar('emailOthers') == true);
         $rt->setFindingReferences($request->getUserVar('findingReferences') == true);
         $rt->setViewReviewPolicy($request->getUserVar('viewReviewPolicy') == true);
         $journal->updateSetting('enableComments', $request->getUserVar('enableComments') ? $request->getUserVar('enableCommentsMode') : COMMENTS_DISABLED);
         $rtDao->updateJournalRT($rt);
     }
     $request->redirect(null, $request->getRequestedPage());
 }
 /**
  * Display view meeting proposal page.
  * Last update: EL on February 25th 2013
  */
 function viewProposalFromMeeting($args)
 {
     $journal =& Request::getJournal();
     $articleId = $args[0];
     $this->validate($articleId);
     $user =& Request::getUser();
     $reviewerSubmissionDao =& DAORegistry::getDao('ReviewerSubmissionDAO');
     $articleFileDao =& DAORegistry::getDao('ArticleFileDAO');
     $ercReviewersDao = DAORegistry::getDAO('ErcReviewersDAO');
     $currencyDao =& DAORegistry::getDAO('CurrencyDAO');
     $sectionDecisions =& $this->sectionDecisions;
     $this->setupTemplate(true, 2);
     $submission =& $reviewerSubmissionDao->getReviewerSubmissionFromMeeting($articleId);
     $templateMgr =& TemplateManager::getManager();
     $templateMgr->assign_by_ref('submission', $submission);
     $templateMgr->assign_by_ref('sectionDecisions', $sectionDecisions);
     $templateMgr->assign_by_ref('abstract', $submission->getLocalizedAbstract());
     $templateMgr->assign_by_ref('submissionFile', $submission->getSubmissionFile());
     $templateMgr->assign_by_ref('suppFiles', $submission->getSuppFiles());
     $templateMgr->assign_by_ref('previousFiles', $articleFileDao->getPreviousFilesByArticleId($submission->getId()));
     $templateMgr->assign_by_ref('abstractLocales', $journal->getSupportedLocaleNames());
     $templateMgr->assign_by_ref('reportFiles', $submission->getReportFiles());
     $templateMgr->assign_by_ref('saeFiles', $submission->getSAEFiles());
     $templateMgr->assign('isReviewer', $ercReviewersDao->ercReviewerExists($journal->getId(), $submission->getSectionId(), $user->getId()));
     $sourceCurrencyId = $journal->getSetting('sourceCurrency');
     $templateMgr->assign('sourceCurrency', $currencyDao->getCurrencyByAlphaCode($sourceCurrencyId));
     $templateMgr->display('reviewer/viewProposalFromMeeting.tpl');
 }
 function saveSettings()
 {
     RTAdminHandler::validate();
     // Bring in the comments constants.
     $commentDao =& DAORegistry::getDao('CommentDAO');
     $journal = Request::getJournal();
     if ($journal) {
         $rtDao =& DAORegistry::getDAO('RTDAO');
         $rt = $rtDao->getJournalRTByJournal($journal);
         if (Request::getUserVar('version') == '') {
             $rt->setVersion(null);
         } else {
             $rt->setVersion(Request::getUserVar('version'));
         }
         $rt->setEnabled(Request::getUserVar('enabled') == true);
         $rt->setAbstract(Request::getUserVar('abstract') == true);
         $rt->setCaptureCite(Request::getUserVar('captureCite') == true);
         $rt->setViewMetadata(Request::getUserVar('viewMetadata') == true);
         $rt->setSupplementaryFiles(Request::getUserVar('supplementaryFiles') == true);
         $rt->setPrinterFriendly(Request::getUserVar('printerFriendly') == true);
         $rt->setAuthorBio(Request::getUserVar('authorBio') == true);
         $rt->setDefineTerms(Request::getUserVar('defineTerms') == true);
         $rt->setEmailAuthor(Request::getUserVar('emailAuthor') == true);
         $rt->setEmailOthers(Request::getUserVar('emailOthers') == true);
         $rt->setFindingReferences(Request::getUserVar('findingReferences') == true);
         $journal->updateSetting('enableComments', Request::getUserVar('enableComments') ? Request::getUserVar('enableCommentsMode') : COMMENTS_DISABLED);
         $rtDao->updateJournalRT($rt);
     }
     Request::redirect(null, Request::getRequestedPage());
 }
 /**
  *  Response to Meeting Scheduler
  */
 function replyMeeting()
 {
     $meetingId = Request::getUserVar('meetingId');
     $this->validate($meetingId);
     $user =& Request::getUser();
     $userId = $user->getId();
     $meetingAttendanceDao =& DAORegistry::getDao('MeetingAttendanceDAO');
     $meetingAttendance = $meetingAttendanceDao->getMeetingAttendance($meetingId, $userId);
     $meetingAttendance->setIsAttending(Request::getUserVar('isAttending'));
     $meetingAttendance->setRemarks(Request::getUserVar('remarks'));
     $meetingAttendanceDao =& DAORegistry::getDao('MeetingAttendanceDAO');
     $meetingAttendanceDao->updateReplyOfAttendance($meetingAttendance);
     Request::redirect(null, 'reviewer', 'viewMeeting', $meetingId);
 }
 /**
  * Create initial required data.
  * @return boolean
  */
 function createData()
 {
     // Add initial site data
     $locale = $this->getParam('locale');
     $siteDao =& DAORegistry::getDAO('SiteDAO', $this->dbconn);
     $site = new Site();
     $site->setRedirect(0);
     $site->setMinPasswordLength(INSTALLER_DEFAULT_MIN_PASSWORD_LENGTH);
     $site->setPrimaryLocale($locale);
     $site->setInstalledLocales($this->installedLocales);
     $site->setSupportedLocales($this->installedLocales);
     if (!$siteDao->insertSite($site)) {
         $this->setError(INSTALLER_ERROR_DB, $this->dbconn->errorMsg());
         return false;
     }
     $siteSettingsDao =& DAORegistry::getDAO('SiteSettingsDAO');
     $siteSettingsDao->updateSetting('title', array($locale => __(INSTALLER_DEFAULT_SITE_TITLE)), null, true);
     $siteSettingsDao->updateSetting('contactName', array($locale => __(INSTALLER_DEFAULT_SITE_TITLE)), null, true);
     $siteSettingsDao->updateSetting('contactEmail', array($locale => $this->getParam('adminEmail')), null, true);
     // Add initial site administrator user
     $userDao =& DAORegistry::getDAO('UserDAO', $this->dbconn);
     $user = new User();
     $user->setUsername($this->getParam('adminUsername'));
     $user->setPassword(Validation::encryptCredentials($this->getParam('adminUsername'), $this->getParam('adminPassword'), $this->getParam('encryption')));
     $user->setFirstName($user->getUsername());
     $user->setLastName('');
     $user->setEmail($this->getParam('adminEmail'));
     if (!$userDao->insertUser($user)) {
         $this->setError(INSTALLER_ERROR_DB, $this->dbconn->errorMsg());
         return false;
     }
     $roleDao =& DAORegistry::getDao('RoleDAO', $this->dbconn);
     $role = new Role();
     $role->setJournalId(0);
     $role->setUserId($user->getId());
     $role->setRoleId(ROLE_ID_SITE_ADMIN);
     if (!$roleDao->insertRole($role)) {
         $this->setError(INSTALLER_ERROR_DB, $this->dbconn->errorMsg());
         return false;
     }
     // Install email template list and data for each locale
     $emailTemplateDao =& DAORegistry::getDAO('EmailTemplateDAO');
     $emailTemplateDao->installEmailTemplates($emailTemplateDao->getMainEmailTemplatesFilename());
     foreach ($this->installedLocales as $locale) {
         $emailTemplateDao->installEmailTemplateData($emailTemplateDao->getMainEmailTemplateDataFilename($locale));
     }
     // Install filters and filter templates.
     $this->installFilterTemplates();
     return true;
 }
Exemple #6
0
 function callback($hookName, $args)
 {
     $isEnabled = $this->getSetting(0, 0, 'enabled');
     if ($isEnabled) {
         $taskDao =& DAORegistry::getDao('ScheduledTaskDAO');
         // Grab the scheduled scheduled conference tree
         $scheduledTasks = $this->getSetting(0, 0, 'crontab');
         if (!$scheduledTasks) {
             $this->parseCrontab();
             $scheduledTasks = $this->getSetting(0, 0, 'crontab');
         }
         $tasks = $this->getSetting(0, 0, 'crontab');
         foreach ($tasks as $task) {
             $lastRuntime = $taskDao->getLastRunTime($task['className']);
             if (isset($task['frequency'])) {
                 $canExecute = $this->checkFrequency($task['className'], $task['frequency'], $lastRuntime);
             } else {
                 // WARNING: tasks without 'frequency' entries will run ON EVERY REQUEST.
                 // This can incur a serious performance hit.
                 $canExecute = true;
             }
             if ($canExecute) {
                 // Strip off the package name(s) to get the base class name
                 $className = $task['className'];
                 $pos = strrpos($className, '.');
                 if ($pos === false) {
                     $baseClassName = $className;
                 } else {
                     $baseClassName = substr($className, $pos + 1);
                 }
                 // There's a race here. Several requests may come in closely spaced.
                 // Each may decide it's time to run scheduled tasks, and more than one
                 // can happily go ahead and do it before the "last run" time is updated.
                 // By updating the last run time as soon as feasible, we can minimize
                 // the race window. TODO: there ought to be a safer way of doing this.
                 $taskDao->updateLastRunTime($className, $lastRuntime);
                 // Load and execute the task
                 import($className);
                 $task = new $baseClassName($args);
                 $task->execute();
             }
         }
     }
     return false;
 }
Exemple #7
0
 /**
  * For upgrade to 2.1.1: Migrate the RT settings from the rt_settings
  * table to journal settings and drop the rt_settings table.
  * @return boolean
  */
 function migrateRtSettings()
 {
     $rtDao =& DAORegistry::getDAO('RTDAO');
     $journalDao =& DAORegistry::getDAO('JournalDAO');
     // Bring in the comments constants.
     $commentDao =& DAORegistry::getDao('CommentDAO');
     $result =& $rtDao->retrieve('SELECT * FROM rt_settings');
     while (!$result->EOF) {
         $row = $result->GetRowAssoc(false);
         $journalId = $row['journal_id'];
         $journal =& $journalDao->getJournal($journalId);
         $rt = new JournalRT($journalId);
         $rt->setEnabled(true);
         // No toggle in prior OJS; assume true
         $rt->setVersion($row['version_id']);
         $rt->setAbstract(true);
         // No toggle in prior OJS; assume true
         $rt->setCaptureCite($row['capture_cite']);
         $rt->setViewMetadata($row['view_metadata']);
         $rt->setSupplementaryFiles($row['supplementary_files']);
         $rt->setPrinterFriendly($row['printer_friendly']);
         $rt->setAuthorBio($row['author_bio']);
         $rt->setDefineTerms($row['define_terms']);
         $journal->updateSetting('enableComments', $row['add_comment'] ? COMMENTS_AUTHENTICATED : COMMENTS_DISABLED);
         $rt->setEmailAuthor($row['email_author']);
         $rt->setEmailOthers($row['email_others']);
         $rtDao->updateJournalRT($rt);
         unset($rt);
         unset($journal);
         $result->MoveNext();
     }
     $result->Close();
     unset($result);
     // Drop the table once all settings are migrated.
     $rtDao->update('DROP TABLE rt_settings');
     return true;
 }
 /**
  * Create initial required data.
  * @return boolean
  */
 function createData()
 {
     if ($this->getParam('manualInstall')) {
         // Add insert statements for default data
         // FIXME use ADODB data dictionary?
         $this->executeSQL(sprintf('INSERT INTO site (primary_locale, installed_locales) VALUES (\'%s\', \'%s\')', $this->getParam('locale'), join(':', $this->installedLocales)));
         $this->executeSQL(sprintf('INSERT INTO site_settings (setting_name, setting_type, setting_value, locale) VALUES (\'%s\', \'%s\', \'%s\', \'%s\')', 'title', 'string', addslashes(Locale::translate(INSTALLER_DEFAULT_SITE_TITLE)), $this->getParam('locale')));
         $this->executeSQL(sprintf('INSERT INTO site_settings (setting_name, setting_type, setting_value, locale) VALUES (\'%s\', \'%s\', \'%s\', \'%s\')', 'contactName', 'string', addslashes(Locale::translate(INSTALLER_DEFAULT_SITE_TITLE)), $this->getParam('locale')));
         $this->executeSQL(sprintf('INSERT INTO site_settings (setting_name, setting_type, setting_value, locale) VALUES (\'%s\', \'%s\', \'%s\', \'%s\')', 'contactEmail', 'string', addslashes($this->getParam('adminEmail')), $this->getParam('locale')));
         $this->executeSQL(sprintf('INSERT INTO users (user_id, username, first_name, last_name, password, email, date_registered, date_last_login) VALUES (%d, \'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\')', 1, $this->getParam('adminUsername'), $this->getParam('adminUsername'), $this->getParam('adminUsername'), Validation::encryptCredentials($this->getParam('adminUsername'), $this->getParam('adminPassword'), $this->getParam('encryption')), $this->getParam('adminEmail'), Core::getCurrentDate(), Core::getCurrentDate()));
         $this->executeSQL(sprintf('INSERT INTO roles (journal_id, user_id, role_id) VALUES (%d, %d, %d)', 0, 1, ROLE_ID_SITE_ADMIN));
     } else {
         // Add initial site data
         $locale = $this->getParam('locale');
         $siteDao =& DAORegistry::getDAO('SiteDAO', $this->dbconn);
         $site =& new Site();
         $site->setTitle(Locale::translate(INSTALLER_DEFAULT_SITE_TITLE), $locale);
         $site->setJournalRedirect(0);
         $site->setMinPasswordLength(INSTALLER_DEFAULT_MIN_PASSWORD_LENGTH);
         $site->setPrimaryLocale($locale);
         $site->setInstalledLocales($this->installedLocales);
         $site->setSupportedLocales($this->installedLocales);
         $site->setContactName($site->getTitle($locale), $locale);
         $site->setContactEmail($this->getParam('adminEmail'), $locale);
         if (!$siteDao->insertSite($site)) {
             $this->setError(INSTALLER_ERROR_DB, $this->dbconn->errorMsg());
             return false;
         }
         // Add initial site administrator user
         $userDao =& DAORegistry::getDAO('UserDAO', $this->dbconn);
         $user =& new User();
         $user->setUsername($this->getParam('adminUsername'));
         $user->setPassword(Validation::encryptCredentials($this->getParam('adminUsername'), $this->getParam('adminPassword'), $this->getParam('encryption')));
         $user->setFirstName($user->getUsername());
         $user->setLastName('');
         $user->setEmail($this->getParam('adminEmail'));
         if (!$userDao->insertUser($user)) {
             $this->setError(INSTALLER_ERROR_DB, $this->dbconn->errorMsg());
             return false;
         }
         $roleDao =& DAORegistry::getDao('RoleDAO', $this->dbconn);
         $role =& new Role();
         $role->setJournalId(0);
         $role->setUserId($user->getUserId());
         $role->setRoleId(ROLE_ID_SITE_ADMIN);
         if (!$roleDao->insertRole($role)) {
             $this->setError(INSTALLER_ERROR_DB, $this->dbconn->errorMsg());
             return false;
         }
     }
     return true;
 }
Exemple #9
0
 /**
  * Create initial required data.
  * @return boolean
  */
 function createData()
 {
     if ($this->getParam('manualInstall')) {
         // Add insert statements for default data
         // FIXME use ADODB data dictionary?
         $this->executeSQL(sprintf('INSERT INTO site (primary_locale, installed_locales) VALUES (\'%s\', \'%s\')', $this->getParam('locale'), join(':', $this->installedLocales)));
         $this->executeSQL(sprintf('INSERT INTO site_settings (setting_name, setting_type, setting_value, locale) VALUES (\'%s\', \'%s\', \'%s\', \'%s\')', 'title', 'string', addslashes(Locale::translate(INSTALLER_DEFAULT_SITE_TITLE)), $this->getParam('locale')));
         $this->executeSQL(sprintf('INSERT INTO site_settings (setting_name, setting_type, setting_value, locale) VALUES (\'%s\', \'%s\', \'%s\', \'%s\')', 'contactName', 'string', addslashes(Locale::translate(INSTALLER_DEFAULT_SITE_TITLE)), $this->getParam('locale')));
         $this->executeSQL(sprintf('INSERT INTO site_settings (setting_name, setting_type, setting_value, locale) VALUES (\'%s\', \'%s\', \'%s\', \'%s\')', 'contactEmail', 'string', addslashes($this->getParam('adminEmail')), $this->getParam('locale')));
         $this->executeSQL(sprintf('INSERT INTO users (username, first_name, last_name, password, email, date_registered, date_last_login) VALUES (\'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\')', $this->getParam('adminUsername'), $this->getParam('adminUsername'), $this->getParam('adminUsername'), Validation::encryptCredentials($this->getParam('adminUsername'), $this->getParam('adminPassword'), $this->getParam('encryption')), $this->getParam('adminEmail'), Core::getCurrentDate(), Core::getCurrentDate()));
         $this->executeSQL(sprintf('INSERT INTO roles (conference_id, user_id, role_id) VALUES (%d, (SELECT user_id FROM users WHERE username = \'%s\'), %d)', 0, $this->getParam('adminUsername'), ROLE_ID_SITE_ADMIN));
         // Install email template list and data for each locale
         $emailTemplateDao =& DAORegistry::getDAO('EmailTemplateDAO');
         foreach ($emailTemplateDao->installEmailTemplates($emailTemplateDao->getMainEmailTemplatesFilename(), true) as $sql) {
             $this->executeSQL($sql);
         }
         foreach ($this->installedLocales as $locale) {
             foreach ($emailTemplateDao->installEmailTemplateData($emailTemplateDao->getMainEmailTemplateDataFilename($locale), true) as $sql) {
                 $this->executeSQL($sql);
             }
         }
     } else {
         // Add initial site data
         $locale = $this->getParam('locale');
         $siteDao =& DAORegistry::getDAO('SiteDAO', $this->dbconn);
         $site = new Site();
         $site->setRedirect(0);
         $site->setMinPasswordLength(INSTALLER_DEFAULT_MIN_PASSWORD_LENGTH);
         $site->setPrimaryLocale($locale);
         $site->setInstalledLocales($this->installedLocales);
         $site->setSupportedLocales($this->installedLocales);
         if (!$siteDao->insertSite($site)) {
             $this->setError(INSTALLER_ERROR_DB, $this->dbconn->errorMsg());
             return false;
         }
         $siteSettingsDao =& DAORegistry::getDAO('SiteSettingsDAO');
         $siteSettingsDao->updateSetting('title', array($locale => Locale::translate(INSTALLER_DEFAULT_SITE_TITLE)), null, true);
         $siteSettingsDao->updateSetting('contactName', array($locale => Locale::translate(INSTALLER_DEFAULT_SITE_TITLE)), null, true);
         $siteSettingsDao->updateSetting('contactEmail', array($locale => $this->getParam('adminEmail')), null, true);
         // Add initial site administrator user
         $userDao =& DAORegistry::getDAO('UserDAO', $this->dbconn);
         $user = new User();
         $user->setUsername($this->getParam('adminUsername'));
         $user->setPassword(Validation::encryptCredentials($this->getParam('adminUsername'), $this->getParam('adminPassword'), $this->getParam('encryption')));
         $user->setFirstName($user->getUsername());
         $user->setLastName('');
         $user->setEmail($this->getParam('adminEmail'));
         if (!$userDao->insertUser($user)) {
             $this->setError(INSTALLER_ERROR_DB, $this->dbconn->errorMsg());
             return false;
         }
         $roleDao =& DAORegistry::getDao('RoleDAO', $this->dbconn);
         $role = new Role();
         $role->setConferenceId(0);
         $role->setUserId($user->getId());
         $role->setRoleId(ROLE_ID_SITE_ADMIN);
         if (!$roleDao->insertRole($role)) {
             $this->setError(INSTALLER_ERROR_DB, $this->dbconn->errorMsg());
             return false;
         }
         // Install email template list and data for each locale
         $emailTemplateDao =& DAORegistry::getDAO('EmailTemplateDAO');
         $emailTemplateDao->installEmailTemplates($emailTemplateDao->getMainEmailTemplatesFilename());
         foreach ($this->installedLocales as $locale) {
             $emailTemplateDao->installEmailTemplateData($emailTemplateDao->getMainEmailTemplateDataFilename($locale));
         }
         // Add initial plugin data to versions table
         $versionDao =& DAORegistry::getDAO('VersionDAO');
         import('site.VersionCheck');
         $categories = PluginRegistry::getCategories();
         foreach ($categories as $category) {
             PluginRegistry::loadCategory($category, true);
             $plugins = PluginRegistry::getPlugins($category);
             foreach ($plugins as $plugin) {
                 $versionFile = $plugin->getPluginPath() . '/version.xml';
                 if (FileManager::fileExists($versionFile)) {
                     $versionInfo =& VersionCheck::parseVersionXML($versionFile);
                     $pluginVersion = $versionInfo['version'];
                     $pluginVersion->setCurrent(1);
                     $versionDao->insertVersion($pluginVersion);
                 } else {
                     $pluginVersion = new Version();
                     $pluginVersion->setMajor(1);
                     $pluginVersion->setMinor(0);
                     $pluginVersion->setRevision(0);
                     $pluginVersion->setBuild(0);
                     $pluginVersion->setDateInstalled(Core::getCurrentDate());
                     $pluginVersion->setCurrent(1);
                     $pluginVersion->setProductType('plugins.' . $category);
                     $pluginVersion->setProduct(basename($plugin->getPluginPath()));
                     $versionDao->insertVersion($pluginVersion);
                 }
             }
         }
     }
     return true;
 }
Exemple #10
0
 /**
  * @covers MetadataProperty::isValid
  */
 public function testValidateControlledVocabulary()
 {
     // Build a test vocabulary. (Assoc type and id are 0 to
     // simulate a site-wide vocabulary).
     $controlledVocabDao = DAORegistry::getDao('ControlledVocabDAO');
     $testControlledVocab = $controlledVocabDao->build('test-controlled-vocab', 0, 0);
     // Make a vocabulary entry
     $controlledVocabEntryDao = DAORegistry::getDao('ControlledVocabEntryDAO');
     $testControlledVocabEntry = $controlledVocabEntryDao->newDataObject();
     $testControlledVocabEntry->setName('testEntry', 'en_US');
     $testControlledVocabEntry->setControlledVocabId($testControlledVocab->getId());
     $controlledVocabEntryId = $controlledVocabEntryDao->insertObject($testControlledVocabEntry);
     $metadataProperty = new MetadataProperty('testElement', array(), array(METADATA_PROPERTY_TYPE_VOCABULARY => 'test-controlled-vocab'));
     // This validator checks numeric values
     self::assertEquals(array(METADATA_PROPERTY_TYPE_VOCABULARY => 'test-controlled-vocab'), $metadataProperty->isValid($controlledVocabEntryId));
     self::assertFalse($metadataProperty->isValid($controlledVocabEntryId + 1));
     // Delete the test vocabulary
     $controlledVocabDao->deleteObject($testControlledVocab);
 }
 /**
  * After a decision has been recorded, bumps the paper to the next stage.
  * If the submission requires completion, it's sent back to the author.
  * If not, review is complete, and the paper can be released.
  * @param $schedConf object
  * @param $trackDirectorSubmission object
  * @param $decision int
  */
 function completeReview($trackDirectorSubmission)
 {
     $schedConf =& Request::getSchedConf();
     if ($trackDirectorSubmission->getReviewMode() == REVIEW_MODE_BOTH_SEQUENTIAL) {
         // two-stage submission; paper required
         // The submission is incomplete, and needs the author to submit
         // more materials (potentially for another stage of reviews)
         if ($trackDirectorSubmission->getCurrentStage() == REVIEW_STAGE_ABSTRACT) {
             // We've just completed reviewing the abstract. Prepare for presentation
             // review process.
             $trackDirectorSubmission->setCurrentStage(REVIEW_STAGE_PRESENTATION);
             // The paper itself needs to be collected. Flag it so the author
             // may complete it.
             $trackDirectorSubmission->setSubmissionProgress(2);
             // TODO: notify the author the submission must be completed.
             // Q: should the director be given this option explicitly?
             // Now, reassign all reviewers that submitted a review for the last
             // stage of reviews.
             foreach ($trackDirectorSubmission->getReviewAssignments(REVIEW_STAGE_ABSTRACT) as $reviewAssignment) {
                 if ($reviewAssignment->getRecommendation() !== null && $reviewAssignment->getRecommendation() !== '') {
                     // This reviewer submitted a review; reassign them
                     TrackDirectorAction::addReviewer($trackDirectorSubmission, $reviewAssignment->getReviewerId(), REVIEW_STAGE_PRESENTATION);
                 }
             }
         }
     }
     $trackDirectorSubmissionDao =& DAORegistry::getDao('TrackDirectorSubmissionDAO');
     $trackDirectorSubmissionDao->updateTrackDirectorSubmission($trackDirectorSubmission);
     $trackDirectorSubmission->stampStatusModified();
     // Commit the paper changes
     $paperDao =& DAORegistry::getDao('PaperDAO');
     $paperDao->updatePaper($trackDirectorSubmission);
 }
Exemple #12
0
 /**
  * Create initial required data.
  * @return boolean
  */
 function createData()
 {
     // Add initial site administrator user
     $userDao = DAORegistry::getDAO('UserDAO', $this->dbconn);
     $user = $userDao->newDataObject();
     $user->setUsername($this->getParam('adminUsername'));
     $user->setPassword(Validation::encryptCredentials($this->getParam('adminUsername'), $this->getParam('adminPassword'), $this->getParam('encryption')));
     $user->setFirstName($user->getUsername());
     $user->setLastName('');
     $user->setEmail($this->getParam('adminEmail'));
     $user->setInlineHelp(1);
     if (!$userDao->insertObject($user)) {
         $this->setError(INSTALLER_ERROR_DB, $this->dbconn->errorMsg());
         return false;
     }
     // Create an admin user group
     AppLocale::requireComponents(LOCALE_COMPONENT_PKP_DEFAULT);
     $userGroupDao = DAORegistry::getDao('UserGroupDAO', $this->dbconn);
     $adminUserGroup = $userGroupDao->newDataObject();
     $adminUserGroup->setRoleId(ROLE_ID_SITE_ADMIN);
     $adminUserGroup->setContextId(CONTEXT_ID_NONE);
     $adminUserGroup->setDefault(true);
     foreach ($this->installedLocales as $locale) {
         $name = __('default.groups.name.siteAdmin', array(), $locale);
         $namePlural = __('default.groups.plural.siteAdmin', array(), $locale);
         $adminUserGroup->setData('name', $name, $locale);
         $adminUserGroup->setData('namePlural', $namePlural, $locale);
     }
     if (!$userGroupDao->insertObject($adminUserGroup)) {
         $this->setError(INSTALLER_ERROR_DB, $this->dbconn->errorMsg());
         return false;
     }
     // Put the installer into this user group
     $userGroupDao->assignUserToGroup($user->getId(), $adminUserGroup->getId());
     // Add initial site data
     $locale = $this->getParam('locale');
     $siteDao = DAORegistry::getDAO('SiteDAO', $this->dbconn);
     $site = $siteDao->newDataObject();
     $site->setRedirect(0);
     $site->setMinPasswordLength(INSTALLER_DEFAULT_MIN_PASSWORD_LENGTH);
     $site->setPrimaryLocale($locale);
     $site->setInstalledLocales($this->installedLocales);
     $site->setSupportedLocales($this->installedLocales);
     if (!$siteDao->insertSite($site)) {
         $this->setError(INSTALLER_ERROR_DB, $this->dbconn->errorMsg());
         return false;
     }
     // Install email template list and data for each locale
     $emailTemplateDao = DAORegistry::getDAO('EmailTemplateDAO');
     $emailTemplateDao->installEmailTemplates($emailTemplateDao->getMainEmailTemplatesFilename());
     foreach ($this->installedLocales as $locale) {
         $emailTemplateDao->installEmailTemplateData($emailTemplateDao->getMainEmailTemplateDataFilename($locale));
     }
     // Install default site settings
     $siteSettingsDao = DAORegistry::getDAO('SiteSettingsDAO');
     $siteSettingsDao->installSettings('registry/siteSettings.xml', array('contactEmail' => $this->getParam('adminEmail')));
     return true;
 }
 function deleteReviewerVersion($args)
 {
     $reviewId = isset($args[0]) ? (int) $args[0] : 0;
     $fileId = isset($args[1]) ? (int) $args[1] : 0;
     $articleId = isset($args[2]) ? (int) $args[2] : 0;
     $this->validateAction($reviewId);
     $reviewerSubmission =& $this->submission;
     $reviewAssignmentDao =& DAORegistry::getDao('ReviewAssignmentDAO');
     $assignment =& $reviewAssignmentDao->getReviewAssignmentById($reviewId);
     if (!$assignment->getCancelled()) {
         ReviewerAction::deleteReviewerVersion($reviewId, $fileId, $articleId);
     }
     Request::redirect(null, null, 'submission', $reviewerSubmission->getArticleId());
 }
Exemple #14
0
 /**
  * Save track.
  */
 function execute()
 {
     $schedConfDao =& DAORegistry::getDao('SchedConfDAO');
     $schedConf =& Request::getSchedConf();
     import('classes.conference.log.ConferenceLog');
     import('classes.conference.log.ConferenceEventLogEntry');
     //
     // Don't log these, since they aren't particularly nefarious.
     //
     // Website start date and end date.
     if ($schedConf->getStartDate() != $this->_data['siteStartDate']) {
         $schedConf->setStartDate($this->_data['siteStartDate']);
         $schedConfDao->updateSchedConf($schedConf);
     }
     if ($schedConf->getEndDate() != $this->_data['siteEndDate']) {
         $schedConf->setEndDate($this->_data['siteEndDate']);
         $schedConfDao->updateSchedConf($schedConf);
     }
     // Conference Information display flags
     $schedConf->updateSetting('postTimeline', $this->getData('postTimeline'), 'bool');
     $schedConf->updateSetting('postOverview', $this->getData('postOverview'), 'bool');
     $schedConf->updateSetting('postCFP', $this->getData('postCFP'), 'bool');
     $schedConf->updateSetting('postProposalSubmission', $this->getData('postProposalSubmission'), 'bool');
     $schedConf->updateSetting('postTrackPolicies', $this->getData('postTrackPolicies'), 'bool');
     $schedConf->updateSetting('postProgram', $this->getData('postProgram'), 'bool');
     $schedConf->updateSetting('postPresentations', $this->getData('postPresentations'), 'bool');
     $schedConf->updateSetting('postAccommodation', $this->getData('postAccommodation'), 'bool');
     $schedConf->updateSetting('postSupporters', $this->getData('postSupporters'), 'bool');
     $schedConf->updateSetting('postPayment', $this->getData('postPayment'), 'bool');
     //
     // Log the rest.
     //
     $dateFormatShort = Config::getVar('general', 'date_format_short');
     // Physical scheduled conference start date and end date
     if ($schedConf->getSetting('startDate') != $this->_data['startDate']) {
         ConferenceLog::logEvent($schedConf->getConferenceId(), $schedConf->getId(), CONFERENCE_LOG_CONFIGURATION, LOG_TYPE_DEFAULT, 0, 'log.timeline.startDateChanged', array('oldStartDate' => strftime($dateFormatShort, $schedConf->getSetting('startDate')), 'newStartDate' => strftime($dateFormatShort, $this->_data['startDate'])));
         $schedConf->updateSetting('startDate', $this->_data['startDate'], 'date');
     }
     if ($schedConf->getSetting('endDate') != $this->_data['endDate']) {
         ConferenceLog::logEvent($schedConf->getConferenceId(), $schedConf->getId(), CONFERENCE_LOG_CONFIGURATION, LOG_TYPE_DEFAULT, 0, 'log.timeline.endDateChanged', array('oldEndDate' => strftime($dateFormatShort, $schedConf->getSetting('endDate')), 'newEndDate' => strftime($dateFormatShort, $this->_data['endDate'])));
         $schedConf->updateSetting('endDate', $this->_data['endDate'], 'date');
     }
     if ($schedConf->getSetting('regAuthorOpenDate') != $this->_data['regAuthorOpenDate']) {
         ConferenceLog::logEvent($schedConf->getConferenceId(), $schedConf->getId(), CONFERENCE_LOG_CONFIGURATION, LOG_TYPE_DEFAULT, 0, 'log.timeline.regAuthorOpenDateChanged', array('oldRegAuthorOpenDate' => strftime($dateFormatShort, $schedConf->getSetting('regAuthorOpenDate')), 'newRegAuthorOpenDate' => strftime($dateFormatShort, $this->_data['regAuthorOpenDate'])));
         $schedConf->updateSetting('regAuthorOpenDate', $this->_data['regAuthorOpenDate'], 'date');
     }
     if ($schedConf->getSetting('regAuthorCloseDate') != $this->_data['regAuthorCloseDate']) {
         ConferenceLog::logEvent($schedConf->getConferenceId(), $schedConf->getId(), CONFERENCE_LOG_CONFIGURATION, LOG_TYPE_DEFAULT, 0, 'log.timeline.regAuthorCloseDateChanged', array('oldRegAuthorCloseDate' => strftime($dateFormatShort, $schedConf->getSetting('regAuthorCloseDate')), 'newRegAuthorCloseDate' => strftime($dateFormatShort, $this->_data['regAuthorCloseDate'])));
         $schedConf->updateSetting('regAuthorCloseDate', $this->_data['regAuthorCloseDate'], 'date');
     }
     if ($schedConf->getSetting('showCFPDate') != $this->_data['showCFPDate']) {
         ConferenceLog::logEvent($schedConf->getConferenceId(), $schedConf->getId(), CONFERENCE_LOG_CONFIGURATION, LOG_TYPE_DEFAULT, 0, 'log.timeline.showCFPDateChanged', array('oldShowCFPDate' => strftime($dateFormatShort, $schedConf->getSetting('showCFPDate')), 'newShowCFPDate' => strftime($dateFormatShort, $this->_data['showCFPDate'])));
         $schedConf->updateSetting('showCFPDate', $this->_data['showCFPDate'], 'date');
     }
     if ($schedConf->getSetting('submissionsOpenDate') != $this->_data['submissionsOpenDate']) {
         ConferenceLog::logEvent($schedConf->getConferenceId(), $schedConf->getId(), CONFERENCE_LOG_CONFIGURATION, LOG_TYPE_DEFAULT, 0, 'log.timeline.submissionsOpenDateChanged', array('oldSubmissionsOpenDate' => strftime($dateFormatShort, $schedConf->getSetting('submissionsOpenDate')), 'newSubmissionsOpenDate' => strftime($dateFormatShort, $this->_data['submissionsOpenDate'])));
         $schedConf->updateSetting('submissionsOpenDate', $this->_data['submissionsOpenDate'], 'date');
     }
     if ($schedConf->getSetting('submissionsCloseDate') != $this->_data['submissionsCloseDate']) {
         ConferenceLog::logEvent($schedConf->getConferenceId(), $schedConf->getId(), CONFERENCE_LOG_CONFIGURATION, LOG_TYPE_DEFAULT, 0, 'log.timeline.submissionsCloseDateChanged', array('oldSubmissionsCloseDate' => strftime($dateFormatShort, $schedConf->getSetting('submissionsCloseDate')), 'newSubmissionsCloseDate' => strftime($dateFormatShort, $this->_data['submissionsCloseDate'])));
         $schedConf->updateSetting('submissionsCloseDate', $this->_data['submissionsCloseDate'], 'date');
     }
     if ($schedConf->getSetting('regReviewerOpenDate') != $this->_data['regReviewerOpenDate']) {
         ConferenceLog::logEvent($schedConf->getConferenceId(), $schedConf->getId(), CONFERENCE_LOG_CONFIGURATION, LOG_TYPE_DEFAULT, 0, 'log.timeline.regReviewerOpenDateChanged', array('oldRegReviewerOpenDate' => strftime($dateFormatShort, $schedConf->getSetting('regReviewerOpenDate')), 'newRegReviewerOpenDate' => strftime($dateFormatShort, $this->_data['regReviewerOpenDate'])));
         $schedConf->updateSetting('regReviewerOpenDate', $this->_data['regReviewerOpenDate'], 'date');
     }
     if ($schedConf->getSetting('regReviewerCloseDate') != $this->_data['regReviewerCloseDate']) {
         ConferenceLog::logEvent($schedConf->getConferenceId(), $schedConf->getId(), CONFERENCE_LOG_CONFIGURATION, LOG_TYPE_DEFAULT, 0, 'log.timeline.regReviewerCloseDateChanged', array('oldRegReviewerCloseDate' => strftime($dateFormatShort, $schedConf->getSetting('regReviewerCloseDate')), 'newRegReviewerCloseDate' => strftime($dateFormatShort, $this->_data['regReviewerCloseDate'])));
         $schedConf->updateSetting('regReviewerCloseDate', $this->_data['regReviewerCloseDate'], 'date');
     }
     if ($schedConf->getSetting('postAbstractsDate') != $this->_data['postAbstractsDate']) {
         ConferenceLog::logEvent($schedConf->getConferenceId(), $schedConf->getId(), CONFERENCE_LOG_CONFIGURATION, LOG_TYPE_DEFAULT, 0, 'log.timeline.postAbstractsDateChanged', array('oldPostAbstractsDate' => strftime($dateFormatShort, $schedConf->getSetting('postAbstractsDate')), 'newPostAbstractsDate' => strftime($dateFormatShort, $this->_data['postAbstractsDate'])));
         $schedConf->updateSetting('postAbstractsDate', $this->_data['postAbstractsDate'], 'date');
     }
     if ($schedConf->getSetting('postAbstracts') != $this->_data['postAbstracts']) {
         ConferenceLog::logEvent($schedConf->getConferenceId(), $schedConf->getId(), CONFERENCE_LOG_CONFIGURATION, LOG_TYPE_DEFAULT, 0, 'log.timeline.postAbstractsChanged', array('oldPostAbstracts' => Locale::translate($schedConf->getSetting('postAbstracts') ? 'common.true' : 'common.false'), 'newPostAbstracts' => Locale::translate($this->_data['postAbstracts']) ? 'common.true' : 'common.false'));
         $schedConf->updateSetting('postAbstracts', $this->_data['postAbstracts'], 'bool');
     }
     if ($schedConf->getSetting('postScheduleDate') != $this->_data['postScheduleDate']) {
         ConferenceLog::logEvent($schedConf->getConferenceId(), $schedConf->getId(), CONFERENCE_LOG_CONFIGURATION, LOG_TYPE_DEFAULT, 0, 'log.timeline.postScheduleDateChanged', array('oldPostScheduleDate' => strftime($dateFormatShort, $schedConf->getSetting('postPapersDate')), 'newPostScheduleDate' => strftime($dateFormatShort, $this->_data['postPapersDate'])));
         $schedConf->updateSetting('postScheduleDate', $this->_data['postScheduleDate'], 'date');
     }
     if ($schedConf->getSetting('postSchedule') != $this->_data['postSchedule']) {
         ConferenceLog::logEvent($schedConf->getConferenceId(), $schedConf->getId(), CONFERENCE_LOG_CONFIGURATION, LOG_TYPE_DEFAULT, 0, 'log.timeline.postScheduleChanged', array('oldPostSchedule' => Locale::translate($schedConf->getSetting('postSchedule') ? 'common.true' : 'common.false'), 'newPostSchedule' => Locale::translate($this->_data['postSchedule'] ? 'common.true' : 'common.false')));
         $schedConf->updateSetting('postSchedule', $this->_data['postSchedule'], 'bool');
     }
     if ($schedConf->getSetting('postPapersDate') != $this->_data['postPapersDate']) {
         ConferenceLog::logEvent($schedConf->getConferenceId(), $schedConf->getId(), CONFERENCE_LOG_CONFIGURATION, LOG_TYPE_DEFAULT, 0, 'log.timeline.postPapersDateChanged', array('oldPostPapersDate' => strftime($dateFormatShort, $schedConf->getSetting('postPapersDate')), 'newPostPapersDate' => strftime($dateFormatShort, $this->_data['postPapersDate'])));
         $schedConf->updateSetting('postPapersDate', $this->_data['postPapersDate'], 'date');
     }
     if ($schedConf->getSetting('postPapers') != $this->_data['postPapers']) {
         ConferenceLog::logEvent($schedConf->getConferenceId(), $schedConf->getId(), CONFERENCE_LOG_CONFIGURATION, LOG_TYPE_DEFAULT, 0, 'log.timeline.postPapersChanged', array('oldPostPapers' => Locale::translate($schedConf->getSetting('postPapers') ? 'common.true' : 'common.false'), 'newPostPapers' => Locale::translate($this->_data['postPapers'] ? 'common.true' : 'common.false')));
         $schedConf->updateSetting('postPapers', $this->_data['postPapers'], 'bool');
     }
     if ($schedConf->getSetting('delayOpenAccessDate') != $this->_data['delayOpenAccessDate']) {
         ConferenceLog::logEvent($schedConf->getConferenceId(), $schedConf->getId(), CONFERENCE_LOG_CONFIGURATION, LOG_TYPE_DEFAULT, 0, 'log.timeline.delayOpenAccessDateChanged', array('oldDelayOpenAccessDate' => strftime($dateFormatShort, $schedConf->getSetting('delayOpenAccessDate')), 'newDelayOpenAccessDate' => strftime($dateFormatShort, $this->_data['delayOpenAccessDate'])));
         $schedConf->updateSetting('delayOpenAccessDate', $this->_data['delayOpenAccessDate'], 'date');
     }
     if ($schedConf->getSetting('delayOpenAccess') != $this->_data['delayOpenAccess']) {
         ConferenceLog::logEvent($schedConf->getConferenceId(), $schedConf->getId(), CONFERENCE_LOG_CONFIGURATION, LOG_TYPE_DEFAULT, 0, 'log.timeline.delayOpenAccessChanged', array('oldDelayOpenAccess' => Locale::translate($schedConf->getSetting('delayOpenAccess') ? 'common.true' : 'common.false'), 'newDelayOpenAccess' => Locale::translate($this->_data['delayOpenAccess'] ? 'common.true' : 'common.false')));
         $schedConf->updateSetting('delayOpenAccess', $this->_data['delayOpenAccess'], 'bool');
     }
     if ($schedConf->getSetting('closeCommentsDate') != $this->_data['closeCommentsDate']) {
         ConferenceLog::logEvent($schedConf->getConferenceId(), $schedConf->getId(), CONFERENCE_LOG_CONFIGURATION, LOG_TYPE_DEFAULT, 0, 'log.timeline.closeCommentsDateChanged', array('oldCloseCommentsDate' => strftime($dateFormatShort, $schedConf->getSetting('closeCommentsDate')), 'newCloseCommentsDate' => strftime($dateFormatShort, $this->_data['closeCommentsDate'])));
         $schedConf->updateSetting('closeCommentsDate', $this->_data['closeCommentsDate'], 'date');
     }
     if ($schedConf->getSetting('closeComments') != $this->_data['closeComments']) {
         ConferenceLog::logEvent($schedConf->getConferenceId(), $schedConf->getId(), CONFERENCE_LOG_CONFIGURATION, LOG_TYPE_DEFAULT, 0, 'log.timeline.closeCommentsChanged', array('oldCloseComments' => Locale::translate($schedConf->getSetting('closeComments') ? 'common.true' : 'common.false'), 'newCloseComments' => Locale::translate($this->_data['closeComments'] ? 'common.true' : 'common.false')));
         $schedConf->updateSetting('closeComments', $this->_data['closeComments'], 'bool');
     }
 }
 /**
  * Validate a given input against the property specification
  *
  * The given value must validate against at least one of the
  * allowed types. The first allowed type id will be returned as
  * validation result. If the given value fits none of the allowed
  * types, then we'll return 'false'.
  *
  * @param $value mixed the input to be validated
  * @param $locale string the locale to be used for validation
  * @return array|boolean an array with a single entry of the format
  *  "type => additional type parameter" against which the value
  *  validated or boolean false if not validated at all.
  */
 function isValid($value, $locale = null)
 {
     // We never accept null values or arrays.
     if (is_null($value) || is_array($value)) {
         return false;
     }
     // Translate the locale.
     if (is_null($locale)) {
         $locale = '';
     }
     // MetadataProperty::getSupportedTypes() returns an ordered
     // list of possible meta-data types with the most specific
     // type coming first so that we always correctly identify
     // specializations (e.g. a date is a specialized string).
     $allowedTypes = $this->getAllowedTypes();
     foreach (MetadataProperty::getSupportedTypes() as $testedType) {
         if (isset($allowedTypes[$testedType])) {
             foreach ($allowedTypes[$testedType] as $allowedTypeParam) {
                 // Type specific validation
                 switch ($testedType) {
                     case METADATA_PROPERTY_TYPE_COMPOSITE:
                         // Composites can either be represented by a meta-data description
                         // or by a string of the form AssocType:AssocId if the composite
                         // has already been persisted in the database.
                         switch (true) {
                             // Test for MetadataDescription format
                             case is_a($value, 'MetadataDescription'):
                                 $assocType = $value->getAssocType();
                                 break;
                                 // Test for AssocType:AssocId format
                             // Test for AssocType:AssocId format
                             case is_string($value):
                                 $valueParts = explode(':', $value);
                                 if (count($valueParts) != 2) {
                                     break 2;
                                 }
                                 // break the outer switch
                                 list($assocType, $assocId) = $valueParts;
                                 if (!(is_numeric($assocType) && is_numeric($assocId))) {
                                     break 2;
                                 }
                                 // break the outer switch
                                 $assocType = (int) $assocType;
                                 break;
                             default:
                                 // None of the allowed types
                                 break;
                         }
                         // Check that the association type matches
                         // with the allowed association type (which
                         // is configured as an additional type parameter).
                         if (isset($assocType) && $assocType === $allowedTypeParam) {
                             return array(METADATA_PROPERTY_TYPE_COMPOSITE => $assocType);
                         }
                         break;
                     case METADATA_PROPERTY_TYPE_VOCABULARY:
                         // Interpret the type parameter of this type like this:
                         // symbolic[:assoc-type:assoc-id]. If no assoc type/id are
                         // given then we assume :0:0 to represent site-wide vocabs.
                         $vocabNameParts = explode(':', $allowedTypeParam);
                         $vocabNamePartsCount = count($vocabNameParts);
                         switch ($vocabNamePartsCount) {
                             case 1:
                                 // assume a site-wide vocabulary
                                 $symbolic = $allowedTypeParam;
                                 $assocType = $assocId = 0;
                                 break;
                             case 3:
                                 // assume a context-specific vocabulary
                                 list($symbolic, $assocType, $assocId) = $vocabNameParts;
                                 break;
                             default:
                                 // Invalid configuration
                                 assert(false);
                         }
                         if (is_string($value)) {
                             // Try to translate the string value into a controlled vocab entry
                             $controlledVocabEntryDao =& DAORegistry::getDao('ControlledVocabEntryDAO');
                             /* @var $controlledVocabEntryDao ControlledVocabEntryDAO */
                             if (!is_null($controlledVocabEntryDao->getBySetting($value, $symbolic, $assocType, $assocId, 'name', $locale))) {
                                 // The string was successfully translated so mark it as "valid".
                                 return array(METADATA_PROPERTY_TYPE_VOCABULARY => $allowedTypeParam);
                             }
                         }
                         if (is_integer($value)) {
                             // Validate with controlled vocabulary validator
                             import('lib.pkp.classes.validation.ValidatorControlledVocab');
                             $validator = new ValidatorControlledVocab($symbolic, $assocType, $assocId);
                             if ($validator->isValid($value)) {
                                 return array(METADATA_PROPERTY_TYPE_VOCABULARY => $allowedTypeParam);
                             }
                         }
                         break;
                     case METADATA_PROPERTY_TYPE_URI:
                         // Validate with the URI validator
                         import('lib.pkp.classes.validation.ValidatorUri');
                         $validator = new ValidatorUri();
                         if ($validator->isValid($value)) {
                             return array(METADATA_PROPERTY_TYPE_URI => null);
                         }
                         break;
                     case METADATA_PROPERTY_TYPE_DATE:
                         // We allow the following patterns:
                         // YYYY-MM-DD, YYYY-MM and YYYY
                         $datePattern = '/^[0-9]{4}(-[0-9]{2}(-[0-9]{2})?)?$/';
                         if (!preg_match($datePattern, $value)) {
                             break;
                         }
                         // Check whether the given string is really a valid date
                         $dateParts = explode('-', $value);
                         // Set the day and/or month to 1 if not set
                         $dateParts = array_pad($dateParts, 3, 1);
                         // Extract the date parts
                         list($year, $month, $day) = $dateParts;
                         // Validate the date (only leap days will pass unnoticed ;-) )
                         // Who invented this argument order?
                         if (checkdate($month, $day, $year)) {
                             return array(METADATA_PROPERTY_TYPE_DATE => null);
                         }
                         break;
                     case METADATA_PROPERTY_TYPE_INTEGER:
                         if (is_integer($value)) {
                             return array(METADATA_PROPERTY_TYPE_INTEGER => null);
                         }
                         break;
                     case METADATA_PROPERTY_TYPE_STRING:
                         if (is_string($value)) {
                             return array(METADATA_PROPERTY_TYPE_STRING => null);
                         }
                         break;
                     default:
                         // Unknown type. As we validate type in the setter, this
                         // should be unreachable code.
                         assert(false);
                 }
             }
         }
     }
     // Return false if the value didn't validate against any
     // of the allowed types.
     return false;
 }
Exemple #16
0
 /**
  * Create initial required data.
  * @return boolean
  */
 function createData()
 {
     // Add initial site data
     $locale = $this->getParam('locale');
     $siteDao =& DAORegistry::getDAO('SiteDAO', $this->dbconn);
     $site = new Site();
     $site->setRedirect(0);
     $site->setMinPasswordLength(INSTALLER_DEFAULT_MIN_PASSWORD_LENGTH);
     $site->setPrimaryLocale($locale);
     $site->setInstalledLocales($this->installedLocales);
     $site->setSupportedLocales($this->installedLocales);
     if (!$siteDao->insertSite($site)) {
         $this->setError(INSTALLER_ERROR_DB, $this->dbconn->errorMsg());
         return false;
     }
     $siteSettingsDao =& DAORegistry::getDAO('SiteSettingsDAO');
     $siteSettingsDao->updateSetting('title', array($locale => __(INSTALLER_DEFAULT_SITE_TITLE)), null, true);
     $siteSettingsDao->updateSetting('contactName', array($locale => __(INSTALLER_DEFAULT_SITE_TITLE)), null, true);
     $siteSettingsDao->updateSetting('contactEmail', array($locale => $this->getParam('adminEmail')), null, true);
     // Add initial site administrator user
     $userDao =& DAORegistry::getDAO('UserDAO', $this->dbconn);
     $user = new User();
     $user->setUsername($this->getParam('adminUsername'));
     $user->setPassword(Validation::encryptCredentials($this->getParam('adminUsername'), $this->getParam('adminPassword'), $this->getParam('encryption')));
     $user->setFirstName($user->getUsername());
     $user->setLastName('');
     $user->setEmail($this->getParam('adminEmail'));
     if (!$userDao->insertUser($user)) {
         $this->setError(INSTALLER_ERROR_DB, $this->dbconn->errorMsg());
         return false;
     }
     $roleDao =& DAORegistry::getDao('RoleDAO', $this->dbconn);
     $role = new Role();
     $role->setConferenceId(0);
     $role->setUserId($user->getId());
     $role->setRoleId(ROLE_ID_SITE_ADMIN);
     if (!$roleDao->insertRole($role)) {
         $this->setError(INSTALLER_ERROR_DB, $this->dbconn->errorMsg());
         return false;
     }
     // Install email template list and data for each locale
     $emailTemplateDao =& DAORegistry::getDAO('EmailTemplateDAO');
     $emailTemplateDao->installEmailTemplates($emailTemplateDao->getMainEmailTemplatesFilename());
     foreach ($this->installedLocales as $locale) {
         $emailTemplateDao->installEmailTemplateData($emailTemplateDao->getMainEmailTemplateDataFilename($locale));
     }
     // Add initial plugin data to versions table
     $versionDao =& DAORegistry::getDAO('VersionDAO');
     import('site.VersionCheck');
     $categories = PluginRegistry::getCategories();
     foreach ($categories as $category) {
         PluginRegistry::loadCategory($category, true);
         $plugins = PluginRegistry::getPlugins($category);
         foreach ($plugins as $plugin) {
             $versionFile = $plugin->getPluginPath() . '/version.xml';
             if (FileManager::fileExists($versionFile)) {
                 $versionInfo =& VersionCheck::parseVersionXML($versionFile);
                 $pluginVersion = $versionInfo['version'];
                 $pluginVersion->setCurrent(1);
                 $versionDao->insertVersion($pluginVersion);
             } else {
                 $pluginVersion = new Version();
                 $pluginVersion->setMajor(1);
                 $pluginVersion->setMinor(0);
                 $pluginVersion->setRevision(0);
                 $pluginVersion->setBuild(0);
                 $pluginVersion->setDateInstalled(Core::getCurrentDate());
                 $pluginVersion->setCurrent(1);
                 $pluginVersion->setProductType('plugins.' . $category);
                 $pluginVersion->setProduct(basename($plugin->getPluginPath()));
                 $versionDao->insertVersion($pluginVersion);
             }
         }
     }
     return true;
 }
Exemple #17
0
 /**
  * Create initial required data.
  * @return boolean
  */
 function createData()
 {
     if ($this->getParam('manualInstall')) {
         // Add insert statements for default data
         // FIXME use ADODB data dictionary?
         $this->executeSQL(sprintf('INSERT INTO site (primary_locale, installed_locales) VALUES (\'%s\', \'%s\')', $this->getParam('locale'), join(':', $this->installedLocales)));
         $this->executeSQL(sprintf('INSERT INTO site_settings (setting_name, setting_type, setting_value, locale) VALUES (\'%s\', \'%s\', \'%s\', \'%s\')', 'title', 'string', addslashes(Locale::translate(INSTALLER_DEFAULT_SITE_TITLE)), $this->getParam('locale')));
         $this->executeSQL(sprintf('INSERT INTO site_settings (setting_name, setting_type, setting_value, locale) VALUES (\'%s\', \'%s\', \'%s\', \'%s\')', 'contactName', 'string', addslashes(Locale::translate(INSTALLER_DEFAULT_SITE_TITLE)), $this->getParam('locale')));
         $this->executeSQL(sprintf('INSERT INTO site_settings (setting_name, setting_type, setting_value, locale) VALUES (\'%s\', \'%s\', \'%s\', \'%s\')', 'contactEmail', 'string', addslashes($this->getParam('adminEmail')), $this->getParam('locale')));
         $this->executeSQL(sprintf('INSERT INTO users (user_id, username, first_name, last_name, password, email, date_registered, date_last_login) VALUES (%d, \'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\')', 1, $this->getParam('adminUsername'), $this->getParam('adminUsername'), $this->getParam('adminUsername'), Validation::encryptCredentials($this->getParam('adminUsername'), $this->getParam('adminPassword'), $this->getParam('encryption')), $this->getParam('adminEmail'), Core::getCurrentDate(), Core::getCurrentDate()));
         $this->executeSQL(sprintf('INSERT INTO roles (press_id, user_id, role_id) VALUES (%d, %d, %d)', 0, 1, ROLE_ID_SITE_ADMIN));
         // Install email template list and data for each locale
         $emailTemplateDao =& DAORegistry::getDAO('EmailTemplateDAO');
         foreach ($emailTemplateDao->installEmailTemplates($emailTemplateDao->getMainEmailTemplatesFilename(), true) as $sql) {
             $this->executeSQL($sql);
         }
         foreach ($this->installedLocales as $locale) {
             foreach ($emailTemplateDao->installEmailTemplateData($emailTemplateDao->getMainEmailTemplateDataFilename($locale), true) as $sql) {
                 $this->executeSQL($sql);
             }
         }
     } else {
         // Add initial site data
         $locale = $this->getParam('locale');
         $siteDao =& DAORegistry::getDAO('SiteDAO', $this->dbconn);
         $site = new Site();
         $site->setRedirect(0);
         $site->setMinPasswordLength(INSTALLER_DEFAULT_MIN_PASSWORD_LENGTH);
         $site->setPrimaryLocale($locale);
         $site->setInstalledLocales($this->installedLocales);
         $site->setSupportedLocales($this->installedLocales);
         if (!$siteDao->insertSite($site)) {
             $this->setError(INSTALLER_ERROR_DB, $this->dbconn->errorMsg());
             return false;
         }
         // Install email template list and data for each locale
         $emailTemplateDao =& DAORegistry::getDAO('EmailTemplateDAO');
         $emailTemplateDao->installEmailTemplates($emailTemplateDao->getMainEmailTemplatesFilename());
         foreach ($this->installedLocales as $locale) {
             $emailTemplateDao->installEmailTemplateData($emailTemplateDao->getMainEmailTemplateDataFilename($locale));
         }
         $siteSettingsDao =& DAORegistry::getDAO('SiteSettingsDAO');
         $siteSettingsDao->updateSetting('title', array($locale => Locale::translate(INSTALLER_DEFAULT_SITE_TITLE)), null, true);
         $siteSettingsDao->updateSetting('contactName', array($locale => Locale::translate(INSTALLER_DEFAULT_SITE_TITLE)), null, true);
         $siteSettingsDao->updateSetting('contactEmail', array($locale => $this->getParam('adminEmail')), null, true);
         // Add initial site administrator user
         $userDao =& DAORegistry::getDAO('UserDAO', $this->dbconn);
         $user = new User();
         $user->setUsername($this->getParam('adminUsername'));
         $user->setPassword(Validation::encryptCredentials($this->getParam('adminUsername'), $this->getParam('adminPassword'), $this->getParam('encryption')));
         $user->setFirstName($user->getUsername());
         $user->setLastName('');
         $user->setEmail($this->getParam('adminEmail'));
         if (!$userDao->insertUser($user)) {
             $this->setError(INSTALLER_ERROR_DB, $this->dbconn->errorMsg());
             return false;
         }
         // Create an admin user group
         Locale::requireComponents(array(LOCALE_COMPONENT_OMP_DEFAULT_SETTINGS));
         $userGroupDao =& DAORegistry::getDao('UserGroupDAO', $this->dbconn);
         $adminUserGroup = new UserGroup();
         $adminUserGroup->setRoleId(ROLE_ID_SITE_ADMIN);
         $adminUserGroup->setContextId(0);
         $adminUserGroup->setPath(ROLE_PATH_SITE_ADMIN);
         $adminUserGroup->setDefault(true);
         foreach ($this->installedLocales as $locale) {
             $name = Locale::translate('default.groups.name.siteAdmin', array(), $locale);
             $namePlural = Locale::translate('default.groups.plural.siteAdmin', array(), $locale);
             $adminUserGroup->setData('name', $name, $locale);
             $adminUserGroup->setData('namePlural', $namePlural, $locale);
         }
         if (!$userGroupDao->insertUserGroup($adminUserGroup)) {
             $this->setError(INSTALLER_ERROR_DB, $this->dbconn->errorMsg());
             return false;
         }
         // put the installer into this user group
         if (!$userGroupDao->assignUserToGroup($user->getId(), $adminUserGroup->getId())) {
             $this->setError(INSTALLER_ERROR_DB, $this->dbconn->errorMsg());
             return false;
         }
     }
     return true;
 }
 /**
  * Get all scheduled tasks that needs to be executed.
  * @return array
  */
 function _getTasksToRun()
 {
     $tasksToRun = array();
     $isEnabled = $this->getSetting(0, 'enabled');
     if ($isEnabled) {
         $taskDao =& DAORegistry::getDao('ScheduledTaskDAO');
         // Grab the scheduled scheduled tree
         $scheduledTasks = $this->getSetting(0, 'crontab');
         if (is_null($scheduledTasks)) {
             $this->_parseCrontab();
             $scheduledTasks = $this->getSetting(0, 'crontab');
         }
         foreach ($scheduledTasks as $task) {
             // We don't allow tasks without frequency, see _parseCronTab().
             $frequency = new XMLNode();
             $frequency->setAttribute(key($task['frequency']), current($task['frequency']));
             $canExecute = ScheduledTaskHelper::checkFrequency($task['className'], $frequency);
             if ($canExecute) {
                 $tasksToRun[] = $task;
             }
         }
     }
     return $tasksToRun;
 }
 /**
  * Response to Meeting Scheduler
  * Added by EL on March 13th 2013
  */
 function replyMeeting()
 {
     $meetingId = Request::getUserVar('meetingId');
     $submissionId = Request::getUserVar('submissionId');
     $user =& Request::getUser();
     $userId = $user->getId();
     $meetingAttendanceDao =& DAORegistry::getDao('MeetingAttendanceDAO');
     $meetingAttendance = $meetingAttendanceDao->getMeetingAttendance($meetingId, $userId);
     $meetingAttendance->setIsAttending(Request::getUserVar('isAttending'));
     $meetingAttendance->setRemarks(Request::getUserVar('remarks'));
     $meetingAttendanceDao =& DAORegistry::getDao('MeetingAttendanceDAO');
     $meetingAttendanceDao->updateReplyOfAttendance($meetingAttendance);
     Request::redirect(null, 'author', 'submissionReview', $submissionId);
 }
Exemple #20
0
 /**
  * @see PKPPageRouter::loadHandler()
  */
 function callbackLoadHandler($hookName, $args)
 {
     $isEnabled = $this->getSetting(0, 'enabled');
     if ($isEnabled) {
         $taskDao = DAORegistry::getDao('ScheduledTaskDAO');
         // Grab the scheduled scheduled tree
         $scheduledTasks = $this->getSetting(0, 'crontab');
         if (is_null($scheduledTasks)) {
             $this->_parseCrontab();
             $scheduledTasks = $this->getSetting(0, 'crontab');
         }
         foreach ($scheduledTasks as $task) {
             // We don't allow tasks without frequency, see _parseCronTab().
             $frequency = new XMLNode();
             $frequency->setAttribute(key($task['frequency']), current($task['frequency']));
             $canExecute = ScheduledTaskHelper::checkFrequency($task['className'], $frequency);
             if ($canExecute) {
                 // Strip off the package name(s) to get the base class name
                 $className = $task['className'];
                 $pos = strrpos($className, '.');
                 if ($pos === false) {
                     $baseClassName = $className;
                 } else {
                     $baseClassName = substr($className, $pos + 1);
                 }
                 $taskArgs = array();
                 if (isset($task['args'])) {
                     $taskArgs = $task['args'];
                 }
                 // There's a race here. Several requests may come in closely spaced.
                 // Each may decide it's time to run scheduled tasks, and more than one
                 // can happily go ahead and do it before the "last run" time is updated.
                 // By updating the last run time as soon as feasible, we can minimize
                 // the race window. TODO: there ought to be a safer way of doing this.
                 $taskDao->updateLastRunTime($className, time());
                 // Load and execute the task
                 import($className);
                 $task = new $baseClassName($taskArgs);
                 $task->execute();
             }
         }
     }
     return false;
 }