+ add the feature of grant priviledge by module.
This commit is contained in:
@@ -126,11 +126,14 @@ class group extends control
|
||||
public function managePriv($type = 'byGroup', $param = 0)
|
||||
{
|
||||
if($type == 'byGroup') $groupID = $param;
|
||||
$this->view->type = $type;
|
||||
foreach($this->lang->resource as $moduleName => $action) $this->app->loadLang($moduleName);
|
||||
|
||||
if(!empty($_POST))
|
||||
{
|
||||
$this->group->updatePriv($groupID);
|
||||
echo js::alert($this->lang->group->successSaved);
|
||||
if($type == 'byGroup') $result = $this->group->updatePrivByGroup($groupID);
|
||||
if($type == 'byModule') $result = $this->group->updatePrivByModule();
|
||||
print(js::alert($result ? $this->lang->group->successSaved : $this->lang->group->errorNotSaved));
|
||||
die(js::execute('parent.document.body.click();'));
|
||||
}
|
||||
|
||||
@@ -145,8 +148,23 @@ class group extends control
|
||||
$this->view->group = $group;
|
||||
$this->view->groupPrivs = $groupPrivs;
|
||||
|
||||
/* Load lang files of every module. */
|
||||
foreach($this->lang->resource as $moduleName => $action) $this->app->loadLang($moduleName);
|
||||
}
|
||||
elseif($type == 'byModule')
|
||||
{
|
||||
$this->view->header->title = $this->lang->company->common . $this->lang->colon . $this->lang->group->managePriv;
|
||||
$this->view->position[] = $this->lang->group->managePriv;
|
||||
|
||||
foreach($this->lang->resource as $module => $moduleActions)
|
||||
{
|
||||
$modules[$module] = $this->lang->$module->common;
|
||||
foreach($moduleActions as $action)
|
||||
{
|
||||
$actions[$module][$action] = $this->lang->$module->$action;
|
||||
}
|
||||
}
|
||||
$this->view->groups = $this->group->getPairs();
|
||||
$this->view->modules = $modules;
|
||||
$this->view->actions = $actions;
|
||||
}
|
||||
$this->display();
|
||||
}
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
.table-6 select{width:200px; height:200px}
|
||||
@@ -13,3 +13,17 @@ function checkall(checker)
|
||||
$(this).attr("checked", checker.checked)
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Control the actions select control for a module.
|
||||
*
|
||||
* @param string $module
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function setModuleActions(module)
|
||||
{
|
||||
$('#actionBox select').addClass('hidden'); // Hide all select first.
|
||||
$('#actionBox select').val(''); // Unselect all select.
|
||||
$('.' + module + 'Actions').removeClass('hidden'); // Show the action control for current module.
|
||||
}
|
||||
|
||||
+15
-12
@@ -9,18 +9,21 @@
|
||||
* @version $Id$
|
||||
* @link http://www.zentao.net
|
||||
*/
|
||||
$lang->group->common = 'Group';
|
||||
$lang->group->browse = 'Browse';
|
||||
$lang->group->create = 'Create';
|
||||
$lang->group->edit = 'Edit';
|
||||
$lang->group->copy = 'Copy';
|
||||
$lang->group->delete = 'Delete';
|
||||
$lang->group->managePriv = 'Privilege';
|
||||
$lang->group->manageMember = 'Members';
|
||||
$lang->group->linkMember = 'Add members';
|
||||
$lang->group->unlinkMember = 'Remove member';
|
||||
$lang->group->confirmDelete= 'Are you sure to delete this group?';
|
||||
$lang->group->successSaved = 'Success saved.';
|
||||
$lang->group->common = 'Group';
|
||||
$lang->group->browse = 'Browse';
|
||||
$lang->group->create = 'Create';
|
||||
$lang->group->edit = 'Edit';
|
||||
$lang->group->copy = 'Copy';
|
||||
$lang->group->delete = 'Delete';
|
||||
$lang->group->managePriv = 'Privilege';
|
||||
$lang->group->managePrivByGroup = 'Privilege';
|
||||
$lang->group->managePrivByModule = 'Manage privilege by module';
|
||||
$lang->group->manageMember = 'Members';
|
||||
$lang->group->linkMember = 'Add members';
|
||||
$lang->group->unlinkMember = 'Remove member';
|
||||
$lang->group->confirmDelete = 'Are you sure to delete this group?';
|
||||
$lang->group->successSaved = 'Success saved.';
|
||||
$lang->group->errorNotSaved = 'Not saved, please make sure you have selected some actions and groups.';
|
||||
|
||||
$lang->group->id = 'Id';
|
||||
$lang->group->name = 'Name';
|
||||
|
||||
+15
-12
@@ -9,18 +9,21 @@
|
||||
* @version $Id$
|
||||
* @link http://www.zentao.net
|
||||
*/
|
||||
$lang->group->common = '权限分组';
|
||||
$lang->group->browse = '浏览分组';
|
||||
$lang->group->create = '新增分组';
|
||||
$lang->group->edit = '编辑分组';
|
||||
$lang->group->copy = '复制分组';
|
||||
$lang->group->delete = '删除分组';
|
||||
$lang->group->managePriv = '权限维护';
|
||||
$lang->group->manageMember = '成员维护';
|
||||
$lang->group->linkMember = '关联用户';
|
||||
$lang->group->unlinkMember = '移除用户';
|
||||
$lang->group->confirmDelete= '您确定删除该用户分组吗?';
|
||||
$lang->group->successSaved = '成功保存';
|
||||
$lang->group->common = '权限分组';
|
||||
$lang->group->browse = '浏览分组';
|
||||
$lang->group->create = '新增分组';
|
||||
$lang->group->edit = '编辑分组';
|
||||
$lang->group->copy = '复制分组';
|
||||
$lang->group->delete = '删除分组';
|
||||
$lang->group->managePriv = '权限维护';
|
||||
$lang->group->managePrivByGroup = '权限维护';
|
||||
$lang->group->managePrivByModule = '按模块分配权限';
|
||||
$lang->group->manageMember = '成员维护';
|
||||
$lang->group->linkMember = '关联用户';
|
||||
$lang->group->unlinkMember = '移除用户';
|
||||
$lang->group->confirmDelete = '您确定删除该用户分组吗?';
|
||||
$lang->group->successSaved = '成功保存';
|
||||
$lang->group->errorNotSaved = '没有保存,请确认选择了权限数据。';
|
||||
|
||||
$lang->group->id = '编号';
|
||||
$lang->group->name = '分组名称';
|
||||
|
||||
+26
-3
@@ -183,15 +183,14 @@ class groupModel extends model
|
||||
*
|
||||
* @param int $groupID
|
||||
* @access public
|
||||
* @return void
|
||||
* @return bool
|
||||
*/
|
||||
public function updatePriv($groupID)
|
||||
public function updatePrivByGroup($groupID)
|
||||
{
|
||||
/* Delete old. */
|
||||
$this->dao->delete()->from(TABLE_GROUPPRIV)->where('`group`')->eq($groupID)->exec();
|
||||
|
||||
/* Insert new. */
|
||||
if($this->post->actions == false) return;
|
||||
foreach($this->post->actions as $moduleName => $moduleActions)
|
||||
{
|
||||
foreach($moduleActions as $actionName)
|
||||
@@ -202,6 +201,30 @@ class groupModel extends model
|
||||
$this->dao->insert(TABLE_GROUPPRIV)->data($data)->exec();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update privilege by module.
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function updatePrivByModule()
|
||||
{
|
||||
if($this->post->module == false or $this->post->actions == false or $this->post->groups == false) return false;
|
||||
|
||||
foreach($this->post->actions as $action)
|
||||
{
|
||||
foreach($this->post->groups as $group)
|
||||
{
|
||||
$data->group = $group;
|
||||
$data->module = $this->post->module;
|
||||
$data->method = $action;
|
||||
$this->dao->replace(TABLE_GROUPPRIV)->data($data)->exec();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -24,24 +24,27 @@
|
||||
<th><?php echo $lang->group->desc;?></th>
|
||||
<th class='w-p60'><?php echo $lang->group->users;?></th>
|
||||
<th class='{sorter:false}'><?php echo $lang->actions;?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach($groups as $group):?>
|
||||
<tr class='a-center'>
|
||||
<td class='strong'><?php echo $group->id;?></td>
|
||||
<td><?php echo $group->name;?></td>
|
||||
<td class='a-left'><?php echo $group->desc;?></td>
|
||||
<td class='a-left'><?php foreach($groupUsers[$group->id] as $user) echo "<span class='user'>$user</span>";?></td>
|
||||
<td>
|
||||
<?php common::printLink('group', 'managepriv', "type=byGroup¶m=$group->id", $lang->group->managePriv);?>
|
||||
<?php common::printLink('group', 'managemember', "groupID=$group->id", $lang->group->manageMember);?>
|
||||
<?php common::printLink('group', 'edit', "groupID=$group->id", $lang->edit);?>
|
||||
<?php common::printLink('group', 'copy', "groupID=$group->id", $lang->copy);?>
|
||||
<?php common::printLink('group', 'delete', "groupID=$group->id", $lang->delete, "hiddenwin");?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach;?>
|
||||
</tbody>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach($groups as $group):?>
|
||||
<tr class='a-center'>
|
||||
<td class='strong'><?php echo $group->id;?></td>
|
||||
<td><?php echo $group->name;?></td>
|
||||
<td class='a-left'><?php echo $group->desc;?></td>
|
||||
<td class='a-left'><?php foreach($groupUsers[$group->id] as $user) echo "<span class='user'>$user</span>";?></td>
|
||||
<td>
|
||||
<?php common::printLink('group', 'managepriv', "type=byGroup¶m=$group->id", $lang->group->managePrivByGroup);?>
|
||||
<?php common::printLink('group', 'managemember', "groupID=$group->id", $lang->group->manageMember);?>
|
||||
<?php common::printLink('group', 'edit', "groupID=$group->id", $lang->edit);?>
|
||||
<?php common::printLink('group', 'copy', "groupID=$group->id", $lang->copy);?>
|
||||
<?php common::printLink('group', 'delete', "groupID=$group->id", $lang->delete, "hiddenwin");?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach;?>
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr><td colspan='5' class='a-center'><?php echo html::linkButton($lang->group->managePrivByModule, inlink('managePriv', 'type=byModule'));?></td></tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
<?php include '../../common/view/footer.html.php';?>
|
||||
|
||||
@@ -10,42 +10,8 @@
|
||||
* @link http://www.zentao.net
|
||||
*/
|
||||
?>
|
||||
<?php include '../../common/view/header.html.php';?>
|
||||
<form method='post' target='hiddenwin'>
|
||||
<table class='table-1 a-left'>
|
||||
<caption class='caption-tl'><?php echo $group->name . $lang->colon . $lang->group->managePriv;?></caption>
|
||||
<tr class='colhead'>
|
||||
<th><?php echo $lang->group->module;?></th>
|
||||
<th><?php echo $lang->group->method;?></th>
|
||||
</tr>
|
||||
<?php foreach($lang->resource as $moduleName => $moduleActions):?>
|
||||
<tr class='f-14px <?php echo cycle('even, bg-yellow');?>'>
|
||||
<th class='a-right'><?php echo $this->lang->$moduleName->common;?> <input type='checkbox' onclick='check(this, "<?php echo $moduleName;?>")'></td>
|
||||
<td id='<?php echo $moduleName;?>' class='pv-10px'>
|
||||
<?php $i = 1;?>
|
||||
<?php foreach($moduleActions as $action => $actionLabel):?>
|
||||
<div class='w-p20 f-left'><input type='checkbox' name='actions[<?php echo $moduleName;?>][]' value='<?php echo $action;?>' <?php if(isset($groupPrivs[$moduleName][$action])) echo "checked";?> />
|
||||
<?php if(isset($lang->group->newPriv[$moduleName][$actionLabel])):?>
|
||||
<span class='red'><?php echo $lang->$moduleName->$actionLabel;?></span>
|
||||
<?php else:?>
|
||||
<?php echo $lang->$moduleName->$actionLabel;?>
|
||||
<?php endif;?>
|
||||
</div>
|
||||
<?php if(($i % 4) == 0) echo "<div class='c-both'></div>"; $i ++;?>
|
||||
<?php endforeach;?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach;?>
|
||||
<tr>
|
||||
<th class='rowhead'><?php echo $lang->group->checkall;?><input type='checkbox' onclick='checkall(this);'></th>
|
||||
<td class='a-center'>
|
||||
<?php
|
||||
echo html::submitButton($lang->save);
|
||||
echo html::linkButton($lang->goback, $this->createLink('group', 'browse'));
|
||||
echo html::hidden('foo'); // Just a hidden var, to make sure $_POST is not empty.
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
<?php include '../../common/view/footer.html.php';?>
|
||||
<?php
|
||||
include '../../common/view/header.html.php';
|
||||
if($type == 'byGroup') include 'privbygroup.html.php';
|
||||
if($type == 'byModule') include 'privbymodule.html.php';
|
||||
include '../../common/view/footer.html.php';
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
/**
|
||||
* The manage privilege by group view of group module of ZenTaoPMS.
|
||||
*
|
||||
* @copyright Copyright 2009-2010 QingDao Nature Easy Soft Network Technology Co,LTD (www.cnezsoft.com)
|
||||
* @license LGPL (http://www.gnu.org/licenses/lgpl.html)
|
||||
* @author Chunsheng Wang <chunsheng@cnezsoft.com>
|
||||
* @package group
|
||||
* @version $Id: managepriv.html.php 1517 2011-03-07 10:02:57Z wwccss $
|
||||
* @link http://www.zentao.net
|
||||
*/
|
||||
?>
|
||||
<form method='post' target='hiddenwin'>
|
||||
<table class='table-1 a-left'>
|
||||
<caption class='caption-tl'><?php echo $group->name . $lang->colon . $lang->group->managePriv;?></caption>
|
||||
<tr class='colhead'>
|
||||
<th><?php echo $lang->group->module;?></th>
|
||||
<th><?php echo $lang->group->method;?></th>
|
||||
</tr>
|
||||
<?php foreach($lang->resource as $moduleName => $moduleActions):?>
|
||||
<tr class='f-14px <?php echo cycle('even, bg-yellow');?>'>
|
||||
<th class='a-right'><?php echo $this->lang->$moduleName->common;?> <input type='checkbox' onclick='check(this, "<?php echo $moduleName;?>")'></td>
|
||||
<td id='<?php echo $moduleName;?>' class='pv-10px'>
|
||||
<?php $i = 1;?>
|
||||
<?php foreach($moduleActions as $action => $actionLabel):?>
|
||||
<div class='w-p20 f-left'><input type='checkbox' name='actions[<?php echo $moduleName;?>][]' value='<?php echo $action;?>' <?php if(isset($groupPrivs[$moduleName][$action])) echo "checked";?> />
|
||||
<?php if(isset($lang->group->newPriv[$moduleName][$actionLabel])):?>
|
||||
<span class='red'><?php echo $lang->$moduleName->$actionLabel;?></span>
|
||||
<?php else:?>
|
||||
<?php echo $lang->$moduleName->$actionLabel;?>
|
||||
<?php endif;?>
|
||||
</div>
|
||||
<?php if(($i % 4) == 0) echo "<div class='c-both'></div>"; $i ++;?>
|
||||
<?php endforeach;?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach;?>
|
||||
<tr>
|
||||
<th class='rowhead'><?php echo $lang->group->checkall;?><input type='checkbox' onclick='checkall(this);'></th>
|
||||
<td class='a-center'>
|
||||
<?php
|
||||
echo html::submitButton($lang->save);
|
||||
echo html::linkButton($lang->goback, $this->createLink('group', 'browse'));
|
||||
echo html::hidden('foo'); // Just a hidden var, to make sure $_POST is not empty.
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
/**
|
||||
* The manage privilege by group view of group module of ZenTaoPMS.
|
||||
*
|
||||
* @copyright Copyright 2009-2010 QingDao Nature Easy Soft Network Technology Co,LTD (www.cnezsoft.com)
|
||||
* @license LGPL (http://www.gnu.org/licenses/lgpl.html)
|
||||
* @author Chunsheng Wang <chunsheng@cnezsoft.com>
|
||||
* @package group
|
||||
* @version $Id: managepriv.html.php 1517 2011-03-07 10:02:57Z wwccss $
|
||||
* @link http://www.zentao.net
|
||||
*/
|
||||
?>
|
||||
<form method='post' target='hiddenwin'>
|
||||
<table class='table-6 a-center' align='center'>
|
||||
<caption class='caption-tl'><?php echo $lang->group->managePriv;?></caption>
|
||||
<tr class='colhead'>
|
||||
<th><?php echo $lang->group->module;?></th>
|
||||
<th><?php echo $lang->group->method;?></th>
|
||||
<th><?php echo $lang->group->common;?></th>
|
||||
</tr>
|
||||
<tr valign='top'>
|
||||
<td><?php echo html::select('module', $modules, '', " size='10' onclick='setModuleActions(this.value)'");?></td>
|
||||
<td id='actionBox'>
|
||||
<?php
|
||||
$class = '';
|
||||
foreach($actions as $module => $moduleActions)
|
||||
{
|
||||
echo html::select('actions[]', $moduleActions, '', "multiple='multiple' class='$class {$module}Actions'");
|
||||
$class = 'hidden';
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
<td><?php echo html::select('groups[]', $groups, '', "multiple='multiple'");?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class='a-center' colspan='3'>
|
||||
<?php
|
||||
echo html::submitButton($lang->save);
|
||||
echo html::linkButton($lang->goback, $this->createLink('group', 'browse'));
|
||||
echo html::hidden('foo'); // Just make $_POST not empty..
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
Reference in New Issue
Block a user