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"), _("You have no permission to remove DHCP sections!"), 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 # $display= $this->show_header(_("Remove DHCP service"),
290 # _("This server has DHCP features enabled. You can disable them by clicking below."));
292 if (!count($this->dhcpObjectCache)){
293 $attrs= array();
294 $attrs['dn']= 'cn=dhcp,'.$this->dn;
295 $attrs['cn']= array('dhcp');
296 $attrs['objectClass']= array('top', 'dhcpService');
297 $attrs['dhcpPrimaryDN']= array($this->dn);
298 $attrs['dhcpStatements']= array("default-lease-time 600",
299 "max-lease-time 1200",
300 "authoritative",
301 "ddns-update-style none");
302 $attrs['MODIFIED']= TRUE;
303 $this->dhcpSections['cn=dhcp,'.$this->dn]= _("Global options");
304 $this->dhcpObjectCache['cn=dhcp,'.$this->dn]= $attrs;
305 }
307 } else {
308 # $display= $this->show_header(_("Add DHCP service"),
310 # _("This server has DHCP features disabled. You can enable them by clicking below."));
311 return ($display);
312 }
315 /* Show dialog
316 */
317 if(isset($this->dialog) && is_object($this->dialog)){
318 $this->dialog->save_object();
319 $this->dialog->parent = $this;
320 return($this->dialog->execute());
321 }
323 /* Create Listbox with existing Zones
324 */
325 $DhcpList = new divSelectBox("dhcpSections");
326 $DhcpList->SetHeight(400);
328 /* Add entries to divlist
329 */
330 $editImgIns = "<input type='image' src='images/list_new.png' name='insertDhcp_%s' title='"._("Insert new DHCP section")."'>".
331 "<input type='image' src='images/edit.png' name='editDhcp_%s' title='"._("Edit DHCP section")."'>".
332 "<input type='image' src='images/edittrash.png' name='delDhcp_%s' title='"._("Remove DHCP section")."'>";
333 $editImgInsNoDel = "<input type='image' src='images/list_new.png' name='insertDhcp_%s' title='"._("Insert new DHCP section")."'>".
334 "<input type='image' src='images/edit.png' name='editDhcp_%s' title='"._("Edit DHCP section")."'>";
335 $editImg = "<input type='image' src='images/edit.png' name='editDhcp_%s' title='"._("Edit DHCP section")."'>".
336 "<input type='image' src='images/edittrash.png' name='delDhcp_%s' title='"._("Remove DHCP section")."'>";
338 $tmp = new dhcpNewSectionDialog(NULL);
339 foreach($this->dhcpSections as $section => $values ){
341 $values = "<a href='?plug=".$_GET['plug']."&act=edit&id=".base64_encode($section)."'>".$values."</a>";
343 if (count($tmp->sectionMap[$this->objectType($section)])){
344 if ($this->objectType($section) == "dhcpService"){
345 $DhcpList->AddEntry(array(
346 array("string" => $values),
347 array("string" => str_replace("%s",base64_encode($section),$editImgInsNoDel), "attach" => "style='text-align:right;'")
348 ));
349 } else {
350 $DhcpList->AddEntry(array(
351 array("string" => $values),
352 array("string" => str_replace("%s",base64_encode($section),$editImgIns), "attach" => "style='text-align:right;'")
353 ));
354 }
355 } else {
356 $DhcpList->AddEntry(array(
357 array("string" => $values),
358 array("string" => str_replace("%s",base64_encode($section),$editImg), "attach" => "style='text-align:right;'")
359 ));
360 }
361 }
363 /* Display tempalte */
364 $smarty->assign("DhcpList",$DhcpList->DrawList());
365 $display.= $smarty->fetch(get_template_path('servdhcp.tpl', TRUE, dirname(__FILE__)));
366 return($display);
367 }
370 function remove_from_parent()
371 {
372 /* Cancel if there's nothing to do here */
373 if (!$this->initially_was_account){
374 return;
375 }
377 /* Remove subtrees */
378 $ldap= $this->config->get_ldap_link();
379 foreach ($this->dhcpObjectCache as $dn => $content){
380 if ($this->objectType($dn) == 'dhcpService'){
381 $ldap->rmdir_recursive($dn);
382 if (!$ldap->success()){
383 msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $dn, LDAP_DEL, get_class()));
384 }
385 }
386 }
388 /* Remove from self */
389 $ldap= $this->config->get_ldap_link();
391 /* Remove and write to LDAP */
392 plugin::remove_from_parent();
394 @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, $this->attributes, "Save");
395 $ldap->cd($this->dn);
396 $this->cleanup();
397 $ldap->modify ($this->attrs);
399 if (!$ldap->success()){
400 msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, LDAP_MOD, get_class()));
401 }
403 /* Optionally execute a command after we're done */
404 $this->handle_post_events("remove");
405 }
408 /* Save data to object */
409 function save_object()
410 {
411 plugin::save_object();
412 }
415 /* Check supplied data */
416 function check()
417 {
418 /* Call common method to give check the hook */
419 $message= plugin::check();
421 return ($message);
422 }
425 /* Save to LDAP */
426 function save()
427 {
428 /* Take over handling
429 * - Load servdhcp class and dhcpObjectCache for the source dhcp setup.
430 * - Assign dhcpObjectCache to this configuration.
431 * - Save this setup and remove source setup from ldap.
432 */
433 if($this->take_over_id != -1){
434 $id = $this->take_over_id;
435 $src = preg_replace("/cn=dhcp,/","",$this->dhcp_server_list['ENTRIES'][$id]['dn']);
436 $tmp = new servdhcp ($this->config, $src);
437 $this->orig_dn = $src;
438 $this->dhcpObjectCache = $tmp->dhcpObjectCache;
439 }
441 /* Save dhcp setttings */
442 $ldap= $this->config->get_ldap_link();
443 foreach ($this->dhcpObjectCache as $dn => $data){
445 if($this->dn != $this->orig_dn){
446 $dn = preg_replace("/".normalizePreg($this->orig_dn)."$/i",$this->dn,$dn);
447 }
449 /* Remove entry? */
450 if (count($data) == 0){
451 /* Check if exists, then remove... */
452 if($ldap->cat($dn)){
453 $ldap->rmdir_recursive($dn);
454 if (!$ldap->success()){
455 msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $dn, LDAP_MOD, get_class()));
456 }
457 }
458 continue;
459 }
461 /* Opdate dhcp option 'server-name' to actual server name */
462 if($this->dn != $this->orig_dn){
463 $fixed = FALSE;
464 foreach(array("dhcpHost","dhcpSubnet","dhcpGroup","dhcpSharedNetwork") as $object){
465 if(in_array($object,$data['objectClass']) && isset($data['dhcpOption'])){
466 foreach($data['dhcpOption'] as $key => $option){
467 if(preg_match("/^server-name /",$option)){
468 $data['dhcpOption'][$key] = "server-name ".$this->cn;
469 $data['MODIFIED'] = TRUE;
470 break;
471 }
472 }
473 }
475 /* Skip next loops if entry is updated */
476 if($fixed){
477 break;
478 }
479 }
480 }
482 /* Modify existing entry? */
483 if (isset($data['MODIFIED']) || $this->orig_dn != $this->dn){
485 if($ldap->cat($dn)){
486 $modify= TRUE;
487 } else {
488 $modify= FALSE;
489 }
491 /* Build new entry */
492 $attrs= array();
493 foreach ($data as $attribute => $values){
494 if ($attribute == "MODIFIED" || $attribute == "dn"){
495 continue;
496 }
498 if(in_array($attribute,array("dhcpPrimaryDN","dhcpSecondaryDN","dhcpServerDN","dhcpFailOverPeerDN"))){
499 foreach($values as $v_key => $value){
500 $values[$v_key] = preg_replace("/".normalizePreg($this->orig_dn)."$/i",$this->dn,$value);
501 }
502 }
504 if (count($values)){
506 if($attribute == "dhcpOption"){
507 foreach($values as $key => $value){
508 $option_name = trim(preg_replace("/[^ ]*$/","",$value));
509 $option_value= trim(preg_replace("/^[^ ]*/","",$value));
510 if(in_array($option_name,$this->quote_option)){
511 $values[$key] = $option_name." \"".$option_value."\"";
512 }
513 }
514 }
515 if (count($values) == 1){
516 $attrs[$attribute]= $values[0];
517 } else {
518 $attrs[$attribute]= $values;
519 }
520 } else {
521 if ($modify){
522 $attrs[$attribute]= array();
523 }
524 }
525 }
527 $ldap->cd($dn);
528 if ($modify){
529 $ldap->modify($attrs);
530 if (!$ldap->success()){
531 msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $dn, LDAP_MOD, get_class()));
532 }
534 /* Optionally execute a command after we're done */
535 $this->handle_post_events("modify");
536 } else {
537 $ldap->add($attrs);
538 if (!$ldap->success()){
539 msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $dn, LDAP_ADD, get_class()));
540 }
542 /* Optionally execute a command after we're done */
543 $this->handle_post_events("create");
544 }
545 }
546 }
548 $this->dhcpServiceDN= $this->serviceDN;
549 if($this->dn != $this->orig_dn){
550 $this->dhcpServiceDN= preg_replace("/".normalizePreg($this->orig_dn)."$/i",$this->dn,$this->dhcpServiceDN);
551 }
553 /* Replace 'new' dn */
554 if(preg_match("/new$/",$this->dhcpServiceDN)){
555 $this->dhcpServiceDN = preg_replace("/new$/",$this->dn,$this->dhcpServiceDN);
556 }
558 plugin::save();
560 /* Save data to LDAP */
561 $ldap->cd($this->dn);
562 $this->cleanup();
563 $ldap->modify ($this->attrs);
565 if (!$ldap->success()){
566 msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, LDAP_MOD, get_class()));
567 }
569 /* Optionally execute a command after we're done */
570 if ($this->initially_was_account == $this->is_account){
571 if ($this->is_modified){
572 $this->handle_post_events("modify");
573 }
574 } else {
575 $this->handle_post_events("add");
576 }
578 /* Take over handling
579 * - Remove old dhcp config from source server
580 */
581 if($this->take_over_id != -1){
582 $id = $this->take_over_id;
583 $src = $this->dhcp_server_list['ENTRIES'][$id]['dn'];
584 $tmp = new servdhcp ($this->config, $src);
585 $tmp->remove_from_parent();
586 }
587 }
590 function reload()
591 {
592 /* Init LDAP and load list */
593 $ldap= $this->config->get_ldap_link();
594 $ui= get_userinfo();
595 $me= $this->dn;
597 $filter = "(&(objectClass=dhcpService)(|(dhcpPrimaryDN=$me)(dhcpSecondaryDN=$me)(dhcpServerDN=$me)(dhcpFailOverPeerDN=$me)))";
599 $list= get_list($filter, array("server"), $this->config->current['BASE'], array("cn"),GL_SIZELIMIT | GL_SUBSEARCH);
600 $final= array();
602 foreach ($list as $value){
604 /* Set header */
605 $sortpart= split(",", $value['dn']);
606 $sortpart= array_reverse($sortpart);
607 $tmp= implode(",", $sortpart);
609 $final[$value['dn']]= $tmp."!"._("Global options");
611 /* Read all sub entries to place here */
612 $ldap->cd($value['dn']);
613 $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());
614 $this->serviceDN= $value['dn'];
616 while ($attrs= $ldap->fetch()){
617 $sattrs= array();
618 for ($i= 0; $i<$attrs['count']; $i++){
619 $sattrs[$attrs[$i]]= $attrs[$attrs[$i]];
620 unset($sattrs[$attrs[$i]]['count']);
621 }
622 $sattrs['dn']= $ldap->getDN();
624 foreach($sattrs as $name => $values){
625 if($name == "dhcpOption"){
626 foreach($values as $key => $value){
627 $value_name = trim(preg_replace("/[^ ]*$/","",$value));
628 $value_value= trim(preg_replace("/^[^ ]*/","",$value));
629 if(in_array($value_name,$this->quote_option)){
630 $value_value = preg_replace("/^\"/","",$value_value);
631 $value_value = preg_replace("/\"$/","",$value_value);
632 $sattrs[$name][$key] = $value_name." ".$value_value;
633 }
634 }
635 }
636 }
638 $this->dhcpObjectCache[$ldap->getDN()]= $sattrs;
639 $tmp= preg_replace("/".$this->serviceDN."/", "", $ldap->getDN());
640 $indent= substr_count($tmp, ",");
641 $spaces= "";
642 for ($i= 0; $i<$indent; $i++){
643 $spaces.= " ";
644 }
646 foreach ($this->types as $key => $val){
647 if (in_array("$key", $attrs['objectClass'])){
648 $type= $val;
649 break;
650 }
651 }
653 /* Prepare for sorting... */
654 $sortpart= split(",", $ldap->getDN());
655 $sortpart= array_reverse($sortpart);
656 $tmp= implode(",", $sortpart);
657 $final[$ldap->getDN()]= $tmp."!".$spaces.$type." '".$attrs['cn'][0]."'";
658 }
659 }
661 /* Sort it... */
662 natsort($final);
663 $this->dhcpSections= array();
664 foreach ($final as $key => $val){
665 $this->dhcpSections[$key]= preg_replace('/^[^!]+!(.*)$/', '\\1', $val);
666 }
668 }
671 function objectType($dn)
672 {
673 $type= "";
674 $types= array("dhcpService", "dhcpClass", "dhcpSubClass", "dhcpHost",
675 "dhcpGroup", "dhcpPool", "dhcpSubnet", "dhcpSharedNetwork");
677 foreach ($this->dhcpObjectCache[$dn]['objectClass'] as $oc){
678 if (in_array($oc, $types)){
679 $type= $oc;
680 break;
681 }
682 }
684 /* That should not happen... */
685 if ($type == ""){
686 msg_dialog::display(_("Error"), _("The DHCP configuration set is unkown. Please contact your system administrator."), ERROR_DIALOG);
687 }
689 return ($type);
690 }
693 /* Return plugin informations for acl handling */
694 static function plInfo()
695 {
696 return (array(
697 "plShortName" => _("DHCP service"),
698 "plDescription" => _("DHCP service")." ("._("Services").")",
699 "plSelfModify" => FALSE,
700 "plDepends" => array(),
701 "plPriority" => 84,
702 "plSection" => array("administration"),
703 "plCategory" => array("server"),
705 "plProvidedAcls"=> array(
707 )
708 ));
709 }
712 function take_over_service()
713 {
715 }
718 function get_list_of_dhcp_servers()
719 {
720 $ret = array("ENTRIES"=> array(),"FOR_LIST"=> array());
721 $ldap = $this->config->get_ldap_link();
722 $ldap->cd($this->config->current['BASE']);
723 $ldap->search("(&(objectClass=goServer)(dhcpServiceDN=*))",array("dn","cn","dhcpServiceDN"));
724 while($attrs = $ldap->fetch()){
726 /* Skip own config */
727 if($this->dn != "new" && preg_match("/".normalizePreg($this->dn)."$/",$attrs['dn'])){
728 continue;
729 }
731 $ret['ENTRIES'][] = $attrs;
732 }
733 foreach($ret['ENTRIES'] as $key => $data){
734 $ret['FOR_LIST'][$key] = $data['cn'][0];
735 }
736 return($ret);
737 }
740 function getListEntry()
741 {
742 $fields = goService::getListEntry();
743 $fields['Message'] = _("DHCP service");
744 $fields['AllowEdit'] = true;
745 return($fields);
746 }
748 }
750 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
751 ?>