Code

Updated goto plugins to hide gosa-si actions until the gosaSupportURI is defined.
[gosa.git] / gosa-plugins / goto / admin / systems / goto / class_terminalGeneric.inc
1 <?php
3 class termgeneric extends plugin
4 {
5   /* Generic terminal attributes */
6   var $gotoMode= "locked";
7   var $gotoTerminalPath= "";
8   var $gotoSwapServer= "";
9   var $gotoSyslogServer= "";
10   var $gotoSyslogServers = array();
11   var $gotoNtpServer= array();
12   var $gotoNtpServers= array();
13   var $gotoSndModule= "";
14   var $gotoFloppyEnable= "";
15   var $gotoCdromEnable= "";
16   var $ghCpuType= "-";
17   var $ghMemSize= "-";
18   var $ghUsbSupport= "-";
19   var $ghNetNic= array();
20   var $ghIdeDev= array();
21   var $ghScsiDev= array();
22   var $ghGfxAdapter= "-";
23   var $ghSoundAdapter= "-";
24   var $gotoLastUser= "-";
25   var $netConfigDNS;
26   var $auto_activate= FALSE;
27   
28   /* Needed values and lists */
29   var $base= "";
30   var $cn= "";
31   var $description= "";
32   var $orig_dn= "";
33   var $orig_cn= "";
34   var $orig_base= "";
36   var $inheritTimeServer = true;
38   /* Plugin side filled */
39   var $modes= array();
40   var $baseSelector;
42   /* attribute list for save action */
43   var $ignore_account= TRUE;
44   var $attributes= array("gotoMode", "gotoTerminalPath", 
45       "gotoSwapServer", "gotoSyslogServer", "gotoNtpServer",
46       "gotoFloppyEnable", "gotoCdromEnable", "cn", "gotoSndModule",
47       "ghCpuType", "ghMemSize","ghUsbSupport", "description",
48       "ghGfxAdapter", "ghSoundAdapter", "gotoLastUser");
49   var $objectclasses= array("top", "gotoTerminal", "GOhard");
51   var $validActions   = array("reboot" => "", "rescan" => "", "wake" => "", "memcheck" => "", "sysinfo" => "");
53   var $fai_activated = FALSE;
54   var $view_logged = FALSE;
56   var $member_of_ogroup = FALSE;
58   var $kerberos_key_service = NULL;
61   function termgeneric (&$config, $dn= NULL, $parent= NULL)
62   {
63     /* Check if FAI is activated */
64     $tmp= $config->search("faiManagement", "CLASS",array('menu','tabs'));
65     if(!empty($tmp)){
66       $this->fai_activated = TRUE;
67     }
69     plugin::plugin ($config, $dn, $parent);
71     if(class_available("krbHostKeys")){
72       $this->kerberos_key_service = new krbHostKeys($this->config,$this);
73     }
75     if(!isset($this->parent->by_object['ogroup'])){
76       $ldap = $this->config->get_ldap_link();
77       $ldap->cd ($this->config->current['BASE']);
78       $ldap->search("(&(|(objectClass=gotoTerminalTemplate)(objectClass=gotoWorkstationTemplate))(member=".LDAP::prepare4filter($this->dn)."))",array("cn"));
79       $this->member_of_ogroup = $ldap->count() >= 1;
80     }
82     $this->netConfigDNS = new termDNS($this->config,$this,$this->objectclasses);
83     $this->netConfigDNS->MACisMust =TRUE;
85     /* Read arrays */
86     foreach (array("ghNetNic", "ghIdeDev", "ghScsiDev") as $val){
87       if (!isset($this->attrs[$val])){
88         continue;
89       }
90       for ($i= 0; $i<$this->attrs[$val]['count']; $i++){
91         array_push($this->$val, $this->attrs[$val][$i]);
92       }
93     }
95     /* Create used ntp server array */
96     $this->gotoNtpServer= array();
97     if(isset($this->attrs['gotoNtpServer'])){
98       $this->inheritTimeServer = false;
99       for($i = 0 ; $i < $this->attrs['gotoNtpServer']['count']; $i++ ){
100         $server = $this->attrs['gotoNtpServer'][$i];
101         $this->gotoNtpServer[$server] = $server;
102       }
103     }
105     /* Set inherit checkbox state */
106     if((in_array_strict("default",$this->gotoNtpServer)) || (count($this->gotoNtpServer)==0)){
107       $this->inheritTimeServer = true;
108       $this->gotoNtpServer=array();
109     }
111     /* You can't inherit the NTP service, if we are not member in an object group */
112     if(!$this->member_of_ogroup){
113       $this->inheritTimeServer = FALSE;
114     }
116     /* Create available ntp options */
117     $this->gotoNtpServers = $this->config->data['SERVERS']['NTP'];
118     foreach($this->gotoNtpServers as $key => $server){
119       if($server == "default"){
120         unset($this->gotoNtpServers[$key]);
121       }
122     }
124     $this->modes["locked"]= _("Locked");
125     $this->modes["active"]= _("Activated");
127     /* Set base */
128     if ($this->dn == "new"){
129       $ui= get_userinfo();
130       $this->base= dn2base(session::global_is_set("CurrentMainBase")?"cn=dummy,".session::global_get("CurrentMainBase"):$ui->dn);
131     } elseif(preg_match("/".preg_quote(get_ou("systemIncomingRDN"), '/')."/i", $this->dn)){
132       $this->base= preg_replace ("/^[^,]+,".preg_quote(get_ou("systemIncomingRDN"), '/')."/i", "", $this->dn);
133     } else {
134       $this->base= preg_replace ("/^[^,]+,".preg_quote(get_ou("terminalRDN"), '/')."/i", "", $this->dn);
135     }
137     /* Create an array of all Syslog servers */
138     $tmp = $this->config->data['SERVERS']['SYSLOG'];
139     foreach($tmp as $server){
140       $visible = $server;
141       if($server == "default" && $this->member_of_ogroup) {
142         $visible = "["._("inherited")."]";
143       }
144       $this->gotoSyslogServers[$server] = $visible;
145     }
147     $this->orig_dn= $this->dn;
148     $this->orig_cn= $this->cn;
149     $this->orig_base= $this->base;
151     /* Instanciate base selector */
152     $this->baseSelector= new baseSelector($this->get_allowed_bases(), $this->base);
153     $this->baseSelector->setSubmitButton(false);
154     $this->baseSelector->setHeight(300);
155     $this->baseSelector->update(true);
156   }
158   function set_acl_base($base)
159   {
160     plugin::set_acl_base($base);
161     $this->netConfigDNS->set_acl_base($base);
162   }
164   function set_acl_category($cat)
165   {
166     plugin::set_acl_category($cat);
167     $this->netConfigDNS->set_acl_category($cat);
168   }
170   function execute()
171   {
172     /* Call parent execute */
173     plugin::execute();
175     if($this->is_account && !$this->view_logged){
176       $this->view_logged = TRUE;
177       new log("view","terminal/".get_class($this),$this->dn);
178     }
180     /* Do we need to flip is_account state? */
181     if (isset($_POST['modify_state'])){
182       $this->is_account= !$this->is_account;
183     }
185     if (isset($_POST['action']) && $this->acl_is_writeable("FAIstate") && isset($this->validActions[$_POST['saction']])){
186       $action = $_POST['saction'];
188       /* Check if we have an DaemonEvent for this action */
189       if(class_available("gosaSupportDaemon") && class_available("DaemonEvent_".$action)){
190         $events = DaemonEvent::get_event_types(SYSTEM_EVENT | HIDDEN_EVENT);
191         if(isset($events['TRIGGERED']["DaemonEvent_".$action])){
192           $evt = $events['TRIGGERED']["DaemonEvent_".$action];
193           $tmp = new $evt['CLASS_NAME']($this->config);
194           $tmp->add_targets(array($this->netConfigDNS->macAddress));
195           $tmp->set_type(TRIGGERED_EVENT);
196           $o_queue = new gosaSupportDaemon();
197           if(!$o_queue->append($tmp)){
198             msg_dialog::display(_("Service infrastructure"),msgPool::siError($o_queue->get_error()),ERROR_DIALOG);
199           }
200         }
201       }else{
202         msg_dialog::display(_("Event error"),
203                     sprintf(_("Event '%s' is not available!"),$action),ERROR_DIALOG);
204       }
206     }
208     /* Do we represent a valid terminal? */
209     if (!$this->is_account && $this->parent === NULL){
210       $display= "<img alt=\"\" src=\"images/small-error.png\" align=middle>&nbsp;<b>".
211         msgPool::noValidExtension(_("terminal"))."</b>";
212       return($display);
213     }
215     /* Add new ntp Server to our list */
216     if((isset($_POST['addNtpServer'])) && (isset($_POST['gotoNtpServers'])) && $this->acl_is_writeable("gotoNtpServer")){
217       $this->gotoNtpServer[$_POST['gotoNtpServers']] = $_POST['gotoNtpServers'];
218     }
220     /* Delete selected NtpServer for list of used servers  */
221     if((isset($_POST['delNtpServer'])) && (isset($_POST['gotoNtpServerSelected'])) && $this->acl_is_writeable("gotoNtpServer")){
222       foreach($_POST['gotoNtpServerSelected'] as $name){
223         unset($this->gotoNtpServer[$name]);
224       } 
225     }
227     /* Fill templating stuff */
228     $smarty= get_smarty();
229     $smarty->assign("usePrototype", "true");
230     
231     $tmp = $this->plInfo();
232     foreach($tmp['plProvidedAcls'] as $name => $translation){
233       $smarty->assign($name."ACL",$this->getacl($name));
234     }
236     $smarty->assign("cn", $this->cn);
237     $smarty->assign("description", $this->description);
238     $smarty->assign("staticAddress", "");
240     /* tell smarty the inherit checkbox state */
241     $smarty->assign("inheritTimeServer",$this->inheritTimeServer);
243     /* Check if terminal is online */
244     if (class_available("gosaSupportDaemon") && gosaSupportDaemon::ping($this->netConfigDNS->macAddress)){
245       $smarty->assign("actions", array( "halt" => _("Switch off"), 
246                                         "reboot" => _("Reboot"),
247                                         #"memcheck" => _("Memory test"),
248                                         #"sysinfo"  => _("System analysis")
249                                         ));
250     } else {
251       $smarty->assign("actions", array("wake" => _("Wake up"),
252                                        #"memcheck" => _("Memory test"),
253                                        #"sysinfo"  => _("System analysis")
254                                         ));
255     }
257     /* Arrays */
258     $smarty->assign("modes", $this->modes);
260     $tmp2 = array(); 
261     $tmp2['!']= _("Local swap");
262     foreach($this->config->data['SERVERS']['NBD'] as $server){
263       if($server != "default"){
264         $tmp2[$server]= $server;
265       }else{
266         if($this->member_of_ogroup){
267           $tmp2[$server]="["._("inherited")."]";
268         }
269       }
270     }
271   
272     $smarty->assign("swapservers",     $tmp2);
273     $tmp2 = array(); 
274     foreach($this->config->data['SERVERS']['NFS'] as $server){
275       if($server != "default"){
276         $tmp2[$server]= $server;
277       }else{
278         if($this->member_of_ogroup){
279           $tmp2[$server]="["._("inherited")."]";
280         }
281       }
282     }
283   
284     $smarty->assign("nfsservers",     $tmp2);
285     $smarty->assign("syslogservers",  $this->gotoSyslogServers);
287     $tmp = array();
288     foreach($this->gotoNtpServers as $server){
289       if(!in_array_strict($server,$this->gotoNtpServer)){
290         $tmp[$server] = $server;
291       }
292     }
293     
294     $smarty->assign("ntpservers",     $tmp);
295     $smarty->assign("fai_activated",$this->fai_activated);
297     $si_url = $this->config->get_cfg_value("gosaSupportURI");
298     $smarty->assign("si_activated",!empty($si_url));
300     /* Variables */
301     foreach(array("gotoMode", "gotoTerminalPath", "gotoSwapServer","gotoSyslogServer", "gotoNtpServer") as $val){
302       $smarty->assign($val."_select", $this->$val);
303     }
304     $smarty->assign("base", $this->baseSelector->render());
306     $smarty->assign("member_of_ogroup",$this->member_of_ogroup);
308     /* Show main page */
309     $str = $this->netConfigDNS->execute();
310     if(is_object($this->netConfigDNS->dialog)){
311       return($str);
312     }
313     $smarty->assign("netconfig", $str);
315     /* Display kerberos host key options */  
316     $smarty->assign("host_key","");
317     if(is_object($this->kerberos_key_service)){
318       $smarty->assign("host_key",$this->kerberos_key_service->execute_by_prefix("host/"));
319     }
321     return($smarty->fetch (get_template_path('terminal.tpl', TRUE, dirname(__FILE__))));
322   }
324   function remove_from_parent()
325   {
326     if($this->acl_is_removeable()){   
327       $ldap= $this->config->get_ldap_link();
328       $ldap->cd($this->dn);
329       $ldap->cat($this->dn, array('dn'));
330       if($ldap->count()){
331         $this->netConfigDNS->remove_from_parent();
332         $ldap->rmDir($this->dn);
333   
334         new log("remove","terminal/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
335   
336         if (!$ldap->success()){
337           msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, LDAP_DEL, get_class()));
338         }
340         /* Remove kerberos key dependencies too */
341         if(is_object($this->kerberos_key_service)){
342           $this->kerberos_key_service->remove_from_parent_by_prefix("host/");
343         }
345         /* Optionally execute a command after we're done */
346         $this->handle_post_events("remove",array("macAddress" => $this->netConfigDNS->macAddress,"ipHostNumber" => $this->netConfigDNS->ipHostNumber));
348         /* Delete references to object groups */
349         $ldap->cd ($this->config->current['BASE']);
350         $ldap->search ("(&(objectClass=gosaGroupOfNames)(member=".LDAP::prepare4filter($this->dn)."))", array("cn"));
351         while ($ldap->fetch()){
352           $og= new ogroup($this->config, $ldap->getDN());
353           unset($og->member[$this->dn]);
354           $og->save ();
355         }
357         /* Remove all accessTo/trust dependencies */
358         update_accessTo($this->cn,"");
359       }
361       /* Clean queue form entries with this mac 
362        */
363       if(class_available("gosaSupportDaemon") && tests::is_mac($this->netConfigDNS->orig_macAddress)){
364         $q = new gosaSupportDaemon();
365         $q->clean_queue_from_mac($this->netConfigDNS->orig_macAddress);
366       }
367     }
368   }
371   /* Save data to object */
372   function save_object()
373   {
374     /* Create a base backup and reset the
375        base directly after calling plugin::save_object();
376        Base will be set seperatly a few lines below */
377     $base_tmp = $this->base;
378     plugin::save_object();
379     $this->base = $base_tmp;
381     /* Refresh base */
382     if ($this->acl_is_moveable($this->base)){
383       if (!$this->baseSelector->update()) {
384         msg_dialog::display(_("Error"), msgPool::permMove(), ERROR_DIALOG);
385       }
386       if ($this->base != $this->baseSelector->getBase()) {
387         $this->base= $this->baseSelector->getBase();
388         $this->is_modified= TRUE;
389       }
390     }
391     
392     $this->netConfigDNS->save_object();
394     /* Save terminal path to parent since it is used by termstartup, too */
395     if(isset($this->parent->by_object['termstartup'])){
396       $this->parent->by_object['termstartup']->gotoTerminalPath= $this->gotoTerminalPath;
397     }
398     
399     if(isset($_POST['termgeneric_posted'])){
400       if(isset($_POST["inheritTimeServer"]) && $this->member_of_ogroup){
401         $this->inheritTimeServer = true;
402       }else{
403         $this->inheritTimeServer = false;
404       }
405     }  
407     if(isset($_POST["inheritAll"])){
408       $this->set_everything_to_inherited();
409     }
411     /* Hanle kerberos host key plugin */
412     if(is_object($this->kerberos_key_service)){
413       $this->kerberos_key_service->save_object_by_prefix("host/");
414     }
415   }
418   /* Check supplied data */
419   function check()
420   {
421     /* Call common method to give check the hook */
422     $message= plugin::check();
424     /* Skip IP & Mac checks if this is a template */
425     if($this->cn != "default"){
426       $message= array_merge($message, $this->netConfigDNS->check());
427     }
429     /* Permissions for that base? */
430     $this->dn= "cn=".$this->cn.",".get_ou('terminalRDN').$this->base;
432     if ($this->cn == ""){
433       $message[]= msgPool::required(_("Name"));
434     }
436     // Check if a wrong base was supplied
437     if(!$this->baseSelector->checkLastBaseUpdate()){
438       $message[]= msgPool::check_base();
439     }
441     /* Check if given name is a valid host/dns name */
442     if(!tests::is_dns_name($this->cn) ){
443       $message[] = msgPool::invalid(_("Name"));
444     }
446     if ($this->orig_dn == 'new'){
447       $ldap= $this->config->get_ldap_link();
448       $ldap->cd ($this->base);
450       /* It is possible to have a 'default' terminal on every base */
451       if($this->cn == "default"){
452         $ldap->cat($this->dn);
453       }else{
454         $ldap->search ("(&(objectClass=gotoTerminal)(cn=".$this->cn."))", array("cn"));
455       }
456       if ($ldap->count() != 0){
457         while ($attrs= $ldap->fetch()){
458           if (preg_match("/cn=dhcp,/",$attrs['dn']) || preg_match ("/,".preg_quote(get_ou('systemIncomingRDN'), '/')."/i", $ldap->getDN())){
459             continue;
460           } else {
461             if ($attrs['dn'] != $this->orig_dn){
462               $message[]= msgPool::duplicated(_("Name"));
463               break;
464             }
465           }
466         }
467       }
468     }
470     /* Check for valid ntpServer selection */
471     if((!$this->inheritTimeServer) && (!count($this->gotoNtpServer))){
472       $message[]= msgPool::required(_("NTP server"));
473     }
475     /* Check if we are allowed to create or move this object
476      */
477     if($this->orig_dn == "new" && !$this->acl_is_createable($this->base)){
478       $message[] = msgPool::permCreate();
479     }elseif($this->orig_dn != "new" && $this->base != $this->orig_base && !$this->acl_is_moveable($this->base)){
480       $message[] = msgPool::permMove();
481     }
483     return ($message);
484   }
487   /* Save to LDAP */
488   function save()
489   {
490     /* Detect mode changes */
491     $activate= (isset($this->saved_attributes['gotoMode']) &&
492         $this->gotoMode != $this->saved_attributes['gotoMode'] &&
493         $this->gotoMode == "active" &&
494         tests::is_ip($this->netConfigDNS->ipHostNumber)) || $this->auto_activate;
496     /* Find proper terminal path for tftp configuration
497        FIXME: This is suboptimal when the default has changed to
498        another location! */
499     if ($this->gotoTerminalPath == "default"){
500       $ldap= $this->config->get_ldap_link();
502       /* Strip relevant part from dn, keep trailing ',' */
503       $tmp= preg_replace("/^cn=[^,]+,".preg_quote(get_ou('terminalRDN'), '/')."/i", "", $this->dn);
504       $tmp= preg_replace("/".$this->config->current['BASE']."$/i", "", $tmp);
506       /* Walk from top to base and try to load default values for
507          'gotoTerminalPath'. Abort when an entry is found. */
508       while (TRUE){
509         $tmp= preg_replace ("/^[^,]+,/", "", $tmp);
511         $ldap->cat("cn=default,".get_ou('terminalRDN').$tmp.
512             $this->config->current['BASE'], array('gotoTerminalPath'));
513         $attrs= $ldap->fetch();
514         if (isset($attrs['gotoTerminalPath'])){
515           $this->gotoTerminalPath= $attrs['gotoTerminalPath'][0];
516           break;
517         }
519         /* Nothing left? */
520         if ($tmp == ""){
521           break;
522         }
523       }
524     }
526     plugin::save();
528     /* Strip out 'default' values */
529     foreach (array("gotoTerminalPath", "gotoSwapServer", "gotoSyslogServer") as $val){
530       if(isset($this->attrs[$val])){
531         if ($this->attrs[$val] == "default"){
532           $this->attrs[$val]= array();
533         }
534       }
535     }
537     /* Add missing arrays */
538     foreach (array("ghScsiDev", "ghIdeDev", "ghNetNic") as $val){
539       if (isset ($this->$val) && count ($this->$val) != 0){
540         $this->attrs["$val"]= $this->$val;
541       }
542     }
544     /* Remove all empty values */
545     if ($this->orig_dn == 'new'){
546       $attrs= array();
547       foreach ($this->attrs as $key => $val){
548         if (is_array($val) && count($val) == 0){
549           continue;
550         }
551         $attrs[$key]= $val;
552       }
553       $this->attrs= $attrs;
554     }
556     /* Set ntpServers */
557     $this->attrs['gotoNtpServer'] = array();
558     if(!$this->inheritTimeServer){
559       foreach($this->gotoNtpServer as $server){
560         $this->attrs['gotoNtpServer'][] = $server;
561       }
562     }
564     /* cn=default and macAddress=- indicates that this is a template */
565     if($this->cn == "default"){
566       $this->netConfigDNS->macAddress = "-";
567     }
569     /* Write back to ldap */
570     $ldap= $this->config->get_ldap_link();
571     if ($this->orig_dn == 'new'){
572       $ldap->cd($this->config->current['BASE']);
573       $ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $this->dn));
574       $ldap->cd($this->dn);
575       if (!count($this->attrs['gotoNtpServer'])){
576         unset($this->attrs['gotoNtpServer']);
577       }
578       $ldap->add($this->attrs);
579       new log("create","terminal/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
581       $this->netConfigDNS->cn = $this->cn;
582       $this->netConfigDNS->save();
584       $this->handle_post_events("add",array("macAddress" => $this->netConfigDNS->macAddress,"ipHostNumber" => $this->netConfigDNS->ipHostNumber));
585     } else {
586       $ldap->cd($this->dn);
587       $this->cleanup();
588       $ldap->modify ($this->attrs); 
589       new log("modify","terminal/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
591       $this->netConfigDNS->cn = $this->cn;
592       $this->netConfigDNS->save();
594       $this->handle_post_events("modify",array("macAddress" => $this->netConfigDNS->macAddress,"ipHostNumber" => $this->netConfigDNS->ipHostNumber));
596       /* Update all accessTo/trust dependencies */
597       if($this->orig_cn != $this->cn){
598         update_accessTo($this->orig_cn,$this->cn);
599       }
600     }
601     
602     if (!$ldap->success()){
603       msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, 0, get_class()));
604     }
606     /* Send installation activation
607      */
608     if ($activate && class_available("DaemonEvent")){
609       $events = DaemonEvent::get_event_types(SYSTEM_EVENT | HIDDEN_EVENT);
610       $o_queue = new gosaSupportDaemon();
611       if(isset($events['TRIGGERED']['DaemonEvent_installation_activation'])){
612         $evt = $events['TRIGGERED']['DaemonEvent_installation_activation'];
613         $tmp = new $evt['CLASS_NAME']($this->config);
614         $tmp->set_type(TRIGGERED_EVENT);
615         $tmp->add_targets(array($this->netConfigDNS->macAddress));
616         if(!$o_queue->append($tmp)){
617           msg_dialog::display(_("Service infrastructure"),msgPool::siError($o_queue->get_error()),ERROR_DIALOG);
618         }
619       }
620     }
621   }
624   /* Display generic part for server copy & paste */
625   function getCopyDialog()
626   {
627     $vars = array("cn");
628     $smarty = get_smarty();
629     $smarty->assign("cn" ,$this->cn);
630     $smarty->assign("object","terminal");
631     $str = $smarty->fetch(get_template_path("paste_generic.tpl",TRUE));
632     $ret = array();
633     $ret['string'] = $str;
634     $ret['status'] = "";
635     return($ret);
636   }
639   function saveCopyDialog()
640   {
641     if(isset($_POST['cn'])){
642       $this->cn = $_POST['cn'];
643     }
644   }
647   function PrepareForCopyPaste($source)
648   {
649     plugin::PrepareForCopyPaste($source);
650     if(isset($source['macAddress'][0])){
651       $this->netConfigDNS->macAddress = $source['macAddress'][0];
652     }
653     if(isset($source['ipHostNumber'][0])){
654       $this->netConfigDNS->ipHostNumber = $source['ipHostNumber'][0];
655     }
657     /* Create used ntp server array */
658     $this->gotoNtpServer= array();
659     if(isset($source['gotoNtpServer'])){
660       $this->inheritTimeServer = false;
661       unset($source['gotoNtpServer']['count']);
662       foreach($source['gotoNtpServer'] as $server){
663         $this->gotoNtpServer[$server] = $server;
664       }
665     }
667     /* Set inherit checkbox state */
668     if((in_array_strict("default",$this->gotoNtpServer)) || (count($this->gotoNtpServer)==0)){
669       $this->inheritTimeServer = true;
670       $this->gotoNtpServer=array();
671     }
672   }
675   /* Return plugin informations for acl handling */
676   static function plInfo()
677   {
678     return (array(
679           "plShortName"   => _("Terminal"),
680           "plDescription" => _("Terminal generic"),
681           "plSelfModify"  => FALSE,
682           "plDepends"     => array(),
683           "plPriority"    => 1,
684           "plSection"     => array("administration"),
685           "plCategory"    => array("terminal" => array( "description"  => _("Terminal"),
686               "objectClass"  => "gotoTerminal")),
687           "plProvidedAcls"=> array(
688             "cn"                  => _("Name"),
689             "description"         => _("Description"),
690             "base"                => _("Base"),
692             "gotoMode"            => _("Mode"),
693             "gotoSyslogServer"    => _("Syslog server enabled"),
695             "gotoTerminalPath"    => _("Root server"),
696             "gotoSwapServer"      => _("Swap server"),
698             "gotoNtpServer"       => _("Ntp server settings"),
699             "userPassword"      => _("Root password"),
701             "FAIstate"            => _("Action flag"))
702           ));
703   }
706   function set_everything_to_inherited()
707   {
708     $this->gotoTerminalPath  = "default";
709     $this->gotoSwapServer    = "default" ;
710     $this->gotoSyslogServer  = "default";
711     $this->inheritTimeServer = TRUE;
713     /* Set workstation service attributes to inherited */
714     if($this->member_of_ogroup && isset($this->parent->by_object['termservice'])){
715       foreach(array("gotoXKbLayout","gotoXKbModel","gotoXKbVariant","gotoXDriver",
716             "gotoXResolution","gotoXColordepth","gotoXMouseType","gotoXMouseport") as $name){
717         $this->parent->by_object['termservice']->$name = "default";
718       }
719     }
721     /* Set workstation startup attributes to inherited */
722     if($this->member_of_ogroup && isset($this->parent->by_object['termstartup'])){
723       $this->parent->by_object['termstartup']->gotoBootKernel = "default-inherited";
724       $this->parent->by_object['termstartup']->gotoLdapServer = "default-inherited";
725       $this->parent->by_object['termstartup']->gotoLdap_inherit = TRUE;
726       $this->parent->by_object['termstartup']->gotoLdapServers = array();
727     }
728   }
731   function is_modal_dialog()
732   {
733     return((isset($this->dialog) && $this->dialog) || (isset($this->netConfigDNS->dialog) && $this->netConfigDNS->dialog));
734   }
738 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
739 ?>