/** * "Start" the application: * Analyze the URL elements and calls the according controller/method or the fallback */ public function __construct() { // create array with URL parts in $url $this->splitUrl(); // check for controller: no controller given ? then load start-page if (!$this->url_controller) { require APP . 'controller/user.php'; $page = new User(); $page->index(); } elseif (file_exists(APP . 'controller/' . $this->url_controller . '.php')) { // here we did check for controller: does such a controller exist ? // if so, then load this file and create this controller // example: if controller would be "car", then this line would translate into: $this->car = new car(); require APP . 'controller/' . $this->url_controller . '.php'; $this->url_controller = new $this->url_controller(); // check for method: does such a method exist in the controller ? if (method_exists($this->url_controller, $this->url_action)) { if (!empty($this->url_params)) { // Call the method and pass arguments to it call_user_func_array(array($this->url_controller, $this->url_action), $this->url_params); } else { // If no parameters are given, just call the method without parameters, like $this->home->method(); $this->url_controller->{$this->url_action}(); } } else { if (strlen($this->url_action) == 0) { // no action defined: call the default index() method of a selected controller $this->url_controller->index(); } else { header('location: ' . URL . 'error'); } } } else { header('location: ' . URL . 'error'); } }
//On regarde si l'user existe en base $user = User::toConnect($identifiant, $motDePasse); //S'il existe on met dans la superglobale SESSION ses informations if ($user) { $_SESSION['id_user'] = $user[0]['id_user']; $_SESSION['identifiant'] = $user[0]['identifiant']; } // Dans tous les cas on redirige sur l'index (pour l'instant) header('Location: ./index.php'); break; case 'toDisconnect': include 'vues/user/v_deconnection.html'; header('Location: ./index.php'); break; case 'index': $listAllUser = User::index(); include 'vues/user/v_index.html'; break; case 'view': $idUser = $_GET['id']; $user = User::view($idUser); include 'vues/user/v_view.html'; break; case 'add': //TODO break; case 'edit': //TODO break; case 'delete': //TODO
$id = $_GET['id']; $result = $this->userrepository->delete($id); if ($result = true) { header("Location: " . BASE_URL . "admin/user/index"); } } } //OBJECT OF alluser $user = new User(); //IF m IS SET, SET IT TO $method, ELSE DEFAULT IT TO index if (isset($_GET['m'])) { $method = $_GET['m']; } else { $method = "index"; } switch ($method) { case "index": $user->index(); break; case "add": $user->add(); break; case "edit": $user->edit(); break; case "delete": $user->delete(); break; default: $user->index(); }
function edit() { if (isset($_POST['save'])) { $id = $this->input->post('id'); $data = array('fullname' => trim($this->input->post('fullname')), 'useremail' => trim($this->input->post('useremail')), 'state' => trim($this->input->post('state')), 'user_type_id' => trim($this->input->post('user_type_id')), 'changed_date' => date('Y-m-d h:m:s')); $dataIn = $this->crud_model->updateData('user', 'id', $id, $data); if ($dataIn) { $this->admintemp->write('message', 'Edited Successfully'); if ($this->input->post('user_type_id') == 3) { redirect('user/golfusers'); } else { redirect('user'); } } else { $this->admintemp->write('message', 'Error occured while editing'); User::index(); } } else { User::_edit(); } }
public function search() { if (!isset($_GET['p'])) { $_GET['p'] = 1; } $obj = new User(); $data = array(); if (!isset($_GET['q'])) { $_GET['q'] = ""; } if (!isset($_GET['p'])) { $_GET['p'] = ""; } if (!isset($_GET['criterio'])) { $_GET['criterio'] = ""; } $data['data'] = $obj->index($_GET['q'], $_GET['p'], $_GET['criterio']); $data['query'] = $_GET['q']; $data['pag'] = $this->Pagination(array('rows' => $data['data']['rowspag'], 'url' => 'index.php?controller=User&action=search', 'query' => $_GET['q'])); $cols = array("DNI", "NOMBRES Y APELLIDOS", "PERFIL", "TELEFONO"); $opt = array("empleado.nombres" => "nombres", "empleado.apellidos" => "apellidos", "perfil.descripcion" => "perfil"); $data['grilla'] = $this->grilla("User", $cols, $data['data']['rows'], $opt, $data['pag'], false, false, true, false); $view = new View(); $view->setData($data); $view->setTemplate('../view/User/_Lista.php'); $view->setLayout('../template/List.php'); $view->render(); }