/**    
 * function viewer_guid_conenct
 * <pre>
 * 
 * If user has an exisitng intranet login ($new_viewer == false):
 * Given GUID and viewer_id, inject GUID into existing viewer
 *
 * If user never had an intranet login ($new_viewer == true):
 * Given a GUID, create new viewer, person, put into access group, etc.
 *
 * @param $guid [String] [user's GUID]
 * @param $viewer [Int] [user's view_id]
 * @param $new_viewer [BOO] [true when user never had an intranet login]
 * </pre>
 * @return [void]
 *
 *
 */
function viewer_guid_connect($guid, $viewer, $new_viewer)
{
    if ($new_viewer) {
        // 1. create new viewer
        $viewerManager = new RowManager_ViewerManager();
        $viewerManager->setGUID($guid);
        // GUID
        $viewerManager->setLanguageID(1);
        // english
        // TODO this value should not be hard-coded for the account group
        $viewerManager->setAccountGroupID(15);
        // the 'unknown' group
        $viewerManager->setIsActive(true);
        $viewerManager->createNewEntry();
        $viewerID = $viewerManager->getID();
        // get the ID of the newly created viewer
        // 2. put into the 'all' access group
        // PART A
        $viewerAccessGroupManager = new RowManager_ViewerAccessGroupManager();
        $viewerAccessGroupManager->setViewerID($viewerID);
        $viewerAccessGroupManager->setAccessGroupID(ALL_ACCESS_GROUP);
        // add to the 'all' access group
        $viewerAccessGroupManager->createNewEntry();
        // PART B
        $viewerAccessGroupManager = new RowManager_ViewerAccessGroupManager();
        $viewerAccessGroupManager->setViewerID($viewerID);
        $viewerAccessGroupManager->setAccessGroupID(SPT_APPLICANT_ACCESS_GROUP);
        // add to the 'SPT-Student' access group
        $viewerAccessGroupManager->createNewEntry();
        // 3. create new person (or grab person_id from existing record)
        $personManager = new RowManager_PersonManager();
        $personManager->setFirstName('');
        $personManager->setLastName('');
        $personManager->setEmail('');
        $personManager->setSortOrder('person_id');
        $personManager->setAscDesc('DESC');
        // sort by descending person IDs
        $personList = $personManager->getListIterator();
        $personArray = $personList->getDataList();
        //create new entry
        $personManager->createNewEntry();
        $personID = $personManager->getID();
        // get the ID of the newly created person
        // 4. create an access table entry for this (viewer,person) combo
        $accessManager = new RowManager_AccessManager();
        $accessManager->setViewerID($viewerID);
        $accessManager->setPersonID($personID);
        $accessManager->createNewEntry();
    } else {
        $viewerManager = new RowManager_ViewerManager($viewer);
        //echo ($viewerManager->getID());
        $viewerManager->setGUID($guid);
        // GUID
        $viewerManager->updateDBTable();
    }
}
 /**
  * function __construct
  * <pre>
  * Initialize the object.
  * </pre>
  * @param $pathModuleRoot [STRING] The path to this module's root directory
  * @param $viewer [OBJECT] The viewer object.
  * @param $formAction [STRING] The action on a form submit
  * @param $person_id [INTEGER] Value used to initialize the dataManager
  * @return [void]
  */
 function __construct($pathModuleRoot, $viewer, $formAction, $person_id)
 {
     // NOTE: be sure to call the parent constructor before trying to
     //       use the ->formXXX arrays...
     $fieldList = FormProcessor_EditMyInfo::FORM_FIELDS;
     $fieldDisplayTypes = FormProcessor_EditMyInfo::FORM_FIELD_TYPES;
     parent::__construct($formAction, $fieldList, $fieldDisplayTypes);
     $this->pathModuleRoot = $pathModuleRoot;
     $this->viewer = $viewer;
     $this->person_id = $person_id;
     // To make sure this is not exploited to edit any other person's id.
     // If the user has no privileges, this sets the viewer id to be his/her own,
     // even if the variable given to it is not the viewer's person id.
     // NOTE: anyone with higher previliges can edit any person's info, by simply
     // changing the posted variable value.
     // Now load the access Priviledge manager of this viewer
     $this->accessPrivManager = new RowManager_AdminManager();
     // Get the person ID
     $accessManager = new RowManager_AccessManager();
     $accessManager->loadByViewerID($this->viewer->getViewerID());
     $personID = $accessManager->getPersonID();
     // Get the permissions the person has.
     $this->accessPrivManager->loadByPersonID($personID);
     if (!$this->accessPrivManager->isLoaded()) {
         $this->person_id = $personID;
     }
     //End of check.
     // figure out the important fields for the dataManager
     $fieldsOfInterest = implode(',', $this->formFields);
     $this->dataManager = new RowManager_PersonManager($this->person_id);
     $this->dataManager->setFieldsOfInterest($fieldsOfInterest);
     $this->formValues = $this->dataManager->getArrayOfValues();
     // now initialize the labels for this page
     // start by loading the default field labels for this Module
     $languageID = $viewer->getLanguageID();
     $seriesKey = modulecim_hrdb::MULTILINGUAL_SERIES_KEY;
     $pageKey = modulecim_hrdb::MULTILINGUAL_PAGE_FIELDS;
     $this->labels = new MultilingualManager($languageID, $seriesKey, $pageKey);
     // then load the page specific labels for this page
     $pageKey = FormProcessor_EditMyInfo::MULTILINGUAL_PAGE_KEY;
     $this->labels->loadPageLabels($pageKey);
     // load the site default form link labels
     $this->labels->setSeriesKey(SITE_LABEL_SERIES_SITE);
     $this->labels->loadPageLabels(SITE_LABEL_PAGE_FORM_LINKS);
     $this->labels->loadPageLabels(SITE_LABEL_PAGE_FORMERRORS);
 }
 /**
  * function __construct
  * <pre>
  * Initialize the object.
  * </pre>
  * @param $pathModuleRoot [STRING] The path to the module's root dir.
  * @param $viewer [OBJECT] The viewer object.
  * @return [void]
  */
 function __construct($pathModuleRoot, $viewer, $formAction, $sortBy)
 {
     // NOTE: be sure to call the parent constructor before trying to
     //       use the ->formXXX arrays...
     $fieldList = '';
     //FormProcessor_ManageSuperAdmin::FORM_FIELDS;
     $fieldTypes = '';
     //FormProcessor_ManageSuperAdmin::FORM_FIELD_TYPES;
     $displayFields = '';
     //FormProcessor_ManageSuperAdmin::DISPLAY_FIELDS;
     parent::__construct($formAction, '', '');
     // initialzie the object values
     $this->pathModuleRoot = $pathModuleRoot;
     $this->viewer = $viewer;
     // now initialize the labels for this page
     // start by loading the default field labels for this Module
     $languageID = $viewer->getLanguageID();
     $seriesKey = modulecim_sch::MULTILINGUAL_SERIES_KEY;
     $pageKey = page_MySchedule::MULTILINGUAL_PAGE_KEY;
     $this->labels = new MultilingualManager($languageID, $seriesKey, $pageKey);
     // init the person id
     // figure out the viewer's person ID
     $accessManager = new RowManager_AccessManager();
     $accessManager->loadByViewerID($this->viewer->getViewerID());
     $this->personID = $accessManager->getPersonID();
     echo "Your person ID is:" . $this->personID . "<br/>";
     // set the schedule id
     $scheduleManager = new RowManager_ScheduleManager();
     $scheduleManager->setPersonID($this->personID);
     $scheduleList = new ListIterator($scheduleManager);
     $scheduleList->setFirst();
     $this->scheduleID = -1;
     if ($scheduleList->moveNext()) {
         $schManager = $scheduleList->getCurrent(new RowManager_ScheduleManager());
         $this->scheduleID = $schManager->getScheduleID();
         echo "Schedule ID:" . $this->scheduleID . "<br/>";
     } else {
         echo "ERROR finding schedule id.<br/>";
     }
 }
 protected function getPersonIDfromViewerID()
 {
     $accessPriv = new RowManager_AccessManager();
     $accessPriv->setViewerID($this->viewer->getID());
     $accessPrivList = $accessPriv->getListIterator();
     $accessPrivArray = $accessPrivList->getDataList();
     $personID = '';
     reset($accessPrivArray);
     foreach (array_keys($accessPrivArray) as $k) {
         $record = current($accessPrivArray);
         $personID = $record['person_id'];
         // can only be 1 person_id per viewer_id
         next($accessPrivArray);
     }
     return $personID;
 }
 protected function getStaffIDfromViewerID()
 {
     $staffViewer = new MultiTableManager();
     $accessPriv = new RowManager_AccessManager();
     $accessPriv->setViewerID($this->viewer->getID());
     $staff = new RowManager_StaffManager();
     $staffViewer->addRowManager($staff);
     $staffViewer->addRowManager($accessPriv, new JoinPair($staff->getJoinOnPersonID(), $accessPriv->getJoinOnPersonID()));
     $staffViewerList = $staffViewer->getListIterator();
     $staffViewerArray = $staffViewerList->getDataList();
     $staffID = '';
     reset($staffViewerArray);
     foreach (array_keys($staffViewerArray) as $k) {
         $record = current($staffViewerArray);
         $staffID = $record['staff_id'];
         // can only be 1 staff_id per viewer_id
         next($staffViewerArray);
     }
     return $staffID;
 }
