Example #1
0
 protected function remove()
 {
     if (!$this->id) {
         $error = new Error(__METHOD__, Text::read('message.ID.error'));
         die($error->getView());
     }
     // Ajax Callback
     $this->ajaxCallback();
 }
Example #2
0
 protected function detail()
 {
     if (!$this->id) {
         $error = new Error(__METHOD__, Text::read('message.ID.error'));
         die($error->getView());
     }
     $this->myView = new AccountDetailView();
     $this->myModel = new AccountModel();
     $this->__detail();
 }
Example #3
0
 protected function detail()
 {
     if (!$this->id) {
         $error = new Error(__METHOD__, Text::read('message.ID.error'));
         die($error->getView());
     }
     $this->myView = new OrderDetailView();
     $this->myModel = new OrderModel();
     // Cria ligação com modelo de fotos
     $this->myModel->bindPhotoModel();
     $this->__detail();
     // Cria ligação com a visão de fotos
     $this->myView->bindPhotoReadOnlyView();
 }
Example #4
0
 protected function photolist()
 {
     if (!$this->id) {
         $error = new Error(__METHOD__, Text::read('message.ID.error'));
         die($error->getView());
     }
     if ($_POST['multiple']) {
         $this->myView = new PhotoMultipleUploadView();
     } else {
         $this->myView = new PhotoSingleUploadView();
     }
     $this->myModel = new PhotoModel();
     // Ajax Callback
     $this->ajaxCallback();
 }
Example #5
0
 protected function typelist()
 {
     if (!$this->id) {
         $error = new Error(__METHOD__, Text::read('message.ID.error'));
         die($error->getView());
     }
     $this->myModel = new ProductTypeModel();
     // Ajax Callback
     $this->ajaxCallback();
 }
Example #6
0
 protected function modelException($message, $exception)
 {
     // Verifica qual foi a exceção para retornar mensagem ao usuário
     switch ($exception->getCode()) {
         case '23000':
             // Violação de regra
             $this->message['type'] = "error";
             $this->message['text'] = Text::read('message.model.error.constraint');
             break;
         case '42S22':
             // Coluna não encontrada
             $this->message['type'] = "error";
             $this->message['text'] = Text::read('message.model.error.unknownColumn');
             break;
         default:
             $this->message['type'] = "error";
             $this->message['text'] = Text::read('message.model.error.exception');
             break;
     }
     foreach ($exception->getTrace() as $key => $trace) {
         $stackTrace .= $key . ": " . $trace['class'] . "->" . $trace['function'] . "( )<br />";
     }
     $technical = $exception->getMessage();
     $error = new Error($stackTrace, $message, $technical);
     $this->technicalMessage = $error->getView();
 }
Example #7
0
 private function checkAdminLogin()
 {
     if ($this->controller != 'login') {
         // 1. Verifica se o usuário está logado no sistema
         if (!$_SESSION['admLogin']) {
             header("location:" . Config::read('page.url.login'));
         }
         // 2. Verifica se a sessão não expirou por inatividade
         if ($_SESSION['admLogin']->checkInactiveSession()) {
             header("location:" . Config::read('page.url.login.inactive'));
         }
         // 3. Verifica se o usuário possui acesso a página solicitada
         foreach ($_SESSION['admLogin']->getRoles() as $parent) {
             if ($parent->rolePageID == $this->controller) {
                 $accessGranted = true;
                 break;
             }
         }
         // 3.1. Exceção: Página de atualização dos dados do próprio usuário
         if ($this->controller == 'user' && $this->action == 'detail' && $this->id == $_SESSION['admLogin']->getUserID()) {
             $accessGranted = true;
         }
         // 3.2. Exceção: Upload de fotos
         if ($this->controller == 'photo') {
             $accessGranted = true;
         }
         if (!$accessGranted) {
             $error = new Error(__METHOD__, Text::read('message.Loader.error'));
             die($error->getView());
         }
     }
 }