00001 <?php
00002
00015
00016
00017 import("manager.form.schedConfSetup.SchedConfSetupForm");
00018
00019 class SchedConfSetupStep2Form extends SchedConfSetupForm {
00020
00021 function SchedConfSetupStep2Form() {
00022 $settings = array(
00023 'reviewMode' => 'int',
00024 'previewAbstracts' => 'bool',
00025 'acceptSupplementaryReviewMaterials' => 'bool',
00026 'copySubmissionAckPrimaryContact' => 'bool',
00027 'copySubmissionAckSpecified' => 'bool',
00028 'copySubmissionAckAddress' => 'string',
00029 'cfpMessage' => 'string',
00030 'authorGuidelines' => 'string',
00031 'submissionChecklist' => 'object',
00032 'metaDiscipline' => 'bool',
00033 'metaDisciplineExamples' => 'string',
00034 'metaSubjectClass' => 'bool',
00035 'metaSubjectClassTitle' => 'string',
00036 'metaSubjectClassUrl' => 'string',
00037 'metaSubject' => 'bool',
00038 'metaSubjectExamples' => 'string',
00039 'metaCoverage' => 'bool',
00040 'metaCoverageGeoExamples' => 'string',
00041 'metaCoverageChronExamples' => 'string',
00042 'metaCoverageResearchSampleExamples' => 'string',
00043 'metaType' => 'bool',
00044 'metaTypeExamples' => 'string',
00045 'metaCitations' => 'bool',
00046 'enablePublicPaperId' => 'bool',
00047 'enablePublicSuppFileId' => 'bool'
00048 );
00049
00050 $this->addCheck(new FormValidatorEmail($this, 'copySubmissionAckAddress', 'optional', 'user.profile.form.emailRequired'));
00051
00052 parent::SchedConfSetupForm(2, $settings);
00053 }
00054
00058 function initData() {
00059 parent::initData();
00060
00061 $schedConf =& Request::getSchedConf();
00062 $paperTypeDao =& DAORegistry::getDAO('PaperTypeDAO');
00063 $paperTypeEntryIterator = $paperTypeDao->getPaperTypes($schedConf->getId());
00064 $paperTypes = array();
00065 $i=0;
00066 while ($paperTypeEntry =& $paperTypeEntryIterator->next()) {
00067 $paperTypes[$paperTypeEntry->getId()] = array(
00068 'name' => $paperTypeEntry->getName(null),
00069 'description' => $paperTypeEntry->getDescription(null),
00070 'abstractLength' => $paperTypeEntry->getAbstractLength(),
00071 'length' => $paperTypeEntry->getLength(),
00072 'seq' => $i++
00073 );
00074 unset($paperTypeEntry);
00075 }
00076 $this->_data['paperTypes'] = $paperTypes;
00077 }
00078
00082 function readInputData() {
00083 $settingNames = array_keys($this->settings);
00084 $settingNames[] = 'paperTypes';
00085 $this->readUserVars($settingNames);
00086 }
00087
00092 function getLocaleFieldNames() {
00093 return array('cfpMessage', 'authorGuidelines', 'submissionChecklist', 'metaDisciplineExamples', 'metaSubjectClassTitle', 'metaSubjectExamples', 'metaCoverageGeoExamples', 'metaCoverageChronExamples', 'metaCoverageResearchSampleExamples', 'metaTypeExamples', 'paperTypes');
00094 }
00095
00096 function display() {
00097 $schedConf =& Request::getSchedConf();
00098 $templateMgr =& TemplateManager::getManager();
00099
00100 import('mail.MailTemplate');
00101 $mail = new MailTemplate('SUBMISSION_ACK');
00102 if ($mail->isEnabled()) {
00103 $templateMgr->assign('submissionAckEnabled', true);
00104 }
00105
00106 parent::display();
00107 }
00108
00112 function validate() {
00113
00114
00115 $primaryLocale = AppLocale::getPrimaryLocale();
00116 if (isset($this->_data['paperTypes'])) {
00117 $paperTypes =& $this->_data['paperTypes'];
00118 if (!is_array($paperTypes)) return false;
00119
00120 foreach ($paperTypes as $paperTypeId => $paperType) {
00121 if (!isset($paperType['name'][$primaryLocale]) || empty($paperType['name'][$primaryLocale])) {
00122 $fieldName = 'paperTypeName-' . $paperTypeId;
00123 $this->addError($fieldName, __('manager.schedConfSetup.submissions.typeOfSubmission.nameMissing', array('primaryLocale' => $primaryLocale)));
00124 $this->addErrorField($fieldName);
00125 }
00126 if (isset($paperType['abstractLength']) && !empty($paperType['abstractLength']) && (!is_numeric($paperType['abstractLength']) || $paperType['abstractLength'] <= 0)) {
00127 $fieldName = 'paperTypeAbstractLength-' . $paperTypeId;
00128 $this->addError($fieldName, __('manager.schedConfSetup.submissions.typeOfSubmission.abstractLengthInvalid'));
00129 $this->addErrorField($fieldName);
00130 }
00131 }
00132 }
00133
00134 return parent::validate();
00135 }
00136
00140 function execute() {
00141 $schedConf =& Request::getSchedConf();
00142 $paperTypeIds = array();
00143
00144 $paperTypeDao =& DAORegistry::getDAO('PaperTypeDAO');
00145 $paperTypeEntryDao =& DAORegistry::getDAO('PaperTypeEntryDAO');
00146
00147 if (isset($this->_data['paperTypes'])) {
00148 $paperTypes =& $this->_data['paperTypes'];
00149 $paperTypesEntry =& $paperTypeDao->build($schedConf->getId());
00150 $i = 0;
00151 foreach ($paperTypes as $paperTypeId => $paperType) {
00152 if (is_numeric($paperTypeId)) {
00153
00154 $paperTypeEntry = $paperTypeEntryDao->getById($paperTypeId, $paperTypesEntry->getId());
00155 if (!$paperTypeEntry) continue;
00156 } else {
00157
00158 $paperTypeEntry = $paperTypeEntryDao->newDataObject();
00159 $paperTypeEntry->setControlledVocabId($paperTypesEntry->getId());
00160 }
00161 $paperTypeEntry->setName($paperType['name'], null);
00162 $paperTypeEntry->setDescription($paperType['description'], null);
00163 $paperTypeEntry->setAbstractLength($paperType['abstractLength']);
00164 $paperTypeEntry->setLength($paperType['length']);
00165 $paperTypeEntry->setSequence($i++);
00166 if (is_numeric($paperTypeId)) {
00167 $paperTypeEntryDao->updateObject($paperTypeEntry);
00168 } else {
00169 $paperTypeEntryDao->insertObject($paperTypeEntry);
00170
00171 }
00172 $paperTypeIds[] = $paperTypeEntry->getId();
00173 }
00174 }
00175
00176
00177 $paperTypeEntryIterator = $paperTypeDao->getPaperTypes($schedConf->getId());
00178 while ($paperTypeEntry =& $paperTypeEntryIterator->next()) {
00179 if (!in_array($paperTypeEntry->getId(), $paperTypeIds))
00180 $paperTypeEntryDao->deleteObject($paperTypeEntry);
00181 unset($paperTypeEntry);
00182 }
00183
00184 return parent::execute();
00185 }
00186 }
00187
00188 ?>