classes/admin/form/ConferenceSiteSettingsForm.inc.php

Go to the documentation of this file.
00001 <?php
00002 
00015 //$Id$
00016 
00017 import('db.DBDataXMLParser');
00018 import('form.Form');
00019 
00020 class ConferenceSiteSettingsForm extends Form {
00021 
00023    var $conferenceId;
00024 
00029    function ConferenceSiteSettingsForm($conferenceId = null) {
00030       parent::Form('admin/conferenceSettings.tpl');
00031 
00032       $this->conferenceId = isset($conferenceId) ? (int) $conferenceId : null;
00033 
00034       // Validation checks for this form
00035       $this->addCheck(new FormValidatorLocale($this, 'title', 'required', 'admin.conferences.form.titleRequired'));
00036       $this->addCheck(new FormValidator($this, 'conferencePath', 'required', 'admin.conferences.form.pathRequired'));
00037       $this->addCheck(new FormValidatorAlphaNum($this, 'conferencePath', 'required', 'admin.conferences.form.pathAlphaNumeric'));
00038       $this->addCheck(new FormValidatorCustom($this, 'conferencePath', 'required', 'admin.conferences.form.pathExists', create_function('$path,$form,$conferenceDao', 'return !$conferenceDao->conferenceExistsByPath($path) || ($form->getData(\'oldPath\') != null && $form->getData(\'oldPath\') == $path);'), array(&$this, DAORegistry::getDAO('ConferenceDAO'))));
00039       $this->addCheck(new FormValidatorPost($this));
00040    }
00041 
00045    function display() {
00046       $templateMgr =& TemplateManager::getManager();
00047       $templateMgr->assign('conferenceId', $this->conferenceId);
00048       $templateMgr->assign('helpTopicId', 'site.siteManagement');
00049       parent::display();
00050    }
00051 
00055    function initData() {
00056       if (isset($this->conferenceId)) {
00057          $conferenceDao =& DAORegistry::getDAO('ConferenceDAO');
00058          $conference =& $conferenceDao->getConference($this->conferenceId);
00059 
00060          if ($conference != null) {
00061             $this->_data = array(
00062                'title' => $conference->getTitle(null), // Localized
00063                'description' => $conference->getDescription(null), // Localized
00064                'conferencePath' => $conference->getPath(),
00065                'enabled' => $conference->getEnabled()
00066             );
00067 
00068          } else {
00069             $this->conferenceId = null;
00070          }
00071       }
00072       if (!isset($this->conferenceId)) {
00073          $this->_data = array(
00074             'enabled' => 1
00075          );
00076       }
00077    }
00078 
00083    function getLocaleFieldNames() {
00084       return array('title', 'description');
00085    }
00086 
00090    function readInputData() {
00091       $this->readUserVars(array('title', 'description', 'conferencePath', 'enabled'));
00092       $this->setData('enabled', (int)$this->getData('enabled'));
00093 
00094       if (isset($this->conferenceId)) {
00095          $conferenceDao =& DAORegistry::getDAO('ConferenceDAO');
00096          $conference =& $conferenceDao->getConference($this->conferenceId);
00097          $this->setData('oldPath', $conference->getPath());
00098       }
00099    }
00100 
00104    function execute() {
00105       $conferenceDao =& DAORegistry::getDAO('ConferenceDAO');
00106 
00107       if (isset($this->conferenceId)) {
00108          $conference =& $conferenceDao->getConference($this->conferenceId);
00109       }
00110 
00111       if (!isset($conference)) {
00112          $conference = new Conference();
00113       }
00114 
00115       $conference->setPath($this->getData('conferencePath'));
00116       $conference->setEnabled($this->getData('enabled'));
00117 
00118       if ($conference->getId() != null) {
00119          $conferenceDao->updateConference($conference);
00120       } else {
00121          $site =& Request::getSite();
00122 
00123          // Give it a default primary locale.
00124          $conference->setPrimaryLocale($site->getPrimaryLocale());
00125 
00126          $conferenceId = $conferenceDao->insertConference($conference);
00127          $conferenceDao->resequenceConferences();
00128 
00129          // Make the site administrator the conference manager
00130          $sessionManager =& SessionManager::getManager();
00131          $userSession =& $sessionManager->getUserSession();
00132          if ($userSession->getUserId() != null && $userSession->getUserId() != 0 && !empty($conferenceId)) {
00133             $roleDao =& DAORegistry::getDAO('RoleDAO');
00134 
00135             $role = new Role();
00136             $role->setConferenceId($conferenceId);
00137             $role->setSchedConfId(0);
00138             $role->setUserId($userSession->getUserId());
00139             $role->setRoleId(ROLE_ID_CONFERENCE_MANAGER);
00140             $roleDao->insertRole($role);
00141          }
00142 
00143          // Make the file directories for the conference
00144          import('file.FileManager');
00145          FileManager::mkdir(Config::getVar('files', 'files_dir') . '/conferences/' . $conferenceId);
00146          FileManager::mkdir(Config::getVar('files', 'files_dir') . '/conferences/' . $conferenceId . '/schedConfs');
00147          FileManager::mkdir(Config::getVar('files', 'public_files_dir') . '/conferences/' . $conferenceId);
00148          FileManager::mkdir(Config::getVar('files', 'public_files_dir') . '/conferences/' . $conferenceId . '/schedConfs');
00149 
00150          // Install default conference settings
00151          $conferenceSettingsDao =& DAORegistry::getDAO('ConferenceSettingsDAO');
00152          $titles = $this->getData('title');
00153          AppLocale::requireComponents(array(LOCALE_COMPONENT_OCS_DEFAULT));
00154          $conferenceSettingsDao->installSettings($conferenceId, Config::getVar('general', 'registry_dir') . '/conferenceSettings.xml', array(
00155             'privacyStatementUrl' => Request::url($this->getData('conferencePath'), 'index', 'about', 'submissions', null, null, 'privacyStatement'),
00156             'loginUrl' => Request::url('index', 'index', 'login'),
00157             'conferenceUrl' => Request::url($this->getData('conferencePath'), null),
00158             'conferencePath' => $this->getData('conferencePath'),
00159             'primaryLocale' => $site->getPrimaryLocale(),
00160             'aboutUrl' => Request::url($this->getData('conferencePath'), 'index', 'about', null),
00161             'accountUrl' => Request::url($this->getData('conferencePath'), 'index', 'user', 'register'),
00162             'conferenceName' => $titles[$site->getPrimaryLocale()]
00163          ));
00164 
00165          // Install the default RT versions.
00166          import('rt.ocs.ConferenceRTAdmin');
00167          $conferenceRtAdmin = new ConferenceRTAdmin($conferenceId);
00168          $conferenceRtAdmin->restoreVersions(false);
00169       }
00170 
00171       $conference->updateSetting('title', $this->getData('title'), 'string', true);
00172       $conference->updateSetting('description', $this->getData('description'), 'string', true);
00173 
00174 
00175       // Make sure all plugins are loaded for settings preload
00176       PluginRegistry::loadAllPlugins();
00177 
00178       HookRegistry::call('ConferenceSiteSettingsForm::execute', array(&$this, &$conference));
00179    }
00180 }
00181 
00182 ?>

Generated on 25 Jul 2013 for Open Conference Systems by  doxygen 1.4.7