Code

Added diabled picture to render funktion
[gosa.git] / include / smarty / plugins / block.render.php
index 1aa87baf5afeb32d2c0db13af0827c885c94beb8..831009fda1921b1a682ff363cb8c8dd14f841a1d 100755 (executable)
@@ -3,33 +3,52 @@
 function smarty_block_render($params, $text, &$smarty)
 {
        $text = stripslashes($text);
+       $acl = "";
 
+       /* Skip closing tag </render> */        
+       if(empty($text)) {
+               return("");
+       }
+
+       /* Get acl parameter */
        if (isset($params['acl'])) {
                $acl = $params['acl'];
                unset($params['acl']);
        }
 
+//     echo "<font color='blue' size='2'>".$acl."</font>";
+
+       /* Read / Write*/
        if(preg_match("/w/i",$acl)){
-               
-               /* Read / Write*/
+               return ($text);
+       }
 
-       }elseif(preg_match("/r/i",$acl)){
-               
-               /* Read only */
+       /* Disable objects, but keep those active that have mode=read_active */
+       if(!(isset($params['mode']) && $params['mode']=='readable')){
                $from   =  array("/name=/i");
                $to     =  array("disabled name=");
                $text = preg_replace($from,$to,$text);
 
-       }elseif(empty($acl)){
-               
-               /* No rights */
-               $text= "&nbsp;";
-               
+               /* Replace picture if object is disabled */
+               if(isset($params['disable_picture'])){
+                       $syn = "/src=['\"][a-z0-9\/.]*['\"]/i";
+                       $new = "src=\"".$params['disable_picture']."\"";
+                       $text = preg_replace($syn,$new,$text);
+               }
+
+       }               
+
+       /* Read only */
+       if(preg_match("/r/i",$acl)){
+               return($text);  
+       }
+
+       /* No acls */   
+       if(preg_match("/type['\"= ].*submit/",$text)){
+               $text = preg_replace("/submit/","button",$text);
        }else{
-               // unknown
-               $text ="&nbsp;";
+               $text = preg_replace("/value=['\" ].*['\" ]/","",$text);
        }
-               
 
        return $text;
 }