public function fetchList()
 {
     $menuList = $this->order('sort')->select();
     $tree = list_to_tree($menuList);
     $list = tree_to_list($tree);
     return $list;
 }
示例#2
0
 public function node()
 {
     $node_model = M("Node");
     if (!empty($_POST['eq_pid'])) {
         $eq_pid = $_POST['eq_pid'];
     } else {
         $eq_pid = $node_model->where('pid=0')->order('sort asc')->getField('id');
     }
     //dump($node_model -> select());
     $node_list = $node_model->order('sort asc')->select();
     $node_list = tree_to_list(list_to_tree($node_list, $eq_pid));
     $node_list = rotate($node_list);
     //dump($node_list);
     $node_list = implode(",", $node_list['id']) . ",{$eq_pid}";
     $where['id'] = array('in', $node_list);
     $menu = $node_model->field('id,pid,name,url')->where($where)->order('sort asc')->select();
     $tree = list_to_tree($menu);
     $this->assign('eq_pid', $eq_pid);
     $list = tree_to_list($tree);
     $this->assign('node_list', $list);
     //$this->assign('menu',sub_tree_menu($list));
     $role = M("Role")->order('sort asc')->select();
     $this->assign('list', $role);
     $list = $node_model->where('pid=0')->order('sort asc')->getField('id,name');
     $this->assign('groupList', $list);
     $this->display();
 }
示例#3
0
 public function index()
 {
     $widget['date'] = true;
     $this->assign("widget", $widget);
     $this->assign('user_id', get_user_id());
     $auth = $this->config['auth'];
     $this->assign('auth', $auth);
     if ($auth['admin']) {
         $node = D("Dept");
         $dept_id = get_dept_id();
         $dept_name = get_dept_name();
         $menu = array();
         $dept_menu = $node->field('id,pid,name')->where("is_del=0")->order('sort asc')->select();
         $dept_tree = list_to_tree($dept_menu, $dept_id);
         $count = count($dept_tree);
         if (empty($count)) {
             /*获取部门列表*/
             $html = '';
             $html = $html . "<option value='{$dept_id}'>{$dept_name}</option>";
             $this->assign('dept_list', $html);
             /*获取人员列表*/
             $where['dept_id'] = array('eq', $dept_id);
             $emp_list = D("User")->where($where)->getField('id,name');
             $this->assign('emp_list', $emp_list);
         } else {
             /*获取部门列表*/
             $this->assign('dept_list', select_tree_menu($dept_tree));
             $dept_list = tree_to_list($dept_tree);
             $dept_list = rotate($dept_list);
             $dept_list = $dept_list['id'];
             /*获取人员列表*/
             $where['dept_id'] = array('in', $dept_list);
             $emp_list = D("User")->where($where)->getField('id,name');
             $this->assign('emp_list', $emp_list);
         }
     }
     $map = $this->_search();
     if ($auth['admin']) {
         if (empty($map['dept_id'])) {
             if (!empty($dept_list)) {
                 $map['dept_id'] = array('in', array_merge($dept_list, array($dept_id)));
             } else {
                 $map['dept_id'] = array('eq', $dept_id);
             }
         }
     } else {
         $map['user_id'] = get_user_id();
     }
     if (method_exists($this, '_search_filter')) {
         $this->_search_filter($map);
     }
     $model = D("WorkLog");
     if (!empty($model)) {
         $this->_list($model, $map);
     }
     $this->display();
 }
 public function getMenuList()
 {
     $menuTree = $this->getMenuTree(null, $where, 0, 3);
     $menuList = tree_to_list($menuTree, 0, '_son', '_level', 'order');
     //设置总条数
     $this->totalCount = count($menuList);
     //截取该页的信息
     $menuList = array_slice($menuList, ($this->p - 1) * $this->pageSize, $this->pageSize);
     return $menuList;
 }
