/b2b/core/model/admin/mdl.adminroles.php
PHP | 223 lines | 164 code | 21 blank | 38 comment | 17 complexity | 72d8e9b72eea8195d2a6572fefbd129a MD5 | raw file
- <?php
- require_once('shopObject.php');
- class mdl_adminroles extends shopObject{
- var $idColumn = 'role_id'; //??id??
- var $textColumn = 'role_name';
- var $defaultCols = 'role_name,role_memo';
- var $adminCtl = 'trading/delivery_centers';
- var $defaultOrder = array('role_id','desc');
- var $tableName = 'sdb_admin_roles';
- function getAllActions(){
- return array(
- '1'=>'??',
- '2'=>'??',
- '3'=>'??',
- '4'=>'????',
- '5'=>'????',
- '6'=>'????',
- '7'=>'????',
- '8'=>'???',
- '9'=>'????',
- '10'=>'???',
- );
- }
- function rolemap(){
- return array(
- 'goods'=>1,
- 'order'=>2,
- 'member'=>3,
- 'sale'=>4,
- 'site'=>5,
- 'analytics'=>6,
- 'setting'=>7,
- 'tools'=>8,
- 'distribution'=>9,
- 'advance'=>10
- );
- }
- function getColumns(){
- return array(
- 'role_id'=>array('label'=>'??id','class'=>'span-2'),
- 'role_name'=>array('label'=>'????','class'=>'span-4','required'=>1),
- 'role_memo'=>array('label'=>'????','class'=>'span-5'),
- );
- }
- function instance($role_id){
- $role = parent::instance($role_id);
- if($role){
- $rows = $this->db->select('select * from sdb_lnk_acts where role_id='.intval($role_id));
- foreach($rows as $r){
- $role['actions'][] = $r['action_id'];
- }
- }
- //print_r($role);exit;
- return $role;
- }
- /**
- * ??????
- * @parmar $data ??
- * @author yanglish
- **/
- function update($data,$filter){
- $c = parent::update($data,$filter);
- if($filter['role_id']){
- $role_id = array();
- foreach($this->getList('role_id',$filter) as $r){
- $role_id[] = $r['role_id'];
- }
- }else{
- $role_id = $filter['role_id'];
- }
- if(count($role_id)==1){
- if ($data['actions']){
- //print_r($data['actions']);exit;
- $new_date_array = $this->add_new_list($data['actions']);
- foreach ($new_date_array as $key => $val){
- $action .= $val.",";
- }
- $action = array_unique(explode(",",rtrim($action,",")));
- $new_data = $action;
- }else{
- $new_data =array();
- }
- foreach($new_data as $k_key => $k_val){
- $delactions[] = "'{$k_val}'";
- }
- $this->db->exec("delete from sdb_lnk_acts where role_id=".intval($role_id[0]));
- if(count($new_data)>0){
- $p_action = $this->pro_list($new_data);
- //??????????,????????
- if (!empty($p_action)){
- $new_data = array_merge($p_action,$new_data);
- }
- $sql = 'REPLACE INTO `sdb_lnk_acts` (`role_id`,`action_id`) VALUES ';
- foreach($new_data as $action_id){
- $actions[] = "('{$role_id[0]}','$action_id')";
- }
- $sql .= implode($actions,',').';';
- $this->db->exec($sql);
- }
- }else{
- }
- return $c;
- }
- /**
- * ????
- * @parmar $data ??
- * @author yanglish
- **/
- function insert($data){
- //print_r("1111");exit;
- $role_id = parent::insert($data);
- if($role_id && is_array($data['actions'])){
- $new_date = $this->add_new_list($data['actions']);
- $sql = 'REPLACE INTO `sdb_lnk_acts` (`role_id`,`action_id`) VALUES ';
- foreach($new_date as $key => $val){
- $action .= $val.",";
- }
- $action = explode(",",rtrim($action,","));
- $p_action = $this->pro_list($action);
- //??????????,????????
- if (!empty($p_action)){
- $action = array_merge($p_action,$action);
- }
- foreach ($action as $a_key => $a_val){
- $new_action[] = "('$role_id','$a_val')";
- }
- $sql .= implode($new_action,',').';';
- $a = $this->db->exec($sql);
- }
- return $role_id;
- }
- /**
- * ??????????
- * @parmar $List ??
- * @author yanglish
- **/
- function add_new_list($list){
- include_once('adminSctl.php');
- //error_log(print_r($list,true),3,"d:/2.txt");exit;
- $ctl_array = $this->sctl_list($act_config);
- foreach ($list as $l_key => $l_val){
- if (isset($ctl_array[$l_val])){
- $action[] = $ctl_array[$l_val]['binding'];
- }
- }
- //error_log(print_r($action,true),3,"d:/2.txt");exit;
- return $action;
- }
- /**
- * ??????
- * @parmar $List ??
- * @author yanglish
- **/
- function sctl_list($list){
- foreach ($list as $l_key =>$l_val){
- if (empty($l_val['name'])){
- unset($list[$l_key]);
- }else{
- foreach ($l_val['op'] as $ll_k => $ll_v){
- if (empty($ll_v['name'])){
- unset($list[$l_key]['op'][$ll_k]);
- }
- }
- $new_list[] = $list[$l_key]['op'];
- }
- }
- $all_val=array();
- foreach ($new_list as $t_k => $t_v){
- $all_val=$all_val+$t_v;
- }
- return $all_val;
- }
- /**
- * ???????????/????/????/???? ?????????
- * ?????????????????????????? ?????????? hanxuefei 2010-12-24 18:28
- * @parmar $List ??
- * @author yanglish
- **/
- function pro_list($list){
- $new_list = array();
- if (array_search("goods/product-edit-price",$list) && array_search("goods/product-edit-info",$list) && array_search("goods/product-recycle",$list) && array_search("goods/product-edit-repertory",$list)){
- $new_list = array('goods/product-editMode','goods/product-batchEdit','goods/product-renTag','goods/product-delTag','goods/product-tagmgr','goods/product-newTag','goods/product-setTag','goods/product-saveBatchEdit','goods/product-prefilter','goods/product-saveValue','goods/product-saveColSet','goods/product-goodsAlert','goods/product-show','goods/product-virtualcat','goods/product-filter','goods/product-nospec','goods/product-getWholeSaleList','goods/product-clone_goods_img','goods/product-update','goods/product-toRemove','goods/product-enable','goods/product-disable','goods/product-sendNotify','goods/product-setOrder','goods/product-ratelist','goods/product-checkItem','goods/product-editItem','goods/product-getGoodsSpec','goods/product-view_src_img','goods/product-newPic','goods/product-removePic','goods/product-taobaocsv','goods/product-export_taobao_img','goods/product-updateSupplierData','goods/product-batchEdit','goods/product-singleBatchEdit','goods/product-batchImage','goods/product-nextImage','goods/product-apply_wholesale','goods/product-do_apply_wholesale','goods/product-check_bn_repeate','goods/product-nextSaveBatchEdit','goods/product-nextSaveBatchEable','goods/product-import','goods/product-importer');
- }
- return $new_list;
- }
- /**
- * ??????
- * @parmar $List ??
- * @author yanglish
- **/
- function deladmin($list){
- $sSql = 'DELETE FROM sdb_lnk_acts WHERE';
- $sql = 'DELETE FROM sdb_admin_roles WHERE';
- if(count($list)>0){
- $sSql .= ' role_id IN ('.implode(',',$list).')';
- $sql .= ' role_id IN ('.implode(',',$list).')';
- $this->db->exec($sql);
- return $this->db->exec($sSql);
- }
- return false;
- }
- }