Beispiel #6
0
  * person_id [INTEGER]  The is the person id for the person assigned to the campus.
  * campus_id [INTEGER]  The is the campus the person is assigned to.
  */
 $Assignments = new RowManager_AssignmentsManager();
 $Assignments->dropTable();
 $Assignments->createTable();
 /*
  * Access Table
  *
  * This manages the access table.
  *
  * access_id [INTEGER]  This is the key for the table
  * viewer_id [INTEGER]  This is the viewer(user) id of the user who is assigned to a person id.
  * person_id [INTEGER]  This is the person id connected to the viewer id.
  */
 $Access = new RowManager_AccessManager();
 $Access->dropTable();
 $Access->createTable();
 /*
  * Region Table
  *
  * manages regions
  *
  * region_id [INTEGER]  id of a region
  * reg_desc [STRING]  description of a region
  */
 $Region = new RowManager_RegionManager();
 $Region->dropTable();
 $Region->createTable();
 /*
  * EmergencyInfo Table
 protected function getCampusIDfromViewerID()
 {
     $campusAssign = new RowManager_AssignmentsManager();
     $accessPriv = new RowManager_AccessManager();
     $accessPriv->setViewerID($this->viewer->getID());
     $getCampusID = new MultiTableManager();
     $getCampusID->addRowManager($campusAssign);
     $getCampusID->addRowManager($accessPriv, new JoinPair($campusAssign->getJoinOnPersonID(), $accessPriv->getJoinOnPersonID()));
     $accessPrivList = $getCampusID->getListIterator();
     $accessPrivArray = $accessPrivList->getDataList();
     $personID = '';
     $campusID = '';
     reset($accessPrivArray);
     foreach (array_keys($accessPrivArray) as $k) {
         $record = current($accessPrivArray);
         $campusID = $record['campus_id'];
         // NOTE: there may be more than 1 but system will just use last one...
         next($accessPrivArray);
     }
     return $campusID;
 }
 /**
  * function __construct
  * <pre>
  * Initialize the object.
  * </pre>
  * @param $pathModuleRoot [STRING] The path to the module's root dir.
  * @param $viewer [OBJECT] The viewer object.
  * @param $sortBy [STRING] Field data to sort listManager by.
  * @param $managerInit [INTEGER] Initialization value for the listManager.
  * @return [void]
  */
 function __construct($pathModuleRoot, $viewer, $sortBy)
 {
     parent::__construct(page_ViewGroups::DISPLAY_FIELDS);
     $this->pathModuleRoot = $pathModuleRoot;
     $this->viewer = $viewer;
     //Get person ID
     $accessManager = new RowManager_AccessManager();
     $accessManager->loadByViewerID($this->viewer->getViewerID());
     $this->personID = $accessManager->getPersonID();
     echo "ViewerID: " . $this->viewer->getViewerID() . " <br>personID: " . $this->personID . "<br>";
     /*
      * The code below contains the different permission cases for view groups.
      * 
      * Check 1 = check if the user is a SUPER ADMIN
      * Check 2 = check if the user is a STAFF and which campuses he/she is assigned to, taken from HRDB
      * Check 3 =check cim_sch_permissionCampusAdmin for which CAMPUSES this user is ADMIN for
      * Check 4 = check cim_sch_permissionGroupAdmin for which GROUPS this user is ADMIN for
      * If check 1-4 FAIL then ViewGroup will show nothing. (This user is a normal user and have not created any groups .
      */
     $multiTableManager = new MultiTableManager();
     $groupManager = new RowManager_GroupManager();
     $superAdminManager = new RowManager_PermissionsSuperAdminManager();
     //SUPER ADMIN
     //Check if user's Viewer_id is in the PermissionSuperAdmin table
     if ($superAdminManager->loadByViewerID($this->viewer->getViewerID())) {
         // the viewer is a super admin
         echo "ViewerID[" . $this->viewer->getViewerID() . "] is a super admin<br/>";
         $campusGroupManager = new RowManager_CampusGroupManager();
         $multiTableManager->addRowManager($groupManager);
         $multiTableManager->addRowManager($campusGroupManager, new JoinPair($campusGroupManager->getJoinOnGroupID(), $groupManager->getJoinOnGroupID(), JOIN_TYPE_LEFT));
     } else {
         //STAFF
         // This array stores all the campuses associated to the user.
         //This array is continually populated
         $campusArray = array();
         //check HRDB if the user is a staff
         $assignmentManager = new RowManager_AssignmentsManager();
         $assignmentManager->setPersonID($this->personID);
         $assignmentManager->setAssignmentStatus(CA_STAFF);
         $assList = new ListIterator($assignmentManager);
         $assList->setFirst();
         while ($assList->moveNext()) {
             $assMan = $assList->getCurrent(new RowManager_AssignmentsManager());
             //for each campuses found, store in array
             $campusArray[] = $assMan->getCampusID();
         }
         //CAMPUS ADMIN
         //Check cim_sch_permissionsCampusAdmin for the viewer id of the user
         $permissionsCampusAdmin = new RowManager_PermissionsCampusAdminManager();
         $permissionsCampusAdmin->setViewerID($this->viewer->getViewerID());
         $campusAdminList = new ListIterator($permissionsCampusAdmin);
         $campusAdminList->setFirst();
         while ($campusAdminList->moveNext()) {
             $permCampus = $campusAdminList->getCurrent(new RowManager_PermissionsCampusAdminManager());
             //for each campuses found, store in array
             $campusArray[] = $permCampus->getCampusID();
         }
         //remove any duplicate campus ID in the array
         $campusArray = array_unique($campusArray);
         //GROUP ADMIN
         $permissionsGroupAdminManager = new RowManager_PermissionsGroupAdminManager();
         $campusGroupManager = new RowManager_CampusGroupManager();
         //send a list of campues and the viewer ID to constrict the search condition
         //The Viewer_id is use to check the cim_sch_permissionsGroupAdmin table for
         // groups that were created by the user
         $searchCond = $campusGroupManager->returnSearchCondition($campusArray, $this->viewer->getViewerID());
         //create the appropriate join between 3 tables
         //Join cim_sch_group and cim_sch_permissionsGroupAdmin and cim_sch_campusGroup
         $multiTableManager->addRowManager($groupManager);
         $multiTableManager->addRowManager($campusGroupManager, new JoinPair($campusGroupManager->getJoinOnGroupID(), $groupManager->getJoinOnGroupID(), JOIN_TYPE_LEFT));
         $multiTableManager->addRowManager($permissionsGroupAdminManager, new JoinPair($permissionsGroupAdminManager->getJoinOnGroupID(), $groupManager->getJoinOnGroupID(), JOIN_TYPE_LEFT));
         $multiTableManager->addSearchCondition($searchCond);
     }
     /*Case 3: Group Admin - access to an individual group and can create other group admins 
     				(ex. DGL)
     				Normal User - can only submit schedule, assume this unless given other permissions
     					Check the group admin table 
     	
     				check cim_sch_permissiongroupadmin -> cim_sch_campusgroup -> cim_sch_group
     				filter on viewer id 
     
     
     		Case 4: All staff - implicit access to all groups on all campuses where their status is staff 
     				check cim_hrdb_staff table
     					if true
     						get all campuses from cim_hrdb_assignment where assignment status id = 3
     
     
             */
     /*$groupManager = new RowManager_GroupManager();
       $multiTableManager = new MultiTableManager();
       
       $campusGroupManager = new RowManager_CampusGroupManager();
       
       $multiTableManager->addRowManager( $campusGroupManager );
       $multiTableManager->addRowManager( $groupManager, new JoinPair( $campusGroupManager->getJoinOnGroupID(), $groupManager->getJoinOnGroupID(), JOIN_TYPE_RIGHT ) );*/
     // $dataAccessObject = $multiTableManager;
     $multiTableManager->setSortOrder('campus_id');
     //******Not sure this is the way to do it*****
     //       $this->listManager = new GroupList( $sortBy );
     $this->listManager = $multiTableManager->getListIterator();
     // now initialize the labels for this page
     // start by loading the default field labels for this Module
     $languageID = $viewer->getLanguageID();
     $seriesKey = modulecim_sch::MULTILINGUAL_SERIES_KEY;
     $pageKey = modulecim_sch::MULTILINGUAL_PAGE_FIELDS;
     $this->labels = new MultilingualManager($languageID, $seriesKey, $pageKey);
     // then load the page specific labels for this page
     $pageKey = page_ViewGroups::MULTILINGUAL_PAGE_KEY;
     $this->labels->loadPageLabels($pageKey);
     $this->labels->setSeriesKey(SITE_LABEL_SERIES_SITE);
     $this->labels->loadPageLabels(SITE_LABEL_PAGE_FORM_LINKS);
 }
 /**
  * function isBasicAdmin
  * <pre>
  * a simple check to determine if viewer is admin for *some* campus and *some* event
  * </pre>
  * @return [BOOL] 
  */
 function isBasicAdmin($eventID = 'DEFAULT')
 {
     // check if viewer is a super-admin
     if (isset($this->isCampusAdmin[PrivilegeManager::ALL_EVENTS]) && $this->isCampusAdmin[PrivilegeManager::ALL_EVENTS] == PrivilegeManager::ALL_CAMPUSES) {
         return true;
     }
     if (isset($this->isCampusAdmin)) {
         // if no event ID passed in (i.e. very basic check) or eventID is valid for this admin
         if ($eventID == 'DEFAULT' || isset($this->isCampusAdmin[$eventID])) {
             // *some* campus should have been stored in campus admin array
             // 		    echo "<pre>".print_r($this->isCampusAdmin[$evebt=true)."</pre>";
             if (count($this->isCampusAdmin) > 0) {
                 return true;
             }
         }
     }
     // otherwise check if viewer is staff at some campus
     // 		    $viewers = new RowManager_ViewerManager();
     // 		    $viewers->set($this->viewer_id);
     $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()));
     $campusList = $multiTables->getListIterator();
     $campusArray = $campusList->getDataList();
     // 		    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) {
         // store the viewer in the database as a campus id assigned to the current campus
         /*** TODO: low priority because it is an optimization ***/
         return true;
     }
     return false;
 }
 protected function getPersonEmailfromViewerID()
 {
     $personEmailInfo = new MultiTableManager();
     $personInfo = new RowManager_PersonManager();
     $accessPriv = new RowManager_AccessManager();
     $accessPriv->setViewerID($this->viewer->getID());
     $personEmailInfo->addRowManager($personInfo);
     $personEmailInfo->addRowManager($accessPriv, new JoinPair($personInfo->getJoinOnPersonID(), $accessPriv->getJoinOnPersonID()));
     $personEmailList = $personEmailInfo->getListIterator();
     $personEmailArray = $personEmailList->getDataList();
     $personID = '';
     reset($personEmailArray);
     foreach (array_keys($personEmailArray) as $k) {
         $record = current($personEmailArray);
         $personID = $record['person_id'];
         // can only be 1 person_id per viewer_id
         $personEmail = $record['person_email'];
         next($personEmailArray);
     }
     return $personEmail;
 }
 private function getAccessRecords($person_ids)
 {
     $matchedViewerIDs = array();
     $access_manager = new RowManager_AccessManager();
     $access_manager->addSearchCondition("person_id in (" . $person_ids . ")");
     $access_manager->setSortOrder('person_id');
     $access_manager->setAscDesc('DESC');
     // sort by descending person IDs
     $accessData = $access_manager->getListIterator();
     $accessArray = $accessData->getDataList();
     // 	    echo 'access-viewer records = <pre>'.print_r($accessArray,true).'</pre>';
     if (isset($accessArray)) {
         if (count($accessArray) > 0) {
             reset($accessArray);
             foreach (array_keys($accessArray) as $k) {
                 $accessRecord = current($accessArray);
                 $personID = $accessRecord['person_id'];
                 $viewerID = $accessRecord['viewer_id'];
                 $matchedViewerIDs[$viewerID] = $personID;
                 // NOV 27,2007: swapped $viewerID and $personID (key-index swap)
                 next($accessArray);
             }
         }
     }
     // 		 echo 'viewer records = <pre>'.print_r($matchedViewerIDs,true).'</pre>';
     return $matchedViewerIDs;
 }
 /**
  * function __construct
  * <pre>
  * Initialize the object.
  * </pre>
  * @param $pathModuleRoot [STRING] The path to the module's root dir.
  * @param $viewer [OBJECT] The viewer object.
  * @param $sortBy [STRING] Field data to sort listManager by.
  * @param $managerInit [INTEGER] Initialization value for the listManager.
  * @return [void]
  */
 function __construct($pathModuleRoot, $viewer, $sortBy, $campus_id = "")
 {
     parent::__construct(page_PeoplebyCampuses::DISPLAY_FIELDS);
     $this->pathModuleRoot = $pathModuleRoot;
     $this->viewer = $viewer;
     $this->campus_id = $campus_id;
     // echo 'campusID['.$this->campus_id.']<br/>';
     //        $this->managerInit = $managerInit;
     // Now load the access Priviledge manager of this viewer
     $this->adminManager = new RowManager_AdminManager();
     // Get the person ID
     $accessManager = new RowManager_AccessManager();
     $accessManager->loadByViewerID($this->viewer->getViewerID());
     $personID = $accessManager->getPersonID();
     // Get the permissions the person has.
     $this->adminManager->loadByPersonID($personID);
     if ($this->adminManager->hasSitePriv()) {
         $campusManager = new RowManager_CampusManager();
         $campusManager->setSortOrder('campus_desc');
         $this->campusList = $campusManager->getListIterator();
         $this->accessibleCampuses = $this->campusList->getDropListArray();
     } else {
         if ($this->adminManager->hasCampusPriv()) {
             $campusAdminManager = new RowManager_CampusAdminManager();
             $adminID = $this->adminManager->getID();
             // echo 'adminID['.$adminID.']<br/>';
             $campusAdminManager->setAdminID($adminID);
             $multiTableManager = new MultiTableManager();
             $multiTableManager->addRowManager($campusAdminManager);
             $multiTableManager->setSortOrder('campus_desc');
             $campusManager = new RowManager_CampusManager();
             $multiTableManager->addRowManager($campusManager, new JoinPair($campusManager->getJoinOnCampusID(), $campusAdminManager->getJoinOnCampusID()));
             $this->campusList = $multiTableManager->getListIterator();
             $this->accessibleCampuses = array();
             $this->campusList->setFirst();
             while ($this->campusList->moveNext()) {
                 $campusAdminObject = $this->campusList->getCurrent(new RowManager_CampusAdminManager());
                 $campusObject = $this->campusList->getCurrent(new RowManager_CampusManager());
                 $this->accessibleCampuses[$campusAdminObject->getCampusID()] = $campusObject->getLabel();
             }
         } else {
             if ($this->adminManager->isStaff($viewer->getID())) {
                 $staffManager = new RowManager_StaffManager();
                 $staffManager->setPersonID($personID);
                 $multiTableManager = new MultiTableManager();
                 $multiTableManager->addRowManager($staffManager);
                 $multiTableManager->setSortOrder('campus_desc');
                 $assignmentManager = new RowManager_AssignmentsManager();
                 $multiTableManager->addRowManager($assignmentManager, new JoinPair($assignmentManager->getJoinOnPersonID(), $staffManager->getJoinOnPersonID()));
                 $campusManager = new RowManager_CampusManager();
                 $multiTableManager->addRowManager($campusManager, new JoinPair($campusManager->getJoinOnCampusID(), $assignmentManager->getJoinOnCampusID()));
                 $this->campusList = $multiTableManager->getListIterator();
                 $this->accessibleCampuses = array();
                 $this->campusList->setFirst();
                 while ($this->campusList->moveNext()) {
                     $campusAssignObject = $this->campusList->getCurrent(new RowManager_AssignmentsManager());
                     $campusObject = $this->campusList->getCurrent(new RowManager_CampusManager());
                     $this->accessibleCampuses[$campusAssignObject->getCampusID()] = $campusObject->getLabel();
                 }
             } else {
                 $campusManager = new RowManager_CampusManager();
                 $campusManager->setSortOrder('campus_desc');
                 $this->campusList = $campusManager->getListIterator();
                 $this->accessibleCampuses = $this->campusList->getDropListArray();
             }
         }
     }
     // modify the campus_id if necessary
     if ($this->campus_id == page_PeoplebyCampuses::DISPLAY_ALL_ID) {
         // setting the campus id to blank will get entries from all the campuses
         $this->campus_id = '';
     } else {
         if ($this->campus_id == '') {
             // no campus has been specified
             // choose a default campus if none specified
             // echo 'No campus specified<br/>';
             // get the first element from the accessible list
             foreach ($this->accessibleCampuses as $key => $value) {
                 $this->campus_id = $key;
                 break;
             }
             // assert campus_id should now be something
             if ($this->campus_id == '') {
                 die("ERROR - campusID not set to anything<br/>");
             }
         }
     }
     $dataAccessObject = new MultiTableManager();
     $assignmentsManager = new RowManager_AssignmentsManager();
     $assignmentsManager->setCampusID($this->campus_id);
     $dataAccessObject->addRowManager($assignmentsManager);
     $personManager = new RowManager_PersonManager();
     $joinPair = new JoinPair($personManager->getJoinOnPersonID(), $assignmentsManager->getJoinOnPersonID());
     $dataAccessObject->addRowManager($personManager, $joinPair);
     $this->accessManager = new RowManager_AccessManager();
     $joinPair2 = new JoinPair($personManager->getJoinOnPersonID(), $this->accessManager->getJoinOnPersonID(), JOIN_TYPE_LEFT);
     $dataAccessObject->addRowManager($this->accessManager, $joinPair2);
     $this->viewerManager = new RowManager_UserManager();
     $joinPair3 = new JoinPair($this->accessManager->getJoinOnViewerID(), $this->viewerManager->getJoinOnViewerID(), JOIN_TYPE_LEFT);
     $dataAccessObject->addRowManager($this->viewerManager, $joinPair3);
     if ($sortBy == '') {
         $sortBy = 'person_lname';
     }
     $dataAccessObject->setSortOrder($sortBy);
     $this->listManager = $dataAccessObject->getListIterator();
     // now initialize the labels for this page
     // start by loading the default field labels for this Module
     $languageID = $viewer->getLanguageID();
     $seriesKey = modulecim_hrdb::MULTILINGUAL_SERIES_KEY;
     $pageKey = modulecim_hrdb::MULTILINGUAL_PAGE_FIELDS;
     $this->labels = new MultilingualManager($languageID, $seriesKey, $pageKey);
     // then load the page specific labels for this page
     $pageKey = page_PeoplebyCampuses::MULTILINGUAL_PAGE_KEY;
     $this->labels->loadPageLabels($pageKey);
     $this->labels->setSeriesKey(SITE_LABEL_SERIES_SITE);
     $this->labels->loadPageLabels(SITE_LABEL_PAGE_FORM_LINKS);
 }
