示例#1
0
 /**
  * Generate menu as a View object.
  *
  * @static
  * @access	public
  * @param	Menu  $oMenu
  * @return	View
  * @since	1.2.0-dev
  * @version	1.2.0-dev
  */
 public static function generate(Menu $oMenu)
 {
     $oLocales = $oMenu->getLocales();
     /* @var $oLocales \Model\Menu\Locales */
     $aItems = $oMenu->getItems();
     $aRoutes = $oMenu::tree($aItems->toArray());
     $oMenuTool = new MenuModel();
     $oMenuTool->findActiveRoute($aRoutes);
     $oMenuView = $oMenuTool->createNextLevel($aRoutes);
     return View::factory('menu/menu_container')->set('sMenuHeader', $oLocales->getTitle())->set('sMenuMachineName', $oMenu->getWorkingName())->bind('oContent', $oMenuView);
 }
示例#2
0
 /**
  * 删除模型
  */
 public function action()
 {
     $modelId = $this->isG('id', '请选择要删除的数据!');
     $model = \Model\ModelManage::findModel($modelId);
     if (empty($model)) {
         $this->error('模型不存在');
     }
     $this->db()->transaction();
     $deleteModelResult = \Model\ModelManage::deleteModel($modelId);
     if (empty($deleteModelResult)) {
         $this->db()->rollBack();
         $this->error('删除模型失败');
     }
     $deleteModelField = \Model\Field::deleteModelField($modelId);
     if (empty($deleteModelField)) {
         $this->db()->rollBack();
         $this->error('移除模型字段记录失败');
     }
     $deleteMenuResult = \Model\Menu::deleteMenu($model['lang_key']);
     if (empty($deleteMenuResult)) {
         $this->db()->rollBack();
         $this->error('删除菜单失败');
     }
     $this->db()->commit();
     $alterTableResult = \Model\ModelManage::alterTable(strtolower($model['model_name']));
     if (empty($alterTableResult)) {
         $log = new \Expand\Log();
         $failLog = "Alter Model Table Field: {$this->prefix}{$model['model_name']}" . date("Y-m-d H:i:s");
         $log->creatLog('modelError', $failLog);
         $this->error('删除数据库表失败');
     }
     $this->success('删除成功');
 }
示例#3
0
 /**
  * 分类列表
  */
 public function index()
 {
     $tree = \Model\Category::outPutListCate();
     $this->assign('tree', $tree);
     $this->assign('title', \Model\Menu::getTitleWithMenu());
     $this->layout();
 }
示例#4
0
 /**
  * 添加模型
  */
 public function action()
 {
     $this->db()->transaction();
     /**
      * 插入模型信息
      */
     $addModelresult = \Model\ModelManage::addModel();
     if ($addModelresult === false) {
         $this->db()->rollBack();
         $this->error('添加模型失败');
     }
     /**
      * 插入模型菜单
      */
     $addMenuResult = \Model\Menu::insertModelMenu($addModelresult['lang_key'], '9', GROUP . "-{$addModelresult['model_name']}-index");
     if ($addMenuResult === false) {
         $this->db()->rollBack();
         $this->error('插入菜单失败');
     }
     /**
      * 插入初始化的字段
      */
     \Model\ModelManage::setInitField($addModelresult['model_id']);
     $this->db()->commit();
     $initResult = \Model\ModelManage::initModelTable($addModelresult['model_name']);
     $this->success('添加模型成功', $this->url(GROUP . '-Model-index'));
 }
示例#5
0
 /**
  * 删除模型
  */
 public function action()
 {
     $modelId = $this->isG('id', $GLOBALS['_LANG']['COMMON']['DELETE_ID']);
     $model = \Model\Model::findModel($modelId);
     if (empty($model)) {
         $this->error($GLOBALS['_LANG']['MODEL']['NOT_EXIST_MODEL']);
     }
     $this->db()->transaction();
     $deleteModelResult = \Model\Model::deleteModel($modelId);
     if (empty($deleteModelResult)) {
         $this->db()->rollBack();
         $this->error($GLOBALS['_LANG']['COMMON']['DELETE_ERROR']);
     }
     $deleteModelField = \Model\Field::deleteModelField($modelId);
     if (empty($deleteModelField)) {
         $this->db()->rollBack();
         $this->error($GLOBALS['_LANG']['MODEL']['DELETE_MODEL_FIELD_FAIL']);
     }
     $deleteMenuResult = \Model\Menu::deleteMenu(strtoupper($model['model_name']) . "_LIST");
     if (empty($deleteMenuResult)) {
         $this->db()->rollBack();
         $this->error($GLOBALS['_LANG']['MENU']['DELETE_MENU_FAIL']);
     }
     $this->db()->commit();
     $alterTableResult = \Model\Model::alterTable(strtolower($model['model_name']));
     if (empty($alterTableResult)) {
         $log = new \Expand\Log();
         $failLog = "Alter Model Table Field: {$this->prefix}{$model['model_name']}" . date("Y-m-d H:i:s");
         $log->creatLog('modelError', $failLog);
         $this->error($GLOBALS['_LANG']['MODEL']['ALTER_TABLE_ERROR']);
     }
     $this->success($GLOBALS['_LANG']['COMMON']['DELETE_SUCCESS']);
 }
