Code

Fixed several properties.
[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     $this->fai_activated = $config->pluginEnabled("faiManagement");
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=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     /* Check if this host is currently in installation process*/
86     if(class_available("gosaSupportDaemon") && class_available("DaemonEvent")){
87       $o = new gosaSupportDaemon();
88       $e_types = DaemonEvent::get_event_types(USER_EVENT | SYSTEM_EVENT | HIDDEN_EVENT);
89       $evts = $o->get_entries_by_mac(array($this->netConfigDNS->macAddress));
90       foreach($evts as $evt){
91         if(isset($e_types['QUEUED'][$evt['HEADERTAG']]) && $evt['STATUS'] == "processing" &&
92             $e_types['QUEUED'][$evt['HEADERTAG']] == "DaemonEvent_reinstall"){
93           $this->currently_installing =TRUE;
94         }
95       }
96     }
98     /* Read arrays */
99     foreach (array("ghNetNic", "ghIdeDev", "ghScsiDev") as $val){
100       if (!isset($this->attrs[$val])){
101         continue;
102       }
103       for ($i= 0; $i<$this->attrs[$val]['count']; $i++){
104         array_push($this->$val, $this->attrs[$val][$i]);
105       }
106     }
108     /* Create used ntp server array */
109     $this->gotoNtpServer= array();
110     if(isset($this->attrs['gotoNtpServer'])){
111       $this->inheritTimeServer = false;
112       unset($this->attrs['gotoNtpServer']['count']);
113       foreach($this->attrs['gotoNtpServer'] as $server){
114         $this->gotoNtpServer[$server] = $server;
115       }
116     }
118     /* Set inherit checkbox state */
119     if((in_array("default",$this->gotoNtpServer)) || (count($this->gotoNtpServer) == 0)){
120       $this->inheritTimeServer = true;
121       $this->gotoNtpServer=array();
122     }
124     /* You can't inherit the NTP service, if we are not member in an object group */
125     if(!$this->member_of_ogroup){
126       $this->inheritTimeServer = FALSE;
127     }
129     /* Create available ntp options */
130     $tmp = $this->config->data['SERVERS']['NTP'];
131     $this->gotoNtpServers = array();
132     foreach($tmp as $key => $server){
133       if($server == "default") continue;
134       $this->gotoNtpServers[$server] = $server;
135     }
137     $this->modes["active"]= _("Activated");
138     $this->modes["locked"]= _("Locked");
140     /* Set base */
141     if ($this->dn == "new"){
142       $ui= get_userinfo();
143       $this->base= dn2base(session::global_is_set("CurrentMainBase")?"cn=dummy,".session::global_get("CurrentMainBase"):$ui->dn);
144     } elseif(preg_match("/".preg_quote(get_ou("ArpNewDevice", "systemIncomingRDN"), '/')."/i", $this->dn)){
145       $this->base= preg_replace ("/^[^,]+,".preg_quote(get_ou("ArpNewDevice", "systemIncomingRDN"), '/')."/i", "", $this->dn);
146     }else{
147       $this->base= preg_replace ("/^[^,]+,".preg_quote(get_ou("workgeneric", "workstationRDN"), '/')."/i", "", $this->dn);
148     }
150     /* Create an array of all Syslog servers */
151     $tmp = $this->config->data['SERVERS']['SYSLOG'];
152     foreach($tmp as $server){
153       $visible = $server;
154       if($server == "default" && $this->member_of_ogroup) {
155         $visible = "["._("inherited")."]";
156       }
157       $this->gotoSyslogServers[$server] = $visible;
158     }
160     $this->initial_gotoMode = $this->gotoMode;
162     /* Save 'dn' for later referal */
163     $this->orig_dn= $this->dn;
164     $this->orig_cn= $this->cn;
165     $this->orig_base= $this->base;
167     /* Instanciate base selector */
168     $this->baseSelector= new baseSelector($this->get_allowed_bases(), $this->base);
169     $this->baseSelector->setSubmitButton(false);
170     $this->baseSelector->setHeight(300);
171     $this->baseSelector->update(true);
172   }
175   function set_acl_base($base)
176   {
177     plugin::set_acl_base($base);
178     $this->netConfigDNS->set_acl_base($base);
179   }
181   function set_acl_category($cat)
182   {
183     plugin::set_acl_category($cat);
184     $this->netConfigDNS->set_acl_category($cat);
185   }
187   function execute()
188   {
189     /* Call parent execute */
190     plugin::execute();
192     if($this->is_account && !$this->view_logged){
193       $this->view_logged = TRUE;
194       new log("view","workstation/".get_class($this),$this->dn);
195     }
197     /* Do we need to flip is_account state? */
198     if(isset($_POST['modify_state'])){
199       if($this->is_account && $this->acl_is_removeable()){
200         $this->is_account= FALSE;
201       }elseif(!$this->is_account && $this->acl_is_createable()){
202         $this->is_account= TRUE;
203       }
204     }
206     if ((isset($_POST['action'])) && ($this->acl_is_writeable("FAIstate")) && isset($this->validActions[$_POST['saction']]) ){
207       $action= $_POST['saction'];
209       /* Check if we have an DaemonEvent for this action */ 
210       if(class_available("DaemonEvent")){
211         $events = DaemonEvent::get_event_types(SYSTEM_EVENT | HIDDEN_EVENT);
212         if(isset($events['TRIGGERED']["DaemonEvent_".$action])){
213           $evt = $events['TRIGGERED']["DaemonEvent_".$action];
214           $tmp = new $evt['CLASS_NAME']($this->config);
215           $tmp->add_targets(array($this->netConfigDNS->macAddress));
216           $tmp->set_type(TRIGGERED_EVENT);
217           $o_queue = new gosaSupportDaemon();
218           if(!$o_queue->append($tmp)){
219             msg_dialog::display(_("Service infrastructure"),msgPool::siError($o_queue->get_error()),ERROR_DIALOG);
220           }
221         }
222       } else {
223         msg_dialog::display(_("Event error"),
224                     sprintf(_("Event '%s' is not available!"),$action),ERROR_DIALOG);
225       }
228     }
230     /* Do we represent a valid terminal? */
231     if (!$this->is_account && $this->parent === NULL){
232       $display= "<img alt=\"\" src=\"images/small-error.png\" align=middle>&nbsp;<b>".
233         msgPool::noValidExtension(_("workstation"))."</b>";
234       return($display);
235     }
237     /* Add new ntp Server to our list */ 
238     if((isset($_POST['addNtpServer'])) && (isset($_POST['gotoNtpServers'])) && $this->acl_is_writeable("gotoNtpServer")){
239       $this->gotoNtpServer[$_POST['gotoNtpServers']] = $_POST['gotoNtpServers'];
240     }
242     /* Delete selected NtpServer for list of used servers  */
243     if((isset($_POST['delNtpServer'])) && (isset($_POST['gotoNtpServerSelected'])) && $this->acl_is_writeable("gotoNtpServer")){
244       foreach($_POST['gotoNtpServerSelected'] as $name){
245         unset($this->gotoNtpServer[$name]);
246       }
247     }
249     /* Fill templating stuff */
250     $smarty= get_smarty();
253     /* Set acls */
254     $tmp = $this->plInfo();
255     foreach($tmp['plProvidedAcls'] as $name => $translation){
256       $smarty->assign($name."ACL",$this->getacl($name));
257     }
259     $smarty->assign("cn", $this->cn);
260     $smarty->assign("description", $this->description);
261     $smarty->assign("l", $this->l);
263     $tmp = array();
264     foreach($this->gotoNtpServers as $server){
265       if(!in_array($server,$this->gotoNtpServer)){
266         $tmp[$server] = $server;
267       }
268     }
269     $smarty->assign("gotoNtpServers",$tmp);
270         
271     /* Check if workstation is online */
272     if (gosaSupportDaemon::ping($this->netConfigDNS->macAddress)){
273       $smarty->assign("actions", array("halt" => _("Switch off"), "reboot" => _("Reboot"),
274                                        "update" => _("Software update"),
275                                        "reinstall" => _("Reinstall"),
276                                        "rescan" => _("Rescan hardware"),
277                                        #"memcheck" => _("Memory test"),
278                                        "localboot" => _("Force localboot"),
279                                        #"sysinfo"  => _("System analysis")
280                                         ));
281     } else {
282       $smarty->assign("actions", array("wakeup" => _("Wake up"),
283                                        "reinstall" => _("Reinstall"),
284                                        "update" => _("Software update"),
285                                        #"memcheck" => _("Memory test"),
286                                        "localboot" => _("Force localboot"),
287                                        #"sysinfo"  => _("System analysis")
288                                         ));
289     }
290     /* Arrays */
291     $smarty->assign("modes", $this->modes);
292     $smarty->assign("nfsservers", $this->config->data['SERVERS']['NFS']);
293     $smarty->assign("syslogservers", $this->gotoSyslogServers);
294     $smarty->assign("fai_activated",$this->fai_activated);
296     $ntpser = array();
297     foreach($this->gotoNtpServers as $server){
298       if(!in_array($server,$this->gotoNtpServer)){
299         $ntpser[$server] = $server;
300       }
301     }
302     $smarty->assign("gotoNtpServers", $ntpser);
304     /* Variables */
305     foreach(array("gotoMode", "gotoSyslogServer", "gotoNtpServer") as $val){
306       $smarty->assign($val."_select", $this->$val);
307     }
308     $smarty->assign("base", $this->baseSelector->render());
310     /* tell smarty the inherit checkbox state */
311     $smarty->assign("inheritTimeServer",$this->inheritTimeServer);
312     $smarty->assign("member_of_ogroup",$this->member_of_ogroup);
314     $str = $this->netConfigDNS->execute();
315     if(is_object($this->netConfigDNS->dialog)){
316       return($str);
317     }
318     $smarty->assign("netconfig", $str);
320     /* Display kerberos host key options */
321     $smarty->assign("host_key","");
322     if(is_object($this->kerberos_key_service)){
323       $smarty->assign("host_key",$this->kerberos_key_service->execute_by_prefix("host/"));
324     }
326     /* Show main page */
327     $smarty->assign("currently_installing", $this->currently_installing);
328     return($smarty->fetch (get_template_path('workstation.tpl', TRUE, dirname(__FILE__))));
329   }
331   function remove_from_parent()
332   {
333     if($this->acl_is_removeable()){
335       $this->netConfigDNS->remove_from_parent();
336       $ldap= $this->config->get_ldap_link();
337       $ldap->rmdir($this->dn);
338       new log("remove","workstation/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
339       if (!$ldap->success()){
340         msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, LDAP_DEL, get_class()));
341       }
343       /* Remove kerberos key dependencies too */
344       if(is_object($this->kerberos_key_service)){
345         $this->kerberos_key_service->remove_from_parent_by_prefix("host/");
346       }
348       /* Optionally execute a command after we're done */
349       $this->handle_post_events("remove", array("macAddress" => $this->netConfigDNS->macAddress,"ipHostNumber" => $this->netConfigDNS->ipHostNumber));
351       /* Delete references to object groups */
352       $ldap->cd ($this->config->current['BASE']);
353       $ldap->search ("(&(objectClass=gosaGroupOfNames)(member=".LDAP::prepare4filter($this->dn)."))", array("cn"));
354       while ($ldap->fetch()){
355         $og= new ogroup($this->config, $ldap->getDN());
356         unset($og->member[$this->dn]);
357         $og->save ();
358       }
360       /* Remove all accessTo/trust dependencies */
361       update_accessTo($this->cn,"");
362     }
364     /* Clean queue form entries with this mac 
365      */
366     if(class_available("gosaSupportDaemon") && tests::is_mac($this->netConfigDNS->orig_macAddress)){
367       $q = new gosaSupportDaemon();
368       $q->clean_queue_from_mac($this->netConfigDNS->orig_macAddress);
369     }
371     if(isset($_POST["inheritAll"])){
372       $this->set_everything_to_inherited();
373     }
374   }
377   /* Save data to object */
378   function save_object()
379   {
381     /* Create a base backup and reset the
382        base directly after calling plugin::save_object();
383        Base will be set seperatly a few lines below */
384     $base_tmp = $this->base;
385     plugin::save_object();
386     $this->base = $base_tmp;
388     /* Refresh base */
389     if ($this->acl_is_moveable($this->base)){
390       if (!$this->baseSelector->update()) {
391         msg_dialog::display(_("Error"), msgPool::permMove(), ERROR_DIALOG);
392       }
393       if ($this->base != $this->baseSelector->getBase()) {
394         $this->base= $this->baseSelector->getBase();
395         $this->is_modified= TRUE;
396       }
397     }
399     $this->netConfigDNS->save_object();
401     /* Set inherit mode */
402     if((isset($_POST['workgeneric_posted'])) && ($this->acl_is_writeable("gotoNtpServer"))){
403       if(isset($_POST["inheritTimeServer"]) && $this->member_of_ogroup){
404         $this->inheritTimeServer = true;
405       }else{
406         $this->inheritTimeServer = false;
407       }
408     }
409     
410     if(isset($_POST["inheritAll"])){
411       $this->set_everything_to_inherited();
412     }
414     /* Hanle kerberos host key plugin */
415     if(is_object($this->kerberos_key_service)){
416       $this->kerberos_key_service->save_object_by_prefix("host/");
417     }
418   }
421   /* Check supplied data */
422   function check()
423   {
424     /* Call common method to give check the hook */
425     $message= plugin::check();
426  
427     /* Skip IP & Mac checks if this is a template */
428     if($this->cn != "wdefault"){
429       $message= array_merge($message, $this->netConfigDNS->check());
430     }
432     $this->dn= "cn=".$this->cn.",".get_ou("workgeneric", "workstationRDN").$this->base;
434     if ($this->cn == ""){
435       $message[]= msgPool::required(_("Name"));
436     }
438     /* Check if given name is a valid host/dns name */
439     if(!tests::is_dns_name($this->cn)){
440       $message[] = msgPool::invalid(_("Name"));
441     }
443     // Check if a wrong base was supplied
444     if(!$this->baseSelector->checkLastBaseUpdate()){
445       $message[]= msgPool::check_base();
446     }
448     if ($this->orig_dn != $this->dn){
449       $ldap= $this->config->get_ldap_link();
450       $ldap->cd ($this->base);
452       if($this->cn == "wdefault"){
453         $ldap->cat($this->dn);
454       }else{
455         $ldap->search ("(&(cn=".$this->cn.")(objectClass=gotoWorkstation))", array("cn"));
456       }
457       if ($ldap->count() != 0){
458         while ($attrs= $ldap->fetch()){
459           if (preg_match("/cn=dhcp,/",$attrs['dn']) || preg_match ("/,".preg_quote(get_ou("ArpNewDevice", "systemIncomingRDN"), '/')."/i", $ldap->getDN())){
460             continue;
461           } else {
462             if ($attrs['dn'] != $this->orig_dn){
463               $message[]= msgPool::duplicated(_("Name"));
464               break;
465             }
466           }
467         }
468       }
469     }
471     /* Check for valid ntpServer selection */
472     if((!$this->inheritTimeServer) && (!count($this->gotoNtpServer))){
473       $message[]= msgPool::required(_("NTP server"));
474     }
476     /* Only systems with a valid ldap handle can be activated 
477      */
478     if($this->gotoMode == "active" && $this->initial_gotoMode != "active"){
480       if(isset($this->parent->by_object['workstartup']) &&
481           !count($this->parent->by_object['workstartup']->gotoLdapServers) && 
482           !$this->parent->by_object['workstartup']->gotoLdap_inherit){
484         $message[] = _("A valid LDAP server assignement is missing!");
485       }
486     }else{
487       /* Warn the user, that this host is currently installing */
488       if($this->currently_installing && !$this->currently_installing_warned && 
489           !preg_match("/".preg_quote(get_ou("ArpNewDevice", "systemIncomingRDN"), '/')."/i",$this->orig_dn)){
490       
491         /* Force aborting without message dialog */
492         $message[] = "";
493         $this->currently_installing_warned = TRUE;
494         msg_dialog::display(_("Software deployment"), 
495             _("This host is currently installing. If you want to save it, press 'OK'."),
496             CONFIRM_DIALOG);
497       }
498     }
500     /* Check if we are allowed to create or move this object
501      */
502     if($this->orig_dn == "new" && !$this->acl_is_createable($this->base)){
503       $message[] = msgPool::permCreate();
504     }elseif($this->orig_dn != "new" && $this->base != $this->orig_base && !$this->acl_is_moveable($this->base)){
505       $message[] = msgPool::permMove();
506     }
507  
508     return ($message);
509   }
512   /* Save to LDAP */
513   function save()
514   {
515     /* Detect mode changes */
516     $activate= (isset($this->saved_attributes['gotoMode']) &&
517         $this->gotoMode != $this->saved_attributes['gotoMode'] &&
518         $this->gotoMode == "active" &&
519         tests::is_ip($this->netConfigDNS->ipHostNumber)) || $this->auto_activate;
520     plugin::save();
522     /* Strip out 'default' values */
523     foreach (array("gotoSyslogServer") as $val){
525       if (isset($this->attrs[$val]) && $this->attrs[$val] == "default"){
526         $this->attrs[$val]= array();
527       }
528     }
530     /* Add missing arrays */
531     foreach (array("ghScsiDev", "ghIdeDev", "ghNetNic") as $val){
532       if (isset ($this->$val) && count ($this->$val) != 0){
533         $this->attrs["$val"]= $this->$val;
534       }
535     }
537     /* Remove all empty values */
538     if ($this->orig_dn == 'new'){
539       $attrs= array();
540       foreach ($this->attrs as $key => $val){
541         if (is_array($val) && count($val) == 0){
542           continue;
543         }
544         $attrs[$key]= $val;
545       }
546       $this->attrs= $attrs;
547     }
549     /* Update ntp server settings */
550     if($this->inheritTimeServer){
551       if($this->is_new){
552         if(isset($this->attrs['gotoNtpServer'])){
553           unset($this->attrs['gotoNtpServer']);
554         }
555       }else{
556         $this->attrs['gotoNtpServer'] = array();
557       }
558     }else{
559       /* Set ntpServers */
560       $this->attrs['gotoNtpServer'] = array();
561       foreach($this->gotoNtpServer as $server){
562         $this->attrs['gotoNtpServer'][] = $server;
563       }
564     }
566     /* cn=default and macAddress=- indicates that this is a template */
567     if($this->cn == "wdefault"){
568       $this->netConfigDNS->macAddress = "-";
569     }
571     /* Write back to ldap */
572     $ldap= $this->config->get_ldap_link();
573     if ($this->orig_dn == 'new'){
574       $ldap->cd($this->config->current['BASE']);
575       $ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $this->dn));
576       $ldap->cd($this->dn);
577       $ldap->add($this->attrs);
578       new log("create","workstation/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
579       if (!$ldap->success()){
580         msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, 0, get_class()));
581       }
583       $this->netConfigDNS->cn = $this->cn;
584       $this->netConfigDNS->save();
586       $this->handle_post_events("add",array("macAddress" => $this->netConfigDNS->macAddress,"ipHostNumber" => $this->netConfigDNS->ipHostNumber));
587     } else {
588       if ($this->orig_dn != $this->dn){
590         /* Remove all accessTo/trust dependencies */
591         update_accessTo($this->orig_cn,$this->cn);
592       }
593       $ldap->cd($this->dn);
594       $this->cleanup();
595       $ldap->modify ($this->attrs); 
596       if (!$ldap->success()){
597         msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, LDAP_MOD, get_class()));
598       }
599       new log("modify","workstation/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
601       $this->netConfigDNS->cn = $this->cn;
602       $this->netConfigDNS->save();
604       $this->handle_post_events("modify",array("macAddress" => $this->netConfigDNS->macAddress,"ipHostNumber" => $this->netConfigDNS->ipHostNumber));
605     }
607     if ($activate && class_available("DaemonEvent")){
609       /* Send installation activation
610        */
611       $events = DaemonEvent::get_event_types(SYSTEM_EVENT | HIDDEN_EVENT);
612       $o_queue = new gosaSupportDaemon();
613       if(isset($events['TRIGGERED']['DaemonEvent_installation_activation'])){
614         $evt = $events['TRIGGERED']['DaemonEvent_installation_activation'];
615         $tmp = new $evt['CLASS_NAME']($this->config);
616         $tmp->set_type(TRIGGERED_EVENT);
617         $tmp->add_targets(array($this->netConfigDNS->macAddress));
618         if(!$o_queue->append($tmp)){
619           msg_dialog::display(_("Service infrastructure"),msgPool::siError($o_queue->get_error()),ERROR_DIALOG);
620         }
621       }
622     }
623   }
626   /* Display generic part for server copy & paste */
627   function getCopyDialog()
628   {
629     $vars = array("cn");
630     $smarty = get_smarty();
631     $smarty->assign("cn" ,$this->cn);
632     $smarty->assign("object","workstation");
633     $str = $smarty->fetch(get_template_path("paste_generic.tpl",TRUE));
634     $ret = array();
635     $ret['string'] = $str;
636     $ret['status'] = "";
637     return($ret);
638   }
641   function saveCopyDialog()
642   {
643     if(isset($_POST['cn'])){
644       $this->cn = $_POST['cn'];
645     }
646   }
649   function PrepareForCopyPaste($source)
650   {
651     plugin::PrepareForCopyPaste($source);
652     if(isset($source['macAddress'][0])){
653       $this->netConfigDNS->macAddress = $source['macAddress'][0];
654     }
655     if(isset($source['ipHostNumber'][0])){
656       $this->netConfigDNS->ipHostNumber = $source['ipHostNumber'][0];
657     }
659     /* Create used ntp server array */
660     $this->gotoNtpServer= array();
661     if(isset($source['gotoNtpServer'])){
662       $this->inheritTimeServer = false;
663       unset($source['gotoNtpServer']['count']);
664       foreach($source['gotoNtpServer'] as $server){
665         $this->gotoNtpServer[$server] = $server;
666       }
667     }
669     /* Set inherit checkbox state */
670     if((in_array("default",$this->gotoNtpServer)) || (count($this->gotoNtpServer)==0)){
671       $this->inheritTimeServer = true;
672       $this->gotoNtpServer=array();
673     }
674   }
677   /* Return plugin informations for acl handling 
678       #FIXME FAIscript seams to ununsed within this class... */ 
679   static function plInfo()
680   {
681     return (array(  
682           "plShortName"   => _("Generic"),
683           "plDescription" => _("Workstation generic"),
684           "plSelfModify"  => FALSE,
685           "plDepends"     => array(),
686           "plPriority"    => 0,
687           "plSection"     => array("administration"),
688           "plCategory"    => array("workstation" => array("description"  => _("Workstation"),
689                                                           "objectClass"  => "gotoWorkstation")),
690           "plProperties" =>
691           array(
692               array(
693                   "name"          => "workstationRDN",
694                   "type"          => "rdn",
695                   "default"       => "ou=workstations,ou=systems,",
696                   "description"   => _("The 'workstationRDN' statement defines the location where new workstations will be created. The default is 'ou=workstations,ou=systems,'."),
697                   "check"         => "gosaProperty::isRdn",
698                   "migrate"       => "",
699                   "group"         => "plugin",
700                   "mandatory"     => FALSE
701                   ),
702               array(
703                   "name"          => "systemIsoHook",
704                   "type"          => "command",
705                   "default"       => "",
706                   "description"   => _("To enable the burn CD image function, you can specify the 'systemIsoHook'. You will get a CD symbol in the systems list - which calls the hook if pressed."),
707                   "check"         => "gosaProperty::isCommand",
708                   "migrate"       => "",
709                   "group"         => "plugin",
710                   "mandatory"     => FALSE
711                   )
712               ),
714           "plProvidedAcls"=> array(
715             "cn"                  => _("Workstation name"),
716             "description"         => _("Description") ,
717             "l"                   => _("Location") ,
718             "base"                => _("Base") ,
719             "gotoMode"            => _("Goto mode"), 
720             "gotoSyslogServer"    => _("Syslog server"), 
721             "gotoNtpServer"       => _("Ntp server"), 
722             "userPassword"      => _("Root password"),
723             "createFAICD"         => _("Create FAI CD"),
724             "FAIstate"            => _("Action flag"))
725           ));
726   }
728   function set_everything_to_inherited()
729   {
730     $this->gotoSyslogServer  = "default";
731     $this->inheritTimeServer = TRUE;
733     /* Set workstation service attributes to inherited */
734     if($this->member_of_ogroup && isset($this->parent->by_object['workservice'])){
735       foreach(array("gotoXKbLayout","gotoXKbModel","gotoXKbVariant","gotoXDriver",
736             "gotoXResolution","gotoXColordepth","gotoXMouseType","gotoXMouseport") as $name){
737         if($this->parent->by_object['workservice']->acl_is_writeable($name)){
738           $this->parent->by_object['workservice']->$name = "default"; 
739         }
740       }
741     }
743     /* Set workstation startup attributes to inherited */
744     if($this->member_of_ogroup && isset($this->parent->by_object['workstartup'])){
745       $obj = $this->parent->by_object['workstartup'];
746       if($obj->acl_is_writeable("gotoBootKernel")){
747         $this->parent->by_object['workstartup']->gotoBootKernel = "default-inherited";
748       }
749       if($obj->acl_is_writeable("gotoLdapServer")){
750         $this->parent->by_object['workstartup']->gotoLdapServer = "default-inherited";
751         $this->parent->by_object['workstartup']->gotoLdap_inherit = TRUE;
752         $this->parent->by_object['workstartup']->gotoLdapServers = array();
753       }
754       if($obj->acl_is_writeable("FAIdebianMirror")){
755         $this->parent->by_object['workstartup']->FAIdebianMirror= "inherited";
756       }
757     }
758   }
761   function is_modal_dialog()
762   {
763     return((isset($this->dialog) && $this->dialog) || (isset($this->netConfigDNS->dialog) && $this->netConfigDNS->dialog));
764   }
768   // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
769 ?>