* finish task #1059.

This commit is contained in:
wangyidong
2013-01-07 08:39:27 +00:00
parent 34cc956878
commit 2dd1aa2f2d
7 changed files with 126 additions and 69 deletions

View File

@@ -120,7 +120,7 @@ class group extends control
* @access public
* @return void
*/
public function managePriv($type = 'byGroup', $param = 0, $menu = 'my')
public function managePriv($type = 'byGroup', $param = 0, $menu = 'my', $version = '')
{
if($type == 'byGroup') $groupID = $param;
$this->view->type = $type;
@@ -131,7 +131,7 @@ class group extends control
if(!empty($_POST))
{
if($type == 'byGroup') $result = $this->group->updatePrivByGroup($groupID, $menu);
if($type == 'byGroup') $result = $this->group->updatePrivByGroup($groupID, $menu, $version);
if($type == 'byModule') $result = $this->group->updatePrivByModule();
print(js::alert($result ? $this->lang->group->successSaved : $this->lang->group->errorNotSaved));
exit;
@@ -146,11 +146,20 @@ class group extends control
$this->view->header->title = $this->lang->company->common . $this->lang->colon . $group->name . $this->lang->colon . $this->lang->group->managePriv;
$this->view->position[] = $group->name . $this->lang->colon . $this->lang->group->managePriv;
/* Join changelog when be equal or greater than this version.*/
$realVersion = str_replace('_', '.', $version);
$changelog = array();
foreach($this->lang->changelog as $currentVersion => $currentChangeLog)
{
if(version_compare($currentVersion, $realVersion, '>=')) $changelog[] = join($currentChangeLog, ',');
}
$this->view->group = $group;
$this->view->changelogs = $this->lang->changelog;
$this->view->changelogs = ',' . join($changelog, ',') . ',';
$this->view->groupPrivs = $groupPrivs;
$this->view->groupID = $groupID;
$this->view->menu = $menu;
$this->view->version = $version;
}
elseif($type == 'byModule')
{

View File

@@ -1,2 +1,2 @@
.table-6 select{width:200px; height:200px}
#version {border:2px solid red; margin-left:10px;}
#version {margin-left:10px;}

View File

@@ -1,11 +1,6 @@
function showPriv(value)
{
$('.priv').removeClass('red');
privs = newPriv[value];
for(var item in privs)
{
$('#' + privs[item]).addClass('red');
}
location.href = createLink('group', 'managePriv', "type=byGroup&param="+ groupID + "&menu=" + menu + "&version=" + value);
}
/* Override the setHelpLink(). */
@@ -25,8 +20,11 @@ function setModuleActions(module)
$('.' + module + 'Actions').removeClass('hidden'); // Show the action control for current module.
}
$(function()
function setNoChecked()
{
showPriv(version);
var noCheckValue = '';
$(':checkbox').each(function(){
if(!$(this).attr('checked') && $(this).next('span').attr('id') != undefined) noCheckValue = noCheckValue + ',' + $(this).next('span').attr('id');
})
$('#noChecked').val(noCheckValue);
}
);

View File

@@ -41,23 +41,24 @@ $lang->group->all = 'All priv';
$lang->group->copyOptions['copyPriv'] = 'Copy priviledge';
$lang->group->copyOptions['copyUser'] = 'Copy user';
$lang->group->versions[''] = 'Show methods added in every release';
$lang->group->versions['3.3'] = '3.3';
$lang->group->versions['3.2.1'] = '3.2.1';
$lang->group->versions['3.2'] = '3.2';
$lang->group->versions['3.1'] = '3.1';
$lang->group->versions['3.0.beta2'] = '3.0.beta2';
$lang->group->versions['3.0.beta1'] = '3.0.beta1';
$lang->group->versions['2.4'] = '2.4';
$lang->group->versions['2.3'] = '2.3';
$lang->group->versions['2.2'] = '2.2';
$lang->group->versions['2.1'] = '2.1';
$lang->group->versions['2.0'] = '2.0';
$lang->group->versions['1.5'] = '1.5';
$lang->group->versions['1.4'] = '1.4';
$lang->group->versions['1.3'] = '1.3';
$lang->group->versions['1.2'] = '1.2';
$lang->group->versions['1.1'] = '1.1';
$lang->group->versions['1.0.1'] = '1.0.1';
$lang->group->versions[''] = 'Since version of power';
$lang->group->versions['4_0_beta2'] = 'Zentao 4.0.beta2';
$lang->group->versions['3_3'] = 'Zentao 3.3';
$lang->group->versions['3_2_1'] = 'Zentao 3.2.1';
$lang->group->versions['3_2'] = 'Zentao 3.2';
$lang->group->versions['3_1'] = 'Zentao 3.1';
$lang->group->versions['3_0_beta2'] = 'Zentao 3.0.beta2';
$lang->group->versions['3_0_beta1'] = 'Zentao 3.0.beta1';
$lang->group->versions['2_4'] = 'Zentao 2.4';
$lang->group->versions['2_3'] = 'Zentao 2.3';
$lang->group->versions['2_2'] = 'Zentao 2.2';
$lang->group->versions['2_1'] = 'Zentao 2.1';
$lang->group->versions['2_0'] = 'Zentao 2.0';
$lang->group->versions['1_5'] = 'Zentao 1.5';
$lang->group->versions['1_4'] = 'Zentao 1.4';
$lang->group->versions['1_3'] = 'Zentao 1.3';
$lang->group->versions['1_2'] = 'Zentao 1.2';
$lang->group->versions['1_1'] = 'Zentao 1.1';
$lang->group->versions['1_0_1'] = 'Zentao 1.0.1';
include (dirname(__FILE__) . '/resource.php');

View File

@@ -41,23 +41,24 @@ $lang->group->all = '所有权限';
$lang->group->copyOptions['copyPriv'] = '复制权限';
$lang->group->copyOptions['copyUser'] = '复制用户';
$lang->group->versions[''] = '显示各版本新增权限';
$lang->group->versions['3.3'] = '禅道3.3';
$lang->group->versions['3.2.1'] = '禅道3.2.1';
$lang->group->versions['3.2'] = '禅道3.2';
$lang->group->versions['3.1'] = '禅道3.1';
$lang->group->versions['3.0.beta2'] = '禅道3.0.beta2';
$lang->group->versions['3.0.beta1'] = '禅道3.0.beta1';
$lang->group->versions['2.4'] = '禅道2.4';
$lang->group->versions['2.3'] = '禅道2.3';
$lang->group->versions['2.2'] = '禅道2.2';
$lang->group->versions['2.1'] = '禅道2.1';
$lang->group->versions['2.0'] = '禅道2.0';
$lang->group->versions['1.5'] = '禅道1.5';
$lang->group->versions['1.4'] = '禅道1.4';
$lang->group->versions['1.3'] = '禅道1.3';
$lang->group->versions['1.2'] = '禅道1.2';
$lang->group->versions['1.1'] = '禅道1.1';
$lang->group->versions['1.0.1'] = '禅道1.0.1';
$lang->group->versions[''] = '版本至今的权限';
$lang->group->versions['4_0_beta2'] = '禅道4.0.beta2';
$lang->group->versions['3_3'] = '禅道3.3';
$lang->group->versions['3_2_1'] = '禅道3.2.1';
$lang->group->versions['3_2'] = '禅道3.2';
$lang->group->versions['3_1'] = '禅道3.1';
$lang->group->versions['3_0_beta2'] = '禅道3.0.beta2';
$lang->group->versions['3_0_beta1'] = '禅道3.0.beta1';
$lang->group->versions['2_4'] = '禅道2.4';
$lang->group->versions['2_3'] = '禅道2.3';
$lang->group->versions['2_2'] = '禅道2.2';
$lang->group->versions['2_1'] = '禅道2.1';
$lang->group->versions['2_0'] = '禅道2.0';
$lang->group->versions['1_5'] = '禅道1.5';
$lang->group->versions['1_4'] = '禅道1.4';
$lang->group->versions['1_3'] = '禅道1.3';
$lang->group->versions['1_2'] = '禅道1.2';
$lang->group->versions['1_1'] = '禅道1.1';
$lang->group->versions['1_0_1'] = '禅道1.0.1';
include (dirname(__FILE__) . '/resource.php');

View File

@@ -185,20 +185,55 @@ class groupModel extends model
* @access public
* @return bool
*/
public function updatePrivByGroup($groupID, $menu)
public function updatePrivByGroup($groupID, $menu, $version)
{
/* Set priv when have version. */
if($version)
{
$noCheckeds = trim($this->post->noChecked, ',');
if($noCheckeds)
{
$noCheckeds = explode(',', $noCheckeds);
foreach($noCheckeds as $noChecked)
{
/* Delete no checked priv*/
list($module, $method) = explode('-', $noChecked);
$this->dao->delete()->from(TABLE_GROUPPRIV)->where('`group`')->eq($groupID)->andWhere('module')->eq($module)->andWhere('method')->eq($method)->exec();
}
}
/* Replace new. */
if($this->post->actions)
{
foreach($this->post->actions as $moduleName => $moduleActions)
{
foreach($moduleActions as $actionName)
{
$data->group = $groupID;
$data->module = $moduleName;
$data->method = $actionName;
$this->dao->replace(TABLE_GROUPPRIV)->data($data)->exec();
}
}
}
return true;
}
/* Delete old. */
$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)
if($this->post->actions)
{
foreach($moduleActions as $actionName)
foreach($this->post->actions as $moduleName => $moduleActions)
{
$data->group = $groupID;
$data->module = $moduleName;
$data->method = $actionName;
$this->dao->insert(TABLE_GROUPPRIV)->data($data)->exec();
foreach($moduleActions as $actionName)
{
$data->group = $groupID;
$data->module = $moduleName;
$data->method = $actionName;
$this->dao->insert(TABLE_GROUPPRIV)->data($data)->exec();
}
}
}
return true;

View File

@@ -14,33 +14,45 @@
<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, '|')))?>
<?php echo html::a(inlink('managePriv', "type=byGroup&param=$groupID&menu=$module&version=$version"), 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>
<span <?php echo $menu == 'other' ? "class='active'" : ""?>><?php echo html::a(inlink('managePriv', "type=byGroup&param=$groupID&menu=other&version=$version"), $lang->group->other)?></span>
<span <?php echo empty($menu) ? "class='active'" : ""?>><?php echo html::a(inlink('managePriv', "type=byGroup&param=$groupID&menu=&version=$version"), $lang->group->all)?></span>
<span><?php echo html::select('version', $this->lang->group->versions, $version, "onchange=showPriv(this.value)");?></span>
</div>
<table class='table-1 a-left'>
<caption class='caption-tl'>
<?php
echo $group->name . $lang->colon . $lang->group->managePriv;
echo html::select('version', $this->lang->group->versions, '', "onchange=showPriv(this.value)");
?>
</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):?>
<?php if(!$this->group->checkMenuModule($menu, $moduleName)) continue;?>
<?php
/* Check method in select version. */
if($version)
{
$hasMethod = false;
foreach($moduleActions as $action => $actionLabel)
{
if(strpos($changelogs, ",$moduleName-$actionLabel,") !== false)
{
$hasMethod = true;
break;
}
}
if(!$hasMethod) 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'>
<?php $i = 1;?>
<?php foreach($moduleActions as $action => $actionLabel):?>
<?php if(!empty($version) and strpos($changelogs, ",$moduleName-$actionLabel,") === false) continue;?>
<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";?> />
<span class='priv' id=<?php echo $moduleName . '-' . $actionLabel;?>><?php echo $lang->$moduleName->$actionLabel;?></span>
<span class='priv' id="<?php echo $moduleName . '-' . $actionLabel;?>"><?php echo $lang->$moduleName->$actionLabel;?></span>
</div>
<?php if(($i % 4) == 0) echo "<div class='c-both'></div>"; $i ++;?>
<?php endforeach;?>
@@ -51,15 +63,16 @@
<th class='rowhead'><?php echo $lang->selectAll . html::selectAll('', 'checkbox')?></th>
<td class='a-center'>
<?php
echo html::submitButton($lang->save);
echo html::submitButton($lang->save, "onclick='setNoChecked()'");
echo html::linkButton($lang->goback, $this->createLink('group', 'browse'));
echo html::hidden('foo'); // Just a hidden var, to make sure $_POST is not empty.
echo html::hidden('noChecked'); // Save the value of no checked.
?>
</td>
</tr>
</table>
</form>
<script type='text/javascript'>
var newPriv = <?php echo json_encode($changelogs)?>;
var version = "<?php echo $this->config->version?>";
var groupID = <?php echo $groupID?>;
var menu = "<?php echo $menu?>";
</script>