Beispiel #13
0
function process_Form($sqlResult, $template, $errorMessages)
{
    //get the names that are being searched
    $fName = $_REQUEST['fName'];
    $lName = $_REQUEST['lName'];
    //create the needed row managers
    $personM = new RowManager_PersonManager();
    $accessM = new RowManager_AccessManager();
    $viewerM = new RowManager_ViewerManager();
    //setup the join pair needed
    $join = new JoinPair($personM->getJoinOnFieldX('person_id'), $accessM->getJoinOnFieldX('person_id'));
    //create the multi table manager and initialize it
    $MTM = new MultiTableManager();
    $MTM->addRowManager($personM);
    $MTM->addRowManager($accessM, $join);
    //if there is a first name being searched - add that as a condition
    if ($fName != "") {
        $MTM->constructSearchCondition('person_fname', ' LIKE ', '%' . $fName . '%', true);
        $personM->constructSearchCondition('person_fname', ' LIKE ', '%' . $fName . '%', true);
    }
    //if there is a last name being searched - add that as a condition
    if ($lName != "") {
        $MTM->constructSearchCondition('person_lname', ' LIKE ', '%' . $lName . '%', true);
        $personM->constructSearchCondition('person_lname', ' LIKE ', '%' . $lName . '%', true);
    }
    //jump to a display function to show what was reteived from the person database
    //$sqlResult = $personM->find();
    //$rows = showContents($sqlResult, $personM, $personM->getFields());
    //jump to a display function to show what was reteived after joining the databases
    $sqlResult = $MTM->find();
    //$rows = showContents($sqlResult, $personM, $personM->getFields());
    $sqlResult->setFirst();
    //create a new viewer manager to keep data pure
    $viewM = new RowManager_ViewerManager();
    //loop through the results saving them to be displayed
    for ($i = 0; $i < $sqlResult->getRowCount(); $i++) {
        //get the next result and the values
        $sqlResult->getNext($personM);
        $f_name[] = $personM->getValueByFieldName('person_fname');
        $l_name[] = $personM->getValueByFieldName('person_lname');
        $person_id[] = $personM->getValueByFieldName('person_id');
        //get the current accessManager values
        $sqlResult->getCurrent($accessM);
        //create the join for access table -> viewer table and search the database for the record
        $join = new JoinPair($accessM->getJoinOnFieldX('viewer_id'), $viewerM->getJoinOnFieldX('viewer_id'));
        $MTM = new MultiTableManager();
        $MTM->addRowManager($accessM);
        $MTM->addRowManager($viewerM, $join);
        $MTM->constructSearchCondition('viewer_id', '=', $accessM->getValueByFieldName('viewer_id'), true);
        $sqlResult2 = $MTM->find();
        //add the needed information to the arrays to be displayed in the template file
        $sqlResult2->getNext($viewM);
        $viewer_id[] = $viewM->getValueByFieldName('viewer_id');
        $user_id[] = $viewM->getValueByFieldName('viewer_userID');
    }
    //check if there was any result from the initial database query, if not add an error message
    if ($sqlResult->getRowCount() < 1) {
        $errorMessages = 'Failed to join database to get label';
        $template->set('f_name', null);
    } else {
        //add the needed information to the template
        $template->set('f_name', $f_name);
        $template->set('l_name', $l_name);
        $template->set('viewer_id', $viewer_id);
        $template->set('person_id', $person_id);
        $template->set('user_id', $user_id);
    }
}
 /**
  * function __construct
  * <pre>
  * Initialize the object.
  * </pre>
  * @param $pathModuleRoot [STRING] The path to this module's root directory
  * @param $viewer [OBJECT] The viewer object.
  * @param $formAction [STRING] The action on a form submit
  * @param $ [INTEGER] Value used to initialize the rowManager
  * @return [void]
  */
 function __construct($pathModuleRoot, $viewer, $formAction, $person_id, $campus_id, $person_year_id = '')
 {
     // NOTE: be sure to call the parent constructor before trying to
     //       use the ->formXXX arrays...
     parent::__construct($formAction, FormProcessor_EditStudentYearInSchool::FORM_FIELDS, FormProcessor_EditStudentYearInSchool::FORM_FIELD_TYPES);
     $this->pathModuleRoot = $pathModuleRoot;
     $this->viewer = $viewer;
     $this->formAction = $formAction;
     $this->campus_id = $campus_id;
     $this->person_id = $person_id;
     $this->person_year_id = $person_year_id;
     //        if ($person_year_id == '')
     //        {
     // 	       if (isset($person_id))
     // 	       {
     // 		       if (isset($campus_id))
     // 		       {
     // 		       }
     // 	       }
     //        }
     /**** Check privileges and initialize campus drop-down list ***/
     // Now load the access Priviledge manager of this viewer
     $this->adminManager = new RowManager_AdminManager();
     // Get the person ID
     $accessManager = new RowManager_AccessManager();
     $accessManager->loadByViewerID($this->viewer->getViewerID());
     $personID = $accessManager->getPersonID();
     // Get the permissions the person has.
     $this->adminManager->loadByPersonID($personID);
     if ($this->adminManager->hasSitePriv()) {
         $campusManager = new RowManager_CampusManager();
         $campusManager->setSortOrder('campus_desc');
         $this->campusList = $campusManager->getListIterator();
         $this->accessibleCampuses = $this->campusList->getDropListArray();
     } else {
         if ($this->adminManager->hasCampusPriv()) {
             $campusAdminManager = new RowManager_CampusAdminManager();
             $adminID = $this->adminManager->getID();
             // echo 'adminID['.$adminID.']<br/>';
             $campusAdminManager->setAdminID($adminID);
             $multiTableManager = new MultiTableManager();
             $multiTableManager->addRowManager($campusAdminManager);
             $multiTableManager->setSortOrder('campus_desc');
             $campusManager = new RowManager_CampusManager();
             $multiTableManager->addRowManager($campusManager, new JoinPair($campusManager->getJoinOnCampusID(), $campusAdminManager->getJoinOnCampusID()));
             $this->campusList = $multiTableManager->getListIterator();
             $this->accessibleCampuses = array();
             $this->campusList->setFirst();
             while ($this->campusList->moveNext()) {
                 $campusAdminObject = $this->campusList->getCurrent(new RowManager_CampusAdminManager());
                 $campusObject = $this->campusList->getCurrent(new RowManager_CampusManager());
                 $this->accessibleCampuses[$campusAdminObject->getCampusID()] = $campusObject->getLabel();
             }
         } else {
             if ($this->adminManager->isStaff($viewer->getID())) {
                 $staffManager = new RowManager_StaffManager();
                 $staffManager->setPersonID($personID);
                 $multiTableManager = new MultiTableManager();
                 $multiTableManager->addRowManager($staffManager);
                 $multiTableManager->setSortOrder('campus_desc');
                 $assignmentManager = new RowManager_AssignmentsManager();
                 $multiTableManager->addRowManager($assignmentManager, new JoinPair($assignmentManager->getJoinOnPersonID(), $staffManager->getJoinOnPersonID()));
                 $campusManager = new RowManager_CampusManager();
                 $multiTableManager->addRowManager($campusManager, new JoinPair($campusManager->getJoinOnCampusID(), $assignmentManager->getJoinOnCampusID()));
                 $this->campusList = $multiTableManager->getListIterator();
                 $this->accessibleCampuses = array();
                 $this->campusList->setFirst();
                 while ($this->campusList->moveNext()) {
                     $campusAssignObject = $this->campusList->getCurrent(new RowManager_AssignmentsManager());
                     $campusObject = $this->campusList->getCurrent(new RowManager_CampusManager());
                     $this->accessibleCampuses[$campusAssignObject->getCampusID()] = $campusObject->getLabel();
                 }
             } else {
                 $campusManager = new RowManager_CampusManager();
                 $campusManager->setSortOrder('campus_desc');
                 $this->campusList = $campusManager->getListIterator();
                 $this->accessibleCampuses = $this->campusList->getDropListArray();
             }
         }
     }
     // modify the campus_id if necessary
     if ($this->campus_id == FormProcessor_EditStudentYearInSchool::DISPLAY_ALL_ID) {
         // setting the campus id to blank will get entries from all the campuses
         $this->campus_id = '';
     } else {
         if ($this->campus_id == '') {
             // no campus has been specified
             // choose a default campus if none specified
             // echo 'No campus specified<br/>';
             // get the first element from the accessible list
             foreach ($this->accessibleCampuses as $key => $value) {
                 $this->campus_id = $key;
                 break;
             }
             // assert campus_id should now be something
             if ($this->campus_id == '') {
                 die("ERROR - campusID not set to anything<br/>");
             }
         }
     }
     /*** end privilege checking and campus droplist setup ***/
     //         echo 'campus = '.$this->campus_id;
     // create new rowManager (a List Iterator obj.)
     $statuses = '0,1,6';
     // filter by assignment status in ('undefined', 'current student', 'unknown')
     $this->rowManager = new PersonYearList($this->campus_id, $statuses, 'year_id,person_lname');
     // figure out the important fields for the rowItems
     $fieldsOfInterest = implode(',', $this->formFields);
     $this->primaryIDs = array();
     // for each row item ...
     $this->rowManager->setFirst();
     $i = 0;
     $valid_values = explode(',', RowManager_PersonYearManager::FIELD_LIST);
     while ($rowItem = $this->rowManager->getNext()) {
         // make sure rowItems have valid entries in the DB
         if (!$rowItem->isLoaded()) {
             $rowItem->createNewEntry();
         }
         // set the fields of interest ...
         $rowItem->setFieldsOfInterest($fieldsOfInterest);
         // get the primaryID of this rowItem
         $primaryID = $rowItem->getPrimaryKeyValue();
         $this->primaryIDs[$i] = $primaryID;
         $person_id = -1;
         // now initialize beginning form values from rowItem object
         for ($indx = 0; $indx < count($this->formFields); $indx++) {
             $key = $this->formFields[$indx];
             if (in_array($key, $valid_values)) {
                 $this->formValues[$key . $primaryID] = $rowItem->getValueByFieldName($key);
                 if ($key == 'person_id') {
                     $person_id = $this->formValues[$key . $primaryID];
                 }
             } else {
                 if ($person_id != '-1') {
                     $person_manager = new RowManager_PersonManager($person_id);
                     $this->formValues[$key . $primaryID] = $person_manager->getValueByFieldName($key);
                 } else {
                     $this->formValues[$key . $primaryID] = "";
                 }
             }
         }
         // next field
         $i++;
     }
     // next rowItem in rowManager
     //         echo 'array = <pre>'.print_r($this->formValues,true).'</pre>';
     // now initialize the labels for this page
     // start by loading the default field labels for this Module
     $languageID = $viewer->getLanguageID();
     $seriesKey = modulecim_hrdb::MULTILINGUAL_SERIES_KEY;
     $pageKey = modulecim_hrdb::MULTILINGUAL_PAGE_FIELDS;
     $this->labels = new MultilingualManager($languageID, $seriesKey, $pageKey);
     // then load the page specific labels for this page
     $pageKey = FormProcessor_EditStudentYearInSchool::MULTILINGUAL_PAGE_KEY;
     $this->labels->loadPageLabels($pageKey);
     // load the site default form link labels
     $this->labels->setSeriesKey(SITE_LABEL_SERIES_SITE);
     $this->labels->loadPageLabels(SITE_LABEL_PAGE_FORM_LINKS);
 }
 /**
  * function __construct
  * <pre>
  * Initialize the object.
  * </pre>
  * @param $pathModuleRoot [STRING] The path to the module's root dir.
  * @param $viewer [OBJECT] The viewer object.
  * @param $sortBy [STRING] Field data to sort listManager by.
  * @param $managerInit [INTEGER] Initialization value for the listManager.
  * @return [void]
  */
 function __construct($pathModuleRoot, $viewer, $sortBy, $year_id = "", $campus_id = "")
 {
     parent::__construct(page_ViewStudentYearInSchool::DISPLAY_FIELDS);
     $this->pathModuleRoot = $pathModuleRoot;
     $this->viewer = $viewer;
     $this->year_id = $year_id;
     $this->campus_id = $campus_id;
     // echo 'campusID['.$this->campus_id.']<br/>';
     //        $this->managerInit = $managerInit;
     // Now load the access Priviledge manager of this viewer
     $this->adminManager = new RowManager_AdminManager();
     // Get the person ID
     $accessManager = new RowManager_AccessManager();
     $accessManager->loadByViewerID($this->viewer->getViewerID());
     $personID = $accessManager->getPersonID();
     // Get the permissions the person has.
     $this->adminManager->loadByPersonID($personID);
     // need to filter displayed data by campus associated with campus admin
     $campusAdminSearchCondition = '';
     if ($this->adminManager->hasSitePriv()) {
         $campusManager = new RowManager_CampusManager();
         $campusManager->setSortOrder('campus_desc');
         $this->campusList = $campusManager->getListIterator();
         $this->accessibleCampuses = $this->campusList->getDropListArray();
     } else {
         if ($this->adminManager->hasCampusPriv()) {
             $campusAdminManager = new RowManager_CampusAdminManager();
             $adminID = $this->adminManager->getID();
             // echo 'adminID['.$adminID.']<br/>';
             $campusAdminManager->setAdminID($adminID);
             $campusList = $campusAdminManager->getListIterator();
             //$multiTableManager->getListIterator();
             $campusArray = $campusList->getDataList();
             $campusIDsList = "";
             // init the CSV of campus IDs associated with admin
             reset($campusArray);
             foreach (array_keys($campusArray) as $k) {
                 $record = current($campusArray);
                 $campusIDsList .= $record['campus_id'] . ',';
                 // create list of admin campuses
                 next($campusArray);
             }
             $campusIDsList = substr($campusIDsList, 0, -1);
             // remove last comma
             $campusAdminSearchCondition = 'cim_hrdb_assignment.campus_id in (' . $campusIDsList . ')';
         } else {
             if ($this->adminManager->isStaff($viewer->getID())) {
                 $staffManager = new RowManager_StaffManager();
                 $staffManager->setPersonID($personID);
                 $multiTableManager = new MultiTableManager();
                 $multiTableManager->addRowManager($staffManager);
                 $multiTableManager->setSortOrder('campus_desc');
                 $assignmentManager = new RowManager_AssignmentsManager();
                 $multiTableManager->addRowManager($assignmentManager, new JoinPair($assignmentManager->getJoinOnPersonID(), $staffManager->getJoinOnPersonID()));
                 $campusManager = new RowManager_CampusManager();
                 $multiTableManager->addRowManager($campusManager, new JoinPair($campusManager->getJoinOnCampusID(), $assignmentManager->getJoinOnCampusID()));
                 $this->campusList = $multiTableManager->getListIterator();
                 $campusIDsList = "";
                 // init the CSV of campus IDs associated with admin
                 $this->campusList->setFirst();
                 while ($this->campusList->moveNext()) {
                     $campusAssignObject = $this->campusList->getCurrent(new RowManager_AssignmentsManager());
                     $campusObject = $this->campusList->getCurrent(new RowManager_CampusManager());
                     $campusIDsList .= $campusAssignObject->getCampusID() . ',';
                     // create list of admin campuses
                 }
                 $campusIDsList = substr($campusIDsList, 0, -1);
                 // remove last comma
                 $campusAdminSearchCondition = 'cim_hrdb_assignment.campus_id in (' . $campusIDsList . ')';
             }
         }
     }
     $yearManager = new RowManager_YearInSchoolManager();
     $yearManager->setSortOrder('year_id');
     $this->yearValueList = $yearManager->getListIterator();
     $this->yearValues = $this->yearValueList->getDropListArray();
     // Add value to drop-list for showing person data for people not having person_year record
     $keys = array_keys($this->yearValues);
     $this->UNASSIGNED_IDX = $keys[count($this->yearValues) - 1] + 1;
     // assumes autoincrement is active on table
     $this->yearValues[$this->UNASSIGNED_IDX] = page_ViewStudentYearInSchool::UNASSIGNED;
     // 					echo 'values = <pre>'.print_r($this->yearValues, true).'</pre>';
     // modify the year_id if necessary
     if ($this->year_id == page_ViewStudentYearInSchool::DISPLAY_ALL_ID) {
         // setting the year_id to blank will get entries from all the years
         $this->year_id = '';
     } else {
         if ($this->year_id == '') {
             // no campus has been specified
             // choose a default campus if none specified
             // echo 'No campus specified<br/>';
             // get the first element from the accessible list
             foreach ($this->yearValues as $key => $value) {
                 $this->year_id = $key;
                 break;
             }
             // assert campus_id should now be something
             if ($this->year_id == '') {
                 die("ERROR - year_id not set to anything<br/>");
             }
         }
     }
     $dataAccessObject = new MultiTableManager();
     // Check if regular choice made (i.e. person has some year_in_school record)
     if ($this->year_id != $this->UNASSIGNED_IDX) {
         $personYearManager = new RowManager_PersonYearManager();
         $personYearManager->setYear($this->year_id);
         // SOMEWHAT REDUNDANT GIVEN addSearchCondition (which is required)
         $dataAccessObject->addRowManager($personYearManager);
         $yearManager = new RowManager_YearInSchoolManager();
         $joinPair = new JoinPair($personYearManager->getJoinOnYearID(), $yearManager->getJoinOnYearID());
         $dataAccessObject->addRowManager($yearManager, $joinPair);
         $personManager = new RowManager_PersonManager();
         $joinPair1 = new JoinPair($personManager->getJoinOnPersonID(), $personYearManager->getJoinOnPersonID());
         $dataAccessObject->addRowManager($personManager, $joinPair1);
         $assignmentManager = new RowManager_AssignmentsManager();
         $joinPair2 = new JoinPair($personYearManager->getJoinOnPersonID(), $assignmentManager->getJoinOnPersonID());
         $dataAccessObject->addRowManager($assignmentManager, $joinPair2);
         $campusManager = new RowManager_CampusManager();
         $joinPair3 = new JoinPair($assignmentManager->getJoinOnCampusID(), $campusManager->getJoinOnCampusID());
         $dataAccessObject->addRowManager($campusManager, $joinPair3);
         if ($sortBy == '') {
             $sortBy = 'campus_shortDesc,person_lname';
         }
         if ($this->year_id != '') {
             $dataAccessObject->addSearchCondition('cim_hrdb_person_year.year_id = ' . $this->year_id);
         }
         // filter by campuses assigned to this campus admin
         if ($campusAdminSearchCondition != '') {
             $dataAccessObject->addSearchCondition($campusAdminSearchCondition);
         }
         $dataAccessObject->setSortOrder($sortBy);
         $this->listManager = $dataAccessObject->getListIterator();
     } else {
         // 	        $personYearManager = new RowManager_PersonYearManager();
         // 	        $personYearManager->setYear($this->year_id);	// SOMEWHAT REDUNDANT GIVEN addSearchCondition (which is required)
         // 	        $dataAccessObject->addRowManager( $personYearManager );
         //
         // 	        $yearManager = new RowManager_YearInSchoolManager();
         // 	        $joinPair = new JoinPair($personYearManager->getJoinOnYearID(), $yearManager->getJoinOnYearID());
         // 	        $dataAccessObject->addRowManager( $yearManager, $joinPair );
         $personManager = new RowManager_PersonManager();
         $dataAccessObject->addRowManager($personManager);
         $assignmentManager = new RowManager_AssignmentsManager();
         $joinPair2 = new JoinPair($personManager->getJoinOnPersonID(), $assignmentManager->getJoinOnPersonID());
         $dataAccessObject->addRowManager($assignmentManager, $joinPair2);
         $campusManager = new RowManager_CampusManager();
         $joinPair3 = new JoinPair($assignmentManager->getJoinOnCampusID(), $campusManager->getJoinOnCampusID());
         $dataAccessObject->addRowManager($campusManager, $joinPair3);
         if ($sortBy == '') {
             $sortBy = 'campus_shortDesc,person_lname';
         }
         // get sub-query data for filtering out registrants that have already been registered for event
         $subManager = new RowManager_PersonYearManager();
         $personYearManager = new MultiTableManager();
         $personYearManager->addRowManager($subManager);
         $personYearManager->setFieldList('person_id');
         $registered_SQL = $personYearManager->createSQL();
         //          echo "<br>CREATED SQL 1 = ".$registered_SQL;
         // actually creates the sub-query ensuring that registrants listed do NOT have personyear records
         $negateSubQuery = true;
         $addSubQuery = true;
         $dataAccessObject->constructSubQuery('person_id', $registered_SQL, $negateSubQuery, $addSubQuery);
         // filter by campuses assigned to this campus admin
         if ($campusAdminSearchCondition != '') {
             $dataAccessObject->addSearchCondition($campusAdminSearchCondition);
         }
         $dataAccessObject->setSortOrder($sortBy);
         $this->listManager = $dataAccessObject->getListIterator();
     }
     /** TEST **/
     //         $values = $this->listManager->getDataList();
     //         echo 'values found = <pre>'.print_r($values,true).'</pre>';
     /** END TEST **/
     // now initialize the labels for this page
     // start by loading the default field labels for this Module
     $languageID = $viewer->getLanguageID();
     $seriesKey = modulecim_hrdb::MULTILINGUAL_SERIES_KEY;
     $pageKey = modulecim_hrdb::MULTILINGUAL_PAGE_FIELDS;
     $this->labels = new MultilingualManager($languageID, $seriesKey, $pageKey);
     // then load the page specific labels for this page
     $pageKey = page_ViewStudentYearInSchool::MULTILINGUAL_PAGE_KEY;
     $this->labels->loadPageLabels($pageKey);
     $this->labels->setSeriesKey(SITE_LABEL_SERIES_SITE);
     $this->labels->loadPageLabels(SITE_LABEL_PAGE_FORM_LINKS);
 }
