Code

Converted a couple of == / === NULL references
[gosa.git] / plugins / admin / applications / class_applicationGeneric.inc
index 5ecab3a94495d85905ba0af1a94ea12f9717e4ca..875c269f18e791fe51bf55f9096404225a123d33 100644 (file)
@@ -16,6 +16,7 @@ class application extends plugin
   var $gosaApplicationIcon= "";
   var $gotoLogonScript ="";
   var $iconData;
+  var $view_logged = FALSE;
 
   /* Headpage attributes */
   var $last_sorting= "invalid";
@@ -28,7 +29,7 @@ class application extends plugin
 
   var $isReleaseApplikation = false;
 
-  function application ($config, $dn= NULL, $parent= NULL)
+  function application (&$config, $dn= NULL, $parent= NULL)
   {
     plugin::plugin ($config, $dn, $parent);
 
@@ -70,10 +71,6 @@ class application extends plugin
         $this->base= preg_replace ("/^[^,]+,[^,]+,/", "", $this->dn);
       }
     }
-      
-    if($this->is_account && $dn != "new"){
-      @log::log("view","application/".get_class($this),$this->dn);
-    }
   }
 
 
@@ -118,6 +115,12 @@ class application extends plugin
     /* Call parent execute */
     plugin::execute();
 
+    /* Log view */
+    if($this->is_account && !$this->view_logged){
+      $this->view_logged = TRUE;
+      new log("view","application/".get_class($this),$this->dn);
+    }
+
     $smarty= get_smarty();
 
     $tmp = $this->plInfo();
@@ -126,7 +129,7 @@ class application extends plugin
     }
  
     /* Do we represent a valid group? */
-    if (!$this->is_account && $this->parent == NULL){
+    if (!$this->is_account && $this->parent === NULL){
       $display= "<img alt=\"\" src=\"images/stop.png\" align=\"middle\">&nbsp;<b>".
         _("This 'dn' is no application.")."</b>";
       return ($display);
@@ -229,7 +232,7 @@ class application extends plugin
   {
     $ldap= $this->config->get_ldap_link();
     $ldap->rmDir($this->dn);
-    @log::log("remove","application/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
+    new log("remove","application/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
     show_ldap_error($ldap->get_error(), sprintf(_("Removing of application with dn '%s' failed."),$this->dn));
 
     /* Optionally execute a command after we're done */
@@ -332,21 +335,21 @@ class application extends plugin
 
           /* Load the new uploaded Photo */
           if(!$handle  =  imagick_ReadImage($_FILES['picture_file']['tmp_name'])){
-            gosa_log("Can't Load image");
+            print_red(_("Can't access uploaded image."));
           }
 
           /* Resizing image to 147x200 and blur */
           if(!imagick_resize($handle,48,48,IMAGICK_FILTER_GAUSSIAN,0)){
-            gosa_log("imagick_resize failed");
+            print_red(_("Uploaded image could not be resized, possilby the image magick extension is missing."));
           }
 
           /* Converting image to JPEG */
           if(!imagick_convert($handle,"PNG")) {
-            gosa_log("Can't Convert to PNG");
+            print_red(_("Could not convert image to png, possilby the image magick extension is missing."));
           }
 
-          if(imagick_writeimage($handle,$_FILES['picture_file']['tmp_name'])){
-            gosa_log("can't write to specified folder");
+          if(!imagick_writeimage($handle,$_FILES['picture_file']['tmp_name'])){
+            print_red(sprintf(_("Could not save uploaded image to %s."),$_FILES['picture_file']['tmp_name']));
           }
 
           imagick_free($handle);
@@ -456,7 +459,7 @@ class application extends plugin
       $this->cleanup();
       $ldap->modify ($this->attrs); 
       $this->handle_post_events("modify");
-      @log::log("modify","application/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
+      new log("modify","application/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
     } else {
       
       /* Remove gotoLogonScript if it is empty */
@@ -468,7 +471,7 @@ class application extends plugin
       $ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $this->dn));
       $ldap->cd($this->dn);
       $ldap->add($this->attrs);
-      @log::log("create","application/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
+      new log("create","application/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
       $this->handle_post_events("add");
     }
     show_ldap_error($ldap->get_error(), sprintf(_("Saving of application with dn '%s' failed."),$this->dn));
@@ -523,6 +526,14 @@ class application extends plugin
   }
 
 
+  function PrepareForCopyPaste($source)
+  {
+    plugin::PrepareForCopyPaste($source);
+    $source_o = new application($this->config,$source['dn']);
+    $this->gosaApplicationIcon = $source_o->gosaApplicationIcon;     
+  }
+
+
   /* Return plugin informations for acl handling
       #FIXME FAIscript seams to ununsed within this class... */
   function plInfo()