• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP node_merge函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中node_merge函数的典型用法代码示例。如果您正苦于以下问题:PHP node_merge函数的具体用法?PHP node_merge怎么用?PHP node_merge使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了node_merge函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: node_merge

/**
 * 递归重组节点信息为多维数组
 */
function node_merge($node, $access = null, $pid = 0)
{
    // p($node);
    $arr = array();
    foreach ($node as $v) {
        if (is_array($access)) {
            // echo "mark";
            // p($access);
            // p($v);
            $v['access'] = in_array($v['id'], $access) ? 1 : 0;
            // p($v['access']);
        }
        // p($v);
        // die();
        if ($v['pid'] == $pid) {
            // p($v);
            // die();
            $v['child'] = node_merge($node, $access, $v['id']);
            // p($v['child']);
            $arr[] = $v;
            // p($arr[]);
        }
        // p($v);
    }
    return $arr;
}
开发者ID:ppxj,项目名称:rbac,代码行数:29,代码来源:function.php


示例2: access

 public function access()
 {
     $rid = I('rid', 0, 'intval');
     $node = M('node')->order('sort')->select();
     $access = M('access')->where(array('role_id' => $rid))->getField('node_id', true);
     $this->node = node_merge($node, $access);
     $this->rid = $rid;
     $this->display();
 }
开发者ID:pude01,项目名称:doc,代码行数:9,代码来源:RbacAction.class.php


示例3: __construct

 public function __construct()
 {
     parent::__construct();
     $menu = D('Menu');
     $map['status'] = 1;
     $this->menu = node_merge($menu->getAllMenu($map));
     $this->remark = CONTROLLER_NAME . '/' . ACTION_NAME;
     $this->controller = CONTROLLER_NAME;
     //dd($this->menu);
 }
开发者ID:mcxzyang,项目名称:vip,代码行数:10,代码来源:CommController.class.php


示例4: checkAuth

 public function checkAuth()
 {
     $ci =& get_instance();
     $module = strtolower($ci->uri->segment(1));
     if ($module == 'admin') {
         // 判断已登录
         $user = $ci->session->userdata('user');
         // 登录方法做是否已登录判断
         $action = strtolower($ci->uri->segment(3));
         $controller = strtolower($ci->uri->segment(2));
         if ($user && $action == 'login') {
             redirect('/admin/main/index');
         } else {
             if (!$user && $action != 'login') {
                 redirect('/admin/login/login');
             }
         }
         $noauth = $ci->config->item('noauth_controller');
         $ci->load->model('M_node', 'node');
         $list = $ci->node->getList(array('ASC' => 'sort', 'id_in' => $user['node']));
         $open = 0;
         $actId = 0;
         $nav = array('首页', '网站信息');
         foreach ($list as $k => $v) {
             $con = explode('/', $v['name']);
             $num = count($con);
             if (strtolower($con[0]) == $controller && $num > 1) {
                 $open = $v['pid'];
                 $nav = array($list[$v['pid']]['title'], $v['title']);
                 foreach ($list as $val) {
                     if ($val['pid'] == $v['id'] && $action == strtolower($val['name'])) {
                         $actId = $val['id'];
                         break;
                     }
                 }
                 break;
             }
         }
         $list = node_merge($list);
         $ci->assign('leftnav', $list);
         $ci->assign('open', $open);
         if (!in_array(ucwords($controller), $noauth)) {
             if ($open <= 0 || $actId <= 0) {
                 $json = $ci->input->get('json');
                 if (isset($json) && $json == 1) {
                     $ci->outJson(101, '', '对不起,您没有权限操作此项!');
                 }
                 $ci->error('对不起,您没有权限操作此项!', 2);
             }
         }
         $ci->assign('nav', $nav);
     }
     // show_error('您无权访问该功能,该错误已经被记录!点击<a href="'. site_url('admin/main/index') .'">返回</a>');
 }
开发者ID:jimmysum,项目名称:potato-cms,代码行数:54,代码来源:Auth.php