Beispiel #16
0
 /** 
  * function __construct
  * This is the class constructor for Viewer class
  * Initialize a Viewer and determine if they are properly authenticated. 	
  * <pre><code>
  * Save the DB connection Info
  * If no session ID is set then
  *    set the Session ID to empty string
  * end if
  * Get current viewer ID from session ID
  * If viewer ID is empty then
  *    if isDestroySession is set then
  *        Destroy the Session
  *    end if
  *    initialize Empty UnAuthorized Viewer ID
  * else 
  *     User Credientials are valid so ...
  *	 Mark as Valid Authentication	
  *     
  *	 Prepare an SQL statement to lookup the viewer info from the DB
  *	 Now load the Data from the DB
  * end if
  * </pre>
  * @param $isDestroySession [BOOL] Should we destroy the session data if not authenticated?
  * @param $dbName [STRING] The name of the database the viewer info is stored in
  * @param $dbPath [STRING] The path of the database the viewer info is stored in
  * @param $dbUser [STRING] The login ID for the database the viewer info is stored in
  * @param $dbPassword [STRING] The password of the database the viewer info is stored in
  */
 function __construct($isDestroySession = true, $dbName = SITE_DB_NAME, $dbPath = SITE_DB_PATH, $dbUser = SITE_DB_USER, $dbPassword = SITE_DB_PWORD)
 {
     // if no session ID is set then
     if (!isset($_SESSION[SESSION_ID_ID])) {
         // set the Session ID to empty string
         $_SESSION[SESSION_ID_ID] = '';
     }
     if ($_SESSION[SESSION_ID_ID] == '') {
         $_SESSION[SESSION_ID_ID] = 0;
     }
     // Get current viewer ID from session ID
     $this->viewerID = $_SESSION[SESSION_ID_ID];
     // attempt to load a viewerManager object with current viewerID
     $this->viewerManager = new RowManager_ViewerManager($this->viewerID);
     if ($this->viewerManager->isLoaded()) {
         // Update current Session ID with current ViewerID
         $_SESSION[SESSION_ID_ID] = $this->viewerID;
         if ($this->viewerManager->isActive()) {
             $this->isAuthenticated = true;
         } else {
             $this->isAuthenticated = false;
         }
     } else {
         // Info not stored in session, get from GCX
         $this->isAuthenticated = false;
         if (CASUser::checkAuth()) {
             if (!empty($_SESSION['phpCAS']['guid'])) {
                 if ($this->validateLogin($_SESSION['phpCAS']['guid'])) {
                     // a user with this GUID exists in our system
                     $this->isAuthenticated = true;
                 } else {
                     // code added by Russ September 11, 2009
                     // a user with this GUID does not exist in our system - create them
                     $guid = $_SESSION['phpCAS']['guid'];
                     // echo "The GUID[".$guid."]<br/>";
                     $gcxUsername = $_SESSION['phpCAS']['user'];
                     // echo "The gcxUsername[".$gcxUsername."]<br/>";
                     // the gcxUsername is (supposed to be) an email
                     // check to see if there is a cim_hrdb_person record with this email
                     // the comparison needs to be case insensitive (since mysql is insensitive by default, no special doctoring is needed)
                     // search for person record
                     $personManager = new RowManager_PersonManager();
                     $foundPerson = $personManager->loadByEmail($gcxUsername);
                     // get the personID of the person that was searched
                     $personID = $personManager->getID();
                     // if record does not exist
                     // create one
                     // update the personID
                     if (!$foundPerson) {
                         // create a new person record
                         $newpersonManager = new RowManager_PersonManager();
                         $newpersonManager->setEmail($gcxUsername);
                         $newpersonManager->createNewEntry();
                         $personID = $newpersonManager->getID();
                     }
                     // link the personID to the GUID/viewer in the cim_hrdb_access table
                     // first, check to see if any entry already exists in the access table
                     // if foundPerson is true above, it's possible (may have been linked to old viewer/username but not promoted to GCX account yet)
                     $accessManager = new RowManager_AccessManager();
                     $accessEntryFound = $accessManager->loadByPersonID($personID);
                     $viewerID = -1;
                     $createNewViewer = true;
                     if ($accessEntryFound) {
                         $viewerID = $accessManager->getViewerID();
                         $viewerManager = new RowManager_ViewerManager($viewerID);
                         // double check to make sure the viewer referenced in the access table actually exists
                         $viewerAlreadyExists = $viewerManager->isLoaded();
                         if ($viewerAlreadyExists) {
                             // no need to create a new viewer
                             $createNewViewer = false;
                             // update the existing viewer with the GUID and gcxUsername
                             $viewerManager->setGUID($guid);
                             $viewerManager->setUserID($gcxUsername);
                             $viewerManager->setLastLogin();
                             $viewerManager->updateDBTable();
                         }
                         // viewerAlreadyExists
                     }
                     // accessEntryFound
                     if ($createNewViewer) {
                         // create new viewer (user)
                         $newviewerManager = new RowManager_ViewerManager();
                         $newviewerManager->setPassWord('xxx');
                         $newviewerManager->setUserID($gcxUsername);
                         $newviewerManager->setLanguageID(1);
                         // english
                         // TODO this value should not be hard-coded for the account group
                         $newviewerManager->setAccountGroupID(15);
                         // the 'unknown' group
                         $newviewerManager->setIsActive(true);
                         $newviewerManager->setGUID($guid);
                         $newviewerManager->setLastLogin();
                         $newviewerManager->createNewEntry();
                         $viewerID = $newviewerManager->getID();
                         // get the ID of the newly created viewer
                         if ($accessEntryFound) {
                             // update the access table to reference the newly created viewer for the persoa
                             // this is the case where an access table entry may have been orphaned due to the deletion of a viewer
                             $accessManager->setViewerID($viewerID);
                             $accessManager->updateDBTable();
                         } else {
                             // create an access table entry
                             $newaccessManager = new RowManager_AccessManager();
                             $newaccessManager->setViewerID($viewerID);
                             $newaccessManager->setPersonID($personID);
                             $newaccessManager->createNewEntry();
                         }
                     }
                     // put into the 'all' access group
                     $viewerAccessGroupManager = new RowManager_ViewerAccessGroupManager();
                     $viewerAccessGroupManager->setViewerID($viewerID);
                     $viewerAccessGroupManager->setAccessGroupID(ALL_ACCESS_GROUP);
                     // add to the 'all' access group
                     $viewerAccessGroupManager->createNewEntry();
                     // Debugging code added by Russ Martin
                     // echo "validate login failed<br/>";
                     // echo "<pre>".print_r($_SESSION,true)."</pre>";
                     // try again to see if everything updated correctly
                     if ($this->validateLogin($guid)) {
                         // a user/viewer with this GUID now exists in our system
                         $this->isAuthenticated = true;
                     } else {
                         echo "Something has gone wrong: gcxUsername[" . $gcxUsername . "], guid[" . $guid . "]<br/>";
                     }
                 }
             } else {
                 // Debugging code added by Russ Martin
                 // echo "session variable for storing GUID is empty<br/>";
             }
         } else {
             // Debugging code added by Russ Martin
             // echo "CASUser::checkAuth() failed<br/>";
         }
     }
     // set hasSession
     $this->hasSession = $this->viewerID != '';
     // if no session
     if (!$this->hasSession) {
         // User Credentials are invalid so
         // if they want me to destroy the session then
         if ($isDestroySession == true) {
             // Remove session
             // session_destroy();
         }
     }
 }