示例#5
0
 function del_tag($tag_id)
 {
     $model = M("UserTag");
     $tag_list = tree_to_list(list_to_tree($this->get_tag_list("id,pid,name"), $tag_id));
     $tag_list = rotate($tag_list);
     $tag_list = implode(",", $tag_list['id']) . ",{$tag_id}";
     $where['id'] = array('in', $tag_list);
     $this->where($where)->delete();
     $this->_del_data_by_tag($tag_list);
 }
 private function get_emp_list_by_dept_id($id)
 {
     $dept = tree_to_list(list_to_tree(M("Dept")->where('is_del=0')->select(), $id));
     $dept = rotate($dept);
     $dept = implode(",", $dept['id']) . ",{$id}";
     $model = M("User");
     $where['dept_id'] = array('in', $dept);
     $data = $model->where($where)->select();
     return $data;
 }
示例#7
0
 function read()
 {
     $id = $_REQUEST['id'];
     $model = M("Dept");
     $dept = tree_to_list(list_to_tree(M("Dept")->where('is_del=0')->select(), $id));
     $dept = rotate($dept);
     $dept = implode(",", $dept['id']) . ",{$id}";
     $model = D("UserView");
     $where['is_del'] = array('eq', '0');
     $where['dept_id'] = array('in', $dept);
     $data = $model->where($where)->select();
     $this->ajaxReturn($data, "", 1);
 }
 protected function _assign_badge_count()
 {
     $node_list = D("Node")->access_list();
     $system_folder_menu = D("SystemFolder")->get_folder_menu();
     $user_folder_menu = D("UserFolder")->get_folder_menu();
     $node_list = array_merge($node_list, $system_folder_menu, $user_folder_menu);
     foreach ($node_list as $val) {
         $badge_function = $val['badge_function'];
         if (!empty($badge_function) and function_exists($badge_function) and $badge_function != 'badge_sum') {
             if ($badge_function == 'badge_count_system_folder' or $badge_function == 'badge_count_user_folder') {
                 $badge_count[$val['id']] = $badge_function($val['fid']);
             } else {
                 $badge_count[$val['id']] = $badge_function();
             }
         }
     }
     //$node_tree = list_to_tree($node_list);
     foreach ($node_list as $key => $val) {
         if ($val['badge_function'] == 'badge_sum') {
             $child_menu = list_to_tree($node_list, $val['id']);
             $child_menu = tree_to_list($child_menu);
             //dump($child_menu);
             $child_menu_id = rotate($child_menu);
             $count = 0;
             if (isset($child_menu_id['id'])) {
                 $child_menu_id = $child_menu_id['id'];
                 $count = 0;
                 foreach ($child_menu_id as $k1 => $v1) {
                     if (!empty($badge_count[$v1])) {
                         $count += $badge_count[$v1];
                     }
                 }
             }
             $badge_sum[$val['id']] = $count;
         }
     }
     if (!empty($badge_count)) {
         if (!empty($badge_sum)) {
             $total = $badge_count + $badge_sum;
         } else {
             $total = $badge_count;
         }
         $this->assign('badge_count', $total);
     }
 }
示例#9
0
 public function node()
 {
     $node = M("Node");
     if (!empty($_POST['s_pid'])) {
         $pid = $_POST['s_pid'];
     } else {
         $pid = $node->where('pid=0')->order('sort asc')->getField('id');
     }
     $menu = array();
     $menu = $node->field('id,pid,name,check_auth,"#" as url')->order('sort asc')->select();
     $tree = list_to_tree($menu, $pid);
     $this->assign('pid', $pid);
     $list = tree_to_list($tree);
     $this->assign('node_list', $list);
     //$this->assign('menu',sub_tree_menu($list));
     $role = M("Role")->select();
     $this->assign('list', $role);
     $list = $node->where('pid=0')->order('sort asc')->getField('id,name');
     $this->assign('groupList', $list);
     $this->display();
 }
 public function fetchSubMenu()
 {
     $menuInfo = $this->_fetchCurrentMenuInfo();
     //如果无此菜单,则证明为ajax方法.直接退出
     if ($menuInfo == false) {
         return;
     }
     $id = $menuInfo['id'];
     $pid = $menuInfo['pid'];
     /*
      * 有记录,查找出目录结构
      */
     $adminM = D('Admin/AdminMenu');
     $adminM->setCurrentMenuId($id);
     $menus = $adminM->fetchParetnsMenus();
     $subMenu = $adminM->fetchSubMenu($menus, 1, 2);
     $subMenu = tree_to_list($subMenu);
     //添加CURRENT,parent信息
     $subMenu = $this->_addCurrent($subMenu, $menus);
     $tree = list_to_tree($subMenu, $pk = 'id', $pid = 'pid', $child = '_child', $menus[1]);
     return '<ul class="nav nav-list">' . $this->_treeAddHtml($tree) . "</ul>";
 }
