Exemple #1
0
 /**
  * @internal param \Slim\Slim $app
  * @return \Slim\Slim
  */
 public static function init()
 {
     static::defineVariables();
     App::$inst = static::initSlim();
     static::defineProtocol();
     static::initConfig();
     static::initHttpAuth();
     static::initLogger();
     static::initCache();
     static::initDoctrine();
     static::initAppVars();
     static::initRouting();
     //FIXME: uncomnt this line and fix in doctrine-cli
     if (!defined('SERVER_SCRIPT')) {
         SFacebook::init();
     }
     return App::$inst;
 }
 public function callme(Request $request, $response, $next)
 {
     $app = App::getInstance();
     if (false !== $this->rememberme($request) && false !== SecurityController::AppAuthorization()) {
         die;
         return $response->withRedirect($app->path('homepage'));
     }
     if ($request->getUri()->getPath() === $app->path('login')) {
         if (SecurityController::AppAuthorization() === true) {
             return $response->withRedirect($app->path('homepage'));
         }
     }
     if ($request->getUri()->getPath() !== $app->path('login')) {
         if (SecurityController::AppAuthorization() === false) {
             return $response->withRedirect($app->path('login'));
         }
     }
     $response = $next($request, $response);
     return $response;
 }
 public function history()
 {
     $app = App::getInstance();
     $usuario = new usuario();
     $response = $usuario->history($app->user->id())->get();
     return $this->render('usuarios/history.html.twig', ['history' => $response]);
 }
/*
    $app::Router()->get($app->path('profile'), function(Request $request, Response $response, $args){
        $parse = new RequestParse($request, $args);
        $security = new SecurityController();
        echo $security->profile($parse->get('id'));
    });
*/
$app::Router()->get($app->path('profile'), function (Request $request, Response $response, $args) {
    $parse = new RequestParse($request, $args);
    $security = new SecurityController();
    echo $security->profile($parse->get('id'));
});
$app::Router()->get($app->path('login'), function () {
    $security = new SecurityController();
    echo $security->index();
});
$app::Router()->get($app->path('logout'), function (Request $request, Response $response) {
    SecurityController::logout();
    $response = Cookie::deleteCookie($response, 'Rememberme');
    App::Router()->respond($response);
    return $response->withRedirect('/');
});
$app::Router()->post($app->path('auth'), function (Request $request, Response $response, $args) {
    $parse = new RequestParse($request, $args);
    $email = $parse->get('email');
    $password = $parse->get('password');
    $rememberme = $parse->get('rememberme');
    $security = new SecurityController();
    $responseData = $security->authenticate($email, $password, $rememberme);
    return $response->withJson($responseData);
});
use Application\Controller\RequestParse;
use Illuminate\Database\Eloquent;
/**
 * Application Routes
 **/
