Code

Fixed Variable && Template acl settings
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 4 Dec 2006 10:41:49 +0000 (10:41 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 4 Dec 2006 10:41:49 +0000 (10:41 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@5297 594d385d-05f5-0310-b6e9-bd551577e9d8

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

index 0c4fa51df2effc68ff5c0c9a0b2c13b199f3a09a..968561d7ee613794043a01229821c00352141fdc 100644 (file)
@@ -67,6 +67,14 @@ class faiTemplate extends plugin
       $ldap->search("(&(objectClass=FAIclass)(objectClass=".$this->subClass."))",$attrs_to_search);
 
       while($object = $ldap->fetch()){
+
+        /* Skip objects, that are tagged as removed */
+        if(isset($object['FAIstate'][0])){
+          if(preg_match("/removed$/",$object['FAIstate'][0])){
+            continue;
+          }
+        }
+
         /* Set status for save management */
         $objects = array();
         $objects['status']      = "FreshLoaded";
@@ -246,8 +254,13 @@ class faiTemplate extends plugin
 
     $tmp = $this->getList(true);
   
+    /* Create div list with all sub entries listed */
     foreach($this->SubObjects as $key => $name){
 
+      /* Skip removed entries */ 
+      if($name['status'] == "delete") continue;
+
+      /* Get permissions */
       $dn  = $this->acl_base_for_current_object($name['dn']);
       $acl = $this->ui->get_permissions($dn,"fai/faiTemplateEntry")  ;
       $act = "";
index b2a70eec483c172d8a1b654bd46c8c7644446a19..7a3c48ddf370042b058dca626bc8da9956fded21 100644 (file)
@@ -144,40 +144,40 @@ class faiTemplateEntry extends plugin
   /* Save data to object */
   function save_object()
   {
-    if (!isset($_POST['FAItemplatePath'])){
-      return;
-    }
+    /* Check if form is posted and we are not freezed */
     if((isset($_POST['SubObjectFormSubmitted'])) && ($this->FAIstate != "freeze")){
-      foreach($this->attributes as $attrs){
-        if($attrs == "FAItemplateFile") 
-          continue;
-        if($attrs == "FAIowner") {
-          $this->$attrs = $_POST["user"] . '.' . $_POST["group"];
-          continue;
-        }
-        if(isset($_POST[$attrs])){
-          $this->$attrs = $_POST[$attrs];
-        }else{
-          $this->$attrs = "";
-        }
+
+      plugin::save_object();
+
+      /* Set user.group (FAIowner) attribute */  
+      if(isset($_POST['group']) && isset($_POST["user"]) && $this->acl_is_writeable("FAIowner")){
+        $this->FAIowner = $_POST["user"].'.'.$_POST["group"];
+        $this->user = $_POST['user'];
+        $this->group= $_POST['group'];
       }
-      /* Save mode */
-      $tmode= "";
-      foreach (array("s", "u", "g", "o") as $type){
-        $nr= 1;
-        $dest= 0;
-        while ($nr < 5){
-          if (isset($_POST["$type$nr"])){
-            $dest+= $nr;
+
+      /* Check if permissions have changed */
+      if($this->acl_is_writeable("FAImode")){
+
+        /* Save mode */
+        $tmode= "";
+        foreach (array("s", "u", "g", "o") as $type){
+          $nr= 1;
+          $dest= 0;
+          while ($nr < 5){
+            if (isset($_POST["$type$nr"])){
+              $dest+= $nr;
+            }
+            $nr+= $nr;
           }
-          $nr+= $nr;
+          $tmode= $tmode.$dest;
         }
-        $tmode= $tmode.$dest;
+        $this->FAImode= $tmode;
       }
-      $this->FAImode= $tmode;
     }
   }
 
+
   /* Check supplied data */
   function check()
   {
index 12f21d978da0f4794bcc24ea28aeb8ae917ad3e6..60baec911497eab02a7b911977eeb5fda39d0c57 100644 (file)
@@ -210,21 +210,17 @@ class faiVariable extends plugin
     $ret = $this->getList();
     $tmp = array();
     foreach($this->SubObjects as $key => $obj){
-      
       $acl = $ui->get_permissions($obj['dn'],"fai/faiVariableEntry");
-     
       if(preg_match("/r/",$acl)){
         $tmp[$key] = $ret[$key];
       } 
-      
-      $smarty->assign("SubObjects",$tmp);
     }
+    $smarty->assign("SubObjects",$tmp);
 
 
-      /* Magic quotes GPC, escapes every ' " \, to solve some security risks
+    /* Magic quotes GPC, escapes every ' " \, to solve some security risks
      * If we post the escaped strings they will be escaped again
      */
-
     foreach($this->attributes as $attrs){
       if(get_magic_quotes_gpc()){
         $smarty->assign($attrs,htmlentities (stripslashes(utf8_decode($this->$attrs))));
index a047f7a2645bc888ebd15dbef3666c15ede9abe3..c431ab52a8acfb3f6e3c1edd76f4cad3554fb4e4 100644 (file)
@@ -75,7 +75,7 @@
                        </LABEL>
                        </td>
                <td>
-{render acl=$userACL}
+{render acl=$FAIownerACL}
                        <input type="text" name="user" value="{$user}" id="user" size="15">
 {/render}
                </td>
@@ -86,7 +86,7 @@
                        </LABEL>
                        </td>
                <td>
-{render acl=$groupACL}
+{render acl=$FAIownerACL}
                        <input type="text" name="group" value="{$group}" id="group" size="15">
 {/render}
                        <br>
                        <th>&nbsp;</th>
                </tr>
                <tr><td>{t}User{/t}</td>
-{render acl=$userACL}
+{render acl=$FAImodeACL}
                        <td align="center"><input type="checkbox" name="u4" value="4" {$u4}></td>
 {/render}
-{render acl=$userACL}
+{render acl=$FAImodeACL}
                        <td align="center"><input type="checkbox" name="u2" value="2" {$u2}></td>
 {/render}
-{render acl=$userACL}
+{render acl=$FAImodeACL}
                        <td align="center"><input type="checkbox" name="u1" value="1" {$u1}></td>
 {/render}
                        <td>&nbsp;</td>
-{render acl=$userACL}
+{render acl=$FAImodeACL}
                        <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>
-{render acl=$userACL}
+{render acl=$FAImodeACL}
                        <td align="center"><input type="checkbox" name="g4" value="4" {$g4}></td>
 {/render}
-{render acl=$userACL}
+{render acl=$FAImodeACL}
                        <td align="center"><input type="checkbox" name="g2" value="2" {$g2}></td>
 {/render}
-{render acl=$userACL}
+{render acl=$FAImodeACL}
                        <td align="center"><input type="checkbox" name="g1" value="1" {$g1}></td>
 {/render}
                        <td>&nbsp;</td>
-{render acl=$userACL}
+{render acl=$FAImodeACL}
                        <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>
-{render acl=$userACL}
+{render acl=$FAImodeACL}
                        <td align="center"><input type="checkbox" name="o4" value="4" {$o4}></td>
 {/render}
-{render acl=$userACL}
+{render acl=$FAImodeACL}
                        <td align="center"><input type="checkbox" name="o2" value="2" {$o2}></td>
 {/render}
-{render acl=$userACL}
+{render acl=$FAImodeACL}
                        <td align="center"><input type="checkbox" name="o1" value="1" {$o1}></td>
 {/render}
                        <td>&nbsp;</td>
-{render acl=$userACL}
+{render acl=$FAImodeACL}
                        <td align="center"><input type="checkbox" name="s1" value="1" {$s1}></td>
 {/render}
                        <td>({t}sticky{/t})</td>
 </td>
 </tr>
 </table>
+
+<input type='hidden' name='FAItemplateEntryPosted' value='1'>
+
 <!-- Place cursor -->
 <script language="JavaScript" type="text/javascript">
   <!-- // First input field on page