Exemplo n.º 1
0
 /**
  * This action is executed before execute any action in the application
  *
  * @param Event $event
  * @param Dispatcher $dispatcher
  */
 public function beforeDispatch(Event $event, Dispatcher $dispatcher)
 {
     $userGroup = 'guest';
     $isLoggedIn = $this->isLoggedIn($this->session);
     if ($isLoggedIn) {
         $uid = $this->session->get('uid');
         $userService = ServiceFactory::getService('UserService');
         $user = $userService->getUserUsingUid($uid);
         $userGroup = $user['userGroup']['userGroupSlug'];
     }
     $controller = $dispatcher->getControllerName();
     $action = $dispatcher->getActionName();
     $acl = $this->getAcl();
     $isAllowed = $acl->isAllowed($userGroup, $controller, $action);
     if ($isAllowed != Acl::ALLOW) {
         $dispatcher->forward(array('controller' => 'errors', 'action' => 'resourceNotFound'));
         return false;
     }
 }
Exemplo n.º 2
0
 /**
  * Get the conditions of query statement.
  * @param  String $hunterUsername  - the username who founded the issue
  * @param  long   $productId       - the unique ID of the product
  * @param  int    $issueCategoryId - the unique ID of a category of issue
  * @param  int    $issueStatusId   - the unique ID of a status of issue
  * @return the conditions of query statement
  */
 private function getQueryOfIssuesUsingHunterUsernameAndProductAndCategoryAndStatus($hunterUsername, $productId, $issueCategoryId, $issueStatusId)
 {
     $hunterUid = 0;
     if (!empty($hunterUsername)) {
         $userService = ServiceFactory::getService('UserService');
         $hunter = $userService->getUserUsingUsername($hunterUsername);
         $hunterUid = $hunter == NULL ? -1 : $hunter->getUid();
     }
     return $this->getQueryOfIssuesUsingHunterUidAndProductAndCategoryAndStatus($hunterUid, $productId, $issueCategoryId, $issueStatusId);
 }
Exemplo n.º 3
0
<?php

require_once '../header.inc.php';
$svcAlta = ServiceFactory::getService('nuevo');
if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == 'POST') {
    $request = new NuevoClienteRequest();
    $request->razon_social = $_POST['razon_social'];
    $request->numero_cliente = $_POST['numero_cliente'];
    $request->telefono = $_POST['telefono'];
    $request->contacto = $_POST['contacto'];
    $request->calle = $_POST['calle'];
    $request->puerta = $_POST['puerta'];
    $request->piso = $_POST['piso'];
    $request->localidad = $_POST['localidad'];
    $request->provincia = $_POST['provincia'];
    $request->dia_entrega = $_POST['dia_entrega'];
    $request->dia_venta = $_POST['dia_venta'];
    $request->dia_cobranza = $_POST['dia_cobranza'];
    $nuevo = $svcAlta->guardarCliente($request);
    if ($nuevo) {
        header('location: listado.php');
    }
}
include ROOT_PATH . '/views/main.php';
Exemplo n.º 4
0
<?php

require_once '../../header.inc.php';
$svcListado = ServiceFactory::getService('listado');
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    $pagina = $_POST['pagina'];
    $listado = $svcListado->getListado($pagina);
    echo json_encode($listado);
    exit;
}
Exemplo n.º 5
0
 /**
  * Get current User object from session.
  * @param  Session $session - the HTTP Session
  * @return the current User object or NULL
  */
 protected function getCurrentUserObject($session)
 {
     $userService = ServiceFactory::getService('UserService');
     $uid = $session->get('uid');
     return $userService->getUserObjectUsingUid($uid);
 }
Exemplo n.º 6
0
 public function displayAction()
 {
     $userId = isset($_GET['userId']) ? $_GET['userId'] : "1";
     $userDetail = ServiceFactory::getService("User")->getDetail($userId);
     echo ServiceFactory::getService("Tpl")->render("index", array("username" => $userDetail['username'], "password" => $userDetail['password'], "age" => $userDetail['age'], "createTime" => $userDetail['createTime']));
 }