示例5: node_merge

/**
 * 递归重组节点信息
 */
function node_merge($node, $pid = 0)
{
    $arr = array();
    foreach ($node as $v) {
        if ($v['pid'] == $pid) {
            $v['child'] = node_merge($node, $v['id']);
            $arr[] = $v;
        }
    }
    return $arr;
}
开发者ID:qq907274532,项目名称:cms,代码行数:14,代码来源:function.php


示例6: edit

 public function edit()
 {
     $rid = I('role_id', 0, 'intval');
     $field = array('id', 'name', 'title', 'pid');
     $node = M('node')->order('sort')->field($field)->select();
     //原有权限
     $access = M('access')->where(array('role_id' => $rid))->getField('node_id', true);
     $node = node_merge($node, $access);
     //组装数组
     $this->assign('node', $node);
     $this->assign('rid', $rid);
     $this->display();
 }
开发者ID:xazzz,项目名称:EasyCMS,代码行数:13,代码来源:RbacaccessAction.class.php


示例7: index

 public function index()
 {
     if (IS_POST) {
         M('Admin')->data(I("post."))->save();
         $this->mtReturn(200, '保存成功', '', true);
     }
     $menu = D('Menu');
     $map['status'] = 1;
     $this->menu = node_merge($menu->getAllMenu($map));
     $Rs = M('Admin')->find(session('uid'));
     $this->assign('Rs', $Rs);
     $this->display();
 }
开发者ID:mcxzyang,项目名称:vipclub,代码行数:13,代码来源:IndexController.class.php


示例8: node_merge

function node_merge($node, $access = null, $pid = 0)
{
    $arr = array();
    foreach ($node as $v) {
        if (is_array($access)) {
            $v['access'] = in_array($v['id'], $access) ? 1 : 0;
        }
        if ($v['pid'] == $pid) {
            $v['child'] = node_merge($node, $access, $v['id']);
            $arr[] = $v;
        }
    }
    return $arr;
}
开发者ID:nbhtm2014,项目名称:big,代码行数:14,代码来源:function.php


示例9: add

 public function add()
 {
     $input = $this->input->post();
     if ($input) {
         $this->load->library('form_validation');
         $this->form_validation->set_data($input);
         $this->form_validation->set_rules($this->rules);
         if ($this->form_validation->run() == TRUE) {
             $input['time'] = time();
             if (isset($input['id'])) {
                 $res = $this->node->update($input, 'id');
             } else {
                 $res = $this->node->add($input);
             }
             if ($res) {
                 $this->outJson(0);
             } else {
                 $this->outJson(1);
             }
         } else {
             $this->outJson(101, '', current($this->form_validation->error_array()));
         }
     } else {
         $id = $this->input->get('id');
         $data = array();
         if ($id) {
             $data = $this->node->getOne($id);
             if (!$data) {
                 $this->error('节点不存在');
             }
         }
         // echo '<pre>';print_r($data);die;
         $list = $this->node->getAll();
         $list = node_merge($list);
         $this->assign('list', $list);
         $this->assign('data', $data);
         $this->display();
     }
 }
开发者ID:jimmysum,项目名称:potato-cms,代码行数:39,代码来源:Node.php


示例10: add

 public function add()
 {
     $input = $this->input->post();
     if ($input) {
         $this->load->library('form_validation');
         $this->form_validation->set_data($input);
         $this->form_validation->set_rules($this->rules);
         if ($this->form_validation->run() == TRUE) {
             $input['time'] = time();
             if (isset($input['id'])) {
                 $res = $this->category->update($input, 'id');
             } else {
                 $res = $this->category->add($input);
             }
             if ($res) {
                 $this->outJson(0);
             } else {
                 $this->outJson(1);
             }
         } else {
             $this->outJson(101, '', current($this->form_validation->error_array()));
         }
     } else {
         $id = $this->input->get('id');
         $cate = array();
         if ($id) {
             $cate = $this->category->getOne($id);
             if (!$cate) {
                 $this->error('分类不存在');
             }
         }
         $this->assign('cate', $cate);
         $list = $this->category->getAll();
         $list = node_merge($list);
         $this->assign('list', $list);
         $this->display();
     }
 }
