Code

Added optional filter input field. Which does not have any effect yet.
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 21 May 2008 13:41:51 +0000 (13:41 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 21 May 2008 13:41:51 +0000 (13:41 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@10984 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-core/include/class_acl.inc
gosa-core/include/class_userinfo.inc

index b173f68e99baa89a78fae376554b31789a1edc4e..faeac26983282bd7c980f961ce8ed8cc7e0deed6 100644 (file)
@@ -39,6 +39,7 @@ class acl extends plugin
   var $target= "group";
   var $aclTypes= array();
   var $aclObjects= array();
+  var $aclFilter= "";
   var $aclMyObjects= array();
   var $users= array();
   var $roles= array();
@@ -225,7 +226,7 @@ class acl extends plugin
   {
     /* Call parent execute */
     plugin::execute();
-  
+
     $tmp= session::get('plist');
     $plist= $tmp->info;
 
@@ -355,6 +356,7 @@ class acl extends plugin
       $this->gosaAclEntry[$this->currentIndex]['type']= $this->aclType;
       $this->gosaAclEntry[$this->currentIndex]['members']= $this->recipients;
       $this->gosaAclEntry[$this->currentIndex]['acl']= $this->aclContents;
+      $this->gosaAclEntry[$this->currentIndex]['filter']= $this->aclFilter;
       $this->dialogState= 'head';
       $this->dialog= FALSE;
     }
@@ -406,7 +408,7 @@ class acl extends plugin
     }
 
     /* Save common values */
-    foreach (array("aclType", "aclObject", "target") as $key){
+    foreach (array("aclType","aclFilter", "aclObject", "target") as $key){
       if (isset($_POST[$key])){
         $this->$key= validate($_POST[$key]);
       }
@@ -477,6 +479,7 @@ class acl extends plugin
 
       $smarty->assign("aclList", $aclList->DrawList());
       $smarty->assign("aclType", $this->aclType);
+      $smarty->assign("aclFilter", $this->aclFilter);
       $smarty->assign("aclTypes", $this->aclTypes);
       $smarty->assign("target", $this->target);
       $smarty->assign("targets", $this->targets);
@@ -801,8 +804,18 @@ class acl extends plugin
 
   static function explodeACL($acl)
   {
-    list($index, $type)= split(':', $acl);
+
+    $list= split(':', $acl);
+    if(count($list) == 5){
+      list($index, $type,$member,$permission,$filter)= $list;
+      $filter = base64_decode($filter);
+    }else{
+      $filter = "";
+      list($index, $type,$member,$permission)= $list;
+    }
+
     $a= array( $index => array("type" => $type,
+                               "filter"=> $filter,
                                "members" => acl::extractMembers($acl,$type == "role")));
    
     /* Handle different types */
@@ -877,7 +890,7 @@ class acl extends plugin
   static function extractACL($acl)
   {
     /* Rip acl off the string, seperate by ',' and place it in an array */
-    $as= preg_replace('/^[^:]+:[^:]+:[^:]*:(.*)$/', '\1', $acl);
+    $as= preg_replace('/^[^:]+:[^:]+:[^:]*:([^:]*).*$/', '\1', $acl);
     $aa= split(',', $as);
     $a= array();
 
@@ -963,6 +976,7 @@ class acl extends plugin
     /* New entry gets presets... */
     if ($new){
       $this->aclType= 'base';
+      $this->aclFilter= "";
       $this->recipients= array();
       $this->aclContents= array();
     } else {
@@ -970,6 +984,7 @@ class acl extends plugin
       $this->aclType= $acl['type'];
       $this->recipients= $acl['members'];
       $this->aclContents= $acl['acl'];
+      $this->aclFilter= $acl['filter'];
     }
 
     $this->wasNewEntry= $new;
@@ -1001,6 +1016,7 @@ class acl extends plugin
   {
     /* Assemble ACL's */
     $tmp_acl= array();
+  
     foreach ($this->gosaAclEntry as $prio => $entry){
       $final= "";
       $members= "";
@@ -1044,6 +1060,12 @@ class acl extends plugin
         $final.= preg_replace('/,$/', '', $acl);
       }
 
+      /* Append additional filter options 
+       */
+      if(!empty($entry['filter'])){
+        $final .= ":".base64_encode($entry['filter']);
+      }
+
       $tmp_acl[]= $final;
     } 
 
index c1263330cef07987f05014760159e37de477dae1..0719927c152b6612030f4ea7fa4a3d14839fad84 100644 (file)
@@ -210,7 +210,7 @@ class userinfo
 
     /* Push cache answer? */
     $ACL_CACHE = &session::get('ACL_CACHE');
-    if (isset($ACL_CACHE["$dn+$object+$attribute"])){
+    if (0 && isset($ACL_CACHE["$dn+$object+$attribute"])){
 
       /* Remove write if needed */
       if ($skip_write){
@@ -221,6 +221,10 @@ class userinfo
       return($ret);
     }
 
+    /* Get ldap object, for later filter checks 
+     */
+    $ldap = $this->config->get_ldap_link();
+
     $acl= array("r" => "", "w" => "", "c" => "", "d" => "", "m" => "", "a" => "");
 
     /* Build dn array */
@@ -255,7 +259,31 @@ class userinfo
             continue;
           }
 
-          /* Per attribute ACL? */
+#         /* With user filter */
+#         $sdn = preg_replace("/^[^,]*+,/","",$dn);
+#         if (isset($subacl['filter']) && !empty($subacl['filter'])){
+#
+#           $ldap->cd($sdn);
+#           $ldap->ls($subacl['filter'],$sdn);
+#           if(!$ldap->count()){
+#             continue;
+#           }else{
+#             $found = FALSE; 
+#             while($attrs = $ldap->fetch()){
+#               echo $attrs['dn']."<br>";
+#               if($attrs['dn'] == $dn){
+#                 $found = TRUE;
+#                 echo $acl."<br>";;
+#                 break;
+#               }
+#             }
+#             if(!$found){
+#               continue;
+#             }
+#           }
+#         }
+
+         /* Per attribute ACL? */
           if (isset($subacl['acl'][$object][$attribute])){
             $acl= $this->mergeACL($acl, $subacl['type'], $subacl['acl'][$object][$attribute]);
             continue;