Code

Updated acl resolver and the reference tab
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 22 Apr 2010 12:52:09 +0000 (12:52 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 22 Apr 2010 12:52:09 +0000 (12:52 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@17793 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 978b248d22386a1642cde3d1fcac041630a4a569..d65aee1e0f3b0f4edeeeb0cd95efe75e04d804a8 100644 (file)
@@ -11,22 +11,20 @@ class aclResolver
     // The users 'dn' and 'uid' used to verify the collected acls
     private $validateDn;
     private $validateUid;
+    private $acl_category;
+    private $parent;
 
     function __construct($config, $dn, $parent)
     {
         $this->config = &$config;
         $this->dn = $dn;
+        $this->parent = $parent;
 
         // Replace this with a user defined one later.
         $ui = get_userinfo();
         $this->validateUid = $ui->uid;
         $this->validateDn = $ui->dn;
 
-        // Get ACL category for the current object.
-        if(isset($parent->acl_category) && !empty($parent->acl_category)){
-            $this->acl_category = preg_replace("/\/$/","",$parent->acl_category);
-        }
-
         // Build class mapping - only once, will not change during session.
         if(!session::is_set('aclConverter::classMapping')){
             $tmp= session::global_get('plist');
@@ -65,8 +63,9 @@ class aclResolver
                 "sub" => _("Complete subtree"),
                 "psub" => _("Complete subtree (permanent)"),
                 "role" => _("Use ACL defined in role"));
-
-        $this->reload();
+    
+        // Enforce to reload acl result 
+        $this->renderedList = "";
     }
 
     
@@ -77,6 +76,11 @@ class aclResolver
         $ui->reset_acl_cache();
         $ui->loadACL();
 
+        // Get ACL category for the current object.
+        if(isset($this->parent->acl_category) && !empty($this->parent->acl_category)){
+            $this->acl_category = preg_replace("/\/$/","",$this->parent->acl_category);
+        }
+
         foreach($ui->allACLs as $dn => $acls){
             if(preg_match("/".preg_quote($dn,'/')."$/i", $this->dn)){
 
@@ -99,9 +103,6 @@ class aclResolver
                 }
             }
         }
-
-        // Enforce to reload acl result 
-        $this->renderedList = "";
     }
     
 
