+ add function of sort resource.

This commit is contained in:
zhujinyong
2012-07-01 08:09:54 +00:00
parent 563646b3d4
commit 0f2e699807
2 changed files with 52 additions and 2 deletions
+2 -1
View File
@@ -139,6 +139,7 @@ class group extends control
if($type == 'byGroup')
{
$this->group->sortResource();
$group = $this->group->getById($groupID);
$groupPrivs = $this->group->getPrivs($groupID);
@@ -148,10 +149,10 @@ class group extends control
$this->view->group = $group;
$this->view->changelogs = $this->lang->changelog;
$this->view->groupPrivs = $groupPrivs;
}
elseif($type == 'byModule')
{
$this->group->sortResource();
$this->view->header->title = $this->lang->company->common . $this->lang->colon . $this->lang->group->managePriv;
$this->view->position[] = $this->lang->group->managePriv;
+50 -1
View File
@@ -144,7 +144,7 @@ class groupModel extends model
while($priv = $stmt->fetch()) $privs[$priv->module][$priv->method] = $priv->method;
return $privs;
}
/**
* Get user pairs of a group.
*
@@ -248,4 +248,53 @@ class groupModel extends model
$this->dao->insert(TABLE_USERGROUP)->data($data)->exec();
}
}
/**
* Sort resource.
*
* @access public
* @return void
*/
public function sortResource()
{
$resources = $this->lang->resource;
unset($this->lang->resource);
ksort($this->lang->moduleOrder, SORT_ASC);
foreach($this->lang->moduleOrder as $moduleName)
{
$resource = $resources->$moduleName;
unset($resources->$moduleName);
$this->lang->resource->$moduleName = $resource;
}
foreach($resources as $key => $resource)
{
$this->lang->resource->$key = $resource;
}
foreach($this->lang->resource as $moduleName => $resources)
{
$resources = (array)$resources;
if(isset($this->lang->$moduleName->methodOrder))
{
ksort($this->lang->$moduleName->methodOrder, SORT_ASC);
foreach($this->lang->$moduleName->methodOrder as $key)
{
$tmpResources->$key = $resources[$key];
unset($resources[$key]);
}
if($resources)
{
$resources = array_keys($resources);
$labels = array_values($resources);
foreach($resources as $key => $resource)
{
$tmpResources->$resource = $labels[$key];
}
}
$this->lang->resource->$moduleName = $tmpResources;
unset($tmpResources);
}
}
}
}