Code

Updated block render.
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 11 Dec 2007 06:27:30 +0000 (06:27 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 11 Dec 2007 06:27:30 +0000 (06:27 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@8074 594d385d-05f5-0310-b6e9-bd551577e9d8

include/smarty/plugins/block.render.php

index 63e02b68f6d1e9b25ec20111329f078844435ca9..40a456aef679e984256f3c2ab3758757f96b1a89 100755 (executable)
@@ -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 "<font color='blue' size='2'>&nbsp;".$acl."</font>";
        }
 
+
+
+       /* 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 "<input type='checkbox' name='use_".$name."' ".$check." 
+                                       onClick=\"changeState('".$name."');\" class='center'>";
+
+                       /* 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);