开发者ID:jimmysum,项目名称:potato-cms,代码行数:38,代码来源:Cate.php


示例11: access

 public function access()
 {
     if (IS_POST) {
         $rid = isset($_POST['rid']) ? $_POST['rid'] : 0;
         $arr = array();
         $acc = M('access');
         $acc->where('role_id=' . $rid)->delete();
         foreach ($_POST['access'] as $v) {
             $tmp = explode('_', $v);
             // p($tmp);
             $arr[] = array('role_id' => $rid, 'node_id' => $tmp[0], 'level' => $tmp[1]);
         }
         // p($arr);die;
         $res = $acc->addAll($arr);
         if ($res) {
             $this->success('权限修改成功', U('adminList'));
         } else {
             $this->error('权限修改失败', U('access'));
         }
         return;
     }
     $rid = isset($_GET['rid']) ? $_GET['rid'] : 0;
     $res = K('Node')->getNode();
     $acc = M('access')->where('role_id=' . $rid)->all();
     if (!$res) {
         $res = 0;
     }
     $role = array();
     foreach ($acc as $v) {
         $role[] = $v['node_id'];
     }
     $res = node_merge($res, $role);
     $this->assign('node', $res);
     $this->assign('rid', $rid);
     $this->display();
 }
开发者ID:sujinw,项目名称:webPHP,代码行数:36,代码来源:AdminUserController.class.php


示例12: add

 public function add()
 {
     $input = $this->input->post();
     if ($input) {
         // print_r($input);die;
         $this->load->library('form_validation');
         $this->form_validation->set_data($input);
         $this->form_validation->set_rules($this->rules);
         if ($this->form_validation->run() == TRUE) {
             $user = $this->session->userdata('user');
             $input['userid'] = $user['info']['id'];
             $input['publish_time'] = strtotime($input['publish_time']);
             if (isset($input['id'])) {
                 $input['update_time'] = time();
                 $res = $this->article->update($input, 'id');
             } else {
                 $input['time'] = time();
                 $res = $this->article->add($input);
             }
             if ($res) {
                 $this->outJson(0);
             } else {
                 $this->outJson(1);
             }
         } else {
             $this->outJson(101, '', current($this->form_validation->error_array()));
         }
     } else {
         $id = $this->input->get('id');
         $article = array();
         if ($id) {
             $article = $this->article->getOne($id);
             if (!$article) {
                 $this->error('文章不存在');
             }
             $this->load->model('M_Admin', 'user');
             $user = $this->user->getUserById($article['userid']);
             $article['username'] = $user['username'];
         }
         $this->assign('article', $article);
         $list = $this->category->getAll();
         $list = node_merge($list);
         $this->assign('list', $list);
         $this->display();
     }
 }
开发者ID:jimmysum,项目名称:potato-cms,代码行数:46,代码来源:Article.php


示例13: cate_list

 /**
  * [cate_list 公共的无限级分类]
  * @param  [type] $model [description]
  * @return [type]        [description]
  */
 public function cate_list($model, $where = array(), $order = array())
 {
     $list = $model->where($where)->order($order)->select();
     return node_merge($list);
 }
开发者ID:qq907274532,项目名称:cms,代码行数:10,代码来源:BaseController.class.php


示例14: access

 public function access()
 {
     $rid = $_GET['rid'];
     //读取有用字段
     $field = array('id', 'name', 'title', 'pid');
     $node = M('node')->order('sort')->field($field)->select();
     //读取用户原有权限
     $access = M('access')->where(array('role_id' => $rid))->getField('node_id', true);
     $node = node_merge($node, $access);
     $this->assign('rid', $rid);
     $this->assign('node', $node);
     $this->display();
 }