示例#11
0
 function ajaxRead()
 {
     $type = $_REQUEST['type'];
     $id = $_REQUEST['id'];
     switch ($type) {
         case "company":
             $model = M("Dept");
             $dept = tree_to_list(list_to_tree(M("Dept")->select(), $id));
             $dept = rotate($dept);
             $dept = implode(",", $dept['id']) . ",{$id}";
             $model = M("User");
             $where['dept_id'] = array('in', $dept);
             $data = $model->where($where)->field('id,emp_name,dept_id,email')->select();
             break;
         case "rank":
             $model = M("User");
             $where['rank_id'] = array('eq', $id);
             $data = $model->where($where)->field('id,emp_name,email')->select();
             break;
         case "position":
             $model = M("User");
             $where['position_id'] = array('eq', $id);
             $data = $model->where($where)->field('id,emp_name,email')->select();
             break;
         case "personal":
             $model = M("FlowType");
             if ($id == "#") {
                 $id = "";
             }
             $where['group'] = array('eq', $id);
             $where['email'] = array('neq', '');
             $where['user_id'] = array('eq', get_user_id());
             $data = $model->where($where)->field('id,name as emp_name,email')->select();
             break;
         default:
     }
     if (true) {
         // 读取成功
         $this->ajaxReturn($data, "", 1);
     }
 }
示例#12
0
/**
 * 将list_to_tree的树还原成列表
 * @param  array  $tree 原来的树
 * @param  string $child 孩子节点的键
 * @param  string $order 排序显示的键,一般是主键 升序排列
 * @param  array  $list 过渡用的中间数组,
 * @return array        返回排过序的列表数组
 * @author yangweijie <*****@*****.**>
 */
function tree_to_list($tree, $child = '_child', $order = 'id', &$list = array())
{
    if (is_array($tree)) {
        $refer = array();
        foreach ($tree as $key => $value) {
            $reffer = $value;
            if (isset($reffer[$child])) {
                unset($reffer[$child]);
                tree_to_list($value[$child], $child, $order, $list);
            }
            $list[] = $reffer;
        }
        $list = list_sort_by($list, $order, $sortby = 'asc');
    }
    return $list;
}
 /**
  * 取系统菜单列表,用于显示在上级菜单的OPTION
  * @return ARRAY 包括有所有菜单信息的二级数组
  * author:panjie 3792535@qq.com
  */
 private function _fetchMenuList()
 {
     $menuModel = new MenuModel();
     $data = $menuModel->getMenuTree(null, null, 0, 2);
     return tree_to_list($data, 0, '_son');
 }
