예제 #1
0
 public function getLists()
 {
     $user = new User_model();
     if (!$user->loadPropertiesFromPrimaryKey($_SESSION['UserID']) || !$user->isAdmin()) {
         header("Content-type: text/plain", true, 403);
         echo "Invalid session user credentials";
         return;
     }
     $advisors = User_model::getAllAdvisors();
     $programChairs = User_model::getAllProgramChairs();
     foreach ($advisors as $key => $advisor) {
         foreach ($programChairs as $programChair) {
             if ($advisor->getUserID() == $programChair->getUserID()) {
                 unset($advisors[$key]);
                 break;
             }
         }
     }
     $response = array("advisors" => array(), "programChairs" => array());
     foreach ($advisors as $advisor) {
         array_push($response['advisors'], array('userid' => $advisor->getUserID(), 'name' => $advisor->getName()));
     }
     foreach ($programChairs as $programChair) {
         array_push($response['programChairs'], array('userid' => $programChair->getUserID(), 'name' => $programChair->getName()));
     }
     header("Content-type: application/json", true, 200);
     echo json_encode($response);
 }
예제 #2
0
 public function index($advisorUserID = "all", $studentUserID = "all", $advisingLogEntryType = "all")
 {
     $user = new User_model();
     if (!$user->loadPropertiesFromPrimaryKey($_SESSION['UserID'])) {
         redirect('Login/logout');
     }
     if (!$user->isProgramChair() && !$user->isAdvisor()) {
         redirect('Login/logout');
     }
     if ($advisingLogEntryType === "all") {
         $advisingLogEntryType = null;
     }
     if ($advisorUserID === "all") {
         $advisorUserID = null;
     }
     if ($user->isAdvisor() && !$user->isProgramChair() && ($advisorUserID == null || $advisorUserID != $user->getUserID())) {
         $advisorUserID = $user->getUserID();
     }
     if ($studentUserID === "all") {
         $studentUserID = null;
     }
     $advisors = $user->isProgramChair() ? User_model::getAllAdvisors() : array($user);
     $students = $user->isProgramChair() ? array() : $user->getAdvisees();
     $types = Advising_log_entry_model::getAllAdvisingLogEntryTypes();
     $data = array('user' => $user, 'logEntries' => Advising_log_entry_model::getAllAdvisingLogEntries($advisorUserID, $studentUserID, $advisingLogEntryType), 'advisors' => $advisors, 'students' => $students, 'types' => $types, 'advisorUserID' => $advisorUserID == null ? "all" : $advisorUserID, 'studentUserID' => $studentUserID == null ? "all" : $studentUserID, 'advisingLogEntryType' => $advisingLogEntryType == null ? "all" : $advisingLogEntryType);
     $this->load->view('advisinglog_index_view', $data);
 }