Code

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