示例#14
0
function select_tree_menu($tree)
{
    $html = "";
    if (is_array($tree)) {
        $list = tree_to_list($tree);
        foreach ($list as $val) {
            $html = $html . "<option value='{$val['id']}'>" . str_pad("", $val['level'] * 3, "│") . "├─" . "{$val['name']}</option>";
        }
    }
    return $html;
}
示例#15
0
 function read()
 {
     $type = $_REQUEST['type'];
     $id = $_REQUEST['id'];
     switch ($type) {
         case "company":
             $model = M("Dept");
             $dept = tree_to_list(list_to_tree(M("Dept")->where('is_del=0')->select(), $id));
             $dept = rotate($dept);
             $dept = implode(",", $dept['id']) . ",{$id}";
         case "emp":
             $model = M("Dept");
             $dept = tree_to_list(list_to_tree(M("Dept")->where('is_del=0')->select(), $id));
             $dept = rotate($dept);
             $dept = implode(",", $dept['id']) . ",{$id}";
             $sql = D("UserView")->buildSql();
             $model = new Model();
             $where['dept_id'] = array('in', $dept);
             $where['is_del'] = array('eq', 0);
             $data = $model->table($sql . "a")->where($where)->select();
             break;
         case "rank":
             $sql = D("UserView")->buildSql();
             $model = new Model();
             $where['rank_id'] = array('eq', $id);
             $where['is_del'] = array('eq', 0);
             $data = $model->table($sql . "a")->where($where)->select();
             break;
         case "position":
             $sql = D("UserView")->buildSql();
             $model = new Model();
             $where['position_id'] = array('eq', $id);
             $where['is_del'] = array('eq', 0);
             $data = $model->table($sql . "a")->where($where)->select();
             break;
         case "personal":
             $model = D("UserTag");
             if ($id == "#") {
                 $data = $model->get_data_list("Contact");
                 $data = rotate($data);
                 $data = $data['row_id'];
                 $where['id'] = array('not in', implode(",", $data));
             } else {
                 $test = $model;
                 $data = $model->get_data_list("Contact", $id);
                 $data = rotate($data);
                 $data = $data['row_id'];
                 $where['id'] = array('in', implode(",", $data));
             }
             $model = M("Contact");
             $where['is_del'] = array('eq', 0);
             $data = $model->where($where)->field('id,name,position as position_name,email')->select();
             //echo $model->getLastSql();
             break;
         default:
     }
     $new = array();
     if (true) {
         // 读取成功
         $this->ajaxReturn($data, dump($test, false), 1);
     }
 }
示例#16
0
 public function _assign_mail_folder_list()
 {
     $model = D("Folder");
     $list = $model->get_list("mail/mail_list", 2);
     $system_folder = array(array("id" => 1, "name" => "收件箱"), array("id" => 2, "name" => "已发送"));
     $list = array_merge($system_folder, $list);
     $tree = list_to_tree($list);
     $this->assign('folder_list', dropdown_menu($tree));
     $temp = tree_to_list($tree);
     return $temp;
 }
 /**
  * 操作分类初始化
  * @param string $type
  * @author huajie <*****@*****.**>
  */
 public function operate($type = 'move')
 {
     //检查操作参数
     if (strcmp($type, 'move') == 0) {
         $operate = '移动';
     } elseif (strcmp($type, 'merge') == 0) {
         $operate = '合并';
     } else {
         $this->error('参数错误!');
     }
     $from = intval(I('get.from'));
     empty($from) && $this->error('参数错误!');
     //获取分类
     $map = array('status' => 1, 'id' => array('neq', $from));
     $list = M('Category')->where($map)->field('id,pid,title')->select();
     //移动分类时增加移至根分类
     if (strcmp($type, 'move') == 0) {
         //不允许移动至其子孙分类
         $list = tree_to_list(list_to_tree($list));
         $pid = M('Category')->getFieldById($from, 'pid');
         $pid && array_unshift($list, array('id' => 0, 'title' => '根分类'));
     }
     $this->assign('type', $type);
     $this->assign('operate', $operate);
     $this->assign('from', $from);
     $this->assign('list', $list);
     $this->meta_title = $operate . '分类';
     $this->display();
 }
