classes/manager/form/ProgramSettingsForm.inc.php

Go to the documentation of this file.
00001 <?php
00002 
00015 //$Id$
00016 
00017 import('form.Form');
00018 
00019 class ProgramSettingsForm extends Form {
00020 
00022    var $settings;
00023 
00027    function ProgramSettingsForm() {
00028       parent::Form('manager/programSettings.tpl');
00029 
00030       $this->addCheck(new FormValidatorPost($this));
00031       
00032       $this->settings = array(
00033          'program' => 'string',
00034          'programFileTitle' => 'string'
00035       );
00036    }
00037 
00041    function display() {
00042       import('file.PublicFileManager');
00043       $site =& Request::getSite();
00044       $schedConf =& Request::getSchedConf();
00045 
00046       $templateMgr =& TemplateManager::getManager();
00047       $templateMgr->assign('helpTopicId','conference.currentConferences.program');
00048       $templateMgr->assign('publicSchedConfFilesDir', Request::getBaseUrl() . '/' . PublicFileManager::getSchedConfFilesPath($schedConf->getId()));
00049       $templateMgr->assign('programFile', $schedConf->getSetting('programFile'));
00050 
00051       parent::display();
00052    }
00053 
00057    function initData() {
00058       $schedConf =& Request::getSchedConf();
00059       
00060       $this->data = array();
00061       foreach (array_keys($this->settings) as $settingName) {
00062          $this->_data[$settingName] = $schedConf->getSetting($settingName);
00063       }
00064    }
00065 
00070    function getLocaleFieldNames() {
00071       return array_keys($this->settings);
00072    }
00073 
00077    function readInputData() {
00078       $this->readUserVars(array_keys($this->settings));
00079    }
00080 
00084    function execute() {
00085       $schedConf =& Request::getSchedConf();
00086       
00087       foreach ($this->_data as $name => $value) {
00088          $schedConf->updateSetting(
00089             $name,
00090             $value,
00091             $this->settings[$name],
00092             true
00093          );
00094       }
00095    }
00096    
00102    function uploadProgram($settingName, $locale) {
00103       $schedConf =& Request::getSchedConf();
00104 
00105       import('file.PublicFileManager');
00106       $fileManager = new PublicFileManager();
00107       if ($fileManager->uploadError($settingName)) return false;
00108       if ($fileManager->uploadedFileExists($settingName)) {
00109          $oldName = $fileManager->getUploadedFileName('programFile');
00110          $extension = $fileManager->getExtension($oldName);
00111          if (!$extension) {
00112             return false;
00113          }
00114          $uploadName = 'program-' . $locale . '.' . $extension;
00115          if ($fileManager->uploadSchedConfFile($schedConf->getId(), $settingName, $uploadName)) {
00116             $value = $schedConf->getSetting($settingName);
00117             $value[$locale] = array(
00118                'name' => $oldName,
00119                'uploadName' => $uploadName,
00120                'dateUploaded' => Core::getCurrentDate(),
00121             );
00122 
00123             $schedConf->updateSetting($settingName, $value, 'object', true);
00124             return true;
00125          }
00126       }
00127 
00128       return false;
00129    }
00130 
00136    function deleteProgram($settingName, $locale = null) {
00137       $schedConf =& Request::getSchedConf();
00138       $settingsDao =& DAORegistry::getDAO('SchedConfSettingsDAO');
00139       $setting = $schedConf->getSetting($settingName);
00140 
00141       import('file.PublicFileManager');
00142       $fileManager = new PublicFileManager();
00143       if ($fileManager->removeSchedConfFile($schedConf->getId(), $locale !== null ? $setting[$locale]['uploadName'] : $setting['uploadName'] )) {
00144          return $settingsDao->deleteSetting($schedConf->getId(), $settingName, $locale);
00145       } else {
00146          return false;
00147       }
00148       
00149    }
00150 }
00151 
00152 ?>

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