示例#6
0
 public function index()
 {
     $condition = "";
     $param = array();
     $search = $this->g('search');
     if (!empty($search)) {
         $condition = " user_account LIKE :user_account OR user_mail LIKE :user_mail OR user_name LIKE :user_name ";
         $param['user_account'] = "%{$search}%";
         $param['user_mail'] = "%{$search}%";
         $param['user_name'] = "%{$search}%";
     }
     $page = new \Expand\Team\Page();
     $total = count($this->db('user')->where($condition)->select($param));
     $count = $page->total($total);
     $page->handle();
     $list = $this->db('user')->where($condition)->order("user_id desc")->limit("{$page->firstRow}, {$page->listRows}")->select($param);
     $show = $page->show();
     foreach (\Model\Content::listContent('department') as $key => $value) {
         $findDepartment[$value['department_id']] = $value['department_name'];
     }
     $this->assign('findDepartment', $findDepartment);
     $this->assign('page', $show);
     $this->assign('list', $list);
     $this->assign('title', \Model\Menu::getTitleWithMenu());
     $this->layout();
 }
示例#7
0
 /**
  * 添加新菜单
  */
 public function menuAction()
 {
     $result = \Model\Menu::addMenu();
     if ($result['status'] == false) {
         $this->error($result['mes']);
     }
     $this->success($GLOBALS['_LANG']['MENU']['ADD_MENU_SUCCESS'], $this->url('Team-Index-menuList'));
 }
示例#8
0
 /**
  * 更新系统
  */
 public function upgrade()
 {
     \Model\Option::getUpdate();
     $version = \Model\Option::findOption('version')['value'];
     $content = \Model\Content::findContent('update_list', $version, 'update_list_pre_version');
     $this->assign($content);
     $this->assign('title', \Model\Menu::getTitleWithMenu());
     $this->layout();
 }
 /**
  * 设置菜单
  */
 public function setMenu()
 {
     $id = $this->isG('id', '请选择用户组');
     $group = \Model\Content::findContent('user_group', $id, 'user_group_id');
     if (empty($group)) {
         $this->error('用户组不存在');
     }
     $this->assign($group);
     $this->assign('menu', \Model\Menu::menu());
     $this->assign('title', "设置'{$group['user_group_name']}'用户组菜单");
     $this->layout();
 }
示例#10
0
 /**
  * 我的报表
  */
 public function my()
 {
     $page = new \Expand\Team\Page();
     $total = count(\Model\Content::listContent('report', array('user_id' => $_SESSION['team']['user_id']), 'user_id = :user_id'));
     $count = $page->total($total);
     $page->handle();
     $list = \Model\Content::listContent('report', array('user_id' => $_SESSION['team']['user_id']), 'user_id = :user_id', 'report_id DESC', "{$page->firstRow}, {$page->listRows}");
     $show = $page->show();
     $this->assign('page', $show);
     $this->assign('list', $list);
     $this->assign('title', \Model\Menu::getTitleWithMenu());
     $this->layout('Report_index');
 }
示例#11
0
 private function insertUpdateProcessing(EntityManager $em, $data, $id = null)
 {
     $update = !is_null($id);
     try {
         $em->beginTransaction();
         //Create or retrive entity
         if ($update) {
             $menu = $em->find('Model\\Menu', $id);
         } else {
             $menu = new Menu();
         }
         //If update mode delete all items on db
         if ($update) {
             foreach ($menu->getChildren() as $child) {
                 $em->remove($child);
             }
         }
         $menu->setName($data['menu_name']);
         $menu->setDescription($data['menu_description']);
         if ($update) {
             $em->merge($menu);
         } else {
             $em->persist($menu);
         }
         $em->flush();
         $items = $this->processMenu($data, $menu->getId(), array());
         foreach ($items as $item) {
             $menu->addMenuItem($item);
         }
         $em->merge($menu);
         $em->flush();
         $em->commit();
     } catch (\Exception $e) {
         $em->rollback();
         throw $e;
     }
     return $menu->getId();
 }
