1 <?php
3 class workgeneric extends plugin
4 {
5 /* Generic terminal attributes */
6 var $gotoMode= "locked";
7 var $initial_gotoMode= "locked";
8 var $gotoSyslogServer= "";
9 var $gotoSyslogServers= array();
10 var $gotoNtpServer= array();
11 var $gotoNtpServers= array();
12 var $gotoSndModule= "";
13 var $gotoFloppyEnable= "";
14 var $gotoCdromEnable= "";
15 var $description= "";
16 var $ghCpuType= "-";
17 var $ghMemSize= "-";
18 var $ghUsbSupport= "-";
19 var $ghNetNic= array();
20 var $ghIdeDev= array();
21 var $ghScsiDev= array();
22 var $ghGfxAdapter= "-";
23 var $ghSoundAdapter= "-";
24 var $gotoLastUser= "-";
25 var $FAIscript= "";
26 var $view_logged = FALSE;
27 var $auto_activate= FALSE;
29 /* Needed values and lists */
30 var $base= "";
31 var $cn= "";
32 var $l= "";
33 var $orig_dn= "";
34 var $orig_cn= "";
35 var $orig_base= "";
37 /* Plugin side filled */
38 var $modes= array();
40 var $netConfigDNS;
42 var $inheritTimeServer = true;
44 /* attribute list for save action */
45 var $ignore_account= TRUE;
46 var $attributes= array("gotoMode", "gotoSyslogServer", "gotoNtpServer",
47 "gotoFloppyEnable", "gotoCdromEnable", "cn", "gotoSndModule",
48 "ghCpuType", "ghMemSize", "ghUsbSupport", "description",
49 "ghGfxAdapter", "ghSoundAdapter", "gotoLastUser", "l","FAIscript");
50 var $objectclasses= array("top", "gotoWorkstation", "GOhard");
52 var $validActions = array("reboot" => "", "localboot" => "", "halt" => "", "update" => "", "reinstall" => "",
53 "rescan" => "", "wakeup" => "", "memcheck" => "", "sysinfo" => "");
55 var $fai_activated = FALSE;
57 var $member_of_ogroup = FALSE;
59 var $currently_installing = FALSE;
60 var $currently_installing_warned = FALSE;
62 var $kerberos_key_service = NULL;
64 function workgeneric (&$config, $dn= NULL, $parent= NULL)
65 {
66 $tmp= $config->search("faiManagement", "CLASS",array('menu','tabs'));
67 if(!empty($tmp)){
68 $this->fai_activated = TRUE;
69 }
71 plugin::plugin ($config, $dn, $parent);
73 if(class_available("krbHostKeys")){
74 $this->kerberos_key_service = new krbHostKeys($this->config,$this);
75 }
77 if(!isset($this->parent->by_object['ogroup'])){
78 $ldap = $this->config->get_ldap_link();
79 $ldap->cd ($this->config->current['BASE']);
80 $ldap->search("(&(objectClass=gotoWorkstationTemplate)(member=".LDAP::prepare4filter($this->dn)."))",array("cn"));
81 $this->member_of_ogroup = $ldap->count() >= 1;
82 }
84 $this->netConfigDNS = new termDNS($this->config,$this,$this->objectclasses);
85 $this->netConfigDNS->MACisMust =TRUE;
87 /* Check if this host is currently in installation process*/
88 if(class_available("gosaSupportDaemon") && class_available("DaemonEvent")){
89 $o = new gosaSupportDaemon();
90 $e_types = DaemonEvent::get_event_types(USER_EVENT | SYSTEM_EVENT | HIDDEN_EVENT);
91 $evts = $o->get_entries_by_mac(array($this->netConfigDNS->macAddress));
92 foreach($evts as $evt){
93 if(isset($e_types['QUEUED'][$evt['HEADERTAG']]) && $evt['STATUS'] == "processing" &&
94 $e_types['QUEUED'][$evt['HEADERTAG']] == "DaemonEvent_reinstall"){
95 $this->currently_installing =TRUE;
96 }
97 }
98 }
100 /* Read arrays */
101 foreach (array("ghNetNic", "ghIdeDev", "ghScsiDev") as $val){
102 if (!isset($this->attrs[$val])){
103 continue;
104 }
105 for ($i= 0; $i<$this->attrs[$val]['count']; $i++){
106 array_push($this->$val, $this->attrs[$val][$i]);
107 }
108 }
110 /* Create used ntp server array */
111 $this->gotoNtpServer= array();
112 if(isset($this->attrs['gotoNtpServer'])){
113 $this->inheritTimeServer = false;
114 unset($this->attrs['gotoNtpServer']['count']);
115 foreach($this->attrs['gotoNtpServer'] as $server){
116 $this->gotoNtpServer[$server] = $server;
117 }
118 }
120 /* Set inherit checkbox state */
121 if((in_array("default",$this->gotoNtpServer)) || (count($this->gotoNtpServer) == 0)){
122 $this->inheritTimeServer = true;
123 $this->gotoNtpServer=array();
124 }
126 /* You can't inherit the NTP service, if we are not member in an object group */
127 if(!$this->member_of_ogroup){
128 $this->inheritTimeServer = FALSE;
129 }
131 /* Create available ntp options */
132 $tmp = $this->config->data['SERVERS']['NTP'];
133 $this->gotoNtpServers = array();
134 foreach($tmp as $key => $server){
135 if($server == "default") continue;
136 $this->gotoNtpServers[$server] = $server;
137 }
139 $this->modes["active"]= _("Activated");
140 $this->modes["locked"]= _("Locked");
142 /* Set base */
143 if ($this->dn == "new"){
144 $ui= get_userinfo();
145 $this->base= dn2base($ui->dn);
146 } else {
147 $this->base= preg_replace ("/^[^,]+,".preg_quote(get_ou("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;
166 }
169 function set_acl_base($base)
170 {
171 plugin::set_acl_base($base);
172 $this->netConfigDNS->set_acl_base($base);
173 }
175 function set_acl_category($cat)
176 {
177 plugin::set_acl_category($cat);
178 $this->netConfigDNS->set_acl_category($cat);
179 }
181 function execute()
182 {
183 /* Call parent execute */
184 plugin::execute();
186 if($this->is_account && !$this->view_logged){
187 $this->view_logged = TRUE;
188 new log("view","workstation/".get_class($this),$this->dn);
189 }
191 /* Do we need to flip is_account state? */
192 if(isset($_POST['modify_state'])){
193 if($this->is_account && $this->acl_is_removeable()){
194 $this->is_account= FALSE;
195 }elseif(!$this->is_account && $this->acl_is_createable()){
196 $this->is_account= TRUE;
197 }
198 }
200 if ((isset($_POST['action'])) && ($this->acl_is_writeable("FAIstate")) && isset($this->validActions[$_POST['saction']]) ){
201 $action= $_POST['saction'];
203 /* Check if we have an DaemonEvent for this action */
204 if(class_available("DaemonEvent")){
205 $events = DaemonEvent::get_event_types(SYSTEM_EVENT | HIDDEN_EVENT);
206 if(isset($events['TRIGGERED']["DaemonEvent_".$action])){
207 $evt = $events['TRIGGERED']["DaemonEvent_".$action];
208 $tmp = new $evt['CLASS_NAME']($this->config);
209 $tmp->add_targets(array($this->netConfigDNS->macAddress));
210 $tmp->set_type(TRIGGERED_EVENT);
211 $o_queue = new gosaSupportDaemon();
212 if(!$o_queue->append($tmp)){
213 msg_dialog::display(_("Service infrastructure"),msgPool::siError($o_queue->get_error()),ERROR_DIALOG);
214 }
215 }
216 } else {
217 msg_dialog::display(_("Event error"),
218 sprintf(_("Event '%s' is not available!"),$action),ERROR_DIALOG);
219 }
222 }
224 /* Do we represent a valid terminal? */
225 if (!$this->is_account && $this->parent === NULL){
226 $display= "<img alt=\"\" src=\"images/small-error.png\" align=middle> <b>".
227 msgPool::noValidExtension(_("workstation"))."</b>";
228 return($display);
229 }
231 /* Base select dialog */
232 $once = true;
233 foreach($_POST as $name => $value){
234 if(preg_match("/^chooseBase/",$name) && $once && $this->acl_is_writeable("base")){
235 $once = false;
236 $this->dialog = new baseSelectDialog($this->config,$this,$this->get_allowed_bases());
237 $this->dialog->setCurrentBase($this->base);
238 }
239 }
241 /* Dialog handling */
242 if(is_object($this->dialog)){
243 /* Must be called before save_object */
244 $this->dialog->save_object();
246 if($this->dialog->isClosed()){
247 $this->dialog = false;
248 }elseif($this->dialog->isSelected()){
250 /* A new base was selected, check if it is a valid one */
251 $tmp = $this->get_allowed_bases();
252 if(isset($tmp[$this->dialog->isSelected()])){
253 $this->base = $this->dialog->isSelected();
254 }
256 $this->dialog= false;
257 }else{
258 return($this->dialog->execute());
259 }
260 }
262 /* Add new ntp Server to our list */
263 if((isset($_POST['addNtpServer'])) && (isset($_POST['gotoNtpServers'])) && $this->acl_is_writeable("gotoNtpServer")){
264 $this->gotoNtpServer[$_POST['gotoNtpServers']] = $_POST['gotoNtpServers'];
265 }
267 /* Delete selected NtpServer for list of used servers */
268 if((isset($_POST['delNtpServer'])) && (isset($_POST['gotoNtpServerSelected'])) && $this->acl_is_writeable("gotoNtpServer")){
269 foreach($_POST['gotoNtpServerSelected'] as $name){
270 unset($this->gotoNtpServer[$name]);
271 }
272 }
274 /* Fill templating stuff */
275 $smarty= get_smarty();
277 /* Set acls */
278 $tmp = $this->plInfo();
279 foreach($tmp['plProvidedAcls'] as $name => $translation){
280 $smarty->assign($name."ACL",$this->getacl($name));
281 }
283 $smarty->assign("cn", $this->cn);
284 $smarty->assign("description", $this->description);
285 $smarty->assign("l", $this->l);
286 $smarty->assign("bases", $this->get_allowed_bases());
287 $smarty->assign("staticAddress", "");
289 $tmp = array();
290 foreach($this->gotoNtpServers as $server){
291 if(!in_array($server,$this->gotoNtpServer)){
292 $tmp[$server] = $server;
293 }
294 }
295 $smarty->assign("gotoNtpServers",$tmp);
297 /* Check if workstation is online */
298 if (gosaSupportDaemon::ping($this->netConfigDNS->macAddress)){
299 $smarty->assign("actions", array("halt" => _("Switch off"), "reboot" => _("Reboot"),
300 "update" => _("Software update"),
301 "reinstall" => _("Reinstall"),
302 "rescan" => _("Rescan hardware"),
303 #"memcheck" => _("Memory test"),
304 "localboot" => _("Force localboot"),
305 #"sysinfo" => _("System analysis")
306 ));
307 } else {
308 $smarty->assign("actions", array("wakeup" => _("Wake up"),
309 "reinstall" => _("Reinstall"),
310 "update" => _("Software update"),
311 #"memcheck" => _("Memory test"),
312 "localboot" => _("Force localboot"),
313 #"sysinfo" => _("System analysis")
314 ));
315 }
316 /* Arrays */
317 $smarty->assign("modes", $this->modes);
318 $smarty->assign("nfsservers", $this->config->data['SERVERS']['NFS']);
319 $smarty->assign("syslogservers", $this->gotoSyslogServers);
320 $smarty->assign("fai_activated",$this->fai_activated);
322 $ntpser = array();
323 foreach($this->gotoNtpServers as $server){
324 if(!in_array($server,$this->gotoNtpServer)){
325 $ntpser[$server] = $server;
326 }
327 }
328 $smarty->assign("gotoNtpServers", $ntpser);
330 /* Variables */
331 foreach(array("base", "gotoMode", "gotoSyslogServer", "gotoNtpServer") as $val){
332 $smarty->assign($val."_select", $this->$val);
333 }
335 /* tell smarty the inherit checkbox state */
336 $smarty->assign("inheritTimeServer",$this->inheritTimeServer);
337 $smarty->assign("member_of_ogroup",$this->member_of_ogroup);
339 $str = $this->netConfigDNS->execute();
340 if(is_object($this->netConfigDNS->dialog)){
341 return($str);
342 }
343 $smarty->assign("netconfig", $str);
345 /* Display kerberos host key options */
346 $smarty->assign("host_key","");
347 if(is_object($this->kerberos_key_service)){
348 $smarty->assign("host_key",$this->kerberos_key_service->execute_by_prefix("host/"));
349 }
351 /* Show main page */
352 $smarty->assign("currently_installing", $this->currently_installing);
353 return($smarty->fetch (get_template_path('workstation.tpl', TRUE, dirname(__FILE__))));
354 }
356 function remove_from_parent()
357 {
358 if($this->acl_is_removeable()){
360 $this->netConfigDNS->remove_from_parent();
361 $ldap= $this->config->get_ldap_link();
362 $ldap->rmdir($this->dn);
363 new log("remove","workstation/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
364 if (!$ldap->success()){
365 msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, LDAP_DEL, get_class()));
366 }
368 /* Remove kerberos key dependencies too */
369 if(is_object($this->kerberos_key_service)){
370 $this->kerberos_key_service->remove_from_parent_by_prefix("host/");
371 }
373 /* Optionally execute a command after we're done */
374 $this->handle_post_events("remove", array("macAddress" => $this->netConfigDNS->macAddress,"ipHostNumber" => $this->netConfigDNS->ipHostNumber));
376 /* Delete references to object groups */
377 $ldap->cd ($this->config->current['BASE']);
378 $ldap->search ("(&(objectClass=gosaGroupOfNames)(member=".LDAP::prepare4filter($this->dn)."))", array("cn"));
379 while ($ldap->fetch()){
380 $og= new ogroup($this->config, $ldap->getDN());
381 unset($og->member[$this->dn]);
382 $og->save ();
383 }
385 /* Remove all accessTo/trust dependencies */
386 update_accessTo($this->cn,"");
387 }
389 /* Clean queue form entries with this mac
390 */
391 if(class_available("gosaSupportDaemon") && tests::is_mac($this->netConfigDNS->orig_macAddress)){
392 $q = new gosaSupportDaemon();
393 $q->clean_queue_from_mac($this->netConfigDNS->orig_macAddress);
394 }
396 if(isset($_POST["inheritAll"])){
397 $this->set_everything_to_inherited();
398 }
399 }
402 /* Save data to object */
403 function save_object()
404 {
406 /* Create a base backup and reset the
407 base directly after calling plugin::save_object();
408 Base will be set seperatly a few lines below */
409 $base_tmp = $this->base;
410 plugin::save_object();
411 $this->base = $base_tmp;
413 /* Save base, since this is no LDAP attribute */
414 $tmp = $this->get_allowed_bases();
415 if(isset($_POST['base'])){
416 if(isset($tmp[$_POST['base']])){
417 $this->base= $_POST['base'];
418 }
419 }
421 $this->netConfigDNS->save_object();
423 /* Set inherit mode */
424 if((isset($_POST['workgeneric_posted'])) && ($this->acl_is_writeable("gotoNtpServer"))){
425 if(isset($_POST["inheritTimeServer"]) && $this->member_of_ogroup){
426 $this->inheritTimeServer = true;
427 }else{
428 $this->inheritTimeServer = false;
429 }
430 }
432 if(isset($_POST["inheritAll"])){
433 $this->set_everything_to_inherited();
434 }
436 /* Hanle kerberos host key plugin */
437 if(is_object($this->kerberos_key_service)){
438 $this->kerberos_key_service->save_object_by_prefix("host/");
439 }
440 }
443 /* Check supplied data */
444 function check()
445 {
446 /* Call common method to give check the hook */
447 $message= plugin::check();
449 /* Skip IP & Mac checks if this is a template */
450 if($this->cn != "wdefault"){
451 $message= array_merge($message, $this->netConfigDNS->check());
452 }
454 $this->dn= "cn=".$this->cn.",".get_ou('workstationRDN').$this->base;
456 if ($this->cn == ""){
457 $message[]= msgPool::required(_("Name"));
458 }
460 /* Check if given name is a valid host/dns name */
461 if(!tests::is_dns_name($this->cn)){
462 $message[] = msgPool::invalid(_("Name"));
463 }
465 if ($this->orig_dn != $this->dn){
466 $ldap= $this->config->get_ldap_link();
467 $ldap->cd ($this->base);
469 if($this->cn == "wdefault"){
470 $ldap->cat($this->dn);
471 }else{
472 $ldap->search ("(&(cn=".$this->cn.")(objectClass=gotoWorkstation))", array("cn"));
473 }
474 if ($ldap->count() != 0){
475 while ($attrs= $ldap->fetch()){
476 if (preg_match("/cn=dhcp,/",$attrs['dn']) || preg_match ("/,".preg_quote(get_ou('systemIncomingRDN'), '/')."/i", $ldap->getDN())){
477 continue;
478 } else {
479 if ($attrs['dn'] != $this->orig_dn){
480 $message[]= msgPool::duplicated(_("Name"));
481 break;
482 }
483 }
484 }
485 }
486 }
488 /* Check for valid ntpServer selection */
489 if((!$this->inheritTimeServer) && (!count($this->gotoNtpServer))){
490 $message[]= msgPool::required(_("NTP server"));
491 }
493 /* Only systems with a valid ldap handle can be activated
494 */
495 if($this->gotoMode == "active" && $this->initial_gotoMode != "active"){
497 if(isset($this->parent->by_object['workstartup']) &&
498 !count($this->parent->by_object['workstartup']->gotoLdapServers) &&
499 !$this->parent->by_object['workstartup']->gotoLdap_inherit){
501 $message[] = _("A valid LDAP server assignement is missing!");
502 }
503 }else{
504 /* Warn the user, that this host is currently installing */
505 if($this->currently_installing && !$this->currently_installing_warned &&
506 !preg_match("/".preg_quote(get_ou("systemIncomingRDN"), '/')."/i",$this->orig_dn)){
508 /* Force aborting without message dialog */
509 $message[] = "";
510 $this->currently_installing_warned = TRUE;
511 msg_dialog::display(_("Software deployment"),
512 _("This host is currently installing. If you want to save it, press 'OK'."),
513 CONFIRM_DIALOG);
514 }
515 }
517 /* Check if we are allowed to create or move this object
518 */
519 if($this->orig_dn == "new" && !$this->acl_is_createable($this->base)){
520 $message[] = msgPool::permCreate();
521 }elseif($this->orig_dn != "new" && $this->base != $this->orig_base && !$this->acl_is_moveable($this->base)){
522 $message[] = msgPool::permMove();
523 }
525 return ($message);
526 }
529 /* Save to LDAP */
530 function save()
531 {
532 /* Detect mode changes */
533 $activate= (isset($this->saved_attributes['gotoMode']) &&
534 $this->gotoMode != $this->saved_attributes['gotoMode'] &&
535 $this->gotoMode == "active" &&
536 tests::is_ip($this->netConfigDNS->ipHostNumber)) || $this->auto_activate;
537 plugin::save();
539 /* Strip out 'default' values */
540 foreach (array("gotoSyslogServer") as $val){
542 if (isset($this->attrs[$val]) && $this->attrs[$val] == "default"){
543 $this->attrs[$val]= array();
544 }
545 }
547 /* Add missing arrays */
548 foreach (array("ghScsiDev", "ghIdeDev", "ghNetNic") as $val){
549 if (isset ($this->$val) && count ($this->$val) != 0){
550 $this->attrs["$val"]= $this->$val;
551 }
552 }
554 /* Remove all empty values */
555 if ($this->orig_dn == 'new'){
556 $attrs= array();
557 foreach ($this->attrs as $key => $val){
558 if (is_array($val) && count($val) == 0){
559 continue;
560 }
561 $attrs[$key]= $val;
562 }
563 $this->attrs= $attrs;
564 }
566 /* Update ntp server settings */
567 if($this->inheritTimeServer){
568 if($this->is_new){
569 if(isset($this->attrs['gotoNtpServer'])){
570 unset($this->attrs['gotoNtpServer']);
571 }
572 }else{
573 $this->attrs['gotoNtpServer'] = array();
574 }
575 }else{
576 /* Set ntpServers */
577 $this->attrs['gotoNtpServer'] = array();
578 foreach($this->gotoNtpServer as $server){
579 $this->attrs['gotoNtpServer'][] = $server;
580 }
581 }
583 /* cn=default and macAddress=- indicates that this is a template */
584 if($this->cn == "wdefault"){
585 $this->netConfigDNS->macAddress = "-";
586 }
588 /* Write back to ldap */
589 $ldap= $this->config->get_ldap_link();
590 if ($this->orig_dn == 'new'){
591 $ldap->cd($this->config->current['BASE']);
592 $ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $this->dn));
593 $ldap->cd($this->dn);
594 $ldap->add($this->attrs);
595 new log("create","workstation/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
596 if (!$ldap->success()){
597 msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, 0, get_class()));
598 }
600 $this->netConfigDNS->cn = $this->cn;
601 $this->netConfigDNS->save();
603 $this->handle_post_events("add",array("macAddress" => $this->netConfigDNS->macAddress,"ipHostNumber" => $this->netConfigDNS->ipHostNumber));
604 } else {
605 if ($this->orig_dn != $this->dn){
607 /* Remove all accessTo/trust dependencies */
608 update_accessTo($this->orig_cn,$this->cn);
609 }
610 $ldap->cd($this->dn);
611 $this->cleanup();
612 $ldap->modify ($this->attrs);
613 if (!$ldap->success()){
614 msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, LDAP_MOD, get_class()));
615 }
616 new log("modify","workstation/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
618 $this->netConfigDNS->cn = $this->cn;
619 $this->netConfigDNS->save();
621 $this->handle_post_events("modify",array("macAddress" => $this->netConfigDNS->macAddress,"ipHostNumber" => $this->netConfigDNS->ipHostNumber));
622 }
624 if ($activate && class_available("DaemonEvent")){
626 /* Send installation activation
627 */
628 $events = DaemonEvent::get_event_types(SYSTEM_EVENT | HIDDEN_EVENT);
629 $o_queue = new gosaSupportDaemon();
630 if(isset($events['TRIGGERED']['DaemonEvent_installation_activation'])){
631 $evt = $events['TRIGGERED']['DaemonEvent_installation_activation'];
632 $tmp = new $evt['CLASS_NAME']($this->config);
633 $tmp->set_type(TRIGGERED_EVENT);
634 $tmp->add_targets(array($this->netConfigDNS->macAddress));
635 if(!$o_queue->append($tmp)){
636 msg_dialog::display(_("Service infrastructure"),msgPool::siError($o_queue->get_error()),ERROR_DIALOG);
637 }
638 }
639 }
640 }
643 /* Display generic part for server copy & paste */
644 function getCopyDialog()
645 {
646 $vars = array("cn");
647 $smarty = get_smarty();
648 $smarty->assign("cn" ,$this->cn);
649 $smarty->assign("object","workstation");
650 $str = $smarty->fetch(get_template_path("paste_generic.tpl",TRUE));
651 $ret = array();
652 $ret['string'] = $str;
653 $ret['status'] = "";
654 return($ret);
655 }
658 function saveCopyDialog()
659 {
660 if(isset($_POST['cn'])){
661 $this->cn = $_POST['cn'];
662 }
663 }
666 function PrepareForCopyPaste($source)
667 {
668 plugin::PrepareForCopyPaste($source);
669 if(isset($source['macAddress'][0])){
670 $this->netConfigDNS->macAddress = $source['macAddress'][0];
671 }
672 if(isset($source['ipHostNumber'][0])){
673 $this->netConfigDNS->ipHostNumber = $source['ipHostNumber'][0];
674 }
676 /* Create used ntp server array */
677 $this->gotoNtpServer= array();
678 if(isset($source['gotoNtpServer'])){
679 $this->inheritTimeServer = false;
680 unset($source['gotoNtpServer']['count']);
681 foreach($source['gotoNtpServer'] as $server){
682 $this->gotoNtpServer[$server] = $server;
683 }
684 }
686 /* Set inherit checkbox state */
687 if((in_array("default",$this->gotoNtpServer)) || (count($this->gotoNtpServer)==0)){
688 $this->inheritTimeServer = true;
689 $this->gotoNtpServer=array();
690 }
691 }
694 /* Return plugin informations for acl handling
695 #FIXME FAIscript seams to ununsed within this class... */
696 static function plInfo()
697 {
698 return (array(
699 "plShortName" => _("Generic"),
700 "plDescription" => _("Workstation generic"),
701 "plSelfModify" => FALSE,
702 "plDepends" => array(),
703 "plPriority" => 0,
704 "plSection" => array("administration"),
705 "plCategory" => array("workstation" => array("description" => _("Workstation"),
706 "objectClass" => "gotoWorkstation")),
707 "plProvidedAcls"=> array(
708 "cn" => _("Workstation name"),
709 "description" => _("Description") ,
710 "l" => _("Location") ,
711 "base" => _("Base") ,
712 "gotoMode" => _("Goto mode"),
713 "gotoSyslogServer" => _("Syslog server"),
714 "gotoNtpServer" => _("Ntp server"),
715 "userPassword" => _("Root password"),
716 "createFAICD" => _("Create FAI CD"),
717 "FAIstate" => _("Action flag"))
718 ));
719 }
721 function set_everything_to_inherited()
722 {
723 $this->gotoSyslogServer = "default";
724 $this->inheritTimeServer = TRUE;
726 /* Set workstation service attributes to inherited */
727 if($this->member_of_ogroup && isset($this->parent->by_object['workservice'])){
728 foreach(array("gotoXKbLayout","gotoXKbModel","gotoXKbVariant","gotoXDriver",
729 "gotoXResolution","gotoXColordepth","gotoXMouseType","gotoXMouseport") as $name){
730 if($this->parent->by_object['workservice']->acl_is_writeable($name)){
731 $this->parent->by_object['workservice']->$name = "default";
732 }
733 }
734 }
736 /* Set workstation startup attributes to inherited */
737 if($this->member_of_ogroup && isset($this->parent->by_object['workstartup'])){
738 $obj = $this->parent->by_object['workstartup'];
739 if($obj->acl_is_writeable("gotoBootKernel")){
740 $this->parent->by_object['workstartup']->gotoBootKernel = "default-inherited";
741 }
742 if($obj->acl_is_writeable("gotoLdapServer")){
743 $this->parent->by_object['workstartup']->gotoLdapServer = "default-inherited";
744 $this->parent->by_object['workstartup']->gotoLdap_inherit = TRUE;
745 $this->parent->by_object['workstartup']->gotoLdapServers = array();
746 }
747 if($obj->acl_is_writeable("FAIdebianMirror")){
748 $this->parent->by_object['workstartup']->FAIdebianMirror= "inherited";
749 }
750 }
751 }
754 function is_modal_dialog()
755 {
756 return((isset($this->dialog) && $this->dialog) || (isset($this->netConfigDNS->dialog) && $this->netConfigDNS->dialog));
757 }
760 }
761 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
762 ?>