Esempio n. 1
0
/**
 * Index Page for this controller.
 *
 * Maps to the following URL
 * 		http://example.com/index.php/welcome
 *	- or -
 * 		http://example.com/index.php/welcome/index
 *	- or -
 * Since this controller is set as the default controller in
 * config/routes.php, it's displayed at http://example.com/
 *
 * So any other public methods not prefixed with an underscore will
 * map to /index.php/welcome/<method_name>
 * @see http://codeigniter.com/user_guide/general/urls.html
 */
public function index()
{
$user = new models\user();
 $user->setUsername("njenga");
 $user->setPassword("njenga");
 $user->setUserGroup("1");
 $this->em->persist($user);
$this->em->flush();
$this->load->view('welcome_message');
}
Esempio n. 2
0
 /**
  * define page title and load template files
  */
 public function index()
 {
     $this->data['title'] = 'Yimu Admin';
     // $course = new \models\courses;
     $user_model = new \models\user();
     // $total = $user_model->allUsers();
     $total = count($user_model->allUsers());
     $pages = new \helpers\paginator('10', 'p');
     $this->data['users'] = $user_model->allUsers($pages->get_limit());
     $pages->set_total($total);
     $path = DIR . 'dashboard/users?';
     $this->data['page_links'] = $pages->page_links($path, null);
     $this->data['title'] = 'Users';
     View::rendertemplate('header', $this->data);
     View::rendertemplate('sidebar', $this->data);
     View::render('user/user.index', $this->data);
     View::rendertemplate('footer', $this->data);
 }
Esempio n. 3
0
 /**
  * A pre-dispatch function
  * @param \zinux\kernel\routing\request $request
  */
 public function pre_auth_checkpoint(\zinux\kernel\routing\request $request)
 {
     # if user already signed in?
     if (models\user::HasSignedin()) {
         # no need for check
         return;
     }
     # a list of exception array({controller => array(actions)}) which does not need signin sig.
     $signin_free_ops = array("index" => array("signin", "signup", "activate"), "error" => "*");
     # the normalized currently requested {conttroller => action}
     $current_request = array("controller" => strtolower($request->controller->name), "action" => strtolower($request->action->name));
     # if current request's matches with an index in the signin free list
     if (isset($signin_free_ops[$current_request["controller"]]) && ($signin_free_ops[$current_request["controller"]] === "*" || in_array($current_request["action"], $signin_free_ops[$current_request["controller"]]))) {
         return;
     }
     throw new \zinux\kernel\exceptions\accessDeniedException();
 }
Esempio n. 4
0
 public function password()
 {
     $this->data['title'] = 'Change Password';
     $user_model = new \models\user();
     $user_id = \helpers\session::get('user')->user_id;
     $user_details = $user_model->get(array('user_id' => $user_id, 'user_password' => md5($_POST['old_password'])));
     if (isset($_POST['password1']) && !empty($_POST['password1'])) {
         if (count($user_details) > 0) {
             if ($_POST['password1'] == $_POST['password2']) {
                 //update user db
                 $update_array = array('user_password' => md5($_POST['password1']));
                 $update_array = \helpers\gump::xss_clean($update_array);
                 $update_array = \helpers\gump::sanitize($update_array);
                 $update_id = $user_model->updateId($update_array, $user_id);
                 if ($update_id > 0) {
                     $this->data['success'] = 'Password Changed';
                 } else {
                     $this->data['error'] = 'Operation Fails!';
                 }
             } else {
                 $this->data['error'] = 'Incorrect match, password change fails!';
             }
         } else {
             $this->data['error'] = 'Incorrect match, password change fails!';
         }
     }
     View::rendertemplate('header', $this->data);
     View::render('user/user.password', $this->data);
     View::rendertemplate('footer', $this->data);
 }