From d5b20d63aafd6e495dd4fe3b22ea1437ee7a1efc Mon Sep 17 00:00:00 2001 From: hickert Date: Thu, 9 Feb 2006 08:15:32 +0000 Subject: [PATCH] Several changes for incoming objects DNS remove_from_parent fixed Object removement fixed, wrong tab initialisation git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@2643 594d385d-05f5-0310-b6e9-bd551577e9d8 --- plugins/admin/systems/SelectDeviceType.tpl | 46 ++ .../admin/systems/class_SelectDeviceType.inc | 84 ++++ .../admin/systems/class_componentGeneric.inc | 3 +- plugins/admin/systems/class_phoneGeneric.inc | 4 +- plugins/admin/systems/class_printGeneric.inc | 4 +- plugins/admin/systems/class_servDNS.inc | 25 +- plugins/admin/systems/class_servGeneric.inc | 5 +- plugins/admin/systems/class_servKolab.inc | 3 +- .../admin/systems/class_systemManagement.inc | 428 +++++++++++++----- plugins/admin/systems/class_termDNS.inc | 52 ++- .../admin/systems/class_terminalGeneric.inc | 6 +- plugins/admin/systems/class_winGeneric.inc | 4 +- .../systems/class_workstationGeneric.inc | 3 +- plugins/admin/systems/network.tpl | 2 +- 14 files changed, 527 insertions(+), 142 deletions(-) create mode 100644 plugins/admin/systems/SelectDeviceType.tpl create mode 100644 plugins/admin/systems/class_SelectDeviceType.inc diff --git a/plugins/admin/systems/SelectDeviceType.tpl b/plugins/admin/systems/SelectDeviceType.tpl new file mode 100644 index 000000000..dddbfa272 --- /dev/null +++ b/plugins/admin/systems/SelectDeviceType.tpl @@ -0,0 +1,46 @@ +
+

+{t}This is a new system which currently has no system type defined. Please choose a system type for this entry, the depending dialog will be shown if you press 'save'. If this system should be added to an objectGroup, specify the objectgroup name and this system will be added automatically.{/t} +
+
+

+

+
+{t}Please select a system type and if prefered select a object group too.{/t} +
+
+

+
+ + + + + +
+ + + + +
+ {t}System type{/t}  + +
+
+ + + + +
+ {t}Membership in following objectGroups{/t}  + +
+
+

 

+

+ + +

