classes/handler/validation/HandlerValidatorRoles.inc.php

00001 <?php
00014 import('handler.validation.HandlerValidator');
00015 
00016 class HandlerValidatorRoles extends HandlerValidator {
00017    var $roles;
00018    
00019    var $all;
00020 
00030    function HandlerValidatorRoles(&$handler, $redirectLogin = true, $message = null, $additionalArgs = array(), $roles, $all = false) {
00031       parent::HandlerValidator($handler, $redirectLogin, $message, $additionalArgs);
00032       $this->roles = $roles;
00033       $this->all = $all;
00034    }
00035 
00041    function isValid() {
00042       // Get conference ID from request
00043       $conference =& Request::getConference();
00044       $conferenceId = $conference ? $conference->getId() : 0;
00045 
00046       // Get scheduled conference ID from request
00047       $schedConf =& Request::getSchedConf();
00048       $schedConfId = $schedConf ? $schedConf->getId() : 0;
00049       
00050       $user = Request::getUser();
00051       if ( !$user ) return false;
00052 
00053       $roleDao =& DAORegistry::getDAO('RoleDAO');
00054       $returner = true;
00055       foreach ( $this->roles as $roleId ) {
00056          if ( $roleId == ROLE_ID_SITE_ADMIN ) {
00057             $exists = $roleDao->roleExists(0, 0, $user->getId(), $roleId);
00058          } elseif ( $roleId == ROLE_ID_CONFERENCE_MANAGER ) {
00059             $exists = $roleDao->roleExists($conferenceId, 0, $user->getId(), $roleId);
00060          }else { 
00061             $exists = $roleDao->roleExists($conferenceId, $schedConfId, $user->getId(), $roleId);
00062          }
00063          if ( !$this->all && $exists) return true;
00064          $returner = $returner && $exists;
00065       } 
00066       
00067       return $returner;
00068    }
00069 }
00070 
00071 ?>

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