/**
  * function getHTML
  * <pre>
  * This method returns the HTML data generated by this object.
  * </pre>
  * @return [STRING] HTML Display data.
  */
 function getHTML()
 {
     // Uncomment the following line if you want to create a template
     // tailored for this page:
     //$path = $this->pathModuleRoot.'templates/';
     // Otherwise use the standard Templates for the site:
     $path = SITE_PATH_TEMPLATES;
     /*
      * store the link values
      */
     // example:
     // $this->linkValues[ 'view' ] = 'add/new/href/data/here';
     // store the link labels
     $this->linkLabels['edit'] = $this->labels->getLabel('[Edit]');
     $this->linkLabels['del'] = $this->labels->getLabel('[Delete]');
     $this->linkLabels['cont'] = $this->labels->getLabel('[Continue]');
     // $this->linkLabels[ 'view' ] = 'new link label here';
     /*
      * store any additional link Columns
      */
     // example:
     //$title = $this->labels->getLabel( '[title_groups]');
     //$columnLabel = $this->labels->getLabel( '[groups]');
     //$link = $this->linkValues[ 'groups' ];
     //$fieldName = 'accessgroup_id';
     //$this->addLinkColumn( $title, $columnLabel, $link, $fieldName);
     /*
      * Update any label tags ...
      */
     // example:
     // $name = $user->getName();
     // $this->labels->setLabelTag( '[Title]', '[userName]', $name);
     // NOTE:  this parent method prepares the $this->template with the
     // common AdminBox data.
     $this->prepareTemplate($path);
     // store the statevar id to edit
     $this->template->set('editEntryID', $this->eventadmin_id);
     // store all the fields to the template
     $this->setFormFieldsToTemplate();
     /*
      * Form related Template variables:
      */
     /*
      * Insert the date start/end values for the following date fields:
      */
     // example:
     //$this->template->set( 'startYear_[fieldName]', 2000);
     //$this->template->set( 'endYear_[fieldName]', 2010);
     /*
      * List related Template variables :
      */
     // Store the XML Node name for the Data Access Field List
     $xmlNodeName = RowManager_EventAdminAssignmentManager::XML_NODE_NAME;
     $this->template->set('rowManagerXMLNodeName', $xmlNodeName);
     // store the primary key field name for the data being displayed
     $this->template->set('primaryKeyFieldName', 'eventadmin_id');
     // store data list to the template
     // NOTE: we initialize it here to make sure we capture any new data
     // from a recent processData() call.
     $dataAccessManager = new RowManager_EventAdminAssignmentManager();
     $dataAccessManager->setEventID($this->event_id);
     $dataAccessManager->setSortOrder($this->sortBy);
     //        $this->dataList = new EventAdminAssignmentList( $this->sortBy );
     $this->dataList = $dataAccessManager->getListIterator();
     $this->template->setXML('dataList', $this->dataList->getXML());
     /*
      * Add any additional data required by the template here
      */
     // get a list of all viewer_id's
     $viewer = new RowManager_ViewerManager();
     $viewer->setSortOrder('viewer_userID');
     $viewerList = new ListIterator($viewer);
     $viewerArray = $viewerList->getDropListArray();
     $this->template->set('list_viewer_id', $viewerArray);
     // get a list of all privilege_id's
     $privilege = new RowManager_PrivilegeTypeManager();
     $privilege->setSortOrder('priv_desc');
     $privilegeList = new ListIterator($privilege);
     $privilegeArray = $privilegeList->getDropListArray();
     $this->template->set('list_priv_id', $privilegeArray);
     $templateName = 'siteAdminBox.php';
     // if you are creating a custom template for this page then
     // replace $templateName with the following:
     //$templateName = 'page_AddEventAdmin.php';
     return $this->template->fetch($templateName);
 }