开发者ID:zmou,项目名称:service,代码行数:13,代码来源:RBACAction.class.php


示例15: getwhere

 public function getwhere()
 {
     $info = D('Node')->getRbac($_SESSION['id']);
     $list = node_merge($info);
     foreach ($list as $k => $v) {
         foreach ($v['child'] as $key => $va) {
             $list[$k]['child'][$key]['url'] = U($va['name'] . '/index');
         }
     }
     return $list;
     //$result=M('access')->alias('a')->join('')
 }
开发者ID:qq907274532,项目名称:YmxCMS,代码行数:12,代码来源:BaseController.class.php


示例16: distribute

 public function distribute()
 {
     $input = $this->input->post();
     $this->load->model('M_Access', 'access');
     if ($input) {
         if (isset($input['id'])) {
             $user = $this->session->userdata('user');
             if ($input['id'] == 1 && $user['info']['role_id'] != 1) {
                 $this->outJson(101, '', '不可以修改超级管理员权限!');
             }
             $data = $this->role->getOne($input['id']);
             if (!$data) {
                 $this->outJson(101, '', '参数错误');
             }
             $this->access->del($input['id']);
             $data = array();
             foreach ($input['check'] as $v) {
                 $data[] = array('role_id' => $input['id'], 'node_id' => $v);
             }
             $res = $this->access->addMuti($data);
             if ($res) {
                 $this->outJson(0);
             } else {
                 $this->outJson(1);
             }
         } else {
             $this->outJson(101, '', '参数错误');
         }
     } else {
         $id = $this->input->get('id');
         if (!$id) {
             $this->outJson(-1);
         }
         $data = $this->role->getOne($id);
         if (!$data) {
             $this->outJson(101, '', '参数错误');
         }
         $access = $this->access->getList(array('role_id' => $id));
         $auth = array();
         foreach ($access as $k => $v) {
             $auth[] = $v['node_id'];
         }
         $this->load->model('M_node', 'node');
         $list = $this->node->getAll();
         $list = node_merge($list);
         $this->assign('auth', $auth);
         $this->assign('list', $list);
         $this->assign('data', $data);
         $this->display();
     }
 }
开发者ID:jimmysum,项目名称:potato-cms,代码行数:51,代码来源:Role.php


示例17: role

 /**
  * 权限配置
  * @author jiangwenshu <[email protected]>
  */
 public function role()
 {
     $role_id = I('role_id', 0, 'intval');
     $data = array();
     if (IS_POST) {
         M('access')->where('role_id=' . $role_id)->delete();
         foreach ($_POST['role'] as $v) {
             //获取菜单节点
             $tmp = explode('_', $v);
             $data[] = array('role_id' => $role_id, 'node_id' => $tmp[0], 'level' => $tmp[1]);
         }
         //插入新权限  addAll循环插入
         if (M('access')->addAll($data)) {
             $this->success('操作成功!', "index");
         } else {
             $this->error('操作失败!');
         }
     } else {
         $menus = D("Menu")->order('sort')->field(array('id', 'title', 'pid'))->select();
         $access = M('access')->where('role_id=' . $role_id)->getField('node_id', true);
         $lists = node_merge($menus, $access);
         $this->assign("role_id", $role_id);
         $this->assign("menus", $lists);
         $this->display();
     }
 }
开发者ID:jws132,项目名称:sjcrm,代码行数:30,代码来源:AuthController.class.php


示例18: nodeList

 public function nodeList()
 {
     $nodes = $this->order("sort asc")->select();
     $list = node_merge($nodes);
     return $list;
 }
开发者ID:jws132,项目名称:sjcrm,代码行数:6,代码来源:MenuModel.class.php


