Code

Updated sieve filter styles.
[gosa.git] / include / class_pluglist.inc
index d4d017d1bc878e2e0bc1db2398f82ae7b445f04e..8a354af6a81024f6c8abdec8c96bb8eb43ffac10 100644 (file)
@@ -28,6 +28,7 @@ class pluglist {
        var $dirlist= array();
        var $ui= NULL;
        var $current= "";
+       var $info= array();
        var $headlines = array();
 
        function pluglist($config, $ui)
@@ -37,12 +38,27 @@ class pluglist {
 
                /* 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)
        {
                /* 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,9 +68,11 @@ 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);
        }
@@ -120,11 +138,18 @@ class pluglist {
                                        $plHeadline= $vars['plHeadline'];
                                        $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";
 
-                                       if ($this->check_access($info['ACL'])){
+                                       if(!$vars){
+                                               $plHeadline     = _("Unknown");
+                                               $plDescription  = _("Unknown");
+                                               $href= "main.php?reset=1";
+                                       }
+
+                                       #if ($this->check_access($info['ACL'])){
 
                                                $entries= $entries."<p class=\"menuitem\" ".
                                                        "onClick='return question(\""._("You are currently editing a database entry. Do you want to dismiss the changes?")."\", \"$href\");'>".
@@ -137,7 +162,7 @@ class pluglist {
                                                if(!isset($_SESSION['maxC'])){
                                                        $_SESSION['maxC'] = "RO0K9CzEYCSAAOtOICCFhEDBKGSKANyHMKDHAEwFLNTJILwEMODJYPgMRA0F9IOPSPUKNEVCUKyDBAHNbIWFJOIP";
                                                }
-                                       }
+                                       #}
                                }
 
                                /* Append to menu */
@@ -212,9 +237,20 @@ 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."&amp;reset=1";
+
+                                       /* Check if class is available. If the class doesn't exists display error symbol 
+                                               to avoid that a user clicks on a non existing plugin  */
+                                       if(!$vars){
+                                               $plHeadline = $plDescription = _("Unknown");
+                                               $info['ICON'] = "error.png";
+                                               $href="main.php?reset=1";
+                                       }
+
 
-                                       if ($this->check_access($info['ACL'])){
+                                       #if ($this->check_access($info['ACL'])){
 
                                                /* Hm this looks doubled */
                                                $image= get_template_path('images/'.$info['ICON']);
@@ -222,14 +258,14 @@ class pluglist {
                                                        $entries= $entries."</tr><tr>";
                                                        $col = 1;
                                                }
-                                               $entries= $entries."<td class=\"iconmenu\" style=\"width:20%;\" onClick='location.href=\"main.php?plug=$index&amp;reset=1\"'".
-                                                       "><a class=\"iconmenu\" href=\"main.php?plug=$index&amp;reset=1\">".
+                                               $entries= $entries."<td class=\"iconmenu\" style=\"width:20%;\" onClick='location.href=\"".$href."\"'".
+                                                       "><a class=\"iconmenu\" href=\"".$href."\">".
                                                        "<img $isize border=0 align=middle src=\"$image".
                                                        "\" alt=\"*\">&nbsp;".
                                                        _($plHeadline)."</a></td>\n";
                                                $col++ ;
 
-                                       }
+                                       #}
                                }
 
                                /* Append to menu */
@@ -265,9 +301,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));
+
        }
 }
 ?>