Skip to content
Snippets Groups Projects
Select Git revision
  • be48025b36ce6123b0ba1f75ce6b0e94573dc4a6
  • master default
  • disable-new-requests
  • fix-bulletin-view-missing-notes-error
  • add-missing-queue-managers
  • projects-task-53
  • projects-task-51
  • projects-task-43
  • projects-task-24
  • projects-task-31
  • projects-task-32
  • projects-task-8
  • project-setup-docs
  • projects-task-28
  • projects-task-27
  • projects-task-9
  • projects-task-7
  • mass-update-course-codes-in-sections
  • wdn-four
  • learning-outcomes
  • additional-bulletin-pages
  • svn-redesign
  • svn-popups
  • svn-trunk
  • svn-performance
  • svn-tim
26 results

RequestController.php

Blame
  • admin.php 6.39 KiB
    <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
    
    class Admin extends CI_Controller 
    {
        public function __construct()
        {
            parent::__construct();
            
            if (!$this->is_logged_in()) {
                redirect('adminlogin');
            }
        }
        
        public function index()
        {
            $users = $this->contacts_model->get_users();
            
            $this->load->view('admin', array(
                'users' => $users
            ));
        }
        
        public function add()
        {
            $this->load->view('admin_add');
        }
        
        public function add_user()
        {
            sleep(2);
            $this->load->library('form_validation');
            $this->form_validation->set_rules('email', 'Email', 'required|max_length[40]|valid_email');
            $this->form_validation->set_rules('pwd', 'Password', 'required|max_length[20]|alpha_numeric');
            
            if ($this->form_validation->run() == FALSE) {
                $json = json_encode(array(
                    'isSuccessful' => FALSE,
                    'message' => "<strong>Adding</strong> failed!"
                ));
                echo $json;
            } else {
                $is_added = $this->contacts_model->add_user($this->input->post('email'), $this->input->post('pwd'));
                if ($is_added) {
                    $message = "<strong>".$this->input->post('email')."</strong> has been added!";
                    $json = json_encode(array(
                        'isSuccessful' => TRUE,
                        'message' => $message
                    ));
                    echo $json;
                } else {
                    $message = "<strong>".$this->input->post('email')."</strong> already exists!";
                    $json = json_encode(array(
                        'isSuccessful' => FALSE,
                        'message' => $message
                    ));
                    echo $json;
                }
            }
        }
        
        public function delete()
        {
            $users = $this->contacts_model->get_users();
            
            $this->load->view('admin_delete', array(
                'users' => $users 
            ));
        }
        
        public function delete_user()