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();
83 // Now fake a valid ldap entry ... this is necessary to avoid
84 // modifications in the dns/dhcp classes
86 // First fake cn
87 $this->attrs['hostId'][0] = $this->hostId;
88 $this->attrs['cn'][0] = $this->hostId;
90 // Second detect DNS settings.
91 $ldap = $this->config->get_ldap_link();
92 $ldap->cd($this->config->current['BASE']);
93 $strippedHostId = preg_replace("/\..*$/","",$this->hostId);
94 $ldap->search("(&(objectClass=dNSZone)(|(relativeDomainName=".$this->hostId.")(relativeDomainName=".$strippedHostId."))(aRecord=*))",array("aRecord"));
95 if($ldap->count()){
96 $attrs = $ldap->fetch();
97 $this->attrs['ipHostNumber']['count'] = 0;
98 $this->attrs['ipHostNumber'][0] = $attrs['aRecord'][0];
99 }
101 // Initialize DHCP and DNS
102 $this->netConfigDNS = new termDNS($this->config,$this,$this->objectclasses, FALSE, "hostId");
103 $this->netConfigDNS->set_acl_category("opsi");
104 $this->netConfigDNS->set_acl_base($this->config->current['BASE']);
105 $this->netConfigDNS->IPisMust = FALSE;
106 $this->netConfigDNS->MACisMust = FALSE;
107 }
110 /*! \brief Try to load opsi client informations from the
111 gosa support daemon.
112 */
113 private function init()
114 {
115 $err = FALSE;
116 $this->init_failed = FALSE;
117 $this->initially_was_account = FALSE;
119 /* We are a standalone plugin.
120 */
121 if($this->standalone ) {
122 $this->is_account = TRUE;
123 }
125 /* Try to load client infos from the gosa support daemon
126 */
127 if(!empty($this->hostId)){
129 $list = $this->opsi->list_clients($this->hostId);
130 $err |= $this->opsi->is_error();
132 /* Walk through all returned opsi clients and try to detect
133 one that matches our hostId.
134 #FIXME Implement an opsi method which returns infos for only one opsi client, not all.
135 */
136 foreach($list as $entry){
137 if(preg_match("/^".preg_quote($this->hostId, '/')."$/i",$entry['NAME'][0]['VALUE'])){
138 $this->initially_was_account = TRUE;
139 $this->is_account = TRUE;
140 foreach(array(
141 "is_installed" => "LASTSEEN",
142 "description" => "DESCRIPTION",
143 "mac" => "MAC",
144 "note" => "NOTES") as $des => $src){
145 $des2 = "initial_".$des;
146 $this->$des2 = $this->$des = $entry[$src][0]['VALUE'];
147 }
148 break;
149 }
150 }
151 }
153 /* Read informations about available netboot products.
154 If not already done, before.
155 */
156 if(!$err && !count($this->a_availableNetbootProducts)){
157 $this->a_availableNetbootProducts = $this->opsi->get_netboot_products();
158 ksort($this->a_availableNetbootProducts);
159 $err |= $this->opsi->is_error();
160 }
162 /* Read informations about available netboot products.
163 If not already done, before.
164 */
165 if(!$err && !count($this->a_availableLocalProducts)) {
166 $this->a_availableLocalProducts = $this->opsi->get_local_products();
167 ksort($this->a_availableLocalProducts);
168 $err |= $this->opsi->is_error();
169 }
171 /* Get products selected by this host.
172 */
173 if(!$err && !empty($this->hostId)) {
174 $tmp = array_keys($this->opsi->get_netboot_products($this->hostId));
175 $err |= $this->opsi->is_error();
176 if(count($tmp) && !$err && !isset($this->a_availableNetbootProducts[$this->s_selectedNetbootProduct]['CFG'])){
177 $this->s_selectedNetbootProduct = $tmp[0];
179 /* Read configuration for "Netboot Products" */
180 if(isset($this->a_availableNetbootProducts[$this->s_selectedNetbootProduct])){
181 $CFG = $this->opsi->get_product_properties($this->s_selectedNetbootProduct,$this->hostId);
182 $this->a_availableNetbootProducts[$this->s_selectedNetbootProduct]['CFG'] = $CFG;
183 }
184 }
185 $err |= $this->opsi->is_error();
186 }
188 /* Get all selected local products
189 */
190 if(!$err && !empty($this->hostId) && !count($this->a_selectedLocalProducts)) {
191 $tmp = $this->opsi->get_local_products($this->hostId);
192 $err |= $this->opsi->is_error();
193 $this->a_selectedLocalProducts = $tmp;
194 }
196 /* Load product configuration for all already selected products.
197 */
198 if(!$err && !empty($this->hostId)) {
199 foreach($this->a_selectedLocalProducts as $name => $data){
200 if(!$err && !isset($this->a_selectedLocalProducts[$name]['CFG'])){
201 $CFG = $this->opsi->get_product_properties($name,$this->hostId);
202 $err |= $this->opsi->is_error();
203 $this->a_selectedLocalProducts[$name]['CFG'] = $CFG;
204 }
205 }
206 }
208 /* Check if everything went fine else reset everything and display a retry button
209 */
210 if($err){
211 $this->init_failed = TRUE;
213 }else{
215 /* Remember initial settings */
216 $this->a_initial_selectedLocalProducts = $this->a_selectedLocalProducts;
217 $this->s_initial_selectedNetbootProduct = $this->s_selectedNetbootProduct;
218 $this->a_initial_availableNetbootProducts = $this->a_availableNetbootProducts;
220 /* Ensure that a valid netboot is selected product is.
221 */
222 if(empty($this->s_selectedNetbootProduct)){
223 $this->s_selectedNetbootProduct = key($this->a_availableNetbootProducts);
224 }
225 }
226 }
229 /*! \brief Check given data.
230 @return Array Returns an array with all issues.
231 */
232 public function check()
233 {
234 $messages = plugin::check();
235 $messages= array_merge($messages, $this->netConfigDNS->check());
237 if(empty($this->hostId)){
238 $messages[] = msgPool::required(_("Name"));
239 }elseif(!preg_match("/\./",$this->hostId)){
241 /* The hostId must contain a domain part
242 */
243 $messages[] = msgPool::invalid(_("Name"),$this->hostId,"",
244 _("The field 'Name' must contain a domain part!"));
245 }elseif(preg_match("/[^a-z0-9\.\-_]/",$this->hostId)){
246 $messages[] = msgPool::invalid(_("Name"),$this->hostId,"/[a-z0-9\.\-_]/");
247 }
249 /* Ensure that the mac address is valid
250 */
251 if(!tests::is_mac($this->mac) || empty($this->mac)){
252 $messages[] = msgPool::invalid(_("MAC address"),$this->mac,"","00:0C:7F:31:33:F1");
253 }
254 return($messages);
255 }
258 /*! \brief Create the html ui of this plugin
259 @return String HTML content.
260 */
261 public function execute()
262 {
263 $display ="";
265 /* The pluign initialization failed due to communication problems with the gosa daemon.
266 A retry button will be displayed here.
267 */
268 if($this->init_failed){
269 $smarty = get_smarty();
270 $smarty->assign("standalone ", $this->standalone );
271 $smarty->assign("init_failed",TRUE);
272 $smarty->assign("message",$this->opsi->get_error());
273 return($smarty->fetch(get_template_path("generic.tpl",TRUE,dirname(__FILE__))));
274 }
277 /* If we are not a stand alone opsi client, we must be a samba client
278 which has the opsi tab enabled.
279 Check if the opsi is added or removed and display state buttons.
280 */
281 if(!$this->standalone ){
283 /* Do we need to flip is_account state? */
284 if(isset($_POST['modify_state'])){
285 if($this->is_account && $this->acl_is_removeable()){
286 $this->is_account= FALSE;
287 }elseif(!$this->is_account && $this->acl_is_createable()){
288 $this->is_account= TRUE;
289 }
290 }
291 if($this->is_account){
292 $display = $this->show_disable_header(msgPool::removeFeaturesButton(_("OPSI")),
293 msgPool::featuresEnabled(_("OPSI")));
294 }else{
295 $display = $this->show_enable_header(msgPool::addFeaturesButton(_("OPSI")),
296 msgPool::featuresDisabled(_("OPSI")));
297 return($display);
298 }
299 }
301 /* Check if we have a sub dialog opened
302 */
303 if(is_object($this->dialog)){
304 $this->dialog->save_object();
305 return($this->dialog->execute());
306 }
308 /* Create HTML output of this plugin
309 */
310 $smarty = get_smarty();
311 $smarty->assign("standalone", $this->standalone );
312 foreach($this->attributes as $attr){
313 $smarty->assign($attr,$this->$attr);
314 }
316 /* Assign ACLs */
317 $tmp = $this->plInfo();
318 foreach($tmp['plProvidedAcls'] as $name => $translated){
319 $smarty->assign($name."ACL",$this->getacl($name));
320 }
322 $smarty->assign("is_installed", $this->is_installed);
323 $smarty->assign("init_failed",FALSE);
324 $divSLP = new divSelectBox();
325 $divALP = new divSelectBox();
327 /* Create list of available local products
328 */
329 foreach($this->a_availableLocalProducts as $name => $data){
330 if(isset($this->a_selectedLocalProducts[$name])) continue;
332 $add_tab = array("string" => "<input type='image' src='images/back.png' name='add_lp_".$name."'>");
333 $name_tab = array("string" => $name);
334 $desc_tab = array("string" => "<div style='height: 14px;overflow:hidden;'>".$data['DESC']."</div>",
335 "attach" => "title='".$data['DESC']."' style='border-right:0px;'");
337 if($this->acl_is_writeable("localProduct")){
338 $divALP->AddEntry(array($add_tab,$name_tab,$desc_tab));
339 }else{
340 $divALP->AddEntry(array($name_tab,$desc_tab));
341 }
342 }
344 /* Create list of selected local products
345 */
346 ksort($this->a_selectedLocalProducts);
347 if($this->acl_is_readable("localProduct")){
348 foreach($this->a_selectedLocalProducts as $name => $data){
350 $name_tab = array("string" => $name);
351 $desc_tab = array(
352 "string" => "<div style='height: 14px;overflow:hidden;'>".$data['DESC']."</div>",
353 "attach" => "title='".$data['DESC']."'");
355 /* Only display edit button, if there is something to edit
356 */
357 $edit = "<img src='images/empty.png' alt=' '>";
358 if(count($data['CFG'])){
359 $edit = "<input type='image' src='images/lists/edit.png' name='edit_lp_".$name."'>";
360 }
361 $del = "<input type='image' src='images/lists/trash.png' name='del_lp_".$name."'>";
363 $opt_tab = array("string" => $edit.$del,
364 "attach" => "style='border-right:0px; width: 40px; text-align:right;'");
366 if($this->acl_is_writeable("localProduct")){
367 $divSLP->AddEntry(array($name_tab,$desc_tab,$opt_tab));
368 }else{
369 $divSLP->AddEntry(array($name_tab,$desc_tab));
370 }
371 }
372 }
374 /* Check if netboot product is configurable
375 */
376 $cfg_able =FALSE;
377 if(isset($this->a_availableNetbootProducts[$this->s_selectedNetbootProduct]['CFG'])){
378 $cfg_able = count($this->a_availableNetbootProducts[$this->s_selectedNetbootProduct]['CFG']);
379 $cfg_able &= $this->acl_is_readable("netbootProduct");
380 }
382 // Get net config template
383 $str = $this->netConfigDNS->execute();
384 if(is_object($this->netConfigDNS->dialog)){
385 return($str);
386 }
387 $smarty->assign("netconfig", $str);
389 $smarty->assign("netboot_configurable",$cfg_able);
390 $smarty->assign("hostId", $this->hostId);
391 $smarty->assign("divSLP", $divSLP->DrawList());
392 $smarty->assign("divALP", $divALP->DrawList());
393 $smarty->assign("SNP", $this->s_selectedNetbootProduct);
394 $smarty->assign("ANP", $this->a_availableNetbootProducts);
395 return($display.$smarty->fetch(get_template_path("generic.tpl",TRUE,dirname(__FILE__))));
396 }
399 /*! \brief Save modifications using the gosa support daemon.
400 */
401 public function save()
402 {
404 /* Check if we have to create a new opsi client
405 or just have to save client modifications.
406 */
407 if(!$this->initially_was_account && $this->is_account){
408 $res = $this->opsi->add_client($this->hostId,$this->mac,$this->note,$this->description);
409 if($this->opsi->is_error()){
410 msg_dialog::display(_("Error"),msgPool::siError($this->opsi->get_error()),ERROR_DIALOG);
411 return;
412 }
413 }else{
415 /* Update client modifcations.
416 -Only if necessary
417 */
418 if($this->note != $this->initial_note ||
419 $this->description != $this->initial_description ||
420 $this->mac != $this->initial_mac){
421 $this->opsi->modify_client($this->hostId,$this->mac,$this->note,$this->description);
422 if($this->opsi->is_error()){
423 msg_dialog::display(_("Error"),msgPool::siError($this->opsi->get_error()),ERROR_DIALOG);
424 return;
425 }
426 }
427 }
430 /***********
431 Detect local netboot product changes
432 - Check which products were removed.
433 - Check which products were added.
434 ***********/
437 /* Detect which products were removed an which added.
438 */
439 $del = array_diff_assoc($this->a_initial_selectedLocalProducts,$this->a_selectedLocalProducts);
440 $add = array_diff_assoc($this->a_selectedLocalProducts,$this->a_initial_selectedLocalProducts);
442 /* Remove products from client
443 */
444 foreach($del as $name => $data){
445 $this->opsi->del_product_from_client($name,$this->hostId);
446 if($this->opsi->is_error()){
447 msg_dialog::display(_("Error"),msgPool::siError($this->opsi->get_error()),ERROR_DIALOG);
448 return;
449 }
450 }
452 /* Add products to client
453 And set the product properties.
454 */
455 foreach($add as $name => $data){
456 $this->opsi->add_product_to_client($name,$this->hostId);
457 if($this->opsi->is_error()){
458 msg_dialog::display(_("Error"),msgPool::siError($this->opsi->get_error()),ERROR_DIALOG);
459 return;
460 }
461 if(!empty($data['CFG'])){
462 $this->opsi->set_product_properties($name,$data['CFG'],$this->hostId);
463 if($this->opsi->is_error()){
464 msg_dialog::display(_("Error"),msgPool::siError($this->opsi->get_error()),ERROR_DIALOG);
465 return;
466 }
467 }
468 }
470 /* Save local product properties
471 */
472 foreach($this->a_selectedLocalProducts as $name => $data){
473 if(isset($del[$name]) || isset($add[$name])) continue;
475 /* Update product properties if there are changes
476 */
477 $diffs = $this->get_config_changes($data['CFG'],$this->a_initial_selectedLocalProducts[$name]['CFG']);
478 if(count($diffs)){
479 $this->opsi->set_product_properties($name,$diffs,$this->hostId);
480 if($this->opsi->is_error()){
481 msg_dialog::display(_("Error"),msgPool::siError($this->opsi->get_error()),ERROR_DIALOG);
482 return;
483 }
484 }
485 }
487 /*********
488 Detect Netboot product changes
489 - Check if another netboot product was selected.
490 - Check if the product properties were changes.
491 *********/
493 /* Update used netboot product.
494 */
495 if($this->s_selectedNetbootProduct != $this->s_initial_selectedNetbootProduct){
496 if(!empty($this->s_initial_selectedNetbootProduct)){
497 $this->opsi->del_product_from_client($this->s_initial_selectedNetbootProduct,$this->hostId);
498 if($this->opsi->is_error()){
499 msg_dialog::display(_("Error"),msgPool::siError($this->opsi->get_error()),ERROR_DIALOG);
500 return;
501 }
502 }
503 $this->opsi->add_product_to_client($this->s_selectedNetbootProduct,$this->hostId);
504 if($this->opsi->is_error()){
505 msg_dialog::display(_("Error"),msgPool::siError($this->opsi->get_error()),ERROR_DIALOG);
506 return;
507 }
508 }
510 /* Check if we have to update the netboot product properties
511 This is the case, if this product is newly selected.
512 Or if there was at least one configuration attribute modified.
513 */
514 $cfg_1 = $cfg_2 = array();
515 if(isset($this->a_availableNetbootProducts[$this->s_selectedNetbootProduct]['CFG'])){
516 $cfg_1 = $this->a_availableNetbootProducts[$this->s_selectedNetbootProduct]['CFG'];
517 }
518 if(isset($this->a_initial_availableNetbootProducts[$this->s_selectedNetbootProduct]['CFG'])){
519 $cfg_2 = $this->a_initial_availableNetbootProducts[$this->s_selectedNetbootProduct]['CFG'];
520 }
521 $diffs = $this->get_config_changes($cfg_1,$cfg_2);
522 $to_update = array();
523 if( !$this->initially_was_account ||
524 $this->s_selectedNetbootProduct != $this->s_initial_selectedNetbootProduct){
525 $to_update = $this->a_availableNetbootProducts[$this->s_selectedNetbootProduct]['CFG'];
526 }elseif(count($diffs)){
527 $to_update = $diffs;
528 }
530 if(count($to_update)){
531 $name = $this->s_selectedNetbootProduct;
532 $this->opsi->set_product_properties($name,$to_update,$this->hostId);
533 if($this->opsi->is_error()){
534 msg_dialog::display(_("Error"),msgPool::siError($this->opsi->get_error()),ERROR_DIALOG);
535 return;
536 }
537 }
539 $this->netConfigDNS->cn = $this->hostId;
540 $this->netConfigDNS->save();
541 }
544 public function get_config_changes($c1,$c2)
545 {
546 /* Get key which are not present in both entries
547 */
548 $res = array();
549 foreach($c2 as $name => $value){
550 if(!isset($c1[$name]) || $c1[$name]['DEFAULT'] != $c2[$name]['DEFAULT']){
551 $res[$name] = $c2[$name];
552 }
553 }
554 foreach($c1 as $name => $value){
555 if(!isset($c2[$name]) || $c2[$name]['DEFAULT'] != $c1[$name]['DEFAULT']){
556 $res[$name] = $c1[$name];
557 }
558 }
559 return($res);
560 }
563 /*! \brief Removes the opsi client
564 */
565 public function remove_from_parent()
566 {
567 $this->netConfigDNS->remove_from_parent();
569 $this->opsi->del_client($this->hostId);
570 if($this->opsi->is_error()){
571 msg_dialog::display(_("Error"),msgPool::siError($this->opsi->get_error()),ERROR_DIALOG);
572 return;
573 }
574 }
577 /*! \brief Save html posts
578 */
579 public function save_object()
580 {
581 /* Init failed; reinit is triggered here.
582 */
583 if(isset($_POST['reinit']) && $this->init_failed){
584 $this->init();
585 }
587 /* Property are currently edited, close the dialog.
588 */
589 if(isset($_POST['cancel_properties']) && is_object($this->dialog)){
590 $this->dialog = NULL;
591 }
593 /* Save product property changes
594 */
595 if(isset($_POST['save_properties']) && ($this->dialog instanceof opsiProperties)){
596 $this->dialog->save_object();
597 $pro = $this->dialog->get_product();
598 $CFG = $this->dialog->get_cfg();
599 if(isset($this->a_selectedLocalProducts[$pro])){
600 if($this->acl_is_writeable("localProduct")){
601 $this->a_selectedLocalProducts[$pro]['CFG'] = $CFG;
602 }
603 $this->dialog = NULL;
604 }elseif($this->s_selectedNetbootProduct == $pro){
605 if($this->acl_is_writeable("netbootProduct")){
606 $this->a_availableNetbootProducts[$pro]['CFG'] = $CFG;
607 }
608 $this->dialog = NULL;
609 }else{
610 trigger_error("Fatal, unknown product was configured.");
611 }
612 }
614 /* Save html post
615 */
616 if(isset($_POST['opsiGeneric_posted'])){
618 plugin::save_object();
619 $this->netConfigDNS->save_object();
621 /* Get hostId
622 */
623 if(isset($_POST['hostId']) && $this->standalone && $this->acl_is_writeable("hostId")){
624 $this->hostId = get_post('hostId');
625 }
627 /* Send actions like 'install' or 'wake' to the si server
628 */
629 if($this->acl_is_writeable("triggerAction") &&
630 isset($_POST['opsi_action']) &&
631 isset($_POST['opsi_trigger_action']) &&
632 $this->standalone ){
633 $action = $_POST['opsi_action'];
634 if($action == "install"){
635 $this->install_client();
636 }
637 if($action == "wake"){
638 $this->wake_client();
639 }
640 }
642 /* Get selected netboot product.
643 */
644 if(isset($_POST['opsi_netboot_product']) && $this->acl_is_writeable("netbootProduct")){
645 $SNP = trim($_POST['opsi_netboot_product']);
646 if(isset($this->a_availableNetbootProducts[$SNP])){
647 if(!isset($this->a_availableNetbootProducts[$SNP]['CFG'])){
648 $CFG = $this->opsi->get_product_properties($SNP);
649 $this->a_availableNetbootProducts[$SNP]['CFG'] = $CFG;
650 if($this->opsi->is_error()){
651 $this->init_failed = TRUE;
652 return;
653 }
654 }
655 $this->s_selectedNetbootProduct = $SNP;
656 }
657 }
659 /* Add/remove/edit local products
660 */
661 foreach($_POST as $name => $value){
663 /* Check if netboot product configuration is requested
664 */
665 if(preg_match("/^configure_netboot/",$name) && $this->acl_is_readable("netbootProduct")){
666 $pro = $this->s_selectedNetbootProduct;
667 $cfg = $this->a_availableNetbootProducts[$pro]['CFG'];
668 $this->dialog = new opsiProperties($this->config,$pro,$cfg,$this->hostId);
669 break;
670 }
672 /* Add product
673 */
674 if(preg_match("/^add_lp_/",$name) && $this->acl_is_writeable("localProduct")){
675 $product = preg_replace("/^add_lp_(.*)_.$/","\\1",$name);
676 if(isset($this->a_availableLocalProducts[$product]) && !isset($this->a_selectedLocalProducts[$product])){
677 $this->a_selectedLocalProducts[$product] = $this->a_availableLocalProducts[$product];
678 $CFG = $this->opsi->get_product_properties($product);
679 if($this->opsi->is_error()){
680 $this->init_failed = TRUE;
681 return;
682 }
683 $this->a_selectedLocalProducts[$product]['CFG'] = $CFG;
684 }
685 break;
686 }
688 /* Delete product
689 */
690 if(preg_match("/^del_lp_/",$name) && $this->acl_is_writeable("localProduct")){
691 $product = preg_replace("/^del_lp_(.*)_.$/","\\1",$name);
692 if(isset($this->a_selectedLocalProducts[$product])){
693 unset($this->a_selectedLocalProducts[$product]);
694 }
695 break;
696 }
698 /* Edit a product
699 */
700 if(preg_match("/^edit_lp_/",$name) && $this->acl_is_readable("localProduct")){
701 $product = preg_replace("/^edit_lp_(.*)_.$/","\\1",$name);
702 $this->dialog = new opsiProperties($this->config,
703 $product,$this->a_selectedLocalProducts[$product]['CFG'],$this->hostId);
704 break;
705 }
706 }
707 }
708 }
711 /* Triggers client installation
712 */
713 function install_client()
714 {
715 $this->opsi->send_action("install",$this->hostId,$this->mac);
716 if($this->opsi->is_error()){
717 msg_dialog::display(_("Error"),msgPool::siError($this->opsi->get_error()),ERROR_DIALOG);
718 }
719 }
722 /* Wake up client
723 */
724 function wake_client()
725 {
726 /* Check if we are able to communicate with the GOsa supprot daemon
727 */
728 if(class_available("gosaSupportDaemon")){
729 $o = new gosaSupportDaemon();
730 if($o->connect() && class_available("DaemonEvent_wakeup")){
731 $evt = new DaemonEvent_wakeup($this->config);
732 $evt->add_targets(array($this->mac));
733 $o->append($evt);
734 }
735 }
736 }
739 /* Return plugin informations for acl handling */
740 static function plInfo()
741 {
742 return (array(
743 "plShortName" => _("Generic"),
744 "plDescription" => _("OPSI generic"),
745 "plSelfModify" => FALSE,
746 "plDepends" => array(),
747 "plPriority" => 1,
748 "plSection" => array("administration"),
749 "plCategory" => array("opsi" => array("description" => _("Opsi"),
750 "objectClass" => "dummy_class_opsi")),
752 "plProvidedAcls"=> array(
753 "hostId" => _("Name"),
754 "mac" => _("MAC address"),
755 "description" => _("Description"),
756 "note" => _("Note"),
757 "netbootProduct" => _("Netboot product"),
758 "localProduct" => _("Local product"),
759 "triggerAction" => _("Action"))
760 ));
761 }
762 }
765 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
766 ?>