示例#12
0
 public function inMenu()
 {
     $inMenu = array();
     if ($this->id) {
         $menuSite = \Model\Menu::where('element_id', $this->id)->where('module', 'site')->get();
         foreach ($menuSite as $m) {
             $node = $m->rootNode();
             if (!empty($node)) {
                 $inMenu[$node] = true;
             }
         }
     }
     $menu = \Model\Menu::where('parent', 0)->get();
     $return = array();
     foreach ($menu as $m) {
         $return[] = array('menu' => $m, 'checked' => isset($inMenu[$m->id]));
     }
     return $return;
 }
示例#13
0
 /**
  * 添加/编辑菜单
  */
 public function menuAction()
 {
     $menuId = $this->g('id');
     if (empty($menuId)) {
         $this->assign('title', $GLOBALS['_LANG']['COMMON']['ADD']);
         $this->routeMethod('POST');
     } else {
         if (!($content = \Model\Menu::findMenu($menuId))) {
             $this->error($GLOBALS['_LANG']['MENU']['NOT_EXITS_MENU']);
         }
         $this->assign($content);
         $this->assign('title', $GLOBALS['_LANG']['COMMON']['EDIT']);
         $this->routeMethod('PUT');
     }
     $this->assign('topMenu', \Model\Menu::topMenu());
     $this->assign('menu_id', $menuId);
     $this->assign('url', $this->url('Team-Index-menuAction'));
     $this->layout();
 }
示例#14
0
 /**
  * 添加/编辑菜单
  */
 public function menuAction()
 {
     $menuId = $this->g('id');
     if (empty($menuId)) {
         $this->assign('title', '添加菜单');
         $this->routeMethod('POST');
     } else {
         if (!($content = \Model\Menu::findMenu($menuId))) {
             $this->error('不存在的菜单');
         }
         $this->assign($content);
         $this->assign('title', '编辑菜单');
         $this->routeMethod('PUT');
     }
     $this->assign('topMenu', \Model\Menu::topMenu());
     $this->assign('menu_id', $menuId);
     $this->assign('url', $this->url(GROUP . '-Index-menuAction'));
     $this->layout();
 }
示例#15
0
 protected function _record($model, $action)
 {
     parent::_record($model, $action);
     $module = $this->modelName;
     if (Input::get('inmenu') && is_array(Input::get('menu'))) {
         $menuSite = \Model\Menu::where('element_id', $this->result['model']['id'])->where('module', $module)->get();
         $inMenu = array();
         $isMenu = array();
         foreach ($menuSite as $m) {
             $inMenu[$m->id] = $m->rootNode();
             if (in_array($inMenu[$m->id], Input::get('menu'))) {
                 $isMenu[] = $inMenu[$m->id];
                 $menu = $m;
                 $menu->module = $module;
                 $menu->name = $this->result['model']['name'];
                 $menu->path = $this->result['model']['path'];
                 $model->menu()->save($menu);
             } else {
                 $m->forceDelete();
             }
         }
         $newMenu = array_diff(Input::get('menu'), $isMenu);
         foreach ($newMenu as $mn) {
             $menu = new \Model\Menu();
             $menu->module = $module;
             $menu->name = $this->result['model']['name'];
             $menu->path = $this->result['model']['path'];
             $menu->parent = $mn;
             if ($this->result['model']['parent']) {
                 $parent = \Model\Menu::where('element_id', $this->result['model']['parent'])->where('module', $module)->get();
                 foreach ($parent as $m) {
                     $node = $m->rootNode();
                     if ($node == $mn) {
                         $menu->parent = $m->id;
                     }
                 }
             }
             $model->menu()->save($menu);
         }
     }
     return $this->result();
 }
示例#16
0
 /**
  * 添加模型
  */
 public function action($jump = FALSE, $commit = FALSE)
 {
     parent::action($jump, $commit);
     $modelId = $this->db()->getLastInsert;
     $modelName = $this->p('name');
     /**
      * 插入模型菜单
      */
     $addMenuResult = \Model\Menu::insertMenu(['menu_name' => $this->p('title'), 'menu_pid' => '9', 'menu_url' => GROUP . "-" . ucfirst($modelName) . "-index"]);
     if ($addMenuResult === false) {
         $this->db()->rollBack();
         $this->error('插入菜单失败');
     }
     /**
      * 插入初始化的字段
      */
     \Model\ModelManage::setInitField($modelId);
     $this->db()->commit();
     $initResult = \Model\ModelManage::initModelTable(strtolower($modelName));
     $this->success('添加模型成功', $this->url(GROUP . '-Model-index'));
 }
