summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: cd03bd1)
raw | patch | inline | side by side (parent: cd03bd1)
author | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Mon, 10 Sep 2007 07:54:29 +0000 (07:54 +0000) | ||
committer | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Mon, 10 Sep 2007 07:54:29 +0000 (07:54 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.5@7232 594d385d-05f5-0310-b6e9-bd551577e9d8
plugins/admin/systems/class_servDHCP.inc | patch | blob | history | |
plugins/admin/systems/servdhcp.tpl | patch | blob | history |
index 168d7a8e85d03bafa5b7c84029cf9166f8bfa60c..351e2112c7f993bde1e4d1933a57f94891c64cda 100644 (file)
var $orig_dn = "";
+ var $dhcp_server_list = array();
+ var $take_over_id = -1;
+
function servdhcp ($config, $dn= NULL, $parent= NULL)
{
plugin::plugin ($config, $dn, $parent);
$this->is_account= FALSE;
}
+ $this->dhcp_server_list = $this->get_list_of_dhcp_servers();
+ }
+
+
+ function take_over_service()
+ {
+
+ }
+
+
+ function get_list_of_dhcp_servers()
+ {
+ $ret = array();
+ $ldap = $this->config->get_ldap_link();
+ $ldap->cd($this->config->current['BASE']);
+ $ldap->search("(&(objectClass=goServer)(dhcpServiceDN=*))",array("dn","cn","dhcpServiceDN"));
+ while($attrs = $ldap->fetch()){
+ $ret['ENTRIES'][] = $attrs;
+ }
+ foreach($ret['ENTRIES'] as $key => $data){
+ $ret['FOR_LIST'][$key] = $data['cn'][0];
+ }
+ return($ret);
+ }
+
+
+ function get_dhcp_info_string($id)
+ {
+ $ret = "";
+ $ldap = $this->config->get_ldap_link();
+ $ldap->cd("cn=dhcp,".$this->dhcp_server_list['ENTRIES'][$id]['dn']);
+ $ldap->search("(|(objectClass=dhcpSharedNetwork)(objectClass=dhcpSubnet)(objectClass=dhcpPool)(objectClass=dhcpGroup)(objectClass=dhcpHost))",array("dn","cn"));
+ $ldap->search("(objectClass=*)",array("dn","cn"));
+ while($attrs = $ldap->fetch()){
+ $ret .= $attrs['dn']."\n";
+ }
+ return($ret);
}
/* Fill templating stuff */
$smarty= get_smarty();
+ $smarty->assign("dns_take_over",FALSE);
$display= "";
+
+ /*****************/
+ /* Handle Take Over Actions
+ /*****************/
+
+ /* Give smarty the required informations */
+ $smarty->assign("dhcp_server_list", $this->dhcp_server_list['FOR_LIST']);
+
+ /* Take over requested, save id */
+ if(isset($_POST['take_over_src']) && isset($_POST['take_over'])){
+ $id = $_POST['take_over_src'];
+ if(isset($this->dhcp_server_list['ENTRIES'][$id])){
+ $this->take_over_id = $id;
+ }
+ }
+
+ /* Abort take over action */
+ if(isset($_POST['cancel_take_over'])){
+ $this->dialog =false;
+ $this->take_over_id = -1;
+ $this->dhcp_server_list = $this->get_list_of_dhcp_servers();
+ }
+
+ /* Display informartion about take over that will be started when saving this server
+ * and hide default dhcp output
+ */
+ if($this->take_over_id != -1){
+ $this->dialog = FALSE;
+ $id = $this->take_over_id;
+ $info = $this->get_dhcp_info_string($id);
+ $smarty->assign("dns_take_over",TRUE);
+ $smarty->assign("info",$info);
+ $warning = sprintf(_("You are going to take over the dhcp setup from server '%s'."),$this->dhcp_server_list['ENTRIES'][$id]['cn'][0]);
+ $warning2 = _("The take over will be startet when you save this system. To abort this action, use the cancel button below.");
+ $smarty->assign("warning",$warning);
+ $smarty->assign("warning2",$warning2);
+ return($smarty->fetch(get_template_path('servdhcp.tpl', TRUE)));
+ }
+
+
+ /*****************/
+ /* List handling
+ /*****************/
+
/* Section Creation? */
if (isset($_POST['create_section']) && isset($_POST['section'])){
$section= $_POST['section'];
/* Save to LDAP */
function save()
{
- $ldap= $this->config->get_ldap_link();
+ /* Take over handling
+ * - Load servdhcp class and dhcpObjectCache for the source dhcp setup.
+ * - Assign dhcpObjectCache to this configuration.
+ * - Save this setup and remove source setup from ldap.
+ */
+ if($this->take_over_id != -1){
+ $id = $this->take_over_id;
+ $src = preg_replace("/cn=dhcp,/","",$this->dhcp_server_list['ENTRIES'][$id]['dn']);
+ $tmp = new servdhcp ($this->config, $src);
+ $this->orig_dn = $src;
+ $this->dhcpObjectCache = $tmp->dhcpObjectCache;
+ }
+ /* Save dhcp setttings */
+ $ldap= $this->config->get_ldap_link();
foreach ($this->dhcpObjectCache as $dn => $data){
if($this->dn != $this->orig_dn){
} else {
$this->handle_post_events("add");
}
-
+
+ /* Take over handling
+ * - Remove old dhcp config from source server
+ */
+ if($this->take_over_id != -1){
+ $id = $this->take_over_id;
+ $src = $this->dhcp_server_list['ENTRIES'][$id]['dn'];
+ $tmp = new servdhcp ($this->config, $src);
+ $tmp->remove_from_parent();
+ }
}
index 76739f150700d4718b8d26640c964f873bfcdadb..69331f271063e26bd92017569d1f53ac0436674f 100644 (file)
-<h2>{t}DHCP sections{/t}</h2>
+{if $dns_take_over}
<table summary="" width="100%">
+ <tr>
+ <td style="width:100%;vertical-align:top;">
+ <h2>{t}DHCP take over initiated{/t}</h2>
+ {$warning}
+ {t}This includes 'all' DHCP subsections that are located within this server. Please double check if your really want to do this.{/t}
+ <p>
+ {$warning2}
+ <br>
+ <input type='submit' name='cancel_take_over' value='{t}Cancel{/t}'>
+ </p>
+ <p>
+ {t}Following objects will be taken over{/t} :
+ </p>
+ <p>
+ <pre>{$info}</pre>
+ </p>
+ </td>
+ </tr>
+</table>
+{else}
+<table summary="" width="100%">
+<tr>
+ <td style="width:100%;vertical-align:top;">
+ <b>{t}Take over dhcp configuration from following server{/t}</b>
+ <select name='take_over_src'>
+ {html_options options=$dhcp_server_list}
+ </select>
+ <input type="submit" name="take_over" value="{t}Apply{/t}">
+ </td>
+</tr>
<tr>
<td style="width:100%;vertical-align:top;">
+ <h2>{t}DHCP sections{/t}</h2>
{$DhcpList}
<!-- <input type="submit" name="takeOver" value="{t}Take over{/t}" {$dhcpACL}>-->
</td>
</tr>
</table>
+{/if}