Пример #2
0
 function __construct($viewerID)
 {
     $this->viewer_id = $viewerID;
     // set defaults
     $this->isSuperAdmin = false;
     $this->isFinanceAdmin = array();
     $this->isEventAdmin = array();
     $this->isCampusAdmin = array();
     $superAdminManager = new RowManager_SuperAdminAssignmentManager();
     // the permissions are scaled if you have n permission you all have any permission < n
     $this->isSuperAdmin = $superAdminManager->loadByViewer($viewerID);
     if ($this->isSuperAdmin == true) {
         $this->isFinanceAdmin[PrivilegeManager::ALL_EVENTS] = 1;
         $this->isEventAdmin[PrivilegeManager::ALL_EVENTS] = 1;
         $this->isCampusAdmin[PrivilegeManager::ALL_EVENTS] = PrivilegeManager::ALL_CAMPUSES;
     }
     // determine for which events the viewer is an finance, event, or campus admin
     $eventPrivManager = new RowManager_EventAdminAssignmentManager();
     $eventPrivManager->setViewerID($this->viewer_id);
     $privList = $eventPrivManager->getListIterator();
     $privArray = $privList->getDataList();
     $isEventAdmin = array();
     reset($privArray);
     foreach (array_keys($privArray) as $k) {
         $record = current($privArray);
         $eventID = $record['event_id'];
         $priv = $record['priv_id'];
         $adminID = $record['eventadmin_id'];
         // set admin flags based on records found in eventadmin table (SUPER_ADMIN has its own table)
         switch ($priv) {
             case PrivilegeManager::FINANCE_ADMIN:
                 $this->isFinanceAdmin[$eventID] = 1;
                 // set value to true (1)
                 $this->isEventAdmin[$eventID] = 1;
                 // set value to true (1)
                 $this->isCampusAdmin[$eventID] = PrivilegeManager::ALL_CAMPUSES;
                 // set value to represent all campuses
                 break;
             case PrivilegeManager::EVENT_ADMIN:
                 $this->isEventAdmin[$eventID] = 1;
                 // set value to true (1)
                 $this->isCampusAdmin[$eventID] = PrivilegeManager::ALL_CAMPUSES;
                 // set value to represent all campuses
                 break;
             case PrivilegeManager::CAMPUS_ADMIN:
                 $adminCampuses = new RowManager_EventAdminCampusAssignmentManager();
                 $adminCampuses->setEventAdminID($adminID);
                 $campusList = $adminCampuses->getListIterator();
                 $campusArray = $campusList->getDataList();
                 // 		       	echo "campuslist = <pre>".print_r($campusArray,true)."</pre>";
                 $adminCampusList = '';
                 reset($campusArray);
                 foreach (array_keys($campusArray) as $k) {
                     $row = current($campusArray);
                     $campus_id = $row['campus_id'];
                     $adminCampusList .= $campus_id . '|';
                     next($campusArray);
                 }
                 $adminCampusList = substr($adminCampusList, 0, -1);
                 // remove last '|'
                 $this->isCampusAdmin[$eventID] = $adminCampusList;
                 // set value to list of campus IDs
                 break;
             default:
                 break;
         }
         next($privArray);
     }
     // if no privileges found, then check if viewer is C4C staff with associated campus(es)
     if (count($this->isCampusAdmin) < 1) {
         $access = new RowManager_AccessManager();
         $access->setViewerID($this->viewer_id);
         $person = new RowManager_PersonManager();
         $staff = new RowManager_StaffManager();
         $staff->setIsActive('1');
         $assign = new RowManager_AssignmentsManager();
         $assign->setAssignmentStatus(CA_STAFF);
         $campus = new RowManager_CampusManager();
         $multiTables = new MultiTableManager();
         $multiTables->addRowManager($access);
         $multiTables->addRowManager($person, new JoinPair($access->getJoinOnPersonID(), $person->getJoinOnPersonID()));
         $multiTables->addRowManager($staff, new JoinPair($person->getJoinOnPersonID(), $staff->getJoinOnPersonID()));
         $multiTables->addRowManager($assign, new JoinPair($assign->getJoinOnPersonID(), $person->getJoinOnPersonID()));
         $multiTables->addRowManager($campus, new JoinPair($assign->getJoinOnCampusID(), $campus->getJoinOnCampusID()));
         // 		    $multiTables->addSearchCondition("cim_hrdb_assignment.assignmentstatus_id = ".PrivilegeManager::STATUS_STAFF);
         $campusList = $multiTables->getListIterator();
         $campusArray = $campusList->getDataList();
         reset($campusArray);
         //  		    echo 'campus array for user: <pre>'.print_r($campusArray, true).'</pre><br>';
         // some campus was found, so viewer is admin for this campus (for all events)
         if (isset($campusArray) && count($campusArray) > 0) {
             $listOfCampuses = '';
             foreach (array_keys($campusArray) as $k) {
                 $record = current($campusArray);
                 $campus_id = $record['campus_id'];
                 $listOfCampuses = $campus_id . '|';
                 next($campusArray);
             }
             $listOfCampuses = substr($listOfCampuses, 0, -1);
             // remove last '|'
             $this->isCampusAdmin[PrivilegeManager::ALL_EVENTS] = $listOfCampuses;
             // 				 echo 'pre campus list = <pre>'.print_r($this->isCampusAdmin,true).'</pre>';
         }
     }
     //        echo '<br>super admin = '.$this->isSuperAdmin;
     //        echo '<br>event admin = <pre>'.print_r($this->isEventAdmin,true).'</pre>';
     //        echo '<br>campus admin = <pre>'.print_r($this->isCampusAdmin, true).'</pre>';
     //        echo '<br>finance admin = <pre>'.print_r($this->isFinanceAdmin, true).'</pre>';
     $this->isStudent = true;
     // all users have at least student-level access
 }