Code

Fixed saving of applications
authorcajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 23 Mar 2006 07:55:52 +0000 (07:55 +0000)
committercajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 23 Mar 2006 07:55:52 +0000 (07:55 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@2900 594d385d-05f5-0310-b6e9-bd551577e9d8

plugins/admin/applications/class_applicationGeneric.inc
plugins/admin/applications/class_applicationManagement.inc
plugins/admin/applications/tabs_application.inc

index 738a75ad2b3c3aa06480b9589549e710eb394728..3e780faa432459536427a3e17086316fa5627594 100644 (file)
@@ -184,139 +184,143 @@ class application extends plugin
   /* Save data to object */
   function save_object()
   {
-       if (isset($_POST['cn'])){
+    if (isset($_POST['cn'])){
+
+      /* Save attributes */
+      parent::save_object();
+
+      /* Save application flags */
+      $flag= "";
+      if (isset($_POST['exec_for_groupmembers']) && $_POST['exec_for_groupmembers'] == 1){
+        $flag.= "G";
+      }
+      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";
+      }
+      if (isset($_POST['overwrite_config']) && $_POST['overwrite_config'] == 1){
+        $flag.= "O";
+      }
+      if (chkacl ($this->acl, "gosaApplicationFlags") ==""){
+        $this->gosaApplicationFlags= "[$flag]";
+      }
+
+      /* Check for picture upload */
+      if (isset($_FILES['picture_file']['name']) && $_FILES['picture_file']['name'] != ""){
+        if (!is_uploaded_file($_FILES['picture_file']['tmp_name'])) {
+          print_red (_("The specified picture has not been uploaded correctly."));
+        }
+    
+        if (!function_exists("imagick_blob2image")){
+          /* Get temporary file name for conversation */
+          $fname = tempnam ("/tmp", "GOsa");
+
+          /* Open file and write out photoData */
+          $fp = fopen ($fname, "w");
+          fwrite ($fp, $_FILES['picture_file']['tmp_name']);
+          fclose ($fp);
+
+          /* Build conversation query. Filename is generated automatically, so
+             we do not need any special security checks. Exec command and save
+             output. For PHP safe mode, you'll need a configuration which respects
+             image magick as executable... */
+          $query= "convert -size 48x48 $fname -resize 48x48 +profile \"*\" -";
+          @DEBUG (DEBUG_SHELL, __LINE__, __FUNCTION__, __FILE__, $query, "Execute");
+
+          /* Read data written by convert */
+          $output= "";
+          $sh= popen($query, 'r');
+          while (!feof($sh)){
+            $output.= fread($sh, 4096);
+          }
+          pclose($sh);
+
+          unlink($fname);      
+        } else {
 
-               /* Save application flags */
-               $flag= "";
-               if (isset($_POST['exec_for_groupmembers']) && $_POST['exec_for_groupmembers'] == 1){
-                       $flag.= "G";
-               }
-               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";
-               }
-               if (isset($_POST['overwrite_config']) && $_POST['overwrite_config'] == 1){
-                       $flag.= "O";
-               }
-               if (chkacl ($this->acl, "gosaApplicationFlags") ==""){
-                       $this->gosaApplicationFlags= "[$flag]";
-               }
+          /* Load the new uploaded Photo */
+          if(!$handle  =  imagick_ReadImage($_FILES['picture_file']['tmp_name'])){
+            gosa_log("Can't Load image");
+          }
+
+          /* Resizing image to 147x200 and blur */
+          if(!imagick_resize($handle,48,48,IMAGICK_FILTER_GAUSSIAN,0)){
+            gosa_log("imagick_resize failed");
+          }
+
+          /* Converting image to JPEG */
+          if(!imagick_convert($handle,"PNG")) {
+            gosa_log("Can't Convert to PNG");
+          }
+
+          if(imagick_writeimage($handle,$_FILES['picture_file']['tmp_name'])){
+            gosa_log("can't write to specified folder");
+          }
+          
+          imagick_free($handle);
+        }
+
+        /* Activate new picture */
+        $this->set_picture($_FILES['picture_file']['tmp_name']);
+        }      
+
+
+      /* Save base, since this is no LDAP attribute */
+      if (isset($_POST['base']) && chkacl($this->acl, "create") == ""){
+        $this->base= $_POST['base'];
+      }
+    }
 
-               /* Check for picture upload */
-               if (isset($_FILES['picture_file']['name']) && $_FILES['picture_file']['name'] != ""){
-                       if (!is_uploaded_file($_FILES['picture_file']['tmp_name'])) {
-                               print_red (_("The specified picture has not been uploaded correctly."));
-                       }
-       
-                       if (!function_exists("imagick_blob2image")){
-                               /* Get temporary file name for conversation */
-                               $fname = tempnam ("/tmp", "GOsa");
-
-                               /* Open file and write out photoData */
-                               $fp = fopen ($fname, "w");
-                               fwrite ($fp, $_FILES['picture_file']['tmp_name']);
-                               fclose ($fp);
-
-                               /* Build conversation query. Filename is generated automatically, so
-                                  we do not need any special security checks. Exec command and save
-                                  output. For PHP safe mode, you'll need a configuration which respects
-                                  image magick as executable... */
-                               $query= "convert -size 48x48 $fname -resize 48x48 +profile \"*\" -";
-                               @DEBUG (DEBUG_SHELL, __LINE__, __FUNCTION__, __FILE__, $query, "Execute");
-
-                               /* Read data written by convert */
-                               $output= "";
-                               $sh= popen($query, 'r');
-                               while (!feof($sh)){
-                                       $output.= fread($sh, 4096);
-                               }
-                               pclose($sh);
-
-                               unlink($fname); 
-                       } else {
-
-                               /* Load the new uploaded Photo */
-                               if(!$handle  =  imagick_ReadImage($_FILES['picture_file']['tmp_name'])){
-                                 gosa_log("Can't Load image");
-                               }
-
-                               /* Resizing image to 147x200 and blur */
-                               if(!imagick_resize($handle,48,48,IMAGICK_FILTER_GAUSSIAN,0)){
-                                 gosa_log("imagick_resize failed");
-                               }
-
-                               /* Converting image to JPEG */
-                               if(!imagick_convert($handle,"PNG")) {
-                                 gosa_log("Can't Convert to PNG");
-                               }
-
-                               if(imagick_writeimage($handle,$_FILES['picture_file']['tmp_name'])){
-                                 gosa_log("can't write to specified folder");
-                               }
-                               
-                               imagick_free($handle);
-                       }
-
-                       /* Activate new picture */
-                       $this->set_picture($_FILES['picture_file']['tmp_name']);
-                       }       
-
-
-               /* Save base, since this is no LDAP attribute */
-               if (isset($_POST['base']) && chkacl($this->acl, "create") == ""){
-                       $this->base= $_POST['base'];
-               }
-       }
   }
 
 
   /* Check values */
   function check()
   {
-       $message= array();
+    $message= array();
 
-       /* Permissions for that base? */
-       if ($this->base != ""){
-               $new_dn= "cn=".$this->cn.",ou=apps,".$this->base;
-       } else {
-               $new_dn= $this->dn;
-       }
+    /* Permissions for that base? */
+    if ($this->base != ""){
+      $new_dn= "cn=".$this->cn.",ou=apps,".$this->base;
+    } else {
+      $new_dn= $this->dn;
+    }
 
-       $ui= get_userinfo();
-       $acl= get_permissions ($new_dn, $ui->subtreeACL);
-       $acl= get_module_permission($acl, "application", $new_dn);
-       if (chkacl($acl, "create") != ""){
-               $message[]= _("You have no permissions to create a application on this 'Base'.");
-       }
+    $ui= get_userinfo();
+    $acl= get_permissions ($new_dn, $ui->subtreeACL);
+    $acl= get_module_permission($acl, "application", $new_dn);
+    if (chkacl($acl, "create") != ""){
+      $message[]= _("You have no permissions to create a application on this 'Base'.");
+    }
 
-       /* All required fields are set? */
-       if ($this->cn == ""){
-               $message[]= _("Required field 'Name' is not filled.");
-       }
+    /* All required fields are set? */
+    if ($this->cn == ""){
+      $message[]= _("Required field 'Name' is not filled.");
+    }
 
-       if(preg_match("/[^a-z0-9]/",$this->cn)) {
-               $message[]=_("Invalid character in application name. Only a-z 0-9 are allowed.");
-       }
+    if(preg_match("/[^a-z0-9]/",$this->cn))    {
+      $message[]=_("Invalid character in application name. Only a-z 0-9 are allowed.");
+    }
 
-       if ($this->gosaApplicationExecute == ""){
-               $message[]= _("Required field 'Execute' is not filled.");
-       }
+    if ($this->gosaApplicationExecute == ""){
+      $message[]= _("Required field 'Execute' is not filled.");
+    }
 
-       /* Check for existing application */
-       $ldap= $this->config->get_ldap_link();
-       $ldap->cd($this->config->current["BASE"]);
-       $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'.");
-       }
+    /* Check for existing application */
+    $ldap= $this->config->get_ldap_link();
+    $ldap->cd($this->config->current["BASE"]);
+    $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'.");
+    }
 
