Code

Remove the tabs::tabs call from tabs_printers.inc because
[gosa.git] / trunk / 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" => "", "wakeup" => "", "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("krbHostKeys")){
74       $this->kerberos_key_service = new krbHostKeys($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 ("/^[^,]+,".preg_quote(get_ou("workstationRDN"), '/')."/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                                         ));
306     } else {
307       $smarty->assign("actions", array("wakeup" => _("Wake up"),
308                                        "reinstall" => _("Reinstall"),
309                                        "update" => _("Software update"),
310                                        #"memcheck" => _("Memory test"),
311                                        "localboot" => _("Force localboot"),
312                                        #"sysinfo"  => _("System analysis")
313                                         ));
314     }
315     /* Arrays */
316     $smarty->assign("modes", $this->modes);
317     $smarty->assign("nfsservers", $this->config->data['SERVERS']['NFS']);
318     $smarty->assign("syslogservers", $this->gotoSyslogServers);
319     $smarty->assign("fai_activated",$this->fai_activated);
321     $ntpser = array();
322     foreach($this->gotoNtpServers as $server){
323       if(!in_array($server,$this->gotoNtpServer)){
324         $ntpser[$server] = $server;
325       }
326     }
327     $smarty->assign("gotoNtpServers", $ntpser);
329     /* Variables */
330     foreach(array("base", "gotoMode", "gotoSyslogServer", "gotoNtpServer") as $val){
331       $smarty->assign($val."_select", $this->$val);
332     }
334     /* tell smarty the inherit checkbox state */
335     $smarty->assign("inheritTimeServer",$this->inheritTimeServer);
336     $smarty->assign("member_of_ogroup",$this->member_of_ogroup);
338     $str = $this->netConfigDNS->execute();
339     if(is_object($this->netConfigDNS->dialog)){
340       return($str);
341     }
342     $smarty->assign("netconfig", $str);
344     /* Display kerberos host key options */
345     $smarty->assign("host_key","");
346     if(is_object($this->kerberos_key_service)){
347       $smarty->assign("host_key",$this->kerberos_key_service->execute_by_prefix("host/"));
348     }
350     /* Show main page */
351     $smarty->assign("currently_installing", $this->currently_installing);
352     return($smarty->fetch (get_template_path('workstation.tpl', TRUE, dirname(__FILE__))));
353   }
355   function remove_from_parent()
356   {
357     if($this->acl_is_removeable()){
359       $this->netConfigDNS->remove_from_parent();
360       $ldap= $this->config->get_ldap_link();
361       $ldap->rmdir($this->dn);
362       new log("remove","workstation/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
363       if (!$ldap->success()){
364         msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, LDAP_DEL, get_class()));
365       }
367       /* Remove kerberos key dependencies too */
368       if(is_object($this->kerberos_key_service)){
369         $this->kerberos_key_service->remove_from_parent_by_prefix("host/");
370       }
372       /* Optionally execute a command after we're done */
373       $this->handle_post_events("remove", array("macAddress" => $this->netConfigDNS->macAddress,"ipHostNumber" => $this->netConfigDNS->ipHostNumber));
375       /* Delete references to object groups */
376       $ldap->cd ($this->config->current['BASE']);
377       $ldap->search ("(&(objectClass=gosaGroupOfNames)(member=".LDAP::prepare4filter($this->dn)."))", array("cn"));
378       while ($ldap->fetch()){
379         $og= new ogroup($this->config, $ldap->getDN());
380         unset($og->member[$this->dn]);
381         $og->save ();
382       }
384       /* Remove all accessTo/trust dependencies */
385       update_accessTo($this->cn,"");
386     }
388     /* Clean queue form entries with this mac 
389      */
390     if(class_available("gosaSupportDaemon") && tests::is_mac($this->netConfigDNS->orig_macAddress)){
391       $q = new gosaSupportDaemon();
392       $q->clean_queue_from_mac($this->netConfigDNS->orig_macAddress);
393     }
395     if(isset($_POST["inheritAll"])){
396       $this->set_everything_to_inherited();
397     }
398   }
401   /* Save data to object */
402   function save_object()
403   {
405     /* Create a base backup and reset the
406        base directly after calling plugin::save_object();
407        Base will be set seperatly a few lines below */
408     $base_tmp = $this->base;
409     plugin::save_object();
410     $this->base = $base_tmp;
412     /* Save base, since this is no LDAP attribute */
413     $tmp = $this->get_allowed_bases();
414     if(isset($_POST['base'])){
415       if(isset($tmp[$_POST['base']])){
416         $this->base= $_POST['base'];
417       }
418     }
420     $this->netConfigDNS->save_object();
422     /* Set inherit mode */
423     if((isset($_POST['workgeneric_posted'])) && ($this->acl_is_writeable("gotoNtpServer"))){
424       if(isset($_POST["inheritTimeServer"]) && $this->member_of_ogroup){
425         $this->inheritTimeServer = true;
426       }else{
427         $this->inheritTimeServer = false;
428       }
429     }
430     
431     if(isset($_POST["inheritAll"])){
432       $this->set_everything_to_inherited();
433     }
435     /* Hanle kerberos host key plugin */
436     if(is_object($this->kerberos_key_service)){
437       $this->kerberos_key_service->save_object_by_prefix("host/");
438     }
439   }
442   /* Check supplied data */
443   function check()
444   {
445     /* Call common method to give check the hook */
446     $message= plugin::check();
447  
448     /* Skip IP & Mac checks if this is a template */
449     if($this->cn != "wdefault"){
450       $message= array_merge($message, $this->netConfigDNS->check());
451     }
453     $this->dn= "cn=".$this->cn.",".get_ou('workstationRDN').$this->base;
455     if ($this->cn == ""){
456       $message[]= msgPool::required(_("Name"));
457     }
459     /* Check if given name is a valid host/dns name */
460     if(!tests::is_dns_name($this->cn)){
461       $message[] = msgPool::invalid(_("Name"));
462     }
464     if ($this->orig_dn != $this->dn){
465       $ldap= $this->config->get_ldap_link();
466       $ldap->cd ($this->base);
468       if($this->cn == "wdefault"){
469         $ldap->cat($this->dn);
470       }else{
471         $ldap->search ("(&(cn=".$this->cn.")(objectClass=gotoWorkstation))", array("cn"));
472       }
473       if ($ldap->count() != 0){
474         while ($attrs= $ldap->fetch()){
475           if (preg_match("/cn=dhcp,/",$attrs['dn']) || preg_match ("/,".get_ou('systemIncomingRDN')."/", $ldap->getDN())){
476             continue;
477           } else {
478             if ($attrs['dn'] != $this->orig_dn){
479               $message[]= msgPool::duplicated(_("Name"));
480               break;
481             }
482           }
483         }
484       }
485     }
487     /* Check for valid ntpServer selection */
488     if((!$this->inheritTimeServer) && (!count($this->gotoNtpServer))){
489       $message[]= msgPool::required(_("NTP server"));
490     }
492     /* Only systems with a valid ldap handle can be activated 
493      */
494     if($this->gotoMode == "active" && $this->initial_gotoMode != "active"){
496       if(isset($this->parent->by_object['workstartup']) &&
497           !count($this->parent->by_object['workstartup']->gotoLdapServers) && 
498           !$this->parent->by_object['workstartup']->gotoLdap_inherit){
500         $message[] = _("A valid LDAP server assignement is missing!");
501       }
502     }else{
503       /* Warn the user, that this host is currently installing */
504       if($this->currently_installing && !$this->currently_installing_warned && 
505           !preg_match("/".preg_quote(get_ou("systemIncomingRDN"), '/')."/",$this->orig_dn)){
506       
507         /* Force aborting without message dialog */
508         $message[] = "";
509         $this->currently_installing_warned = TRUE;
510         msg_dialog::display(_("Software deployment"), 
511             _("This host is currently installing. If you want to save it, press 'OK'."),
512             CONFIRM_DIALOG);
513       }
514     }
516     /* Check if we are allowed to create or move this object
517      */
518     if($this->orig_dn == "new" && !$this->acl_is_createable($this->base)){
519       $message[] = msgPool::permCreate();
520     }elseif($this->orig_dn != "new" && $this->base != $this->orig_base && !$this->acl_is_moveable($this->base)){
521       $message[] = msgPool::permMove();
522     }
523  
524     return ($message);
525   }
528   /* Save to LDAP */
529   function save()
530   {
531     /* Detect mode changes */
532     $activate= (isset($this->saved_attributes['gotoMode']) &&
533         $this->gotoMode != $this->saved_attributes['gotoMode'] &&
534         $this->gotoMode == "active" &&
535         tests::is_ip($this->netConfigDNS->ipHostNumber)) || $this->auto_activate;
536     plugin::save();
538     /* Strip out 'default' values */
539     foreach (array("gotoSyslogServer") as $val){
541       if (isset($this->attrs[$val]) && $this->attrs[$val] == "default"){
542         $this->attrs[$val]= array();
543       }
544     }
546     /* Add missing arrays */
547     foreach (array("ghScsiDev", "ghIdeDev", "ghNetNic") as $val){
548       if (isset ($this->$val) && count ($this->$val) != 0){
549         $this->attrs["$val"]= $this->$val;
550       }
551     }
553     /* Remove all empty values */
554     if ($this->orig_dn == 'new'){
555       $attrs= array();
556       foreach ($this->attrs as $key => $val){
557         if (is_array($val) && count($val) == 0){
558           continue;
559         }
560         $attrs[$key]= $val;
561       }
562       $this->attrs= $attrs;
563     }
565     /* Update ntp server settings */
566     if($this->inheritTimeServer){
567       if($this->is_new){
568         if(isset($this->attrs['gotoNtpServer'])){
569           unset($this->attrs['gotoNtpServer']);
570         }
571       }else{
572         $this->attrs['gotoNtpServer'] = array();
573       }
574     }else{
575       /* Set ntpServers */
576       $this->attrs['gotoNtpServer'] = array();
577       foreach($this->gotoNtpServer as $server){
578         $this->attrs['gotoNtpServer'][] = $server;
579       }
580     }
582     /* cn=default and macAddress=- indicates that this is a template */
583     if($this->cn == "wdefault"){
584       $this->netConfigDNS->macAddress = "-";
585     }
587     /* Write back to ldap */
588     $ldap= $this->config->get_ldap_link();
589     if ($this->orig_dn == 'new'){
590       $ldap->cd($this->config->current['BASE']);
591       $ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $this->dn));
592       $ldap->cd($this->dn);
593       $ldap->add($this->attrs);
594       new log("create","workstation/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
595       if (!$ldap->success()){
596         msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, 0, get_class()));
597       }
599       $this->netConfigDNS->cn = $this->cn;
600       $this->netConfigDNS->save();
602       $this->handle_post_events("add",array("macAddress" => $this->netConfigDNS->macAddress,"ipHostNumber" => $this->netConfigDNS->ipHostNumber));
603     } else {
604       if ($this->orig_dn != $this->dn){
606         /* Remove all accessTo/trust dependencies */
607         update_accessTo($this->orig_cn,$this->cn);
608       }
609       $ldap->cd($this->dn);
610       $this->cleanup();
611       $ldap->modify ($this->attrs); 
612       if (!$ldap->success()){
613         msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, LDAP_MOD, get_class()));
614       }
615       new log("modify","workstation/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
617       $this->netConfigDNS->cn = $this->cn;
618       $this->netConfigDNS->save();
620       $this->handle_post_events("modify",array("macAddress" => $this->netConfigDNS->macAddress,"ipHostNumber" => $this->netConfigDNS->ipHostNumber));
621     }
623     if ($activate && class_available("DaemonEvent")){
625       /* Send installation activation
626        */
627       $events = DaemonEvent::get_event_types(SYSTEM_EVENT | HIDDEN_EVENT);
628       $o_queue = new gosaSupportDaemon();
629       if(isset($events['TRIGGERED']['DaemonEvent_installation_activation'])){
630         $evt = $events['TRIGGERED']['DaemonEvent_installation_activation'];
631         $tmp = new $evt['CLASS_NAME']($this->config);
632         $tmp->set_type(TRIGGERED_EVENT);
633         $tmp->add_targets(array($this->netConfigDNS->macAddress));
634         if(!$o_queue->append($tmp)){
635           msg_dialog::display(_("Service infrastructure"),msgPool::siError($o_queue->get_error()),ERROR_DIALOG);
636         }
637       }
638     }
639   }
642   /* Display generic part for server copy & paste */
643   function getCopyDialog()
644   {
645     $vars = array("cn");
646     $smarty = get_smarty();
647     $smarty->assign("cn" ,$this->cn);
648     $smarty->assign("object","workstation");
649     $str = $smarty->fetch(get_template_path("paste_generic.tpl",TRUE));
650     $ret = array();
651     $ret['string'] = $str;
652     $ret['status'] = "";
653     return($ret);
654   }
657   function saveCopyDialog()
658   {
659     if(isset($_POST['cn'])){
660       $this->cn = $_POST['cn'];
661     }
662   }
665   function PrepareForCopyPaste($source)
666   {
667     plugin::PrepareForCopyPaste($source);
668     if(isset($source['macAddress'][0])){
669       $this->netConfigDNS->macAddress = $source['macAddress'][0];
670     }
671     if(isset($source['ipHostNumber'][0])){
672       $this->netConfigDNS->ipHostNumber = $source['ipHostNumber'][0];
673     }
675     /* Create used ntp server array */
676     $this->gotoNtpServer= array();
677     if(isset($source['gotoNtpServer'])){
678       $this->inheritTimeServer = false;
679       unset($source['gotoNtpServer']['count']);
680       foreach($source['gotoNtpServer'] as $server){
681         $this->gotoNtpServer[$server] = $server;
682       }
683     }
685     /* Set inherit checkbox state */
686     if((in_array("default",$this->gotoNtpServer)) || (count($this->gotoNtpServer)==0)){
687       $this->inheritTimeServer = true;
688       $this->gotoNtpServer=array();
689     }
690   }
693   /* Return plugin informations for acl handling 
694       #FIXME FAIscript seams to ununsed within this class... */ 
695   static function plInfo()
696   {
697     return (array(  
698           "plShortName"   => _("Generic"),
699           "plDescription" => _("Workstation generic"),
700           "plSelfModify"  => FALSE,
701           "plDepends"     => array(),
702           "plPriority"    => 0,
703           "plSection"     => array("administration"),
704           "plCategory"    => array("workstation" => array("description"  => _("Workstation"),
705                                                           "objectClass"  => "gotoWorkstation")),
706           "plProvidedAcls"=> array(
707             "cn"                  => _("Workstation name"),
708             "description"         => _("Description") ,
709             "l"                   => _("Location") ,
710             "base"                => _("Base") ,
711             "gotoMode"            => _("Goto mode"), 
712             "gotoSyslogServer"    => _("Syslog server"), 
713             "gotoNtpServer"       => _("Ntp server"), 
714             "userPassword"      => _("Root password"),
715             "createFAICD"         => _("Create FAI CD"),
716             "FAIstate"            => _("Action flag"))
717           ));
718   }
720   function set_everything_to_inherited()
721   {
722     $this->gotoSyslogServer  = "default";
723     $this->inheritTimeServer = TRUE;
725     /* Set workstation service attributes to inherited */
726     if($this->member_of_ogroup && isset($this->parent->by_object['workservice'])){
727       foreach(array("gotoXKbLayout","gotoXKbModel","gotoXKbVariant",
728             "gotoXResolution","gotoXColordepth","gotoXMouseType","gotoXMouseport") as $name){
729         if($this->parent->by_object['workservice']->acl_is_writeable($name)){
730           $this->parent->by_object['workservice']->$name = "default"; 
731         }
732       }
733     }
735     /* Set workstation startup attributes to inherited */
736     if($this->member_of_ogroup && isset($this->parent->by_object['workstartup'])){
737       $obj = $this->parent->by_object['workstartup'];
738       if($obj->acl_is_writeable("gotoBootKernel")){
739         $this->parent->by_object['workstartup']->gotoBootKernel = "default-inherited";
740       }
741       if($obj->acl_is_writeable("gotoLdapServer")){
742         $this->parent->by_object['workstartup']->gotoLdapServer = "default-inherited";
743         $this->parent->by_object['workstartup']->gotoLdap_inherit = TRUE;
744         $this->parent->by_object['workstartup']->gotoLdapServers = array();
745       }
746       if($obj->acl_is_writeable("FAIdebianMirror")){
747         $this->parent->by_object['workstartup']->FAIdebianMirror= "inherited";
748       }
749     }
750   }
752   // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
753 ?>