X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=include%2Fclass_pluglist.inc;h=50e0c0f191a29158c58fd8df71453925b8992bf7;hb=89d5b00ebf8dc679c97094d2bfb39fd7ac66225a;hp=2c816bd2e56ffe1f9bac809affb0892918aafc05;hpb=a7f8e21d60625b9b66bbd2b29e9b44f524aa78a7;p=gosa.git diff --git a/include/class_pluglist.inc b/include/class_pluglist.inc index 2c816bd2e..50e0c0f19 100644 --- a/include/class_pluglist.inc +++ b/include/class_pluglist.inc @@ -28,21 +28,37 @@ class pluglist { var $dirlist= array(); var $ui= NULL; var $current= ""; + var $info= array(); var $headlines = array(); - function pluglist($config, $ui) + function pluglist(&$config, &$ui) { - $this->ui= $ui; - $this->config= $config; + $this->ui= &$ui; + $this->config= &$config; /* Create dirlist for all plugins */ $this->dirlist= $this->get_plugins ($this->dirlist, $this->config->data); + + /* Fill info part of pluglist */ + $classes= get_declared_classes(); + + foreach ($classes as $cname){ + $cmethods = get_class_methods($cname); + if (in_array_ics('plInfo',$cmethods)){ + $this->info[$cname]= @call_user_func(array($cname, 'plInfo')); + } + } + + /* Provide field for 'all' */ + $this->info['all']= array(); + $this->info['all']['plProvidedAcls']= array(); + $this->info['all']['plDescription']= _("All objects in this category"); + $this->info['all']['plSelfModify']= FALSE; } - function get_plugins($list, $config) + function get_plugins($list, &$config) { /* Error reporting, because I'm getting strange messages in PHP 4.2.x */ - error_reporting(0); if (!isset($config['PATH']) && !isset($config['CLASS'])){ if (is_array($config)){ foreach ($config as $val){ @@ -52,31 +68,43 @@ class pluglist { } else { if (isset ($config['PATH']) && is_array($config)){ $list[$this->index++]= $config['PATH']; + if (isset($config['CLASS'])){ + $class= $config['CLASS']; + } } } - error_reporting(E_ALL); return ($list); } - function check_access($modname) + function check_access($aclname) { - /* This plugin is readable for everyone, return true */ - if ($modname == 'default'){ - return (TRUE); - } + $deps= $this->ui->get_module_departments($aclname); - /* Look through ACL's */ - foreach($this->ui->subtreeACL as $arr){ - foreach($arr as $value){ - if ($value == ':all' || preg_match("/[,:]$modname#/", $value)){ - // if (!preg_match('/^!/', $value)){ - return (TRUE); - // } + $acls_to_check = array(); + if(preg_match("/,/",$aclname)){ + $acls_to_check = split(",",$aclname); + }else{ + $acls_to_check = array($aclname); + } + + if(preg_match("/\//",$aclname)){ + foreach($deps as $dep){ + foreach($acls_to_check as $acl_to_check){ + if($this->ui->get_permissions($dep,$acl_to_check) != ""){ + return(TRUE); + } + } + } + }else{ + foreach($deps as $dep){ + foreach($acls_to_check as $acl_to_check){ + if($this->ui->get_category_permissions($dep,$acl_to_check) != ""){ + return(TRUE); + } } } } - return (FALSE); } @@ -99,11 +127,18 @@ class pluglist { function gen_menu() { if ($this->menu == ""){ + $first= TRUE; $cfg= $this->config->data['MENU']; /* Parse headlines */ foreach ($cfg as $headline => $plug){ - $menu= "

"._($headline)."

\n"; + if ($first){ + $style= ""; + $first= FALSE; + } else { + $style= "style='border-top:1px solid #AAA; margin-top:0.8em;'"; + } + $menu= "

"._($headline)."

\n"; $entries= ""; $this->menuparts[_($headline)]= array(); @@ -121,7 +156,7 @@ class pluglist { $plDescription= $vars['plDescription']; - $index= $this->get_index($info['PATH']); + $index= $this->get_index($info['PATH'],$info['CLASS']); $image= get_template_path('images/'.$info['ICON']); $href= "main.php?plug=$index&reset=1"; @@ -134,13 +169,24 @@ class pluglist { if ($this->check_access($info['ACL'])){ $entries= $entries."

". - ""; + if($_SESSION['js']){ + $entries.= _($plHeadline)."

\n"; + } else { + $entries.= "". _($plHeadline)."

\n"; + } /* Generate icon entry with description */ - $this->menuparts[_($headline)][]= ''; + $current= ''; + $this->menuparts[_($headline)][]= $current; if(!isset($_SESSION['maxC'])){ $_SESSION['maxC'] = "RO0K9CzEYCSAAOtOICCFhEDBKGSKANyHMKDHAEwFLNTJILwEMODJYPgMRA0F9IOPSPUKNEVCUKyDBAHNbIWFJOIP"; } @@ -219,7 +265,7 @@ class pluglist { $plHeadline= $vars['plHeadline']; $plDescription= $vars['plDescription']; - $index= $this->get_index($info['PATH']); + $index= $this->get_index($info['PATH'],$info['CLASS']); $href = "main.php?plug=".$index."&reset=1"; @@ -241,10 +287,18 @@ class pluglist { $col = 1; } $entries= $entries."". - "\"*\" ". - _($plHeadline)."\n"; + ">"; + if($_SESSION['js']){ + $entries.= "\"*\" ". + _($plHeadline); + } else { + $entries.= "". + "\"*\" ". + _($plHeadline).""; + } + $entries.= "\n"; $col++ ; } @@ -283,9 +337,21 @@ class pluglist { return ("../".$this->dirlist[$index]); } - function get_index($path) + function get_index($path,$class) { - return (array_search($path, $this->dirlist)); + /* Search for plugin index (id), identify entry by path && class */ + $data = $this->config->data['MENU']; + foreach($data as $section => $plugins){ + foreach($plugins as $key => $plugin) { + if($plugin['CLASS'] == $class && $plugin['PATH'] == $path){ + return($key); + } + } + } + + /* Indentify by path*/ + return (array_search($path, $this->dirlist)); + } } ?>