Exemplo n.º 1
0
 /**
  * Query a dependent table to retrieve rows matching the current row.
  *
  * @param string|Zend_Db_Table_Abstract  $dependentTable
  * @param string                         OPTIONAL $ruleKey
  * @param Zend_Db_Table_Select           OPTIONAL $select
  * @return Zend_Db_Table_Rowset_Abstract Query result from $dependentTable
  * @throws Zend_Db_Table_Row_Exception If $dependentTable is not a table or is not loadable.
  */
 public function findDependentRowset($dependentTable, $ruleKey = null, Zend_Db_Table_Select $select = null)
 {
     if (is_string($dependentTable)) {
         $dependentTable = System_Locator_TableLocator::getInstance()->get($dependentTable);
     }
     return parent::findDependentRowset($dependentTable, $ruleKey, $select);
 }
Exemplo n.º 2
0
 public function findDependentRowset($dependentTable, $ruleKey = null, Zend_Db_Table_Select $select = null)
 {
     // Possível Informação de Chave
     if (is_string($dependentTable)) {
         $needle = $dependentTable;
         $mapper = $this->getTable()->info(Zend_Db_Table::DEPENDENT_TABLES);
         // Busca por Chave como Referência
         if (array_key_exists($needle, $mapper)) {
             // Chave Encontrada
             // Transformando a Pesquisa
             $dependentTable = $mapper[$needle];
             // Tabela Informada = Tabela Dependente
         }
     }
     return parent::findDependentRowset($dependentTable, $ruleKey, $select);
 }
Exemplo n.º 3
0
 /**
  * Returns permissions assigned to a specific role
  * @param Zend_Db_Table_Row_Abstract $resource
  * @param Zend_Db_Table_Row_Abstract $role
  * @return Ambigous <Zend_Db_Table_Row_Abstract, NULL, unknown>
  */
 function getByResource(Zend_Db_Table_Row_Abstract $resource, Zend_Db_Table_Row_Abstract $role)
 {
     #var_dump($role);
     $select = $this->select()->setIntegrityCheck(false)->from(array('perm' => $this->_name), array('privilege', 'role_id'))->joinInner(array('rop' => Zend_Registry::get('tablePrefix') . 'acl_role'), 'perm.role_id = rop.id', 'rop.name')->where("role_id = ?", $role->id, Zend_Db::INT_TYPE)->where("resource_id = ?", $resource->id, Zend_Db::INT_TYPE)->limit(1);
     #echo $select->__toString().'<br>'
     $mdlRole = new Acl_Model_Role();
     $select2 = $mdlRole->select()->order('priority DESC')->limit(1);
     if (is_null($this->fetchRow($select))) {
         $childRole = $role->findDependentRowset('Acl_Model_Role', null, $select2)->current();
         if (!is_null($childRole)) {
             return $this->getByResource($resource, $childRole);
         }
     }
     /*else {
     			return $this->fetchRow($select);
     		}*/
     return $this->fetchRow($select);
 }
 /**
  * Constructor
  *
  * @param Zend_Db_Table_Row_Abstract $row
  * @param string|Zend_Db_Table_Abstract $matchTableName
  * @param string|Zend_Db_Table_Abstract $junctionTableName
  * @param string $matchRefRule
  * @throws Zend_Db_Table_Rowset_Exception
  */
 public function __construct(Zend_Db_Table_Row_Abstract $row, $matchTableName, $junctionTableName, $matchRefRule = null)
 {
     $this->_matchRowset = $row->findManyToManyRowset($matchTableName, $junctionTableName);
     $this->_junctionRowset = $row->findDependentRowset($junctionTableName);
     if (count($this->_matchRowset) != count($this->_junctionRowset)) {
         throw new Zend_Db_Table_Rowset_Exception('Mismatch in values returned in the matching rowset and the junction rowset');
     }
     // set count
     $this->_count = count($this->_matchRowset);
     // prepare junction rowset index (to ensure order)
     $junctionData = $this->_junctionRowset->toArray();
     // will get raw data, no iteration
     // get name of column to key off of
     /* @var $t Zend_Db_Table */
     $junctionTable = new $junctionTableName();
     $this->_referenceMap = $junctionTable->getReference($matchTableName, $matchRefRule);
     foreach ($junctionData as $index => $data) {
         $this->_junctionRowsetIndex[$index] = $data[$this->_referenceMap['columns'][0]];
         // @todo: identify use case with compound key
     }
 }
Exemplo n.º 5
0
 /**
  * Return items filter by widget
  * @param int $level
  * @param Zend_Db_Table_Row_Abstract $menu
  * @param Zend_Db_Table_Row_Abstract $menuItem
  * @param array $arrData
  */
 public function getMenuItemsForWidget($level = 0, Zend_Db_Table_Row_Abstract $menu, Zend_Db_Table_Row_Abstract $menuItem = null, &$arrData)
 {
     if (intval($level) < 1) {
         $mdlMenu = new menu_Model_Menu();
         $selectMenu = $mdlMenu->select()->where('IFNULL(parent_id,0)=?', 0, Zend_Db::INT_TYPE);
         $items = $menu->findDependentRowset('menu_Model_Item', 'Menu', $selectMenu);
         #Zend_Debug::dump($menu->toArray());
         #Zend_Debug::dump($selectMenu->__toString());
         #Zend_Debug::dump($items->toArray());
         #die();
         if ($items->count() > 0) {
             $level++;
             foreach ($items as $item) {
                 $arrData[$item->id] = $item->title;
                 $selectItem = $this->select()->where('parent_id=?', $item->id, Zend_Db::INT_TYPE);
                 $subItems = $item->findDependentRowset('menu_Model_Item', 'MenuParent');
                 if ($subItems->count() > 0) {
                     $this->getMenuItemsForWidget($level, $menu, $item, $arrData);
                 }
             }
         }
     } else {
         $selectItem = $this->select()->where('parent_id=?', $menuItem->id, Zend_Db::INT_TYPE);
         $subItems = $menuItem->findDependentRowset('menu_Model_Item', 'MenuParent');
         if ($subItems->count() > 0) {
             $level++;
             foreach ($subItems as $smi) {
                 $prefix = str_pad("", $level - 1, "-");
                 $arrData[$smi->id] = $prefix . ' ' . $smi->title;
                 $this->getMenuItemsForWidget($level, $menu, $smi, $arrData);
             }
         }
     }
 }