pages/trackDirector/TrackDirectorHandler.inc.php

Go to the documentation of this file.
00001 <?php
00002 
00016 // $Id$
00017 
00018 
00019 // Filter track
00020 define('FILTER_TRACK_ALL', 0);
00021 
00022 import('submission.trackDirector.TrackDirectorAction');
00023 import('handler.Handler');
00024 
00025 class TrackDirectorHandler extends Handler {
00029    function TrackDirectorHandler() {
00030       parent::Handler();
00031    }
00032 
00038    function submissions($args, &$request) {
00039       $this->index($args, $request);
00040    }  
00041 
00045    function index($args) {
00046       $this->validate();
00047       $this->setupTemplate();
00048 
00049       $schedConf =& Request::getSchedConf();
00050       $schedConfId = $schedConf->getId();
00051       $user =& Request::getUser();
00052 
00053       // Get the user's search conditions, if any
00054       $searchField = Request::getUserVar('searchField');
00055       $searchMatch = Request::getUserVar('searchMatch');
00056       $search = Request::getUserVar('search');
00057 
00058       $trackDao =& DAORegistry::getDAO('TrackDAO');
00059       $trackDirectorSubmissionDao =& DAORegistry::getDAO('TrackDirectorSubmissionDAO');
00060 
00061       $page = isset($args[0]) ? $args[0] : '';
00062       $tracks =& $trackDao->getTrackTitles($schedConfId);
00063       
00064       $sort = Request::getUserVar('sort');
00065       $sort = isset($sort) ? $sort : 'id';
00066       $sortDirection = Request::getUserVar('sortDirection');
00067 
00068       $filterTrackOptions = array(
00069          FILTER_TRACK_ALL => AppLocale::Translate('director.allTracks')
00070       ) + $tracks;
00071 
00072       switch($page) {
00073          case 'submissionsAccepted':
00074             $functionName = 'getTrackDirectorSubmissionsAccepted';
00075             $helpTopicId = 'editorial.trackDirectorsRole.presentations';
00076             break;
00077          case 'submissionsArchives':
00078             $functionName = 'getTrackDirectorSubmissionsArchives';
00079             $helpTopicId = 'editorial.trackDirectorsRole.archives';
00080             break;
00081          default:
00082             $page = 'submissionsInReview';
00083             $functionName = 'getTrackDirectorSubmissionsInReview';
00084             $helpTopicId = 'editorial.trackDirectorsRole.review';
00085       }
00086 
00087       $filterTrack = Request::getUserVar('filterTrack');
00088       if ($filterTrack != '' && array_key_exists($filterTrack, $filterTrackOptions)) {
00089          $user->updateSetting('filterTrack', $filterTrack, 'int', $schedConfId);
00090       } else {
00091          $filterTrack = $user->getSetting('filterTrack', $schedConfId);
00092          if ($filterTrack == null) {
00093             $filterTrack = FILTER_TRACK_ALL;
00094             $user->updateSetting('filterTrack', $filterTrack, 'int', $schedConfId);
00095          }  
00096       }
00097 
00098       $rangeInfo = Handler::getRangeInfo('submissions', array($functionName, (string) $searchField, (string) $searchMatch, (string) $search));
00099       while (true) {
00100          $submissions =& $trackDirectorSubmissionDao->$functionName(
00101             $user->getId(),
00102             $schedConf->getId(),
00103             $filterTrack,
00104             $searchField,
00105             $searchMatch,
00106             $search,
00107             null,
00108             null,
00109             null,
00110             $sort=='status'?null:$rangeInfo,
00111             $sort,
00112             $sortDirection
00113          );
00114          if ($submissions->isInBounds()) break;
00115          unset($rangeInfo);
00116          $rangeInfo =& $submissions->getLastPageRangeInfo();
00117          unset($submissions);
00118       }
00119       
00120       if ($sort == 'status') {
00121          // Sort all submissions by status, which is too complex to do in the DB
00122          $submissionsArray = $submissions->toArray();
00123          unset($submissions);
00124          $compare = create_function('$s1, $s2', 'return strcmp($s1->getSubmissionStatus(), $s2->getSubmissionStatus());');
00125          usort ($submissionsArray, $compare);
00126          if($sortDirection == 'DESC') {
00127             $submissionsArray = array_reverse($submissionsArray);
00128          }
00129          // Convert submission array back to an ItemIterator class
00130          import('core.ArrayItemIterator');
00131          $submissions =& ArrayItemIterator::fromRangeInfo($submissionsArray, $rangeInfo);
00132       }
00133 
00134       $templateMgr =& TemplateManager::getManager();
00135       $templateMgr->assign('helpTopicId', $helpTopicId);
00136       $templateMgr->assign('trackOptions', $filterTrackOptions);
00137       $templateMgr->assign('filterTrack', $filterTrack);
00138       $templateMgr->assign_by_ref('submissions', $submissions);
00139       $templateMgr->assign('track', Request::getUserVar('track'));
00140       $templateMgr->assign('pageToDisplay', $page);
00141       $templateMgr->assign('trackDirector', $user->getFullName());
00142       $templateMgr->assign('yearOffsetFuture', SCHED_CONF_DATE_YEAR_OFFSET_FUTURE);
00143       $templateMgr->assign('durationOptions', $this->getDurationOptions());
00144       $templateMgr->assign('sort', $sort);
00145       $templateMgr->assign('sortDirection', $sortDirection);
00146       // Set search parameters
00147       $duplicateParameters = array(
00148          'searchField', 'searchMatch', 'search'
00149       );
00150       foreach ($duplicateParameters as $param)
00151          $templateMgr->assign($param, Request::getUserVar($param));
00152 
00153       $templateMgr->assign('reviewType', Array(
00154          REVIEW_STAGE_ABSTRACT => __('submission.abstract'),
00155          REVIEW_STAGE_PRESENTATION => __('submission.paper')
00156       ));
00157 
00158       $templateMgr->assign('fieldOptions', Array(
00159          SUBMISSION_FIELD_TITLE => 'paper.title',
00160          SUBMISSION_FIELD_AUTHOR => 'user.role.author',
00161          SUBMISSION_FIELD_DIRECTOR => 'user.role.director'
00162       ));
00163 
00164       $templateMgr->display('trackDirector/index.tpl');
00165    }
00166 
00171    function validate() {
00172       parent::validate();
00173       $conference =& Request::getConference();
00174       $schedConf =& Request::getSchedConf();
00175 
00176       $page = Request::getRequestedPage();
00177 
00178       if (!isset($conference) || !isset($schedConf)) {
00179          Validation::redirectLogin();
00180       }
00181 
00182       if($page == ROLE_PATH_TRACK_DIRECTOR && !Validation::isTrackDirector($conference->getId(), $schedConf->getId())) {
00183          Validation::redirectLogin();
00184       }
00185 
00186       if($page == ROLE_PATH_DIRECTOR && !Validation::isDirector($conference->getId(), $schedConf->getId())) {
00187          Validation::redirectLogin();
00188       }
00189    }
00190 
00195    function setupTemplate($subclass = false, $paperId = 0, $parentPage = null) {
00196       parent::setupTemplate();
00197       AppLocale::requireComponents(array(LOCALE_COMPONENT_OCS_DIRECTOR, LOCALE_COMPONENT_PKP_SUBMISSION, LOCALE_COMPONENT_OCS_AUTHOR));
00198       $templateMgr =& TemplateManager::getManager();
00199       $isDirector = Validation::isDirector();
00200       $pageHierarchy = array();
00201 
00202       $conference =& Request::getConference();
00203       $schedConf =& Request::getSchedConf();
00204 
00205       $templateMgr->assign('helpTopicId', $isDirector ? 'editorial.directorsRole' : 'editorial.trackDirectorsRole');
00206 
00207       if ($schedConf) {
00208          $pageHierarchy[] = array(Request::url(null, null, 'index'), $schedConf->getFullTitle(), true);
00209       } elseif ($conference) {
00210          $pageHierarchy[] = array(Request::url(null, 'index', 'index'), $conference->getConferenceTitle(), true);
00211       }
00212 
00213       $roleSymbolic = $isDirector ? 'director' : 'trackDirector';
00214       $roleKey = $isDirector ? 'user.role.director' : 'user.role.trackDirector';
00215 
00216       $pageHierarchy[] = array(Request::url(null, null, 'user'), 'navigation.user');
00217       $pageHierarchy[] = array(Request::url(null, null, $roleSymbolic), $roleKey);
00218       if ($subclass) {
00219          $pageHierarchy[] = array(Request::url(null, null, $roleSymbolic), 'paper.submissions');
00220       }
00221 
00222       import('submission.trackDirector.TrackDirectorAction');
00223       $submissionCrumb = TrackDirectorAction::submissionBreadcrumb($paperId, $parentPage, $roleSymbolic);
00224       if (isset($submissionCrumb)) {
00225          $pageHierarchy = array_merge($pageHierarchy, $submissionCrumb);
00226       }
00227    
00228       $templateMgr->assign('pageHierarchy', $pageHierarchy);
00229    }
00230 
00235    function instructions($args) {
00236       import('submission.common.Action');
00237       if (!isset($args[0]) || !Action::instructions($args[0])) {
00238          Request::redirect(null, null, Request::getRequestedPage());
00239       }
00240    }
00241 
00242    function getDurationOptions() {
00243       return array(
00244          60 * 10     => '0:10',
00245          60 * 60 * 0.25 => '0:15',
00246          60 * 20     => '0:20',
00247          60 * 60 * 0.5  => '0:30',
00248          60 * 60 * 1 => '1:00',
00249          60 * 60 * 1.5  => '1:30',
00250          60 * 60 * 2 => '2:00',
00251          60 * 60 * 2.5  => '2:30',
00252          60 * 60 * 3 => '3:00',
00253          60 * 60 * 3.5  => '3:30',
00254          60 * 60 * 4 => '4:00',
00255          60 * 60 * 4 => '5:00',
00256          60 * 60 * 5 => '6:00',
00257          60 * 60 * 6 => '7:00',
00258          60 * 60 * 7 => '8:00',
00259       );
00260    }
00261 }
00262 
00263 ?>

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