Exemple #1
0
 function fetch_menu_list($pid = 0)
 {
     //$mn = new model_cnotify;
     $select = new database_select();
     $select->from(array('i' => $this->name))->order('i.orderid')->where('i.parentid = ?', $pid);
     return $this->entity_all($this->adapter->fetch_all($select));
 }
Exemple #2
0
 function fetch_list($w = array())
 {
     $select = new database_select();
     $select->from(array('i' => $this->name));
     if (@(string) $w['id']) {
         $select->where('stitle', (string) $w['id']);
     }
     return $select;
 }
Exemple #3
0
 function fetch_role_title_by_role($rule)
 {
     $mr = new model_crole();
     $select = new database_select();
     $select->from(array('i' => $this->name), array('r.title'));
     $select->join(array('r' => $mr->name), 'r.id = i.role', '');
     $select->where(array('i.parentid' => $rule));
     $select->order('r.title');
     $select->group('r.id');
     return $this->adapter->fetch_col($select);
 }
Exemple #4
0
 function fetch_control_no_read()
 {
     $select = new database_select();
     $select->from($this->name, array('id', 'title', 'style'));
     $select->where(array('`is_read` = ?' => 0, '`menu` = ?' => 0));
     $select->order('date');
     $select->limit(50);
     return $this->adapter->fetch_all($select);
 }
Exemple #5
0
 function fetch_control_list($where = null, $order = null, $count = null, $offset = null)
 {
     $select = new database_select(null, $this->adapter);
     $select->from($this->name);
     if ($where) {
         $select->where($where);
     }
     if ($order) {
         $select->order($order);
     }
     if ($count) {
         $select->limit($count, $offset);
     }
     return $select;
 }
Exemple #6
0
 public function init_acl()
 {
     if (!$this->model_role || !$this->model_rule || !$this->model_resource || !$this->model_role2role || !$this->model_rule2role || !$this->model_rule2resource) {
         return false;
     }
     $this->_acl = new acl();
     // Добавляем роли
     $roles = $this->model_role->fetch_col('id');
     if (!$roles) {
         return false;
     }
     foreach ($roles as $el) {
         $select = new database_select();
         $select->from(array('i' => $this->model_role->name), array('i.id'))->join(array('r' => $this->model_role2role->name), 'i.id = r.role', '')->group('i.id')->where('r.parentid = ?', $el);
         $parents = $this->model_role->adapter->fetch_col($select);
         $this->_acl->add_role($el, $parents);
     }
     // Добавляем ресурсы
     $select = new database_select();
     $select->from(array('i' => $this->model_resource->name), array('i.id'))->join_left(array('r' => $this->model_resource->name), 'i.parentid = r.id', array('parentid' => 'r.id'))->group('i.id');
     $resources = $this->model_resource->fetch_all($select);
     if (!$resources) {
         return false;
     }
     foreach ($resources as $el) {
         $this->_acl->add_resource($el->id, $el->parentid);
     }
     // Добавляем правила
     $rules = $this->model_rule->fetch_all(null, 'orderid');
     if (!$rules) {
         return false;
     }
     foreach ($rules as $el) {
         $select_1 = new database_select();
         $select_1->from(array('i' => $this->model_role->name), array('i.id'))->join(array('r' => $this->model_rule2role->name), 'i.id = r.role', '')->group('i.id')->where('r.parentid = ?', $el->id);
         $roles_refer = $this->model_role->adapter->fetch_col($select_1);
         $select_2 = new database_select();
         $select_2->from(array('i' => $this->model_resource->name), array('i.id'))->join(array('r' => $this->model_rule2resource->name), 'i.id = r.resource', '')->group('i.id')->where('r.parentid = ?', $el->id);
         $resources_refer = $this->model_resource->adapter->fetch_col($select_2);
         $this->_acl->{$el->is_allow ? 'allow' : 'deny'}($roles_refer, $resources_refer);
     }
 }
Exemple #7
0
 function finished_quant($oid = null, $id = null)
 {
     $select = new database_select();
     $select->from(array('i' => $this->_model_order_item->name), array('quant' => '(SUM(i.quant))'))->join(array('o' => $this->_model_order->name), 'o.id = i.parentid', '')->where('o.id = ?', $oid)->group('o.id');
     if ($id != null) {
         $select->where('i.' . $this->_field_order_item_id . ' = ?', $id);
     }
     return (int) $this->_model_order_item->adapter->fetch_one($select);
 }