/** * 获取用户模块 */ public function getUserModule() { $this->_utilUserSession = $this->getGlobal('util/session/UserSession', 'Util_UserSession'); $userClass = $this->_utilUserSession->getUserClass(); if (!$userClass instanceof Object) { return array(); } $userRole = $userClass->role; $moduleList = params('act/module'); $rbacEveryOne = config('RBAC_EVERYONE'); //所有用户 $rbacOnly = config('RBAC_ONLY'); //登陆用户 foreach ($moduleList as $key => &$val) { $val['url'] = url('index/index/left', array('module' => $val['module'])); if (empty($val['act'])) { $val['checked'] = false; continue; } if ($val['act'] == $rbacEveryOne || $val['act'] == $rbacOnly) { $val['checked'] = true; continue; } $val['act'] = explode(',', $val['act']); $intersect = array_intersect($userRole, $val['act']); if (count($intersect)) { $val['checked'] = true; } else { $val['checked'] = false; } } return $moduleList; }
public function edit($postArr) { if (empty($postArr['id'])) { return array('info' => '参数错误', 'status' => -1); } if (empty($postArr['title'])) { return array('info' => '标题不能为空', 'status' => -1); } if (empty($postArr['content'])) { return array('info' => '内容不能为空', 'status' => -1); } $editArr = array(); $this->_utilUserSession = $this->getGlobal('util/session/UserSession', 'Util_UserSession'); $userClass = $this->_utilUserSession->getUserClass(); $editArr['title'] = $postArr['title']; $editArr['content'] = $postArr['content']; $editArr['type'] = $postArr['type']; $editArr['jump_url'] = $postArr['jump_url'] ? $postArr['jump_url'] : '0'; $editArr['game_type'] = $postArr['game_type']; $editArr['is_top'] = $postArr['is_Top']; $editArr['user_id'] = $userClass->userId; $editArr['time'] = config('CURRENT_TIME'); if ($this->update($editArr, "id='{$postArr['id']}'")) { return array('info' => '编辑资讯成功', 'status' => 1, 'url' => url('index/news/index')); } else { return array('info' => '编辑资讯失败', 'status' => -2); } }