示例#17
0
 /**
  * 添加模型
  */
 public function action()
 {
     $this->db()->transaction();
     /**
      * 插入模型信息
      */
     $addModelresult = \Model\Model::addModel();
     if ($addModelresult['status'] == false) {
         $this->db()->rollBack();
         $this->error($addModelresult['mes']);
     }
     /**
      * 插入模型菜单
      */
     $addMenuResult = \Model\Menu::insertModelMenu($addModelresult['mes']['lang_key'], '9', "Team-{$addModelresult['mes']['model_name']}-index");
     if ($addMenuResult == false) {
         $this->db()->rollBack();
         $this->error($GLOBALS['_LANG']['MENU']['ADD_MENU_FAIL']);
     }
     /**
      * 插入初始化的字段
      */
     $setFieldResult = \Model\Model::setInitField($addModelresult['mes']['model_id']);
     if ($setFieldResult['status'] == false) {
         $this->db()->rollBack();
         $this->error($setFieldResult['mes']);
     }
     $this->db()->commit();
     $initResult = \Model\Model::initModelTable($addModelresult['mes']['model_name']);
     if ($setFieldResult['status'] == false) {
         $log = new \Expand\Log();
         $failLog = "Create Model Table Field: {$setFieldResult['mes']}" . date("Y-m-d H:i:s");
         $log->creatLog('modelError', $failLog);
         $this->error($GLOBALS['_LANG']['MODEL']['CREATE_TABLE_ERROR']);
     }
     $this->success($GLOBALS['_LANG']['MODEL']['ADD_MODEL_SUCCESS'], $this->url('Team-Model-index'));
 }
示例#18
0
 /**
  * 模型列表
  */
 public function index()
 {
     $this->assign('list', \Model\ModelManage::modelList());
     $this->assign('title', \Model\Menu::getTitleWithMenu());
     $this->layout();
 }
示例#19
0
 public function before()
 {
     $this->assign('menu', \Model\Menu::menu($_SESSION['admin']['user_group_id']));
 }
示例#20
0
 public function action()
 {
     $this->assign('topMenu', json_encode(\Model\Menu::topMenu()));
     parent::action();
 }
示例#21
0
 /**
  * 添加新菜单
  */
 public function menuAction()
 {
     $result = \Model\Menu::addMenu();
     $this->success('添加菜单成功', $this->url(GROUP . '-Index-menuList'));
 }
<?php

$this->layout('main');
use Model\Menu;
$datas = Menu::tableTree($datas);
$this->start('body');
$this->extend('inc/header');
$par = ['s' => $_GET['s']];
?>

<div class="container">
     <h1>菜单</h1>
     
     <?php 
if ($list == 1) {
    ?>
     <table class="table">
      <caption>管理菜单(<?php 
    echo $count;
    ?>
). 
      	<span class='pull-right'>
      		<a href="<?php 
    echo url('menu/admin/view');
    ?>
" class="button">
	          添加
	        </a>
	         
	      </span>
	  </caption>
示例#23
0
 /**
  * 待我审核/指派的任务
  */
 public function check()
 {
     $condition = "t.task_delete = 0 AND tc.check_user_id = :check_user_id ";
     $param = array('check_user_id' => $_SESSION['team']['user_id']);
     $type = $this->g('type');
     if ($type >= '0') {
         $condition .= " AND t.task_status = :task_status";
         $param['task_status'] = $type;
         $order = "t.task_priority ASC, t.task_status ASC, t.task_id DESC";
     }
     //搜索
     if (!empty($_GET['search'])) {
         $condition .= " AND t.task_title LIKE :task_title";
         $param['task_title'] = '%' . $this->g('search') . '%';
     }
     //设置系统消息已读
     switch ($type) {
         case '0':
             \Model\Notice::readNotice('2');
             break;
         case '2':
             \Model\Notice::readNotice('3');
             break;
     }
     //待指派的任务执行人ID为空且是当前用户部门的
     if (!empty($_GET['user_type'])) {
         $condition .= " AND t.task_user_id = '' AND t.task_department_id = :task_department_id ";
         $param['task_department_id'] = $_SESSION['team']['user_department_id'];
         \Model\Notice::readNotice('5');
     }
     $page = new \Expand\Team\Page();
     $total = count($this->db('task AS t')->field("t.*")->join("{$this->prefix}task_check AS tc ON tc.task_id = t.task_id")->where($condition)->order($order)->group('t.task_id')->select($param));
     $count = $page->total($total);
     $page->handle();
     $list = $this->db('task AS t')->field("t.*")->join("{$this->prefix}task_check AS tc ON tc.task_id = t.task_id")->where($condition)->order($order)->group('t.task_id')->limit("{$page->firstRow}, {$page->listRows}")->select($param);
     $show = $page->show();
     $this->assign('page', $show);
     $this->assign('list', $list);
     $this->assign('title', \Model\Menu::getTitleWithMenu());
     $this->layout('Task_index');
 }