$user = new UserController(); $user->logout(); break; case "register": include_once "controllers/UserController.php"; $user = new UserController(); $user->register(); break; case "user": include_once "controllers/UserController.php"; $user = new UserController(); if ($_GET["action"] == "update") { $user->update(); } if ($_GET["action"] == "delete") { $user->delete(); } break; case "profile": include_once "controllers/UserController.php"; $user = new UserController(); $user->profile(); break; case "dashboard": include_once "controllers/DashboardController.php"; $dashboard = new dashboardController(); $dashboard->render(); break; case "app": include_once "controllers/AppController.php"; $app = new appController();
/** * Tests the update function in the UserController * @param void * @return void */ public function testDelete() { Input::replace($this->userData); $user = new UserController(); $user->store(); $user->delete(1); $usersSaved = User::withTrashed()->find(1); $this->assertNotNull($usersSaved->deleted_at); }
break; case "save": $vars['edittype'] = $_POST['edittype']; $vars['password'] = $_POST['password']; $vars['password2'] = $_POST['password2']; $vars['id'] = $_POST['id']; $vars['user_id'] = $_POST['user_id']; $vars['user_name'] = $_POST['user_name']; $vars['title'] = $_POST['title']; $vars['level'] = $_POST['level']; $vars['email'] = $_POST['email']; $vars['active'] = $_POST['active']; $user->save($p, $vars); break; case "delete": $user->delete($id); break; case "batchDelete": $ids = $_POST['del']; $user->batchDelete($p, $ids); break; case "chgpasswd": $user->chgpasswd($id); break; case "chgpasswdsave": $vars = $_POST; $user->chgpasswdsave($vars); break; default: $user->browse(); break;
include_once '../models/UserModel.php'; class UserController extends ParentController { public function __construct() { $this->model = new UserModel(); } } $controller = new UserController(); if (isset($_GET["get"]) && isset($HTTP_RAW_POST_DATA)) { $json = json_decode($controller->getWhere(null, json_decode($HTTP_RAW_POST_DATA)->data)); if ($json->affected_rows === 1) { session_start(); $_SESSION["id_usuario"] = $json->objects[0]->id_usuario; $_SESSION["rol"] = $json->objects[0]->usu_rol; $_SESSION["nombres"] = $json->objects[0]->usu_nombres; $_SESSION['apellidos'] = $json->objects[0]->usu_apellidos; $_SESSION['usuario'] = $json->objects[0]->usu_usuario; } print json_encode(array("success" => $json->affected_rows === 1, "user" => $json->objects[0])); if (isset($_GET["login"])) { } } else { if (isset($_GET["save"]) && isset($HTTP_RAW_POST_DATA)) { print $controller->save($_GET["save"], json_decode($HTTP_RAW_POST_DATA)->data); } else { if (isset($_GET["delete"])) { print $controller->delete($_GET["delete"]); } } }
UserController::process_login(); }); $routes->post('/user/save', function () { UserController::save(); }); $routes->post('/user/update', function () { UserController::update(); }); $routes->get('/user/:id', function ($id) { UserController::show($id); }); $routes->get('/user/:id/edit', function ($id) { UserController::edit($id); }); $routes->get('/user/:id/delete', function ($id) { UserController::delete($id); }); $routes->get('/poll', function () { PollController::index(); }); $routes->get('/poll/new', function () { PollController::create(); }); $routes->post('/poll/save', function () { PollController::save(); }); $routes->post('/poll/update', function () { PollController::update(); }); $routes->get('/poll/:id', function ($id) { PollController::show($id);