From: hickert Date: Mon, 11 Sep 2006 10:14:20 +0000 (+0000) Subject: Added ability to change FAIstate via ogroup X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=b034f9b35a7b197429c063af707e5a20297660ac;p=gosa.git Added ability to change FAIstate via ogroup git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.5@4638 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/plugins/admin/ogroups/class_termgroup.inc b/plugins/admin/ogroups/class_termgroup.inc index e0bde96a5..967ebc6f8 100644 --- a/plugins/admin/ogroups/class_termgroup.inc +++ b/plugins/admin/ogroups/class_termgroup.inc @@ -19,6 +19,14 @@ class termgroup extends plugin var $orig_dn = ""; var $didAction = FALSE; + var $mapActions = array("reboot" => "localboot", + "instant_update" => "softupdate", + "update" => "sceduledupdate", + "reinstall" => "install", + "rescan" => "", + "memcheck" => "memcheck", + "sysinfo" => "sysinfo"); + function termgroup ($config, $dn= NULL) { @@ -129,6 +137,52 @@ class termgroup extends plugin $this->handle_post_events("remove"); } + + function update_term_member_FAIstate($act) + { + /* Get required informations */ + $og = $this->parent->by_object['ogroup']; + $allobs = $og->allobjects; + $mem = $og->member; + + /* Get correct value for FAIstate */ + $action = $this->mapActions[$act]; + + /* Get ldap connection */ + $ldap = $this->config->get_ldap_link(); + $ldap->cd ($this->config->current['BASE']); + + /* Foreach member of mthis ogroup ... */ + foreach($mem as $key ){ + + /* check objectClasses and create attributes array */ + $attrs = array("FAIstate"=>$action); + for($i = 0; $i < $allobs[$key]['objectClass']['count'] ; $i ++){ + $attrs['objectClass'][] = $allobs[$key]['objectClass'][$i]; + } + if(($attrs['FAIstate'] != "") && (!in_array("FAIobject",$attrs['objectClass']))){ + $attrs['objectClass'][] = "FAIobject"; + } + if($attrs['FAIstate'] == ""){ + $attrs['FAIstate'] = array(); + } + + /* If this objects is workstation,terminal or server upodate FAIstate */ + 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(!preg_match("/success/i",$ldap->get_error())) { + gosa_log("FAILED !! Updating FAIstate to '".$action."' : ".$key); + }else{ + gosa_log("OK. Updating FAIstate to '".$action."' : ".$key); + } + } + } + } + + function execute() { /* Call parent execute */ @@ -149,6 +203,10 @@ class termgroup extends plugin } if (isset($_POST['action'])){ + + /* Update members fai state */ + $this->update_term_member_FAIstate(trim($_POST['saction'])); + $cmd= search_config($this->config->data['TABS'], "workgeneric", "ACTIONCMD"); if ($cmd == ""){ print_red(_("No ACTIONCMD definition found in your gosa.conf"));