Esempio n. 1
0
 /**
  *
  * @param type $viewName 
  * @return array
  */
 public function getProfile($viewName)
 {
     $config = array();
     $row = false;
     $_profile = new Profile_DataView_User_MapperView();
     $session = Zend_Auth::getInstance()->getStorage()->read();
     $login = '';
     if ($session !== null) {
         $login = $session->getLogin();
     }
     $idProfile = Zend_Controller_Front::getInstance()->getParam('id_profile');
     if ($idProfile) {
         $_where = new ZendT_Db_Where();
         $_where->addFilter('id', $idProfile);
         $row = $_profile->retriveRow($_where);
     }
     if ($login && !$row) {
         $_where = new ZendT_Db_Where();
         $_where->addFilter('login', $login);
         $_where->addFilter('objeto', $viewName);
         $_where->addFilter('tipo', 'Grid');
         $_where->addFilter('padrao', 'S');
         $row = $_profile->retriveRow($_where);
     }
     if (!$row) {
         $login = '******';
         $_where = new ZendT_Db_Where();
         $_where->addFilter('login', $login);
         $_where->addFilter('objeto', $viewName);
         $_where->addFilter('tipo', 'Grid');
         $_where->addFilter('padrao', 'S');
         $row = $_profile->retriveRow($_where);
     }
     if (!$row) {
         $login = '******';
         $_where = new ZendT_Db_Where();
         $_where->addFilter('login', $login);
         $_where->addFilter('objeto', $viewName);
         $_where->addFilter('tipo', 'Grid');
         $_where->addFilter('padrao', 'S');
         $row = $_profile->retriveRow($_where);
     }
     if ($row) {
         $config = unserialize($row['config']->get());
         $config['grouds'] = ZendT_Sort::sortArray($config['grouds'], 'order');
     }
     return $config;
 }
Esempio n. 2
0
 /**
  *
  * @param type $viewName 
  * @return array
  */
 public static function getProfile($formName)
 {
     $config = array();
     $row = false;
     $_profile = new Profile_DataView_ObjectView_MapperView();
     $session = Zend_Auth::getInstance()->getStorage()->read();
     $login = '';
     if ($session !== null) {
         $login = $session->getLogin();
     }
     $idProfile = '';
     if (isset($_COOKIE['profile-' . $formName])) {
         $idProfile = $_COOKIE['profile-' . $formName];
     }
     if ($idProfile) {
         $_where = new ZendT_Db_Where();
         $_where->addFilter('id', $idProfile);
         $row = $_profile->retriveRow($_where);
     }
     if ($login && !$row) {
         $_where = new ZendT_Db_Where();
         $_where->addFilter('login', $login);
         $_where->addFilter('objeto', $formName);
         $_where->addFilter('tipo', 'F');
         $_where->addFilter('padrao', 'S');
         $_where->addFilter('publico', 'N');
         $row = $_profile->retriveRow($_where);
     }
     if (!$row) {
         $_where = new ZendT_Db_Where();
         $_where->addFilter('publico', 'S');
         $_where->addFilter('objeto', $formName);
         $_where->addFilter('tipo', 'F');
         $_where->addFilter('padrao', 'S');
         $row = $_profile->retriveRow($_where);
     }
     if ($row) {
         $config = unserialize($row['config']->get());
         $config['grouds'] = ZendT_Sort::sortArray($config['grouds'], 'order');
         $config['id'] = $row['id']->get();
     }
     return $config;
 }
Esempio n. 3
0
 public function configAction()
 {
     $this->_helper->layout->disableLayout();
     $this->_helper->viewRenderer->setNoRender(true);
     $json = new ZendT_Json_Result();
     try {
         $id = $this->getRequest()->getParam('id');
         $row = $this->getMapper()->setId($id)->retriveRow();
         if ($row['tipo']->toPhp() == 'F') {
             $config = $this->_getConfigForm($row);
         } else {
             if ($row['tipo']->toPhp() == 'G') {
                 $config = $this->_getConfigGrid($row);
             } else {
                 if ($row['tipo']->toPhp() == 'P' || $row['tipo']->toPhp() == 'X') {
                     $config = $this->_getConfigReport($row);
                 } else {
                     if ($row['tipo']->toPhp() == 'C') {
                         $config = $this->_getConfigChart($row);
                     } else {
                         if ($row['tipo']->toPhp() == 'D' || $row['tipo']->toPhp() == 'I') {
                             $config = $this->_getConfigDynamic($row);
                         } else {
                             if ($row['tipo']->toPhp() == 'B') {
                                 $config = $this->_getConfigDashboard($row);
                             }
                         }
                     }
                 }
             }
         }
         $_prev = new Profile_DataView_ObjectViewPriv_MapperView();
         $_where = new ZendT_Db_Where();
         $_where->addFilter('profile_object_view_priv.id_profile_object_view', $id);
         $rows = $_prev->recordset($_where);
         $config['row'] = $row;
         $config['row']['padrao'] = $config['row']['padrao']->toPhp();
         $config['advanced']['owner'] = '';
         $config['advanced']['share'] = '';
         unset($config['advanced']['owner-multiple']);
         unset($config['advanced']['share-multiple']);
         while ($row = $rows->getRow()) {
             if ($row['tipo']->toPhp() == 'O') {
                 $config['advanced']['owner'] .= ';' . $row['nome_papel']->get();
             } else {
                 $config['advanced']['share'] .= ';' . $row['nome_papel']->get();
             }
         }
         $config['advanced']['owner'] = substr($config['advanced']['owner'], 1);
         $config['advanced']['share'] = substr($config['advanced']['share'], 1);
         if ($config['ini']['fields']) {
             $config['ini']['fields'] = ZendT_Sort::sortArray($config['ini']['fields'], 'label');
         }
         $json->setResult($config);
         /* Verifica se o campo que foi passado como filtro existe */
         $field = $this->getRequest()->getParam('field');
         if ($field) {
             if (isset($config['ini']['fields'][$field])) {
                 $json->setResult(array("exists" => true));
             } else {
                 $json->setResult(array("exists" => false));
             }
         }
     } catch (Exception $ex) {
         $json->setException($ex);
     }
     echo $json->render();
 }