1 <?php
3 function smarty_block_render($params, $text, &$smarty)
4 {
5 /* Skip closing tag </render> */
6 if(empty($text)) {
7 return("");
8 }
10 /* Get acl parameter */
11 if (isset($params['acl'])) {
12 $acl = $params['acl'];
13 unset($params['acl']);
14 }
16 echo "<font color='blue' size='2'> ".$acl."</font>";
18 /* Read / Write*/
19 if(preg_match("/w/i",$acl)){
20 return ($text);
21 }
23 $text = preg_replace ("/\n/","GOSA_LINE_BREAK",$text);
25 /* Disable objects, but keep those active that have mode=read_active */
26 if(!(isset($params['mode']) && $params['mode']=='read_active')){
28 /* Disable options && greyout divlists */
29 $from = array("/class=['\"]list1nohighlight['\"]/i",
30 "/class=['\"]list0['\"]/i",
31 "/class=['\"]list1['\"]/i");
32 $to = array("class='list1nohighlightdisabled'",
33 "class='list1nohighlightdisabled'",
34 "class='list1nohighlightdisabled'");
36 if(!preg_match("/ disabled /",$text)){
37 $from [] = "/name=/i" ;
38 $to [] = "disabled name=";
39 }
41 $text = preg_replace($from,$to,$text);
43 /* Replace picture if object is disabled */
44 if(isset($params['disable_picture'])){
45 $syn = "/src=['\"][^\"']*['\"]/i";
46 $new = "src=\"".$params['disable_picture']."\"";
47 $text = preg_replace($syn,$new,$text);
48 }
49 }
51 /* Read only */
52 if(preg_match("/r/i",$acl)){
53 return(preg_replace("/GOSA_LINE_BREAK/","\n",$text));
54 }
56 /* No acls */
57 if(preg_match("/type['\"= ].*submit/",$text)){
58 $text = preg_replace("/submit/","button",$text);
59 }else{
60 $text = preg_replace("/value=['\"][^\"']*['\"]/","",$text);
61 }
63 /* Remove select options */
64 $from = array("#<option.*<\/option>#i",
65 "/(<textarea.*>).*(<\/textarea>)/i",
66 "/^(.*<input.*)checked(.*>.*)$/i");
68 $to = array(" ",
69 "\\1\\2",
70 "\\1 \\2");
71 $text = preg_replace($from,$to,$text);
72 $text = preg_replace("/GOSA_LINE_BREAK/","\n",$text);
73 return $text;
74 }
76 ?>