@@ -112,6 +113,8 @@ class aclResolver
     {
         if(empty($this->renderedList)){
 
+            $this->reload();
+
             // Base template - each entry start with this 
             $tpl = 
                 "\n <tr class='acl-viewer-head %s'>".
@@ -268,4 +271,3 @@ class aclResolver
 }
 
 ?>
-
index db662408cbb44559b12ad4d461a7a98ceb860c58..de7b44f20dc8d9ba279140b024404c343b34f16c 100644 (file)
 
 class reference extends plugin
 {
-  /* attribute list for save action */
-  var $attributes= array();
-  var $objectclasses= array();
-  var $objectlist= "";
-  var $obtypes= array();
-  var $fold= array();
-  var $objectCache= array();
-
-  function reference (&$config, $dn= NULL)
-  {
-    /* Include config object */
-    $this->config= &$config;
-    $this->dn= $dn;
-
-    /* Fill translation array */
-    $this->obtypes= array(  
-        "gosaAccount" => array(           "text" => _("Generic"),
-          "image" => "images/penguin.png"),
-        "posixAccount" => array(   "text" =>_("UNIX"),
-          "image" => "plugins/users/images/select_user.png"),
-        "gosaMailAccount" => array("text" => _("Mail"),
-          "image" => "images/mailto.png"),
-        "sambaSamAccount" => array("text" => _("Samba"),
-          "image" => "plugins/systems/images/select_winstation.png"),
-        "sambaAccount" => array(   "text" => _("Samba"),
-          "image" => "plugins/sysmtes/images/select_winstation.png"),
-        "goFaxAccount" => array(   "text" => _("FAX"),
-          "image" => "plugins/gofax/images/fax_small.png"),
-        "gosaProxyAccount" => array("text" => _("Proxy"),
-          "image" => "images/select_proxy.png"),
-        "PureFTPdUser" => array(   "text" => _("FTP"),
-          "image" => "images/select_proxy.png"),
-        "posixGroup" => array(     "text" => _("Group"),
-          "image" => "plugins/groups/images/select_group.png"),
-        "gosaDepartment" => array( "text" => _("Department"),
-          "image" => "images/select_department.png"),
-        "goFonHardware" => array(   "text" => _("Phone"),
-            "image" => "plugins/systems/images/select_phone.png"),
-        "gosaApplication" => array("text" => _("Application"),
-            "image" => "plugins/goto/images/select_application.png"),
-        "goServer" => array(      "text" => _("Server"),
-            "image" => "plugins/systems/images/select_server.png"),
-        "gotoTerminal" => array(   "text" => _("Thin Client"),
-            "image" => "images/select_terminal.png"),
-        "gotoWorkstation" => array("text" => _("Workstation"),
-            "image" => "plugins/systems/images/select_workstation.png"),
-        "gosaGroupOfNames" => array("text" => _("Object group"),
-            "image" => "plugins/ogroups/images/select_ogroup.png"),
-        "gotoPrinter" => array(           "text" => _("Printer"),
-            "image" => "plugins/systems/images/select_printer.png"));
-  }
-
-  function execute()
-  {
-    /* Call parent execute */
-    plugin::execute();
-
-    // ACL's we have
-    $ui = get_userinfo();
-    
-
-
-    /* Set government mode */
-    $smarty= get_smarty();
-
-    if (isset($_GET['show'])){
-      $dn= base64_decode($_GET['show']);
-      if (isset($this->fold["$dn"])){
-        unset($this->fold["$dn"]);
-      } else {
-        $this->fold["$dn"]= "$dn";
-      }
+    /* attribute list for save action */
+    var $attributes= array();
+    var $objectclasses= array();
+    var $objectlist= "";
+    var $obtypes= array();
+    var $fold= array();
+    var $objectCache= array();
+    var $aclResolver = NULL;
+
+    function reference (&$config, $dn= NULL)
+    {
+        /* Include config object */
+        $this->config= &$config;
+        $this->dn= $dn;
+        $this->aclResolver = new aclResolver($this->config, $this->dn, $this);
+
+        /* Fill translation array */
+        $this->obtypes= array(  
+                "gosaAccount" => array(           "text" => _("Generic"),
+                    "image" => "images/penguin.png"),
+                "posixAccount" => array(   "text" =>_("UNIX"),
+                    "image" => "plugins/users/images/select_user.png"),
+                "gosaMailAccount" => array("text" => _("Mail"),
+                    "image" => "images/mailto.png"),
+                "sambaSamAccount" => array("text" => _("Samba"),
+                    "image" => "plugins/systems/images/select_winstation.png"),
+                "sambaAccount" => array(   "text" => _("Samba"),
+                    "image" => "plugins/sysmtes/images/select_winstation.png"),
+                "goFaxAccount" => array(   "text" => _("FAX"),
+                    "image" => "plugins/gofax/images/fax_small.png"),
+                "gosaProxyAccount" => array("text" => _("Proxy"),
+                    "image" => "images/select_proxy.png"),
+                "PureFTPdUser" => array(   "text" => _("FTP"),
+                    "image" => "images/select_proxy.png"),
+                "posixGroup" => array(     "text" => _("Group"),
+                    "image" => "plugins/groups/images/select_group.png"),
+                "gosaDepartment" => array( "text" => _("Department"),
+                    "image" => "images/select_department.png"),
+                "goFonHardware" => array(   "text" => _("Phone"),
+                        "image" => "plugins/systems/images/select_phone.png"),
+                "gosaApplication" => array("text" => _("Application"),
+                        "image" => "plugins/goto/images/select_application.png"),
+                "goServer" => array(      "text" => _("Server"),
+                        "image" => "plugins/systems/images/select_server.png"),
+                "gotoTerminal" => array(   "text" => _("Thin Client"),
+                        "image" => "images/select_terminal.png"),
+                "gotoWorkstation" => array("text" => _("Workstation"),
+                        "image" => "plugins/systems/images/select_workstation.png"),
+                "gosaGroupOfNames" => array("text" => _("Object group"),
+                        "image" => "plugins/ogroups/images/select_ogroup.png"),
+                "gotoPrinter" => array(           "text" => _("Printer"),
+                        "image" => "plugins/systems/images/select_printer.png"));
+
     }
 
-    /* Fill array */
-    $this->reload();
-    $smarty->assign("objectList", $this->objectlist);
-    $r = new aclResolver($this->config, $this->dn, $this);
-    $smarty->assign("acls",$r->getReadableACL());
-
-    /* Show main page */
-    return ($smarty->fetch (get_template_path('contents.tpl', TRUE, dirname(__FILE__))));
-  }
-
-  function reload()
-  {
-    $ldap= $this->config->get_ldap_link();
-    $ldap->cd($this->config->current['BASE']);
-
-    $ldap->search(
-        "(|(gotoHotplugDeviceDN=".LDAP::prepare4filter($this->dn).")".
-        "(member=".LDAP::prepare4filter($this->dn).")(memberUid=".$this->uid."))",
-        array("memberUid","member","cn","description","objectClass"));
-
-    $cycle= array("F5F5F5", "ECECEC");
-    $id= 0;
-    $this->objectlist= "";
-    while ($attrs= $ldap->fetch()){
-
-      /* Add more information? */
-      $addon= "";
-      if (in_array($attrs['dn'], $this->fold)){
-        $memberattr= "";
-        if (isset($attrs['memberUid'])){
-          unset($attrs['memberUid']['count']);
-          $memberattr= "memberUid";
-        } 
-        if (isset($attrs['member'])){
-          unset($attrs['member']['count']);
-          $memberattr= "member";
-        } 
-        if ($memberattr == ""){
-          continue;
-        }
-        foreach ($attrs[$memberattr] as $uid){
-          $content= $this->getCacheObject($uid);
-          if ($content === NULL) {
-            continue;
-          }
-          $addon.= 
-            ' <tr style="background-color:'.$cycle[$id&1].';"> '.
-            '   <td title="'.$attrs['cn'][0].'">&nbsp;&nbsp;&nbsp;'.$content['name'].'</td>'.
-            '   <td>'.$content['description'].'</td>'.
-            '   <td>'.$content['type'].'</td> '.
-            ' </tr>';
+    function execute()
+    {
+        /* Call parent execute */
+        plugin::execute();
+
+        // ACL's we have
+        $ui = get_userinfo();
+
+        /* Set government mode */
+        $smarty= get_smarty();
+
+        if (isset($_GET['show'])){
+            $dn= base64_decode($_GET['show']);
+            if (isset($this->fold["$dn"])){
+                unset($this->fold["$dn"]);
+            } else {
+                $this->fold["$dn"]= "$dn";
+            }
         }
-      }
-
-      /* Build final entry */
-      if (isset($attrs['description'])){
-        $description= $attrs['description'][0];
-      } else {
-        $description= "-";
-      }
-      $content= $this->createContentString($attrs['objectClass']);
-      if ($addon == ""){
-        $img= "images/lists/expand.png";
-      } else {
-        $img= "images/lists/sort-down.png";
-      }
-
-      $this->objectlist.= 
-        ' <tr style="background-color:'.$cycle[$id&1].';">  '.
-        '   <td class="phonelist" title="'.$attrs['cn'][0].'">  '.
-        '     '.image($img).
-        '     <a href="main.php?plug='.$_GET['plug'].'&amp;start=&amp;show='.base64_encode($attrs['dn']).'"> '.
-        '     &nbsp;'.$attrs['cn'][0].
-        '     </a> '.
-        '   </td> '.
-        '   <td>'.
-        '     <a href="main.php?plug='.$_GET['plug'].'&amp;start=&amp;show='.base64_encode($attrs['dn']).'"> '.
-        $description.
-        '     </a> '.
-        '   </td> '.
-        '   <td>'.$content.'</td> '.
-        ' </tr>'.$addon;
-      $id++;
+
+        /* Fill array */
+        $this->reload();
+        $smarty->assign("objectList", $this->objectlist);
+        $smarty->assign("acls",$this->aclResolver->getReadableACL());
+
+        /* Show main page */
+        return ($smarty->fetch (get_template_path('contents.tpl', TRUE, dirname(__FILE__))));
     }
 
-  }
-
-  function getCacheObject($dn)
-  {
-    if (!isset($this->objectCache[$dn])){
-      $ldap= $this->config->get_ldap_link();
-      if (preg_match('/,/', $dn)){
-        $ldap->cat($dn, array("cn", "objectClass", "description","ou"));
-      } else {
-        $ldap->search("(uid=$dn)", array("cn", "objectClass", "description","ou"));
-      }
-      if ($ldap->count()){
-        $attrs= $ldap->fetch();
-
-        if(isset($attrs['ou']) && !isset($attrs['cn'])){
-          $attrs['cn'] = $attrs['ou'];
+
+    function reload()
+    {
+        $ldap= $this->config->get_ldap_link();
+        $ldap->cd($this->config->current['BASE']);
+
+        $ldap->search(
+                "(|(gotoHotplugDeviceDN=".LDAP::prepare4filter($this->dn).")".
+                "(member=".LDAP::prepare4filter($this->dn).")(memberUid=".$this->uid."))",
+                array("memberUid","member","cn","description","objectClass"));
+
+        $cycle= array("F5F5F5", "ECECEC");
+        $id= 0;
+        $this->objectlist= "";
+        while ($attrs= $ldap->fetch()){
+
+            /* Add more information? */
+            $addon= "";
+            if (in_array($attrs['dn'], $this->fold)){
+                $memberattr= "";
+                if (isset($attrs['memberUid'])){
+                    unset($attrs['memberUid']['count']);
+                    $memberattr= "memberUid";
+                } 
+                if (isset($attrs['member'])){
+                    unset($attrs['member']['count']);
+                    $memberattr= "member";
+                } 
+                if ($memberattr == ""){
+                    continue;
+                }
+                foreach ($attrs[$memberattr] as $uid){
+                    $content= $this->getCacheObject($uid);
+                    if ($content === NULL) {
+                        continue;
+                    }
+                    $addon.= 
+                        ' <tr style="background-color:'.$cycle[$id&1].';"> '.
+                        '   <td title="'.$attrs['cn'][0].'">&nbsp;&nbsp;&nbsp;'.$content['name'].'</td>'.
+                        '   <td>'.$content['description'].'</td>'.
+                        '   <td>'.$content['type'].'</td> '.
+                        ' </tr>';
+                }
+            }
+
+            /* Build final entry */
+            if (isset($attrs['description'])){
+                $description= $attrs['description'][0];
+            } else {
+                $description= "-";
+            }
+            $content= $this->createContentString($attrs['objectClass']);
+            if ($addon == ""){
+                $img= "images/lists/expand.png";
+            } else {
+                $img= "images/lists/sort-down.png";
+            }
+
+            $this->objectlist.= 
+                ' <tr style="background-color:'.$cycle[$id&1].';">  '.
+                '   <td class="phonelist" title="'.$attrs['cn'][0].'">  '.
+                '     '.image($img).
+                '     <a href="main.php?plug='.$_GET['plug'].'&amp;start=&amp;show='.base64_encode($attrs['dn']).'"> '.
+                '     &nbsp;'.$attrs['cn'][0].
+                '     </a> '.
+                '   </td> '.
+                '   <td>'.
+                '     <a href="main.php?plug='.$_GET['plug'].'&amp;start=&amp;show='.base64_encode($attrs['dn']).'"> '.
+                $description.
+                '     </a> '.
+                '   </td> '.
+                '   <td>'.$content.'</td> '.
+                ' </tr>'.$addon;
+            $id++;
         }
 
-        if (isset($attrs['description'])){
-          $description= $attrs['description'][0];
-        } else {
-          $description= "-";
+    }
+
+    function getCacheObject($dn)
+    {
+        if (!isset($this->objectCache[$dn])){
+            $ldap= $this->config->get_ldap_link();
+            if (preg_match('/,/', $dn)){
+                $ldap->cat($dn, array("cn", "objectClass", "description","ou"));
+            } else {
+                $ldap->search("(uid=$dn)", array("cn", "objectClass", "description","ou"));
+            }
+            if ($ldap->count()){
+                $attrs= $ldap->fetch();
+
+                if(isset($attrs['ou']) && !isset($attrs['cn'])){
+                    $attrs['cn'] = $attrs['ou'];
+                }
+
+                if (isset($attrs['description'])){
+                    $description= $attrs['description'][0];
+                } else {
+                    $description= "-";
+                }
+                $this->objectCache[$dn]= array(        'name' => $attrs['cn'][0],
+                        'description' => "$description",
+                        'type' => $this->createContentString($attrs['objectClass']));
+            } else {
+                return NULL;
+            }
         }
-        $this->objectCache[$dn]= array(        'name' => $attrs['cn'][0],
-            'description' => "$description",
-            'type' => $this->createContentString($attrs['objectClass']));
-      } else {
-        return NULL;
-      }
+        return ($this->objectCache[$dn]);
     }
-    return ($this->objectCache[$dn]);
-  }
-
-  function createContentString($classes)
-  {
-    $result= "";
-    if(!is_null($classes)) {
-      foreach ($classes as $class){
-        if (isset($this->obtypes[$class])){
-          $result.= 
-            " ".image($this->obtypes[$class]['image']).
-            " <a>".
-            "   ".$this->obtypes[$class]['text'].
-            " </a> ";
+
+    function createContentString($classes)
+    {
+        $result= "";
+        if(!is_null($classes)) {
+            foreach ($classes as $class){
+                if (isset($this->obtypes[$class])){
+                    $result.= 
+                        " ".image($this->obtypes[$class]['image']).
+                        " <a>".
+                        "   ".$this->obtypes[$class]['text'].
+                        " </a> ";
+                }
+            }
         }
-      }
+        return (preg_replace('/ $/', '', $result));
     }
-    return (preg_replace('/ $/', '', $result));
-  }
 
 }
 
index 6550d8b60ecde2e620add48f9ee8a860dea5ba97..ba8193e3f70ba1a2147b3f8c8e3f87d1a8f79af9 100644 (file)
             {/if}
         </td>
         <td>
+          <div id='autocomplete' class='autocomplete'></div>
+            <script type='text/javascript'>
+              new Ajax.Autocompleter(
+                    'bs_input_', 
+                    'autocomplete', 
+                    'autocomplete.php?type=base', 
+                    { minChars: 3, frequency: 0.5 });
+            </script>
             {$acls}
         </td>
     </tr>