Code

Added acls to fai template entry
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 18 Oct 2006 07:53:04 +0000 (07:53 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 18 Oct 2006 07:53:04 +0000 (07:53 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@4893 594d385d-05f5-0310-b6e9-bd551577e9d8

plugins/admin/fai/class_faiTemplate.inc
plugins/admin/fai/class_faiTemplateEntry.inc
plugins/admin/fai/faiTemplateEntry.tpl

index dd364ccd1a77db288303eee814701cd69eb4bfa2..0c4fa51df2effc68ff5c0c9a0b2c13b199f3a09a 100644 (file)
@@ -136,6 +136,9 @@ class faiTemplate extends plugin
             $obj  = $this->get_object_attributes($obj,$this->sub_Load_Later);
           }
           $this->dialog= new $this->subClassName($this->config,$this->dn,$obj);
+          $this->dialog->set_acl_base($this->acl_base);
+          $this->dialog->set_acl_category("fai");
+
           $_SESSION['objectinfo'] = $obj['dn'];
           $this->dialog->parent = &$this;
           $this->is_dialog=true;
@@ -166,6 +169,8 @@ class faiTemplate extends plugin
 
       if(preg_match("/c/",$acl)){
         $this->dialog= new $this->subClassName($this->config,"new");
+        $this->dialog->set_acl_base($this->acl_base);
+        $this->dialog->set_acl_category("fai");
         $this->is_dialog=true;
       }
     }
@@ -432,7 +437,7 @@ class faiTemplate extends plugin
         if(empty($obj[$attrs])){
           $obj[$attrs] = array();
         }
-        $tmp[$attrs] = stripslashes($obj[$attrs]);
+        $tmp[$attrs] =($obj[$attrs]);
       }    
         
       $tmp['objectClass'] = $this->subClasses;
index a2e9035dfc3cba4676456fa9b2a713259507bfcf..24bab5d1311f3d4239325e13b4e5de9c06ffd68d 100644 (file)
@@ -52,9 +52,16 @@ class faiTemplateEntry extends plugin
     $this->user = explode( '.', $this->FAIowner );
     $this->group = $this->user[1];
     $this->user = $this->user[0];
+
     $_SESSION['binary'] = $this->FAItemplateFile;
     $_SESSION['binarytype'] = 'octet-stream';
     $_SESSION['binaryfile'] = basename( $this->FAItemplatePath );
+
+    if(!empty($this->dn) && $this->dn != "new"){
+      $ldap = $this->config->get_ldap_link();
+      $_SESSION['binary'] =$ldap->get_attribute($this->dn,"FAItemplateFile");
+      $this->FAItemplateFile = $_SESSION['binary'];
+    }
     
     $this->FAImode= sprintf("%0.4s", $this->FAImode)." ";
   }
@@ -70,7 +77,7 @@ class faiTemplateEntry extends plugin
     $smarty->assign("rand", rand(0, 10000));
     $display = "";
 
