Code

Test
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 22 Apr 2010 14:03:31 +0000 (14:03 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 22 Apr 2010 14:03:31 +0000 (14:03 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@17794 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-core/plugins/generic/references/class_aclResolver.inc
gosa-core/plugins/generic/references/class_reference.inc
gosa-core/plugins/generic/references/contents.tpl

index d65aee1e0f3b0f4edeeeb0cd95efe75e04d804a8..f1145560711aef6719ce87aa94ccaf27d5de18fa 100644 (file)
@@ -14,6 +14,9 @@ class aclResolver
     private $acl_category;
     private $parent;
 
+    // Used for the autocompleter
+    private $userMap;
+
     function __construct($config, $dn, $parent)
     {
         $this->config = &$config;
@@ -111,6 +114,15 @@ class aclResolver
      */    
     function getReadableACL() 
     {
+        if(isset($_POST['aclTarget'])){
+            $d = get_post('aclTarget');
+            if(isset($this->userMap[$d])){
+                $this->validateDn = $this->userMap[$d]['dn'];
+                $this->validateUid = $this->userMap[$d]['uid'][0];
+                $this->renderedList = "";
+            }
+        }
+        
         if(empty($this->renderedList)){
 
             $this->reload();
@@ -159,7 +171,8 @@ class aclResolver
                 "\n </tr>";
 
 
-            $str = "<table summary='"._("Object permissions")."' class='acl-viewer'>";
+            $str = "<br>".sprintf(_("ACL from the viewpoint of user '%s'"), "<b>".$this->validateUid."</b>");
+            $str.= "<table summary='"._("Object permissions")."' class='acl-viewer'>";
             $ldap = $this->config->get_ldap_link();
             $ldap->cd($this->config->current['BASE']);
             $ui = get_userinfo();
@@ -268,6 +281,22 @@ class aclResolver
         }
         return($str."</ul>");
     }
+
+    function processAutocomplete()
+    {
+            $ldap = $this->config->get_ldap_link();
+            $ldap->cd($this->config->current['BASE']);
+            $ldap->search("(&(objectClass=gosaAccount)(|(sn=*".get_post('aclTarget')."*)".
+                    "(uid=*".get_post('aclTarget')."*)(givenName=*".get_post('aclTarget')."*)))",
+                    array('uid','dn','sn','givenName'));
+            echo "<ul>";
+            while($attrs = $ldap->fetch()){
+                $display = $attrs['givenName'][0]." ".$attrs['sn'][0]." [".$attrs['uid'][0]."]";
+                echo "<li>{$display}</li>";
+                $this->userMap[$display] = $attrs;
+            }
+            echo "</ul>";
+    }
 }
 
 ?>
index de7b44f20dc8d9ba279140b024404c343b34f16c..d2a09670e381e14e3c9413fed44630c784461ce1 100644 (file)
@@ -87,6 +87,8 @@ class reference extends plugin
 
         /* Set government mode */
         $smarty= get_smarty();
+        $smarty->assign("usePrototype", "true");
+        session::set('autocomplete', $this->aclResolver);
 
         if (isset($_GET['show'])){
             $dn= base64_decode($_GET['show']);
index ba8193e3f70ba1a2147b3f8c8e3f87d1a8f79af9..e974fb51b76aa15329f34d4fa8c68ad8f8d6a2c5 100644 (file)
             {/if}
         </td>
         <td>
+          <input class='filter_textfield' placeholder='{t}Search{/t}...' 
+            id='aclTarget' name='aclTarget' type='text' value='' 
+            onChange='document.mainform.submit();'>
           <div id='autocomplete' class='autocomplete'></div>
             <script type='text/javascript'>
               new Ajax.Autocompleter(
-                    'bs_input_', 
+                    'aclTarget', 
                     'autocomplete', 
-                    'autocomplete.php?type=base', 
+                    'autocomplete.php', 
                     { minChars: 3, frequency: 0.5 });
             </script>
             {$acls}