示例#18
0
function tree_to_list($tree, $i = 0)
{
    $list = array();
    foreach ($tree as $key => $value) {
        $value['level'] = $i;
        if (is_array($value['_child'])) {
            $i++;
            $list = array_merge($list, tree_to_list($value['_child'], $i));
            $i--;
        }
        unset($value['_child']);
        $list[] = $value;
    }
    return $list;
}
示例#19
0
 public function mine()
 {
     $widget['date-range'] = true;
     $this->assign("widget", $widget);
     $this->assign('user_id', get_user_id());
     $this->assign("title", '日志查询');
     $auth = $this->config['auth'];
     $this->assign('auth', $auth);
     if ($_GET['id']) {
         $id = $_GET['id'];
         $this->assign("XIN", 0);
     } else {
         $id = get_user_id();
         $this->assign("XIN", 1);
     }
     if ($auth['admin']) {
         $rolein = false;
         $role = D('role_user')->where('user_id = ' . get_user_id())->field('role_id')->select();
         for ($i = 0; $i < count($role); $i++) {
             if ($role[$i]['role_id'] == 1 || $role[$i]['role_id'] == 12) {
                 $rolein = true;
                 continue;
             }
         }
         $node = D("Dept");
         $dept_id = get_dept_id();
         $dept_name = get_dept_name();
         $menu = array();
         $dept_menu = $node->field('id,pid,name')->where("is_del=0")->order('sort asc')->select();
         if ($rolein) {
             $dept_tree = list_to_tree($dept_menu);
         } else {
             $dept_tree = list_to_tree($dept_menu, $dept_id);
         }
         $count = count($dept_tree);
         //            dump(get_user_id());
         //            exit;
         if (empty($count)) {
             /*获取部门列表*/
             $html = '';
             $html = $html . "<option value='{$dept_id}'>{$dept_name}</option>";
             $this->assign('dept_list', $html);
             /*获取人员列表*/
             $where['dept_id'] = array('eq', $dept_id);
             $emp_list = D("User")->where($where)->getField('id,emp_name');
             //				$this->assign('emp_list',$emp_list);
         } else {
             /*获取部门列表*/
             $this->assign('dept_list', select_tree_menu($dept_tree));
             $dept_list = tree_to_list($dept_tree);
             $dept_list = rotate($dept_list);
             $dept_list = $dept_list['id'];
             /*获取人员列表*/
             $where['dept_id'] = array('in', $dept_list);
             $emp_list = D("User")->where($where)->getField('id,emp_name');
             //				$this->assign('emp_list',$emp_list);
         }
     }
     $map = $this->_search();
     $map['user_id'] = $id;
     if (method_exists($this, '_search_filter')) {
         $this->_search_filter($map);
     }
     $model = D("WorkLog");
     if (!empty($model)) {
         $this->_list($model, $map);
         //			$this -> _list($model,'');
     }
     $this->assign("uid", $id);
     $this->display();
 }
<?php 
$term = sp_get_term($_GET['id']);
$child_terms = sp_get_child_terms($term['parent']);
$pterm = sp_get_term($term['parent']);
$nav_label = $pterm['name'];
$lists = sp_sql_posts_paged_bycatid($_GET['id'], "order:post_modified DESC,listorder ASC;", 33, "{prev}{liststart}{list}{listend}{next}");
$kaoyan_img = sp_getslide('kaoyan_img');
$kyimg = $kaoyan_img[0];
$nav_label = isset($nav_label) ? $nav_label : $post_title;
$nid = sp_nav_id($nav_label);
$nav_cid = sp_nav_cid($nid);
if ($nav_cid == 1) {
    $navList = tree_to_list($navTree);
} else {
    $navT = sp_get_menu_tree($nav_cid);
    $navList = tree_to_list($navT);
}
$snav = getParents($navList, $nid);
$parent_sid = $snav[0]['id'];
$parent_slabel = $snav[0]['label'];
$parent_shref = $snav[0]['href'];
$child_snav = getChilds($navList, $parent_sid);
foreach ($child_snav as $key => $value) {
    if ($key % 2 == 0) {
        $ou[] = $value;
    } else {
        $ji[] = $value;
    }
}
$child_snav = array_merge($ou, $ji);
$child_snav_height = count($child_snav) * 35;
示例#21
0
文件: common.php 项目: uwitec/semoa
function tree_to_list($tree, $level = 0, $pk = 'id', $pid = 'pid', $child = '_child')
{
    $list = array();
    if (is_array($tree)) {
        foreach ($tree as $val) {
            $val['level'] = $level;
            $child = $val['_child'];
            if (isset($child)) {
                if (is_array($child)) {
                    unset($val['_child']);
                    $list[] = $val;
                    $list = array_merge($list, tree_to_list($child, $level + 1));
                }
            } else {
                $list[] = $val;
            }
        }
        return $list;
    }
}