public function run() { DB::table('userlevels')->delete(); $stamp = date('Y-m-d H:i:s'); $userlevels_array = array(array('userlevels_name' => 'Admin User', 'created_at' => $stamp, 'updated_at' => $stamp), array('userlevels_name' => 'Support User', 'created_at' => $stamp, 'updated_at' => $stamp), array('userlevels_name' => 'Staff User', 'created_at' => $stamp, 'updated_at' => $stamp)); foreach ($userlevels_array as $added_row) { Userlevel::create($added_row); } }
function login($username = '', $password = '') { $result = FALSE; $CI =& get_instance(); if (empty($username) or empty($password)) { return FALSE; } // check if it is a normal user $this->where('name', $username); $this->where('password', md5($password)); $this->get(); // if the user exists if ($this->exists()) { $result = TRUE; $lvl = new Userlevel(); $lvl->get_by_id($this->level); if ($lvl->exists()) { $CI->session->set_userdata('level', $lvl->level); } else { $CI->session->set_userdata('level', 0); } $CI->session->set_userdata('mode', 'view'); $CI->session->set_userdata('id', $this->id); $this->lastenter = $this->curenter; $this->curenter = $CI->input->ip_address(); $this->save(); } else { // check if it is the root $g_name = $CI->config->item('root'); $g_pass = $CI->config->item('root_password'); if ($username == $g_name and $password == $g_pass) { $result = TRUE; $CI->session->set_userdata('mode', 'edit'); $CI->session->set_userdata('id', -1); $CI->session->set_userdata('level', -1); } } // sync the user with the session $this->from_session(); // return the login result return $result; }
<?php include 'system_load.php'; //Including this file we load system. //user Authentication. authenticate_user('admin'); //user level object $new_userlevel = new Userlevel(); //installation form processing when submits. if (isset($_POST['settings_submit']) && $_POST['settings_submit'] == 'Yes') { //validation to check if fields are empty! if ($_POST['site_url'] == '') { $message = $language['site_url_empty']; } else { if ($_POST['email_from'] == '') { $message = $language['email_from_required']; } else { if ($_POST['email_to'] == '') { $message = $language['reply_cannot_empty']; } else { //adding site url set_option('site_url', $_POST['site_url']); set_option('site_name', $_POST['site_name']); set_option('email_from', $_POST['email_from']); set_option('email_to', $_POST['email_to']); set_option('public_key', $_POST['public_key']); set_option('private_key', $_POST['private_key']); set_option('redirect_on_logout', $_POST['redirect_on_logout']); set_option('language', $_POST['language']); set_option('skin', $_POST['skin']); set_option('maximum_login_attempts', $_POST['maximum_login_attempts']);
<?php $ci =& get_instance(); $ci->load->library('gui'); //getting the level; $id = $ci->uri->segment(5); $user = new User(); $user->get_by_id($id); $levels = new Userlevel(); $levels->get(); $lvls = array(); foreach ($levels->all as $item) { $lvls[$item->level] = $item->name; } echo $ci->gui->form($ci->app->app_url('editusraction'), array('level' => $ci->gui->dropdown("level", $user->level, $lvls), 'name' => $ci->gui->textbox("name", $user->name), 'password' => $ci->gui->password("password"), 'email' => $ci->gui->textbox("email", $user->email), '' => $ci->gui->button("submit", "Edit user", array("type" => "submit"))), '', array('id' => $user->id));
<?php $ci =& get_instance(); $ci->load->library('gui'); //getting the level; $id = $ci->uri->segment(5); $level = new Userlevel(); $level->get_by_id($id); echo $ci->gui->form($ci->app->app_url('editlvlaction'), array("Level name" => $ci->gui->textbox('name', $level->name), "Level number" => $ci->gui->number('level', $level->level), "" => $ci->gui->button('submit', 'Edit level', array('type' => 'submit'))), "", array('id' => $id));
<?php $ci =& get_instance(); $level = new Userlevel(); $level->get_by_id($ci->input->post('id')); $level->name = $ci->input->post('name'); $level->level = $ci->input->post('level'); $level->save(); $ci->app->add_info('level updated');
public function get_userlevel() { return Userlevel::whereUserlevels_id(Auth::user()->users_userlevels_fk)->first()->userlevels_name; }