1 <?php
3 class servdhcp extends goService
4 {
5 /* attribute list for save action */
6 var $attributes= array("dhcpServiceDN");
7 var $objectclasses= array("dhcpServer");
8 var $conflicts = array("servdhcp");
9 var $dhcpServiceDN= "";
11 /* Section storage */
12 var $dhcpSections= array();
13 var $dhcpObjectCache= array();
14 var $current_object= "";
15 var $types= array();
16 var $serviceDN= "";
18 var $quote_option = array("domain-name");
20 var $orig_dn = "";
22 var $dhcp_server_list = array("ENTRIES"=> array(),"FOR_LIST"=> array());
23 var $take_over_id = -1;
24 var $display_warning = TRUE;
26 function servdhcp (&$config, $dn= NULL, $parent= NULL)
27 {
28 plugin::plugin ($config, $dn, $parent);
30 $this->serviceDN = "cn=dhcp,".$dn;
31 $this->orig_dn = $dn;
33 $this->DisplayName = _("DHCP service");
35 $this->types= array( "dhcpLog" => _("Logging"),
36 "dhcpService" => _("Global options"),
37 "dhcpClass" => _("Class"),
38 "dhcpSubClass" => _("Subclass"),
39 "dhcpHost" => _("Host"),
40 "dhcpGroup" => _("Group"),
41 "dhcpPool" => _("Pool"),
42 "dhcpSubnet" => _("Subnet"),
43 "dhcpFailOverPeer" => _("Failover peer"),
44 "dhcpSharedNetwork" => _("Shared network"));
47 /* Backport: PHP4 compatibility */
48 foreach($this->types as $type => $translation){
49 $this->types[strtolower($type)] = $translation;
50 }
52 /* Load information about available services */
53 $this->reload();
54 if (!count($this->dhcpSections)){
55 $this->is_account= FALSE;
56 $this->dhcp_server_list = $this->get_list_of_dhcp_servers();
57 }
58 }
61 function execute()
62 {
63 /* Call parent execute */
64 plugin::execute();
66 /* Fill templating stuff */
67 $smarty= get_smarty();
68 $smarty->assign("dns_take_over",FALSE);
69 $display= "";
72 /*****************/
73 /* Handle Take Over Actions
74 /*****************/
76 /* Give smarty the required informations */
77 $smarty->assign("dhcp_server_list", $this->dhcp_server_list['FOR_LIST']);
78 $smarty->assign("dhcp_server_list_cnt", count($this->dhcp_server_list['FOR_LIST']));
80 /* Take over requested, save id */
81 if(isset($_POST['take_over_src']) && isset($_POST['take_over'])){
82 $id = $_POST['take_over_src'];
83 if(isset($this->dhcp_server_list['ENTRIES'][$id])){
84 $this->take_over_id = $id;
85 }
86 }
88 /* Abort take over action */
89 if(isset($_POST['cancel_take_over'])){
90 $this->dialog =false;
91 $this->take_over_id = -1;
92 $this->dhcp_server_list = $this->get_list_of_dhcp_servers();
93 }
95 /* Display informartion about take over that will be started when saving this server
96 * and hide default dhcp output
97 */
98 if($this->take_over_id != -1){
100 $this->dialog = FALSE;
101 $id = $this->take_over_id;
102 $smarty->assign("dns_take_over",TRUE);
103 $warning = sprintf(_("You have requested a migration of the DHCP setup from server '%s' to the current one."),
104 $this->dhcp_server_list['ENTRIES'][$id]['cn'][0]);
105 $warning.= " "._("The migration will be started when you save this system.");
107 if($this->display_warning){
108 msg_dialog::display(_("Warning"), $warning, WARNING_DIALOG);
109 $this->display_warning = FALSE;
110 }
111 return($smarty->fetch(get_template_path('servdhcp.tpl', TRUE, dirname(__FILE__))));
112 }
115 /*****************/
116 /* List handling
117 /*****************/
119 /* Section Creation? */
120 if (isset($_POST['create_section']) && isset($_POST['section'])){
121 $section= $_POST['section'];
122 $tmp = new dhcpNewSectionDialog(NULL);
123 if (isset($tmp->sectionMap[$section])){
124 $this->dialog= new $section($this,$this->current_object);
125 $this->current_object= "";
126 } else {
127 $this->dialog= FALSE;
128 }
129 }
131 /* Cancel section creation? */
132 if (isset($_POST['cancel_section']) || isset($_POST['cancel_dhcp'])){
133 $this->dialog= FALSE;
134 }
136 /* Save changes */
137 if (isset($_POST['save_dhcp'])){
138 $this->dialog->save_object();
139 $messages= $this->dialog->check();
140 if (count($messages)){
141 msg_dialog::displayChecks($messages);
142 } else {
143 $dn= $this->dialog->dn;
144 $class= get_class($this->dialog);
145 $type= $this->types[$class];
146 if(empty($this->serviceDN)){
147 $indent= substr_count(preg_replace("/".$this->dn."/", '', $dn), ",") -1;
148 }else{
149 $indent= substr_count(preg_replace("/".$this->serviceDN."/", '', $dn), ",");
150 }
151 $spaces= "";
152 for ($i= 0; $i<$indent; $i++){
153 $spaces.= " ";
154 }
155 $data= $this->dialog->save();
156 if ($this->current_object == ""){
158 /* New object */
159 $newsects= array();
160 foreach ($this->dhcpSections as $key => $dsc){
161 $newsects[$key]= $dsc;
162 if ($key == $dn){
163 $spaces.= " ";
164 $newsects[$data['dn']]= "$spaces$type '".preg_replace('/^[^=]+=([^,]+),.*$/', '\1', $data['dn'])."'";
165 }
166 }
167 $this->dhcpObjectCache[$data['dn']]= $data;
168 $this->dhcpSections= $newsects;
169 } else {
170 if ($dn != $data['dn']){
171 /* Old object, new name */
172 $this->dhcpObjectCache[$dn]= array();
173 $this->dhcpObjectCache[$data['dn']]= $data;
175 /* If we renamed a section, we've to rename a couple of objects, too */
176 foreach ($this->dhcpObjectCache as $key => $dsc){
177 if (preg_match("/,$dn$/", $key)){
178 $new_dn= preg_replace("/,$dn$/", ",".$data['dn'], $key);
179 $dsc['MODIFIED']= TRUE;
180 $this->dhcpObjectCache[$new_dn]= $dsc;
181 unset($this->dhcpObjectCache[$key]);
182 }
183 }
184 $newsects= array();
185 foreach ($this->dhcpSections as $key => $dsc){
186 if ($key == $dn){
187 $newsects[$data['dn']]= "$spaces$type '".preg_replace('/^[^=]+=([^,]+),.*$/', '\1', $data['dn'])."'";
188 continue;
189 }
190 if (preg_match("/,$dn$/", $key)){
191 $new_dn= preg_replace("/,$dn$/", ",".$data['dn'], $key);
192 $newsects[$new_dn]= $dsc;
193 } else {
194 $newsects[$key]= $dsc;
195 }
196 }
197 $this->dhcpSections= $newsects;
199 } else {
200 /* Old object, old name */
201 $this->dhcpObjectCache[$data['dn']]= $data;
202 }
203 }
204 $this->dialog= FALSE;
205 }
206 }
208 /* Remove section? */
209 if (isset($_POST['delete_dhcp_confirm'])){
210 if ($this->acl_is_removeable()){
211 unset($this->dhcpSections[$this->current_object]);
212 unset($this->dhcpObjectCache[$this->current_object]);
213 $this->dhcpObjectCache[$this->current_object]= array();
214 foreach ($this->dhcpSections as $key => $value){
215 if (preg_match("/".$this->current_object."$/", $key)){
216 unset($this->dhcpSections[$key]);
217 unset($this->dhcpObjectCache[$key]);
218 $this->dhcpObjectCache[$key]= array();
219 }
220 }
221 } else {
222 msg_dialog::display(_("Permission error"), msgPool::permDelete(), ERROR_DIALOG);
223 }
224 $this->dialog= FALSE;
225 }
227 /* Look for post entries */
228 foreach($_POST as $name => $value){
230 /* Insert new section? */
231 if (preg_match('/^insertDhcp_.*_x$/', $name)){
232 $dn= base64_decode(preg_replace('/^insertDhcp_([^_]+)_x$/', '\1', $name));
233 if (isset($this->dhcpObjectCache[$dn])){
234 $this->dialog= new dhcpNewSectionDialog($this->objectType($dn));
235 $this->current_object= $dn;
236 $this->dialog->acl= $this->acl;
237 }
238 }
240 /* Edit section? */
241 if (preg_match('/^editDhcp_.*_x$/', $name)){
242 $dn= base64_decode(preg_replace('/^editDhcp_([^_]+)_x$/', '\1', $name));
243 if (isset($this->dhcpObjectCache[$dn])){
244 $section= $this->objectType($dn);
245 $this->current_object= $dn;
246 $this->dialog= new $section($this,$this->dhcpObjectCache[$dn]);
247 }
248 }
250 /* Remove section? */
251 if (preg_match('/^delDhcp_.*_x$/', $name)){
252 $dn= base64_decode(preg_replace('/^delDhcp_([^_]+)_x$/', '\1', $name));
253 if (isset($this->dhcpObjectCache[$dn])){
254 $this->current_object= $dn;
255 $this->dialog= 1;
256 $smarty->assign("warning", msgPool::deleteInfo(LDAP::fix($dn),_("DHCP section")));
257 return($smarty->fetch(get_template_path('remove_dhcp.tpl', TRUE, dirname(__FILE__))));
258 }
259 }
261 }
263 if(isset($_GET['act']) && $_GET['act']=="edit" && isset($_GET['id'])){
264 $dn = base64_decode($_GET['id']);
265 if (isset($this->dhcpObjectCache[$dn])){
266 $section= $this->objectType($dn);
267 $this->current_object= $dn;
268 $this->dialog= new $section($this,$this->dhcpObjectCache[$dn]);
269 }
270 }
273 if(isset($_GET['act']) && $_GET['act']=="edit" && isset($_GET['id'])){
274 $dn = base64_decode($_GET['id']);
275 if (isset($this->dhcpObjectCache[$dn])){
276 $section= $this->objectType($dn);
277 $this->current_object= $dn;
278 $this->dialog= new $section($this,$this->dhcpObjectCache[$dn]);
279 }
280 }
283 /* Do we need to flip is_account state? */
284 if (isset($_POST['modify_state'])){
285 $this->is_account= !$this->is_account;
286 }
288 /* Show tab dialog headers */
289 if ($this->is_account){
290 if (!count($this->dhcpObjectCache)){
291 $attrs= array();
292 $attrs['dn']= 'cn=dhcp,'.$this->dn;
293 $attrs['cn']= array('dhcp');
294 $attrs['objectClass']= array('top', 'dhcpService');
295 $attrs['dhcpPrimaryDN']= array($this->dn);
296 $attrs['dhcpStatements']= array("default-lease-time 600",
297 "max-lease-time 1200",
298 "authoritative",
299 "ddns-update-style none");
300 $attrs['MODIFIED']= TRUE;
301 $this->dhcpSections['cn=dhcp,'.$this->dn]= _("Global options");
302 $this->dhcpObjectCache['cn=dhcp,'.$this->dn]= $attrs;
303 }
305 } else {
306 return ($display);
307 }
310 /* Show dialog
311 */
312 if(isset($this->dialog) && is_object($this->dialog)){
313 $this->dialog->save_object();
314 $this->dialog->parent = $this;
315 return($this->dialog->execute());
316 }
318 /* Create Listbox with existing Zones
319 */
320 $DhcpList = new divSelectBox("dhcpSections");
321 $DhcpList->SetHeight(400);
323 /* Add entries to divlist
324 */
325 $editImgIns = "<input type='image' src='images/lists/new.png' name='insertDhcp_%s' title='"._("Insert new DHCP section")."'>".
326 "<input type='image' src='images/lists/edit.png' name='editDhcp_%s' title='"._("Edit DHCP section")."'>".
327 "<input type='image' src='images/lists/trash.png' name='delDhcp_%s' title='"._("Remove DHCP section")."'>";
328 $editImgInsNoDel = "<input type='image' src='images/lists/new.png' name='insertDhcp_%s' title='"._("Insert new DHCP section")."'>".
329 "<input type='image' src='images/lists/edit.png' name='editDhcp_%s' title='"._("Edit DHCP section")."'>";
330 $editImg = "<input type='image' src='images/lists/edit.png' name='editDhcp_%s' title='"._("Edit DHCP section")."'>".
331 "<input type='image' src='images/lists/trash.png' name='delDhcp_%s' title='"._("Remove DHCP section")."'>";
333 $tmp = new dhcpNewSectionDialog(NULL);
334 foreach($this->dhcpSections as $section => $values ){
336 $values = "<a href='?plug=".$_GET['plug']."&act=edit&id=".base64_encode($section)."'>".$values."</a>";
338 if (count($tmp->sectionMap[$this->objectType($section)])){
339 if ($this->objectType($section) == "dhcpService"){
340 $DhcpList->AddEntry(array(
341 array("string" => $values),
342 array("string" => str_replace("%s",base64_encode($section),$editImgInsNoDel), "attach" => "style='text-align:right;'")
343 ));
344 } else {
345 $DhcpList->AddEntry(array(
346 array("string" => $values),
347 array("string" => str_replace("%s",base64_encode($section),$editImgIns), "attach" => "style='text-align:right;'")
348 ));
349 }
350 } else {
351 $DhcpList->AddEntry(array(
352 array("string" => $values),
353 array("string" => str_replace("%s",base64_encode($section),$editImg), "attach" => "style='text-align:right;'")
354 ));
355 }
356 }
358 /* Display tempalte */
359 $smarty->assign("DhcpList",$DhcpList->DrawList());
360 $display.= $smarty->fetch(get_template_path('servdhcp.tpl', TRUE, dirname(__FILE__)));
361 return($display);
362 }
365 function remove_from_parent()
366 {
367 /* Cancel if there's nothing to do here */
368 if (!$this->initially_was_account){
369 return;
370 }
372 /* Remove subtrees */
373 $ldap= $this->config->get_ldap_link();
374 foreach ($this->dhcpObjectCache as $dn => $content){
375 if ($this->objectType($dn) == 'dhcpService'){
376 $ldap->rmdir_recursive($dn);
377 if (!$ldap->success()){
378 msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $dn, LDAP_DEL, get_class()));
379 }
380 }
381 }
383 /* Remove from self */
384 $ldap= $this->config->get_ldap_link();
386 /* Remove and write to LDAP */
387 plugin::remove_from_parent();
389 @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, $this->attributes, "Save");
390 $ldap->cd($this->dn);
391 $this->cleanup();
392 $ldap->modify ($this->attrs);
394 if (!$ldap->success()){
395 msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, LDAP_MOD, get_class()));
396 }
398 /* Optionally execute a command after we're done */
399 $this->handle_post_events("remove");
400 }
403 /* Save data to object */
404 function save_object()
405 {
406 plugin::save_object();
407 }
410 /* Check supplied data */
411 function check()
412 {
413 /* Call common method to give check the hook */
414 $message= plugin::check();
416 return ($message);
417 }
420 /* Save to LDAP */
421 function save()
422 {
423 /* Take over handling
424 * - Load servdhcp class and dhcpObjectCache for the source dhcp setup.
425 * - Assign dhcpObjectCache to this configuration.
426 * - Save this setup and remove source setup from ldap.
427 */
428 if($this->take_over_id != -1){
429 $id = $this->take_over_id;
430 $src = preg_replace("/cn=dhcp,/","",$this->dhcp_server_list['ENTRIES'][$id]['dn']);
431 $tmp = new servdhcp ($this->config, $src);
432 $this->orig_dn = $src;
433 $this->dhcpObjectCache = $tmp->dhcpObjectCache;
434 }
436 /* Save dhcp setttings */
437 $ldap= $this->config->get_ldap_link();
438 foreach ($this->dhcpObjectCache as $dn => $data){
440 if($this->dn != $this->orig_dn){
441 $dn = preg_replace("/".preg_quote($this->orig_dn, '/')."$/i",$this->dn,$dn);
442 }
444 /* Remove entry? */
445 if (count($data) == 0){
446 /* Check if exists, then remove... */
447 if($ldap->cat($dn)){
448 $ldap->rmdir_recursive($dn);
449 if (!$ldap->success()){
450 msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $dn, LDAP_MOD, get_class()));
451 }
452 }
453 continue;
454 }
456 /* Opdate dhcp option 'server-name' to actual server name */
457 if($this->dn != $this->orig_dn){
458 $fixed = FALSE;
459 foreach(array("dhcpHost","dhcpSubnet","dhcpGroup","dhcpSharedNetwork") as $object){
460 if(in_array($object,$data['objectClass']) && isset($data['dhcpOption'])){
461 foreach($data['dhcpOption'] as $key => $option){
462 if(preg_match("/^server-name /",$option)){
463 $data['dhcpOption'][$key] = "server-name ".$this->cn;
464 $data['MODIFIED'] = TRUE;
465 break;
466 }
467 }
468 }
470 /* Skip next loops if entry is updated */
471 if($fixed){
472 break;
473 }
474 }
475 }
477 /* Modify existing entry? */
478 if (isset($data['MODIFIED']) || $this->orig_dn != $this->dn){
480 if($ldap->cat($dn)){
481 $modify= TRUE;
482 } else {
483 $modify= FALSE;
484 }
486 /* Build new entry */
487 $attrs= array();
488 foreach ($data as $attribute => $values){
489 if ($attribute == "MODIFIED" || $attribute == "dn"){
490 continue;
491 }
493 if(in_array($attribute,array("dhcpPrimaryDN","dhcpSecondaryDN","dhcpServerDN","dhcpFailOverPeerDN"))){
494 foreach($values as $v_key => $value){
495 $values[$v_key] = preg_replace("/".preg_quote($this->orig_dn, '/')."$/i",$this->dn,$value);
496 }
497 }
499 if (count($values)){
501 if($attribute == "dhcpOption"){
502 foreach($values as $key => $value){
503 $option_name = trim(preg_replace("/[^ ]*$/","",$value));
504 $option_value= trim(preg_replace("/^[^ ]*/","",$value));
505 if(in_array($option_name,$this->quote_option)){
506 $values[$key] = $option_name." \"".$option_value."\"";
507 }
508 }
509 }
510 if (count($values) == 1){
511 $attrs[$attribute]= $values[0];
512 } else {
513 $attrs[$attribute]= $values;
514 }
515 } else {
516 if ($modify){
517 $attrs[$attribute]= array();
518 }
519 }
520 }
522 $ldap->cd($dn);
523 if ($modify){
524 $ldap->modify($attrs);
525 if (!$ldap->success()){
526 msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $dn, LDAP_MOD, get_class()));
527 }
529 /* Optionally execute a command after we're done */
530 $this->handle_post_events("modify");
531 } else {
532 $ldap->add($attrs);
533 if (!$ldap->success()){
534 msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $dn, LDAP_ADD, get_class()));
535 }
537 /* Optionally execute a command after we're done */
538 $this->handle_post_events("create");
539 }
540 }
541 }
543 $this->dhcpServiceDN= $this->serviceDN;
544 if($this->dn != $this->orig_dn){
545 $this->dhcpServiceDN= preg_replace("/".preg_quote($this->orig_dn, '/')."$/i",$this->dn,$this->dhcpServiceDN);
546 }
548 /* Replace 'new' dn */
549 if(preg_match("/new$/",$this->dhcpServiceDN)){
550 $this->dhcpServiceDN = preg_replace("/new$/",$this->dn,$this->dhcpServiceDN);
551 }
553 plugin::save();
555 /* Save data to LDAP */
556 $ldap->cd($this->dn);
557 $this->cleanup();
558 $ldap->modify ($this->attrs);
560 if (!$ldap->success()){
561 msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, LDAP_MOD, get_class()));
562 }
564 /* Optionally execute a command after we're done */
565 if ($this->initially_was_account == $this->is_account){
566 if ($this->is_modified){
567 $this->handle_post_events("modify");
568 }
569 } else {
570 $this->handle_post_events("add");
571 }
573 /* Take over handling
574 * - Remove old dhcp config from source server
575 */
576 if($this->take_over_id != -1){
577 $id = $this->take_over_id;
578 $src = $this->dhcp_server_list['ENTRIES'][$id]['dn'];
579 $tmp = new servdhcp ($this->config, $src);
580 $tmp->remove_from_parent();
581 }
582 }
585 function reload()
586 {
587 /* Init LDAP and load list */
588 $ldap= $this->config->get_ldap_link();
589 $ui= get_userinfo();
590 $me= $this->dn;
592 $filter = "(&(objectClass=dhcpService)(|(dhcpPrimaryDN=$me)(dhcpSecondaryDN=$me)(dhcpServerDN=$me)(dhcpFailOverPeerDN=$me)))";
594 $list= get_list($filter, array("server"), $this->config->current['BASE'], array("cn"),GL_SIZELIMIT | GL_SUBSEARCH);
595 $final= array();
597 foreach ($list as $value){
599 /* Set header */
600 $sortpart= split(",", $value['dn']);
601 $sortpart= array_reverse($sortpart);
602 $tmp= implode(",", $sortpart);
604 $final[$value['dn']]= $tmp."!"._("Global options");
606 /* Read all sub entries to place here */
607 $ldap->cd($value['dn']);
608 $ldap->search("(|(objectClass=dhcpService)(objectClass=dhcpLog)(objectClass=dhcpClass)(objectClass=dhcpSubClass)(objectClass=dhcpHost)(objectClass=dhcpGroup)(objectClass=dhcpPool)(objectClass=dhcpSubnet)(objectClass=dhcpSharedNetwork)(objectClass=dhcpOptions)(objectClass=dhcpTSigKey)(objectClass=dhcpDnsZone)(objectClass=dhcpFailOverPeer))", array());
609 $this->serviceDN= $value['dn'];
611 while ($attrs= $ldap->fetch()){
612 $sattrs= array();
613 for ($i= 0; $i<$attrs['count']; $i++){
614 $sattrs[$attrs[$i]]= $attrs[$attrs[$i]];
615 unset($sattrs[$attrs[$i]]['count']);
616 }
617 $sattrs['dn']= $ldap->getDN();
619 foreach($sattrs as $name => $values){
620 if($name == "dhcpOption"){
621 foreach($values as $key => $value){
622 $value_name = trim(preg_replace("/[^ ]*$/","",$value));
623 $value_value= trim(preg_replace("/^[^ ]*/","",$value));
624 if(in_array($value_name,$this->quote_option)){
625 $value_value = preg_replace("/^\"/","",$value_value);
626 $value_value = preg_replace("/\"$/","",$value_value);
627 $sattrs[$name][$key] = $value_name." ".$value_value;
628 }
629 }
630 }
631 }
633 $this->dhcpObjectCache[$ldap->getDN()]= $sattrs;
634 $tmp= preg_replace("/".$this->serviceDN."/", "", $ldap->getDN());
635 $indent= substr_count($tmp, ",");
636 $spaces= "";
637 for ($i= 0; $i<$indent; $i++){
638 $spaces.= " ";
639 }
641 foreach ($this->types as $key => $val){
642 if (in_array("$key", $attrs['objectClass'])){
643 $type= $val;
644 break;
645 }
646 }
648 /* Prepare for sorting... */
649 $sortpart= split(",", $ldap->getDN());
650 $sortpart= array_reverse($sortpart);
651 $tmp= implode(",", $sortpart);
652 $final[$ldap->getDN()]= $tmp."!".$spaces.$type." '".$attrs['cn'][0]."'";
653 }
654 }
656 /* Sort it... */
657 natsort($final);
658 $this->dhcpSections= array();
659 foreach ($final as $key => $val){
660 $this->dhcpSections[$key]= preg_replace('/^[^!]+!(.*)$/', '\\1', $val);
661 }
663 }
666 function objectType($dn)
667 {
668 $type= "";
669 $types= array("dhcpService", "dhcpClass", "dhcpSubClass", "dhcpHost",
670 "dhcpGroup", "dhcpPool", "dhcpSubnet", "dhcpSharedNetwork");
672 foreach ($this->dhcpObjectCache[$dn]['objectClass'] as $oc){
673 if (in_array($oc, $types)){
674 $type= $oc;
675 break;
676 }
677 }
679 /* That should not happen... */
680 if ($type == ""){
681 msg_dialog::display(_("Error"), _("The DHCP configuration set is unkown. Please contact your system administrator."), ERROR_DIALOG);
682 }
684 return ($type);
685 }
688 /* Return plugin informations for acl handling */
689 static function plInfo()
690 {
691 return (array(
692 "plShortName" => _("DHCP service"),
693 "plDescription" => _("DHCP service")." ("._("Services").")",
694 "plSelfModify" => FALSE,
695 "plDepends" => array(),
696 "plPriority" => 84,
697 "plSection" => array("administration"),
698 "plCategory" => array("server"),
700 "plProvidedAcls"=> array(
701 "start" => _("Start service"), // Remove this to hide the start button at all.
702 "stop" => _("Stop service"), // Remove this to hide the stop button at all.
703 "restart" => _("Restart service"))// Remove this to hide the restart button at all.
704 ));
705 }
708 function take_over_service()
709 {
711 }
714 function get_list_of_dhcp_servers()
715 {
716 $ret = array("ENTRIES"=> array(),"FOR_LIST"=> array());
717 $ldap = $this->config->get_ldap_link();
718 $ldap->cd($this->config->current['BASE']);
719 $ldap->search("(&(objectClass=goServer)(dhcpServiceDN=*))",array("dn","cn","dhcpServiceDN"));
720 while($attrs = $ldap->fetch()){
722 /* Skip own config */
723 if($this->dn != "new" && preg_match("/".preg_quote($this->dn, '/')."$/",$attrs['dn'])){
724 continue;
725 }
727 $ret['ENTRIES'][] = $attrs;
728 }
729 foreach($ret['ENTRIES'] as $key => $data){
730 $ret['FOR_LIST'][$key] = $data['cn'][0];
731 }
732 return($ret);
733 }
736 function getListEntry()
737 {
738 $fields = goService::getListEntry();
739 $fields['Message'] = _("DHCP service");
740 #$fields['AllowEdit'] = true;
741 return($fields);
742 }
744 }
746 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
747 ?>