Code

Fixed attachment for printer
[gosa.git] / plugins / admin / applications / class_applicationGeneric.inc
index 48615401f0f8821bfa397f897cb49417aadb3148..0918b0f031cf82a4d098f4af11b6e6eea0b153f1 100644 (file)
@@ -16,7 +16,6 @@ class application extends plugin
   var $gosaApplicationIcon= "";
   var $gotoLogonScript ="";
   var $iconData;
-  var $Categories = array();
 
   /* Headpage attributes */
   var $last_sorting= "invalid";
@@ -31,25 +30,6 @@ class application extends plugin
   {
        plugin::plugin ($config, $dn);
 
-       $tmp = new xmlParse();
-       
-       $this->Categories= array();
-       if(!isset($this->config->data['MAIN']['KDE_APPLICATIONS_MENU']))        {
-               print_red(_("There is no value for 'KDE_APPLICATIONS_MENU' specified in your gosa.conf."));
-       }else{
-               $path = $this->config->data['MAIN']['KDE_APPLICATIONS_MENU'];
-               if(file_exists($path)){
-                       if(is_readable($path)){
-                               $tmp->parseMenu($path);
-                               $this->Categories = $tmp->GetData();
-                       }else{
-                               print_red(sprintf(_("The specified file '%s' for 'KDE_APPLICATIONS_MENU' in your gosa.conf is not accessable."),$path));
-                       }
-               }else{
-                       print_red(sprintf(_("The specified file '%s' for 'KDE_APPLICATIONS_MENU' in your gosa.conf is not accessable."),$path));
-               }
-       }
-
        /* Load icon */
        $ldap= $config->get_ldap_link();
        if ($dn != 'new'){
@@ -78,11 +58,15 @@ class application extends plugin
   }
 
 
-  function generateTempalte(){
+  function generateTemplate(){
        $str= "# This code is part of GOsa (https://gosa.gonicus.de)\n#\n";
 
-       $names = $this->parent->by_object['applicationParameters']->option_name;
-       $values = $this->parent->by_object['applicationParameters']->option_value;
+       $values = array();
+       $names  = array();
+       if($this->parent->by_object['applicationParameters']->is_account){
+               $names = $this->parent->by_object['applicationParameters']->option_name;
+               $values = $this->parent->by_object['applicationParameters']->option_value;
+       }
 
        if (count($names)){
                $str .="# This plugin handles these environment variables:\n";
@@ -115,7 +99,6 @@ class application extends plugin
        plugin::execute();
 
        $smarty= get_smarty();
-       $smarty->assign("categories",array_flip($this->Categories));
 
        /* Do we represent a valid group? */
        if (!$this->is_account && $this->parent == NULL){
@@ -124,18 +107,8 @@ class application extends plugin
                 return ($display);
        }
 
-#      if(isset($_POST['ScriptTemplate'])){
-               $head = $this->generateTempalte();
-               $scr  = $this->gotoLogonScript; 
-               
-               if(preg_match("/### END HEADER ###/",$scr)){
-                       $pos = strrpos($scr,"### END HEADER ###");
-                       $pos = $pos + strlen("### END HEADER ###");
-                       $scr=substr($scr,$pos,(strlen($scr)));
-               }
-
-               $this->gotoLogonScript = $head.$scr;
-#      }
+       $head = $this->generateTemplate();
+       $this->gotoLogonScript= $this->generateTemplate().preg_replace('/.*### END HEADER ###/s', '', $this->gotoLogonScript);
        
        if((isset($_POST['upLoad']))&&(isset($_FILES['ScriptFile']))){
                $str = file_get_contents($_FILES['ScriptFile']['tmp_name']);
@@ -158,13 +131,14 @@ class application extends plugin
        $smarty->assign("rand", rand(0, 10000));
 
        /* Variables */
-       foreach(array("description", "gosaApplicationExecute", "gosaApplicationName") as $val){
+       foreach(array("description", "gosaApplicationExecute", "gosaApplicationName","cn") as $val){
                $smarty->assign($val, $this->$val);
                $smarty->assign($val."ACL", chkacl($this->acl, $val));
        }
 
        /* Checkboxes */
        foreach (array("G" => "exec_for_groupmembers", "O" => "overwrite_config",
+                       "L" => "place_on_kicker",
                        "D" => "place_on_desktop", "M" => "place_in_startmenu") as $key => $val){
                if (preg_match("/$key/", $this->gosaApplicationFlags)){
                        $smarty->assign("$val", "checked");
@@ -222,6 +196,9 @@ class application extends plugin
                if (isset($_POST['place_on_desktop']) && $_POST['place_on_desktop'] == 1){
                        $flag.= "D";
                }
+               if (isset($_POST['place_on_kicker']) && $_POST['place_on_kicker'] == 1){
+                       $flag.= "L";
+               }
                if (isset($_POST['place_in_startmenu']) && $_POST['place_in_startmenu'] == 1){
                        $flag.= "M";
                }
@@ -335,7 +312,7 @@ class application extends plugin
        /* Check for existing application */
        $ldap= $this->config->get_ldap_link();
        $ldap->cd($this->config->current["BASE"]);
-       $ldap->search("(&(objectClass=gosaApplication)(cn=$this->cn))");
+       $ldap->search("(&(objectClass=gosaApplication)(cn=$this->cn))",array("cn"));
        $ldap->fetch();
        if ($ldap->count() != 0 && $this->dn == "new"){
                $message[]= _("There's already an application with this 'Name'.");