Code

Updated system Management.
[gosa.git] / gosa-plugins / systems / admin / systems / class_systemManagement.inc
index e05a52c3a388a031384288fcee8fe4441224cc6d..6283f5c1b9976e9a7617cf58609e542304fa1ad1 100644 (file)
@@ -327,7 +327,7 @@ class systems extends plugin
           $this->systab->by_object[$tabname]->base = $this->DivListSystem->selectedBase;
           $this->systab->base = $this->DivListSystem->selectedBase;
         }else{
-          print_red(_("You are not allowed to create a new object of this type."));
+          msg_dialog::display(_("Error"), msgPool::permCreate(), ERROR_DIALOG);
         }
       }
     }
@@ -380,7 +380,7 @@ class systems extends plugin
         session::set('objectinfo',$this->dn);
         add_lock ($this->dn, $this->ui->dn);
       }else{ 
-        print_red (_("You can't edit this object type yet!"));
+        msg_dialog::display(_("Error"), _("Editing this type of object is not supported yet!"), ERROR_DIALOG);
         del_lock($this->dn);
       }
     }
@@ -408,7 +408,7 @@ class systems extends plugin
         session::set('objectinfo',$this->dn);
         return ($smarty->fetch(get_template_path('password.tpl', TRUE)));
       }else{
-        print_red(_("You are not allowed to change the password for this object."));
+        msg_dialog::display(_("Permission error"), _("You have no permission to change this password!"), ERROR_DIALOG);
       }
     }
 
@@ -420,7 +420,7 @@ class systems extends plugin
     /* Correctly specified? */
     if (isset($_POST['password_finish'])){
       if ($_POST['new_password'] != $_POST['repeated_password']){
-        print_red (_("Passwords entered as new and repeated do not match!"));
+        msg_dialog::display(_("Error"), _("The passwords you've entered as 'New password' and 'Repeated password' do not match!"), ERROR_DIALOG);
         return($smarty->fetch(get_template_path('password.tpl', TRUE)));
       }
     }
@@ -474,10 +474,10 @@ class systems extends plugin
           $ldap->modify($attrs);
           new log("security","systems/".get_class($this),$this->dn,array_keys($attrs),$ldap->get_error());
         }else{
-          print_red(_("You are not allowed to change the password for this object."));
+          msg_dialog::display(_("Permission error"), _("You have no permission to change this password!"), ERROR_DIALOG);
         }
       }else{
-        print_red(_("Can't detect object to change password."));
+        msg_dialog::display(_("Error"), _("Cannot determine object to change password!"), ERROR_DIALOG);
       }
       session::un_set('objectinfo');
     }
@@ -519,6 +519,27 @@ class systems extends plugin
         }
         $events = DaemonEvent::get_event_types(SYSTEM_EVENT);
         $type = preg_replace("/^[a-z]*_event_/","",$s_action);
+        $o_queue = new gosaSupportDaemon();
+
+        /* Skip installation or update trigerred events, 
+         *  if this entry is currently processing.
+         */
+        if(preg_match("/trigger_event/",$s_action) && in_array($type,array("DaemonEvent_reinstall","DaemonEvent_update"))){
+          foreach($mac as $key => $mac_address){
+            foreach($o_queue->get_entries_by_mac(array($mac_address)) as $entry){
+
+              $entry['STATUS'] = strtoupper($entry['STATUS']);
+              if($entry['STATUS'] == "PROCESSING" && 
+                  isset($events['QUEUED'][$entry['HEADERTAG']]) && 
+                  in_array($events['QUEUED'][$entry['HEADERTAG']],array("DaemonEvent_reinstall","DaemonEvent_update"))){
+                unset($mac[$key]);
+
+                new log("security","systems/".get_class($this),"",array(),"Skip adding 'DaemonEvent::".$type."' for mac '".$mac_address."', there is already a job in progress.");
+                break;
+              }
+            }
+          }
+        }        
 
         /* Prepare event to be added 
          */
@@ -545,8 +566,7 @@ class systems extends plugin
         $o_queue = new gosaSupportDaemon();
         $o_queue->append($this->systab);
         if($o_queue->is_error()){
-          msg_dialog::display(_("Daemon"),sprintf(_("Something went wrong while talking to the daemon: %s."),
-                $o_queue->get_error()),ERROR_DIALOG);
+          msg_dialog::display(_("Service infrastructure"),msgPool::siError($o_queue->get_error()),ERROR_DIALOG);
         }else{
           $this->systab = FALSE;
         }
@@ -575,19 +595,14 @@ class systems extends plugin
           return(gen_locked_message($user,$this->dns));
         }
 
-        $dns_names = "<br><pre>";
+        $dns_names = array();
         foreach($this->dns as $dn){
           add_lock ($dn, $this->ui->dn);
-          $dns_names .= $dn."\n";
+          $dns_names[] = @LDAP::fix($dn);
         }
