3
function smarty_block_render($params, $text, &$smarty)
5
/* Skip closing tag </render> */
10
/* Get acl parameter */
12
if (isset($params['acl'])) {
13
$acl = $params['acl'];
17
if (session::is_set('debugLevel') && session::get('debugLevel') & DEBUG_ACL ){
18
echo "<font color='blue' size='2'> ".$acl."</font>";
23
/* Parameter : checkbox, checked
24
* If the parameter 'checkbox' is given, we create a html checkbox in front
25
* of the current object.
26
* The parameter 'checked' specifies whether the box is checked or not.
27
* The checkbox disables or enables the current object.
29
if(isset($params['checkbox']) && $params['checkbox']){
31
/* Detect name and id of the current object */
32
$use_text = preg_replace("/\n/"," ",$text);
33
$name = preg_replace('/^.* name[ ]*=[ ]*("|\')([^\"\' ]*).*$/i',"\\2",$use_text);
36
if(preg_match("/ id=(\"|')[^\"']*(\"|')/i",$text)){
37
$id = preg_replace('/^.* id[ ]*=[ ]*("|\')([^\"\' ]*).*$/i',"\\2",$use_text);
42
/* Is the box checked? */
43
isset($params['checked'])&&$params['checked'] ? $check = " checked " : $check = "";
45
/* If name isset, we have a html input field */
49
echo "<input type='checkbox' name='use_".$name."' ".$check."
50
onClick=\"changeState('".$name."');\" class='center'>";
52
/* Disable current object, if checkbox isn't checked */
54
$text = preg_replace("/name=/i"," disabled name=",$text);
57
/* Add id to current entry, if it is missing */
59
$text = preg_replace("/name=/i"," id=\"".$name."\" name=",$text);
66
if(preg_match("/w/i",$acl)){
70
$text = preg_replace ("/\n/","GOSA_LINE_BREAK",$text);
72
/* Disable objects, but keep those active that have mode=read_active */
73
if(!(isset($params['mode']) && ($params['mode']=='read_active') && preg_match("/(r|w)/",$acl))){
75
/* Disable options && greyout lists */
76
$from = array("/class=['\"]list1nohighlight['\"]/i",
77
"/class=['\"]list0['\"]/i",
78
"/class=['\"]list1['\"]/i",
79
"/class=['\"]sortableListItem[^'\"]*['\"]/i");
80
$to = array("class='list1nohighlightdisabled'",
81
"class='list1nohighlightdisabled'",
82
"class='list1nohighlightdisabled'",
83
"class='sortableListItemDisabled'");
85
if(!preg_match("/ disabled /",$text)){
86
$from [] = "/name=/i" ;
87
$to [] = "disabled name=";
90
$text = preg_replace($from,$to,$text);
92
/* Replace picture if object is disabled */
93
if(isset($params['disable_picture'])){
94
$syn = "/src=['\"][^\"']*['\"]/i";
95
$new = "src=\"".$params['disable_picture']."\"";
96
$text = preg_replace($syn,$new,$text);
101
if(preg_match("/r/i",$acl)){
102
return(preg_replace("/GOSA_LINE_BREAK/","\n",$text));
106
if(preg_match("/type['\"= ].*submit/",$text)){
107
$text = preg_replace("/submit/","button",$text);
109
$text = preg_replace("/value=['\"][^\"']*['\"]/","",$text);
112
/* Remove select options */
113
$from = array("#<option.*<\/option>#i",
114
"/(<textarea.*>).*(<\/textarea>)/i",
115
"/^(.*<input.*)checked(.*>.*)$/i");
120
$text = preg_replace($from,$to,$text);
121
$text = preg_replace("/GOSA_LINE_BREAK/","\n",$text);