public function show() { $u = new User_model($this->template, $this->router->query_string); $u->show($this->router->id); $this->set_view("show"); $this->template->render(null, "html"); }
function restart() { $user = new User_model(); $dataU = $user->getData(); $content_view = $this->view->fetch('menu_view', array('data' => $dataU)); $this->view->display(LAYOUT, array('content' => $content_view)); }
public function index() { //load models $this->load->model('Curriculum_model', 'Curriculum_course_slot_model', 'Course_model', 'User_model'); $this->load->helper('url'); $user = new User_model(); //~ //verify the user is valid and a program chair if (isset($_SESSION['UserID'])) { $user->loadPropertiesFromPrimaryKey($_SESSION['UserID']); if (!$user->isProgramChair()) { redirect('login'); } } else { redirect('login'); } $curriculum = new Curriculum_Model(); $_SESSION['maxCurriculumIndex'] = 1; $_SESSION['reqs'] = array(); //call and pass data to initial curriculum view $curriculums = $curriculum->getAllCurriculums(); $data = array(); //creating easy to use array for table foreach ($curriculums as $curr) { $arr = ['name' => $curr->getName(), 'id' => $curr->getCurriculumID(), 'date' => $curr->getDateCreated()]; array_push($data, $arr); } $this->load->view('curriculum_choice', array('data' => $data)); }
public function removeProgramChair() { $user = new User_model(); if (!$user->loadPropertiesFromPrimaryKey($_SESSION['UserID']) || !$user->isAdmin()) { header("Content-type: text/plain", true, 403); echo "Invalid session user credentials"; return; } if (!isset($_POST['userid'])) { header("Content-type: text/plain", true, 400); echo "Missing User ID"; return; } $m_user = new User_model(); if (!$m_user->loadPropertiesFromPrimaryKey($_POST['userid'])) { header("Content-type: text/plain", true, 400); echo "Invalid User ID"; return; } if ($m_user->isProgramChair()) { $m_user->removeRole(User_model::ROLE_PROGRAM_CHAIR); } header("Content-type: text/plain", true, 200); echo " "; }
/** * Register new user * @return json */ public function autenticateUser() { if ($this->input->server('REQUEST_METHOD') == 'POST') { // loads $this->load->model('admin/user_model'); $this->load->helper(array('form', 'url')); $this->load->library('form_validation'); $this->form_validation->set_rules('email', 'email', 'required'); $this->form_validation->set_rules('password', 'password', 'required'); if ($this->form_validation->run() == FALSE) { return $this->output->set_content_type('application/json')->set_output(json_encode(array('status' => FALSE))); } // populate user $user = new User_model(); $user->email = $this->input->post('email'); $user->password = $this->input->post('password'); $status = $user->autenticate(); if ($status == TRUE) { redirect(base_url('/dashboard')); } else { $render['error'] = 'User/Login incorrect!'; $this->twig->parse('admin/index.html.twig', $render); } } }
protected function render_body() { if (!empty($_POST)) { $errors = $this->validate_first_name(isset($_POST['first-name']) ? $_POST['first-name'] : ""); $errors .= $this->validate_last_name(isset($_POST['last-name']) ? $_POST['last-name'] : ""); $errors .= $this->validate_username(isset($_POST['username']) ? $_POST['username'] : ""); $errors .= $this->validate_password(isset($_POST['password']) ? $_POST['password'] : ""); $errors .= $this->validate_academic_year(isset($_POST['academic-year']) ? $_POST['academic-year'] : ""); if ($errors) { $this->render_register_form($errors); } else { $user = new User(); $user->set_first_name($_POST['first-name']); $user->set_last_name($_POST['last-name']); $user->set_username($_POST['username']); $user->set_password($_POST['password']); $user->set_academic_year($_POST['academic-year']); $user_model = new User_model(); if ($user_model->store_user($user, false, false, true) == false) { $this->render_register_form('Username already exists.'); } else { $this->redirect_to_main_page(); } } } else { $this->render_register_form(); } }
public function tes() { $this->load->model('user_model'); $r = new User_model(); $user = $r->getData(1, 'id'); var_dump($user->hasPrivilage('edit_user')); }
function reset_password() { $user_model = new User_model(); $user_service = new User_service(); $user_model->set_user_name($this->input->post('txtusername', TRUE)); $user_model->set_password(md5($this->input->post('txtpassword', TRUE))); echo $user_service->update_password($user_model); }
function change_publish_status() { $user_model = new User_model(); $user_service = new User_service(); $user_model->set_id(trim($this->input->post('id', TRUE))); $user_model->set_is_published(trim($this->input->post('value', TRUE))); echo $user_service->publish_status_of_user($user_model); }
public function submit() { $user = new User_model(); if (!$user->loadPropertiesFromPrimaryKey($_SESSION['UserID'])) { redirect('Login/logout'); } if (!$user->isAdmin()) { header("Content-type: text/plain", true, 401); echo "Unauthorized access"; return; } // Check $_FILES['upfile']['error'] value. switch ($_FILES['boss_file']['error']) { case UPLOAD_ERR_OK: break; case UPLOAD_ERR_NO_FILE: header("Content-type: text/plain", true, 400); echo "No file sent"; return; case UPLOAD_ERR_INI_SIZE: case UPLOAD_ERR_FORM_SIZE: header("Content-type: text/plain", true, 400); echo "Exceeded file size limit"; return; default: header("Content-type: text/plain", true, 500); echo "Unknown error occurred"; return; } // You should also check filesize here. if ($_FILES['boss_file']['size'] > self::MAX_FILE_SIZE) { header("Content-type: text/plain", true, 400); echo "Exceeded file size limit"; return; } $file_name = hash("md5", time() . $_FILES['boss_file']['tmp_name']); $file_path = self::UPLOAD_FILE_DIR . "/" . $file_name . ".txt"; if (!move_uploaded_file($_FILES['boss_file']['tmp_name'], $file_path)) { header("Content-type: text/plain", true, 500); echo "Failed to move uploaded file"; return; } include_once 'application/libraries/boss_import/ParserServerTest.php'; $result = ParseFile($file_path); // In future, possibly check to make sure file was successfully deleted here unlink($file_path); if ($result == null) { header("Content-type: text/plain", true, 200); echo "Success"; } else { header("Content-type: text/plain", true, 400); echo $result; } }
protected function render_body() { echo "<h1>Alumni</h1>\n\t\t\t Sort alumni\n\t\t\t <select id='sort-alumni'>\n\t\t\t <option selected disabled>Choose here</option>\n\t\t <option value='last-name-asc'>By last name in ascending order</option>\n\t\t <option value='last-name-desc'>By last name in descending order</option>\n\t\t \t <option value='academic-year-asc'>By academic year in ascending order</option>\n\t\t \t <option value='academic-year-desc'>By academic year in descending order</option>\n\t\t\t </select><br />\n\t\t\t \n\t\t\t <p id='error-message'></p>\n\t\t\t Filter alumni\n\t\t\t <select id='filter-alumni'>\n\t\t\t <option selected disabled>Choose here</option>\n\t\t <option value='year'>By year</option>\n\t\t <option value='first-name'>By first name</option>\n\t\t <option value='last-name'>By last name</option>\n\t\t\t </select>\n\n\t\t\t <div id='filter-alumni-form'>\n\t\t\t <input id='filter-alumni-text' type='text'></input>\n\t\t\t <button id='alumni-filter-button'>Filter</button>\n\t\t\t <button id='alumni-all-button'>Get All</button>\n\t\t\t </div>\n\n\n\t\t\t <table id='alumni-list'>\n\t\t\t <tr>\n\t\t\t \t<th>Name</th>\n\t\t\t \t<th>Academic year</th>\n\t\t\t </tr>"; $user_model = new User_model(); $users = $user_model->get_users(); foreach ($users as $user) { $username = $user->get_username(); echo "<tr>\n\t\t\t\t <td><a href='alumni.php?page=profile&username={$username}'</a>" . $user->get_first_name() . " " . $user->get_last_name() . "</td>\n\t\t\t\t <td>" . $user->get_academic_year() . "</td>\n\t\t\t\t </tr>"; } echo "</table>"; }
public function getDownline($aktif = true) { $where = $aktif ? "AND status = 'aktif'" : ""; $downline_data = $this->db->query("SELECT id_user FROM members WHERE id_referral = '" . $this->dataMember->id_user . "' {$where}")->result(); $downline_obj = array(); foreach ($downline_data as $key => $value) { $user_model = new User_model(); $downline_obj[] = $user_model->getData($value->id_user, 'id'); } return $downline_obj; }
public function guestLogin() { //Create a new user object $user = new User_model(); //Load userdata $user->loadPropertiesFromPrimaryKey('123'); //Setup session $_SESSION['UserID'] = $user->getUserID(); //Redirect to the mainpage controller redirect('Mainpage'); }
public function run($id_user) { $u = new User_model(); $user = $u->getData($id_user, "id"); $this->crawlUp(serialize($user), $user->dataUser->id, 8); if (count($this->bonus_queue) > 0 and $this->cekBelumDiproses($user->dataUser->id)) { return $this->db->insert_batch("bonus_queue", $this->bonus_queue); } else { return false; } }
public function index() { $user = new User_model(); if (!$user->loadPropertiesFromPrimaryKey($_SESSION['UserID'])) { redirect('Login/logout'); } if (!$user->isAdvisor()) { redirect('Login/logout'); } $data = array("user" => $user); $this->load->view('view_advisees', $data); }
function logout() { $user_model = new User_model(); $user_service = new User_service(); $user_model->set_is_online('0'); $user_model->set_id($this->session->userdata('USER_ID')); $user_service->update_user_online_status($user_model); $this->session->set_userdata('USER_ONLINE', 'N'); $this->session->set_userdata('USER_LOGGED_IN', 'FALSE'); $this->session->sess_destroy(); redirect(site_url() . '/login/load_login'); }
/** * Sauvegarde des modifications */ public function save() { // Mise a jour des donnees en base $model = new User_model(); $model->usridusr = $this->input->post('usridusr'); $model->usrlbnom = $this->input->post('nom'); $model->usrlblgn = $this->input->post('login'); $model->usrlbpwd = $this->input->post('password'); $model->update($this->db); $model->setProjects($this->db, explode(",", $this->input->post('selectedProjectIds'))); $this->session->set_flashdata('message', formatInfo('User mis a jour')); redirect('listusers/index'); }
/** * Checks if given user is authenticated (has signed in). * * @param User_model $user * @param int $type * @param boolean $redirect * @return boolean */ public function check_user($user, $type = null, $redirect = true) { $check = !empty($user); if (!$check and $redirect) { redirect('/?from=' . urlencode(current_url())); } if ($check) { if (!is_null($type) and !$user->is($type)) { $check = false; $redirect and redirect('/'); } } return $check; }
public function remove($curriculumID = null) { $user = new User_model(); if (!$user->loadPropertiesFromPrimaryKey($_SESSION['UserID'])) { redirect('Login/logout'); } if (!$user->isStudent()) { redirect('Login/logout'); } $curriculum = new Curriculum_model(); if ($curriculum->loadPropertiesFromPrimaryKey($curriculumID)) { $user->removeCurriculum($curriculum); } redirect('Selectcurriculum/index'); }
/** * Must be called by XHR * Called by User Edition form Validation * * Returns 1 if true, 0 if false * */ function check_email_exists() { $id_user = $this->input->post('id_user'); $email = $this->input->post('email'); $exists = $this->user_model->user_with_same_email_exists($email, $id_user); $this->xhr_output($exists); }
public function admin() { //Load the admin mainpage if user is a admin if (!isset($_SESSION['UserID'])) { redirect('Login/logout'); } $user = new User_model(); if (!$user->loadPropertiesFromPrimaryKey($_SESSION['UserID'])) { redirect('Login/logout'); } if ($user->isAdmin()) { $this->load->view('MainPages/admin_main_page', array('user' => $user)); } else { index(); } }
/** * Test de connexion * @param $db database * @param $usrlblgn login * @param $usrlblgn login */ static function connectUser($db, $usrlblgn, $usrlbpwd) { $row = connectUserRow($db, $usrlblgn, $usrlbpwd); if ($row == null) { return null; } return User_model::User_modelFromRow($row); }
public function register() { $this->load->model("User_model", "user_model"); if (User_model::is_authorize(User_model::$TYPE_ADM) || User_model::is_authorize(User_model::$TYPE_DEV)) { redirect("dashboard"); } else { $data = ['title' => "Register"]; $this->load->view('pages/register', $data); } }
public function index($type = 'driver') { $this->db->where('type', $type); $users = array(); $result = $this->db->get('users')->result(); foreach ($result as $user) { array_push($users, User_model::initialize($user)->asJson()); } $this->output->set_content_type('application/json')->set_status_header(200)->set_output(json_encode(array('users' => $users))); }
public function index() { $users = User_model::all(); foreach ($users as $key => $value) { echo "ID : " . $value->id . "<br>"; echo "First Name : " . $value->first_name . "<br>"; echo "Last Name : " . $value->last_name . "<br>"; echo "Email : " . $value->email . "<br><br>"; } }
public function index() { if (!isset($_SESSION['UserID'])) { redirect('Login/logout'); } //Create new user and load its data $user = new User_model(); if (!$user->loadPropertiesFromPrimaryKey($_SESSION['UserID'])) { redirect('Login/logout'); } //If user did not load, logout the session if (!$user->isStudent()) { redirect('Mainpage'); } //If not a student, redirect to mainpage $advisor = $user->getAdvisor(); $advisorName = $advisor->getName(); $data = array('user' => $user, 'advisor' => $advisor); $this->load->view('advisorInfo', $data); }
public function deleteUser() { $post = $this->input->post('id'); if ($post == $this->session->id) { $error = array('status' => 'error', 'msg' => 'You cannot delete yourself.'); echo json_encode($error); exit; } User_model::deleteUser($post); $msg = array('status' => 'success', 'msg' => 'Successfully delete user id: ' . $post); echo json_encode($msg); }
public function __construct() { parent::__construct(); $this->load->model("Setting_model", "setting_model"); $this->load->model("User_model", "user_model"); if (!User_model::is_authorize(User_model::$TYPE_ADM) && !User_model::is_authorize(User_model::$TYPE_DEV)) { redirect("login"); } if ($this->session->userdata(User_model::$SESSION_LOCK) != null) { redirect("lockscreen"); } }
private function _send($timeoff, $relations = NULL) { $CI =& ci_get_instance(); $staff = NULL; if ($relations && isset($relations['user'])) { $staff = $relations['user']; } else { $timeoff->user->get(); if ($timeoff->user->exists()) { $staff = $timeoff->user; } else { $timeoff->user = new User_model(); if ($timeoff->user_id) { $timeoff->user->get_by_id($timeoff->user_id); } } $staff = $timeoff->user->get_clone(); } $staff_view = $staff->title(); /* compile message */ $text = $timeoff->view_text(); // a hack to overcome the wrong staff problem for new timeoffs $text['user'][1] = $staff_view; $msg = new stdClass(); $msg->subject = lang('timeoff') . ': ' . $timeoff->prop_text('status'); $msg->body = array(); foreach ($text as $ta) { $msg->body[] = $ta[0] . ': ' . $ta[1]; } $msg_id = $CI->hc_notifier->add_message($msg); $group_id = 'save_timeoff'; $CI->hc_notifier->enqueue_message($msg_id, $staff, $group_id); // send to all admins too $um = new User_model(); $um->where_in('level', array(USER_MODEL::LEVEL_MANAGER, USER_MODEL::LEVEL_ADMIN))->where('active', USER_MODEL::STATUS_ACTIVE); $um->get(); foreach ($um as $u) { $CI->hc_notifier->enqueue_message($msg_id, $u, $group_id); } }
public function change() { if (!isset($_SESSION['UserID'])) { redirect('Login/logout'); } //Create new user and load its data $user = new User_model(); if (!$user->loadPropertiesFromPrimaryKey($_SESSION['UserID'])) { redirect('Login/logout'); } //If user did not load, logout the session if ($user->isGuest()) { redirect('Mainpage'); } //If not a student, redirect to mainpage $oldpw = $this->input->post('oldpw'); $newpw = $this->input->post('newpw'); $newpw2 = $this->input->post('newpw2'); if (!$user->authenticate($oldpw)) { $this->load->view('changePassword', array('user' => $user, 'error' => TRUE)); } elseif ($newpw != $newpw2) { $this->load->view('changePassword', array('user' => $user, 'error2' => TRUE)); } elseif (strpbrk($newpw, '!@#$%&*-+=1234567890') === FALSE || strlen($newpw) < 8) { $this->load->view('changePassword', array('user' => $user, 'error3' => TRUE)); } elseif (strpbrk($newpw, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ') === FALSE || strlen($newpw) < 8) { $this->load->view('changePassword', array('user' => $user, 'error3' => TRUE)); } else { $user->setPassword($newpw); $user->update(); $this->load->view('changePassword', array('user' => $user, 'success' => TRUE)); } }