* adjust for add priv package for add relation.
This commit is contained in:
@@ -621,6 +621,7 @@ class group extends control
|
||||
|
||||
$this->view->privs = $privs;
|
||||
$this->view->modules = array('' => $this->lang->group->selectModule) + $this->group->getMenuModules(null, true);
|
||||
$this->view->packages = $this->group->getPrivPackagePairs(null, implode(',', $modules));
|
||||
$this->view->modulePrivs = $this->group->getPrivByModule($modules);
|
||||
$this->view->type = $type;
|
||||
$this->display();
|
||||
@@ -670,6 +671,7 @@ class group extends control
|
||||
|
||||
$this->view->privs = $privs;
|
||||
$this->view->modules = array('' => $this->lang->group->selectModule) + $this->group->getMenuModules(null, true);
|
||||
$this->view->packages = $this->group->getPrivPackagePairs(null, implode(',', $modules));
|
||||
$this->view->modulePrivs = $this->group->getPrivByModule($modules);
|
||||
$this->view->type = $type;
|
||||
$this->display('group', 'addrelation');
|
||||
@@ -689,16 +691,43 @@ class group extends control
|
||||
if(is_string($privIdList)) $privIdList = explode(',', $privIdList);
|
||||
|
||||
$modules = $this->group->getMenuModules(null, true);
|
||||
$packages = $this->group->getPrivPackagePairs(null, $module);
|
||||
$modulePrivs = $this->group->getPrivByModule($module);
|
||||
|
||||
$tree = "<ul class='tree' data-ride='tree'><li>";
|
||||
$tree .= html::a('#', $modules[$module]);
|
||||
$tree .= "<ul class='relationBox'>";
|
||||
foreach($modulePrivs[$module] as $id => $modulePriv)
|
||||
foreach($packages as $packageID => $packageName)
|
||||
{
|
||||
if(empty($modulePrivs[$module][$packageID])) continue;
|
||||
$tree .= '<li>';
|
||||
$tree .= html::a('#', $packageName);
|
||||
$tree .= '<ul>';
|
||||
|
||||
foreach($modulePrivs[$module][$packageID] as $id => $modulePriv)
|
||||
{
|
||||
$tree .= '<li>';
|
||||
$tree .= html::checkbox("relation[$module]", array($id => $modulePriv->name), '');
|
||||
$tree .= '</li>';
|
||||
}
|
||||
$tree .= '</ul></li>';
|
||||
unset($modulePrivs[$module][$packageID]);
|
||||
}
|
||||
if(!empty($modulePrivs[$module]))
|
||||
{
|
||||
$tree .= '<li>';
|
||||
$tree .= html::checkbox("relation[$module]", array($id => $modulePriv->name), '');
|
||||
$tree .= '</li>';
|
||||
$tree .= html::a('#', $this->lang->group->unassigned);
|
||||
$tree .= '<ul>';
|
||||
foreach($modulePrivs[$module] as $packageID => $packagePrivs)
|
||||
{
|
||||
foreach($packagePrivs as $id => $modulePriv)
|
||||
{
|
||||
$tree .= '<li>';
|
||||
$tree .= html::checkbox("relation[$module]", array($id => $modulePriv->name), '');
|
||||
$tree .= '</li>';
|
||||
}
|
||||
}
|
||||
$tree .= '</ul></li>';
|
||||
}
|
||||
$tree .= '</ul></li></ul>';
|
||||
return print($tree);
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
.tree .relationBox li{float:left; width: 150px;}
|
||||
.tree .relationBox li ul li{float:left; width: 150px;}
|
||||
#dataform {min-height:240px;}
|
||||
|
||||
@@ -846,7 +846,7 @@ class groupModel extends model
|
||||
*/
|
||||
public function getPrivPackagesByModule($module)
|
||||
{
|
||||
return $this->dao->select('*')->from(TABLE_PRIVPACKAGE)->where('module')->eq($module)->orderBy('order_asc')->fetchAll('id');
|
||||
return $this->dao->select('*')->from(TABLE_PRIVPACKAGE)->where('module')->in($module)->orderBy('order_asc')->fetchAll('id');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1115,12 +1115,16 @@ class groupModel extends model
|
||||
*/
|
||||
public function getPrivByModule($modules)
|
||||
{
|
||||
return $this->dao->select('t1.*,t2.name,t2.desc')->from(TABLE_PRIV)->alias('t1')
|
||||
$stmt = $this->dao->select('t1.*,t2.name,t2.desc')->from(TABLE_PRIV)->alias('t1')
|
||||
->leftJoin(TABLE_PRIVLANG)->alias('t2')->on('t1.id=t2.priv')
|
||||
->where('t1.module')->in($modules)
|
||||
->andWhere('t2.lang')->eq($this->app->getClientLang())
|
||||
->orderBy('`order`')
|
||||
->fetchGroup('module', 'id');
|
||||
->query();
|
||||
|
||||
$privs = array();
|
||||
while($priv = $stmt->fetch()) $privs[$priv->module][$priv->package][$priv->id] = $priv;
|
||||
return $privs;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -42,9 +42,30 @@
|
||||
<li>
|
||||
<?php echo html::a('#', $modules[$privModule]);?>
|
||||
<ul class='relationBox'>
|
||||
<?php foreach($modulePrivs[$privModule] as $id => $modulePriv):?>
|
||||
<li><?php echo html::checkbox("relation[{$privModule}]", array($id => $modulePriv->name), '')?></li>
|
||||
<?php foreach($packages as $packageID => $packageName):?>
|
||||
<?php if(empty($modulePrivs[$privModule][$packageID])) continue;?>
|
||||
<li>
|
||||
<?php echo html::a('#', $packageName);?>
|
||||
<ul>
|
||||
<?php foreach($modulePrivs[$privModule][$packageID] as $id => $modulePriv):?>
|
||||
<li><?php echo html::checkbox("relation[{$privModule}]", array($id => $modulePriv->name), '')?></li>
|
||||
<?php endforeach;?>
|
||||
<?php unset($modulePrivs[$privModule][$packageID]);?>
|
||||
</ul>
|
||||
</li>
|
||||
<?php endforeach;?>
|
||||
<?php if(!empty($modulePrivs[$privModule])):?>
|
||||
<li>
|
||||
<?php echo html::a('#', $lang->group->unassigned);?>
|
||||
<ul>
|
||||
<?php foreach($modulePrivs[$privModule] as $packageID => $packagePrivs):?>
|
||||
<?php foreach($packagePrivs as $id => $modulePriv):?>
|
||||
<li><?php echo html::checkbox("relation[{$privModule}]", array($id => $modulePriv->name), '')?></li>
|
||||
<?php endforeach;?>
|
||||
<?php endforeach;?>
|
||||
</ul>
|
||||
</li>
|
||||
<?php endif;?>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
Reference in New Issue
Block a user