Code

Added sorting to workstation startup. FAI server/release
[gosa.git] / gosa-plugins / goto / admin / systems / goto / class_workstationGeneric.inc
1 <?php
3 class workgeneric extends plugin
4 {
5   /* Generic terminal attributes */
6   var $gotoMode= "locked";
7   var $initial_gotoMode= "locked";
8   var $gotoSyslogServer= "";
9   var $gotoSyslogServers= array();
10   var $gotoNtpServer= array();
11   var $gotoNtpServers= array();
12   var $gotoSndModule= "";
13   var $gotoFloppyEnable= "";
14   var $gotoCdromEnable= "";
15   var $description= "";
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 $FAIscript= "";
26   var $view_logged = FALSE;
27   var $auto_activate= FALSE;
29   /* Needed values and lists */
30   var $base= "";
31   var $cn= "";
32   var $l= "";
33   var $orig_dn= "";
34   var $orig_cn= "";
35   var $orig_base= "";
37   /* Plugin side filled */
38   var $modes= array();
40   var $netConfigDNS;
42   var $inheritTimeServer = true;
44   /* attribute list for save action */
45   var $ignore_account= TRUE;
46   var $attributes= array("gotoMode", "gotoSyslogServer", "gotoNtpServer",
47       "gotoFloppyEnable", "gotoCdromEnable", "cn", "gotoSndModule",
48       "ghCpuType", "ghMemSize", "ghUsbSupport", "description",
49       "ghGfxAdapter", "ghSoundAdapter", "gotoLastUser", "l","FAIscript");
50   var $objectclasses= array("top", "gotoWorkstation", "GOhard");
52   var $validActions   = array("reboot" => "", "localboot" => "", "halt" => "", "update" => "", "reinstall" => "",
53                             "rescan" => "", "wake" => "", "memcheck" => "", "sysinfo" => "");
54   
55   var $fai_activated = FALSE;
57   var $member_of_ogroup = FALSE;
59   var $currently_installing = FALSE;
60   var $currently_installing_warned = FALSE;
62   var $kerberos_key_service = NULL;
64   function workgeneric (&$config, $dn= NULL, $parent= NULL)
65   {
66     $tmp= $config->search("faiManagement", "CLASS",array('menu','tabs'));
67     if(!empty($tmp)){
68       $this->fai_activated = TRUE;
69     }
71     plugin::plugin ($config, $dn, $parent);
73     if(class_available("krb_host_keys")){
74       $this->kerberos_key_service = new krb_host_keys($this->config,$this);
75     }
77     if(!isset($this->parent->by_object['ogroup'])){
78       $ldap = $this->config->get_ldap_link();
79       $ldap->cd ($this->config->current['BASE']);
80       $ldap->search("(&(objectClass=gotoWorkstationTemplate)(member=".LDAP::prepare4filter($this->dn)."))",array("cn"));
81       $this->member_of_ogroup = $ldap->count() >= 1;
82     }
84     $this->netConfigDNS = new termDNS($this->config,$this,$this->objectclasses);
86     /* Check if this host is currently in installation process*/
87     if(class_available("gosaSupportDaemon") && class_available("DaemonEvent")){
88       $o = new gosaSupportDaemon();
89       $e_types = DaemonEvent::get_event_types(USER_EVENT | SYSTEM_EVENT | HIDDEN_EVENT);
90       $evts = $o->get_entries_by_mac(array($this->netConfigDNS->macAddress));
91       foreach($evts as $evt){
92         if(isset($e_types['QUEUED'][$evt['HEADERTAG']]) && $evt['STATUS'] == "processing" &&
93             $e_types['QUEUED'][$evt['HEADERTAG']] == "DaemonEvent_reinstall"){
94           $this->currently_installing =TRUE;
95         }
96       }
97     }
99     /* Read arrays */
100     foreach (array("ghNetNic", "ghIdeDev", "ghScsiDev") as $val){
101       if (!isset($this->attrs[$val])){
102         continue;
103       }
104       for ($i= 0; $i<$this->attrs[$val]['count']; $i++){
105         array_push($this->$val, $this->attrs[$val][$i]);
106       }
107     }
109     /* Create used ntp server array */
110     $this->gotoNtpServer= array();
111     if(isset($this->attrs['gotoNtpServer'])){
112       $this->inheritTimeServer = false;
113       unset($this->attrs['gotoNtpServer']['count']);
114       foreach($this->attrs['gotoNtpServer'] as $server){
115         $this->gotoNtpServer[$server] = $server;
116       }
117     }
119     /* Set inherit checkbox state */
120     if((in_array("default",$this->gotoNtpServer)) || (count($this->gotoNtpServer) == 0)){
121       $this->inheritTimeServer = true;
122       $this->gotoNtpServer=array();
123     }
125     /* You can't inherit the NTP service, if we are not member in an object group */
126     if(!$this->member_of_ogroup){
127       $this->inheritTimeServer = FALSE;
128     }
130     /* Create available ntp options */
131     $tmp = $this->config->data['SERVERS']['NTP'];
132     $this->gotoNtpServers = array();
133     foreach($tmp as $key => $server){
134       if($server == "default") continue;
135       $this->gotoNtpServers[$server] = $server;
136     }
138     $this->modes["active"]= _("Activated");
139     $this->modes["locked"]= _("Locked");
141     /* Set base */
142     if ($this->dn == "new"){
143       $ui= get_userinfo();
144       $this->base= dn2base($ui->dn);
145     } else {
146       $this->base= preg_replace ("/^[^,]+,".normalizePreg(get_ou("workstationou"))."/i", "", $this->dn);
147     }
149     /* Create an array of all Syslog servers */
150     $tmp = $this->config->data['SERVERS']['SYSLOG'];
151     foreach($tmp as $server){
152       $visible = $server;
153       if($server == "default" && $this->member_of_ogroup) {
154         $visible = "["._("inherited")."]";
155       }
156       $this->gotoSyslogServers[$server] = $visible;
157     }
159     $this->initial_gotoMode = $this->gotoMode;
161     /* Save 'dn' for later referal */
162     $this->orig_dn= $this->dn;
163     $this->orig_cn= $this->cn;
164     $this->orig_base= $this->base;
165   }
168   function set_acl_base($base)
169   {
170     plugin::set_acl_base($base);
171     $this->netConfigDNS->set_acl_base($base);
172   }
174   function set_acl_category($cat)
175   {
176     plugin::set_acl_category($cat);
177     $this->netConfigDNS->set_acl_category($cat);
178   }
180   function execute()
181   {
182     /* Call parent execute */
183     plugin::execute();
185     if($this->is_account && !$this->view_logged){
186       $this->view_logged = TRUE;
187       new log("view","workstation/".get_class($this),$this->dn);
188     }
190     /* Do we need to flip is_account state? */
191     if(isset($_POST['modify_state'])){
192       if($this->is_account && $this->acl_is_removeable()){
193         $this->is_account= FALSE;
194       }elseif(!$this->is_account && $this->acl_is_createable()){
195         $this->is_account= TRUE;
196       }
197     }
199     if ((isset($_POST['action'])) && ($this->acl_is_writeable("FAIstate")) && isset($this->validActions[$_POST['saction']]) ){
200       $action= $_POST['saction'];
202       /* Check if we have an DaemonEvent for this action */ 
203       if(class_available("DaemonEvent")){
204         $events = DaemonEvent::get_event_types(SYSTEM_EVENT | HIDDEN_EVENT);
205         if(isset($events['TRIGGERED']["DaemonEvent_".$action])){
206           $evt = $events['TRIGGERED']["DaemonEvent_".$action];
207           $tmp = new $evt['CLASS_NAME']($this->config);
208           $tmp->add_targets(array($this->netConfigDNS->macAddress));
209           $tmp->set_type(TRIGGERED_EVENT);
210           $o_queue = new gosaSupportDaemon();
211           if(!$o_queue->append($tmp)){
212             msg_dialog::display(_("Service infrastructure"),msgPool::siError($o_queue->get_error()),ERROR_DIALOG);
213           }
214         }
215       } else {
216         msg_dialog::display(_("Event error"),
217                     sprintf(_("Event '%s' is not available!"),$action),ERROR_DIALOG);
218       }
221     }
223     /* Do we represent a valid terminal? */
224     if (!$this->is_account && $this->parent === NULL){
225       $display= "<img alt=\"\" src=\"images/small-error.png\" align=middle>&nbsp;<b>".
226         msgPool::noValidExtension(_("workstation"))."</b>";
227       return($display);
228     }
230     /* Base select dialog */
231     $once = true;
232     foreach($_POST as $name => $value){
233       if(preg_match("/^chooseBase/",$name) && $once && $this->acl_is_writeable("base")){
234         $once = false;
235         $this->dialog = new baseSelectDialog($this->config,$this,$this->get_allowed_bases());
236         $this->dialog->setCurrentBase($this->base);
237       }
238     }
240     /* Dialog handling */
241     if(is_object($this->dialog)){
242       /* Must be called before save_object */
243       $this->dialog->save_object();
245       if($this->dialog->isClosed()){
246         $this->dialog = false;
247       }elseif($this->dialog->isSelected()){
249         /* A new base was selected, check if it is a valid one */
250         $tmp = $this->get_allowed_bases();
251         if(isset($tmp[$this->dialog->isSelected()])){
252           $this->base = $this->dialog->isSelected();
253         }
255         $this->dialog= false;
256       }else{
257         return($this->dialog->execute());
258       }
259     }
261     /* Add new ntp Server to our list */ 
262     if((isset($_POST['addNtpServer'])) && (isset($_POST['gotoNtpServers'])) && $this->acl_is_writeable("gotoNtpServer")){
263       $this->gotoNtpServer[$_POST['gotoNtpServers']] = $_POST['gotoNtpServers'];
264     }
266     /* Delete selected NtpServer for list of used servers  */
267     if((isset($_POST['delNtpServer'])) && (isset($_POST['gotoNtpServerSelected'])) && $this->acl_is_writeable("gotoNtpServer")){
268       foreach($_POST['gotoNtpServerSelected'] as $name){
269         unset($this->gotoNtpServer[$name]);
270       }
271     }
273     /* Fill templating stuff */
274     $smarty= get_smarty();
276     /* Set acls */
277     $tmp = $this->plInfo();
278     foreach($tmp['plProvidedAcls'] as $name => $translation){
279       $smarty->assign($name."ACL",$this->getacl($name));
280     }
282     $smarty->assign("cn", $this->cn);
283     $smarty->assign("description", $this->description);
284     $smarty->assign("l", $this->l);
285     $smarty->assign("bases", $this->get_allowed_bases());
286     $smarty->assign("staticAddress", "");
288     $tmp = array();
289     foreach($this->gotoNtpServers as $server){
290       if(!in_array($server,$this->gotoNtpServer)){
291         $tmp[$server] = $server;
292       }
293     }
294     $smarty->assign("gotoNtpServers",$tmp);
295         
296     /* Check if workstation is online */
297     if (gosaSupportDaemon::ping($this->netConfigDNS->macAddress)){
298       $smarty->assign("actions", array("halt" => _("Switch off"), "reboot" => _("Reboot"),
299                                        "update" => _("Software update"),
300                                        "reinstall" => _("Reinstall"),
301                                        "rescan" => _("Rescan hardware"),
302                                        "memcheck" => _("Memory test"),
303                                        "localboot" => _("Force localboot"),
304                                        "sysinfo"  => _("System analysis")));
305     } else {
306       $smarty->assign("actions", array("wake" => _("Wake up"),
307                                        "reinstall" => _("Reinstall"),
308                                        "update" => _("Software update"),
309                                        "memcheck" => _("Memory test"),
310                                        "localboot" => _("Force localboot"),
311                                        "sysinfo"  => _("System analysis")));
312     }
313     /* Arrays */
314     $smarty->assign("modes", $this->modes);
315     $smarty->assign("nfsservers", $this->config->data['SERVERS']['NFS']);
316     $smarty->assign("syslogservers", $this->gotoSyslogServers);
317     $smarty->assign("fai_activated",$this->fai_activated);
319     $ntpser = array();
320     foreach($this->gotoNtpServers as $server){
321       if(!in_array($server,$this->gotoNtpServer)){
322         $ntpser[$server] = $server;
323       }
324     }
325     $smarty->assign("gotoNtpServers", $ntpser);
327     /* Variables */
328     foreach(array("base", "gotoMode", "gotoSyslogServer", "gotoNtpServer") as $val){
329       $smarty->assign($val."_select", $this->$val);
330     }
332     /* tell smarty the inherit checkbox state */
333     $smarty->assign("inheritTimeServer",$this->inheritTimeServer);
334     $smarty->assign("member_of_ogroup",$this->member_of_ogroup);
336     $str = $this->netConfigDNS->execute();
337     if(is_object($this->netConfigDNS->dialog)){
338       return($str);
339     }
340     $smarty->assign("netconfig", $str);
342     /* Display kerberos host key options */
343     $smarty->assign("host_key","");
344     if(is_object($this->kerberos_key_service)){
345       $smarty->assign("host_key",$this->kerberos_key_service->execute_by_prefix("host/"));
346     }
348     /* Show main page */
349     $smarty->assign("currently_installing", $this->currently_installing);
350     return($smarty->fetch (get_template_path('workstation.tpl', TRUE, dirname(__FILE__))));
351   }
353   function remove_from_parent()
354   {
355     if($this->acl_is_removeable()){
357       $this->netConfigDNS->remove_from_parent();
358       $ldap= $this->config->get_ldap_link();
359       $ldap->rmdir($this->dn);
360       new log("remove","workstation/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
361       if (!$ldap->success()){
362         msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, LDAP_DEL, get_class()));
363       }
365       /* Remove kerberos key dependencies too */
366       if(is_object($this->kerberos_key_service)){
367         $this->kerberos_key_service->remove_from_parent_by_prefix("host/");
368       }
370       /* Optionally execute a command after we're done */
371       $this->handle_post_events("remove", array("macAddress" => $this->netConfigDNS->macAddress,"ipHostNumber" => $this->netConfigDNS->ipHostNumber));
373       /* Delete references to object groups */
374       $ldap->cd ($this->config->current['BASE']);
375       $ldap->search ("(&(objectClass=gosaGroupOfNames)(member=".LDAP::prepare4filter($this->dn)."))", array("cn"));
376       while ($ldap->fetch()){
377         $og= new ogroup($this->config, $ldap->getDN());
378         unset($og->member[$this->dn]);
379         $og->save ();
380       }
382       /* Remove all accessTo/trust dependencies */
383       update_accessTo($this->cn,"");
384     }
386     /* Clean queue form entries with this mac 
387      */
388     if(class_available("gosaSupportDaemon") && tests::is_mac($this->netConfigDNS->orig_macAddress)){
389       $q = new gosaSupportDaemon();
390       $q->clean_queue_from_mac($this->netConfigDNS->orig_macAddress);
391     }
393     if(isset($_POST["inheritAll"])){
394       $this->set_everything_to_inherited();
395     }
396   }
399   /* Save data to object */
400   function save_object()
401   {
403     /* Create a base backup and reset the
404        base directly after calling plugin::save_object();
405        Base will be set seperatly a few lines below */
406     $base_tmp = $this->base;
407     plugin::save_object();
408     $this->base = $base_tmp;
410     /* Save base, since this is no LDAP attribute */
411     $tmp = $this->get_allowed_bases();
412     if(isset($_POST['base'])){
413       if(isset($tmp[$_POST['base']])){
414         $this->base= $_POST['base'];
415       }
416     }
418     $this->netConfigDNS->save_object();
420     /* Set inherit mode */
421     if((isset($_POST['workgeneric_posted'])) && ($this->acl_is_writeable("gotoNtpServer"))){
422       if(isset($_POST["inheritTimeServer"]) && $this->member_of_ogroup){
423         $this->inheritTimeServer = true;
424       }else{
425         $this->inheritTimeServer = false;
426       }
427     }
428     
429     if(isset($_POST["inheritAll"])){
430       $this->set_everything_to_inherited();
431     }
433     /* Hanle kerberos host key plugin */
434     if(is_object($this->kerberos_key_service)){
435       $this->kerberos_key_service->save_object_by_prefix("host/");
436     }
437   }
440   /* Check supplied data */
441   function check()
442   {
443     /* Call common method to give check the hook */
444     $message= plugin::check();
445  
446     /* Skip IP & Mac checks if this is a template */
447     if($this->cn != "wdefault"){
448       $message= array_merge($message, $this->netConfigDNS->check());
449     }
451     $this->dn= "cn=".$this->cn.",".get_ou('workstationou').$this->base;
453     if ($this->cn == ""){
454       $message[]= msgPool::required(_("Name"));
455     }
457     /* Check if given name is a valid host/dns name */
458     if(!tests::is_dns_name($this->cn)){
459       $message[] = msgPool::invalid(_("Name"));
460     }
462     if ($this->orig_dn != $this->dn){
463       $ldap= $this->config->get_ldap_link();
464       $ldap->cd ($this->base);
466       if($this->cn == "wdefault"){
467         $ldap->cat($this->dn);
468       }else{
469         $ldap->search ("(&(cn=".$this->cn.")(objectClass=gotoWorkstation))", array("cn"));
470       }
471       if ($ldap->count() != 0){
472         while ($attrs= $ldap->fetch()){
473           if (preg_match("/cn=dhcp,/",$attrs['dn']) || preg_match ("/,".get_ou('incomingou')."/", $ldap->getDN())){
474             continue;
475           } else {
476             if ($attrs['dn'] != $this->orig_dn){
477               $message[]= msgPool::duplicated(_("Name"));
478               break;
479             }
480           }
481         }
482       }
483     }
485     /* Check for valid ntpServer selection */
486     if((!$this->inheritTimeServer) && (!count($this->gotoNtpServer))){
487       $message[]= msgPool::required(_("NTP server"));
488     }
490     /* Only systems with a valid ldap handle can be activated 
491      */
492     if($this->gotoMode == "active" && $this->initial_gotoMode != "active"){
494       if(isset($this->parent->by_object['workstartup']) &&
495           !count($this->parent->by_object['workstartup']->gotoLdapServers) && 
496           !$this->parent->by_object['workstartup']->gotoLdap_inherit){
498         $message[] = _("A valid LDAP server assignement is missing!");
499       }
500     }else{
501       /* Warn the user, that this host is currently installing */
502       if($this->currently_installing && !$this->currently_installing_warned && 
503           !preg_match("/".normalizePreg(get_ou("incomingou"))."/",$this->orig_dn)){
504       
505         /* Force aborting without message dialog */
506         $message[] = "";
507         $this->currently_installing_warned = TRUE;
508         msg_dialog::display(_("Software deployment"), 
509             _("This host is currently installing. If you want to save it, press 'OK'."),
510             CONFIRM_DIALOG);
511       }
512     }
514     /* Check if we are allowed to create or move this object
515      */
516     if($this->orig_dn == "new" && !$this->acl_is_createable($this->base)){
517       $message[] = msgPool::permCreate();
518     }elseif($this->orig_dn != "new" && $this->base != $this->orig_base && !$this->acl_is_moveable($this->base)){
519       $message[] = msgPool::permMove();
520     }
521  
522     return ($message);
523   }
526   /* Save to LDAP */
527   function save()
528   {
529     /* Detect mode changes */
530     $activate= (isset($this->saved_attributes['gotoMode']) &&
531         $this->gotoMode != $this->saved_attributes['gotoMode'] &&
532         $this->gotoMode == "active" &&
533         tests::is_ip($this->netConfigDNS->ipHostNumber)) || $this->auto_activate;
534     plugin::save();
536     /* Strip out 'default' values */
537     foreach (array("gotoSyslogServer") as $val){
539       if (isset($this->attrs[$val]) && $this->attrs[$val] == "default"){
540         $this->attrs[$val]= array();
541       }
542     }
544     /* Add missing arrays */
545     foreach (array("ghScsiDev", "ghIdeDev", "ghNetNic") as $val){
546       if (isset ($this->$val) && count ($this->$val) != 0){
547         $this->attrs["$val"]= $this->$val;
548       }
549     }
551     /* Remove all empty values */
552     if ($this->orig_dn == 'new'){
553       $attrs= array();
554       foreach ($this->attrs as $key => $val){
555         if (is_array($val) && count($val) == 0){
556           continue;
557         }
558         $attrs[$key]= $val;
559       }
560       $this->attrs= $attrs;
561     }
563     /* Update ntp server settings */
564     if($this->inheritTimeServer){
565       if($this->is_new){
566         if(isset($this->attrs['gotoNtpServer'])){
567           unset($this->attrs['gotoNtpServer']);
568         }
569       }else{
570         $this->attrs['gotoNtpServer'] = array();
571       }
572     }else{
573       /* Set ntpServers */
574       $this->attrs['gotoNtpServer'] = array();
575       foreach($this->gotoNtpServer as $server){
576         $this->attrs['gotoNtpServer'][] = $server;
577       }
578     }
580     /* Write back to ldap */
581     $ldap= $this->config->get_ldap_link();
582     if ($this->orig_dn == 'new'){
583       $ldap->cd($this->config->current['BASE']);
584       $ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $this->dn));
585       $ldap->cd($this->dn);
586       $ldap->add($this->attrs);
587       new log("create","workstation/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
588       if (!$ldap->success()){
589         msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, 0, get_class()));
590       }
591       $this->handle_post_events("add",array("macAddress" => $this->netConfigDNS->macAddress,"ipHostNumber" => $this->netConfigDNS->ipHostNumber));
592     } else {
593       if ($this->orig_dn != $this->dn){
595         /* Remove all accessTo/trust dependencies */
596         update_accessTo($this->orig_cn,$this->cn);
597       }
598       $ldap->cd($this->dn);
599       $this->cleanup();
600       $ldap->modify ($this->attrs); 
601       if (!$ldap->success()){
602         msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, LDAP_MOD, get_class()));
603       }
604       new log("modify","workstation/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
605       $this->handle_post_events("modify",array("macAddress" => $this->netConfigDNS->macAddress,"ipHostNumber" => $this->netConfigDNS->ipHostNumber));
606     }
608     /* cn=default and macAddress=- indicates that this is a template */
609     if($this->cn == "wdefault"){
610       $this->netConfigDNS->macAddress = "-";
611     }
613     $this->netConfigDNS->cn = $this->cn;
614     $this->netConfigDNS->save();
616     if ($activate && class_available("DaemonEvent")){
618       /* Send installation activation
619        */
620       $events = DaemonEvent::get_event_types(SYSTEM_EVENT | HIDDEN_EVENT);
621       $o_queue = new gosaSupportDaemon();
622       if(isset($events['TRIGGERED']['DaemonEvent_installation_activation'])){
623         $evt = $events['TRIGGERED']['DaemonEvent_installation_activation'];
624         $tmp = new $evt['CLASS_NAME']($this->config);
625         $tmp->set_type(TRIGGERED_EVENT);
626         $tmp->add_targets(array($this->netConfigDNS->macAddress));
627         if(!$o_queue->append($tmp)){
628           msg_dialog::display(_("Service infrastructure"),msgPool::siError($o_queue->get_error()),ERROR_DIALOG);
629         }
630       }
631     }
632   }
635   /* Display generic part for server copy & paste */
636   function getCopyDialog()
637   {
638     $vars = array("cn");
639     $smarty = get_smarty();
640     $smarty->assign("cn" ,$this->cn);
641     $smarty->assign("object","workstation");
642     $str = $smarty->fetch(get_template_path("paste_generic.tpl",TRUE));
643     $ret = array();
644     $ret['string'] = $str;
645     $ret['status'] = "";
646     return($ret);
647   }
650   function saveCopyDialog()
651   {
652     if(isset($_POST['cn'])){
653       $this->cn = $_POST['cn'];
654     }
655   }
658   function PrepareForCopyPaste($source)
659   {
660     plugin::PrepareForCopyPaste($source);
661     if(isset($source['macAddress'][0])){
662       $this->netConfigDNS->macAddress = $source['macAddress'][0];
663     }
664     if(isset($source['ipHostNumber'][0])){
665       $this->netConfigDNS->ipHostNumber = $source['ipHostNumber'][0];
666     }
668     /* Create used ntp server array */
669     $this->gotoNtpServer= array();
670     if(isset($source['gotoNtpServer'])){
671       $this->inheritTimeServer = false;
672       unset($source['gotoNtpServer']['count']);
673       foreach($source['gotoNtpServer'] as $server){
674         $this->gotoNtpServer[$server] = $server;
675       }
676     }
678     /* Set inherit checkbox state */
679     if((in_array("default",$this->gotoNtpServer)) || (count($this->gotoNtpServer)==0)){
680       $this->inheritTimeServer = true;
681       $this->gotoNtpServer=array();
682     }
683   }
686   /* Return plugin informations for acl handling 
687       #FIXME FAIscript seams to ununsed within this class... */ 
688   static function plInfo()
689   {
690     return (array(  
691           "plShortName"   => _("Generic"),
692           "plDescription" => _("Workstation generic"),
693           "plSelfModify"  => FALSE,
694           "plDepends"     => array(),
695           "plPriority"    => 0,
696           "plSection"     => array("administration"),
697           "plCategory"    => array("workstation" => array("description"  => _("Workstation"),
698                                                           "objectClass"  => "gotoWorkstation")),
699           "plProvidedAcls"=> array(
700             "cn"                  => _("Workstation name"),
701             "description"         => _("Description") ,
702             "l"                   => _("Location") ,
703             "base"                => _("Base") ,
704             "gotoMode"            => _("Goto mode"), 
705             "gotoSyslogServer"    => _("Syslog server"), 
706             "gotoNtpServer"       => _("Ntp server"), 
707             "gotoRootPasswd"      => _("Root password"),
708             "FAIstate"            => _("Action flag"))
709           ));
710   }
712   function set_everything_to_inherited()
713   {
714     $this->gotoSyslogServer  = "default";
715     $this->inheritTimeServer = TRUE;
717     /* Set workstation service attributes to inherited */
718     if($this->member_of_ogroup && isset($this->parent->by_object['workservice'])){
719       foreach(array("gotoXKbLayout","gotoXKbModel","gotoXKbVariant",
720             "gotoXResolution","gotoXColordepth","gotoXMouseType","gotoXMouseport") as $name){
721         $this->parent->by_object['workservice']->$name = "default"; 
722       }
723     }
725     /* Set workstation startup attributes to inherited */
726     if($this->member_of_ogroup && isset($this->parent->by_object['workstartup'])){
727       $this->parent->by_object['workstartup']->gotoBootKernel = "default-inherited";
728       $this->parent->by_object['workstartup']->gotoLdapServer = "default-inherited";
729       $this->parent->by_object['workstartup']->FAIdebianMirror= "inherited";
730     }
731   }
733   // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
734 ?>