Esempio n. 1
0
 public function indexAction()
 {
     $gaIndex = Config::getAppOptions('layout');
     if (!isset($gaIndex['indexController']) || empty($gaIndex['indexController'])) {
         $gaIndex['indexController'] = "Backend\\Controller\\Backend";
     }
     if (!isset($gaIndex['indexAction']) || empty($gaIndex['indexAction'])) {
         $gaIndex['indexAction'] = "index";
     }
     if (!isset($gaIndex['indexParam']) || empty($gaIndex['indexParam'])) {
         $gaIndex['indexParam'] = "";
     }
     $loResource = $this->forward()->dispatch($gaIndex['indexController'], array('action' => $gaIndex['indexAction'], $gaIndex['indexParam']));
     $loView = new ViewModel(array('loController' => $this));
     $loView->addChild($loResource, 'lsApplication');
     return $loView;
 }
Esempio n. 2
0
 /**
  * @param array $paParams
  * @return \Zend\Http\Response
  */
 public function csv(array $paParams = null)
 {
     $laResult = $this->getEntityManager()->getRepository($this->_sEntityExtended)->getList($paParams);
     //Debug::displayd($laResult);
     $lsFileName = $this->_sRoute . date('Y-m-d') . '.csv';
     $lsData = '';
     if (is_array($this->_aGridCols)) {
         $lsComma = '';
         foreach ($this->_aGridCols as $lsCol => $lsTitle) {
             $lsData .= $lsComma . '"' . $lsTitle . '"';
             $lsComma = ',';
         }
         $lsData .= ";\n";
     }
     if (is_array($laResult['resultSet'])) {
         foreach ($laResult['resultSet'] as $lsline => $laValue) {
             if (is_array($laValue)) {
                 $lsComma = '';
                 foreach ($this->_aGridFields as $lsCol => $lsField) {
                     $lsData .= $lsComma . '"' . utf8_decode($this->formatFieldToCSV($lsField, $laValue[$lsField])) . '"';
                     $lsComma = ',';
                 }
                 $lsData .= ";\n";
             }
         }
     }
     header('Content-Description: File Transfer');
     header('Content-Type: text/plan');
     header('Content-Disposition: attachment; filename="' . $lsFileName . '"');
     header('Connection: Keep-Alive');
     header('Expires: 0');
     header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
     header('Pragma: public');
     header('Content-Length: ' . count($lsData));
     echo $lsData;
     $loView = new ViewModel();
     $loView->setTerminal(true);
     $loResponse = $this->getResponse();
     return $loResponse;
 }
Esempio n. 3
0
 public function confirmEmailAction()
 {
     $lsToken = $this->params()->fromRoute('id');
     $loViewModel = new ViewModel(array('token' => $lsToken));
     try {
         $loEntityManager = $this->getServiceLocator()->get('doctrine.entitymanager.orm_default');
         $loUser = $loEntityManager->getRepository('Access\\Entity\\Access')->findOneBy(array('stRegistrationToken' => $lsToken));
         $loUser->set('isActive', 1);
         $loUser->set('enumEmailConfirmed', 1);
         $loUser->set('dtConfirmation', data('Y-m-d H:i:s', time()));
         $loEntityManager->persist($loUser);
         $loUserManager->flush();
     } catch (\Exception $e) {
         $loViewModel->setTemplate('Access/registration/confirm-email-error.phtml');
     }
     return $loViewModel;
 }
Esempio n. 4
0
 /**
  * 
  * @param int $pnStatus
  * @param bool $pbActive
  * @param string $psBack
  * @param string $psFolderTitle
  * @return string|\Onion\View\Model\ViewModel
  */
 public function gridx($pnStatus = 0, $pbActive = 1, $psBack = 'index', $psFolderTitle = null)
 {
     $loGrid = Application::factory('User\\Grid\\UserGrid');
     $lnPage = $this->request('p', 0);
     $lnRows = $this->request('rows', $loGrid->get('numRows'));
     $lsOrder = $this->request('ord', $loGrid->get('order'));
     $lsOrderCol = $this->request('col', $loGrid->get('orderCol'));
     $lsQuery = $this->request('q', '');
     $lsField = $this->request('f', '');
     $lsField = $loGrid->isSearchField($lsField) ? $lsField : $loGrid->get('searchFieldDefault');
     $lsWhere = '';
     if ($loGrid->get('showSearch') && !empty($lsQuery)) {
         $loSearch = new Search();
         $loSearch->set('sSearchFields', $lsField);
         $lsWhere .= $loSearch->createRLikeQuery('"' . $lsQuery . '"', 'r');
     }
     $laParams = array('status' => $pnStatus, 'active' => $pbActive, 'rows' => $lnRows, 'page' => $lnPage, 'col' => $lsOrderCol, 'ord' => $lsOrder, 'q' => $lsQuery, 'where' => $lsWhere);
     if (method_exists($this, 'gridBeforeSelect')) {
         $laParams = $this->gridBeforeSelect($laParams);
     }
     $laResult = $this->getEntityManager()->getRepository($this->_sEntityExtended)->getList($laParams, $lbCache = false);
     if (method_exists($this, 'gridAfterSelect')) {
         $laResult = $this->gridAfterSelect($laResult);
     }
     $laMessages = $this->flashMessenger()->getMessages();
     $loGrid->setData($laResult['resultSet'])->setTotalResults($laResult['totalCount'])->setBackTo($psBack)->setMessages($laMessages)->setNumRows($lnRows)->setSearchFieldDefault($lsField)->setSearchQuery($lsQuery)->setOrder($lsOrder)->setOrderCol($lsOrderCol)->setCurrentPage($lnPage);
     $lsGrid = $loGrid->render($this->_sRoute, $psFolderTitle);
     if (method_exists($this, 'gridAfterRender')) {
         $lsGrid = $this->gridAfterRender($lsGrid);
     }
     $loView = new ViewModel();
     if ($this->isXmlHttpRequest()) {
         $loView->setTerminal(true);
         // desabilita o layout
         $loResponse = $this->getResponse();
         $loResponse->setStatusCode(200);
         $loResponse->setContent($lsGrid);
         return $loResponse;
     } else {
         $loView->setVariables(array('lsGrid' => $lsGrid, 'lsFolder' => '', 'lsTitleP' => ''), true);
     }
     return $loView;
 }
Esempio n. 5
0
 public function authAction()
 {
     $lsToken = $this->request('tk', null);
     if ($lsToken !== null) {
         $loEntity = $this->getEntityManager()->getRepository($this->_sEntity)->findOneBy(array('stToken' => $lsToken, 'isActive' => 1));
         if (is_object($loEntity)) {
             $lsResouceController = $loEntity->get('stResource');
             $lsAction = $loEntity->get('stAction');
             $lnResourceId = $loEntity->get('Resource_id');
             $loEntity->set('dtLastAccess', Date('Y-m-d H:i:s'));
             $this->getEntityManager()->persist($loEntity);
             $this->entityFlush();
             $loResource = $this->forward()->dispatch($lsResouceController, array('action' => $lsAction, 'id' => $lnResourceId, 'allow' => true));
             $loView = new ViewModel();
             $loView->addChild($loResource, 'actionAccess');
             return $loView;
         }
     }
     return $this->redirect()->toRoute('access', array('controller' => 'access', 'action' => 'login'));
 }