1 <?php
4 /*! \brief The opsi client base class.
5 This class can be implemented in tow different ways:
6 * as standalone opsi client
7 * as part of the samba tabs
8 both types will be detected automatically.
10 This class allows to edit the properties of an opsi client
11 and its products.
12 */
13 class opsiGeneric extends plugin
14 {
15 /* Contains a list of all available netboot products
16 */
17 private $a_availableNetbootProducts = array();
18 private $a_initial_availableNetbootProducts = array();
19 private $s_selectedNetbootProduct = "";
20 private $s_initial_selectedNetbootProduct = "";
22 /* Contains a list of all available local products
23 */
24 private $a_availableLocalProducts = array();
25 private $a_selectedLocalProducts = array();
26 private $a_initial_selectedLocalProducts = array();
28 /* Internal veriables
29 */
30 private $opsi; // The opsi handle
31 public $parent = NULL; // The parent object (in case of samba)
33 public $hostId = ""; // The host Id of the currently edit opsi host
34 public $mac = ""; // The hosts mac address
35 public $note = ""; // A note
36 public $description = ""; // The client description
38 public $initial_mac = "";
39 public $initial_note = "";
40 public $initial_description = "";
42 private $init_failed = FALSE; // Is true if the opsi communication failed
43 private $standalone = TRUE; // Is true if this is a standlone plugin. (Not samba)
44 private $is_installed= FALSE; // Is true is the hast is already installed.
46 public $attributes = array("mac","note","description");
48 public $netConfigDNS = NULL;
50 /*! \brief Initialize this class
51 @param Object The GOsa base config.
52 @param String The Id of the host that we want to edit.
53 @param Object The parent object. (in case of samba)
54 */
55 public function __construct(&$config,$hostId,&$parent = NULL)
56 {
57 /* Create opsi handle
58 */
59 $this->opsi = new opsi($config);
60 $this->config = $config;
62 /* Check if we are are part of a windows workstation
63 */
64 $this->parent = $parent;
65 if($parent instanceof wingeneric){
66 $this->standalone = FALSE;
67 }
69 /* Get hostId
70 */
71 if($hostId != "new"){
72 if(preg_match("/^opsi:/",$hostId)){
73 $this->hostId = preg_replace("/^opsi:=([^,]*),.*$/","\\1",$hostId);
74 }elseif($this->parent instanceof wingeneric){
75 $this->hostId = $this->parent->cn;
76 $this->hostId = preg_replace('/\$$/',"",$this->hostId);
77 }
78 }
80 /* Try to plugin */
81 $this->init();
82 }
85 /*! \brief Try to load opsi client informations from the
86 gosa support daemon.
87 */
88 private function init()
89 {
90 $err = FALSE;
91 $this->init_failed = FALSE;
92 $this->initially_was_account = FALSE;
94 /* We are a standalone plugin.
95 */
96 if($this->standalone ) {
97 $this->is_account = TRUE;
98 }
101 /* Try to load client infos from the gosa support daemon
102 */
103 if(!empty($this->hostId)){
104 $list = $this->opsi->list_clients($this->hostId);
105 $err |= $this->opsi->is_error();
107 /* Walk through all returned opsi clients and try to detect
108 one that matches our hostId.
109 #FIXME Implement an opsi method which returns infos for only one opsi client, not all.
110 */
111 foreach($list as $entry){
112 if(preg_match("/^".preg_quote($this->hostId, '/')."$/i",$entry['NAME'][0]['VALUE'])){
113 $this->initially_was_account = TRUE;
114 $this->is_account = TRUE;
115 foreach(array(
116 "is_installed" => "LASTSEEN",
117 "description" => "DESCRIPTION",
118 "mac" => "MAC",
119 "note" => "NOTES") as $des => $src){
120 $des2 = "initial_".$des;
121 $this->$des2 = $this->$des = $entry[$src][0]['VALUE'];
122 }
123 break;
124 }
125 }
126 }
128 // Get package info
129 $list = array();
130 if(!empty($this->hostId)){
131 $list = $this->opsi->get_full_product_host_information($this->hostId);
132 }
133 $err |= $this->opsi->is_error();
135 /* Read informations about available netboot products.
136 If not already done, before.
137 */
138 if(!$err){
139 foreach($list as $key => $entry){
141 $tmp = array('DESC'=>$entry['data']['DESCRIPTION'],'NAME'=>$key);
142 if($entry['configurable']){
143 $tmp['CFG'] = $entry['data']['PROPERTIES'];
144 }
146 if($entry['data']['TYPE'] == "localboot"){
147 if(!$entry['installed']){
148 $this->a_availableLocalProducts[$key] = $tmp;
149 }else{
150 $this->a_selectedLocalProducts[$key] = $tmp;
151 }
152 }else{
153 $this->a_availableNetbootProducts[$key] = $tmp;
154 if($entry['installed']){
155 $this->s_selectedNetbootProduct= $key;
156 }
157 }
158 }
159 }
161 /* Check if everything went fine else reset everything and display a retry button
162 */
163 if($err){
164 $this->init_failed = TRUE;
166 }else{
168 /* Remember initial settings */
169 $this->a_initial_selectedLocalProducts = $this->a_selectedLocalProducts;
170 $this->s_initial_selectedNetbootProduct = $this->s_selectedNetbootProduct;
171 $this->a_initial_availableNetbootProducts = $this->a_availableNetbootProducts;
173 /* Ensure that a valid netboot is selected product is.
174 */
175 if(empty($this->s_selectedNetbootProduct)){
176 $this->s_selectedNetbootProduct = key($this->a_availableNetbootProducts);
177 }
179 // Now fake a valid ldap entry ... this is necessary to avoid
180 // modifications in the dns/dhcp classes
182 // First fake cn
183 $this->attrs['hostId'][0] = $this->hostId;
184 $this->attrs['cn'][0] = $this->hostId;
186 // Second detect DNS settings.
187 $ldap = $this->config->get_ldap_link();
188 $ldap->cd($this->config->current['BASE']);
189 $strippedHostId = preg_replace("/\..*$/","",$this->hostId);
190 $ldap->search("(&(objectClass=dNSZone)(|(relativeDomainName=".$this->hostId.")(relativeDomainName=".$strippedHostId."))(aRecord=*))",array("aRecord"));
191 if($ldap->count()){
192 $attrs = $ldap->fetch();
193 $this->attrs['ipHostNumber']['count'] = 0;
194 $this->attrs['ipHostNumber'][0] = $attrs['aRecord'][0];
195 }
197 $this->attrs['macAddress']['count'] = 1;
198 $this->attrs['macAddress'][0] = &$this->mac;
200 // Initialize DHCP and DNS
201 $this->netConfigDNS = new termDNS($this->config,$this,$this->objectclasses, FALSE, "hostId");
202 $this->netConfigDNS->set_acl_category("opsi");
203 $this->netConfigDNS->set_acl_base($this->config->current['BASE']);
204 $this->netConfigDNS->IPisMust = FALSE;
205 $this->netConfigDNS->MACisMust = FALSE;
206 }
207 }
210 /*! \brief Check given data.
211 @return Array Returns an array with all issues.
212 */
213 public function check()
214 {
216 // In case of initialization problem, we do not save anything.
217 // We can skip checks here, the date isn't usable.
218 if($this->init_failed){
219 return;
220 };
222 $messages = plugin::check();
223 $messages= array_merge($messages, $this->netConfigDNS->check());
225 if(empty($this->hostId)){
226 $messages[] = msgPool::required(_("Name"));
227 }elseif(!preg_match("/\./",$this->hostId)){
229 /* The hostId must contain a domain part
230 */
231 $messages[] = msgPool::invalid(_("Name"),$this->hostId,"",
232 _("The field 'Name' must contain a domain part!"));
233 }elseif(preg_match("/[^a-z0-9\.\-_]/",$this->hostId)){
234 $messages[] = msgPool::invalid(_("Name"),$this->hostId,"/[a-z0-9\.\-_]/");
235 }
237 /* Ensure that the mac address is valid
238 */
239 if(!tests::is_mac($this->mac) || empty($this->mac)){
240 $messages[] = msgPool::invalid(_("MAC address"),$this->mac,"","00:0C:7F:31:33:F1");
241 }
242 return($messages);
243 }
246 /*! \brief Create the html ui of this plugin
247 @return String HTML content.
248 */
249 public function execute()
250 {
251 $display ="";
253 /* The pluign initialization failed due to communication problems with the gosa daemon.
254 A retry button will be displayed here.
255 */
256 if($this->init_failed){
257 $smarty = get_smarty();
258 $smarty->assign("standalone ", $this->standalone );
259 $smarty->assign("init_failed",TRUE);
260 $smarty->assign("message",$this->opsi->get_error());
261 return($smarty->fetch(get_template_path("generic.tpl",TRUE,dirname(__FILE__))));
262 }
265 /* If we are not a stand alone opsi client, we must be a samba client
266 which has the opsi tab enabled.
267 Check if the opsi is added or removed and display state buttons.
268 */
269 if(!$this->standalone ){
271 /* Do we need to flip is_account state? */
272 if(isset($_POST['modify_state'])){
273 if($this->is_account && $this->acl_is_removeable()){
274 $this->is_account= FALSE;
275 }elseif(!$this->is_account && $this->acl_is_createable()){
276 $this->is_account= TRUE;
277 }
278 }
279 if($this->is_account){
280 $display = $this->show_disable_header(msgPool::removeFeaturesButton(_("OPSI")),
281 msgPool::featuresEnabled(_("OPSI")));
282 }else{
283 $display = $this->show_enable_header(msgPool::addFeaturesButton(_("OPSI")),
284 msgPool::featuresDisabled(_("OPSI")));
285 return($display);
286 }
287 }
289 /* Check if we have a sub dialog opened
290 */
291 if(is_object($this->dialog)){
292 $this->dialog->save_object();
293 return($this->dialog->execute());
294 }
296 /* Create HTML output of this plugin
297 */
298 $smarty = get_smarty();
299 $smarty->assign("standalone", $this->standalone );
300 foreach($this->attributes as $attr){
301 $smarty->assign($attr,$this->$attr);
302 }
304 /* Assign ACLs */
305 $tmp = $this->plInfo();
306 foreach($tmp['plProvidedAcls'] as $name => $translated){
307 $smarty->assign($name."ACL",$this->getacl($name));
308 }
310 $smarty->assign("is_installed", $this->is_installed);
311 $smarty->assign("init_failed",FALSE);
312 $divSLP = new divSelectBox();
313 $divALP = new divSelectBox();
315 /* Create list of available local products
316 */
317 foreach($this->a_availableLocalProducts as $name => $data){
318 if(isset($this->a_selectedLocalProducts[$name])) continue;
320 $add_tab = array("string" => "<input type='image' src='images/back.png' name='add_lp_".$name."'>");
321 $name_tab = array("string" => $name);
322 $desc_tab = array("string" => "<div style='height: 14px;overflow:hidden;'>".$data['DESC']."</div>",
323 "attach" => "title='".$data['DESC']."' style='border-right:0px;'");
325 if($this->acl_is_writeable("localProduct")){
326 $divALP->AddEntry(array($add_tab,$name_tab,$desc_tab));
327 }else{
328 $divALP->AddEntry(array($name_tab,$desc_tab));
329 }
330 }
332 /* Create list of selected local products
333 */
334 ksort($this->a_selectedLocalProducts);
335 if($this->acl_is_readable("localProduct")){
336 foreach($this->a_selectedLocalProducts as $name => $data){
338 $name_tab = array("string" => $name);
339 $desc_tab = array(
340 "string" => "<div style='height: 14px;overflow:hidden;'>".$data['DESC']."</div>",
341 "attach" => "title='".$data['DESC']."'");
343 /* Only display edit button, if there is something to edit
344 */
345 $edit = "<img src='images/empty.png' alt=' '>";
346 if(count($data['CFG'])){
347 $edit = "<input type='image' src='images/lists/edit.png' name='edit_lp_".$name."'>";
348 }
349 $del = "<input type='image' src='images/lists/trash.png' name='del_lp_".$name."'>";
351 $opt_tab = array("string" => $edit.$del,
352 "attach" => "style='border-right:0px; width: 40px; text-align:right;'");
354 if($this->acl_is_writeable("localProduct")){
355 $divSLP->AddEntry(array($name_tab,$desc_tab,$opt_tab));
356 }else{
357 $divSLP->AddEntry(array($name_tab,$desc_tab));
358 }
359 }
360 }
362 /* Check if netboot product is configurable
363 */
364 $cfg_able =FALSE;
365 if(isset($this->a_availableNetbootProducts[$this->s_selectedNetbootProduct]['CFG'])){
366 $cfg_able = count($this->a_availableNetbootProducts[$this->s_selectedNetbootProduct]['CFG']);
367 $cfg_able &= $this->acl_is_readable("netbootProduct");
368 }
370 // Get net config template
371 $str = $this->netConfigDNS->execute();
372 if(is_object($this->netConfigDNS->dialog)){
373 return($str);
374 }
375 $smarty->assign("netconfig", $str);
377 $smarty->assign("netboot_configurable",$cfg_able);
378 $smarty->assign("hostId", $this->hostId);
379 $smarty->assign("divSLP", $divSLP->DrawList());
380 $smarty->assign("divALP", $divALP->DrawList());
381 $smarty->assign("SNP", $this->s_selectedNetbootProduct);
382 $smarty->assign("ANP", $this->a_availableNetbootProducts);
383 return($display.$smarty->fetch(get_template_path("generic.tpl",TRUE,dirname(__FILE__))));
384 }
387 /*! \brief Save modifications using the gosa support daemon.
388 */
389 public function save()
390 {
391 if($this->init_failed){
392 return;
393 }
395 /* Check if we have to create a new opsi client
396 or just have to save client modifications.
397 */
398 if(!$this->initially_was_account && $this->is_account){
399 $res = $this->opsi->add_client($this->hostId,$this->mac,$this->note,$this->description);
400 if($this->opsi->is_error()){
401 msg_dialog::display(_("Error"),msgPool::siError($this->opsi->get_error()),ERROR_DIALOG);
402 return;
403 }
404 }else{
406 /* Update client modifcations.
407 -Only if necessary
408 */
409 if($this->note != $this->initial_note ||
410 $this->description != $this->initial_description ||
411 $this->mac != $this->initial_mac){
412 $this->opsi->modify_client($this->hostId,$this->mac,$this->note,$this->description);
413 if($this->opsi->is_error()){
414 msg_dialog::display(_("Error"),msgPool::siError($this->opsi->get_error()),ERROR_DIALOG);
415 return;
416 }
417 }
418 }
421 /***********
422 Detect local netboot product changes
423 - Check which products were removed.
424 - Check which products were added.
425 ***********/
428 /* Detect which products were removed an which added.
429 */
430 $del = array_diff_assoc($this->a_initial_selectedLocalProducts,$this->a_selectedLocalProducts);
431 $add = array_diff_assoc($this->a_selectedLocalProducts,$this->a_initial_selectedLocalProducts);
433 /* Remove products from client
434 */
435 foreach($del as $name => $data){
436 $this->opsi->del_product_from_client($name,$this->hostId);
437 if($this->opsi->is_error()){
438 msg_dialog::display(_("Error"),msgPool::siError($this->opsi->get_error()),ERROR_DIALOG);
439 return;
440 }
441 }
443 /* Add products to client
444 And set the product properties.
445 */
446 foreach($add as $name => $data){
447 $this->opsi->add_product_to_client($name,$this->hostId);
448 if($this->opsi->is_error()){
449 msg_dialog::display(_("Error"),msgPool::siError($this->opsi->get_error()),ERROR_DIALOG);
450 return;
451 }
452 if(!empty($data['CFG'])){
453 $this->opsi->set_product_properties($name,$data['CFG'],$this->hostId);
454 if($this->opsi->is_error()){
455 msg_dialog::display(_("Error"),msgPool::siError($this->opsi->get_error()),ERROR_DIALOG);
456 return;
457 }
458 }
459 }
461 /* Save local product properties
462 */
463 foreach($this->a_selectedLocalProducts as $name => $data){
464 if(isset($del[$name]) || isset($add[$name])) continue;
466 /* Update product properties if there are changes
467 */
468 $diffs = $this->get_config_changes($data['CFG'],$this->a_initial_selectedLocalProducts[$name]['CFG']);
469 if(count($diffs)){
470 $this->opsi->set_product_properties($name,$diffs,$this->hostId);
471 if($this->opsi->is_error()){
472 msg_dialog::display(_("Error"),msgPool::siError($this->opsi->get_error()),ERROR_DIALOG);
473 return;
474 }
475 }
476 }
478 /*********
479 Detect Netboot product changes
480 - Check if another netboot product was selected.
481 - Check if the product properties were changes.
482 *********/
484 /* Update used netboot product.
485 */
486 if($this->s_selectedNetbootProduct != $this->s_initial_selectedNetbootProduct){
487 if(!empty($this->s_initial_selectedNetbootProduct)){
488 $this->opsi->del_product_from_client($this->s_initial_selectedNetbootProduct,$this->hostId);
489 if($this->opsi->is_error()){
490 msg_dialog::display(_("Error"),msgPool::siError($this->opsi->get_error()),ERROR_DIALOG);
491 return;
492 }
493 }
494 $this->opsi->add_product_to_client($this->s_selectedNetbootProduct,$this->hostId);
495 if($this->opsi->is_error()){
496 msg_dialog::display(_("Error"),msgPool::siError($this->opsi->get_error()),ERROR_DIALOG);
497 return;
498 }
499 }
501 /* Check if we have to update the netboot product properties
502 This is the case, if this product is newly selected.
503 Or if there was at least one configuration attribute modified.
504 */
505 $cfg_1 = $cfg_2 = array();
506 if(isset($this->a_availableNetbootProducts[$this->s_selectedNetbootProduct]['CFG'])){
507 $cfg_1 = $this->a_availableNetbootProducts[$this->s_selectedNetbootProduct]['CFG'];
508 }
509 if(isset($this->a_initial_availableNetbootProducts[$this->s_selectedNetbootProduct]['CFG'])){
510 $cfg_2 = $this->a_initial_availableNetbootProducts[$this->s_selectedNetbootProduct]['CFG'];
511 }
512 $diffs = $this->get_config_changes($cfg_1,$cfg_2);
513 $to_update = array();
514 if( !$this->initially_was_account ||
515 $this->s_selectedNetbootProduct != $this->s_initial_selectedNetbootProduct){
516 $to_update = $this->a_availableNetbootProducts[$this->s_selectedNetbootProduct]['CFG'];
517 }elseif(count($diffs)){
518 $to_update = $diffs;
519 }
521 if(count($to_update)){
522 $name = $this->s_selectedNetbootProduct;
523 $this->opsi->set_product_properties($name,$to_update,$this->hostId);
524 if($this->opsi->is_error()){
525 msg_dialog::display(_("Error"),msgPool::siError($this->opsi->get_error()),ERROR_DIALOG);
526 return;
527 }
528 }
530 $this->netConfigDNS->cn = $this->hostId;
531 $this->netConfigDNS->save();
532 }
535 public function get_config_changes($c1,$c2)
536 {
537 /* Get key which are not present in both entries
538 */
539 $res = array();
540 foreach($c2 as $name => $value){
541 if(!isset($c1[$name]) || $c1[$name]['CURRENT'] != $c2[$name]['CURRENT']){
542 $res[$name] = $c2[$name];
543 }
544 }
545 foreach($c1 as $name => $value){
546 if(!isset($c2[$name]) || $c2[$name]['CURRENT'] != $c1[$name]['CURRENT']){
547 $res[$name] = $c1[$name];
548 }
549 }
550 return($res);
551 }
554 /*! \brief Removes the opsi client
555 */
556 public function remove_from_parent()
557 {
558 if($this->init_failed){
559 return;
560 }
561 $this->netConfigDNS->remove_from_parent();
563 $this->opsi->del_client($this->hostId);
564 if($this->opsi->is_error()){
565 msg_dialog::display(_("Error"),msgPool::siError($this->opsi->get_error()),ERROR_DIALOG);
566 return;
567 }
568 }
571 /*! \brief Save html posts
572 */
573 public function save_object()
574 {
575 /* Init failed; reinit is triggered here.
576 */
577 if(isset($_POST['reinit']) && $this->init_failed){
578 $this->init();
579 }
581 /* Property are currently edited, close the dialog.
582 */
583 if(isset($_POST['cancel_properties']) && is_object($this->dialog)){
584 $this->dialog = NULL;
585 }
587 /* Save product property changes
588 */
589 if(isset($_POST['save_properties']) && ($this->dialog instanceof opsiProperties)){
590 $this->dialog->save_object();
591 $pro = $this->dialog->get_product();
592 $CFG = $this->dialog->get_cfg();
593 if(isset($this->a_selectedLocalProducts[$pro])){
594 if($this->acl_is_writeable("localProduct")){
595 $this->a_selectedLocalProducts[$pro]['CFG'] = $CFG;
596 }
597 $this->dialog = NULL;
598 }elseif($this->s_selectedNetbootProduct == $pro){
599 if($this->acl_is_writeable("netbootProduct")){
600 $this->a_availableNetbootProducts[$pro]['CFG'] = $CFG;
601 }
602 $this->dialog = NULL;
603 }else{
604 trigger_error("Fatal, unknown product was configured.");
605 }
606 }
608 /* Save html post
609 */
610 if(isset($_POST['opsiGeneric_posted'])){
612 plugin::save_object();
613 $this->netConfigDNS->save_object();
614 $this->mac = $this->netConfigDNS->macAddress;
616 /* Get hostId
617 */
618 if(isset($_POST['hostId']) && $this->standalone && $this->acl_is_writeable("hostId")){
619 $this->hostId = get_post('hostId');
620 }
622 /* Send actions like 'install' or 'wake' to the si server
623 */
624 if($this->acl_is_writeable("triggerAction") &&
625 isset($_POST['opsi_action']) &&
626 isset($_POST['opsi_trigger_action']) &&
627 $this->standalone ){
628 $action = $_POST['opsi_action'];
629 if($action == "install"){
630 $this->install_client();
631 }
632 if($action == "wake"){
633 $this->wake_client();
634 }
635 }
637 /* Get selected netboot product.
638 */
639 if(isset($_POST['opsi_netboot_product']) && $this->acl_is_writeable("netbootProduct")){
640 $SNP = trim($_POST['opsi_netboot_product']);
641 if(isset($this->a_availableNetbootProducts[$SNP])){
642 if(!isset($this->a_availableNetbootProducts[$SNP]['CFG'])){
643 $CFG = $this->opsi->get_product_properties($SNP);
644 $this->a_availableNetbootProducts[$SNP]['CFG'] = $CFG;
645 if($this->opsi->is_error()){
646 $this->init_failed = TRUE;
647 return;
648 }
649 }
650 $this->s_selectedNetbootProduct = $SNP;
651 }
652 }
654 /* Add/remove/edit local products
655 */
656 foreach($_POST as $name => $value){
658 /* Check if netboot product configuration is requested
659 */
660 if(preg_match("/^configure_netboot/",$name) && $this->acl_is_readable("netbootProduct")){
661 $pro = $this->s_selectedNetbootProduct;
662 $cfg = $this->a_availableNetbootProducts[$pro]['CFG'];
663 $this->dialog = new opsiProperties($this->config,$pro,$cfg,$this->hostId);
664 break;
665 }
667 /* Add product
668 */
669 if(preg_match("/^add_lp_/",$name) && $this->acl_is_writeable("localProduct")){
670 $product = preg_replace("/^add_lp_(.*)_.$/","\\1",$name);
671 if(isset($this->a_availableLocalProducts[$product]) && !isset($this->a_selectedLocalProducts[$product])){
672 $this->a_selectedLocalProducts[$product] = $this->a_availableLocalProducts[$product];
673 $CFG = $this->opsi->get_product_properties($product);
674 if($this->opsi->is_error()){
675 $this->init_failed = TRUE;
676 return;
677 }
678 $this->a_selectedLocalProducts[$product]['CFG'] = $CFG;
679 }
680 break;
681 }
683 /* Delete product
684 */
685 if(preg_match("/^del_lp_/",$name) && $this->acl_is_writeable("localProduct")){
686 $product = preg_replace("/^del_lp_(.*)_.$/","\\1",$name);
687 if(isset($this->a_selectedLocalProducts[$product])){
688 unset($this->a_selectedLocalProducts[$product]);
689 }
690 break;
691 }
693 /* Edit a product
694 */
695 if(preg_match("/^edit_lp_/",$name) && $this->acl_is_readable("localProduct")){
696 $product = preg_replace("/^edit_lp_(.*)_.$/","\\1",$name);
697 $this->dialog = new opsiProperties($this->config,
698 $product,$this->a_selectedLocalProducts[$product]['CFG'],$this->hostId);
699 break;
700 }
701 }
702 }
703 }
706 /* Triggers client installation
707 */
708 function install_client()
709 {
710 $this->opsi->send_action("install",$this->hostId,$this->mac);
711 if($this->opsi->is_error()){
712 msg_dialog::display(_("Error"),msgPool::siError($this->opsi->get_error()),ERROR_DIALOG);
713 }
714 }
717 /* Wake up client
718 */
719 function wake_client()
720 {
721 /* Check if we are able to communicate with the GOsa supprot daemon
722 */
723 if(class_available("gosaSupportDaemon")){
724 $o = new gosaSupportDaemon();
725 if($o->connect() && class_available("DaemonEvent_wakeup")){
726 $evt = new DaemonEvent_wakeup($this->config);
727 $evt->add_targets(array($this->mac));
728 $o->append($evt);
729 }
730 }
731 }
734 /* Return plugin informations for acl handling */
735 static function plInfo()
736 {
737 return (array(
738 "plShortName" => _("Generic"),
739 "plDescription" => _("OPSI generic"),
740 "plSelfModify" => FALSE,
741 "plDepends" => array(),
742 "plPriority" => 1,
743 "plSection" => array("administration"),
744 "plCategory" => array("opsi" => array("description" => _("Opsi"),
745 "objectClass" => "dummy_class_opsi")),
747 "plProvidedAcls"=> array(
748 "hostId" => _("Name"),
749 "mac" => _("MAC address"),
750 "description" => _("Description"),
751 "note" => _("Note"),
752 "netbootProduct" => _("Netboot product"),
753 "localProduct" => _("Local product"),
754 "triggerAction" => _("Action"))
755 ));
756 }
757 }
760 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
761 ?>