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->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 == ""){
157 /* New object */
158 $newsects= array();
159 foreach ($this->dhcpSections as $key => $dsc){
160 $newsects[$key]= $dsc;
161 if ($key == $dn){
162 $spaces.= " ";
163 $newsects[$data['dn']]= "$spaces$type '".preg_replace('/^[^=]+=([^,]+),.*$/', '\1', $data['dn'])."'";
164 }
165 }
166 $this->dhcpObjectCache[$data['dn']]= $data;
167 $this->dhcpSections= $newsects;
168 } else {
169 if ($dn != $data['dn']){
170 /* Old object, new name */
171 $this->dhcpObjectCache[$dn]= array();
172 $this->dhcpObjectCache[$data['dn']]= $data;
174 /* If we renamed a section, we've to rename a couple of objects, too */
175 foreach ($this->dhcpObjectCache as $key => $dsc){
176 if (preg_match("/,$dn$/", $key)){
177 $new_dn= preg_replace("/,$dn$/", ",".$data['dn'], $key);
178 $dsc['MODIFIED']= TRUE;
179 $this->dhcpObjectCache[$new_dn]= $dsc;
180 unset($this->dhcpObjectCache[$key]);
181 }
182 }
183 $newsects= array();
184 foreach ($this->dhcpSections as $key => $dsc){
185 if ($key == $dn){
186 $newsects[$data['dn']]= "$spaces$type '".preg_replace('/^[^=]+=([^,]+),.*$/', '\1', $data['dn'])."'";
187 continue;
188 }
189 if (preg_match("/,$dn$/", $key)){
190 $new_dn= preg_replace("/,$dn$/", ",".$data['dn'], $key);
191 $newsects[$new_dn]= $dsc;
192 } else {
193 $newsects[$key]= $dsc;
194 }
195 }
196 $this->dhcpSections= $newsects;
198 } else {
199 /* Old object, old name */
200 $this->dhcpObjectCache[$data['dn']]= $data;
201 }
202 }
203 $this->dialog= FALSE;
204 }
205 }
207 /* Remove section? */
208 if (isset($_POST['delete_dhcp_confirm'])){
209 if ($this->acl_is_removeable()){
210 unset($this->dhcpSections[$this->current_object]);
211 unset($this->dhcpObjectCache[$this->current_object]);
212 $this->dhcpObjectCache[$this->current_object]= array();
213 foreach ($this->dhcpSections as $key => $value){
214 if (preg_match("/".$this->current_object."$/", $key)){
215 unset($this->dhcpSections[$key]);
216 unset($this->dhcpObjectCache[$key]);
217 $this->dhcpObjectCache[$key]= array();
218 }
219 }
220 } else {
221 msg_dialog::display(_("Permission error"), msgPool::permDelete(), ERROR_DIALOG);
222 }
223 $this->dialog= FALSE;
224 }
226 /* Look for post entries */
227 foreach($_POST as $name => $value){
229 /* Insert new section? */
230 if (preg_match('/^insertDhcp_.*_x$/', $name)){
231 $dn= base64_decode(preg_replace('/^insertDhcp_([^_]+)_x$/', '\1', $name));
232 if (isset($this->dhcpObjectCache[$dn])){
233 $this->dialog= new dhcpNewSectionDialog($this->objectType($dn));
234 $this->current_object= $dn;
235 $this->dialog->acl= $this->acl;
236 }
237 }
239 /* Edit section? */
240 if (preg_match('/^editDhcp_.*_x$/', $name)){
241 $dn= base64_decode(preg_replace('/^editDhcp_([^_]+)_x$/', '\1', $name));
242 if (isset($this->dhcpObjectCache[$dn])){
243 $section= $this->objectType($dn);
244 $this->current_object= $dn;
245 $this->dialog= new $section($this->dhcpObjectCache[$dn]);
246 }
247 }
249 /* Remove section? */
250 if (preg_match('/^delDhcp_.*_x$/', $name)){
251 $dn= base64_decode(preg_replace('/^delDhcp_([^_]+)_x$/', '\1', $name));
252 if (isset($this->dhcpObjectCache[$dn])){
253 $this->current_object= $dn;
254 $this->dialog= 1;
255 $smarty->assign("warning", msgPool::deleteInfo(@LDAP::fix($dn),_("DHCP section")));
256 return($smarty->fetch(get_template_path('remove_dhcp.tpl', TRUE, dirname(__FILE__))));
257 }
258 }
260 }
262 if(isset($_GET['act']) && $_GET['act']=="edit" && isset($_GET['id'])){
263 $dn = base64_decode($_GET['id']);
264 if (isset($this->dhcpObjectCache[$dn])){
265 $section= $this->objectType($dn);
266 $this->current_object= $dn;
267 $this->dialog= new $section($this->dhcpObjectCache[$dn]);
268 }
269 }
272 if(isset($_GET['act']) && $_GET['act']=="edit" && isset($_GET['id'])){
273 $dn = base64_decode($_GET['id']);
274 if (isset($this->dhcpObjectCache[$dn])){
275 $section= $this->objectType($dn);
276 $this->current_object= $dn;
277 $this->dialog= new $section($this->dhcpObjectCache[$dn]);
278 }
279 }
282 /* Do we need to flip is_account state? */
283 if (isset($_POST['modify_state'])){
284 $this->is_account= !$this->is_account;
285 }
287 /* Show tab dialog headers */
288 if ($this->is_account){
289 if (!count($this->dhcpObjectCache)){
290 $attrs= array();
291 $attrs['dn']= 'cn=dhcp,'.$this->dn;
292 $attrs['cn']= array('dhcp');
293 $attrs['objectClass']= array('top', 'dhcpService');
294 $attrs['dhcpPrimaryDN']= array($this->dn);
295 $attrs['dhcpStatements']= array("default-lease-time 600",
296 "max-lease-time 1200",
297 "authoritative",
298 "ddns-update-style none");
299 $attrs['MODIFIED']= TRUE;
300 $this->dhcpSections['cn=dhcp,'.$this->dn]= _("Global options");
301 $this->dhcpObjectCache['cn=dhcp,'.$this->dn]= $attrs;
302 }
304 } else {
305 return ($display);
306 }
309 /* Show dialog
310 */
311 if(isset($this->dialog) && is_object($this->dialog)){
312 $this->dialog->save_object();
313 $this->dialog->parent = $this;
314 return($this->dialog->execute());
315 }
317 /* Create Listbox with existing Zones
318 */
319 $DhcpList = new divSelectBox("dhcpSections");
320 $DhcpList->SetHeight(400);
322 /* Add entries to divlist
323 */
324 $editImgIns = "<input type='image' src='images/list_new.png' name='insertDhcp_%s' title='"._("Insert new DHCP section")."'>".
325 "<input type='image' src='images/lists/edit.png' name='editDhcp_%s' title='"._("Edit DHCP section")."'>".
326 "<input type='image' src='images/lists/trash.png' name='delDhcp_%s' title='"._("Remove DHCP section")."'>";
327 $editImgInsNoDel = "<input type='image' src='images/list_new.png' name='insertDhcp_%s' title='"._("Insert new DHCP section")."'>".
328 "<input type='image' src='images/lists/edit.png' name='editDhcp_%s' title='"._("Edit DHCP section")."'>";
329 $editImg = "<input type='image' src='images/lists/edit.png' name='editDhcp_%s' title='"._("Edit DHCP section")."'>".
330 "<input type='image' src='images/lists/trash.png' name='delDhcp_%s' title='"._("Remove DHCP section")."'>";
332 $tmp = new dhcpNewSectionDialog(NULL);
333 foreach($this->dhcpSections as $section => $values ){
335 $values = "<a href='?plug=".$_GET['plug']."&act=edit&id=".base64_encode($section)."'>".$values."</a>";
337 if (count($tmp->sectionMap[$this->objectType($section)])){
338 if ($this->objectType($section) == "dhcpService"){
339 $DhcpList->AddEntry(array(
340 array("string" => $values),
341 array("string" => str_replace("%s",base64_encode($section),$editImgInsNoDel), "attach" => "style='text-align:right;'")
342 ));
343 } else {
344 $DhcpList->AddEntry(array(
345 array("string" => $values),
346 array("string" => str_replace("%s",base64_encode($section),$editImgIns), "attach" => "style='text-align:right;'")
347 ));
348 }
349 } else {
350 $DhcpList->AddEntry(array(
351 array("string" => $values),
352 array("string" => str_replace("%s",base64_encode($section),$editImg), "attach" => "style='text-align:right;'")
353 ));
354 }
355 }
357 /* Display tempalte */
358 $smarty->assign("DhcpList",$DhcpList->DrawList());
359 $display.= $smarty->fetch(get_template_path('servdhcp.tpl', TRUE, dirname(__FILE__)));
360 return($display);
361 }
364 function remove_from_parent()
365 {
366 /* Cancel if there's nothing to do here */
367 if (!$this->initially_was_account){
368 return;
369 }
371 /* Remove subtrees */
372 $ldap= $this->config->get_ldap_link();
373 foreach ($this->dhcpObjectCache as $dn => $content){
374 if ($this->objectType($dn) == 'dhcpService'){
375 $ldap->rmdir_recursive($dn);
376 if (!$ldap->success()){
377 msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $dn, LDAP_DEL, get_class()));
378 }
379 }
380 }
382 /* Remove from self */
383 $ldap= $this->config->get_ldap_link();
385 /* Remove and write to LDAP */
386 plugin::remove_from_parent();
388 @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, $this->attributes, "Save");
389 $ldap->cd($this->dn);
390 $this->cleanup();
391 $ldap->modify ($this->attrs);
393 if (!$ldap->success()){
394 msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, LDAP_MOD, get_class()));
395 }
397 /* Optionally execute a command after we're done */
398 $this->handle_post_events("remove");
399 }
402 /* Save data to object */
403 function save_object()
404 {
405 plugin::save_object();
406 }
409 /* Check supplied data */
410 function check()
411 {
412 /* Call common method to give check the hook */
413 $message= plugin::check();
415 return ($message);
416 }
419 /* Save to LDAP */
420 function save()
421 {
422 /* Take over handling
423 * - Load servdhcp class and dhcpObjectCache for the source dhcp setup.
424 * - Assign dhcpObjectCache to this configuration.
425 * - Save this setup and remove source setup from ldap.
426 */
427 if($this->take_over_id != -1){
428 $id = $this->take_over_id;
429 $src = preg_replace("/cn=dhcp,/","",$this->dhcp_server_list['ENTRIES'][$id]['dn']);
430 $tmp = new servdhcp ($this->config, $src);
431 $this->orig_dn = $src;
432 $this->dhcpObjectCache = $tmp->dhcpObjectCache;
433 }
435 /* Save dhcp setttings */
436 $ldap= $this->config->get_ldap_link();
437 foreach ($this->dhcpObjectCache as $dn => $data){
439 if($this->dn != $this->orig_dn){
440 $dn = preg_replace("/".normalizePreg($this->orig_dn)."$/i",$this->dn,$dn);
441 }
443 /* Remove entry? */
444 if (count($data) == 0){
445 /* Check if exists, then remove... */
446 if($ldap->cat($dn)){
447 $ldap->rmdir_recursive($dn);
448 if (!$ldap->success()){
449 msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $dn, LDAP_MOD, get_class()));
450 }
451 }
452 continue;
453 }
455 /* Opdate dhcp option 'server-name' to actual server name */
456 if($this->dn != $this->orig_dn){
457 $fixed = FALSE;
458 foreach(array("dhcpHost","dhcpSubnet","dhcpGroup","dhcpSharedNetwork") as $object){
459 if(in_array($object,$data['objectClass']) && isset($data['dhcpOption'])){
460 foreach($data['dhcpOption'] as $key => $option){
461 if(preg_match("/^server-name /",$option)){
462 $data['dhcpOption'][$key] = "server-name ".$this->cn;
463 $data['MODIFIED'] = TRUE;
464 break;
465 }
466 }
467 }
469 /* Skip next loops if entry is updated */
470 if($fixed){
471 break;
472 }
473 }
474 }
476 /* Modify existing entry? */
477 if (isset($data['MODIFIED']) || $this->orig_dn != $this->dn){
479 if($ldap->cat($dn)){
480 $modify= TRUE;
481 } else {
482 $modify= FALSE;
483 }
485 /* Build new entry */
486 $attrs= array();
487 foreach ($data as $attribute => $values){
488 if ($attribute == "MODIFIED" || $attribute == "dn"){
489 continue;
490 }
492 if(in_array($attribute,array("dhcpPrimaryDN","dhcpSecondaryDN","dhcpServerDN","dhcpFailOverPeerDN"))){
493 foreach($values as $v_key => $value){
494 $values[$v_key] = preg_replace("/".normalizePreg($this->orig_dn)."$/i",$this->dn,$value);
495 }
496 }
498 if (count($values)){
500 if($attribute == "dhcpOption"){
501 foreach($values as $key => $value){
502 $option_name = trim(preg_replace("/[^ ]*$/","",$value));
503 $option_value= trim(preg_replace("/^[^ ]*/","",$value));
504 if(in_array($option_name,$this->quote_option)){
505 $values[$key] = $option_name." \"".$option_value."\"";
506 }
507 }
508 }
509 if (count($values) == 1){
510 $attrs[$attribute]= $values[0];
511 } else {
512 $attrs[$attribute]= $values;
513 }
514 } else {
515 if ($modify){
516 $attrs[$attribute]= array();
517 }
518 }
519 }
521 $ldap->cd($dn);
522 if ($modify){
523 $ldap->modify($attrs);
524 if (!$ldap->success()){
525 msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $dn, LDAP_MOD, get_class()));
526 }
528 /* Optionally execute a command after we're done */
529 $this->handle_post_events("modify");
530 } else {
531 $ldap->add($attrs);
532 if (!$ldap->success()){
533 msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $dn, LDAP_ADD, get_class()));
534 }
536 /* Optionally execute a command after we're done */
537 $this->handle_post_events("create");
538 }
539 }
540 }
542 $this->dhcpServiceDN= $this->serviceDN;
543 if($this->dn != $this->orig_dn){
544 $this->dhcpServiceDN= preg_replace("/".normalizePreg($this->orig_dn)."$/i",$this->dn,$this->dhcpServiceDN);
545 }
547 /* Replace 'new' dn */
548 if(preg_match("/new$/",$this->dhcpServiceDN)){
549 $this->dhcpServiceDN = preg_replace("/new$/",$this->dn,$this->dhcpServiceDN);
550 }
552 plugin::save();
554 /* Save data to LDAP */
555 $ldap->cd($this->dn);
556 $this->cleanup();
557 $ldap->modify ($this->attrs);
559 if (!$ldap->success()){
560 msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, LDAP_MOD, get_class()));
561 }
563 /* Optionally execute a command after we're done */
564 if ($this->initially_was_account == $this->is_account){
565 if ($this->is_modified){
566 $this->handle_post_events("modify");
567 }
568 } else {
569 $this->handle_post_events("add");
570 }
572 /* Take over handling
573 * - Remove old dhcp config from source server
574 */
575 if($this->take_over_id != -1){
576 $id = $this->take_over_id;
577 $src = $this->dhcp_server_list['ENTRIES'][$id]['dn'];
578 $tmp = new servdhcp ($this->config, $src);
579 $tmp->remove_from_parent();
580 }
581 }
584 function reload()
585 {
586 /* Init LDAP and load list */
587 $ldap= $this->config->get_ldap_link();
588 $ui= get_userinfo();
589 $me= $this->dn;
591 $filter = "(&(objectClass=dhcpService)(|(dhcpPrimaryDN=$me)(dhcpSecondaryDN=$me)(dhcpServerDN=$me)(dhcpFailOverPeerDN=$me)))";
593 $list= get_list($filter, array("server"), $this->config->current['BASE'], array("cn"),GL_SIZELIMIT | GL_SUBSEARCH);
594 $final= array();
596 foreach ($list as $value){
598 /* Set header */
599 $sortpart= split(",", $value['dn']);
600 $sortpart= array_reverse($sortpart);
601 $tmp= implode(",", $sortpart);
603 $final[$value['dn']]= $tmp."!"._("Global options");
605 /* Read all sub entries to place here */
606 $ldap->cd($value['dn']);
607 $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());
608 $this->serviceDN= $value['dn'];
610 while ($attrs= $ldap->fetch()){
611 $sattrs= array();
612 for ($i= 0; $i<$attrs['count']; $i++){
613 $sattrs[$attrs[$i]]= $attrs[$attrs[$i]];
614 unset($sattrs[$attrs[$i]]['count']);
615 }
616 $sattrs['dn']= $ldap->getDN();
618 foreach($sattrs as $name => $values){
619 if($name == "dhcpOption"){
620 foreach($values as $key => $value){
621 $value_name = trim(preg_replace("/[^ ]*$/","",$value));
622 $value_value= trim(preg_replace("/^[^ ]*/","",$value));
623 if(in_array($value_name,$this->quote_option)){
624 $value_value = preg_replace("/^\"/","",$value_value);
625 $value_value = preg_replace("/\"$/","",$value_value);
626 $sattrs[$name][$key] = $value_name." ".$value_value;
627 }
628 }
629 }
630 }
632 $this->dhcpObjectCache[$ldap->getDN()]= $sattrs;
633 $tmp= preg_replace("/".$this->serviceDN."/", "", $ldap->getDN());
634 $indent= substr_count($tmp, ",");
635 $spaces= "";
636 for ($i= 0; $i<$indent; $i++){
637 $spaces.= " ";
638 }
640 foreach ($this->types as $key => $val){
641 if (in_array("$key", $attrs['objectClass'])){
642 $type= $val;
643 break;
644 }
645 }
647 /* Prepare for sorting... */
648 $sortpart= split(",", $ldap->getDN());
649 $sortpart= array_reverse($sortpart);
650 $tmp= implode(",", $sortpart);
651 $final[$ldap->getDN()]= $tmp."!".$spaces.$type." '".$attrs['cn'][0]."'";
652 }
653 }
655 /* Sort it... */
656 natsort($final);
657 $this->dhcpSections= array();
658 foreach ($final as $key => $val){
659 $this->dhcpSections[$key]= preg_replace('/^[^!]+!(.*)$/', '\\1', $val);
660 }
662 }
665 function objectType($dn)
666 {
667 $type= "";
668 $types= array("dhcpService", "dhcpClass", "dhcpSubClass", "dhcpHost",
669 "dhcpGroup", "dhcpPool", "dhcpSubnet", "dhcpSharedNetwork");
671 foreach ($this->dhcpObjectCache[$dn]['objectClass'] as $oc){
672 if (in_array($oc, $types)){
673 $type= $oc;
674 break;
675 }
676 }
678 /* That should not happen... */
679 if ($type == ""){
680 msg_dialog::display(_("Error"), _("The DHCP configuration set is unkown. Please contact your system administrator."), ERROR_DIALOG);
681 }
683 return ($type);
684 }
687 /* Return plugin informations for acl handling */
688 static function plInfo()
689 {
690 return (array(
691 "plShortName" => _("DHCP service"),
692 "plDescription" => _("DHCP service")." ("._("Services").")",
693 "plSelfModify" => FALSE,
694 "plDepends" => array(),
695 "plPriority" => 84,
696 "plSection" => array("administration"),
697 "plCategory" => array("server"),
699 "plProvidedAcls"=> array(
701 )
702 ));
703 }
706 function take_over_service()
707 {
709 }
712 function get_list_of_dhcp_servers()
713 {
714 $ret = array("ENTRIES"=> array(),"FOR_LIST"=> array());
715 $ldap = $this->config->get_ldap_link();
716 $ldap->cd($this->config->current['BASE']);
717 $ldap->search("(&(objectClass=goServer)(dhcpServiceDN=*))",array("dn","cn","dhcpServiceDN"));
718 while($attrs = $ldap->fetch()){
720 /* Skip own config */
721 if($this->dn != "new" && preg_match("/".normalizePreg($this->dn)."$/",$attrs['dn'])){
722 continue;
723 }
725 $ret['ENTRIES'][] = $attrs;
726 }
727 foreach($ret['ENTRIES'] as $key => $data){
728 $ret['FOR_LIST'][$key] = $data['cn'][0];
729 }
730 return($ret);
731 }
734 function getListEntry()
735 {
736 $fields = goService::getListEntry();
737 $fields['Message'] = _("DHCP service");
738 $fields['AllowEdit'] = true;
739 return($fields);
740 }
742 }
744 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
745 ?>