示例19: _list

 /**
  * 根据表单生成查询条件
  * 进行列表过滤
  * @param Model $model 数据对象
  * @param HashMap $map 过滤条件
  * @param string $sortBy 排序
  * @param boolean $asc 是否正序
  */
 protected function _list($model, $map = array(), $sortBy = '', $asc = false)
 {
     //排序字段 默认为主键名
     if (!empty($_REQUEST['_order'])) {
         $order = $_REQUEST['_order'];
     } else {
         $order = !empty($sortBy) ? $sortBy : $model->getPk();
     }
     //排序方式默认按照倒序排列
     //接受 sort参数 0 表示倒序 非0都 表示正序
     if (!empty($_REQUEST['_sort'])) {
         $sort = $_REQUEST['_sort'] == 'asc' ? 'asc' : 'desc';
     } else {
         $sort = $asc ? 'asc' : 'desc';
     }
     //取得满足条件的记录数
     $count = $model->where($map)->count();
     //每页显示的记录数
     if (!empty($_REQUEST['numPerPage'])) {
         $listRows = $_REQUEST['numPerPage'];
     } else {
         $listRows = '10';
     }
     //设置当前页码
     if (!empty($_REQUEST['pageNum'])) {
         $nowPage = $_REQUEST['pageNum'];
     } else {
         $nowPage = 1;
     }
     $_GET['p'] = $nowPage;
     //创建分页对象
     import("ORG.Util.Page");
     $p = new Page($count, $listRows);
     //分页查询数据
     //$list = $model->where($map)->order($order . ' ' . $sort)->select();
     $list = $model->where($map)->order($order . ' ' . $sort)->limit($p->firstRow . ',' . $p->listRows)->select();
     //回调函数,用于数据加工,如将用户id,替换成用户名称
     if (method_exists($this, '_tigger_list')) {
         $this->_tigger_list($list);
     }
     //分页跳转的时候保证查询条件
     foreach ($map as $key => $val) {
         if (!is_array($val)) {
             $p->parameter .= "{$key}=" . urlencode($val) . "&";
         }
     }
     //分页显示
     $page = $p->show();
     //列表排序显示
     $sortImg = $sort;
     //排序图标
     $sortAlt = $sort == 'desc' ? '升序排列' : '倒序排列';
     //排序提示
     $sort = $sort == 'desc' ? 1 : 0;
     //排序方式
     //读取节点数据
     $app = M('Node')->order('sort')->select();
     $app = node_merge($app);
     //打包数组
     //模板赋值显示
     $this->assign('app', $app);
     $this->assign('list', $list);
     $this->assign('sort', $sort);
     $this->assign('order', $order);
     $this->assign('sortImg', $sortImg);
     $this->assign('sortType', $sortAlt);
     $this->assign("page", $page);
     $this->assign("search", $search);
     //搜索类型
     $this->assign("values", $_POST['values']);
     //搜索输入框内容
     $this->assign("totalCount", $count);
     //总条数
     $this->assign("numPerPage", $p->listRows);
     //每页显多少条
     $this->assign("currentPage", $nowPage);
     //当前页码
 }
开发者ID:xazzz,项目名称:EasyCMS,代码行数:86,代码来源:RbacnodeAction.class.php


示例20: accessAction

 /**
  * 配置权限
  */
 public function accessAction()
 {
     $rid = I('rid', 0, 'intval');
     $field = array('id', 'name', 'title', 'pid');
     $node = M('node')->order('sort')->field($field)->select();
     //;
     //读取原有权限
     $access = M('access')->where(array('role_id' => $rid))->getField('node_id', true);
     $node = node_merge($node, $access);
     $this->assign('rid', $rid);
     $this->assign('node', $node);
     if (array_key_exists('HTTP_X_PJAX', $_SERVER) && $_SERVER['HTTP_X_PJAX']) {
         $this->display();
     } else {
         layout(true);
         $this->display();
     }
 }
开发者ID:ndflydog,项目名称:thinkphp_rbac_pjax,代码行数:21,代码来源:RbacController.class.php



注:本文中的node_merge函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP node_object_prepare函数代码示例发布时间:2022-05-15
下一篇:
PHP node_load_multiple函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap