Example #1
0
function user_options($add_blank = FALSE)
{
    $u = new User_m();
    $u->where('username !=', 'mannysoft');
    $rows = $u->order_by('username')->get();
    $minute = 0;
    if ($add_blank == TRUE) {
        $options[''] = '';
    }
    $options[0] = '-- All --';
    foreach ($rows as $row) {
        $options[$row->username] = $row->username . ' -- ' . $row->lname . ', ' . $row->fname;
    }
    return $options;
}
Example #2
0
 function get_all_posts()
 {
     //        $limit
     //get all posts
     //get all comments according to the post
     //get all replies according to the comment
     $this->load->model('post_m');
     $post_m = new Post_m();
     $all_post = $post_m->get_all_posts();
     $this->load->model('comment_m');
     $comment_m = new Comment_m();
     $this->load->model('reply_m');
     $reply_m = new Reply_m();
     $this->load->model('user_m');
     $user_m = new User_m();
     for ($i = 0; $i < count($all_post); $i++) {
         $comments = $comment_m->get_comments($all_post[$i]["post_id"]);
         for ($j = 0; $j < count($comments); $j++) {
             $replies = $reply_m->get_reply($comments[$j]["comment_id"]);
             $comments[$j]["replies"] = $replies;
             $comments[$j]["commented_user"] = $user_m->getUserName($comments[$j]["user_id"])[0]["name"];
         }
         $all_post[$i]["comments"] = $comments;
         $comment_username = $all_post[$i]["post_user"] = $user_m->getUserName($all_post[$i]["user_id"])[0]["name"];
     }
     //var_dump($all_post);
     //       for($i = 0 ; $i < count($all_post) ; $i++){
     //           echo $all_post[$i]["post"]."</br>";
     //           $comments = $all_post[$i]["comments"];
     //           for($j = 0 ; $j < count($comments) ; $j++){
     //               echo "\t".$comments[$j]["description"]."</br>";
     //               $replies = $comments[$j]["replies"];
     //               for($k = 0 ; $k < count($replies) ; $k++){
     //                   echo "\t \t".$replies[$k]["description"]."</br>";
     //               }
     //           }
     //       }
     $data["all_posts"] = $all_post;
     $data["user_name"] = $this->session->userdata('userName');
     $this->load->view('post_test', $data);
 }
 private function loginAsAnonymous($userName)
 {
     $this->load->model('user_m');
     $user = new User_m();
     $results = $user->authenticateAsAnonymous($userName);
     if (count($results) == 1) {
         $this->load->library('session');
         $this->session->set_userdata(array('userId' => $results[0]->id, 'userName' => $results[0]->name, 'userRole' => $results[0]->user_role));
         $this->load->model('permission_m');
         $permision = new Permission_m();
         $results = $permision->getAlowedURLsByUserRole($results[0]->user_role);
         $resultsArray = array();
         foreach ($results as $key => $value) {
             $resultsArray[] = $value->url;
         }
         $this->session->set_userdata(array('permissions' => $resultsArray));
         $this->output->set_status_header('200');
     } else {
         $this->output->set_status_header('401');
     }
 }
Example #4
0
 function show_login()
 {
     $data = array();
     $data['system_message'] = '';
     if (Input::get('op')) {
         $username = Input::get('username');
         $password = Input::get('password');
         if ($username == "" || $password == "") {
             $data['system_message'] = 'Please complete the fields!';
         } else {
             // Encript password
             $password = do_hash($password, 'md5');
             $u = new User_m();
             $u->where('username', $username);
             $u->where('password', $password);
             $u->where('stat', 'Active');
             $u->get();
             // Check if the user exists
             if ($u->exists()) {
                 // Lets check if the idle function is enable
                 // Seconds before logout if user is idle
                 $seconds_user_idle = Setting::getField('seconds_user_idle');
                 if ($seconds_user_idle != '') {
                     unset($this->session->sess_expiration);
                     $this->session->sess_expiration = $seconds_user_idle;
                     $this->load->library('session');
                 }
                 $session_data = array('user_id' => $u->id, 'username' => $u->username, 'lname' => $u->lname, 'office_id' => $u->office_id, 'group_id' => $u->group_id, 'user_type' => $u->user_type);
                 Session::put($session_data);
                 redirect('home/home_page', 'refresh');
             } else {
                 $data['system_message'] = 'Invalid username or password!';
             }
         }
     }
     return View::make('login', $data);
 }
});
</script>

<div id="general" class="settings_tab">
<form action="" method="post">
<table width="100%" border="0" cellpadding="5" cellspacing="5" class="type-one">
  <tr class="type-one-header">
    <th width="21%">General</th>
    <th width="72%">&nbsp;</th>
    <th width="7%"><input name="active_tabs" type="hidden" id="active_tabs" value="general" /></th>
  </tr>
  <tr>
    <td><input name="op" type="hidden" id="op" value="1" /></td>
    <td>
	<?php 
    $u = new User_m();
    $u->get_by_username(Session::get('username'));
    ?>
    <?php 
    if ($u->group_id == '1000') {
        ?>
    <?php 
        echo ' LGU Code: ' . form_input('lgu_code', $settings['lgu_code']);
        ?>
    <?php 
    }
    ?>
&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
Example #6
0
 function print_user_access()
 {
     if ($this->ci->input->is_ajax_request()) {
         return;
     }
     return;
     $u = new User_m();
     $u->get_by_username($this->ci->session->userdata('username'));
     $u->get();
     $p = new Permission_m();
     $permissions = $p->get_by_group_id($u->group_id);
     foreach ($this->permissions as $permission) {
         echo '<br>' . $permission->module;
         $methods = json_decode($permission->roles);
         $i = 0;
         if (is_array($methods)) {
             foreach ($methods as $method) {
                 if ($i == 0) {
                     echo '<br>----';
                     $i++;
                 }
                 echo $method . ', ';
             }
         }
         //print_r($methods);
     }
     //print_r( $this->user_access);
 }
Example #7
0
<table width="100%" border="0" class="type-one">
  <tr class="type-one-header">
    <th width="2%"><input name="checkall" type="checkbox" id="checkall" onclick="select_all('log', '1');" value="1"/></th>
    <th width="7%"><strong>Username</strong></th>
    <th width="10%"><strong>Name
      <input name="op" type="hidden" id="op" value="1" />
    </strong></th>
    <th width="10%"><strong>Office</strong></th>
    <th width="11%"><strong>Activity</strong></th>
    <th width="16%"><strong>Details</strong></th>
    <th width="16%"><strong>Employee Affected </strong></th>
    <th width="13%"><strong>Date</strong></th>
    <th width="15%">&nbsp;</th>
  </tr>
  <?php 
$u = new User_m();
foreach ($logs as $log) {
    $id = $log['id'];
    $username = $log['username'];
    $employee_affected = $log['employee_id_affected'];
    $command = $log['command'];
    $details = $log['details'];
    $date = $log['date'];
    $u->get_by_username($username);
    $this->Employee->fields = array('lname', 'fname');
    $lname = '';
    $fname = '';
    $employee_info = $this->Employee->get_employee_info($employee_affected);
    if (!empty($employee_info)) {
        $lname = $employee_info['lname'];
        $fname = $employee_info['fname'];
 function up()
 {
     $lgu_code = Setting::getField('lgu_code');
     if ($lgu_code == 'marinduque_province') {
         $u = new User_m();
         $u->where('group_id !=', 1000);
         $users = $u->get();
         foreach ($users as $user) {
             //echo $user->user_type;
             //echo $user->group_id;
             // Lets update the
             $us = new User_m();
             $us->get_by_id($user->id);
             $us->group_id = $user->user_type;
             $us->save();
             // Lets assign permission
             if ($user->group_id == 5) {
                 $p = new Permission_m();
                 $p->where('group_id', $user->group_id);
                 $p->where('module', 'attendance')->get();
                 $p->group_id = $user->group_id;
                 $p->module = 'attendance';
                 $p->roles = json_encode(array('view_attendance', 'dtr'));
                 $p->save();
                 $p = new Permission_m();
                 $p->where('group_id', $user->group_id);
                 $p->where('module', 'leave_manage')->get();
                 $p->group_id = $user->group_id;
                 $p->module = 'leave_manage';
                 $p->roles = json_encode(array('file_leave', 'leave_apps', 'reports'));
                 $p->save();
                 $p = new Permission_m();
                 $p->where('group_id', $user->group_id);
                 $p->where('module', 'manual_manage')->get();
                 $p->group_id = $user->group_id;
                 $p->module = 'manual_manage';
                 $p->roles = json_encode(array('cto', 'cto_apps'));
                 $p->save();
             }
             if ($user->group_id == 3) {
                 $p = new Permission_m();
                 $p->where('group_id', $user->group_id);
                 $p->where('module', 'attendance')->get();
                 $p->group_id = $user->group_id;
                 $p->module = 'attendance';
                 $p->roles = json_encode(array('view_attendance', 'dtr', 'jo', 'double_entries', 'view_absences', 'view_late', 'view_ob', 'view_tardiness', 'view_ten_tardiness'));
                 $p->save();
                 $p = new Permission_m();
                 $p->where('group_id', $user->group_id);
                 $p->where('module', 'manual_manage')->get();
                 $p->group_id = $user->group_id;
                 $p->module = 'manual_manage';
                 $p->roles = json_encode(array('login', 'cto', 'cto_apps', 'cto_forward_balance', 'office_pass'));
                 $p->save();
             }
         }
         if ($this->db->table_exists('groups')) {
             $g = new Group_m();
             $g->get();
             // We will populate only if the groups
             // table is empty
             if (!$g->exists()) {
                 $this->db->order_by('id');
                 $q = $this->db->get('user_group');
                 if ($q->num_rows() > 0) {
                     foreach ($q->result_array() as $row) {
                         $g = new Group_m();
                         $g->name = $row['name'];
                         $g->description = $row['description'];
                         $g->save();
                     }
                 }
             }
         }
     }
 }