X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=gosa-plugins%2Fsystems%2Fadmin%2Fsystems%2Fclass_servGeneric.inc;h=cc451e00662f2ec79855955c178697e004c535b0;hb=bcf8cfc0e3032ad9f1aae4ade00cce5331f26316;hp=e95e36ef2926fb8a93b26de1617c2f1ea806a57f;hpb=936d923ac7fe064ca11606695988855ee8253a2b;p=gosa.git
diff --git a/gosa-plugins/systems/admin/systems/class_servGeneric.inc b/gosa-plugins/systems/admin/systems/class_servGeneric.inc
index e95e36ef2..cc451e006 100644
--- a/gosa-plugins/systems/admin/systems/class_servGeneric.inc
+++ b/gosa-plugins/systems/admin/systems/class_servGeneric.inc
@@ -32,6 +32,8 @@ class servgeneric extends plugin
var $l= "";
var $description= "";
var $orig_dn= "";
+ var $orig_cn= "";
+ var $orig_base= "";
/* attribute list for save action */
var $attributes= array("cn", "description","gotoMode");
@@ -48,6 +50,9 @@ class servgeneric extends plugin
var $fai_activated =FALSE;
var $view_logged = FALSE;
+ var $currently_installing = FALSE;
+ var $currently_installing_warned = FALSE;
+
function servgeneric (&$config, $dn= NULL, $parent= NULL)
{
/* Check if FAI is activated */
@@ -69,14 +74,29 @@ class servgeneric extends plugin
$this->base= dn2base($ui->dn);
$this->cn= "";
} else {
- $this->base= preg_replace ("/^[^,]+,[^,]+,[^,]+,/", "", $this->dn);
+ $this->base= preg_replace ("/^[^,]+,".normalizePreg(get_ou("serverou"))."/", "", $this->dn);
}
$this->netConfigDNS = new termDNS($this->config,$this,$this->objectclasses);
$this->netConfigDNS->set_acl_category("server");
$this->netConfigDNS->set_acl_base($this->base);
+
+ /* Check if this host is currently in installation process*/
+ if(class_available("gosaSupportDaemon") && class_available("DaemonEvent")){
+ $o = new gosaSupportDaemon();
+ $e_types = DaemonEvent::get_event_types(USER_EVENT | SYSTEM_EVENT | HIDDEN_EVENT);
+ $evts = $o->get_entries_by_mac(array($this->netConfigDNS->macAddress));
+ foreach($evts as $evt){
+ if(isset($e_types['QUEUED'][$evt['HEADERTAG']]) && $evt['STATUS'] == "processing" &&
+ $e_types['QUEUED'][$evt['HEADERTAG']] == "DaemonEvent_reinstall"){
+ $this->currently_installing =TRUE;
+ }
+ }
+ }
/* Save dn for later references */
- $this->orig_dn= $this->dn;
+ $this->orig_dn = $this->dn;
+ $this->orig_cn = $this->cn;
+ $this->orig_base = $this->base;
}
@@ -106,13 +126,11 @@ class servgeneric extends plugin
/* Do we represent a valid server? */
if (!$this->is_account && $this->parent === NULL){
- $display= " ".
- _("This 'dn' has no server features.")."";
+ $display= " ".
+ msgPool::noValidExtension(_("server"))."";
return($display);
}
-
-
if ((isset($_POST['action'])) && ($this->acl_is_writeable("FAIstate")) && isset($this->mapActions[$_POST['saction']]) ){
$action = $_POST['saction'];
@@ -123,18 +141,16 @@ class servgeneric extends plugin
$evt = $events['TRIGGERED']["DaemonEvent_".$action];
$tmp = new $evt['CLASS_NAME']($this->config);
$tmp->add_targets(array($this->netConfigDNS->macAddress));
- $tmp->set_type(($action == "reinstall" || $action == "update")?SCHEDULED_EVENT:TRIGGERED_EVENT);
+ $tmp->set_type(TRIGGERED_EVENT);
$o_queue = new gosaSupportDaemon();
if(!$o_queue->append($tmp)){
- 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{
msg_dialog::display(_("Event error"),
sprintf(_("Event '%s' is not available!"),$action),ERROR_DIALOG);
}
-
}
/* Base select dialog */
@@ -213,6 +229,7 @@ class servgeneric extends plugin
}
$smarty->assign("netconfig", $str);
$smarty->assign("modes", $this->modes);
+ $smarty->assign("currently_installing", $this->currently_installing);
return($smarty->fetch (get_template_path('server.tpl', TRUE)));
}
@@ -228,9 +245,13 @@ class servgeneric extends plugin
$ldap= $this->config->get_ldap_link();
$ldap->rmdir($this->dn);
+ update_accessTo($this->orig_cn,"");
+
new log("remove","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
- show_ldap_error($ldap->get_error(), sprintf(_("Removing of system server/generic with dn '%s' failed."),$this->dn));
+ if (!$ldap->success()){
+ msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, LDAP_MOD, get_class()));
+ }
/* Delete references to object groups */
$ldap->cd ($this->config->current['BASE']);
@@ -240,6 +261,13 @@ class servgeneric extends plugin
unset($og->member[$this->dn]);
$og->save ();
}
+
+ /* Clean queue form entries with this mac
+ */
+ if(class_available("gosaSupportDaemon") && tests::is_mac($this->netConfigDNS->orig_macAddress)){
+ $q = new gosaSupportDaemon();
+ $q->clean_queue_from_mac($this->netConfigDNS->orig_macAddress);
+ }
$this->handle_post_events("remove",array("macAddress" => $this->netConfigDNS->macAddress,"ipHostNumber" => $this->netConfigDNS->ipHostNumber));
}
@@ -299,6 +327,25 @@ class servgeneric extends plugin
}
}
+ /* Warn the user, that this host is currently installing */
+ if($this->currently_installing && !$this->currently_installing_warned && !preg_match("/".normalizePreg(get_ou("incomingou"))."/",$this->orig_dn)){
+
+ /* Force aborting without message dialog */
+ $message[] = "";
+ $this->currently_installing_warned = TRUE;
+ msg_dialog::display(_("Software deployment"),
+ _("This host is currently installing, if you really want to save it, press 'OK'."),
+ CONFIRM_DIALOG);
+ }
+
+ /* Check if we are allowed to create or move this object
+ */
+ if($this->orig_dn == "new" && !$this->acl_is_createable($this->base)){
+ $message[] = msgPool::permCreate();
+ }elseif($this->cn != $this->orig_cn || $this->base != $this->orig_base && !$this->acl_is_moveable($this->base)){
+ $message[] = msgPool::permMove();
+ }
+
return ($message);
}
@@ -336,28 +383,22 @@ class servgeneric extends plugin
new log("create","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
$mode= "add";
} else {
-
- /* cn is not case sensitive for ldap, but for php it is!! */
- if($this->config->current['DNMODE'] == "cn"){
- if (strtolower($this->orig_dn) != (strtolower($this->dn))){
- $this->recursive_move($this->orig_dn, $this->dn);
- plugin::save();
- }
- }else{
- if ($this->orig_dn != $this->dn){
- $this->recursive_move($this->orig_dn, $this->dn);
- plugin::save();
- }
- }
$ldap->cd($this->dn);
$this->cleanup();
$ldap->modify ($this->attrs);
new log("modify","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
+ /* Update all accessTo/trust dependencies */
+ if($this->orig_cn != $this->cn){
+ update_accessTo($this->orig_cn,$this->cn);
+ }
+
$mode= "modify";
}
- show_ldap_error($ldap->get_error(), sprintf(_("Saving of system server/generic with dn '%s' failed."),$this->dn));
+ if (!$ldap->success()){
+ msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, LDAP_DEL, get_class()));
+ }
$this->netConfigDNS->cn = $this->cn;
$this->netConfigDNS->save();
@@ -376,8 +417,7 @@ class servgeneric extends plugin
$tmp->set_type(TRIGGERED_EVENT);
$tmp->add_targets(array($this->netConfigDNS->macAddress));
if(!$o_queue->append($tmp)){
- 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);
}
}
}