diff --git a/module/group/control.php b/module/group/control.php index afec51771f..b22105823f 100644 --- a/module/group/control.php +++ b/module/group/control.php @@ -248,6 +248,7 @@ class group extends control $privs = $this->group->getPrivsListByView($menu); $privPackages = $this->group->getPrivManagerPairs('package'); $privLang = $this->group->transformPrivLang($privs); + $privs = $this->group->getCustomPrivs($menu, $privs); $privList = array(); $privMethods = array(); @@ -265,11 +266,11 @@ class group extends control if(!isset($selectPrivs[$priv->parentCode][$priv->parent])) $selectPrivs[$priv->parentCode][$priv->parent] = 0; if(!empty($groupPrivs[$priv->module][$priv->method])) $selectPrivs[$priv->parentCode][$priv->parent] ++; } - $unassignedModule = array_diff(array_keys(get_object_vars($this->lang->resource)), array_keys($privList)); + $unassignedModule = array_diff(array_keys(get_object_vars($this->lang->resource)), array_keys($privList)); foreach($unassignedModule as $index => $module) { - if(!$this->group->checkMenuModule($menu, $module)) continue;; + if(!$this->group->checkMenuModule($menu, $module)) continue; $selectPrivs[$module] = array(); $selectPrivs[$module][0] = 0; @@ -290,7 +291,6 @@ class group extends control $this->view->privList = $privList; $this->view->privMethods = $privMethods; $this->view->selectPrivs = $selectPrivs; - $this->view->privLang = $privLang; $this->view->privPackages = $privPackages; } elseif($type == 'byModule') @@ -449,7 +449,7 @@ class group extends control */ public function editManagePriv($browseType = '', $view = '', $paramID = 0, $recTotal = 0, $recPerPage = 100, $pageID = 1) { - if(empty($browseType) and $browseType != 'bysearch') $browseType = $this->cookie->managePrivEditType ? $this->cookie->managePrivEditType : 'bycard';; + if(empty($browseType) and $browseType != 'bysearch') $browseType = $this->cookie->managePrivEditType ? $this->cookie->managePrivEditType : 'bycard'; if($browseType == 'bysearch' and $this->cookie->managePrivEditType == 'bycard') $browseType = 'bycard'; $moduleLang = $this->group->getMenuModules($view, true); diff --git a/module/group/model.php b/module/group/model.php index bd38c1f8b8..acba022b73 100644 --- a/module/group/model.php +++ b/module/group/model.php @@ -2005,4 +2005,39 @@ class groupModel extends model return $needPairs ? $privPairs : $privs; } + + /** + * Get custom privs. + * + * @param string $menu + * @param array $privs + * @access public + * @return array + */ + public function getCustomPrivs($menu, $privs = array()) + { + $allPrivs = $this->dao->select('module,method')->from(TABLE_PRIV)->fetchGroup('module', 'method'); + foreach($this->lang->resource as $module => $methods) + { + foreach($methods as $method => $methodLabel) + { + if(isset($allPrivs[$module][$method])) continue; + if(!$this->checkMenuModule($menu, $module)) continue; + if(!isset($this->lang->{$module}->{$methodLabel})) $this->app->loadLang($module); + + $key = "{$module}-{$methodLabel}"; + $priv = new stdclass(); + $priv->module = $module; + $priv->method = $method; + $priv->parent = 0; + $priv->key = $key; + $priv->parentCode = $module; + $priv->moduleOrder = 0; + $priv->name = $this->lang->{$module}->{$methodLabel}; + + $privs[$key] = $priv; + } + } + return $privs; + } } diff --git a/module/group/view/privbygroup.html.php b/module/group/view/privbygroup.html.php index 8f232dfe5d..23091fb0c7 100644 --- a/module/group/view/privbygroup.html.php +++ b/module/group/view/privbygroup.html.php @@ -112,9 +112,8 @@ $i = 1; - $unassigned = (!empty($moduleActions) and !empty($privMethods[$moduleName])) ? array_diff(array_keys(get_object_vars($moduleActions)), $privMethods[$moduleName]) : array(); - $modulePrivs = count($privList[$moduleName], 1) - count($selectPrivs[$moduleName], 1) + count($unassigned); - $moduleSelect = array_sum($selectPrivs[$moduleName]); + $modulePrivs = count($privList[$moduleName], 1) - count($selectPrivs[$moduleName], 1); + $moduleSelect = array_sum($selectPrivs[$moduleName]); ?> $privs):?>