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("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("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);
266 $tmp = array();
267 foreach($this->gotoNtpServers as $server){
268 if(!in_array($server,$this->gotoNtpServer)){
269 $tmp[$server] = $server;
270 }
271 }
272 $smarty->assign("gotoNtpServers",$tmp);
274 /* Check if workstation is online */
275 if (gosaSupportDaemon::ping($this->netConfigDNS->macAddress)){
276 $smarty->assign("actions", array("halt" => _("Switch off"), "reboot" => _("Reboot"),
277 "update" => _("Software update"),
278 "reinstall" => _("Reinstall"),
279 "rescan" => _("Rescan hardware"),
280 #"memcheck" => _("Memory test"),
281 "localboot" => _("Force localboot"),
282 #"sysinfo" => _("System analysis")
283 ));
284 } else {
285 $smarty->assign("actions", array("wakeup" => _("Wake up"),
286 "reinstall" => _("Reinstall"),
287 "update" => _("Software update"),
288 #"memcheck" => _("Memory test"),
289 "localboot" => _("Force localboot"),
290 #"sysinfo" => _("System analysis")
291 ));
292 }
293 /* Arrays */
294 $smarty->assign("modes", $this->modes);
295 $smarty->assign("nfsservers", $this->config->data['SERVERS']['NFS']);
296 $smarty->assign("syslogservers", $this->gotoSyslogServers);
297 $smarty->assign("fai_activated",$this->fai_activated);
299 $ntpser = array();
300 foreach($this->gotoNtpServers as $server){
301 if(!in_array($server,$this->gotoNtpServer)){
302 $ntpser[$server] = $server;
303 }
304 }
305 $smarty->assign("gotoNtpServers", $ntpser);
307 /* Variables */
308 foreach(array("gotoMode", "gotoSyslogServer", "gotoNtpServer") as $val){
309 $smarty->assign($val."_select", $this->$val);
310 }
311 $smarty->assign("base", $this->baseSelector->render());
313 /* tell smarty the inherit checkbox state */
314 $smarty->assign("inheritTimeServer",$this->inheritTimeServer);
315 $smarty->assign("member_of_ogroup",$this->member_of_ogroup);
317 $str = $this->netConfigDNS->execute();
318 if(is_object($this->netConfigDNS->dialog)){
319 return($str);
320 }
321 $smarty->assign("netconfig", $str);
323 /* Display kerberos host key options */
324 $smarty->assign("host_key","");
325 if(is_object($this->kerberos_key_service)){
326 $smarty->assign("host_key",$this->kerberos_key_service->execute_by_prefix("host/"));
327 }
329 /* Show main page */
330 $smarty->assign("currently_installing", $this->currently_installing);
331 return($smarty->fetch (get_template_path('workstation.tpl', TRUE, dirname(__FILE__))));
332 }
334 function remove_from_parent()
335 {
336 if($this->acl_is_removeable()){
338 $this->netConfigDNS->remove_from_parent();
339 $ldap= $this->config->get_ldap_link();
340 $ldap->rmdir($this->dn);
341 new log("remove","workstation/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
342 if (!$ldap->success()){
343 msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, LDAP_DEL, get_class()));
344 }
346 /* Remove kerberos key dependencies too */
347 if(is_object($this->kerberos_key_service)){
348 $this->kerberos_key_service->remove_from_parent_by_prefix("host/");
349 }
351 /* Optionally execute a command after we're done */
352 $this->handle_post_events("remove", array("macAddress" => $this->netConfigDNS->macAddress,"ipHostNumber" => $this->netConfigDNS->ipHostNumber));
354 /* Delete references to object groups */
355 $ldap->cd ($this->config->current['BASE']);
356 $ldap->search ("(&(objectClass=gosaGroupOfNames)(member=".LDAP::prepare4filter($this->dn)."))", array("cn"));
357 while ($ldap->fetch()){
358 $og= new ogroup($this->config, $ldap->getDN());
359 unset($og->member[$this->dn]);
360 $og->save ();
361 }
363 /* Remove all accessTo/trust dependencies */
364 update_accessTo($this->cn,"");
365 }
367 /* Clean queue form entries with this mac
368 */
369 if(class_available("gosaSupportDaemon") && tests::is_mac($this->netConfigDNS->orig_macAddress)){
370 $q = new gosaSupportDaemon();
371 $q->clean_queue_from_mac($this->netConfigDNS->orig_macAddress);
372 }
374 if(isset($_POST["inheritAll"])){
375 $this->set_everything_to_inherited();
376 }
377 }
380 /* Save data to object */
381 function save_object()
382 {
384 /* Create a base backup and reset the
385 base directly after calling plugin::save_object();
386 Base will be set seperatly a few lines below */
387 $base_tmp = $this->base;
388 plugin::save_object();
389 $this->base = $base_tmp;
391 /* Refresh base */
392 if ($this->acl_is_moveable($this->base)){
393 if (!$this->baseSelector->update()) {
394 msg_dialog::display(_("Error"), msgPool::permMove(), ERROR_DIALOG);
395 }
396 if ($this->base != $this->baseSelector->getBase()) {
397 $this->base= $this->baseSelector->getBase();
398 $this->is_modified= TRUE;
399 }
400 }
402 $this->netConfigDNS->save_object();
404 /* Set inherit mode */
405 if((isset($_POST['workgeneric_posted'])) && ($this->acl_is_writeable("gotoNtpServer"))){
406 if(isset($_POST["inheritTimeServer"]) && $this->member_of_ogroup){
407 $this->inheritTimeServer = true;
408 }else{
409 $this->inheritTimeServer = false;
410 }
411 }
413 if(isset($_POST["inheritAll"])){
414 $this->set_everything_to_inherited();
415 }
417 /* Hanle kerberos host key plugin */
418 if(is_object($this->kerberos_key_service)){
419 $this->kerberos_key_service->save_object_by_prefix("host/");
420 }
421 }
424 /* Check supplied data */
425 function check()
426 {
427 /* Call common method to give check the hook */
428 $message= plugin::check();
430 /* Skip IP & Mac checks if this is a template */
431 if($this->cn != "wdefault"){
432 $message= array_merge($message, $this->netConfigDNS->check());
433 }
435 $this->dn= "cn=".$this->cn.",".get_ou('workstationRDN').$this->base;
437 if ($this->cn == ""){
438 $message[]= msgPool::required(_("Name"));
439 }
441 /* Check if given name is a valid host/dns name */
442 if(!tests::is_dns_name($this->cn)){
443 $message[] = msgPool::invalid(_("Name"));
444 }
446 // Check if a wrong base was supplied
447 if(!$this->baseSelector->checkLastBaseUpdate()){
448 $message[]= msgPool::check_base();
449 }
451 if ($this->orig_dn != $this->dn){
452 $ldap= $this->config->get_ldap_link();
453 $ldap->cd ($this->base);
455 if($this->cn == "wdefault"){
456 $ldap->cat($this->dn);
457 }else{
458 $ldap->search ("(&(cn=".$this->cn.")(objectClass=gotoWorkstation))", array("cn"));
459 }
460 if ($ldap->count() != 0){
461 while ($attrs= $ldap->fetch()){
462 if (preg_match("/cn=dhcp,/",$attrs['dn']) || preg_match ("/,".preg_quote(get_ou('systemIncomingRDN'), '/')."/i", $ldap->getDN())){
463 continue;
464 } else {
465 if ($attrs['dn'] != $this->orig_dn){
466 $message[]= msgPool::duplicated(_("Name"));
467 break;
468 }
469 }
470 }
471 }
472 }
474 /* Check for valid ntpServer selection */
475 if((!$this->inheritTimeServer) && (!count($this->gotoNtpServer))){
476 $message[]= msgPool::required(_("NTP server"));
477 }
479 /* Only systems with a valid ldap handle can be activated
480 */
481 if($this->gotoMode == "active" && $this->initial_gotoMode != "active"){
483 if(isset($this->parent->by_object['workstartup']) &&
484 !count($this->parent->by_object['workstartup']->gotoLdapServers) &&
485 !$this->parent->by_object['workstartup']->gotoLdap_inherit){
487 $message[] = _("A valid LDAP server assignement is missing!");
488 }
489 }else{
490 /* Warn the user, that this host is currently installing */
491 if($this->currently_installing && !$this->currently_installing_warned &&
492 !preg_match("/".preg_quote(get_ou("systemIncomingRDN"), '/')."/i",$this->orig_dn)){
494 /* Force aborting without message dialog */
495 $message[] = "";
496 $this->currently_installing_warned = TRUE;
497 msg_dialog::display(_("Software deployment"),
498 _("This host is currently installing. If you want to save it, press 'OK'."),
499 CONFIRM_DIALOG);
500 }
501 }
503 /* Check if we are allowed to create or move this object
504 */
505 if($this->orig_dn == "new" && !$this->acl_is_createable($this->base)){
506 $message[] = msgPool::permCreate();
507 }elseif($this->orig_dn != "new" && $this->base != $this->orig_base && !$this->acl_is_moveable($this->base)){
508 $message[] = msgPool::permMove();
509 }
511 return ($message);
512 }
515 /* Save to LDAP */
516 function save()
517 {
518 /* Detect mode changes */
519 $activate= (isset($this->saved_attributes['gotoMode']) &&
520 $this->gotoMode != $this->saved_attributes['gotoMode'] &&
521 $this->gotoMode == "active" &&
522 tests::is_ip($this->netConfigDNS->ipHostNumber)) || $this->auto_activate;
523 plugin::save();
525 /* Strip out 'default' values */
526 foreach (array("gotoSyslogServer") as $val){
528 if (isset($this->attrs[$val]) && $this->attrs[$val] == "default"){
529 $this->attrs[$val]= array();
530 }
531 }
533 /* Add missing arrays */
534 foreach (array("ghScsiDev", "ghIdeDev", "ghNetNic") as $val){
535 if (isset ($this->$val) && count ($this->$val) != 0){
536 $this->attrs["$val"]= $this->$val;
537 }
538 }
540 /* Remove all empty values */
541 if ($this->orig_dn == 'new'){
542 $attrs= array();
543 foreach ($this->attrs as $key => $val){
544 if (is_array($val) && count($val) == 0){
545 continue;
546 }
547 $attrs[$key]= $val;
548 }
549 $this->attrs= $attrs;
550 }
552 /* Update ntp server settings */
553 if($this->inheritTimeServer){
554 if($this->is_new){
555 if(isset($this->attrs['gotoNtpServer'])){
556 unset($this->attrs['gotoNtpServer']);
557 }
558 }else{
559 $this->attrs['gotoNtpServer'] = array();
560 }
561 }else{
562 /* Set ntpServers */
563 $this->attrs['gotoNtpServer'] = array();
564 foreach($this->gotoNtpServer as $server){
565 $this->attrs['gotoNtpServer'][] = $server;
566 }
567 }
569 /* cn=default and macAddress=- indicates that this is a template */
570 if($this->cn == "wdefault"){
571 $this->netConfigDNS->macAddress = "-";
572 }
574 /* Write back to ldap */
575 $ldap= $this->config->get_ldap_link();
576 if ($this->orig_dn == 'new'){
577 $ldap->cd($this->config->current['BASE']);
578 $ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $this->dn));
579 $ldap->cd($this->dn);
580 $ldap->add($this->attrs);
581 new log("create","workstation/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
582 if (!$ldap->success()){
583 msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, 0, get_class()));
584 }
586 $this->netConfigDNS->cn = $this->cn;
587 $this->netConfigDNS->save();
589 $this->handle_post_events("add",array("macAddress" => $this->netConfigDNS->macAddress,"ipHostNumber" => $this->netConfigDNS->ipHostNumber));
590 } else {
591 if ($this->orig_dn != $this->dn){
593 /* Remove all accessTo/trust dependencies */
594 update_accessTo($this->orig_cn,$this->cn);
595 }
596 $ldap->cd($this->dn);
597 $this->cleanup();
598 $ldap->modify ($this->attrs);
599 if (!$ldap->success()){
600 msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, LDAP_MOD, get_class()));
601 }
602 new log("modify","workstation/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
604 $this->netConfigDNS->cn = $this->cn;
605 $this->netConfigDNS->save();
607 $this->handle_post_events("modify",array("macAddress" => $this->netConfigDNS->macAddress,"ipHostNumber" => $this->netConfigDNS->ipHostNumber));
608 }
610 if ($activate && class_available("DaemonEvent")){
612 /* Send installation activation
613 */
614 $events = DaemonEvent::get_event_types(SYSTEM_EVENT | HIDDEN_EVENT);
615 $o_queue = new gosaSupportDaemon();
616 if(isset($events['TRIGGERED']['DaemonEvent_installation_activation'])){
617 $evt = $events['TRIGGERED']['DaemonEvent_installation_activation'];
618 $tmp = new $evt['CLASS_NAME']($this->config);
619 $tmp->set_type(TRIGGERED_EVENT);
620 $tmp->add_targets(array($this->netConfigDNS->macAddress));
621 if(!$o_queue->append($tmp)){
622 msg_dialog::display(_("Service infrastructure"),msgPool::siError($o_queue->get_error()),ERROR_DIALOG);
623 }
624 }
625 }
626 }
629 /* Display generic part for server copy & paste */
630 function getCopyDialog()
631 {
632 $vars = array("cn");
633 $smarty = get_smarty();
634 $smarty->assign("cn" ,$this->cn);
635 $smarty->assign("object","workstation");
636 $str = $smarty->fetch(get_template_path("paste_generic.tpl",TRUE));
637 $ret = array();
638 $ret['string'] = $str;
639 $ret['status'] = "";
640 return($ret);
641 }
644 function saveCopyDialog()
645 {
646 if(isset($_POST['cn'])){
647 $this->cn = $_POST['cn'];
648 }
649 }
652 function PrepareForCopyPaste($source)
653 {
654 plugin::PrepareForCopyPaste($source);
655 if(isset($source['macAddress'][0])){
656 $this->netConfigDNS->macAddress = $source['macAddress'][0];
657 }
658 if(isset($source['ipHostNumber'][0])){
659 $this->netConfigDNS->ipHostNumber = $source['ipHostNumber'][0];
660 }
662 /* Create used ntp server array */
663 $this->gotoNtpServer= array();
664 if(isset($source['gotoNtpServer'])){
665 $this->inheritTimeServer = false;
666 unset($source['gotoNtpServer']['count']);
667 foreach($source['gotoNtpServer'] as $server){
668 $this->gotoNtpServer[$server] = $server;
669 }
670 }
672 /* Set inherit checkbox state */
673 if((in_array("default",$this->gotoNtpServer)) || (count($this->gotoNtpServer)==0)){
674 $this->inheritTimeServer = true;
675 $this->gotoNtpServer=array();
676 }
677 }
680 /* Return plugin informations for acl handling
681 #FIXME FAIscript seams to ununsed within this class... */
682 static function plInfo()
683 {
684 return (array(
685 "plShortName" => _("Generic"),
686 "plDescription" => _("Workstation generic"),
687 "plSelfModify" => FALSE,
688 "plDepends" => array(),
689 "plPriority" => 0,
690 "plSection" => array("administration"),
691 "plCategory" => array("workstation" => array("description" => _("Workstation"),
692 "objectClass" => "gotoWorkstation")),
693 "plProvidedAcls"=> array(
694 "cn" => _("Workstation name"),
695 "description" => _("Description") ,
696 "l" => _("Location") ,
697 "base" => _("Base") ,
698 "gotoMode" => _("Goto mode"),
699 "gotoSyslogServer" => _("Syslog server"),
700 "gotoNtpServer" => _("Ntp server"),
701 "userPassword" => _("Root password"),
702 "createFAICD" => _("Create FAI CD"),
703 "FAIstate" => _("Action flag"))
704 ));
705 }
707 function set_everything_to_inherited()
708 {
709 $this->gotoSyslogServer = "default";
710 $this->inheritTimeServer = TRUE;
712 /* Set workstation service attributes to inherited */
713 if($this->member_of_ogroup && isset($this->parent->by_object['workservice'])){
714 foreach(array("gotoXKbLayout","gotoXKbModel","gotoXKbVariant","gotoXDriver",
715 "gotoXResolution","gotoXColordepth","gotoXMouseType","gotoXMouseport") as $name){
716 if($this->parent->by_object['workservice']->acl_is_writeable($name)){
717 $this->parent->by_object['workservice']->$name = "default";
718 }
719 }
720 }
722 /* Set workstation startup attributes to inherited */
723 if($this->member_of_ogroup && isset($this->parent->by_object['workstartup'])){
724 $obj = $this->parent->by_object['workstartup'];
725 if($obj->acl_is_writeable("gotoBootKernel")){
726 $this->parent->by_object['workstartup']->gotoBootKernel = "default-inherited";
727 }
728 if($obj->acl_is_writeable("gotoLdapServer")){
729 $this->parent->by_object['workstartup']->gotoLdapServer = "default-inherited";
730 $this->parent->by_object['workstartup']->gotoLdap_inherit = TRUE;
731 $this->parent->by_object['workstartup']->gotoLdapServers = array();
732 }
733 if($obj->acl_is_writeable("FAIdebianMirror")){
734 $this->parent->by_object['workstartup']->FAIdebianMirror= "inherited";
735 }
736 }
737 }
740 function is_modal_dialog()
741 {
742 return((isset($this->dialog) && $this->dialog) || (isset($this->netConfigDNS->dialog) && $this->netConfigDNS->dialog));
743 }
746 }
747 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
748 ?>