Code

Updated server to hide gosa-si actions until the gosaSupportURI is defined.
[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;
41   var $baseSelector;
43   var $inheritTimeServer = true;
45   /* attribute list for save action */
46   var $ignore_account= TRUE;
47   var $attributes= array("gotoMode", "gotoSyslogServer", "gotoNtpServer",
48       "gotoFloppyEnable", "gotoCdromEnable", "cn", "gotoSndModule",
49       "ghCpuType", "ghMemSize", "ghUsbSupport", "description",
50       "ghGfxAdapter", "ghSoundAdapter", "gotoLastUser", "l","FAIscript");
51   var $objectclasses= array("top", "gotoWorkstation", "GOhard");
53   var $validActions   = array("reboot" => "", "localboot" => "", "halt" => "", "update" => "", "reinstall" => "",
54                             "rescan" => "", "wakeup" => "", "memcheck" => "", "sysinfo" => "");
55   
56   var $fai_activated = FALSE;
58   var $member_of_ogroup = FALSE;
60   var $currently_installing = FALSE;
61   var $currently_installing_warned = FALSE;
63   var $kerberos_key_service = NULL;
65   function workgeneric (&$config, $dn= NULL, $parent= NULL)
66   {
67     $tmp= $config->search("faiManagement", "CLASS",array('menu','tabs'));
68     if(!empty($tmp)){
69       $this->fai_activated = TRUE;
70     }
72     plugin::plugin ($config, $dn, $parent);
74     if(class_available("krbHostKeys")){
75       $this->kerberos_key_service = new krbHostKeys($this->config,$this);
76     }
78     if(!isset($this->parent->by_object['ogroup'])){
79       $ldap = $this->config->get_ldap_link();
80       $ldap->cd ($this->config->current['BASE']);
81       $ldap->search("(&(objectClass=gotoWorkstationTemplate)(member=".LDAP::prepare4filter($this->dn)."))",array("cn"));
82       $this->member_of_ogroup = $ldap->count() >= 1;
83     }
85     $this->netConfigDNS = new termDNS($this->config,$this,$this->objectclasses);
86     $this->netConfigDNS->MACisMust =TRUE;
88     /* Check if this host is currently in installation process*/
89     if(class_available("gosaSupportDaemon") && class_available("DaemonEvent")){
90       $o = new gosaSupportDaemon();
91       $e_types = DaemonEvent::get_event_types(USER_EVENT | SYSTEM_EVENT | HIDDEN_EVENT);
92       $evts = $o->get_entries_by_mac(array($this->netConfigDNS->macAddress));
93       foreach($evts as $evt){
94         if(isset($e_types['QUEUED'][$evt['HEADERTAG']]) && $evt['STATUS'] == "processing" &&
95             $e_types['QUEUED'][$evt['HEADERTAG']] == "DaemonEvent_reinstall"){
96           $this->currently_installing =TRUE;
97         }
98       }
99     }
101     /* Read arrays */
102     foreach (array("ghNetNic", "ghIdeDev", "ghScsiDev") as $val){
103       if (!isset($this->attrs[$val])){
104         continue;
105       }
106       for ($i= 0; $i<$this->attrs[$val]['count']; $i++){
107         array_push($this->$val, $this->attrs[$val][$i]);
108       }
109     }
111     /* Create used ntp server array */
112     $this->gotoNtpServer= array();
113     if(isset($this->attrs['gotoNtpServer'])){
114       $this->inheritTimeServer = false;
115       unset($this->attrs['gotoNtpServer']['count']);
116       foreach($this->attrs['gotoNtpServer'] as $server){
117         $this->gotoNtpServer[$server] = $server;
118       }
119     }
121     /* Set inherit checkbox state */
122     if((in_array_strict("default",$this->gotoNtpServer)) || (count($this->gotoNtpServer) == 0)){
123       $this->inheritTimeServer = true;
124       $this->gotoNtpServer=array();
125     }
127     /* You can't inherit the NTP service, if we are not member in an object group */
128     if(!$this->member_of_ogroup){
129       $this->inheritTimeServer = FALSE;
130     }
132     /* Create available ntp options */
133     $tmp = $this->config->data['SERVERS']['NTP'];
134     $this->gotoNtpServers = array();
135     foreach($tmp as $key => $server){
136       if($server == "default") continue;
137       $this->gotoNtpServers[$server] = $server;
138     }
140     $this->modes["active"]= _("Activated");
141     $this->modes["locked"]= _("Locked");
143     /* Set base */
144     if ($this->dn == "new"){
145       $ui= get_userinfo();
146       $this->base= dn2base(session::global_is_set("CurrentMainBase")?"cn=dummy,".session::global_get("CurrentMainBase"):$ui->dn);
147     } elseif(preg_match("/".preg_quote(get_ou("systemIncomingRDN"), '/')."/i", $this->dn)){
148       $this->base= preg_replace ("/^[^,]+,".preg_quote(get_ou("systemIncomingRDN"), '/')."/i", "", $this->dn);
149     }else{
150       $this->base= preg_replace ("/^[^,]+,".preg_quote(get_ou("workstationRDN"), '/')."/i", "", $this->dn);
151     }
153     /* Create an array of all Syslog servers */
154     $tmp = $this->config->data['SERVERS']['SYSLOG'];
155     foreach($tmp as $server){
156       $visible = $server;
157       if($server == "default" && $this->member_of_ogroup) {
158         $visible = "["._("inherited")."]";
159       }
160       $this->gotoSyslogServers[$server] = $visible;
161     }
163     $this->initial_gotoMode = $this->gotoMode;
165     /* Save 'dn' for later referal */
166     $this->orig_dn= $this->dn;
167     $this->orig_cn= $this->cn;
168     $this->orig_base= $this->base;
170     /* Instanciate base selector */
171     $this->baseSelector= new baseSelector($this->get_allowed_bases(), $this->base);
172     $this->baseSelector->setSubmitButton(false);
173     $this->baseSelector->setHeight(300);
174     $this->baseSelector->update(true);
175   }
178   function set_acl_base($base)
179   {
180     plugin::set_acl_base($base);
181     $this->netConfigDNS->set_acl_base($base);
182   }
184   function set_acl_category($cat)
185   {
186     plugin::set_acl_category($cat);
187     $this->netConfigDNS->set_acl_category($cat);
188   }
190   function execute()
191   {
192     /* Call parent execute */
193     plugin::execute();
195     if($this->is_account && !$this->view_logged){
196       $this->view_logged = TRUE;
197       new log("view","workstation/".get_class($this),$this->dn);
198     }
200     /* Do we need to flip is_account state? */
201     if(isset($_POST['modify_state'])){
202       if($this->is_account && $this->acl_is_removeable()){
203         $this->is_account= FALSE;
204       }elseif(!$this->is_account && $this->acl_is_createable()){
205         $this->is_account= TRUE;
206       }
207     }
209     if ((isset($_POST['action'])) && ($this->acl_is_writeable("FAIstate")) && isset($this->validActions[$_POST['saction']]) ){
210       $action= $_POST['saction'];
212       /* Check if we have an DaemonEvent for this action */ 
213       if(class_available("gosaSupportDaemon") && class_available("DaemonEvent")){
214         $events = DaemonEvent::get_event_types(SYSTEM_EVENT | HIDDEN_EVENT);
215         if(isset($events['TRIGGERED']["DaemonEvent_".$action])){
216           $evt = $events['TRIGGERED']["DaemonEvent_".$action];
217           $tmp = new $evt['CLASS_NAME']($this->config);
218           $tmp->add_targets(array($this->netConfigDNS->macAddress));
219           $tmp->set_type(TRIGGERED_EVENT);
220           $o_queue = new gosaSupportDaemon();
221           if(!$o_queue->append($tmp)){
222             msg_dialog::display(_("Service infrastructure"),msgPool::siError($o_queue->get_error()),ERROR_DIALOG);
223           }
224         }
225       } else {
226         msg_dialog::display(_("Event error"),
227                     sprintf(_("Event '%s' is not available!"),$action),ERROR_DIALOG);
228       }
231     }
233     /* Do we represent a valid terminal? */
234     if (!$this->is_account && $this->parent === NULL){
235       $display= "<img alt=\"\" src=\"images/small-error.png\" align=middle>&nbsp;<b>".
236         msgPool::noValidExtension(_("workstation"))."</b>";
237       return($display);
238     }
240     /* Add new ntp Server to our list */ 
241     if((isset($_POST['addNtpServer'])) && (isset($_POST['gotoNtpServers'])) && $this->acl_is_writeable("gotoNtpServer")){
242       $this->gotoNtpServer[$_POST['gotoNtpServers']] = $_POST['gotoNtpServers'];
243     }
245     /* Delete selected NtpServer for list of used servers  */
246     if((isset($_POST['delNtpServer'])) && (isset($_POST['gotoNtpServerSelected'])) && $this->acl_is_writeable("gotoNtpServer")){
247       foreach($_POST['gotoNtpServerSelected'] as $name){
248         unset($this->gotoNtpServer[$name]);
249       }
250     }
252     /* Fill templating stuff */
253     $smarty= get_smarty();
254     $smarty->assign("usePrototype", "true");
256     /* Set acls */
257     $tmp = $this->plInfo();
258     foreach($tmp['plProvidedAcls'] as $name => $translation){
259       $smarty->assign($name."ACL",$this->getacl($name));
260     }
262     $smarty->assign("cn", $this->cn);
263     $smarty->assign("description", $this->description);
264     $smarty->assign("l", $this->l);
265     $smarty->assign("staticAddress", "");
267     $tmp = array();
268     foreach($this->gotoNtpServers as $server){
269       if(!in_array_strict($server,$this->gotoNtpServer)){
270         $tmp[$server] = $server;
271       }
272     }
273     $smarty->assign("gotoNtpServers",$tmp);
274         
275     /* Check if workstation is online */
276     if (gosaSupportDaemon::ping($this->netConfigDNS->macAddress)){
277       $smarty->assign("actions", array("halt" => _("Switch off"), "reboot" => _("Reboot"),
278                                        "update" => _("Software update"),
279                                        "reinstall" => _("Reinstall"),
280                                        "rescan" => _("Rescan hardware"),
281                                        #"memcheck" => _("Memory test"),
282                                        "localboot" => _("Force localboot"),
283                                        #"sysinfo"  => _("System analysis")
284                                         ));
285     } else {
286       $smarty->assign("actions", array("wakeup" => _("Wake up"),
287                                        "reinstall" => _("Reinstall"),
288                                        "update" => _("Software update"),
289                                        #"memcheck" => _("Memory test"),
290                                        "localboot" => _("Force localboot"),
291                                        #"sysinfo"  => _("System analysis")
292                                         ));
293     }
294     /* Arrays */
295     $smarty->assign("modes", $this->modes);
296     $smarty->assign("nfsservers", $this->config->data['SERVERS']['NFS']);
297     $smarty->assign("syslogservers", $this->gotoSyslogServers);
298     $smarty->assign("fai_activated",$this->fai_activated);
300     $ntpser = array();
301     foreach($this->gotoNtpServers as $server){
302       if(!in_array_strict($server,$this->gotoNtpServer)){
303         $ntpser[$server] = $server;
304       }
305     }
306     $smarty->assign("gotoNtpServers", $ntpser);
308     /* Variables */
309     foreach(array("gotoMode", "gotoSyslogServer", "gotoNtpServer") as $val){
310       $smarty->assign($val."_select", $this->$val);
311     }
312     $smarty->assign("base", $this->baseSelector->render());
314     /* tell smarty the inherit checkbox state */
315     $smarty->assign("inheritTimeServer",$this->inheritTimeServer);
316     $smarty->assign("member_of_ogroup",$this->member_of_ogroup);
318     $str = $this->netConfigDNS->execute();
319     if(is_object($this->netConfigDNS->dialog)){
320       return($str);
321     }
322     $smarty->assign("netconfig", $str);
324     /* Display kerberos host key options */
325     $smarty->assign("host_key","");
326     if(is_object($this->kerberos_key_service)){
327       $smarty->assign("host_key",$this->kerberos_key_service->execute_by_prefix("host/"));
328     }
330     /* Show main page */
331     $smarty->assign("currently_installing", $this->currently_installing);
332     return($smarty->fetch (get_template_path('workstation.tpl', TRUE, dirname(__FILE__))));
333   }
335   function remove_from_parent()
336   {
337     if($this->acl_is_removeable()){
339       $this->netConfigDNS->remove_from_parent();
340       $ldap= $this->config->get_ldap_link();
341       $ldap->rmdir($this->dn);
342       new log("remove","workstation/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
343       if (!$ldap->success()){
344         msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, LDAP_DEL, get_class()));
345       }
347       /* Remove kerberos key dependencies too */
348       if(is_object($this->kerberos_key_service)){
349         $this->kerberos_key_service->remove_from_parent_by_prefix("host/");
350       }
352       /* Optionally execute a command after we're done */
353       $this->handle_post_events("remove", array("macAddress" => $this->netConfigDNS->macAddress,"ipHostNumber" => $this->netConfigDNS->ipHostNumber));
355       /* Delete references to object groups */
356       $ldap->cd ($this->config->current['BASE']);
357       $ldap->search ("(&(objectClass=gosaGroupOfNames)(member=".LDAP::prepare4filter($this->dn)."))", array("cn"));
358       while ($ldap->fetch()){
359         $og= new ogroup($this->config, $ldap->getDN());
360         unset($og->member[$this->dn]);
361         $og->save ();
362       }
364       /* Remove all accessTo/trust dependencies */
365       update_accessTo($this->cn,"");
366     }
368     /* Clean queue form entries with this mac 
369      */
370     if(class_available("gosaSupportDaemon") && tests::is_mac($this->netConfigDNS->orig_macAddress)){
371       $q = new gosaSupportDaemon();
372       $q->clean_queue_from_mac($this->netConfigDNS->orig_macAddress);
373     }
375     if(isset($_POST["inheritAll"])){
376       $this->set_everything_to_inherited();
377     }
378   }
381   /* Save data to object */
382   function save_object()
383   {
385     /* Create a base backup and reset the
386        base directly after calling plugin::save_object();
387        Base will be set seperatly a few lines below */
388     $base_tmp = $this->base;
389     plugin::save_object();
390     $this->base = $base_tmp;
392     /* Refresh base */
393     if ($this->acl_is_moveable($this->base)){
394       if (!$this->baseSelector->update()) {
395         msg_dialog::display(_("Error"), msgPool::permMove(), ERROR_DIALOG);
396       }
397       if ($this->base != $this->baseSelector->getBase()) {
398         $this->base= $this->baseSelector->getBase();
399         $this->is_modified= TRUE;
400       }
401     }
403     $this->netConfigDNS->save_object();
405     /* Set inherit mode */
406     if((isset($_POST['workgeneric_posted'])) && ($this->acl_is_writeable("gotoNtpServer"))){
407       if(isset($_POST["inheritTimeServer"]) && $this->member_of_ogroup){
408         $this->inheritTimeServer = true;
409       }else{
410         $this->inheritTimeServer = false;
411       }
412     }
413     
414     if(isset($_POST["inheritAll"])){
415       $this->set_everything_to_inherited();
416     }
418     /* Hanle kerberos host key plugin */
419     if(is_object($this->kerberos_key_service)){
420       $this->kerberos_key_service->save_object_by_prefix("host/");
421     }
422   }
425   /* Check supplied data */
426   function check()
427   {
428     /* Call common method to give check the hook */
429     $message= plugin::check();
430  
431     /* Skip IP & Mac checks if this is a template */
432     if($this->cn != "wdefault"){
433       $message= array_merge($message, $this->netConfigDNS->check());
434     }
436     $this->dn= "cn=".$this->cn.",".get_ou('workstationRDN').$this->base;
438     if ($this->cn == ""){
439       $message[]= msgPool::required(_("Name"));
440     }
442     /* Check if given name is a valid host/dns name */
443     if(!tests::is_dns_name($this->cn)){
444       $message[] = msgPool::invalid(_("Name"));
445     }
447     // Check if a wrong base was supplied
448     if(!$this->baseSelector->checkLastBaseUpdate()){
449       $message[]= msgPool::check_base();
450     }
452     if ($this->orig_dn != $this->dn){
453       $ldap= $this->config->get_ldap_link();
454       $ldap->cd ($this->base);
456       if($this->cn == "wdefault"){
457         $ldap->cat($this->dn);
458       }else{
459         $ldap->search ("(&(cn=".$this->cn.")(objectClass=gotoWorkstation))", array("cn"));
460       }
461       if ($ldap->count() != 0){
462         while ($attrs= $ldap->fetch()){
463           if (preg_match("/cn=dhcp,/",$attrs['dn']) || preg_match ("/,".preg_quote(get_ou('systemIncomingRDN'), '/')."/i", $ldap->getDN())){
464             continue;
465           } else {
466             if ($attrs['dn'] != $this->orig_dn){
467               $message[]= msgPool::duplicated(_("Name"));
468               break;
469             }
470           }
471         }
472       }
473     }
475     /* Check for valid ntpServer selection */
476     if((!$this->inheritTimeServer) && (!count($this->gotoNtpServer))){
477       $message[]= msgPool::required(_("NTP server"));
478     }
480     /* Only systems with a valid ldap handle can be activated 
481      */
482     if($this->gotoMode == "active" && $this->initial_gotoMode != "active"){
484       if(isset($this->parent->by_object['workstartup']) &&
485           !count($this->parent->by_object['workstartup']->gotoLdapServers) && 
486           !$this->parent->by_object['workstartup']->gotoLdap_inherit){
488         $message[] = _("A valid LDAP server assignement is missing!");
489       }
490     }else{
491       /* Warn the user, that this host is currently installing */
492       if($this->currently_installing && !$this->currently_installing_warned && 
493           !preg_match("/".preg_quote(get_ou("systemIncomingRDN"), '/')."/i",$this->orig_dn)){
494       
495         /* Force aborting without message dialog */
496         $message[] = "";
497         $this->currently_installing_warned = TRUE;
498         msg_dialog::display(_("Software deployment"), 
499             _("This host is currently installing. If you want to save it, press 'OK'."),
500             CONFIRM_DIALOG);
501       }
502     }
504     /* Check if we are allowed to create or move this object
505      */
506     if($this->orig_dn == "new" && !$this->acl_is_createable($this->base)){
507       $message[] = msgPool::permCreate();
508     }elseif($this->orig_dn != "new" && $this->base != $this->orig_base && !$this->acl_is_moveable($this->base)){
509       $message[] = msgPool::permMove();
510     }
511  
512     return ($message);
513   }
516   /* Save to LDAP */
517   function save()
518   {
519     /* Detect mode changes */
520     $activate= (isset($this->saved_attributes['gotoMode']) &&
521         $this->gotoMode != $this->saved_attributes['gotoMode'] &&
522         $this->gotoMode == "active" &&
523         tests::is_ip($this->netConfigDNS->ipHostNumber)) || $this->auto_activate;
524     plugin::save();
526     /* Strip out 'default' values */
527     foreach (array("gotoSyslogServer") as $val){
529       if (isset($this->attrs[$val]) && $this->attrs[$val] == "default"){
530         $this->attrs[$val]= array();
531       }
532     }
534     /* Add missing arrays */
535     foreach (array("ghScsiDev", "ghIdeDev", "ghNetNic") as $val){
536       if (isset ($this->$val) && count ($this->$val) != 0){
537         $this->attrs["$val"]= $this->$val;
538       }
539     }
541     /* Remove all empty values */
542     if ($this->orig_dn == 'new'){
543       $attrs= array();
544       foreach ($this->attrs as $key => $val){
545         if (is_array($val) && count($val) == 0){
546           continue;
547         }
548         $attrs[$key]= $val;
549       }
550       $this->attrs= $attrs;
551     }
553     /* Update ntp server settings */
554     if($this->inheritTimeServer){
555       if($this->is_new){
556         if(isset($this->attrs['gotoNtpServer'])){
557           unset($this->attrs['gotoNtpServer']);
558         }
559       }else{
560         $this->attrs['gotoNtpServer'] = array();
561       }
562     }else{
563       /* Set ntpServers */
564       $this->attrs['gotoNtpServer'] = array();
565       foreach($this->gotoNtpServer as $server){
566         $this->attrs['gotoNtpServer'][] = $server;
567       }
568     }
570     /* cn=default and macAddress=- indicates that this is a template */
571     if($this->cn == "wdefault"){
572       $this->netConfigDNS->macAddress = "-";
573     }
575     /* Write back to ldap */
576     $ldap= $this->config->get_ldap_link();
577     if ($this->orig_dn == 'new'){
578       $ldap->cd($this->config->current['BASE']);
579       $ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $this->dn));
580       $ldap->cd($this->dn);
581       $ldap->add($this->attrs);
582       new log("create","workstation/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
583       if (!$ldap->success()){
584         msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, 0, get_class()));
585       }
587       $this->netConfigDNS->cn = $this->cn;
588       $this->netConfigDNS->save();
590       $this->handle_post_events("add",array("macAddress" => $this->netConfigDNS->macAddress,"ipHostNumber" => $this->netConfigDNS->ipHostNumber));
591     } else {
592       if ($this->orig_dn != $this->dn){
594         /* Remove all accessTo/trust dependencies */
595         update_accessTo($this->orig_cn,$this->cn);
596       }
597       $ldap->cd($this->dn);
598       $this->cleanup();
599       $ldap->modify ($this->attrs); 
600       if (!$ldap->success()){
601         msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, LDAP_MOD, get_class()));
602       }
603       new log("modify","workstation/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
605       $this->netConfigDNS->cn = $this->cn;
606       $this->netConfigDNS->save();
608       $this->handle_post_events("modify",array("macAddress" => $this->netConfigDNS->macAddress,"ipHostNumber" => $this->netConfigDNS->ipHostNumber));
609     }
611     if ($activate && class_available("DaemonEvent")){
613       /* Send installation activation
614        */
615       $events = DaemonEvent::get_event_types(SYSTEM_EVENT | HIDDEN_EVENT);
616       $o_queue = new gosaSupportDaemon();
617       if(isset($events['TRIGGERED']['DaemonEvent_installation_activation'])){
618         $evt = $events['TRIGGERED']['DaemonEvent_installation_activation'];
619         $tmp = new $evt['CLASS_NAME']($this->config);
620         $tmp->set_type(TRIGGERED_EVENT);
621         $tmp->add_targets(array($this->netConfigDNS->macAddress));
622         if(!$o_queue->append($tmp)){
623           msg_dialog::display(_("Service infrastructure"),msgPool::siError($o_queue->get_error()),ERROR_DIALOG);
624         }
625       }
626     }
627   }
630   /* Display generic part for server copy & paste */
631   function getCopyDialog()
632   {
633     $vars = array("cn");
634     $smarty = get_smarty();
635     $smarty->assign("cn" ,$this->cn);
636     $smarty->assign("object","workstation");
637     $str = $smarty->fetch(get_template_path("paste_generic.tpl",TRUE));
638     $ret = array();
639     $ret['string'] = $str;
640     $ret['status'] = "";
641     return($ret);
642   }
645   function saveCopyDialog()
646   {
647     if(isset($_POST['cn'])){
648       $this->cn = $_POST['cn'];
649     }
650   }
653   function PrepareForCopyPaste($source)
654   {
655     plugin::PrepareForCopyPaste($source);
656     if(isset($source['macAddress'][0])){
657       $this->netConfigDNS->macAddress = $source['macAddress'][0];
658     }
659     if(isset($source['ipHostNumber'][0])){
660       $this->netConfigDNS->ipHostNumber = $source['ipHostNumber'][0];
661     }
663     /* Create used ntp server array */
664     $this->gotoNtpServer= array();
665     if(isset($source['gotoNtpServer'])){
666       $this->inheritTimeServer = false;
667       unset($source['gotoNtpServer']['count']);
668       foreach($source['gotoNtpServer'] as $server){
669         $this->gotoNtpServer[$server] = $server;
670       }
671     }
673     /* Set inherit checkbox state */
674     if((in_array_strict("default",$this->gotoNtpServer)) || (count($this->gotoNtpServer)==0)){
675       $this->inheritTimeServer = true;
676       $this->gotoNtpServer=array();
677     }
678   }
681   /* Return plugin informations for acl handling 
682       #FIXME FAIscript seams to ununsed within this class... */ 
683   static function plInfo()
684   {
685     return (array(  
686           "plShortName"   => _("Generic"),
687           "plDescription" => _("Workstation generic"),
688           "plSelfModify"  => FALSE,
689           "plDepends"     => array(),
690           "plPriority"    => 0,
691           "plSection"     => array("administration"),
692           "plCategory"    => array("workstation" => array("description"  => _("Workstation"),
693                                                           "objectClass"  => "gotoWorkstation")),
694           "plProvidedAcls"=> array(
695             "cn"                  => _("Workstation name"),
696             "description"         => _("Description") ,
697             "l"                   => _("Location") ,
698             "base"                => _("Base") ,
699             "gotoMode"            => _("Goto mode"), 
700             "gotoSyslogServer"    => _("Syslog server"), 
701             "gotoNtpServer"       => _("Ntp server"), 
702             "userPassword"      => _("Root password"),
703             "createFAICD"         => _("Create FAI CD"),
704             "FAIstate"            => _("Action flag"))
705           ));
706   }
708   function set_everything_to_inherited()
709   {
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['workservice'])){
715       foreach(array("gotoXKbLayout","gotoXKbModel","gotoXKbVariant","gotoXDriver",
716             "gotoXResolution","gotoXColordepth","gotoXMouseType","gotoXMouseport") as $name){
717         if($this->parent->by_object['workservice']->acl_is_writeable($name)){
718           $this->parent->by_object['workservice']->$name = "default"; 
719         }
720       }
721     }
723     /* Set workstation startup attributes to inherited */
724     if($this->member_of_ogroup && isset($this->parent->by_object['workstartup'])){
725       $obj = $this->parent->by_object['workstartup'];
726       if($obj->acl_is_writeable("gotoBootKernel")){
727         $this->parent->by_object['workstartup']->gotoBootKernel = "default-inherited";
728       }
729       if($obj->acl_is_writeable("gotoLdapServer")){
730         $this->parent->by_object['workstartup']->gotoLdapServer = "default-inherited";
731         $this->parent->by_object['workstartup']->gotoLdap_inherit = TRUE;
732         $this->parent->by_object['workstartup']->gotoLdapServers = array();
733       }
734       if($obj->acl_is_writeable("FAIdebianMirror")){
735         $this->parent->by_object['workstartup']->FAIdebianMirror= "inherited";
736       }
737     }
738   }
741   function is_modal_dialog()
742   {
743     return((isset($this->dialog) && $this->dialog) || (isset($this->netConfigDNS->dialog) && $this->netConfigDNS->dialog));
744   }
748   // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
749 ?>