Code

Added printer patch
[gosa.git] / plugins / admin / applications / class_applicationGeneric.inc
index bf90cea8cb900abbbd1f2e2d5c103a005224abef..42626b91e1cf43ec63c5e14d7c2fdaf64d3d33de 100644 (file)
@@ -110,6 +110,18 @@ class application extends plugin
 
     $smarty= get_smarty();
 
+    if(isset($_POST['download'])){
+      header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
+      header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
+      header("Cache-Control: no-cache");
+      header("Pragma: no-cache");
+      header("Cache-Control: post-check=0, pre-check=0");
+      header("Content-type: application/octet-stream");
+      header( "Content-disposition: attachment; filename=".$this->cn.".gotoLogonScript" );
+      echo $this->gotoLogonScript;
+      exit();
+    }
+
     /* Do we represent a valid group? */
     if (!$this->is_account && $this->parent == NULL){
       $display= "<img alt=\"\" src=\"images/stop.png\" align=\"middle\">&nbsp;<b>".
@@ -166,7 +178,7 @@ class application extends plugin
     $smarty->assign("rand", rand(0, 10000));
 
     /* Variables */
-    foreach(array("description", "gosaApplicationExecute", "gosaApplicationName","cn") as $val){
+    foreach(array("description", "gosaApplicationExecute", "gosaApplicationName","cn","gotoLogonScript","gosaApplicationIcon") as $val){
       $smarty->assign($val, $this->$val);
       $smarty->assign($val."ACL", chkacl($this->acl, $val));
     }
@@ -394,6 +406,9 @@ class application extends plugin
   /* Save to LDAP */
   function save()
   {
+    /* Get application script without header part, to check if we must save the script itself */
+    $script = preg_replace('/.*### END HEADER ###/s', '', $this->gotoLogonScript);
+
     plugin::save();
     $this->attrs["gosaApplicationIcon"]= $this->gosaApplicationIcon;
 
@@ -403,11 +418,23 @@ class application extends plugin
 
     $a= $ldap->fetch();
     if (count($a)){
+      
+      /* Remove gotoLogonScript if it is empty */
+      if(empty($script))    {
+        $this->attrs['gotoLogonScript'] = array();
+      }
+
       $ldap->cd($this->dn);
       $this->cleanup();
       $ldap->modify ($this->attrs); 
       $this->handle_post_events("modify");
     } else {
+
+      /* Remove gotoLogonScript if it is empty */
+      if(empty($script))    {
+        unset($this->attrs['gotoLogonScript']);
+      }
+
       $ldap->cd($this->config->current['BASE']);
       $ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $this->dn));
       $ldap->cd($this->dn);