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