Code

Fixed submit button handling
[gosa.git] / include / smarty / plugins / block.render.php
1 <?php
3 function smarty_block_render($params, $text, &$smarty)
4 {
5         $text = stripslashes($text);
6         $acl = "";
8         /* Skip closing tag </render> */        
9         if(empty($text)) {
10                 return("");
11         }
13         /* Get acl parameter */
14         if (isset($params['acl'])) {
15                 $acl = $params['acl'];
16                 unset($params['acl']);
17         }
19         echo "<font color='blue' size='2'>".$acl."</font>";
21         /* Read / Write*/
22         if(preg_match("/w/i",$acl)){
23                 return ($text);
24         }
26         /* Disable objects, but keep submit buttons active in readmode */
27         if(!preg_match("/submit/",$text)){
28                 $from   =  array("/name=/i");
29                 $to     =  array("disabled name=");
30                 $text = preg_replace($from,$to,$text);
31         }               
33         /* Read only */
34         if(preg_match("/r/i",$acl)){
35                 return($text);  
36         }
38         /* No acls */   
39         if(preg_match("/type['\"= ].*submit/",$text)){
40                 $text = preg_replace("/submit/","button",$text);
41         }else{
42                 $text = preg_replace("/value=['\" ].*['\" ]/","",$text);
43         }
45         return $text;
46 }
48 ?>