-       return $message;
+    return $message;
   }
 
 
index 710d4249e8e8d0ff2e9f9755b7f0db108cf97630..2cf74aa6968f1dc1957887959fe651776388e7ef 100644 (file)
@@ -301,6 +301,7 @@ class applicationManagement extends plugin
       if (count($message) == 0){
 
         /* Save data data to ldap */
+        $this->apptabs->set_release($this->Release);
         $this->apptabs->save();
         gosa_log ("Application object'".$this->dn."' has been saved");
 
index c884fed956e29cc902f3d68e33ad525cbc1e613b..5ed150f3f8d964cfb44be90e4e9875309c9fcd35 100644 (file)
@@ -2,19 +2,28 @@
 
 class apptabs extends tabs
 {
+  var $Release= "";
 
   function apptabs($config, $data, $dn)
   {
        tabs::tabs($config, $data, $dn);
   }
 
+  function set_release($newRelease)
+  {
+       $this->Release= preg_replace('/,ou=apps,.*$/', '', $newRelease);
+       if ($this->Release != ""){
+               $this->Release= ",".$this->Release;
+       }
+  }
+
   function save()
   {
        $baseobject= $this->by_object['application'];
 
        /* Check for new 'dn', in order to propagate the
           'dn' to all plugins */
-       $new_dn= "cn=".$baseobject->cn.",ou=apps,".$baseobject->base;
+       $new_dn= "cn=".$baseobject->cn.$this->Release.",ou=apps,".$baseobject->base;
 
         /* Move group? */
         if ($this->dn != $new_dn){