X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=plugins%2Fadmin%2Fogroups%2Fclass_termgroup.inc;h=61e5c21764bd5baec5bdf639a313ceaa931bbb8f;hb=bff18a7c96f757ca1aefdff3ab57dc385d69b5dc;hp=046a6906d9b333846893299bf68e44fd8a6a085c;hpb=e9f2caf5ea6297d9f14adeb07c4c1f0ae160a00d;p=gosa.git diff --git a/plugins/admin/ogroups/class_termgroup.inc b/plugins/admin/ogroups/class_termgroup.inc index 046a6906d..61e5c2176 100644 --- a/plugins/admin/ogroups/class_termgroup.inc +++ b/plugins/admin/ogroups/class_termgroup.inc @@ -19,14 +19,23 @@ class termgroup extends plugin var $orig_dn = ""; var $didAction = FALSE; + var $mapActions = array("reboot" => "localboot", + "instant_update" => "softupdate", + "update" => "scheduledupdate", + "reinstall" => "install", + "rescan" => "", + "memcheck" => "memcheck", + "sysinfo" => "sysinfo"); - function termgroup ($config, $dn= NULL) + var $CopyPasteVars = array("gotoNtpServers","modes","inheritTimeServer"); + + function termgroup ($config, $dn= NULL, $parent= NULL) { /*************** Some initialisations ***************/ - plugin::plugin($config, $dn); + plugin::plugin($config, $dn, $parent); $ldap= $config->get_ldap_link(); @@ -129,6 +138,51 @@ 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->objcache; + + /* 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($og->member 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 */ @@ -148,7 +202,11 @@ class termgroup extends plugin $names.= "$cn "; } - if (isset($_POST['action'])){ + if (isset($_POST['action']) && $this->acl == "#all#"){ + + /* 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")); @@ -169,12 +227,12 @@ class termgroup extends plugin ***************/ /* Add new ntp Server to our list */ - if((isset($_POST['addNtpServer'])) && (isset($_POST['gotoNtpServers']))){ + if((isset($_POST['addNtpServer'])) && (isset($_POST['gotoNtpServers'])) && $this->acl == "#all#"){ $this->gotoNtpServer[$_POST['gotoNtpServers']] = $_POST['gotoNtpServers']; } /* Delete selected NtpServer for list of used servers */ - if((isset($_POST['delNtpServer'])) && (isset($_POST['gotoNtpServerSelected']))){ + if((isset($_POST['delNtpServer'])) && (isset($_POST['gotoNtpServerSelected'])) && $this->acl == "#all#"){ foreach($_POST['gotoNtpServerSelected'] as $name){ unset($this->gotoNtpServer[$name]); } @@ -210,7 +268,6 @@ class termgroup extends plugin $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')); $smarty->assign("gotoNtpServers",$this->gotoNtpServers); $smarty->assign("syslogservers", $this->config->data['SERVERS']['SYSLOG']);