/**
  * 获取所有默认角色
  *
  * @return array
  */
 public function getAllDefaultRoles()
 {
     if (null == self::$_allDefaultRoles) {
         self::$_allDefaultRoles = $this->_cache->load('acl_all_default_roles');
         if (self::$_allDefaultRoles == false) {
             $rows = $this->_db->select()->from(array('role' => 'acl_role'), array('role_name', 'mod_name'))->join('acl_module', 'acl_module.mod_name=role.mod_name', array())->where('role.is_guest=0')->where('role.is_default=1');
             $rows = $this->_db->fetchAll($rows);
             $roles = array();
             foreach ($rows as $row) {
                 $roles[$row['mod_name']] = "{$row['mod_name']}.{$row['role_name']}";
             }
             self::$_allDefaultRoles = $roles;
             $this->_cache->save($roles, 'acl_all_default_roles');
         }
     }
     return self::$_allDefaultRoles;
 }
 /**
  * Get the list of the products for all categories
  *
  *
  * @return array
  */
 public function getListOfAllNewProducts()
 {
     $products = array();
     $this->getDataByName();
     $oProducts = new ProductsObject();
     $oSubCat = new SubCategoriesObject();
     $oCategory = new CatalogCategoriesObject();
     $subCategories = $oSubCat->getSubCatByCategory(0, false, $this->_currentLang);
     $oCategory->setQuery($subCategories);
     $categoryQuery = $oCategory->getDataCatagory($this->_currentLang, false);
     $oProducts->setQuery($categoryQuery);
     $select = $oProducts->getProducts($this->_currentLang, false);
     $select->where('P_New = 1');
     $select->order('PI_Name ASC');
     $products = $this->_db->fetchAll($select);
     //echo $select;
     return $products;
 }
 /**
  * get roles and resources from db, build Zend_Acl structure and add permissions
  * @param Zend_Db $db
  */
 protected function makeAcl($db)
 {
     $acl = new Zend_Acl();
     $res = $db->fetchAll('select * from system_role');
     foreach ($res as $obj) {
         if ($obj['inherit_role'] != '') {
             if ($acl->hasRole($obj['inherit_role'])) {
                 $acl->addRole(new Zend_Acl_Role($obj['role']), $obj['inherit_role']);
             } else {
                 /**
                  * @todo very simply system to order roles, add role before inherited role
                  */
                 $res[] = $obj;
                 continue;
             }
         } else {
             $acl->addRole(new Zend_Acl_Role($obj['role']));
         }
     }
     $res = $db->fetchAll('select * from system_resource');
     foreach ($res as $obj) {
         $acl->addResource(new Zend_Acl_Resource($obj['resource']));
     }
     $res = $db->fetchAll('select r.role as role, rs.resource as resource, permission, privilege ' . 'from system_role as r join system_role_has_system_resource as m on ' . '(r.id = m.system_role_id) join system_resource as rs on (m.system_resource_id = rs.id)');
     foreach ($res as $obj) {
         $privilege = explode(',', $obj['privilege']);
         if ($obj['permission'] == 'allow') {
             $acl->allow($obj['role'], $obj['resource'], $privilege);
         } else {
             $acl->deny($obj['role'], $obj['resource'], $privilege);
         }
     }
     return $acl;
 }
Exemple #4
0
 /**
  * Enter description here ...
  * @return unknown
  */
 public function getAllIntroAdmin()
 {
     $row = $this->db->fetchAll("SELECT * FROM intro");
     return $row;
 }