pages/manager/ManagerAccommodationHandler.inc.php

Go to the documentation of this file.
00001 <?php
00002 
00015 //$Id$
00016 
00017 import('pages.manager.ManagerHandler');
00018 
00019 class ManagerAccommodationHandler extends ManagerHandler {
00023    function ManagerAccommodationHandler() {
00024       parent::ManagerHandler();
00025    }
00026 
00030    function accommodation() {
00031       $this->validate();
00032       $this->setupTemplate(true);
00033 
00034       $schedConf =& Request::getSchedConf();
00035       if (!$schedConf) Request::redirect (null, null, 'index');
00036 
00037       import('manager.form.AccommodationSettingsForm');
00038 
00039       $settingsForm = new AccommodationSettingsForm();
00040       if ($settingsForm->isLocaleResubmit()) {
00041          $settingsForm->readInputData();
00042       } else {
00043          $settingsForm->initData();
00044       }
00045       $settingsForm->display();
00046    }
00047 
00051    function saveAccommodationSettings() {
00052       $this->validate();
00053       $this->setupTemplate(true);
00054 
00055       $schedConf =& Request::getSchedConf();
00056       if (!$schedConf) Request::redirect (null, null, 'index');
00057 
00058       import('manager.form.AccommodationSettingsForm');
00059 
00060       $settingsForm = new AccommodationSettingsForm();
00061       $settingsForm->readInputData();
00062 
00063       $editData = false;
00064 
00065       $accommodationFiles =& $schedConf->getSetting('accommodationFiles');
00066       if (Request::getUserVar('uploadAccommodationFile')) {
00067          // Get a numeric key for this file.
00068          $thisFileKey = 0;
00069          if (isset($accommodationFiles[$settingsForm->getFormLocale()])) foreach ($accommodationFiles[$settingsForm->getFormLocale()] as $key => $junk) {
00070             $thisFileKey = $key + 1;
00071          }
00072 
00073          import('file.PublicFileManager');
00074          $fileManager = new PublicFileManager();
00075          $success = !$fileManager->uploadError('accommodationFile');
00076          if ($success && $success = $fileManager->uploadedFileExists('accommodationFile')) {
00077             $oldName = $fileManager->getUploadedFileName('accommodationFile');
00078             $extension = $fileManager->getExtension($oldName);
00079             if (!$extension) break;
00080             $uploadName = 'accommodation-' . $thisFileKey . '.' . $extension;
00081             if ($success && $success = $fileManager->uploadSchedConfFile($schedConf->getId(), 'accommodationFile', $uploadName)) {
00082                $value = array(
00083                   'name' => $oldName,
00084                   'uploadName' => $uploadName,
00085                   'dateUploaded' => Core::getCurrentDate(),
00086                   'title' => Request::getUserVar('accommodationFileTitle')
00087                );
00088                $accommodationFiles[$settingsForm->getFormLocale()][$thisFileKey] =& $value;
00089                $settingsForm->setData('accommodationFiles', $accommodationFiles);
00090                $settingsForm->setData('accommodationFileTitle', '');
00091                $schedConf->updateSetting('accommodationFiles', $accommodationFiles, 'object', true);
00092             }
00093          }
00094          if (!$success) {
00095             $settingsForm->addError('accommodationFiles', __('common.uploadFailed'));
00096          }
00097          $editData = true;
00098       } else {
00099          $formLocale = $settingsForm->getFormLocale();
00100          $deleteKey = null;
00101          if (isset($accommodationFiles[$formLocale])) {
00102             foreach ($accommodationFiles[$formLocale] as $key => $junk) {
00103                if (Request::getUserVar("deleteAccommodationFile-$formLocale-$key")) $deleteKey = $key;
00104             }
00105          }
00106          if ($deleteKey !== null) {
00107             import('file.PublicFileManager');
00108             $fileManager = new PublicFileManager();
00109             if ($fileManager->removeSchedConfFile($schedConf->getId(), $accommodationFiles[$formLocale][$deleteKey]['uploadName'])) {
00110                unset($accommodationFiles[$formLocale][$deleteKey]);
00111                $schedConf->updateSetting('accommodationFiles', $accommodationFiles, 'object', true);
00112             }
00113             $editData = true;
00114          }
00115       }
00116 
00117       if (!$editData && $settingsForm->validate()) {
00118          $settingsForm->execute();
00119 
00120          $templateMgr =& TemplateManager::getManager();
00121          $templateMgr->assign(array(
00122             'currentUrl' => Request::url(null, null, null, 'accommodation'),
00123             'pageTitle' => 'schedConf.accommodation',
00124             'message' => 'common.changesSaved',
00125             'backLink' => Request::url(null, null, Request::getRequestedPage()),
00126             'backLinkLabel' => 'manager.conferenceSiteManagement'
00127          ));
00128          $templateMgr->display('common/message.tpl');
00129 
00130       } else {
00131          $settingsForm->display();
00132       }
00133    }
00134 
00135 }
00136 ?>

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