Code

Updated Template Widgets to support ACls
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 19 May 2011 09:19:10 +0000 (09:19 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 19 May 2011 09:19:10 +0000 (09:19 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@20880 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-plugins/goto-ng/admin/newConfigManagement/TemplateEngine/TemplateWidget_textEditor.tpl
gosa-plugins/goto-ng/admin/newConfigManagement/TemplateEngine/class_TemplateWidget_checkbox.inc
gosa-plugins/goto-ng/admin/newConfigManagement/TemplateEngine/class_TemplateWidget_combobox.inc
gosa-plugins/goto-ng/admin/newConfigManagement/TemplateEngine/class_TemplateWidget_file.inc
gosa-plugins/goto-ng/admin/newConfigManagement/TemplateEngine/class_TemplateWidget_fixedList.inc
gosa-plugins/goto-ng/admin/newConfigManagement/TemplateEngine/class_TemplateWidget_list.inc
gosa-plugins/goto-ng/admin/newConfigManagement/TemplateEngine/class_TemplateWidget_stringLong.inc
gosa-plugins/goto-ng/admin/newConfigManagement/TemplateEngine/class_TemplateWidget_textEditor.inc
gosa-plugins/goto-ng/admin/newConfigManagement/TemplateEngine/class_TemplateWidget_textarea.inc

index 06d78b65c8192e655ca056fc3fe23fa872086cc8..011c2bbd5f33b04edffca03f35c645eb5a67c5f9 100644 (file)
@@ -1,12 +1,12 @@
 {if $write_protect}
   {t}The text is write protected due to its encoding. Editing may break it!{/t}
   <br>
-  <button type='submit' name='editAnyway' {if !$enabled} disabled {/if}>{t}Edit anyway{/t}</button>
+  <button type='submit' name='editAnyway' {if !$enabled || !$writeable} disabled {/if}>{t}Edit anyway{/t}</button>
 {/if}
-<textarea {if !$enabled} disabled {/if} {if $write_protect} disabled {/if} {if !$write_protect} name="{$postName}" {/if}
+<textarea {if !$enabled || !$writeable} disabled {/if} {if $write_protect} disabled {/if} {if !$write_protect} name="{$postName}" {/if}
     style="width:100%;height:300px;" id="{$postName}"
-    rows="20" cols="120">{$value}</textarea>
+    rows="20" cols="120">{if $readable}{$value}{/if}</textarea>
 <div>
-  <input type="file" name="ImportFile" {if !$enabled} disabled {/if} style="width:280px;">&nbsp;
-  <button type='submit' name='ImportUpload' {if !$enabled} disabled {/if}>{t}Import text{/t}</button>
+  <input type="file" name="ImportFile" {if !$enabled || !$writeable} disabled {/if} style="width:280px;">&nbsp;
+  <button type='submit' name='ImportUpload' {if !$enabled || !$writeable} disabled {/if}>{t}Import text{/t}</button>
 </div>
index 27488cbef79da5d8f2fd178f8e98ae115877c229..acb7958404c5c41b2fcc0fe2393235db000d10dc 100644 (file)
@@ -4,15 +4,15 @@ class TemplateWidget_checkbox extends TemplateWidget
 {
     function render()
     {
-        $str = "";
-        $disabled = (!$this->enabled)? "disabled" : "";
-        $str .= "<input type='checkbox' value='1' name='{$this->postName}' {$disabled}";
+        $disabled = (!$this->enabled || !$this->writeable)? "disabled" : "";
+        $name = (!$this->enabled || !$this->writeable)? "dummy".rand(0,10000) : $this->postName;
 
+        $str = "";
+        $str .= "<input type='checkbox' value='1' name='{$name}' {$disabled}";
         if($this->value) $str .= " checked ";
-
         $str .= ">";
 
-        $str .= "<input type='hidden' name='{$this->postName}_posted' value='1'>";
+        $str .= "<input type='hidden' name='{$name}_posted' value='1'>";
         return($str);
     }
 
index e1b4ecdb41e174beb1f5802eb5610e6a6376b97f..7be45f158d0ea9ddb27953fbc252c5662fa82151 100644 (file)
@@ -7,13 +7,15 @@ class TemplateWidget_combobox extends TemplateWidget
         $str = "";
 
         // Build up list data
-        $disabled = (!$this->enabled)? "disabled" : "";
-        $str .= "<select size='1' name='{$this->postName}' {$disabled}>";
-        foreach($this->values as $name => $value){
-            if($name == $this->value){
-                $str .= "<option selected value=\"{$name}\">{$value}</option>\n";
+        $disabled = (!$this->enabled || !$this->writeable)? "disabled" : "";
+        $name = (!$this->enabled || !$this->writeable)? "dummy".rand(0,10000) : $this->postName;
+
+        $str .= "<select size='1' name='{$name}' {$disabled}>";
+        foreach($this->values as $option => $value){
+            if($option == $this->value){
+                $str .= "<option selected value=\"{$option}\">{$value}</option>\n";
             }else{
-                $str .= "<option value=\"{$name}\">{$value}</option>\n";
+                $str .= "<option value=\"{$option}\">{$value}</option>\n";
             }
         }
         $str .= "</select>";
index 197d6453a4ab19c4895c55f30fab8a8aea22a51c..8598afff9f11c6f8685b76fe45126999984603e5 100644 (file)
@@ -29,22 +29,24 @@ class TemplateWidget_file extends TemplateWidget
 
     function render()
     {
+        $disabled = (!$this->enabled || !$this->writeable)? "disabled" : "";
+        $name = (!$this->enabled || !$this->writeable)? "dummy".rand(0,10000) : $this->postName;
+
         $title = set_post($this->description);  
-        $disabled = (!$this->enabled) ? 'disalbed' : '';
         if(mb_strlen($this->value) == 0){   
             $ret = "<i>"._("No file uploaded yet")."</i>";
             $ret.= "<br> <input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"2000000\">
-                <input id=\"{$this->postName}\" 
-                name=\"{$this->postName}\" 
+                <input id=\"{$name}\" 
+                name=\"{$name}\" 
                 {$disabled}
                 type=\"file\" 
                 size=\"20\" 
                 maxlength=\"255\" 
                 accept=\"*.*\">&nbsp;";
-            $ret.= "<button {$disabled} name='{$this->postName}_Upload'>"._("Upload")."</button>";
+            $ret.= "<button {$disabled} name='{$name}_Upload'>"._("Upload")."</button>";
         }else{
             $ret = "<i>"._("File uploaded").": ".mb_strlen($this->value)." "._("Bytes");
-            $ret.= "&nbsp;<button {$disabled} name='{$this->postName}_Remove'>".msgPool::delButton()."</button>";
+            $ret.= "&nbsp;<button {$disabled} name='{$name}_Remove'>".msgPool::delButton()."</button>";
         }
         return($ret);
     }
index 8e227e218ae3dbec0440a0931a7301d84ca2bbc7..892d4ba3555d7f2d8788c85498cd38dc5bd6f5c1 100644 (file)
@@ -34,7 +34,9 @@ class TemplateWidget_fixedList extends TemplateWidget
 
         // Build up list data
         $this->listWidget->setDeleteable($this->enabled);
-        $disabled = (!$this->enabled)? "disabled" : "";
+        $disabled = (!$this->enabled || !$this->writeable)? "disabled" : "";
+        $name = (!$this->enabled || !$this->writeable)? "dummy".rand(0,10000) : $this->postName;
+
         $data = $this->value;
         foreach($this->value as $key => $name){
             $lData[$key] = array('data' => array($this->values[$name]));
@@ -42,12 +44,12 @@ class TemplateWidget_fixedList extends TemplateWidget
         $this->listWidget->setListData($data, $lData);
         $this->listWidget->update();
         $str .= $this->listWidget->render();
-        $str .= "<select size='1' name='{$this->postName}_Input' {$disabled}>";
+        $str .= "<select size='1' name='{$name}_Input' {$disabled}>";
         foreach($this->getAvailableOptions() as $name => $value){
             $str .= "<option value=\"{$name}\">{$value}</option>\n";
         }
         $str .= "</select>";
-        $str .= "<button name='{$this->postName}_Add' {$disabled}>".msgPool::addButton()."</button>";
+        $str .= "<button name='{$name}_Add' {$disabled}>".msgPool::addButton()."</button>";
         return($str);
     }
 
index 8bf17a07f32a2d96e5479e9abfd5a778214cd74b..de77b6eb1718aa9832ae0f449a06c724217a3982 100644 (file)
@@ -13,7 +13,7 @@ class TemplateWidget_list extends TemplateWidget
         $this->listWidget->setColspecs(array('*'));
         $this->listWidget->setWidth("100%");
         $this->listWidget->setHeight("70px");
-        $this->listWidget->setAcl("rwcdm");
+        $this->listWidget->setAcl("");
     }
 
 
@@ -24,10 +24,16 @@ class TemplateWidget_list extends TemplateWidget
         $this->listWidget->setListData($this->value);
         $this->listWidget->update();
         $str .= $this->listWidget->render();
-        $disabled = (!$this->enabled)? "disabled" : "";
+        $disabled = (!$this->enabled || !$this->writeable)? "disabled" : "";
+        $name = (!$this->enabled || !$this->writeable)? "dummy".rand(0,10000) : $this->postName;
 
-        $str .= "<input type='text' name='{$this->postName}_Input' {$disabled}>";
-        $str .= "<button name='{$this->postName}_Add' {$disabled}>".msgPool::addButton()."</button>";
+        $acls = "";
+        $acls.= ($this->writeable && $this->enabled) ? 'w' : '';
+        $acls.= ($this->readable) ? 'r' : '';
+        $this->listWidget->setAcl($acls);
+
+        $str .= "<input type='text' name='{$name}_Input' {$disabled}>";
+        $str .= "<button name='{$name}_Add' {$disabled}>".msgPool::addButton()."</button>";
         return($str);
     }
 
index 671b4b1340baefc3a4312109777ef6e5f2519e5c..02d2ad0db4e0a6134ab61cf3c982a3944afea430 100644 (file)
@@ -11,7 +11,8 @@ class TemplateWidget_stringLong extends TemplateWidget
         $value = " value=\"{$value}\" ";
         $title = (empty($this->description))?"": " title=\"{$desc}\"";
         
-        $disabled = (!$this->enabled)? "disabled" : "";
+        $disabled = (!$this->enabled || !$this->writeable)? "disabled" : "";
+        $name = (!$this->enabled || !$this->writeable)? "dummy".rand(0,10000) : $name;
         return("<input type='text' style='width:100%;' {$title} {$name} {$value} {$disabled}>");
     }
 }
index ce85384bb1fd79a436c7daee3d5bb8e6e6d92593..b052507e93ea31a6f634d7d2e1a953fb9edb8daa 100644 (file)
@@ -27,6 +27,8 @@ class TemplateWidget_textEditor extends TemplateWidget
         $smarty->assign("write_protect", set_post($this->write_protect));
         $smarty->assign("value", set_post($this->value));
         $smarty->assign("enabled", set_post($this->enabled));
+        $smarty->assign("readable", set_post($this->readable));
+        $smarty->assign("writeable", set_post($this->writeable));
         return($smarty->fetch(get_template_path("TemplateWidget_textEditor.tpl", TRUE, dirname(__FILE__))));
     }
 
index 8ca6ff8387d10d9f807fd2192aa65fd3fe0fae71..0cbd34246bff3a00cb634a3adb8ec7bbdac68b51 100644 (file)
@@ -5,12 +5,14 @@ class TemplateWidget_textarea extends TemplateWidget
     function render()
     {
         $title = set_post($this->description);
-        $disabled = (!$this->enabled)? "disabled" : "";
+
+        $disabled = (!$this->enabled || !$this->writeable)? "disabled" : "";
+        $name = (!$this->enabled || !$this->writeable)? "dummy".rand(0,10000) : $this->postName;
         return("<textarea   title=\"{$title}\"
                             style='width:100%'
                             {$disabled} 
                             rows=4 type='text' 
-                            name=\"{$this->postName}\">".set_post($this->value)."</textarea>");
+                            name=\"{$name}\">".set_post($this->value)."</textarea>");
     }
 
 }