private function addPermissionRecordForGroup($groupID)
 {
     $permissionController = new PermissionController();
     $permissionSelectResult = $this->getPermissionModel()->select();
     //        dump($permissionSelectResult);dump($groupID);die;
     for ($i = 0; $i < count($permissionSelectResult); $i++) {
         $authorityData[AUTHORITY_ID_GROUP] = $groupID;
         $authorityData[AUTHORITY_ID_PERMISSION] = $permissionSelectResult[$i][PERMISSION_ID];
         $authorityData[AUTHORITY_ADDED_DATE] = $this->getCurrentDateTime();
         $authorityData[AUTHORITY_ADDED_BY] = $this->getCurrentUserID();
         $authorityData[AUTHORITY_ENABLED] = 1;
         $permissionController->addAuthority($authorityData);
     }
 }
示例#2
0
 public function addNewMenu()
 {
     $newMenuData = $_POST['new_menu'];
     //        dump($newMenuData);
     if ($newMenuData['name'] == null) {
         $this->error('菜单名不能为空.');
     }
     if ($newMenuData['url'] == null) {
         $this->error('菜单URL不能为空.');
     }
     if ($this->isMenuNameExist($newMenuData['name'])) {
         $this->error('该菜单名已经存在.');
     }
     if ($this->isMenuURLExist($newMenuData['url'], $newMenuData['id_father'])) {
         $this->error('该URL已经存在');
     }
     //        if($newMenuData['isvisible'] == null){
     //            $newMenuData['isvisible'] = false;
     //        }else{
     //            $newMenuData['isvisible'] = true;
     //        }
     if ($newMenuData['id_father'] == 0) {
         $newMenuData['level'] = 0;
     } else {
         $newMenuData['level'] = 1;
         if (!$this->isMenuVisible($newMenuData['id_father'])) {
             $newMenuData['isvisible'] = false;
         }
     }
     if ($newMenuData['type'] == 1) {
         $newMenuData['level'] = 0;
         $newMenuData['id_father'] = 0;
     } else {
         if ($newMenuData['type'] == 3) {
             $newMenuData['isvisible'] = false;
         }
     }
     $newMenuData[MENU_ADMIN_ADDED_DATE] = $this->getCurrentDateTime();
     $newMenuData[MENU_ADMIN_ADDED_BY] = $this->getCurrentUserID();
     //        dump($newMenuData);die;
     $newMenuInsertResult = $this->getMenuModel()->data($newMenuData)->add();
     if ($newMenuInsertResult) {
         $this->doWriteAdminOperationLog(CONTROLLER_NAME, ACTION_NAME, '添加新菜单:[' . $newMenuInsertResult[MENU_ADMIN_ID] . ']' . $newMenuData[MENU_ADMIN_NAME] . '(' . $newMenuData[MENU_ADMIN_URL] . ')成功');
         $newPermissionData[PERMISSION_ADDED_DATE] = $this->getCurrentDateTime();
         $newPermissionData[PERMISSION_ADDED_BY] = $this->getCurrentUserID();
         $newPermissionData[PERMISSION_TYPE] = 2;
         $newPermissionData[PERMISSION_NAME] = $newMenuInsertResult[MENU_ADMIN_NAME] . '的权限';
         $newPermissionData[PERMISSION_INTRODUCTION] = $newMenuInsertResult[MENU_ADMIN_NAME] . '的权限描述(自动生成)';
         $newPermissionData[PERMISSION_ENABLED] = 1;
         $newPermissionData[PERMISSION_ID_MENU] = $newMenuInsertResult[MENU_ADMIN_ID];
         $permissionController = new PermissionController();
         $permissionController->addNewPermission($newPermissionData);
         $this->success('添加新菜单:[' . $newMenuInsertResult['id'] . ']' . $newMenuData['name'] . '(' . $newMenuData['url'] . ')成功', U('Menu/index'), 3);
     } else {
         $this->error('添加失败, 请稍候重试.');
     }
 }