diff --git a/plugins/admin/systems/class_SelectDeviceType.inc b/plugins/admin/systems/class_SelectDeviceType.inc new file mode 100644 index 000000000..66c2eed59 --- /dev/null +++ b/plugins/admin/systems/class_SelectDeviceType.inc @@ -0,0 +1,84 @@ + "Eins ist toll", "zwei" => "Zwei ist noch besser"); + + /* attribute list for save action */ + var $ignore_account= TRUE; + var $attributes= array("ObjectGroup","SystemType"); + var $objectclasses= array("whatever"); + + var $ObjectGroups = array(); + var $SystemTypes = array(); + + var $ObjectGroup = ""; + var $SystemType = ""; + + function SelectDeviceType ($config, $dn= NULL) + { + plugin::plugin ($config, $dn); + + /* Get object groups */ + $ldap = $this->config->get_ldap_link(); + $ldap->cd ($this->config->current['BASE']); + $ldap->search("(&(objectClass=gosaGroupOfNames)(cn=*))",array("cn")); + $this->ObjectGroups['none']=_("none"); + while($attrs = $ldap->fetch()){ + $this->ObjectGroups[$attrs['dn']]= $attrs['cn'][0]; + } + + $this->SystemTypes =array("server"=>_("Server"),"workstation"=>_("Workstation"),"terminal"=>_("Terminal")); + } + + function execute() + { + /* Call parent execute */ + plugin::execute(); + + /* Fill templating stuff */ + $smarty= get_smarty(); + $display= ""; + + $smarty->assign("ObjectGroups" ,$this->ObjectGroups); + $smarty->assign("ObjectGroupKeys" ,array_flip($this->ObjectGroups)); + $smarty->assign("SystemTypes" ,$this->SystemTypes); + $smarty->assign("SystemTypeKeys" ,array_flip($this->SystemTypes)); + + $smarty->assign("ObjectGroup",$this->ObjectGroup); + $smarty->assign("SystemType",$this->SystemType); + + $display.= $smarty->fetch(get_template_path('SelectDeviceType.tpl', TRUE)); + return($display); + } + + /* Save data to object */ + function save_object() + { + plugin::save_object(); + foreach($this->attributes as $attr){ + if(isset($_POST[$attr])){ + $this->$attr = $_POST[$attr]; + } + } + } + + /* Check supplied data */ + function check() + { + $message= array(); + + return ($message); + } + + /* Save to LDAP */ + function save() + { + } +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/plugins/admin/systems/class_componentGeneric.inc b/plugins/admin/systems/class_componentGeneric.inc index 164b4aa7c..9650956cb 100644 --- a/plugins/admin/systems/class_componentGeneric.inc +++ b/plugins/admin/systems/class_componentGeneric.inc @@ -70,6 +70,7 @@ class componentGeneric extends plugin function remove_from_parent() { $ldap= $this->config->get_ldap_link(); + $this->netConfigDNS->remove_from_parent(); $ldap->rmdir($this->dn); show_ldap_error($ldap->get_error()); $this->handle_post_events("remove"); @@ -82,7 +83,6 @@ class componentGeneric extends plugin unset($og->member[$this->dn]); $og->save (); } - $this->netConfigDNS->remove_from_parent(); } @@ -173,6 +173,7 @@ class componentGeneric extends plugin $this->handle_post_events("modify"); } + $this->netConfigDNS->cn = $this->cn; $this->netConfigDNS->save($this->dn); show_ldap_error($ldap->get_error()); diff --git a/plugins/admin/systems/class_phoneGeneric.inc b/plugins/admin/systems/class_phoneGeneric.inc index 97325ea67..86696b0b9 100644 --- a/plugins/admin/systems/class_phoneGeneric.inc +++ b/plugins/admin/systems/class_phoneGeneric.inc @@ -215,6 +215,7 @@ class phoneGeneric extends plugin return; } + $this->netConfigDNS->remove_from_parent(); $ldap->rmdir($this->dn); show_ldap_error($ldap->get_error()); $this->handle_post_events("remove"); @@ -227,7 +228,6 @@ class phoneGeneric extends plugin unset($og->member[$this->dn]); $og->save (); } - $this->netConfigDNS->remove_from_parent(); } @@ -365,7 +365,7 @@ class phoneGeneric extends plugin } $this->handle_post_events("modify"); } - + $this->netConfigDNS->cn = $this->cn; $this->netConfigDNS->save($this->dn); show_ldap_error($ldap->get_error()); diff --git a/plugins/admin/systems/class_printGeneric.inc b/plugins/admin/systems/class_printGeneric.inc index c5717286f..9fe834993 100644 --- a/plugins/admin/systems/class_printGeneric.inc +++ b/plugins/admin/systems/class_printGeneric.inc @@ -440,6 +440,7 @@ class printgeneric extends plugin $ldap->cat($this->dn); if(count($ldap->fetch()) ){ + $this->netConfigDNS->remove_from_parent(); $ldap->rmdir($this->dn); show_ldap_error($ldap->get_error()); $this->handle_post_events("remove"); @@ -452,8 +453,6 @@ class printgeneric extends plugin unset($og->member[$this->dn]); $og->save (); } - - $this->netConfigDNS->remove_from_parent(); } } } @@ -628,6 +627,7 @@ class printgeneric extends plugin } show_ldap_error($ldap->get_error()); + $this->netConfigDNS->cn = $this->cn; $this->netConfigDNS->save($this->dn); /* Optionally execute a command after we're done */ diff --git a/plugins/admin/systems/class_servDNS.inc b/plugins/admin/systems/class_servDNS.inc index 6039a29bb..086dc9524 100644 --- a/plugins/admin/systems/class_servDNS.inc +++ b/plugins/admin/systems/class_servDNS.inc @@ -18,10 +18,18 @@ class servdns extends plugin var $dialog = NULL; var $usedDNS = array(); + + var $orig_dn = ""; + + var $DNSinitially_was_account; + + function servdns ($config, $dn= NULL) { plugin::plugin ($config, $dn); + $this->orig_dn = $dn; + /* All types with required attrs */ $this->RecordTypes['aRecord'] = "aRecord"; // ok $this->RecordTypes['mDRecord'] = "mDRecord"; // ok @@ -47,7 +55,6 @@ class servdns extends plugin $this->RecordTypes['rRSIGRecord'] = "rRSIGRecord"; // ok $this->RecordTypes['nSECRecord'] = "nSECRecord"; // ok - $this->cn = $this->attrs['cn'][0]; $types = array(); /* Get all records */ @@ -56,7 +63,7 @@ class servdns extends plugin $ldap->search("(&(objectClass=dNSZone)(relativeDomainName=@))",array("*")); while($attrs = $ldap->fetch()){ - /* If relative domainname == cn + /* If relative domainname * Try to read dnsclass / TTl / zone */ $this->usedDNS[$attrs['dn']] = $attrs['dn']; @@ -296,12 +303,26 @@ class servdns extends plugin /* Remove dns service */ function remove_from_parent() { + if(!$this->DNSinitially_was_account){ + return; + } + $ldap = $this->config->get_ldap_link(); $ldap->cd($this->config->current['BASE']); foreach($this->usedDNS as $dn){ $ldap->cd($dn); $ldap->rmdir_recursive($dn); } + + $ldap = $this->config->get_ldap_link(); + $ldap->cd($this->orig_dn); + $ldap->search("(&(objectClass=dNSZone)(zoneName=*)(relativeDomainName=@))",array("relativeDomainName","zoneName")); + while($attr = $ldap->fetch()){ + $ldap->cd($attr['dn']); + $ldap->rmDir($attr['dn']); + } + + show_ldap_error($ldap->get_error()); } diff --git a/plugins/admin/systems/class_servGeneric.inc b/plugins/admin/systems/class_servGeneric.inc index 0c7c0d99e..883c3989d 100644 --- a/plugins/admin/systems/class_servGeneric.inc +++ b/plugins/admin/systems/class_servGeneric.inc @@ -126,6 +126,7 @@ class servgeneric extends plugin function remove_from_parent() { + $this->netConfigDNS->remove_from_parent(); $ldap= $this->config->get_ldap_link(); $ldap->rmdir($this->dn); show_ldap_error($ldap->get_error()); @@ -138,7 +139,6 @@ class servgeneric extends plugin unset($og->member[$this->dn]); $og->save (); } - $this->netConfigDNS->remove_from_parent(); $this->handle_post_events("remove"); } @@ -180,8 +180,10 @@ class servgeneric extends plugin if ($ldap->count() != 0){ while ($attrs= $ldap->fetch()){ if ($attrs['dn'] != $this->orig_dn){ + if(!preg_match("/,ou=incoming,/",$attrs['dn'])){ $message[]= sprintf (_("There is already an entry '%s' in the base choosen by you"), $this->cn); break; + } } } } @@ -235,6 +237,7 @@ class servgeneric extends plugin $ldap->modify($this->attrs); $mode= "modify"; } + $this->netConfigDNS->cn = $this->cn; $this->netConfigDNS->save($this->dn); show_ldap_error($ldap->get_error()); diff --git a/plugins/admin/systems/class_servKolab.inc b/plugins/admin/systems/class_servKolab.inc index 434ffa93f..f3bd4ef46 100644 --- a/plugins/admin/systems/class_servKolab.inc +++ b/plugins/admin/systems/class_servKolab.inc @@ -178,7 +178,8 @@ class servkolab extends plugin { /* Only modify kolabHost */ $hosts= array(); foreach ($this->kolabHost as $host){ - if ($host != $this->cn){ + + if (isset($this->cn)&&($host != $this->cn)){ $hosts[]= $host; } } diff --git a/plugins/admin/systems/class_systemManagement.inc b/plugins/admin/systems/class_systemManagement.inc index dd5a89608..7471c95d7 100644 --- a/plugins/admin/systems/class_systemManagement.inc +++ b/plugins/admin/systems/class_systemManagement.inc @@ -47,8 +47,8 @@ class systems extends plugin /* Get global filter config */ if (!is_global("terminalfilter")){ - $ui= get_userinfo(); - $base= get_base_from_people($ui->dn); + $ui = get_userinfo(); + $base = get_base_from_people($ui->dn); $terminalfilter= array("workstations" => "checked", "thins" => "checked", "winstations" => "checked", @@ -65,19 +65,24 @@ class systems extends plugin function execute() { - /* Call parent execute */ - plugin::execute(); + /* Call parent execute */ + plugin::execute(); - /* Save data */ + /******************** + Filter handling, check posted filter options and store them in our Session obejct + ********************/ + + /* Save posted filter data */ $terminalfilter= get_global("terminalfilter"); foreach( array("depselect", "user", "regex") as $type){ if (isset($_POST[$type])){ $terminalfilter[$type]= $_POST[$type]; } } + + /* Check if filter checkboxes are selected */ if (isset($_POST['depselect'])){ foreach( array("workstations", "thins", "winstations", "printers", "phones", "servers", "netdev") as $type){ - if (isset($_POST[$type])) { $terminalfilter[$type]= "checked"; } else { @@ -85,6 +90,8 @@ class systems extends plugin } } } + + /* Check for search post */ if (isset($_GET['search'])){ $s= mb_substr($_GET['search'], 0, 1, "UTF8")."*"; if ($s == "**"){ @@ -93,12 +100,16 @@ class systems extends plugin $terminalfilter['regex']= $s; } + + /******************** + Check for functional posts, edit|delete|add|... system devices + ********************/ $s_action = ""; // Contains the action to proceed $s_entry = ""; // The value for s_action $base_back = ""; // The Link for Backbutton $smarty = get_smarty(); - /* Start for New List Managment */ + /* check if base was changed */ if(isset($_GET['act'])&&($_GET['act']=="dep_open")){ $s_action="open"; $s_entry = base64_decode($_GET['dep_id']); @@ -136,13 +147,25 @@ class systems extends plugin } } - if((isset($_GET['act']))&&($_GET['act']=="edit_entry")){ - $s_action ="edit"; - $s_entry = $_GET['id']; + /* 09.02.2006 : New incoming handling ; hickert + * If someone made a systemtype and ogroup selection + * Display the new requested entry type ... servtab in case of server and so on. + */ + if(isset($_POST['SystemTypeChoosen'])){ + $s_action = "SelectedSystemType"; + $s_entry = $_POST['SystemType']; + $this->systab = NULL; } + /* remove image tags from posted entry (posts looks like this 'name_x')*/ $s_entry = preg_replace("/_.$/","",$s_entry); + /* Edit was requested by pressing the name(link) of an item */ + if((isset($_GET['act']))&&($_GET['act']=="edit_entry")){ + $s_action ="edit"; + $s_entry = $_GET['id']; + } + /* Department changed? */ if(isset($_POST['depselect']) && $_POST['depselect']){ $terminalfilter['depselect']= $_POST['depselect']; @@ -154,11 +177,11 @@ class systems extends plugin $terminalfilter['depselect']=(preg_replace("/^[^,]+,/","",$terminalfilter['depselect'])); } + /* back to the roots ^^ */ if($s_action=="root"){ $terminalfilter['depselect']=($this->config->current['BASE']); } - /* If Backbutton is Posted */ if($s_action=="back"){ $base_back = preg_replace("/^[^,]+,/","",$terminalfilter['depselect']); @@ -171,9 +194,10 @@ class systems extends plugin } } + /* Save Termfilter .... */ register_global("terminalfilter", $terminalfilter); $this->reload(); - + /* Check for exeeded sizelimit */ if (($message= check_sizelimit()) != ""){ return($message); @@ -184,17 +208,33 @@ class systems extends plugin return ($smarty->fetch(get_template_path('chooser.tpl', TRUE))); } - /* Create new default terminal */ - if (isset($_POST['create_system'])||$s_action=="newsystem") { - $this->dn= "new"; - $this->acl= array(":all"); - - if(isset($_POST['system'])){ - $sw = $_POST['system']; + /******************** + Create new system ... + ********************/ + /* Create new default terminal + * + * 09.02.2006 ; New incoming handling ; hickert + * Or create specified object of selected system type, from given incoming object + */ + if (isset($_POST['create_system'])||$s_action=="newsystem"||$s_action == "SelectedSystemType") { + + /* If the current entry is an incoming object + * $sw = System type as posted in new incoming handling dialog + */ + if($s_action == "SelectedSystemType") { + $sw = $s_entry; + $dn_backup = $this->dn; }else{ - $sw = $s_entry; + if(isset($_POST['system'])){ + $sw = $_POST['system']; + }else{ + $sw = $s_entry; + } } + $this->dn= "new"; + $this->acl= array(":all"); + switch ($sw){ case 'terminal': $this->systab= new termtabs($this->config, @@ -242,15 +282,56 @@ class systems extends plugin $this->systab->by_object['componentgeneric']->base = $_SESSION['terminalfilter']['depselect']; break; } - + + /* 09.02.2006 ; New incoming handling ; hickert. + * We must create a NEW object of given system type (Posted from SelectDeviceType). + * But we have to use the same attributes as used in incoming object, thats + * what we do here. + */ + if($s_action == "SelectedSystemType"){ + + /* Store some informations, to be able to add this object to + * To specified objectgroup and delete incoming object + */ + $_SESSION['SelectedSystemType']['dn'] = $this->dn; + $_SESSION['SelectedSystemType']['server'] = $s_entry; + $_SESSION['SelectedSystemType']['ogroup'] = $_POST['ObjectGroup']; + + /* restore dn */ + $this->dn = $dn_backup; + + /* Get properties from incoming object */ + $ldap = $this->config->get_ldap_link(); + $ldap->cd($this->dn); + $ldap->cat($this->dn); + $res = $ldap->fetch(); + + /* Unset not needed attributes */ + unset($res['dn']); + unset($res['objectClass']); + + /* Walk through all tabs and set attributes if available */ + foreach($this->systab->by_object as $name => $value){ + foreach($this->systab->by_object[$name]->attributes as $atr){ + if((isset($value))&&(isset($res[$atr]))){ + $this->systab->by_object[$name]->$atr = $res[$atr][0]; + } + } + } + } + + /* set base ... of current divlist position */ $this->systab->base = $_SESSION['terminalfilter']['depselect']; } + /******************** + Edit system ... + ********************/ + /* User wants to edit data? */ if ($s_action == "edit"){ - /* Get 'dn' from posted 'cn', must be unique */ $this->dn= $this->terminals[$s_entry]['dn']; /* Check locking, save current plugin in 'back_plugin', so @@ -270,72 +351,86 @@ class systems extends plugin /* Lock the current entry, so everyone will get the above dialog */ - add_lock ($this->dn, $this->ui->dn); switch ($type){ + case "NewDevice" : + $this->systab = new SelectDeviceType($this->config,$this->dn) ; + break; case "terminal": /* Register systab to trigger edit dialog */ $this->systab= new termtabs($this->config, $this->config->data['TABS']['TERMTABS'], $this->dn); - $this->systab->set_acl($acl); - $_SESSION['objectinfo']= $this->dn; - break; + $this->systab->set_acl($acl); + $_SESSION['objectinfo']= $this->dn; + add_lock ($this->dn, $this->ui->dn); + break; case "server": + /* Register systab to trigger edit dialog */ - $this->systab= new servtabs($this->config, - $this->config->data['TABS']['SERVTABS'], $this->dn); - $this->systab->set_acl($acl); - $_SESSION['objectinfo']= $this->dn; - break; + $this->systab= new servtabs($this->config,$this->config->data['TABS']['SERVTABS'], $this->dn); + $this->systab->set_acl($acl); + $_SESSION['objectinfo']= $this->dn; + add_lock ($this->dn, $this->ui->dn); + break; case "workstation": /* Register systab to trigger edit dialog */ $this->systab= new worktabs($this->config, $this->config->data['TABS']['WORKTABS'], $this->dn); - $this->systab->set_acl($acl); - $_SESSION['objectinfo']= $this->dn; - break; + $this->systab->set_acl($acl); + $_SESSION['objectinfo']= $this->dn; + add_lock ($this->dn, $this->ui->dn); + break; case "printer": /* Register systab to trigger edit dialog */ $this->systab= new printtabs($this->config, $this->config->data['TABS']['PRINTTABS'], $this->dn); - $this->systab->set_acl($acl); - $_SESSION['objectinfo']= $this->dn; - break; + $this->systab->set_acl($acl); + $_SESSION['objectinfo']= $this->dn; + add_lock ($this->dn, $this->ui->dn); + break; case "phone": /* Register systab to trigger edit dialog */ $this->systab= new phonetabs($this->config, $this->config->data['TABS']['PHONETABS'], $this->dn); - $this->systab->set_acl($acl); - $_SESSION['objectinfo']= $this->dn; - break; + $this->systab->set_acl($acl); + $_SESSION['objectinfo']= $this->dn; + add_lock ($this->dn, $this->ui->dn); + break; case "component": /* Register systab to trigger edit dialog */ $this->systab= new componenttabs($this->config, $this->config->data['TABS']['COMPONENTTABS'], $this->dn); - $this->systab->set_acl($acl); - $_SESSION['objectinfo']= $this->dn; - break; - + $this->systab->set_acl($acl); + $_SESSION['objectinfo']= $this->dn; + add_lock ($this->dn, $this->ui->dn); + break; + case "winstation": /* Register systab to trigger edit dialog */ $this->systab= new wintabs($this->config, $this->config->data['TABS']['WINTABS'], $this->dn); - $this->systab->set_acl($acl); - $_SESSION['objectinfo']= $this->dn; - break; + $this->systab->set_acl($acl); + $_SESSION['objectinfo']= $this->dn; + add_lock ($this->dn, $this->ui->dn); + break; default: - print_red (_("You can't edit this object type yet!")); - del_lock($this->dn); - break; + print_red (_("You can't edit this object type yet!")); + del_lock($this->dn); + break; } } + + + /******************** + Change password ... + ********************/ /* Set terminals root password */ if ($s_action=="change_pw"){ @@ -344,6 +439,11 @@ class systems extends plugin return ($smarty->fetch(get_template_path('password.tpl', TRUE))); } + + /******************** + Password cahnge finish, but check if entered data is ok + ********************/ + /* Correctly specified? */ if (isset($_POST['password_finish'])){ if ($_POST['new_password'] != $_POST['repeated_password']){ @@ -352,6 +452,10 @@ class systems extends plugin } } + /******************** + Password change finish + ********************/ + /* Change terminal password */ if (isset($_POST['password_finish']) && $_POST['new_password'] == $_POST['repeated_password']){ @@ -378,12 +482,22 @@ class systems extends plugin unset($_SESSION['objectinfo']); } + + /******************** + Delete system cancel + ********************/ + /* Delete terminal canceled? */ if (isset($_POST['delete_cancel']) || isset($_POST['password_cancel'])){ del_lock ($this->dn); unset($_SESSION['objectinfo']); } + + /******************** + Delete system, confirm dialog + ********************/ + /* Remove terminal was requested */ if ($s_action=="del"){ @@ -414,6 +528,10 @@ class systems extends plugin } } + + /******************** + Delete system, confirmed + ********************/ /* Confirmation for deletion has been passed. Terminal should be deleted. */ if (isset($_POST['delete_terminal_confirm'])){ @@ -429,38 +547,40 @@ class systems extends plugin switch ($type){ case "terminal": - $tabtype= "termtabs"; + $tabtype = "termtabs"; + $tabobj = "TERMTABS"; break; case "workstation": - $tabtype= "worktabs"; + $tabtype = "worktabs"; + $tabobj = "WORKTABS"; break; - + case "phone": - $tabtype= "phonetabs"; + $tabtype = "phonetabs"; + $tabobj = "PHONETABS"; break; case "server": - $tabtype= "servtabs"; + $tabtype = "servtabs"; + $tabobj = "SERVTABS"; break; default: -#print_red (_("You can't remove this object type yet!")); -#del_lock($this->dn); -#return; - $tabtype= "termtabs"; + $tabtype = "termtabs"; + $tabobj = "TERMTABS"; break; } /* Delete request is permitted, perform LDAP action */ if($tabtype=="phonetabs"){ $this->systab= new $tabtype($this->config, - $this->config->data['TABS']['PHONETABS'], $this->dn); + $this->config->data['TABS'][$tabobj], $this->dn); $this->systab->set_acl(array($this->acl)); $this->systab->by_object['phonegeneric']->remove_from_parent (); }else{ $this->systab= new $tabtype($this->config, - $this->config->data['TABS']['TERMTABS'], $this->dn); + $this->config->data['TABS'][$tabobj], $this->dn); $this->systab->set_acl(array($this->acl)); $this->systab->delete(); #$this->systab->by_object['termgeneric']->remove_from_parent (); @@ -484,6 +604,10 @@ class systems extends plugin del_lock ($this->dn); } + + /******************** + Edit system type finished, check if everything went ok + ********************/ /* Finish user edit is triggered by the tabulator dialog, so the user wants to save edited data. Check and save at this point. */ @@ -501,6 +625,39 @@ class systems extends plugin /* Terminal has been saved successfully, remove lock from LDAP. */ + + /* 09.02.2006 Hickert + * New System incoming behavior; you can select a system type and an ogroup membership. + * If this object is an Incoming object, $_SESSION['SelectedSystemType'] isset. + * Check if we must add the new object to an object group. + * !! Don't forget to unset the $_SESSION['SelectedSystemType']... else all edited objects + * !! will be added to the object group. + * + * If this is done, delete the old incoming entry... it is still there, because this is a new + * entry and not an edited one. + */ + if(isset($_SESSION['SelectedSystemType'])){ + $SelectedSystemType= $_SESSION['SelectedSystemType']; + unset($_SESSION['SelectedSystemType']); + if($SelectedSystemType['ogroup'] != "none"){ + $og = new ogroup($this->config,$SelectedSystemType['ogroup']); + if($og){ + $og->AddDelMembership($this->systab->dn); + } + $og->save(); + } + if(!isset($ldap)){ + $ldap = $this->config->get_ldap_link(); + } + $ldap->cd ($this->dn); + $ldap->cat($this->dn); + if(count($ldap->fetch())){ + $ldap->cd($this->dn); + $ldap->rmDir($this->dn); + } + $ldap->cd($this->config->current['BASE']); + } + if ($this->dn != "new"){ del_lock ($this->dn); } @@ -520,22 +677,40 @@ class systems extends plugin } + + /******************** + Edit system was canceled + ********************/ /* Cancel dialogs */ - if (isset($_POST['edit_cancel']) || isset($_POST['password_cancel'])){ + if (isset($_POST['edit_cancel']) || isset($_POST['password_cancel']) || isset($_POST['SystemTypeAborted'])){ if (isset($this->systab)){ del_lock ($this->systab->dn); unset ($this->systab); } $this->systab= NULL; unset($_SESSION['objectinfo']); + + /* 09.02.2006 ; New incoming handling ; hickert + * remove session object which stores our ogroup selection + * for the new incoming handling + */ + if(isset($_SESSION['SelectedSystemType'])){ + unset($_SESSION['SelectedSystemType']); + } } + + /******************** + Display edit dialog, or some other + ********************/ + /* Show tab dialog if object is present */ if ($this->systab){ $display= $this->systab->execute(); + /* Don't show buttons if tab dialog requests this */ - if (!$this->systab->by_object[$this->systab->current]->dialog){ + if ((isset($this->systab->by_object))&&(!$this->systab->by_object[$this->systab->current]->dialog)){ $display.= "

\n"; $display.= "\n"; $display.= " \n"; @@ -546,59 +721,84 @@ class systems extends plugin } - - - - - /* Prepare departments */ + /******************** + Entry handling finished (edit delete ... ) + Now the list generation is the next part of this script. + ********************/ + + /* Prepare departments, + which are shown in the listbox on top of the listbox + */ $options= ""; foreach ($this->config->idepartments as $key => $value){ - if ($terminalfilter['depselect'] == $key){ - $options.= ""; - } else { - $options.= ""; - } + if ($terminalfilter['depselect'] == $key){ + $options.= ""; + } else { + $options.= ""; + } } - /* NEW LIST MANAGMENT */ + /* NEW LIST MANAGMENT */ + + /* Create list header + */ $listhead = "

". - "  ". - "  ". - "  ". + "  ". + "  ". + "  ". "  ". - " ". - " ". - " ". - " ". - " ". - " ". - "  ". - _("Base")." ". - "  ". + " ". + " ". + " ". + " ". + " ". + " ". + "  "._("Base")." ". + " ". + "  ". "
"; + + /* Edit delete link for system types + */ $action= ""; $action.= ""; + $linkopen = "%s"; + /* Create new divlist, and add the header elements + */ $divlist = new divlist("systemstab"); + $divlist->SetSummary(_("This table displays all systems, in the selected tree.")); + $divlist->SetEntriesPerPage(0); $divlist->SetHeader(array( array("string" => " ", "attach" => "style='text-align:center;width:20px;'"), array("string" => _("System")." / "._("Department"), "attach" => "style=''"), array("string" => _("Actions"), "attach" => "style='width:60px;border-right:0px;text-align:right;'" ))); - $divlist->SetSummary(_("This table displays all systems, in the selected tree.")); - $divlist->SetEntriesPerPage(0); - - // Defining Links - $linkopen = "%s"; + /* Add departments, to be able to switch into them + */ foreach($this->departments as $key=> $val){ - + + /* Add missing entries ... */ if(!isset($this->config->departments[trim($key)])){ $this->config->departments[trim($key)]=""; } + /* check if this department contains sub-departments + Display different image in this case + */ $non_empty=""; $keys= str_replace("/","\/",$key); foreach($this->config->departments as $keyd=>$vald ){ @@ -607,13 +807,14 @@ class systems extends plugin } } + /* Add to divlist */ $field1 = array("string" => "department", "attach" => "style='text-align:center;width:20px;'"); $field2 = array("string" => sprintf($linkopen,base64_encode($key),$val), "attach" => "style=''"); $field3 = array("string" => " ", "attach" => "style='width:60px;border-right:0px;text-align:right;'"); $divlist->AddEntry(array($field1,$field2,$field3)); } - // Space + // Iamge spacer $empty =" "; // User and Template Images @@ -634,6 +835,11 @@ class systems extends plugin // Test Every Entry and generate divlist Array foreach($this->terminals as $key => $val){ // Specify Pics for Extensions + if(in_array("goLdapServer" ,$val['objectClass'])){ + + } + + /* Generate picture list, which is currently disabled */ if(in_array("goCupsServer" ,$val['objectClass'])) $cups = $img1; else $cups =$empty; if(in_array("goLogDBServer" ,$val['objectClass'])) $logdb = $img2; else $logdb =$empty; if(in_array("goSyslogServer" ,$val['objectClass'])) $syslog = $img3; else $syslog=$empty; @@ -644,7 +850,6 @@ class systems extends plugin if(in_array("goFonServer" ,$val['objectClass'])) $fon = $img8; else $fon =$empty; if(in_array("goFaxServer" ,$val['objectClass'])) $fax = $img9; else $fax =$empty; if(in_array("goLdapServer" ,$val['objectClass'])) $ldap = $img10; else $ldap =$empty; - $pics = $cups.$logdb.$syslog.$imap.$samba.$nfs.$krb.$fon.$fax.$ldap; $pics = ""; @@ -703,13 +908,12 @@ class systems extends plugin { $temp= ""; $conv= array( + "NQ" => array("select_newsystem.png",_("New System from incoming")), "D" => array("select_default.png",_("Template")), "T" => array("select_terminal.png",_("Terminal")), "L" => array("select_workstation.png",_("Workstation")), "F" => array("select_phone.png",_("Phone")), "S" => array("select_server.png",_("Server")), - "NT"=> array("select_new_terminal.png",_("New Terminal")), - "NL"=> array("select_new_workstation.png",_("New Workstation")), "W" => array("select_winstation.png",_("Winstation")), "C" => array("select_component.png",_("Network Device")), "P" => array("select_printer.png",_("Printer"))); @@ -789,7 +993,7 @@ class systems extends plugin /* Get list of terminals to be shown */ if ($terminalfilter['thins'] == "checked"){ - $termfilter= "(&(objectClass=gotoTerminal)(cn=$regex))"; + $termfilter= "(&(objectClass=goHard)(cn=$regex))"; } else { $termfilter= ""; } @@ -863,10 +1067,6 @@ class systems extends plugin get_list($this->ui->subtreeACL, "(|$workfilter)", FALSE, "ou=workstations,ou=systems,".$base, array("cn", "description", "macAddress", "objectClass", "sambaDomainName"), FALSE)); - $res= array_merge($res, - get_list($this->ui->subtreeACL, "(|$workfilter)", FALSE, "ou=incoming,".$base, - array("cn", "description", "macAddress", "objectClass", "sambaDomainName"), FALSE)); - $res= array_merge($res, get_list($this->ui->subtreeACL, "(|$winfilter)", FALSE, "ou=winstations,ou=systems,".$base, array("cn", "description", "macAddress", "objectClass", "sambaDomainName"), FALSE)); @@ -935,11 +1135,8 @@ class systems extends plugin $tmp= $value["dn"]; } if (preg_match ("/,ou=incoming,/i", $tmp)){ - if (in_array('gotoTerminal', $value['objectClass'])){ - $add= "- "._("New terminal"); - } - if (in_array('gotoWorkstation', $value['objectClass'])){ - $add= "- "._("New workstation"); + if (in_array('GOhard', $value['objectClass'])){ + $add= "- "._("New Device"); } } else { $add= ""; @@ -970,6 +1167,10 @@ class systems extends plugin $terminal['location'] = array_search($tmp, $this->config->departments); $terminal['message'] = _("Workstation template for"); } + }elseif (in_array("GOhard",$value['objectClass'])){ + $terminal = $value; + $terminal['type'] = "Q"; + $terminal['is_new'] = $add; } elseif (in_array('gotoPrinter', $value["objectClass"])){ $terminal = $value; $terminal['type'] = "P"; @@ -1023,22 +1224,25 @@ class systems extends plugin if (in_array('ieee802Device', $classes)){ $type= "component"; - } + }else if (in_array('gotoTerminal', $classes)){ $type= "terminal"; - } + }else if (in_array('gotoWorkstation', $classes)){ $type= "workstation"; - } + }else if (in_array('gotoPrinter', $classes)){ $type= "printer"; - } + }else if (in_array('goFonHardware', $classes)){ $type= "phone"; - } + }else if (in_array('goServer', $classes)){ $type= "server"; - } + }else + if (in_array('GOhard', $classes)){ + $type= "NewDevice"; + }else if (in_array('sambaAccount', $classes) || in_array('sambaSamAccount', $classes)){ $type= "winstation"; diff --git a/plugins/admin/systems/class_termDNS.inc b/plugins/admin/systems/class_termDNS.inc index 2a2e7df25..1a3b8b506 100644 --- a/plugins/admin/systems/class_termDNS.inc +++ b/plugins/admin/systems/class_termDNS.inc @@ -28,12 +28,21 @@ class termDNS extends plugin var $types = array(); var $DNSinitially_was_account = false; - function termDNS ($config, $dn,$objectClasses) + var $orig_dn =""; + + var $IPisMust = false; + var $MACisMust= false; + + function termDNS ($config, $dn,$objectClasses,$IPisMust = false) { /* We need to know which objectClasses are used, to store the ip/mac*/ $this->objectclasses= $objectClasses; plugin::plugin ($config, $dn); + $this->orig_dn= $dn; + + $this->IPisMust = $IPisMust; + /* All types with required attrs */ $this->RecordTypes['aRecord'] = "aRecord"; // ok $this->RecordTypes['mDRecord'] = "mDRecord"; // ok @@ -60,8 +69,11 @@ class termDNS extends plugin $this->RecordTypes['rRSIGRecord'] = "rRSIGRecord"; // ok $this->RecordTypes['nSECRecord'] = "nSECRecord"; // ok - /* Get all available zones */ - $this->cn = $this->attrs['cn'][0]; + echo $this->cn; + /* Get all available zones */ + if(empty($this->cn)&&(isset($this->attrs['cn'][0]))){ + $this->cn = $this->attrs['cn'][0]; + } $this->Zones = $this->get_Zones(); $types = array(); @@ -169,6 +181,7 @@ class termDNS extends plugin $smarty->assign("DNSAccount",$this->DNS_is_account); $smarty->assign("Zones",$this->Zones); $smarty->assign("ZoneKeys",($this->Zones)); + $smarty->assign("IPisMust",(($this->IPisMust)||($this->DNS_is_account))); $changeStateForRecords =""; $smarty->assign("records",$this->generateRecordsList(&$changeStateForRecords)); $smarty->assign("changeStateForRecords",$changeStateForRecords); @@ -180,7 +193,13 @@ class termDNS extends plugin function remove_from_parent() { - /* This cannot be removed... */ + $ldap = $this->config->get_ldap_link(); + $ldap->cd($this->orig_dn); + $ldap->search("(&(objectClass=dNSZone)(zoneName=*)(!(relativeDomainName=@)))",array("relativeDomainName","zoneName")); + while($attr = $ldap->fetch()){ + $ldap->cd($attr['dn']); + $ldap->rmDir($attr['dn']); + } } /* Save data to object */ @@ -234,20 +253,23 @@ class termDNS extends plugin { $message= array(); - /* Check if mac is empty */ - if ($this->macAddress == "" && chkacl ($this->acl, "macAddress") == ""){ - $message[]= _("The required field 'MAC-address' is not set."); - } + + if(($this->IPisMust)||($this->DNS_is_account)){ + /* Check if ip is empty */ + if ($this->ipHostNumber == "" && chkacl ($this->acl, "ipHostNumber") == ""){ + $message[]= _("The required field 'IP-address' is not set."); + } - /* Check if ip is empty */ - if ($this->ipHostNumber == "" && chkacl ($this->acl, "ipHostNumber") == ""){ - $message[]= _("The required field 'IP-address' is not set."); + /* check if given ip is valid ip*/ + $num="(\\d|[1-9]\\d|1\\d\\d|2[0-4]\\d|25[0-5])"; + if (!preg_match("/^$num\\.$num\\.$num\\.$num$/", $this->ipHostNumber)){ + $message[]= _("Wrong IP format in field IP-address."); + } } - /* check if given ip is valid ip*/ - $num="(\\d|[1-9]\\d|1\\d\\d|2[0-4]\\d|25[0-5])"; - if (!preg_match("/^$num\\.$num\\.$num\\.$num$/", $this->ipHostNumber)){ - $message[]= _("Wrong IP format in field IP-address."); + /* Check if mac is empty */ + if ($this->macAddress == "" && chkacl ($this->acl, "macAddress") == ""){ + $message[]= _("The required field 'MAC-address' is not set."); } /* Check if given mac is valid mac */ diff --git a/plugins/admin/systems/class_terminalGeneric.inc b/plugins/admin/systems/class_terminalGeneric.inc index e6a949ab3..bfa881a31 100644 --- a/plugins/admin/systems/class_terminalGeneric.inc +++ b/plugins/admin/systems/class_terminalGeneric.inc @@ -194,8 +194,8 @@ class termgeneric extends plugin $ldap->cd($this->dn); $ldap->cat($this->dn); if($ldap->count()){ - - $ldap->rmdir($this->dn); + $this->netConfigDNS->remove_from_parent(); + $ldap->rmDir($this->dn); show_ldap_error($ldap->get_error()); /* Optionally execute a command after we're done */ @@ -209,7 +209,6 @@ class termgeneric extends plugin unset($og->member[$this->dn]); $og->save (); } - $this->netConfigDNS->remove_from_parent(); } } @@ -319,6 +318,7 @@ class termgeneric extends plugin $ldap->modify($this->attrs); $this->handle_post_events("modify"); } + $this->netConfigDNS->cn = $this->cn; $this->netConfigDNS->save($this->dn); show_ldap_error($ldap->get_error()); diff --git a/plugins/admin/systems/class_winGeneric.inc b/plugins/admin/systems/class_winGeneric.inc index 4fc4ab92e..b2002b79e 100644 --- a/plugins/admin/systems/class_winGeneric.inc +++ b/plugins/admin/systems/class_winGeneric.inc @@ -95,6 +95,7 @@ class wingeneric extends plugin function remove_from_parent() { + $this->netConfigDNS->remove_from_parent(); $ldap= $this->config->get_ldap_link(); $ldap->rmdir($this->dn); show_ldap_error($ldap->get_error()); @@ -108,7 +109,6 @@ class wingeneric extends plugin unset($og->member[$this->dn]); $og->save (); } - $this->netConfigDNS->remove_from_parent(); } @@ -189,6 +189,8 @@ class wingeneric extends plugin $ldap->modify($this->attrs); $this->handle_post_events("modify"); } + + $this->netConfigDNS->cn = $this->cn; $this->netConfigDNS->save($this->dn); show_ldap_error($ldap->get_error()); diff --git a/plugins/admin/systems/class_workstationGeneric.inc b/plugins/admin/systems/class_workstationGeneric.inc index 88abf0466..1c81a6c1f 100644 --- a/plugins/admin/systems/class_workstationGeneric.inc +++ b/plugins/admin/systems/class_workstationGeneric.inc @@ -158,6 +158,7 @@ class workgeneric extends plugin function remove_from_parent() { + $this->netConfigDNS->remove_from_parent(); $ldap= $this->config->get_ldap_link(); $ldap->rmdir($this->dn); show_ldap_error($ldap->get_error()); @@ -173,7 +174,6 @@ class workgeneric extends plugin unset($og->member[$this->dn]); $og->save (); } - $this->netConfigDNS->remove_from_parent(); } @@ -281,6 +281,7 @@ class workgeneric extends plugin $this->handle_post_events("modify"); } } + $this->netConfigDNS->cn = $this->cn; $this->netConfigDNS->save($this->dn); show_ldap_error($ldap->get_error()); } diff --git a/plugins/admin/systems/network.tpl b/plugins/admin/systems/network.tpl index 8a9c50342..467a07488 100644 --- a/plugins/admin/systems/network.tpl +++ b/plugins/admin/systems/network.tpl @@ -5,7 +5,7 @@ - +
-- 2.30.2