Exemplo n.º 7
0
 /**
  * Create an issue of a product.
  * @param  long $productId - the unique ID of the product
  * @return an HttpResponse contains data validation result
  */
 public function createIssueAction($productId)
 {
     $issueTitle = $this->getFilteredContent(strip_tags($this->request->getPost('issueTitle')));
     $issueCategorySlug = $this->getFilteredContent(strip_tags($this->request->getPost('issueCategory')));
     $productVersion = $this->getFilteredContent(strip_tags($this->request->getPost('productVersion')));
     $issueDescription = $this->getFilteredContent(strip_tags($this->request->getPost('issueDescription')));
     $isTokenValid = $this->security->checkToken();
     $productService = ServiceFactory::getService('ProductService');
     $issueService = ServiceFactory::getService('IssueService');
     $product = $productService->getProductObjectUsingId($productId);
     $hunter = $this->getCurrentUserObject($this->session);
     if ($product == NULL) {
         $this->forward('errors/resourceNotFound');
         return;
     }
     $result = $issueService->createIssue($product, $productVersion, $issueCategorySlug, $hunter, $issueTitle, $issueDescription, $isTokenValid);
     if ($isTokenValid) {
         $result['csrfTokenKey'] = $this->security->getTokenKey();
         $result['csrfToken'] = $this->security->getToken();
     }
     if ($isSuccessful) {
         $issueId = $result['issueId'];
         $ipAddress = $this->request->getClientAddress();
         $this->logger->log(sprintf('Issue #%d created by User[%s] at %s.', $issueId, $hunter, $ipAddress), Logger::INFO);
     }
     $response = new Response();
     $response->setHeader('Content-Type', 'application/json');
     $response->setContent(json_encode($result));
     return $response;
 }
Exemplo n.º 8
0
 /**
  * Get issues list submitted by the user logged in.
  * @return a HttpResponse contains JSON data contains information of issues submitted by the user
  */
 public function getSubmittedIssuesAction()
 {
     $hunterUid = $this->session->get('uid');
     $productId = $this->request->get('product');
     $issueCategorySlug = $this->request->get('issueCategory');
     $issueStatusSlug = $this->request->get('issueStatus');
     $pageNumber = $this->request->get('page');
     $limit = self::NUMBER_OF_ISSUES_PER_REQUEST;
     $offset = $pageNumber <= 1 ? 0 : ($pageNumber - 1) * $limit;
     $issueService = ServiceFactory::getService('IssueService');
     $issueCategoryId = $issueService->getIssueCategoryId($issueCategorySlug);
     $issueStatusId = $issueService->getIssueStatusId($issueStatusSlug);
     $issues = $this->getIssuesInBestLanguage($issueService->getIssuesUsingHunterUidAndProductAndCategoryAndStatus($hunterUid, $productId, $issueCategoryId, $issueStatusId, $offset, $limit));
     $numberOfIssues = $issueService->getIssuesCountUsingHunterUidAndProductAndCategoryAndStatus($hunterUid, $productId, $issueCategoryId, $issueStatusId);
     $result = array('isSuccessful' => !empty($issues), 'issues' => $issues, 'totalPages' => ceil($numberOfIssues / $limit));
     $response = new Response();
     $response->setHeader('Content-Type', 'application/json');
     $response->setContent(json_encode($result));
     return $response;
 }
Exemplo n.º 9
0
 /**
  * Reset the password if the email and token is correct.
  * @return an HttpResponse which contains JSON data infers whether the password is reset
  */
 public function doResetPasswordAction()
 {
     $email = $this->request->get('email');
     $token = $this->request->get('token');
     $newPassword = $this->request->get('newPassword');
     $confirmPassword = $this->request->get('confirmPassword');
     $isTokenValid = $this->security->checkToken();
     $userService = ServiceFactory::getService('UserService');
     $result = $userService->resetPassword($email, $token, $newPassword, $confirmPassword, $isTokenValid);
     if ($isTokenValid) {
         $result['csrfTokenKey'] = $this->security->getTokenKey();
         $result['csrfToken'] = $this->security->getToken();
     }
     if ($result['isSuccessful']) {
         $user = $userService->getUserUsingUsernameOrEmail($email);
         $ipAddress = $this->request->getClientAddress();
         $this->logger->log(sprintf('User: [%s] reset password at %s.', $user, $ipAddress), Logger::INFO);
     }
     $response = new Response();
     $response->setHeader('Content-Type', 'application/json');
     $response->setContent(json_encode($result));
     return $response;
 }