* adjust for task #1045.

This commit is contained in:
wangyidong
2013-01-06 07:09:21 +00:00
parent 8c80183c28
commit 0c1b21dd4d
5 changed files with 57 additions and 5 deletions

View File

@@ -120,15 +120,18 @@ class group extends control
* @access public
* @return void
*/
public function managePriv($type = 'byGroup', $param = 0)
public function managePriv($type = 'byGroup', $param = 0, $menu = 'my')
{
if($type == 'byGroup') $groupID = $param;
$this->view->type = $type;
foreach($this->lang->resource as $moduleName => $action) $this->app->loadLang($moduleName);
foreach($this->lang->resource as $moduleName => $action)
{
if($this->group->checkMenuModule($menu, $moduleName)) $this->app->loadLang($moduleName);
}
if(!empty($_POST))
{
if($type == 'byGroup') $result = $this->group->updatePrivByGroup($groupID);
if($type == 'byGroup') $result = $this->group->updatePrivByGroup($groupID, $menu);
if($type == 'byModule') $result = $this->group->updatePrivByModule();
print(js::alert($result ? $this->lang->group->successSaved : $this->lang->group->errorNotSaved));
exit;
@@ -146,6 +149,8 @@ class group extends control
$this->view->group = $group;
$this->view->changelogs = $this->lang->changelog;
$this->view->groupPrivs = $groupPrivs;
$this->view->groupID = $groupID;
$this->view->menu = $menu;
}
elseif($type == 'byModule')
{

View File

@@ -35,6 +35,8 @@ $lang->group->priv = 'Priviledge';
$lang->group->option = 'Option';
$lang->group->inside = 'Group users';
$lang->group->outside = 'Other users';
$lang->group->other = 'Other module';
$lang->group->all = 'All priv';
$lang->group->copyOptions['copyPriv'] = 'Copy priviledge';
$lang->group->copyOptions['copyUser'] = 'Copy user';

View File

@@ -35,6 +35,8 @@ $lang->group->priv = '权限';
$lang->group->option = '选项';
$lang->group->inside = '组内用户';
$lang->group->outside = '组外用户';
$lang->group->other = '其他模块';
$lang->group->all = '所有权限';
$lang->group->copyOptions['copyPriv'] = '复制权限';
$lang->group->copyOptions['copyUser'] = '复制用户';

View File

@@ -185,10 +185,10 @@ class groupModel extends model
* @access public
* @return bool
*/
public function updatePrivByGroup($groupID)
public function updatePrivByGroup($groupID, $menu)
{
/* Delete old. */
$this->dao->delete()->from(TABLE_GROUPPRIV)->where('`group`')->eq($groupID)->exec();
$this->dao->delete()->from(TABLE_GROUPPRIV)->where('`group`')->eq($groupID)->andWhere('module')->in($this->getMenuModules($menu))->exec();
/* Insert new. */
foreach($this->post->actions as $moduleName => $moduleActions)
@@ -302,4 +302,37 @@ class groupModel extends model
}
}
}
/**
* Check menu have module
*
* @param string $menu
* @param string $moduleName
* @access public
* @return void
*/
public function checkMenuModule($menu, $moduleName)
{
if(empty($menu)) return true;
if($menu == 'other' and (isset($this->lang->menugroup->$moduleName) or isset($this->lang->menu->$moduleName))) return false;
if($menu != 'other' and !($moduleName == $menu or (isset($this->lang->menugroup->$moduleName) and $this->lang->menugroup->$moduleName == $menu))) return false;
return true;
}
/**
* Get modules in menu
*
* @param string $menu
* @access public
* @return void
*/
public function getMenuModules($menu)
{
$modules = array();
foreach($this->lang->resource as $moduleName => $action)
{
if($this->checkMenuModule($menu, $moduleName)) $modules[] = $moduleName;
}
return $modules;
}
}

View File

@@ -11,6 +11,15 @@
*/
?>
<form method='post' target='hiddenwin'>
<div id='featurebar'>
<?php foreach($lang->menu as $module => $title):?>
<span <?php echo $menu == $module ? "class='active'" : ""?>>
<?php echo html::a(inlink('managePriv', "type=byGroup&param=$groupID&menu=$module"), substr($title, 0, strpos($title, '|')))?>
</span>
<?php endforeach;?>
<span <?php echo $menu == 'other' ? "class='active'" : ""?>><?php echo html::a(inlink('managePriv', "type=byGroup&param=$groupID&menu=other"), $lang->group->other)?></span>
<span <?php echo empty($menu) ? "class='active'" : ""?>><?php echo html::a(inlink('managePriv', "type=byGroup&param=$groupID&menu="), $lang->group->all)?></span>
</div>
<table class='table-1 a-left'>
<caption class='caption-tl'>
<?php
@@ -23,6 +32,7 @@
<th><?php echo $lang->group->method;?></th>
</tr>
<?php foreach($lang->resource as $moduleName => $moduleActions):?>
<?php if(!$this->group->checkMenuModule($menu, $moduleName)) continue;?>
<tr class='f-14px <?php echo cycle('even, bg-yellow');?>'>
<th class='a-right'><?php echo $this->lang->$moduleName->common;?><?php echo html::selectAll($moduleName, 'checkbox')?></td>
<td id='<?php echo $moduleName;?>' class='pv-10px'>