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 $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= get_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> <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']] = get_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", set_post($this->cn));
260 $smarty->assign("description", set_post($this->description));
261 $smarty->assign("l", set_post($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", set_post($tmp));
271 /* Check if workstation is online */
272 if (gosaSupportDaemon::ping($this->netConfigDNS->macAddress)){
273 $smarty->assign("actions",
274 set_post(
275 array(
276 "halt" => _("Switch off"),
277 "reboot" => _("Reboot"),
278 "update" => _("Software update"),
279 "reinstall" => _("Reinstall"),
280 "rescan" => _("Rescan hardware"),
281 "localboot" => _("Force local boot"),
282 )
283 )
284 );
285 } else {
286 $smarty->assign("actions",
287 set_post(
288 array(
289 "wakeup" => _("Wake up"),
290 "reinstall" => _("Reinstall"),
291 "update" => _("Software update"),
292 "localboot" => _("Force local boot"),
293 )
294 )
295 );
296 }
297 /* Arrays */
298 $smarty->assign("modes", set_post($this->modes));
299 $smarty->assign("nfsservers", set_post($this->config->data['SERVERS']['NFS']));
300 $smarty->assign("syslogservers",set_post($this->gotoSyslogServers));
301 $smarty->assign("fai_activated",set_post($this->fai_activated));
303 $ntpser = array();
304 foreach($this->gotoNtpServers as $server){
305 if(!in_array($server,$this->gotoNtpServer)){
306 $ntpser[$server] = set_post($server);
307 }
308 }
309 $smarty->assign("gotoNtpServers", $ntpser);
311 /* Variables */
312 foreach(array("gotoMode", "gotoSyslogServer", "gotoNtpServer") as $val){
313 $smarty->assign($val."_select", set_post($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("workgeneric", "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("ArpNewDevice", "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 assignment 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("ArpNewDevice", "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", set_post($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 = get_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("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 "plRequirements"=> array(
696 'ldapSchema' => array('gotoWorkstation' => '>=2.7'),
697 'onFailureDisablePlugin' => array(get_class())
698 ),
699 "plCategory" => array("workstation" => array("description" => _("Workstation"),
700 "objectClass" => "gotoWorkstation")),
701 "plProperties" =>
702 array(
703 array(
704 "name" => "workstationRDN",
705 "type" => "rdn",
706 "default" => "ou=workstations,ou=systems,",
707 "description" => _("The 'workstationRDN' statement defines the location where new workstations will be created. The default is 'ou=workstations,ou=systems,'."),
708 "check" => "gosaProperty::isRdn",
709 "migrate" => "migrate_workstationRDN",
710 "group" => "plugin",
711 "mandatory" => FALSE
712 ),
713 array(
714 "name" => "systemIsoHook",
715 "type" => "command",
716 "default" => "",
717 "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."),
718 "check" => "gosaProperty::isCommand",
719 "migrate" => "",
720 "group" => "plugin",
721 "mandatory" => FALSE
722 )
723 ),
725 "plProvidedAcls"=> array(
726 "cn" => _("Workstation name"),
727 "description" => _("Description") ,
728 "l" => _("Location") ,
729 "base" => _("Base") ,
730 "gotoMode" => _("Goto mode"),
731 "gotoSyslogServer" => _("Syslog server"),
732 "gotoNtpServer" => _("NTP server"),
733 "userPassword" => _("Root password"),
734 "createFAICD" => _("Create FAI CD"),
735 "FAIstate" => _("Action flag"))
736 ));
737 }
739 function set_everything_to_inherited()
740 {
741 $this->gotoSyslogServer = "default";
742 $this->inheritTimeServer = TRUE;
744 /* Set workstation service attributes to inherited */
745 if($this->member_of_ogroup && isset($this->parent->by_object['workservice'])){
746 foreach(array("gotoXKbLayout","gotoXKbModel","gotoXKbVariant","gotoXDriver",
747 "gotoXResolution","gotoXColordepth","gotoXMouseType","gotoXMouseport") as $name){
748 if($this->parent->by_object['workservice']->acl_is_writeable($name)){
749 $this->parent->by_object['workservice']->$name = "default";
750 }
751 }
752 }
754 /* Set workstation startup attributes to inherited */
755 if($this->member_of_ogroup && isset($this->parent->by_object['workstartup'])){
756 $obj = $this->parent->by_object['workstartup'];
757 if($obj->acl_is_writeable("gotoBootKernel")){
758 $this->parent->by_object['workstartup']->gotoBootKernel = "default-inherited";
759 }
760 if($obj->acl_is_writeable("gotoLdapServer")){
761 $this->parent->by_object['workstartup']->gotoLdapServer = "default-inherited";
762 $this->parent->by_object['workstartup']->gotoLdap_inherit = TRUE;
763 $this->parent->by_object['workstartup']->gotoLdapServers = array();
764 }
765 if($obj->acl_is_writeable("FAIdebianMirror")){
766 $this->parent->by_object['workstartup']->FAIdebianMirror= "inherited";
767 }
768 }
769 }
772 function is_modal_dialog()
773 {
774 return((isset($this->dialog) && $this->dialog) || (isset($this->netConfigDNS->dialog) && $this->netConfigDNS->dialog));
775 }
778 }
779 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
780 ?>