classes/manager/form/setup/ConferenceSetupForm.inc.php

Go to the documentation of this file.
00001 <?php
00002 
00019 //$Id$
00020 
00021 import("manager.form.setup.ConferenceSetupForm");
00022 import('form.Form');
00023 
00024 class ConferenceSetupForm extends Form {
00025    var $step;
00026    var $settings;
00027 
00033    function ConferenceSetupForm($step, $settings) {
00034       parent::Form(sprintf('manager/setup/step%d.tpl', $step));
00035       $this->step = $step;
00036       $this->settings = $settings;
00037       $this->addCheck(new FormValidatorPost($this));
00038    }
00039 
00043    function display() {
00044       $templateMgr =& TemplateManager::getManager();
00045       $templateMgr->assign('setupStep', $this->step);
00046       $templateMgr->assign('helpTopicId', 'conference.generalManagement.websiteManagement');
00047       $templateMgr->setCacheability(CACHEABILITY_MUST_REVALIDATE);
00048       parent::display();
00049    }
00050 
00054    function initData() {
00055       $conference =& Request::getConference();
00056       $this->_data = $conference->getSettings();
00057    }
00058 
00062    function readInputData() {    
00063       $this->readUserVars(array_keys($this->settings));
00064    }
00065 
00069    function execute() {
00070       $conference =& Request::getConference();
00071       $settingsDao =& DAORegistry::getDAO('ConferenceSettingsDAO');
00072 
00073       foreach ($this->_data as $name => $value) {
00074          if (isset($this->settings[$name])) {
00075             $isLocalized = in_array($name, $this->getLocaleFieldNames());
00076             $settingsDao->updateSetting(
00077                $conference->getId(),
00078                $name,
00079                $value,
00080                $this->settings[$name],
00081                $isLocalized
00082             );
00083          }
00084       }
00085    }
00086 
00092    function uploadImage($settingName, $locale) {
00093       $conference =& Request::getConference();
00094       $settingsDao =& DAORegistry::getDAO('ConferenceSettingsDAO');
00095       $faviconTypes = array('.ico', '.png', '.gif');
00096 
00097       import('file.PublicFileManager');
00098       $fileManager = new PublicFileManager();
00099       if ($fileManager->uploadError($settingName)) return false;
00100       if ($fileManager->uploadedFileExists($settingName)) {
00101          $type = $fileManager->getUploadedFileType($settingName);
00102          $extension = $fileManager->getImageExtension($type);
00103          if (!$extension) {
00104             return false;
00105          }
00106          if ($settingName == 'conferenceFavicon' && !in_array($extension, $faviconTypes)) {
00107             return false;
00108          }
00109          $uploadName = $settingName . '_' . $locale . $extension;
00110          if ($fileManager->uploadConferenceFile($conference->getId(), $settingName, $uploadName)) {
00111             // Get image dimensions
00112             $filePath = $fileManager->getConferenceFilesPath($conference->getId());
00113             list($width, $height) = getimagesize($filePath . '/' . $uploadName);
00114 
00115             $value = $conference->getSetting($settingName);
00116             $value[$locale] = array(
00117                'name' => $fileManager->getUploadedFileName($settingName),
00118                'uploadName' => $uploadName,
00119                'width' => $width,
00120                'height' => $height,
00121                'dateUploaded' => Core::getCurrentDate()
00122             );
00123 
00124             $settingsDao->updateSetting($conference->getId(), $settingName, $value, 'object', true);
00125             return true;
00126          }
00127       }
00128 
00129       return false;
00130    }
00131 
00137    function deleteImage($settingName, $locale = null) {
00138       $conference =& Request::getConference();
00139       $settingsDao =& DAORegistry::getDAO('ConferenceSettingsDAO');
00140       $setting = $settingsDao->getSetting($conference->getId(), $settingName);
00141 
00142       import('file.PublicFileManager');
00143       $fileManager = new PublicFileManager();
00144       if ($fileManager->removeConferenceFile($conference->getId(), $locale !== null ? $setting[$locale]['uploadName'] : $setting['uploadName'] )) {
00145          $returner = $settingsDao->deleteSetting($conference->getId(), $settingName, $locale);
00146          // Ensure page header is refreshed
00147          if ($returner) {
00148             $templateMgr =& TemplateManager::getManager();
00149             $templateMgr->assign(array(
00150                'displayPageHeaderTitle' => $conference->getPageHeaderTitle(),
00151                'displayPageHeaderLogo' => $conference->getPageHeaderLogo()
00152             ));
00153          }
00154          return $returner;
00155       } else {
00156          return false;
00157       }
00158    }
00159 }
00160 
00161 ?>

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