$app::Router()->get('/', function () {
    $home = new HomeController();
    echo $home->index();
});
$app::Router()->get($app->path('homepage'), function () {
    $home = new HomeController();
    echo $home->index();
});
$app::Router()->get($app->path('my_projects'), function () {
    $myproject = new MyProjectController();
    echo $myproject->proyects();
});
$app::Router()->get($app->path('my_tickets'), function () {
    $myticket = new MyTicketController();
    echo $myticket->tickets();
});
$app::Router()->get($app->path('message_confirm'), function (Request $request, Response $response, $args) {
    $dataResponse = [];
    $parse = new RequestParse($request, $args);
    $options = [];
    $options['title'] = $parse->get('title');
    $options['message'] = $parse->get('message');
    $dataResponse['html'] = App::getInstance()->Message()->confirm($options);
    $dataResponse['status'] = true;
    return $response->withJson($dataResponse);
});
$app::Router()->get($app->path('item_detail'), function (Request $request, Response $response, $args) {
    $parse = new RequestParse($request, $args);
    $ticketController = new TicketController();
    $response = $ticketController->detalle($parse->get('id'));
    if (true === $response instanceof \Slim\Http\Response) {
        return $response;
    }
    echo $response;
});
$app::Router()->post($app->path('save_ticket'), function (Request $request, Response $response, $args) {
    $parse = new RequestParse($request, $args);
    $params = ['proyecto' => $parse->get('proyecto'), 'titulo' => $parse->get('tituloItem'), 'asignado' => $parse->get('asignado'), 'descripcion' => $parse->get('descripcion'), 'id' => $parse->get('id'), 'tipoitem' => $parse->get('tipoitem'), 'estado' => $parse->get('estado'), 'prioridad' => $parse->get('prioridad'), 'comentario' => $parse->get('comentario')];
    $ticket = TicketController::Save($params);
    $path = App::getInstance()->path('my_tickets');
    if ($ticket->idItem) {
        $path = App::getInstance()->path('item_detail', ['id' => $ticket->idItem]);
    }
    return $response->withRedirect($path, 301);
});
$app::Router()->get($app->path('new_ticket'), function (Request $request, Response $response, $args) {
    $parse = new RequestParse($request, $args);
    $ticketController = new TicketController();
    $response = $ticketController->createForm($parse->get('id'));
    if (true === $response instanceof \Slim\Http\Response) {
        return $response;
    }
    echo $response;
});
$app::Router()->get($app->path('edit_ticket'), function (Request $request, Response $response, $args) {
    $parse = new RequestParse($request, $args);
    $ticketController = new TicketController();
<?php

define('BASE', realpath('./') . '/');
define('ENVIRONMENT', 'develop');
$url = $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
require BASE . 'vendor/autoload.php';
require BASE . 'app/src/AppClass.php';
require BASE . 'app/src/config.php';
require BASE . 'app/src/capsule.php';
use Application\App;
use Application\Controller\SecurityMiddleware;
use Application\Controller\SecurityController;
use Illuminate\Database\Eloquent;
SecurityController::securityStart();
$app = App::getInstance();
$app::Router()->add(new SecurityMiddleware($app));
require BASE . 'app/routes/security.php';
require BASE . 'app/routes/application.php';
require BASE . 'app/routes/proyectos.php';
require BASE . 'app/routes/equipos.php';
require BASE . 'app/routes/roles.php';
require BASE . 'app/routes/tipoitems.php';
require BASE . 'app/routes/usuarios.php';
require BASE . 'app/routes/items.routes.php';
$app::Router()->run();
Exemple #8
0
/**
 * Roles Routes
 **/
$app::Router()->get($app->path('roles'), function () {
    $rol = new RolController();
    echo $rol->index();
});
$app::Router()->get($app->path('new_rol'), function () {
    $rol = new RolController();
    echo $rol->addForm();
});
$app::Router()->post($app->path('save_rol'), function (Request $request, Response $response, $args) {
    $parse = new RequestParse($request, $args);
    $params = ['id' => $parse->get('id'), 'nombre' => $parse->get('nombre'), 'descripcion' => $parse->get('descripcion')];
    RolController::Save($params);
    return $response->withRedirect(App::getInstance()->path('roles'), 301);
});
$app::Router()->get($app->path('edit_rol'), function (Request $request, Response $response, $args) {
    $parse = new RequestParse($request, $args);
    $rol = new RolController();
    echo $rol->editForm($parse->get('id'));
});
$app::Router()->post($app->path('delete_rol'), function (Request $request, Response $response, $args) {
    $parse = new RequestParse($request, $args);
    $dataResponse = [];
    if ($id = $parse->get('id')) {
        $rol = new RolController();
        $dataResponse['status'] = (bool) $rol->delete($id);
    }
    return $response->withJson($dataResponse);
});
 public function usersByState($idEstado)
 {
     $equipoAtencion = new EquipoAtencion();
     /** @var \Illuminate\Database\Eloquent\Collection $usuarios */
     $usuarios = $equipoAtencion->usersByState($idEstado)->get();
     if (true === $usuarios->isEmpty()) {
         $usuarios[] = Usuario::with([])->Join('UsuarioRolEquipo', 'UsuarioRolEquipo.idUsuario', '=', 'Usuario.idUsuario')->join('Equipo', 'Equipo.idEquipo', '=', 'UsuarioRolEquipo.idEquipo')->selectRaw("Usuario.idUsuario, Usuario.nombreCompleto,\n                                concat(Usuario.nombreCompleto, ' (', Equipo.nombreEquipo,\n                                        CASE WHEN UsuarioRolEquipo.esLider= 1 THEN ' - Lider' ELSE '' END , ')'\n                                ) as descripcion")->find(App::getInstance()->user->id());
     }
     return $usuarios;
 }
    echo $usuariosController->editForm($parse->get('id'));
});
$app::Router()->post($app->path('selfie_edit'), function (Request $request, Response $response, $args) {
    $parameters = json_decode(file_get_contents('php://input'));
    $usuariosController = new UserController();
    $responsedata = $usuariosController->selfie($parameters->id, $parameters->path);
    return $response->withJson($responsedata);
});
$app::Router()->post($app->path('save_user'), function (Request $request, Response $response, $args) {
    $parse = new RequestParse($request, $args);
    $params = ['id' => $parse->get('id'), 'numDocumento' => $parse->get('numDocumento'), 'nombreCompleto' => $parse->get('nombreCompleto'), 'email' => $parse->get('email'), 'nombreUsuario' => $parse->get('usuario'), 'password' => $parse->get('password'), 'tipoDocumento' => $parse->get('tipoDocumento'), 'rolPrincipal' => $parse->get('rolPrincipal'), 'profile' => $parse->get('profile'), 'estado' => $parse->get('estado')];
    $user = UserController::Save($params);
    if ('user' === $parse->get('from')) {
        return $response->withRedirect(App::getInstance()->path('edit_user', ["id" => $user->idUsuario], true), 301);
    } else {
        return $response->withRedirect(App::getInstance()->path('profile', ["id" => $user->idUsuario], true), 301);
    }
});
$app::Router()->post($app->path('delete_user'), function (Request $request, Response $response, $args) {
    $parse = new RequestParse($request, $args);
    $dataResponse = [];
    if ($id = $parse->get('id')) {
        $usuario = new UserController();
        $dataResponse['status'] = (bool) $usuario->delete($id);
    }
    return $response->withJson($dataResponse);
});
$app::Router()->get($app->path('get_user'), function (Request $request, Response $response, $args) {
    $parse = new RequestParse($request, $args);
    $dataResponse = [];
    if ($id = $parse->get('id')) {
Exemple #11
0
 /**
  * Test getting the root dir.
  *
  * @covers ::getRootDir
  */
 public function testGetRootDir()
 {
     $app = new App();
     $rootDir = realpath(__DIR__ . '/../../');
     $this->assertEquals($rootDir, $app->getRootDir());
 }