From f33fd9518bb70114fe1fdd82d6903a5c868da972 Mon Sep 17 00:00:00 2001 From: hickert Date: Tue, 11 Dec 2007 06:27:30 +0000 Subject: [PATCH] Updated block render. git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@8074 594d385d-05f5-0310-b6e9-bd551577e9d8 --- include/smarty/plugins/block.render.php | 47 ++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/include/smarty/plugins/block.render.php b/include/smarty/plugins/block.render.php index 63e02b68f..40a456aef 100755 --- a/include/smarty/plugins/block.render.php +++ b/include/smarty/plugins/block.render.php @@ -8,15 +8,60 @@ function smarty_block_render($params, $text, &$smarty) } /* Get acl parameter */ + $acl = ""; if (isset($params['acl'])) { $acl = $params['acl']; - unset($params['acl']); } + /* Debug output */ if (isset($_SESSION['DEBUGLEVEL']) && $_SESSION['DEBUGLEVEL'] & DEBUG_ACL ){ echo " ".$acl.""; } + + + /* Parameter : checkbox, checked + * If the parameter 'checkbox' is given, we create a html checkbox in front + * of the current object. + * The parameter 'checked' specifies whether the box is checked or not. + * The checkbox disables or enables the current object. + */ + if(isset($params['checkbox'])){ + + /* Detect name and id of the current object */ + $use_text = preg_replace("/\n/"," ",$text); + $name = preg_replace('/^.* name[ ]*=[ ]*("|\')([^\"\' ]*).*$/i',"\\2",$use_text); + + /* Detect id */ + if(preg_match("/ id=(\"|')[^\"']*(\"|')/i",$text)){ + $id = preg_replace('/^.* id[ ]*=[ ]*("|\')([^\"\' ]*).*$/i',"\\2",$use_text); + }else{ + $id = ""; + } + + /* Is the box checked? */ + isset($params['checked'])&&$params['checked'] ? $check = " checked " : $check = ""; + + /* If name isset, we have a html input field */ + if(!empty($name)){ + + /* Print checkbox */ + echo ""; + + /* Disable current object, if checkbox isn't checked */ + if($check == ""){ + $text = preg_replace("/name=/i"," disabled name=",$text); + } + + /* Add id to current entry, if it is missing */ + if($id == ""){ + $text = preg_replace("/name=/i"," id=\"".$name."\" name=",$text); + } + } + } + + /* Read / Write*/ if(preg_match("/w/i",$acl)){ return ($text); -- 2.30.2