From f25d503d1f1195544b02fae075effc7f4c5e597b Mon Sep 17 00:00:00 2001 From: hickert Date: Mon, 3 Jul 2006 04:01:54 +0000 Subject: [PATCH] Set action (FAIstate) to termgroup git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@4013 594d385d-05f5-0310-b6e9-bd551577e9d8 --- plugins/admin/ogroups/class_termgroup.inc | 73 ++++++++++++++++++----- 1 file changed, 59 insertions(+), 14 deletions(-) diff --git a/plugins/admin/ogroups/class_termgroup.inc b/plugins/admin/ogroups/class_termgroup.inc index 7a218d624..6f9b053ab 100644 --- a/plugins/admin/ogroups/class_termgroup.inc +++ b/plugins/admin/ogroups/class_termgroup.inc @@ -15,9 +15,16 @@ class termgroup extends plugin var $modes = array(); var $inheritTimeServer = true; var $acl ; - var $is_account = true; - var $orig_dn = ""; - var $didAction = FALSE; + var $is_account = true; + var $orig_dn = ""; + var $didAction = FALSE; + var $mapActions = array("reboot" => "", + "instant_update" => "softupdate", + "update" => "sceduledupdate", + "reinstall" => "install", + "rescan" => "", + "memcheck" => "memcheck", + "sysinfo" => "sysinfo"); function termgroup ($config, $dn= NULL) @@ -37,8 +44,8 @@ class termgroup extends plugin $this->modes["active"]= _("Activated"); $this->modes["locked"]= _("Locked"); - $this->modes["memcheck"]= _("Memory test"); - $this->modes["sysinfo"]= _("System analysis"); +// $this->modes["memcheck"]= _("Memory test"); +// $this->modes["sysinfo"]= _("System analysis"); $this->orig_dn = $this->dn; @@ -150,6 +157,7 @@ class termgroup extends plugin if (isset($_POST['action'])){ $cmd= search_config($this->config->data['TABS'], "workgeneric", "ACTIONCMD"); + if ($cmd == ""){ print_red(_("No ACTIONCMD definition found in your gosa.conf")); } else { @@ -158,6 +166,45 @@ class termgroup extends plugin 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; } } } @@ -199,18 +246,16 @@ class termgroup extends plugin $smarty->assign($val."ACL", chkacl($this->acl, $val)); } - /* Check if workstation is online */ - $smarty->assign("actions", array( - "halt" => _("Switch off"), - "reboot" => _("Reboot"), - "instant_update" => _("Instant update"), - "update" => _("Scheduled update"), - "reinstall" => _("Reinstall"), - "rescan" => _("Rescan hardware"))); + $smarty->assign("actions", array("halt" => _("Switch off"), "reboot" => _("Reboot"), + "instant_update" => _("Instant update"), + "update" => _("Scheduled update"), + "reinstall" => _("Reinstall"), + "rescan" => _("Rescan hardware"), + "memcheck" => _("Memory test"), + "sysinfo" => _("System analysis"))); $smarty->assign("inheritTimeServer",$this->inheritTimeServer); $smarty->assign("modes", $this->modes); - $smarty->assign("actions", array("wake" => _("Wake up"), "halt" => _("Switch off"), "reboot" => _("Reboot"))); $smarty->assign("actionACL", chkacl($this->acl, 'action')); $tmp = array(); -- 2.30.2