Exemplo n.º 1
0
  * viewer_id [INTEGER]  Identifier of the viewer/user assigned the super-admin role.
  */
 $SuperAdminAssignment = new RowManager_SuperAdminAssignmentManager();
 $SuperAdminAssignment->dropTable();
 $SuperAdminAssignment->createTable();
 /*
  * EventAdminAssignment Table
  *
  * Assigns a particular privilege to a particular user for some event.
  *
  * eventadmin_id [INTEGER]  unique id for event administrator privilege assignment
  * event_id [INTEGER]  id for the event for which privileges are being assigned
  * priv_id [INTEGER]  ID for a particular event privilege
  * viewer_id [INTEGER]  ID associated with a particular system user
  */
 $EventAdminAssignment = new RowManager_EventAdminAssignmentManager();
 $EventAdminAssignment->dropTable();
 $EventAdminAssignment->createTable();
 /*
  * Field Table
  *
  * A form field for a given event.
  *
  * fields_id [INTEGER]  A form field's identifier
  * fieldtype_id [INTEGER]  Identifier for a particular field type
  * fields_desc [STRING]  Description/label associated with a particular field
  * event_id [INTEGER]  The event identifier associated with the form field
  * fields_priority [INTEGER]  The priority of the form field.
  * fields_datacheck [STRING]  The type of data expected to be associated with this form field.
  * fields_reqd [INTEGER]  Whether or not this field is required.
  * fields_invalid [STRING]  Specifies invalid data not allowed in the form field.
 /**
  * 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);
 }
 /**
  * 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->campusaccess_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
     //
     // NOTE: Hobbe, here are the original two lines that I moved to below
     //
     // $xmlNodeName = RowManager_EventAdminCampusAssignmentManager::XML_NODE_NAME;
     // $this->template->set( 'rowManagerXMLNodeName', $xmlNodeName);
     // store the primary key field name for the data being displayed
     $this->template->set('primaryKeyFieldName', 'campusaccess_id');
     // Russ' Debugging Methodoloy
     // 1. Try and create a multi-table manager that returns the
     // result set I want and put it into and array.  Then figure
     // out why that is not making it through to the template.
     //
     // Result: Hobbe, indeed you were creating the multi-table
     // manager correctly (I just renamed the one row manager),
     // otherwise your code was fine.
     //
     // 2. Ok, try and figure out why the template doesn't like
     // XML it is getting.
     //
     // a. first I check another example (FormProcessor_AddSuperAdmin)
     // of where an adminbox type template is generated.  Yes, it
     // appears we are sending the xml properly
     //
     // b. i notice the call to ->set('primaryKeyFieldName', ... )
     // in the example I'm checking, that too seems to be okay
     //
     // c. I notice the xmlNodeName parameter being set in the
     // templates, i realize that we are not setting this properly
     // and refactor the code a little to get the xmlNodeName from
     // the multitablemanager instead.
     // store data list to the template
     // NOTE: we initialize it here to make sure we capture any new data
     // from a recent processData() call.
     $campusAdminManager = new RowManager_EventAdminCampusAssignmentManager();
     //*** ADDED JOIN TO FILTER BY EVENT ***/
     $eventAdminManager = new RowManager_EventAdminAssignmentManager();
     // echo "The eventID is [".$this->event_id."]<br/>";
     $eventAdminManager->setEventID($this->event_id);
     $multiTableManager = new MultiTableManager();
     $multiTableManager->addRowManager($campusAdminManager);
     $multiTableManager->addRowManager($eventAdminManager, new JoinPair($eventAdminManager->getJoinOnEventAdminID(), $campusAdminManager->getJoinOnEventAdminID()));
     // code to check the result set in the multi-table manager
     // $i = 0;
     // $listIt = $multiTableManager->getListIterator();
     // $listIt->setFirst();
     // while( $listIt->moveNext() )
     // {
     //    echo "ith [".$i."] element";
     //    $i++;
     // }
     // end multi-table manager check
     // $this->dataList = $multiTableManager->getListIterator();
     // echo "<pre>List: ".print_r($this->dataList,true)."</pre>";
     //*** END ADD ***/
     $this->dataList = $multiTableManager->getListIterator();
     // Hobbe, I added/moved these two lines and now it works!
     // It has to do with how the template understands the
     // XML that it is passed
     $xmlNodeName = $this->dataList->getRowManagerXMLNodeName();
     $this->template->set('rowManagerXMLNodeName', $xmlNodeName);
     $this->template->setXML('dataList', $this->dataList->getXML());
     /*
      * Add any additional data required by the template here
      */
     $eventAdmin = new RowManager_EventAdminAssignmentManager();
     $eventAdmin->setEventID($this->event_id);
     $viewer = new RowManager_ViewerManager();
     $multiTableManager2 = new MultiTableManager();
     $multiTableManager2->addRowManager($eventAdmin);
     $multiTableManager2->addRowManager($viewer, new JoinPair($eventAdmin->getJoinOnViewerID(), $viewer->getJoinOnViewerID()));
     //      $multiTableManager2->constructSearchCondition( 'event_id', '=', $this->event_id, true );
     $multiTableManager2->setSortOrder('viewer_userID');
     $multiTableManager2->setLabelTemplate('viewer_userID', '[viewer_userID]');
     $listIterator = $multiTableManager2->getListIterator();
     // code to check the result set in the multi-table manager
     /*        echo "<pre>List: ".print_r($listIterator,true)."</pre>";
                    
              $i = 0;
              $listIt = $multiTableManager2->getListIterator();
              $listIt->setFirst();
              while( $listIt->moveNext() )
              {
                 echo "ith [".$i."] element";
                 $i++;
              }
      */
     // end multi-table manager check
     //        echo print_r($listIterator,true);
     /*
             $viewer = new RowManager_ViewerManager();
             $viewer->setSortOrder( 'viewer_userID' );
             $viewerList = new ListIterator($viewer);	
             $viewerArray = $viewerList->getDropListArray();
     */
     $viewerArray = $listIterator->getDropListArray();
     //$listIterator
     $this->template->set('list_eventadmin_id', $viewerArray);
     //        echo print_r($viewerArray,true);
     $campus = new RowManager_CampusManager();
     //       $campus->setEventID( $this->event_id);
     $campus->setSortOrder('campus_id');
     $campusList = new ListIterator($campus);
     $campusArray = $campusList->getDropListArray();
     $this->template->set('list_campus_id', $campusArray);
     $templateName = 'siteAdminBox.php';
     // if you are creating a custom template for this page then
     // replace $templateName with the following:
     //$templateName = 'page_AddCampusAdmin.php';
     return $this->template->fetch($templateName);
 }
Exemplo n.º 4
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
 }