Ejemplo n.º 1
0
 public function preDispatch(Zend_Controller_Request_Abstract $request)
 {
     $resource = $request->getControllerName();
     $action = $request->getActionName();
     $role = $this->_role;
     //se è un tecnico dello staff recupero le categorie che può modificare
     if ($this->_auth->hasIdentity()) {
         if ($this->_auth->getIdentity()->Ruolo == 'staff') {
             $session = new Zend_Session_Namespace('staff');
             $id = $this->_auth->getIdentity()->idUtenti;
             $adminmodel = new Application_Model_Admin();
             $categorie = $adminmodel->getCatByUser($id);
             $session->categorie = $categorie;
         }
     }
     if (!$this->_acl->isAllowed($role, $resource, $action)) {
         $this->_auth->clearIdentity();
         $this->denyAccess();
     }
     /*
             if (!$this->_acl->isAllowed($this->_role, $request->getControllerName())) {
                 $this->_auth->clearIdentity();
                 $this->denyAccess();
             }*/
 }
Ejemplo n.º 2
0
 public function getMultiCellList($type, $columns, $rows, $merge_column = NULL, $link = null, $link_difference = false, $icon = 0)
 {
     /*------------------------Check param id----------------------------------*/
     /*------------------------End check---------------------------------------*/
     $acl = new Application_Model_DbTable_Dbacl();
     //-------------------------Header----------------------
     $form = '';
     $counter = '<strong>Number of record(s): ' . count($rows) . '</strong>';
     $head = $form . '<table class="collape tablesorter" id="table"  width="100%">';
     $col_str = "";
     if ($type != null) {
         $col_str = '<thead><tr><th class="tdheader">No</th>';
     }
     foreach ($columns as $column) {
         $col_str = $col_str . '<th class="tdheader">' . $column . '</th>';
     }
     $col_str .= '</tr></thead>';
     $head .= $col_str;
     //if row empty
     if ($rows == NULL) {
         return $head . '</table><center style="font-size:12pt;">No record</center></form>';
     }
     //------------------------Body----------------------------
     $body = '';
     $row_str = '<tbody>';
     //add element rows
     $tempvalue = 0;
     $class_item = 'items';
     if ($merge_column == NULL) {
         return $this->getCheckList($type, $columns, $rows);
     } else {
         $class_item = "items-no-inline";
     }
     $rt = 0;
     $r = 0;
     foreach ($rows as $row) {
         if ($r % 2 == 0) {
             $attb = 'normal';
         } else {
             $attb = 'alternate';
         }
         $r++;
         //-------------------check select-----------------
         //-------------------end check select-----------------
         $row_str .= '<tr class="' . $attb . '">';
         $i = 0;
         $b = 0;
         $temp = '';
         $row_temp = $row;
         //set link icon
         if ($icon == 0) {
             $img = '<img src="/css/link.png"/>&nbsp;&nbsp;';
         } else {
             $img = '<img src="/css/add.png" class="add"/>&nbsp;&nbsp;';
         }
         foreach ($row as $key => $read) {
             if ($read == null) {
                 $read = '&nbsp';
             }
             if ($i == 0) {
                 $tempvalue = $read;
                 if ($type == null) {
                     $row_str .= "";
                 } else {
                     $row_str .= '<td class="items-no" align="center">' . $r . '</td>';
                 }
             } else {
                 //link session to id
                 if ($link != null) {
                     if (!$link_difference) {
                         foreach ($link as $column => $url) {
                             if ($key == $column) {
                                 $array = array('tag' => 'a', 'attribute' => array('href' => Application_Form_FrmMessage::redirectorview($url) . '/id/' . $row[$column]));
                                 $read = $this->formSubElement($array, $img . $read);
                             }
                         }
                     } else {
                         foreach ($link as $column => $url) {
                             if ($key == $column) {
                                 $array = array('tag' => 'a', 'attribute' => array('href' => Application_Model_Admin::redirector($url) . '/id/' . $tempvalue));
                                 $read = $this->formSubElement($array, $img . $read);
                             }
                         }
                     }
                 }
                 //$link==null
                 //merge column
                 foreach ($merge_column as $column) {
                     if ($column == $key) {
                         $temp .= $read . '<br/>';
                         $b++;
                     }
                 }
                 //close merge column
                 if ($b == 0) {
                     if ('rate' === $key) {
                         if ($read < 0.7) {
                             $row_str .= '<td class="rate-red">' . $read . '</td>';
                         } elseif ($read >= 0.7 && $read < 0.9) {
                             $row_str .= '<td class="rate-amber" >' . $read . '</td>';
                         } else {
                             $row_str .= '<td class="rate-green">' . $read . '</td>';
                         }
                     } else {
                         $text = $this->textAlign($read);
                         $read = $this->checkValue($read);
                         $row_str .= '<td class="' . $class_item . '" ' . $text . '>' . $read . '</td>';
                     }
                 } else {
                     if ($b == 2) {
                         $row_str .= '<td class="' . $class_item . '">' . $temp . '</td>';
                         $b = 0;
                     }
                 }
                 //close c==0
                 //end color
             }
             //close i==0
             $i++;
         }
         //close for each row
         $row_str .= '</tr>';
     }
     //close for each rows
     $body .= $row_str . '</tbody>';
     //------------------------End Body---------------------------
     //------------------------Footer-----------------------------
     $counter = '<strong style="float:right;padding:5px">Number of record(s): ' . count($rows) . '</strong>';
     $footer = '</table>' . $counter;
     //	----------------------End Footer-------------------------
     return $head . $body . $footer;
 }