-    if(isset($_POST['TmpFileUpload'])){
+    if(isset($_POST['TmpFileUpload']) && $this->acl_is_writeable("FAItemplateFile")){
       if($str=file_get_contents($_FILES['FAItemplateFile']['tmp_name'])){
         $this->FAItemplateFile = $str;
 
@@ -90,6 +97,7 @@ class faiTemplateEntry extends plugin
     $bStatus = false; // Hide download icon on default 
     
     if(strlen($this->FAItemplateFile)){
+
       $status= sprintf(_("exists in database (size: %s bytes)"),strlen($this->FAItemplateFile));
       $bStatus = true;  // Display download icon 
     }
@@ -126,11 +134,7 @@ class faiTemplateEntry extends plugin
     $smarty->assign("FAItemplateFile","");
 
     foreach($this->attributes as $attr){
-      if(($this->FAIstate == "freeze") || (chkacl($this->acl,$attr)!= "")){
-        $smarty->assign($attr."ACL"," disabled ");
-      }else{
-        $smarty->assign($attr."ACL","  ");
-      }
+      $smarty->assign($attr."ACL",$this->getacl($attr,preg_match("/freeze/",$this->FAIstate)));
     }
 
     $display.= "<h2><font color='red'>Fix / problen and ensure that size and content are correct if you download this template. Revision > 4582 (gosa-2.5 is already patched)</font></h2>".$smarty->fetch(get_template_path('faiTemplateEntry.tpl', TRUE));
index 4656e4964c7e5568497c4d0ad62d37571b1fa2a0..a047f7a2645bc888ebd15dbef3666c15ede9abe3 100644 (file)
@@ -5,11 +5,15 @@
 <tr>
        <td width="50%">
                {t}Name{/t}{$must}&nbsp;
-               <input value="{$cn}" name="cn" size="45" maxlength="80" {$cnACL}>&nbsp;&nbsp;
+{render acl=$cnACL}
+               <input value="{$cn}" name="cn" size="45" maxlength="80">&nbsp;&nbsp;
+{/render}
        </td>
        <td>
                {t}Description{/t}&nbsp;
-               <input size="45" maxlength="80" value="{$description}" name="description" {$descriptionACL}>
+{render acl=$descriptionACL}
+               <input size="45" maxlength="80" value="{$description}" name="description">
+{/render}
        </td>
 </tr>
 </table>
                <td style="vertical-align:top" class="center">
                        {$status}
                        {if $bStatus}
-                         <a href="getbin.php?rand={$rand}"><img class="center" alt="{t}Save template{/t}..." title="{t}Save template{/t}..." src="images/save.png" border="0" /></a>
+                         <a href="getbin.php?rand={$rand}">
+                               <img class="center" alt="{t}Save template{/t}..." title="{t}Save template{/t}..." src="images/save.png" border="0" />
+                         </a>
                        {/if}
                        <br>
                        <br>
-                       <input type="file" name="FAItemplateFile" value="{$FAItemplateFile}" id="FAItemplateFile" {$FAItemplateFileACL}>
-                       &nbsp;<input type="submit" value="{t}Upload{/t}" name="TmpFileUpload" {$FAItemplateFileACL}>
+{render acl=$FAItemplateFileACL}
+                       <input type="file" name="FAItemplateFile" value="{$FAItemplateFile}" id="FAItemplateFile">
+{/render}
+{render acl=$FAItemplateFileACL}
+                       &nbsp;<input type="submit" value="{t}Upload{/t}" name="TmpFileUpload">
+{/render}
                        <br>
                        <br>
                        </td>
@@ -48,7 +58,9 @@
                                </LABEL>
                                </td>
                        <td>
-                               <input type="text" name="FAItemplatePath" value="{$FAItemplatePath}" id="FAItemplatePath" size="45" {$FAItemplatePathACL}>
+{render acl=$FAItemplatePathACL}
+                               <input type="text" name="FAItemplatePath" value="{$FAItemplatePath}" id="FAItemplatePath" size="45">
+{/render}
                                </td>
                </tr>
                </table>
                        </LABEL>
                        </td>
                <td>
-                       <input type="text" name="user" value="{$user}" id="user" size="15" {$userACL}>
-                       </td>
+{render acl=$userACL}
+                       <input type="text" name="user" value="{$user}" id="user" size="15">
+{/render}
+               </td>
        </tr><tr>
                <td style="vertical-align:top">
                        <LABEL for="group">
                        </LABEL>
                        </td>
                <td>
-                       <input type="text" name="group" value="{$group}" id="group" size="15" {$groupACL}>
+{render acl=$groupACL}
+                       <input type="text" name="group" value="{$group}" id="group" size="15">
+{/render}
                        <br>
                        <br>
-                       </td>
+               </td>
        </tr><tr>
                <td style="vertical-align:top">{t}Access{/t}{$must}&nbsp; </td>
                <td>
                        <th>&nbsp;</th>
                </tr>
                <tr><td>{t}User{/t}</td>
-                       <td align="center"><input type="checkbox" name="u4" value="4" {$u4} {$userACL}></td>
-                       <td align="center"><input type="checkbox" name="u2" value="2" {$u2} {$userACL}></td>
-                       <td align="center"><input type="checkbox" name="u1" value="1" {$u1} {$userACL}></td>
+{render acl=$userACL}
+                       <td align="center"><input type="checkbox" name="u4" value="4" {$u4}></td>
+{/render}
+{render acl=$userACL}
+                       <td align="center"><input type="checkbox" name="u2" value="2" {$u2}></td>
+{/render}
+{render acl=$userACL}
+                       <td align="center"><input type="checkbox" name="u1" value="1" {$u1}></td>
+{/render}
                        <td>&nbsp;</td>
-                       <td align="center"><input type="checkbox" name="s4" value="4" {$s4} {$userACL}></td>
+{render acl=$userACL}
+                       <td align="center"><input type="checkbox" name="s4" value="4" {$s4}></td>
+{/render}
                        <td>({t}SUID{/t})</td>
                        </tr>
 
                <tr><td>{t}Group{/t}</td>
-                       <td align="center"><input type="checkbox" name="g4" value="4" {$g4} {$userACL}></td>
-                       <td align="center"><input type="checkbox" name="g2" value="2" {$g2} {$userACL}></td>
-                       <td align="center"><input type="checkbox" name="g1" value="1" {$g1} {$userACL}></td>
+{render acl=$userACL}
+                       <td align="center"><input type="checkbox" name="g4" value="4" {$g4}></td>
+{/render}
+{render acl=$userACL}
+                       <td align="center"><input type="checkbox" name="g2" value="2" {$g2}></td>
+{/render}
+{render acl=$userACL}
+                       <td align="center"><input type="checkbox" name="g1" value="1" {$g1}></td>
+{/render}
                        <td>&nbsp;</td>
-                       <td align="center"><input type="checkbox" name="s2" value="2" {$s2} {$userACL}></td>
+{render acl=$userACL}
+                       <td align="center"><input type="checkbox" name="s2" value="2" {$s2}></td>
+{/render}
                        <td>({t}SGID{/t})</td>
                        </tr>
 
                <tr><td>{t}Others{/t}</td>
-                       <td align="center"><input type="checkbox" name="o4" value="4" {$o4} {$userACL}></td>
-                       <td align="center"><input type="checkbox" name="o2" value="2" {$o2} {$userACL}></td>
-                       <td align="center"><input type="checkbox" name="o1" value="1" {$o1} {$userACL}></td>
+{render acl=$userACL}
+                       <td align="center"><input type="checkbox" name="o4" value="4" {$o4}></td>
+{/render}
+{render acl=$userACL}
+                       <td align="center"><input type="checkbox" name="o2" value="2" {$o2}></td>
+{/render}
+{render acl=$userACL}
+                       <td align="center"><input type="checkbox" name="o1" value="1" {$o1}></td>
+{/render}
                        <td>&nbsp;</td>
-                       <td align="center"><input type="checkbox" name="s1" value="1" {$s1} {$userACL}></td>
+{render acl=$userACL}
+                       <td align="center"><input type="checkbox" name="s1" value="1" {$s1}></td>
+{/render}
                        <td>({t}sticky{/t})</td>
        </tr></table>