Code

Removed show_ldap_error() calls
[gosa.git] / gosa-plugins / goto / admin / ogroups / goto / class_termgroup.inc
index f819349ff4a6fea15fce0f123cc9bcf3860a91ea..2299d1adfa7ff16d61811419c7ae9c1b1d55d1a6 100644 (file)
@@ -19,6 +19,7 @@ class termgroup extends plugin
                             "update"          => "sceduledupdate",
                             "reinstall"       => "install",
                             "rescan"          => "",
+                            "wake"            => "",
                             "memcheck"        => "memcheck",
                             "sysinfo"         => "sysinfo");
 
@@ -165,7 +166,9 @@ class termgroup extends plugin
       if(preg_match("/(w|t|s)/i",$allobs[$key]['type'])){
         $ldap->cd ($key);
         $ldap->modify($attrs);
-        show_ldap_error($ldap->get_error(),sprintf(_("Setting action state (FAIstate) failed for object '%s', value was '%s'."),$key,$action));
+        if (!$ldap->success()){
+          msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $key->dn, LDAP_MOD, get_class()));
+        }
       }
     }
   }
@@ -185,69 +188,58 @@ class termgroup extends plugin
      ***************/
 
     /* Watch for events */
-    if (isset($_POST['action'])){
-      $macaddresses="";
-      $names="";
+    if ((isset($_POST['action'])) && ($this->acl_is_writeable("FAIstate")) && isset($this->mapActions[$_POST['saction']]) ){
+      $macaddresses= array();
       foreach ($this->members as $cn => $macAddress){
-        $macaddresses.= "$macAddress ";
-        $names.= "$cn ";
+        $macaddresses[]= $macAddress;
       }
 
-      if (isset($_POST['action'])){
-  
-        /* Update members fai state */
-        $this->update_term_member_FAIstate(trim($_POST['saction']));
-
-        $cmd = $this->config->search("workgeneric", "ACTIONCMD",array('tabs'));
-
-        if ($cmd == ""){
-          print_red(_("No ACTIONCMD definition found in your gosa.conf"));
-        } else {
-          exec ($cmd." ".$macaddresses." ".escapeshellarg($_POST['saction']), $dummy, $retval);
-          if ($retval != 0){
-            print_red(sprintf(_("Execution of '%s' failed!"), $cmd));
-          } else {
-            $this->didAction= TRUE;
-
-            /* Get dns from member objects. Create ldap object  */
-            $member = $this->parent->by_object['ogroup']->member;
-            $ldap = $this->config->get_ldap_link();
-            $ldap->cd($this->config->current['BASE']);
-
-            /* walk trough members and add FAIstate */ 
-            foreach($member as $dn =>  $object){
-
-              /* Get object */
-              $ldap->cat($dn,array("objectClass"));
-              $res                = $ldap->fetch();
-              $attrs              = array();
-
-              /* Add FAI state */
-              $attrs['FAIstate']  = "";
-              if(isset($this->mapActions[$_POST['saction']])){
-                $attrs['FAIstate'] = $this->mapActions[$_POST ['saction']];
-              }
-
-              /* Fix objectClass index */
-              for($i = 0; $i < $res['objectClass']['count'] ; $i ++){
-                $attrs['objectClass'][] = $res['objectClass'][$i];
-              }
-
-              /* Check if we must add the objectClass */
-              if(($attrs['FAIstate'] != "") && (!in_array("FAIobject",$attrs['objectClass']))){
-                $attrs['objectClass'][] = "FAIobject";
-              }
-
-              if($attrs['FAIstate'] == ""){
-                $attrs['FAIstate'] = array();
-              }
-
-              $ldap->cd($dn);
-              $ldap->modify($attrs);
-              show_ldap_error($ldap->get_error(), sprintf(_("Saving of system workstation/generic (FAIstate) with dn '%s' failed."),$dn));
-            }
-            $this->didAction= TRUE;
-          }
+      print_red("trigger action is missing");
+      #gosaSupportDaemon::send("gosa_trigger_action_".$_POST['saction'], "255.255.255.255", $macaddresses);
+
+      /* Update members fai state */
+      $this->update_term_member_FAIstate(trim($_POST['saction']));
+
+      $this->didAction= TRUE;
+
+      /* Get dns from member objects. Create ldap object  */
+      $member = $this->parent->by_object['ogroup']->member;
+      $ldap = $this->config->get_ldap_link();
+      $ldap->cd($this->config->current['BASE']);
+
+      /* walk trough members and add FAIstate */ 
+      if ($_POST['saction'] != "wake"){
+        foreach($member as $dn =>  $object){
+
+             /* Get object */
+             $ldap->cat($dn,array("objectClass"));
+             $res                = $ldap->fetch();
+             $attrs              = array();
+
+             /* Add FAI state */
+             $attrs['FAIstate']  = "";
+             if(isset($this->mapActions[$_POST['saction']])){
+                     $attrs['FAIstate'] = $this->mapActions[$_POST ['saction']];
+             }
+
+             /* Fix objectClass index */
+             for($i = 0; $i < $res['objectClass']['count'] ; $i ++){
+                     $attrs['objectClass'][] = $res['objectClass'][$i];
+             }
+
+             /* Check if we must add the objectClass */
+             if(($attrs['FAIstate'] != "") && (!in_array("FAIobject",$attrs['objectClass']))){
+                     $attrs['objectClass'][] = "FAIobject";
+             }
+
+             if($attrs['FAIstate'] == ""){
+                     $attrs['FAIstate'] = array();
+             }
+
+             $ldap->cd($dn);
+             $ldap->modify($attrs);
+        if (!$ldap->success()){
+          msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $dn, LDAP_MOD, get_class()));
         }
       }
     }
@@ -294,6 +286,7 @@ class termgroup extends plugin
     $smarty->assign("actions", array("halt" => _("Switch off"), "reboot" => _("Reboot"),
           "instant_update" => _("Instant update"),
           "update" => _("Scheduled update"),
+          "wake" => _("Wake"),
           "reinstall" => _("Reinstall"),
           "rescan" => _("Rescan hardware"),
           "memcheck" => _("Memory test"),
@@ -377,7 +370,9 @@ class termgroup extends plugin
     if(!$this->didAction){
       $this->handle_post_events("modify");
     }
-    show_ldap_error($ldap->get_error(), _("Saving workstation failed"));
+    if (!$ldap->success()){
+      msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, LDAP_MOD, get_class()));
+    }
 
   }