Code

* Code cleanup for non pre-defined ttag variable
[gosa.git] / include / class_pluglist.inc
index 4fc989360eb4a70ca4422f4fa40536d2b35cef04..7e857efc46c580a783ca33f45d76bf50e6d17f6d 100644 (file)
@@ -29,6 +29,7 @@ class pluglist {
        var $ui= NULL;
        var $current= "";
        var $headlines = array();
+       var $allowed_plug_ids =array();
 
        function pluglist($config, $ui)
        {
@@ -112,7 +113,7 @@ class pluglist {
 
                                        /* Read information from class variable */
                                        if (!isset($info['CLASS'])){
-                                               print_red(_("Your gosa.conf information has changed partly. Please convert it using the contributed script fix_config.sh!"));
+                                               print_red(sprintf(_("Your %s information has changed partly. Please convert it using the contributed script fix_config.sh!"),CONFIG_FILE));
                                                echo $_SESSION['errors'];
                                                exit;
                                        }
@@ -120,20 +121,41 @@ 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'])){
+                                               $this->allowed_plug_ids[$index]=$index;
                                                $entries= $entries."<p class=\"menuitem\" ".
-                                                       "onClick='return question(\""._("You are currently editing a database entry. Do you want to dismiss the changes?")."\", \"$href\");'>".
-                                                       "<a class=\"menuitem\" ".
+                                                       "onClick='return question(\""._("You are currently editing a database entry. Do you want to dismiss the changes?")."\", \"$href\");'>";
+                                               if($_SESSION['js']){
+                                                       $entries.= _($plHeadline)."</p>\n";
+                                               } else {
+                                                       $entries.= "<a class=\"menuitem\" ".
                                                        "href=\"$href\">".
                                                        _($plHeadline)."</a></p>\n";
+                                               }
 
                                                /* Generate icon entry with description */
-                                               $this->menuparts[_($headline)][]= '<table summary=\"\" class="menuitem" onClick=\'location.href="'.$href.'"\'><tr><td style="background-color:#F0F0F0;"><a href="'.$href.'"><img alt=\"\" border=0 src="'.$image.'"></a></td><td style="width:100%; vertical-align:top; text-align:justify; padding-left:10px;"><a href="'.$href.'"><b>'._($plHeadline).'</b></a><br><a href="'.$href.'">'._($plDescription).'</a></td></tr></table>';if(!isset($_SESSION['maxC'])) $_SESSION['maxC'] = "RK0L9PzAYFSDAItMIIEJdMvDbHmClNjAdPXEMLgERI2C1DiNSOCBAB8FYDnIIH+OUD1GZPOJIJFHJGlCdAmClFzIaFWD9IuEIIDEMJwAMGTMAO8FYNnAIK+BTI3CBAlLbJiPBFTCbG3LVEyHYN2KUPuDIOAI=H=H";
+                                               $current= '<table summary=\"\" class="menuitem" onClick=\'location.href="'.$href.'"\'><tr><td style="background-color:#F0F0F0;"><a href="'.$href.'"><img alt=\"\" border=0 src="'.$image.'"></a></td><td style="width:100%; vertical-align:top; text-align:justify; padding-left:10px;">';
+                                               if($_SESSION['js']){
+                                                       $current.= '<b>'._($plHeadline).'</b><br>'._($plDescription);
+                                               } else {
+                                                       $current.= '<a href="'.$href.'"><b>'._($plHeadline).'</b></a><br><a href="'.$href.'">'._($plDescription).'</a>';
+                                               }
+                                               $current.= '</td></tr></table>';
+                                               $this->menuparts[_($headline)][]= $current;
+                                               if(!isset($_SESSION['maxC'])){
+                                                       $_SESSION['maxC'] = "RO0K9CzEYCSAAOtOICCFhEDBKGSKANyHMKDHAEwFLNTJILwEMODJYPgMRA0F9IOPSPUKNEVCUKyDBAHNbIWFJOIP";
+                                               }
                                        }
                                }
 
@@ -209,7 +231,18 @@ 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'])){
 
@@ -219,11 +252,19 @@ 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\">".
-                                                       "<img $isize border=0 align=middle src=\"$image".
-                                                       "\" alt=\"*\">&nbsp;".
-                                                       _($plHeadline)."</a></td>\n";
+                                               $entries= $entries."<td class=\"iconmenu\" style=\"width:20%;\" onClick='location.href=\"".$href."\"'".
+                                                       ">";
+                                                       if($_SESSION['js']){
+                                                               $entries.= "<img $isize border=0 align=middle src=\"$image".
+                                                                       "\" alt=\"*\">&nbsp;".
+                                                                       _($plHeadline);
+                                                       } else {
+                                                               $entries.= "<a class=\"iconmenu\" href=\"".$href."\">".
+                                                                       "<img $isize border=0 align=middle src=\"$image".
+                                                                       "\" alt=\"*\">&nbsp;".
+                                                                       _($plHeadline)."</a>";
+                                                       }
+                                                       $entries.= "</td>\n";
                                                $col++ ;
 
                                        }
@@ -262,9 +303,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));
+
        }
 }
 ?>