D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home
/
jnclnmuac
/
public_html
/
grievance
/
sys_admin
/
application
/
models
/
admin
/
Filename :
UserManagement.php
back
Copy
<?php /** * Model Class For Handling All DB Operations Related To Users * * @author Softpro India Pvt. Ltd. */ defined('BASEPATH') OR exit('No direct script access allowed'); class UserManagement extends CI_Model { function __construct() { parent::__construct(); $this->load->database(); } function getTotalUsers() { $this->db->select("count(*) totalUsers"); $this->db->from('college_admins_and_users'); return $this->db->get(); } function createNewUser(array $newUserInfo) { $this->db->insert('college_admins_and_users', $newUserInfo); return $this->db->insert_id(); } function getUserInfoByMobileNumber($userMobile) { $this->db->select("*"); $this->db->from('college_admins_and_users'); $this->db->where('cau_mobile', $userMobile); return $this->db->get(); } function getUserInfoByEmail($userEmail) { $this->db->select("*"); $this->db->from('college_admins_and_users'); $this->db->where('cau_email', $userEmail); return $this->db->get(); } function getUserInfoBy($userId) { $this->db->select("*"); $this->db->from('college_admins_and_users'); $this->db->where('cau_id', $userId); return $this->db->get(); } function getUserFullInfoById($userId, $userRole, $userType) { $this->db->select("*"); $this->db->from('college_admins_and_users CAU'); $this->db->join('system_admin SA', 'CAU.cau_admin_opr_by = SA.sa_id'); $this->db->join('college_mst CM', 'CAU.clg_id = CM.clg_id'); if ($userType == 'S') { $this->db->join('course_mst CRSM', 'CAU.course_id = CRSM.course_id'); } $this->db->where('CAU.cau_id', $userId); $this->db->where('CAU.cau_user_role_flag', $userRole); $this->db->where('CAU.cau_user_type_flag', $userType); return $this->db->get(); } function getOnlyUsersFullInfo($userId) { $this->db->select("*"); $this->db->from('college_admins_and_users CAU'); $this->db->join('college_mst CM', 'CAU.clg_id = CM.clg_id'); $this->db->where('CAU.cau_id', $userId); $this->db->where('CAU.cau_user_role_flag', 'NA'); $this->db->where("CAU.cau_user_type_flag IN ('S','P','N','F','NA')"); $this->db->order_by('CAU.cau_signup_on desc'); return $this->db->get(); } function getOnlyGCellMgmtMembersFullInfo($userId) { $this->db->select("*"); $this->db->from('college_admins_and_users CAU'); $this->db->join('college_mst CM', 'CAU.clg_id = CM.clg_id'); $this->db->where('CAU.cau_id', $userId); $this->db->where("CAU.cau_user_role_flag IN ('GCM','MGMT')"); $this->db->where("CAU.cau_user_type_flag", "NA"); $this->db->order_by('CAU.cau_signup_on desc'); return $this->db->get(); } function getAllUsers($userType = '', $userRole = '') { $this->db->select('*'); $this->db->from('college_admins_and_users CAU'); $this->db->join('college_mst CLGM', 'CAU.clg_id=CLGM.clg_id'); if ($userType != '' && $userRole != '') { $this->db->where('CAU.cau_user_type_flag', $userType); $this->db->where('CAU.cau_user_role_flag', $userRole); } else if ($userType != '' && $userRole == '') { $this->db->where('CAU.cau_user_type_flag', $userType); } else if ($userType == '' && $userRole != '') { $this->db->where('CAU.cau_user_role_flag', $userRole); } else { $this->db->where("CAU.cau_user_role_flag", 'NA'); $this->db->where("CAU.cau_user_type_flag IN ('S','P','N','F','NA')"); } $this->db->order_by('CAU.cau_signup_on desc'); return $this->db->get(); } function updateUserInfo(array $userUpdatedInfo) { $this->db->where('cau_id', $userUpdatedInfo['cau_id']); return $this->db->update('college_admins_and_users', $userUpdatedInfo); } function isEmailSafeUpdateForUser($userId, $requestedEmail) { $this->db->select("*"); $this->db->from('college_admins_and_users'); $this->db->where('cau_email', $requestedEmail); $this->db->where('cau_id != ' . $userId); $result = $this->db->get()->result(); if (sizeof($result)) { return FALSE; } else { return TRUE; } } function isMobileSafeUpdateForUser($userId, $requestedMobile) { $this->db->select("*"); $this->db->from('college_admins_and_users'); $this->db->where('cau_mobile', $requestedMobile); $this->db->where('cau_id != ' . $userId); $result = $this->db->get()->result(); if (sizeof($result)) { return FALSE; } else { return TRUE; } } }