Code

Converted a couple of == / === NULL references
[gosa.git] / plugins / admin / applications / class_applicationGeneric.inc
index cf00e07b52b6d76fbf08c97edb1ce0d00fd55cab..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);
 
@@ -73,7 +74,8 @@ class application extends plugin
   }
 
 
-  function generateTemplate(){
+  function generateTemplate()
+  {
     $str= "# This code is part of GOsa (https://gosa.gonicus.de)\n#\n";
 
     $values = array();
@@ -113,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();
@@ -120,10 +128,8 @@ class application extends plugin
       $smarty->assign($name."ACL",$this->getacl($name));
     }
  
-    $smarty->assign("baseACL", $this->getacl("base"));
-
     /* 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);
@@ -182,7 +188,8 @@ class application extends plugin
       if($this->dialog->isClosed()){
         $this->dialog = false;
       }elseif($this->dialog->isSelected()){
-  
+        /* Just allow selection valid bases */ 
         $tmp = $this->get_allowed_bases();
         if(isset($tmp[$this->dialog->isSelected()])){
           $this->base = $this->dialog->isSelected();
@@ -225,6 +232,7 @@ class application extends plugin
   {
     $ldap= $this->config->get_ldap_link();
     $ldap->rmDir($this->dn);
+    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 */
@@ -327,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);
@@ -385,12 +393,6 @@ class application extends plugin
       $this->set_acl_base($this->base);
     }
 
-    /* Check acls to create a new application here  */
-    $ui= get_userinfo();
-    if (!$this->acl_is_createable() && $this->dn == "new"){
-      $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.");
@@ -457,6 +459,7 @@ class application extends plugin
       $this->cleanup();
       $ldap->modify ($this->attrs); 
       $this->handle_post_events("modify");
+      new log("modify","application/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
     } else {
       
       /* Remove gotoLogonScript if it is empty */
@@ -468,6 +471,7 @@ class application extends plugin
       $ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $this->dn));
       $ldap->cd($this->dn);
       $ldap->add($this->attrs);
+      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));
@@ -522,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()