Code

Set macAddress to must for opsi hosts.
[gosa.git] / gosa-plugins / opsi / admin / opsi / class_opsigeneric.inc
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;
61     
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   }
83   
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     $list = $this->opsi->get_full_product_host_information($this->hostId);
131     $err |= $this->opsi->is_error();
133     /* Read informations about available netboot products. 
134        If not already done, before.
135      */
136     if(!$err){
137       foreach($list as $key => $entry){
139         $tmp = array('DESC'=>$entry['data']['DESCRIPTION'],'NAME'=>$key);
140         if($entry['configurable']){
141           $tmp['CFG'] = $entry['data']['PROPERTIES'];
142         } 
144         if($entry['data']['TYPE'] == "localboot"){
145           if(!$entry['installed']){
146             $this->a_availableLocalProducts[$key] = $tmp;
147           }else{
148             $this->a_selectedLocalProducts[$key] = $tmp;
149           }
150         }else{
151           $this->a_availableNetbootProducts[$key] = $tmp;
152           if($entry['installed']){
153             $this->s_selectedNetbootProduct= $key;
154           }
155         }
156       }
157     }
159     /* Check if everything went fine else reset everything and display a retry button 
160      */
161     if($err){
162       $this->init_failed = TRUE;
163       
164     }else{
166       /* Remember initial settings */
167       $this->a_initial_selectedLocalProducts = $this->a_selectedLocalProducts;
168       $this->s_initial_selectedNetbootProduct = $this->s_selectedNetbootProduct;
169       $this->a_initial_availableNetbootProducts = $this->a_availableNetbootProducts;
171       /* Ensure that a valid netboot is selected product is.
172        */
173       if(empty($this->s_selectedNetbootProduct)){
174         $this->s_selectedNetbootProduct = key($this->a_availableNetbootProducts);
175       }
177       // Now fake a valid ldap entry ... this is necessary to avoid 
178       //  modifications in the dns/dhcp classes
180       // First fake cn 
181       $this->attrs['hostId'][0] = $this->hostId;
182       $this->attrs['cn'][0] = $this->hostId;
184       // Second detect DNS settings. 
185       $ldap = $this->config->get_ldap_link();
186       $ldap->cd($this->config->current['BASE']);
187       $strippedHostId = preg_replace("/\..*$/","",$this->hostId);
188       $ldap->search("(&(objectClass=dNSZone)(|(relativeDomainName=".$this->hostId.")(relativeDomainName=".$strippedHostId."))(aRecord=*))",array("aRecord"));
189       if($ldap->count()){
190         $attrs = $ldap->fetch();
191         $this->attrs['ipHostNumber']['count'] = 0;
192         $this->attrs['ipHostNumber'][0] = $attrs['aRecord'][0];
193       }
195       $this->attrs['macAddress']['count'] = 1;
196       $this->attrs['macAddress'][0] = &$this->mac;
198       // Initialize DHCP and DNS 
199       $this->netConfigDNS = new termDNS($this->config,$this,$this->objectclasses, FALSE, "hostId");
200       $this->netConfigDNS->set_acl_category("opsi");
201       $this->netConfigDNS->set_acl_base($this->config->current['BASE']);
202       $this->netConfigDNS->IPisMust = FALSE;
203       $this->netConfigDNS->MACisMust = TRUE;
204     }
205   }
208   /*! \brief  Check given data.
209       @return Array   Returns an array with all issues.
210    */
211   public function check()
212   {
213   
214     // In case of initialization problem, we do not save anything.
215     // We can skip checks here, the date isn't usable.
216     if($this->init_failed){ 
217       return;
218     };
220     $messages = plugin::check();
221     $messages= array_merge($messages, $this->netConfigDNS->check());
223     if(empty($this->hostId)){
224       $messages[] = msgPool::required(_("Name"));
225     }elseif(!preg_match("/\./",$this->hostId)){
227       /* The hostId must contain a domain part 
228        */
229       $messages[] = msgPool::invalid(_("Name"),$this->hostId,"",
230           _("The field 'Name' must contain a domain part!"));
231     }elseif(preg_match("/[^a-z0-9\.\-_]/",$this->hostId)){
232       $messages[] = msgPool::invalid(_("Name"),$this->hostId,"/[a-z0-9\.\-_]/");
233     }
235     /* Ensure that the mac address is valid
236      */
237     if(!tests::is_mac($this->mac) || empty($this->mac)){
238       $messages[] = msgPool::invalid(_("MAC address"),$this->mac,"","00:0C:7F:31:33:F1");
239     }
240     return($messages);
241   }
244   /*! \brief  Create the html ui of this plugin
245       @return String  HTML content.
246    */
247   public function execute()
248   {
249     $display ="";
251     /* The pluign initialization failed due to communication problems with the gosa daemon. 
252        A retry button will be displayed here.
253      */
254     if($this->init_failed){
255       $smarty = get_smarty();
256       $smarty->assign("standalone ", $this->standalone );
257       $smarty->assign("init_failed",TRUE);
258       $smarty->assign("message",$this->opsi->get_error());
259       return($smarty->fetch(get_template_path("generic.tpl",TRUE,dirname(__FILE__))));
260     }  
263     /* If we are not a stand alone opsi client, we must be a samba client 
264        which has the opsi tab enabled.
265        Check if the opsi is added or removed and display state buttons.
266      */
267     if(!$this->standalone ){
269       /* Do we need to flip is_account state? */
270       if(isset($_POST['modify_state'])){
271         if($this->is_account && $this->acl_is_removeable()){
272           $this->is_account= FALSE;
273         }elseif(!$this->is_account && $this->acl_is_createable()){
274           $this->is_account= TRUE;
275         }
276       }
277       if($this->is_account){
278         $display = $this->show_disable_header(msgPool::removeFeaturesButton(_("OPSI")), 
279             msgPool::featuresEnabled(_("OPSI")));
280       }else{
281         $display = $this->show_enable_header(msgPool::addFeaturesButton(_("OPSI")), 
282             msgPool::featuresDisabled(_("OPSI")));
283         return($display);
284       } 
285     } 
287     /* Check if we have a sub dialog opened
288      */
289     if(is_object($this->dialog)){
290       $this->dialog->save_object();
291       return($this->dialog->execute());
292     }
294     /* Create HTML output of this plugin
295      */
296     $smarty = get_smarty();
297     $smarty->assign("standalone", $this->standalone );
298     foreach($this->attributes as $attr){
299       $smarty->assign($attr,$this->$attr);
300     }
302     /* Assign ACLs */    
303     $tmp = $this->plInfo();
304     foreach($tmp['plProvidedAcls'] as $name => $translated){
305       $smarty->assign($name."ACL",$this->getacl($name));
306     }
308     $smarty->assign("is_installed", $this->is_installed);
309     $smarty->assign("init_failed",FALSE);
310     $divSLP = new divSelectBox();
311     $divALP = new divSelectBox();
313     /* Create list of available local products 
314      */
315     foreach($this->a_availableLocalProducts as $name => $data){
316       if(isset($this->a_selectedLocalProducts[$name])) continue;
318       $add_tab  = array("string"   => "<input type='image' src='images/back.png' name='add_lp_".$name."'>");
319       $name_tab = array("string"   => $name);
320       $desc_tab = array("string"   => "<div style='height: 14px;overflow:hidden;'>".$data['DESC']."</div>",
321           "attach"   => "title='".$data['DESC']."' style='border-right:0px;'");
323       if($this->acl_is_writeable("localProduct")){
324         $divALP->AddEntry(array($add_tab,$name_tab,$desc_tab));
325       }else{
326         $divALP->AddEntry(array($name_tab,$desc_tab));
327       }
328     }
330     /* Create list of selected local products 
331      */
332     ksort($this->a_selectedLocalProducts);
333     if($this->acl_is_readable("localProduct")){
334       foreach($this->a_selectedLocalProducts as $name => $data){
336         $name_tab = array("string"   => $name);
337         $desc_tab = array(
338             "string" => "<div style='height: 14px;overflow:hidden;'>".$data['DESC']."</div>",
339             "attach" => "title='".$data['DESC']."'");
341         /* Only display edit button, if there is something to edit 
342          */
343         $edit = "<img src='images/empty.png' alt=' '>";
344         if(count($data['CFG'])){
345           $edit = "<input type='image' src='images/lists/edit.png' name='edit_lp_".$name."'>";
346         }
347         $del  = "<input type='image' src='images/lists/trash.png' name='del_lp_".$name."'>";  
349         $opt_tab  = array("string" => $edit.$del,
350             "attach" => "style='border-right:0px; width: 40px; text-align:right;'");
352         if($this->acl_is_writeable("localProduct")){
353           $divSLP->AddEntry(array($name_tab,$desc_tab,$opt_tab));
354         }else{
355           $divSLP->AddEntry(array($name_tab,$desc_tab));
356         }
357       }
358     }
360     /* Check if netboot product is configurable 
361      */
362     $cfg_able =FALSE;
363     if(isset($this->a_availableNetbootProducts[$this->s_selectedNetbootProduct]['CFG'])){
364       $cfg_able = count($this->a_availableNetbootProducts[$this->s_selectedNetbootProduct]['CFG']);
365       $cfg_able &= $this->acl_is_readable("netbootProduct");
366     }
368     // Get net config template
369     $str = $this->netConfigDNS->execute();
370     if(is_object($this->netConfigDNS->dialog)){
371       return($str);
372     }
373     $smarty->assign("netconfig", $str);
375     $smarty->assign("netboot_configurable",$cfg_able);
376     $smarty->assign("hostId", $this->hostId);
377     $smarty->assign("divSLP", $divSLP->DrawList());
378     $smarty->assign("divALP", $divALP->DrawList());
379     $smarty->assign("SNP", $this->s_selectedNetbootProduct);
380     $smarty->assign("ANP", $this->a_availableNetbootProducts);
381     return($display.$smarty->fetch(get_template_path("generic.tpl",TRUE,dirname(__FILE__))));
382   }
385   /*! \brief  Save modifications using the gosa support daemon.
386    */
387   public function save()
388   {
389     if($this->init_failed){ 
390       return;
391     }
392     
393     /* Check if we have to create a new opsi client
394         or just have to save client modifications.
395      */
396     if(!$this->initially_was_account && $this->is_account){
397       $res = $this->opsi->add_client($this->hostId,$this->mac,$this->note,$this->description);
398       if($this->opsi->is_error()){
399         msg_dialog::display(_("Error"),msgPool::siError($this->opsi->get_error()),ERROR_DIALOG);    
400         return;
401       }
402     }else{
404       /* Update client modifcations.
405           -Only if necessary  
406        */
407       if($this->note != $this->initial_note || 
408           $this->description != $this->initial_description ||
409           $this->mac != $this->initial_mac){
410         $this->opsi->modify_client($this->hostId,$this->mac,$this->note,$this->description);
411         if($this->opsi->is_error()){
412           msg_dialog::display(_("Error"),msgPool::siError($this->opsi->get_error()),ERROR_DIALOG);
413           return;
414         }
415       }
416     }
419     /***********
420       Detect local netboot product changes
421        - Check which products were removed.
422        - Check which products were added. 
423      ***********/
426     /* Detect which products were removed an which added.
427      */
428     $del = array_diff_assoc($this->a_initial_selectedLocalProducts,$this->a_selectedLocalProducts);
429     $add = array_diff_assoc($this->a_selectedLocalProducts,$this->a_initial_selectedLocalProducts);
431     /* Remove products from client
432      */
433     foreach($del as $name => $data){
434       $this->opsi->del_product_from_client($name,$this->hostId);
435       if($this->opsi->is_error()){
436         msg_dialog::display(_("Error"),msgPool::siError($this->opsi->get_error()),ERROR_DIALOG);    
437         return;
438       }
439     }
440     
441     /* Add products to client
442        And set the product properties.
443      */
444     foreach($add as $name => $data){
445       $this->opsi->add_product_to_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       if(!empty($data['CFG'])){
451         $this->opsi->set_product_properties($name,$data['CFG'],$this->hostId);
452         if($this->opsi->is_error()){
453           msg_dialog::display(_("Error"),msgPool::siError($this->opsi->get_error()),ERROR_DIALOG);    
454           return;
455         }
456       }
457     }
459     /* Save local product properties 
460      */
461     foreach($this->a_selectedLocalProducts as $name => $data){
462       if(isset($del[$name]) || isset($add[$name])) continue;
464       /* Update product properties if there are changes 
465        */
466       $diffs = $this->get_config_changes($data['CFG'],$this->a_initial_selectedLocalProducts[$name]['CFG']);
467       if(count($diffs)){
468         $this->opsi->set_product_properties($name,$diffs,$this->hostId);
469         if($this->opsi->is_error()){
470           msg_dialog::display(_("Error"),msgPool::siError($this->opsi->get_error()),ERROR_DIALOG);    
471           return;
472         }
473       }
474     }
476     /*********
477       Detect Netboot product changes
478        - Check if another netboot product was selected. 
479        - Check if the product properties were changes.
480      *********/
482     /* Update used netboot product. 
483      */
484     if($this->s_selectedNetbootProduct != $this->s_initial_selectedNetbootProduct){
485       if(!empty($this->s_initial_selectedNetbootProduct)){
486         $this->opsi->del_product_from_client($this->s_initial_selectedNetbootProduct,$this->hostId);
487         if($this->opsi->is_error()){
488           msg_dialog::display(_("Error"),msgPool::siError($this->opsi->get_error()),ERROR_DIALOG);    
489           return;
490         }
491       }
492       $this->opsi->add_product_to_client($this->s_selectedNetbootProduct,$this->hostId);
493       if($this->opsi->is_error()){
494         msg_dialog::display(_("Error"),msgPool::siError($this->opsi->get_error()),ERROR_DIALOG);    
495         return;
496       }
497     }
499     /* Check if we have to update the netboot product properties 
500         This is the case, if this product is newly selected.
501         Or if there was at least one configuration attribute modified.
502      */
503     $cfg_1 = $cfg_2 = array();
504     if(isset($this->a_availableNetbootProducts[$this->s_selectedNetbootProduct]['CFG'])){
505       $cfg_1 = $this->a_availableNetbootProducts[$this->s_selectedNetbootProduct]['CFG'];
506     }
507     if(isset($this->a_initial_availableNetbootProducts[$this->s_selectedNetbootProduct]['CFG'])){
508       $cfg_2 = $this->a_initial_availableNetbootProducts[$this->s_selectedNetbootProduct]['CFG'];
509     }
510     $diffs = $this->get_config_changes($cfg_1,$cfg_2);
511     $to_update = array();
512     if( !$this->initially_was_account || 
513         $this->s_selectedNetbootProduct != $this->s_initial_selectedNetbootProduct){
514       $to_update = $this->a_availableNetbootProducts[$this->s_selectedNetbootProduct]['CFG'];
515     }elseif(count($diffs)){
516       $to_update = $diffs;
517     }
519     if(count($to_update)){
520       $name = $this->s_selectedNetbootProduct;
521       $this->opsi->set_product_properties($name,$to_update,$this->hostId);
522       if($this->opsi->is_error()){
523         msg_dialog::display(_("Error"),msgPool::siError($this->opsi->get_error()),ERROR_DIALOG);
524         return;
525       }
526     }
528     $this->netConfigDNS->cn = $this->hostId;
529     $this->netConfigDNS->save();
530   }
532   
533   public function get_config_changes($c1,$c2)
534   {
535     /* Get key which are not present in both entries 
536      */
537     $res = array();
538     foreach($c2 as $name => $value){
539       if(!isset($c1[$name]) || $c1[$name]['CURRENT'] != $c2[$name]['CURRENT']){
540         $res[$name] = $c2[$name];
541       }
542     }
543     foreach($c1 as $name => $value){
544       if(!isset($c2[$name]) || $c2[$name]['CURRENT'] != $c1[$name]['CURRENT']){
545         $res[$name] = $c1[$name];
546       }
547     }
548     return($res);
549   }
552   /*! \brief  Removes the opsi client 
553    */  
554   public function remove_from_parent()
555   {
556     if($this->init_failed){ 
557       return;
558     }
559     $this->netConfigDNS->remove_from_parent();
561     $this->opsi->del_client($this->hostId);
562     if($this->opsi->is_error()){
563       msg_dialog::display(_("Error"),msgPool::siError($this->opsi->get_error()),ERROR_DIALOG);
564       return;
565     }
566   }
569   /*! \brief  Save html posts 
570    */
571   public function save_object()
572   {
573     /* Init failed; reinit is triggered here.
574      */
575     if(isset($_POST['reinit']) && $this->init_failed){
576       $this->init();
577     }
579     /* Property are currently edited, close the dialog. 
580      */
581     if(isset($_POST['cancel_properties']) && is_object($this->dialog)){
582       $this->dialog = NULL;
583     }
584   
585     /* Save product property changes 
586      */
587     if(isset($_POST['save_properties']) && ($this->dialog instanceof opsiProperties)){
588       $this->dialog->save_object();
589       $pro = $this->dialog->get_product();
590       $CFG = $this->dialog->get_cfg();
591       if(isset($this->a_selectedLocalProducts[$pro])){
592         if($this->acl_is_writeable("localProduct")){
593           $this->a_selectedLocalProducts[$pro]['CFG'] = $CFG;
594         }
595         $this->dialog = NULL;
596       }elseif($this->s_selectedNetbootProduct == $pro){
597         if($this->acl_is_writeable("netbootProduct")){
598           $this->a_availableNetbootProducts[$pro]['CFG'] = $CFG;
599         }
600         $this->dialog = NULL;
601       }else{
602         trigger_error("Fatal, unknown product was configured.");
603       }
604     }
606     /* Save html post
607      */
608     if(isset($_POST['opsiGeneric_posted'])){
610       plugin::save_object();
611       $this->netConfigDNS->save_object();
612       $this->mac = $this->netConfigDNS->macAddress;
613   
614       /* Get hostId 
615        */
616       if(isset($_POST['hostId']) && $this->standalone && $this->acl_is_writeable("hostId")){
617         $this->hostId = get_post('hostId');
618       }
620       /* Send actions like 'install' or 'wake' to the si server 
621        */
622       if($this->acl_is_writeable("triggerAction") && 
623           isset($_POST['opsi_action']) && 
624           isset($_POST['opsi_trigger_action']) && 
625           $this->standalone ){
626         $action = $_POST['opsi_action'];
627         if($action == "install"){
628           $this->install_client(); 
629         }
630         if($action == "wake"){
631           $this->wake_client(); 
632         }
633       }
635       /* Get selected netboot product.
636        */
637       if(isset($_POST['opsi_netboot_product']) && $this->acl_is_writeable("netbootProduct")){
638         $SNP = trim($_POST['opsi_netboot_product']);
639         if(isset($this->a_availableNetbootProducts[$SNP])){
640           if(!isset($this->a_availableNetbootProducts[$SNP]['CFG'])){
641             $CFG = $this->opsi->get_product_properties($SNP);
642             $this->a_availableNetbootProducts[$SNP]['CFG'] = $CFG;
643             if($this->opsi->is_error()){
644               $this->init_failed = TRUE;
645               return;
646             }
647           }
648           $this->s_selectedNetbootProduct = $SNP;
649         }
650       }
652       /* Add/remove/edit local products 
653        */
654       foreach($_POST as $name => $value){
656         /* Check if netboot product configuration is requested 
657          */
658         if(preg_match("/^configure_netboot/",$name) && $this->acl_is_readable("netbootProduct")){
659           $pro = $this->s_selectedNetbootProduct;
660           $cfg = $this->a_availableNetbootProducts[$pro]['CFG'];
661           $this->dialog = new opsiProperties($this->config,$pro,$cfg,$this->hostId);
662           break;
663         }
664       
665         /* Add product 
666          */
667         if(preg_match("/^add_lp_/",$name) && $this->acl_is_writeable("localProduct")){
668           $product = preg_replace("/^add_lp_(.*)_.$/","\\1",$name);
669           if(isset($this->a_availableLocalProducts[$product]) && !isset($this->a_selectedLocalProducts[$product])){
670             $this->a_selectedLocalProducts[$product] = $this->a_availableLocalProducts[$product];
671             $CFG = $this->opsi->get_product_properties($product);
672             if($this->opsi->is_error()){
673               $this->init_failed = TRUE;
674               return;
675             }
676             $this->a_selectedLocalProducts[$product]['CFG'] = $CFG;
677           }
678           break;
679         }
680   
681         /* Delete product 
682          */
683         if(preg_match("/^del_lp_/",$name) && $this->acl_is_writeable("localProduct")){
684           $product = preg_replace("/^del_lp_(.*)_.$/","\\1",$name);
685           if(isset($this->a_selectedLocalProducts[$product])){
686             unset($this->a_selectedLocalProducts[$product]);
687           }
688           break;
689         }
690       
691         /* Edit a product  
692          */
693         if(preg_match("/^edit_lp_/",$name) && $this->acl_is_readable("localProduct")){
694           $product = preg_replace("/^edit_lp_(.*)_.$/","\\1",$name);
695           $this->dialog = new opsiProperties($this->config,
696               $product,$this->a_selectedLocalProducts[$product]['CFG'],$this->hostId);
697           break;
698         }
699       }   
700     }
701   }
704   /* Triggers client installation 
705    */
706   function install_client()
707   {
708     $this->opsi->send_action("install",$this->hostId,$this->mac);
709     if($this->opsi->is_error()){
710       msg_dialog::display(_("Error"),msgPool::siError($this->opsi->get_error()),ERROR_DIALOG);
711     }
712   }
715   /* Wake up client
716    */
717   function wake_client()
718   {
719     /* Check if we are able to communicate with the GOsa supprot daemon
720      */
721     if(class_available("gosaSupportDaemon")){
722       $o = new gosaSupportDaemon();
723       if($o->connect() && class_available("DaemonEvent_wakeup")){
724         $evt = new DaemonEvent_wakeup($this->config);      
725         $evt->add_targets(array($this->mac));
726         $o->append($evt);
727       }
728     }
729   }
732   /* Return plugin informations for acl handling */
733   static function plInfo()
734   {
735     return (array(
736           "plShortName"   => _("Generic"),
737           "plDescription" => _("OPSI generic"),
738           "plSelfModify"  => FALSE,
739           "plDepends"     => array(),
740           "plPriority"    => 1,
741           "plSection"     => array("administration"),
742           "plCategory"    => array("opsi" => array("description"  => _("Opsi"),
743               "objectClass"  => "dummy_class_opsi")),
745           "plProvidedAcls"=> array(
746             "hostId"          => _("Name"),
747             "mac"             => _("MAC address"),
748             "description"     => _("Description"),
749             "note"            => _("Note"),
750             "netbootProduct"  => _("Netboot product"),
751             "localProduct"    => _("Local product"),
752             "triggerAction"   => _("Action"))
753           ));
754   }
758 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
759 ?>