Beispiel #17
0
function process_Form($sqlResult, $template, $errorMessages)
{
    //get the names that are being searched
    $fName = $_REQUEST['fName'];
    $lName = $_REQUEST['lName'];
    //create the needed row managers
    $personM = new RowManager_PersonManager();
    $accessM = new RowManager_AccessManager();
    $viewerM = new RowManager_ViewerManager();
    //setup the join pair needed
    $join = new JoinPair($personM->getJoinOnFieldX('person_id'), $accessM->getJoinOnFieldX('person_id'));
    //create the multi table manager and initialize it
    $MTM = new MultiTableManager();
    $MTM->addRowManager($personM);
    $MTM->addRowManager($accessM, $join);
    //if there is a first name being searched - add that as a condition
    if ($fName != "") {
        $MTM->constructSearchCondition('person_fname', ' LIKE ', '%' . $fName . '%', true);
        $personM->constructSearchCondition('person_fname', ' LIKE ', '%' . $fName . '%', true);
    }
    //if there is a last name being searched - add that as a condition
    if ($lName != "") {
        $MTM->constructSearchCondition('person_lname', ' LIKE ', '%' . $lName . '%', true);
        $personM->constructSearchCondition('person_lname', ' LIKE ', '%' . $lName . '%', true);
    }
    //jump to a display function to show what was reteived from the database
    $rows = showContents($personM->find(), $personM, $personM->getFields());
    echo '<b>' . $rows . ' accounts found in the person table.</b><br><br>';
    //jump to a display function to show what was reteived from the database
    $sqlResult = $MTM->find();
    echo '<b>' . $sqlResult->getRowCount() . ' connections made between person table and access groups.</b><br>';
    $rows = showContents($sqlResult, $personM, $personM->getFields());
    $sqlResult->setFirst();
    $viewM = new RowManager_ViewerManager();
    for ($i = 0; $i < $sqlResult->getRowCount(); $i++) {
        $sqlResult->getNext($personM);
        $f_name[] = $personM->getValueByFieldName('person_fname');
        $l_name[] = $personM->getValueByFieldName('person_lname');
        $person_id[] = $personM->getValueByFieldName('person_id');
        $sqlResult->getCurrent($accessM);
        $join = new JoinPair($accessM->getJoinOnFieldX('viewer_id'), $viewerM->getJoinOnFieldX('viewer_id'));
        $MTM = new MultiTableManager();
        $MTM->addRowManager($accessM);
        $MTM->addRowManager($viewerM, $join);
        $MTM->constructSearchCondition('viewer_id', '=', $accessM->getValueByFieldName('viewer_id'), true);
        $sqlResult2 = $MTM->find();
        $sqlResult2->getNext($viewM);
        $viewer_id[] = $viewM->getValueByFieldName('viewer_id');
        $user_id[] = $viewM->getValueByFieldName('viewer_userID');
    }
    if ($sqlResult->getRowCount() < 1) {
        $errorMessages = 'Failed to join database to get label';
        $template->set('f_name', null);
    } else {
        $template->set('f_name', $f_name);
        $template->set('l_name', $l_name);
        $template->set('viewer_id', $viewer_id);
        $template->set('person_id', $person_id);
        $template->set('user_id', $user_id);
    }
}