-        $dns_names .="</pre>";
 
         /* Lock the current entry, so nobody will edit it during deletion */
-        if (count($this->dns) == 1){
-          $smarty->assign("warning",     sprintf(_("You're about to delete the following entry %s"), @LDAP::fix($dns_names)));
-        } else {
-          $smarty->assign("warning",     sprintf(_("You're about to delete the following entries %s"), @LDAP::fix($dns_names)));
-        }
+        $smarty->assign("warning", msgPool::deleteInfo($dns_names));
         $smarty->assign("multiple", true);
         return($smarty->fetch(get_template_path('remove.tpl', TRUE)));
       }
@@ -654,7 +669,7 @@ class systems extends plugin
           } else {
             /* Normally this shouldn't be reached, send some extra
                logs to notify the administrator */
-            print_red (_("You are not allowed to delete this component!"));
+            msg_dialog::display(_("Permission error"), msgPool::permDelete(), ERROR_DIALOG);
             new log("security","systems/".get_class($this),$dn,array(),"Tried to trick deletion.");
           }
           /* Remove lock file after successfull deletion */
@@ -725,14 +740,14 @@ class systems extends plugin
 
         /* Lock the current entry, so nobody will edit it during deletion */
         add_lock ($this->dn, $this->ui->dn);
-        $smarty->assign("warning", sprintf(_("You're about to delete all information about the component at '%s'."), @LDAP::fix($this->dn)));
+        $smarty->assign("warning", msgPool::deleteInfo(@LDAP::fix($this->dn)));
         $smarty->assign("multiple", false);
         return($smarty->fetch(get_template_path('remove.tpl', TRUE)));
       } else {
 
         /* Obviously the user isn't allowed to delete. Show message and
            clean session. */
-        print_red (_("You are not allowed to delete this component!"));
+        msg_dialog::display(_("Permission error"), msgPool::permDelete(), ERROR_DIALOG);
       }
     }
 
@@ -797,7 +812,7 @@ class systems extends plugin
 
         /* Normally this shouldn't be reached, send some extra
            logs to notify the administrator */
-        print_red (_("You are not allowed to delete this component!"));
+        msg_dialog::display(_("Permission error"), msgPool::permDelete(), ERROR_DIALOG);
         new log("security","systems/".get_class($this),$dn,array(),"Tried to trick deletion.");
       }
 
@@ -806,14 +821,7 @@ class systems extends plugin
     }
 
 
-
-
-
-
-
-
-
-   /********************
+    /********************
       Edit system type finished, check if everything went ok
      ********************/
     /* Finish user edit is triggered by the tabulator dialog, so
@@ -836,7 +844,7 @@ class systems extends plugin
           }
         }
         if(!$found){
-          print_red(sprintf(_("Can't set gotoMode to status 'active', the current object couldn't be identified.")));
+          msg_dialog::display(_("Internal error"), _("Cannot set mode to 'active'!"), ERROR_DIALOG);
         }
 
       }
@@ -906,8 +914,7 @@ class systems extends plugin
             $o_queue = new gosaSupportDaemon();
             $o_queue->append($tmp);
             if($o_queue->is_error()){
-              msg_dialog::display(_("Daemon"),sprintf(_("Something went wrong while talking to the daemon: %s."),
-                    $o_queue->get_error()),ERROR_DIALOG);
+              msg_dialog::display(_("Service infrastructure"),msgPool::siError($o_queue->get_error()),ERROR_DIALOG);
             }
           }
         }
@@ -1431,7 +1438,7 @@ class systems extends plugin
   {
     $temp= "";
     $conv= array(      
-        "NQ" => array("select_newsystem.png",_("New System from incoming")),
+        "NQ" => array("select_newsystem.png",_("New system from incoming")),
         "D" => array("select_default.png",_("Template")),
         "T" => array("select_terminal.png",_("Terminal")),
         "L" => array("select_workstation.png",_("Workstation")),
@@ -1443,10 +1450,10 @@ class systems extends plugin
         "GS" => array("select_server_green.png",_("Server is installing")),
         "YS" => array("select_server_yellow.png",_("Server is waiting for action")),
         "RS" => array("select_server_red.png",_("Server installation failed")),
-        "W" => array("select_winstation.png",_("Winstation")),
-        "C" => array("select_component.png",_("Network Device")),
-        "NT"=> array("select_new_terminal.png",_("New Terminal")),
-        "NL"=> array("select_new_workstation.png",_("New Workstation")),
+        "W" => array("select_winstation.png",_("Win workstation")),
+        "C" => array("select_component.png",_("Network device")),
+        "NT"=> array("select_new_terminal.png",_("New terminal")),
+        "NL"=> array("select_new_workstation.png",_("New workstation")),
         "P" => array("select_printer.png",_("Printer")));
 
     if((isset($input['is_new']))&&(!empty($input['is_new']))){