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); }
public function index() { //load models $this->load->model('Curriculum_model', 'Curriculum_course_slot_model', 'Course_model', 'User_model'); $this->load->helper('url'); $user = new User_model(); //~ //verify the user is valid and a program chair if (isset($_SESSION['UserID'])) { $user->loadPropertiesFromPrimaryKey($_SESSION['UserID']); if (!$user->isProgramChair()) { redirect('login'); } } else { redirect('login'); } $curriculum = new Curriculum_Model(); $_SESSION['maxCurriculumIndex'] = 1; $_SESSION['reqs'] = array(); //call and pass data to initial curriculum view $curriculums = $curriculum->getAllCurriculums(); $data = array(); //creating easy to use array for table foreach ($curriculums as $curr) { $arr = ['name' => $curr->getName(), 'id' => $curr->getCurriculumID(), 'date' => $curr->getDateCreated()]; array_push($data, $arr); } $this->load->view('curriculum_choice', array('data' => $data)); }
public function programChair() { //Load the program chair mainpage if user is a program chair if (!isset($_SESSION['UserID'])) { redirect('Login/logout'); } $user = new User_model(); if (!$user->loadPropertiesFromPrimaryKey($_SESSION['UserID'])) { redirect('Login/logout'); } if ($user->isProgramChair()) { $this->load->view('MainPages/pc_main_page', array('user' => $user)); } else { index(); } }
public function removeProgramChair() { $user = new User_model(); if (!$user->loadPropertiesFromPrimaryKey($_SESSION['UserID']) || !$user->isAdmin()) { header("Content-type: text/plain", true, 403); echo "Invalid session user credentials"; return; } if (!isset($_POST['userid'])) { header("Content-type: text/plain", true, 400); echo "Missing User ID"; return; } $m_user = new User_model(); if (!$m_user->loadPropertiesFromPrimaryKey($_POST['userid'])) { header("Content-type: text/plain", true, 400); echo "Invalid User ID"; return; } if ($m_user->isProgramChair()) { $m_user->removeRole(User_model::ROLE_PROGRAM_CHAIR); } header("Content-type: text/plain", true, 200); echo " "; }
public function confirm_remove() { if (!isset($_SESSION['UserID'])) { redirect('Login/logout'); } //Create new user and load its data $user = new User_model(); if (!$user->loadPropertiesFromPrimaryKey($_SESSION['UserID'])) { redirect('Login/logout'); } if (!$user->isProgramChair()) { redirect('Mainpage'); } $tcourse = $this->input->post("transferCourseID"); $t_course = new Student_transfer_course_model(); $norm_course = new Course_model(); //explode this, then load the data from pimary key, then load course from primary, then add equilvilent course $str_array = explode(",", $tcourse); $t_course->loadPropertiesFromPrimaryKey(intval($str_array[0])); $norm_course->loadPropertiesFromPrimaryKey(intval($str_array[1])); $t_course->removeEquivilentCourse($norm_course); redirect('Transfer_controller/viewIdMapping'); }
public function delete() { $user = new User_model(); if (!$user->loadPropertiesFromPrimaryKey($_SESSION['UserID'])) { redirect('Login/logout'); } if (!$user->isProgramChair()) { redirect('Login/logout'); } if (!$this->uri->segment(3)) { redirect('Coursemanager/index'); } $course = new Course_model(); if (!$course->loadPropertiesFromPrimaryKey($this->uri->segment(3))) { redirect('Coursemanager/index'); } $course->delete(); redirect('Coursemanager/index/' . $course->getCourseName()); }
private function checkSec() { //todo change this to false to enable security. $authorized = false; if (isset($_SESSION['UserID'])) { $userID = $_SESSION['UserID']; $loggedInUser = new User_model(); if ($loggedInUser->loadPropertiesFromPrimaryKey($userID)) { if ($loggedInUser->isAdmin() || $loggedInUser->isProgramChair()) { $authorized = true; } } } if (!$authorized) { redirect('Login/logout'); } }