本文整理匯總了PHP中Admin\Model\AuthGroupModel類的典型用法代碼示例。如果您正苦於以下問題:PHP AuthGroupModel類的具體用法?PHP AuthGroupModel怎麽用?PHP AuthGroupModel使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了AuthGroupModel類的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: checkDynamic
/**
* 檢測是否是需要動態判斷的權限
* @return boolean|null
* 返回true則表示當前訪問有權限
* 返回false則表示當前訪問無權限
* 返回null,則會進入checkRule根據節點授權判斷權限
*
*/
protected function checkDynamic()
{
if (IS_ROOT) {
return true;
//管理員允許訪問任何頁麵
}
//模型權限業務檢查邏輯
//
//提供的工具方法:
//$AUTH_GROUP = D('AuthGroup');
// $AUTH_GROUP->checkModelId($mid); //檢查模型id列表是否全部存在
// AuthGroupModel::getModelOfGroup($gid);//獲取某個用戶組擁有權限的模型id
$model = new AuthGroupModel();
$model_ids = $model->getGroups(UID);
$id = I('id');
switch (strtolower(ACTION_NAME)) {
case 'edit':
//編輯
//編輯
case 'update':
//更新
if (in_array($id, $model_ids)) {
return true;
} else {
return false;
}
case 'setstatus':
//更改狀態
if (is_array($id) && array_intersect($id, (array) $model_ids) == $id) {
return true;
} elseif (in_array($id, $model_ids)) {
return true;
} else {
return false;
}
}
return null;
//不明,需checkRule
}
示例2: getMenu
/**
* 顯示左邊菜單,進行權限控製
* @author huajie <banhuajie@163.com>
*/
protected function getMenu()
{
//獲取站點id
$site_id = I('param.site_id', 0, 'intval');
//獲取動態分類
$site_auth = AuthGroupModel::getAuthSiteies(UID);
//獲取當前用戶所有的內容權限節點
$site_auth = $site_auth == null ? array() : $site_auth;
$site_list = C('SITE_LIST');
if (!IS_ROOT && !in_array($site_id, $site_auth)) {
$site_id = 0;
}
//沒有權限的站點則不顯示
$nodes = array();
foreach ($site_list as $key => $val) {
if (IS_ROOT || in_array($key, $site_auth)) {
$nodes[$key]['title'] = $val . '線路';
$nodes[$key]['url'] = U('Order/index', array('site_id' => $key));
if ($site_id && $site_id == $key) {
$nodes[$key]['current'] = 1;
} else {
$nodes[$key]['current'] = 0;
}
}
}
if (!IS_ROOT && empty($site_id)) {
if (count($nodes)) {
$i = 1;
foreach ($nodes as $key => $value) {
if ($i == 1) {
$site_id = $key;
$nodes[$key]['current'] = 1;
break;
}
$i++;
}
} else {
$this->redirect('Visa/index');
}
}
// echo '<pre>'; print_r($nodes); echo '</pre>';
// 擴展菜單
// $this->assign('_extra_menu', array('旅遊線路'=>$nodes));
$this->assign('nodes', $nodes);
$this->site_id = $site_id;
$this->assign('site_id', $site_id);
}
示例3: recycle
/**
* 回收站列表
* @author huajie <banhuajie@163.com>
*/
public function recycle()
{
//獲取左邊菜單
$this->getMenu();
$map['status'] = -1;
if (!IS_ROOT) {
$cate_auth = AuthGroupModel::getAuthCategories(UID);
if ($cate_auth) {
$map['category_id'] = array('IN', $cate_auth);
} else {
$map['category_id'] = -1;
}
}
$list = $this->lists(D('Document'), $map, 'update_time desc');
//處理列表數據
if (is_array($list)) {
foreach ($list as $k => &$v) {
$v['username'] = get_nickname($v['uid']);
}
}
$this->assign('list', $list);
$this->meta_title = '回收站';
$this->display();
}
示例4: group
/**
* 將用戶添加到用戶組的編輯頁麵
*
* @author 朱亞傑 <zhuyajie@topthink.net>
*/
public function group()
{
$uid = I('uid');
$auth_groups = D('AuthGroup')->getGroups();
$user_groups = AuthGroupModel::getUserGroup($uid);
$ids = array();
foreach ($user_groups as $value) {
$ids[] = $value['group_id'];
}
$nickname = D('Common/User')->getNickName($uid);
$this->assign('nickname', $nickname);
$this->assign('auth_groups', $auth_groups);
$this->assign('user_groups', implode(',', $ids));
$this->meta_title = '用戶組授權';
$this->display();
}
示例5: getMenu
/**
* 顯示左邊菜單,進行權限控製
* @author huajie <banhuajie@163.com>
*/
protected function getMenu()
{
//獲取動態分類
$cate_auth = AuthGroupModel::getAuthCategories(UID);
//獲取當前用戶所有的內容權限節點
$cate_auth = $cate_auth == null ? array() : $cate_auth;
$cate = M('Category')->where(array('status' => 1))->field('id,title,pid,allow_publish')->order('pid,sort')->select();
//沒有權限的分類則不顯示
if (!IS_ROOT) {
foreach ($cate as $key => $value) {
if (!in_array($value['id'], $cate_auth)) {
unset($cate[$key]);
}
}
}
$cate = list_to_tree($cate);
//生成分類樹
//獲取分類id
$cate_id = I('param.cate_id');
$this->cate_id = $cate_id;
//是否展開分類
$hide_cate = false;
if (ACTION_NAME != 'recycle' && ACTION_NAME != 'draftbox' && ACTION_NAME != 'mydocument') {
$hide_cate = true;
}
//生成每個分類的url
foreach ($cate as $key => &$value) {
$value['url'] = 'Article/index?cate_id=' . $value['id'];
if ($cate_id == $value['id'] && $hide_cate) {
$value['current'] = true;
} else {
$value['current'] = false;
}
if (!empty($value['_child'])) {
$is_child = false;
foreach ($value['_child'] as $ka => &$va) {
$va['url'] = 'Article/index?cate_id=' . $va['id'];
if (!empty($va['_child'])) {
foreach ($va['_child'] as $k => &$v) {
$v['url'] = 'Article/index?cate_id=' . $v['id'];
$v['pid'] = $va['id'];
$is_child = $v['id'] == $cate_id ? true : false;
}
}
//展開子分類的父分類
if ($va['id'] == $cate_id || $is_child) {
$is_child = false;
if ($hide_cate) {
$value['current'] = true;
$va['current'] = true;
} else {
$value['current'] = false;
$va['current'] = false;
}
} else {
$va['current'] = false;
}
}
}
}
$this->assign('nodes', $cate);
$this->assign('cate_id', $this->cate_id);
//獲取麵包屑信息
$nav = get_parent_category($cate_id);
$this->assign('rightNav', $nav);
//獲取回收站權限
$show_recycle = $this->checkRule('Admin/article/recycle');
$this->assign('show_recycle', IS_ROOT || $show_recycle);
//獲取草稿箱權限
$show_draftbox = C('OPEN_DRAFTBOX');
$this->assign('show_draftbox', IS_ROOT || $show_draftbox);
}
示例6: remove
/**
* 刪除狀態為-1的數據(包含擴展模型)
* @return true 刪除成功, false 刪除失敗
* @author huajie <banhuajie@163.com>
*/
public function remove()
{
//查詢假刪除的基礎數據
if (is_administrator()) {
$map = array('status' => -1);
} else {
$cate_ids = AuthGroupModel::getAuthCategories(UID);
$map = array('status' => -1, 'category_id' => array('IN', trim(implode(',', $cate_ids), ',')));
}
$base_list = $this->where($map)->field('id,model_id')->select();
//刪除擴展模型數據
$base_ids = array_column($base_list, 'id');
//孤兒數據
$orphan = get_stemma($base_ids, $this, 'id,model_id');
$all_list = array_merge($base_list, $orphan);
foreach ($all_list as $key => $value) {
$logic = $this->logic($value['model_id']);
$logic->delete($value['id']);
}
//刪除基礎數據
$ids = array_merge($base_ids, (array) array_column($orphan, 'id'));
if (!empty($ids)) {
$res = $this->where(array('id' => array('IN', trim(implode(',', $ids), ','))))->delete();
}
return $res;
}
示例7: group
/**
* 將用戶添加到用戶組的編輯頁麵
* @author kevin <kevin.liu@yunzhihui.com>
*/
public function group()
{
$uid = I('uid');
$auth_groups = D('AuthGroup')->getGroups();
$user_groups = AuthGroupModel::getUserGroup($uid);
$ids = array();
foreach ($user_groups as $value) {
$ids[] = $value['group_id'];
}
$userInfo = get_userinfo($uid);
$this->assign('userinfo', $userInfo);
$this->assign('auth_groups', $auth_groups);
$this->assign('user_groups', implode(',', $ids));
$this->meta_title = '用戶組授權';
$this->display();
}
示例8: recycle
/**
* 回收站列表
* @author huajie <banhuajie@163.com>
*/
public function recycle()
{
//獲取左邊菜單
$this->getMenu();
if (IS_ROOT) {
$map = array('status' => -1);
} else {
$cate_auth = AuthGroupModel::getAuthCategories(UID);
if ($cate_auth) {
$map = array('status' => -1, 'category_id' => array('IN', implode(',', $cate_auth)));
} else {
$map = array('status' => -1, 'category_id' => -1);
}
}
$list = M('Document')->where($map)->field('id,title,uid,category_id,type,update_time')->order('update_time desc')->select();
//處理列表數據
foreach ($list as $k => &$v) {
$v['username'] = get_nickname($v['uid']);
//$v['create_time'] = time_format($v['create_time']);
}
$this->assign('list', $list);
$this->meta_title = '回收站';
$this->display();
}
示例9: checkDynamic
protected function checkDynamic()
{
$cates = AuthGroupModel::getAuthCategories(UID);
switch (strtolower(ACTION_NAME)) {
case 'index':
//文檔列表
//文檔列表
case 'add':
// 新增
$cate_id = I('cate_id');
break;
case 'edit':
//編輯
//編輯
case 'update':
//更新
$doc_id = I('id');
$cate_id = M('Document')->where(array('id' => $doc_id))->getField('category_id');
break;
case 'setstatus':
//更改狀態
//更改狀態
case 'permit':
//回收站
$doc_id = (array) I('ids');
$cate_id = M('Document')->where(array('id' => array('in', $doc_id)))->getField('category_id', true);
$cate_id = array_unique($cate_id);
break;
}
if (!$cate_id) {
return null;
//不明
} elseif (!is_array($cate_id) && in_array($cate_id, $cates)) {
return true;
//有權限
} elseif (is_array($cate_id) && $cate_id == array_intersect($cate_id, $cates)) {
return true;
//有權限
} else {
return false;
//無權限
}
}