6 commits - lib/api lib/ext lib/locale public_html/js

Jeroen van Meeuwen vanmeeuwen at kolabsys.com
Fri Aug 1 21:01:30 CEST 2014


 lib/api/kolab_api_service_ous.php      |    2 +
 lib/api/kolab_api_service_resource.php |   44 ++++++++++++------------
 lib/ext/Net/LDAP3.php                  |   59 ++++++++++++++++-----------------
 lib/locale/en_US.php                   |   12 ++++--
 public_html/js/kolab_admin.js          |   37 +++++++++++++-------
 5 files changed, 86 insertions(+), 68 deletions(-)

New commits:
commit 52d4a612083ed8ba413dd9a1939c9ae3cfbe77a7
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date:   Fri Aug 1 21:01:13 2014 +0200

    Allow multiple VLV configurations for the same base dn

diff --git a/lib/ext/Net/LDAP3.php b/lib/ext/Net/LDAP3.php
index bddfb7a..e0180bb 100644
--- a/lib/ext/Net/LDAP3.php
+++ b/lib/ext/Net/LDAP3.php
@@ -1837,41 +1837,40 @@ class Net_LDAP3
 
         $filter = strtolower($filter);
 
-        if (!empty($vlv_indexes[$base_dn])) {
-            $this->_debug("Found a VLV for base_dn: " . $base_dn);
-            if ($vlv_indexes[$base_dn]['filter'] == $filter) {
-                if ($vlv_indexes[$base_dn]['scope'] == $scope) {
-                    $this->_debug("Scope and filter matches");
-
-                    // Not passing any sort attributes means you don't care
-                    if (!empty($sort_attrs)) {
-                        $sort_attrs = (array) $sort_attrs;
-                        if (count(array_intersect($sort_attrs, $vlv_indexes[$base_dn]['sort'])) == count($sort_attrs)) {
-                            return $sort_attrs;
+        foreach ($vlv_indexes as $vlv_index) {
+            if (!empty($vlv_index[$base_dn])) {
+                $this->_debug("Found a VLV for base_dn: " . $base_dn);
+                if ($vlv_index[$base_dn]['filter'] == $filter) {
+                    if ($vlv_index[$base_dn]['scope'] == $scope) {
+                        $this->_debug("Scope and filter matches");
+
+                        // Not passing any sort attributes means you don't care
+                        if (!empty($sort_attrs)) {
+                            $sort_attrs = (array) $sort_attrs;
+                            if (count(array_intersect($sort_attrs, $vlv_index[$base_dn]['sort'])) == count($sort_attrs)) {
+                                return $sort_attrs;
+                            }
+                            else {
+                                return false;
+                            }
                         }
                         else {
-                            return false;
+                            return $vlv_index[$base_dn]['sort'][0];
                         }
                     }
                     else {
-                        return $vlv_indexes[$base_dn]['sort'][0];
+                        $this->_debug("Scope does not match. VLV: " . var_export($vlv_index[$base_dn]['scope'], true)
+                            . " while looking for " . var_export($scope, true));
+                        return false;
                     }
                 }
                 else {
-                    $this->_debug("Scope does not match. VLV: " . var_export($vlv_indexes[$base_dn]['scope'], true)
-                        . " while looking for " . var_export($scope, true));
-                    return false;
+                    $this->_debug("Filter does not match");
                 }
             }
-            else {
-                $this->_debug("Filter does not match");
-                return false;
-            }
-        }
-        else {
-            $this->_debug("No VLV for base dn", $base_dn);
-            return false;
         }
+
+        return false;
     }
 
     /**
@@ -1948,11 +1947,13 @@ class Net_LDAP3
                 $_vlv_sort[] = explode(' ', $vlv_index_attrs['vlvsort']);
             }
 
-            $this->_vlv_indexes_and_searches[$_vlv_base_dn] = array(
-                'scope'  => self::scopeint2str($_vlv_scope),
-                'filter' => strtolower($_vlv_filter),
-                'sort'   => $_vlv_sort,
-            );
+            $this->_vlv_indexes_and_searches[] = array(
+                    $_vlv_base_dn => array(
+                            'scope'  => self::scopeint2str($_vlv_scope),
+                            'filter' => strtolower($_vlv_filter),
+                            'sort'   => $_vlv_sort,
+                        ),
+                );
         }
 
         // cache this


commit da73d1841cac84057b85e16004bbaf5f6e4f1fbe
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date:   Fri Aug 1 17:17:32 2014 +0200

    Hide the epoch field that is not yet implemented

diff --git a/public_html/js/kolab_admin.js b/public_html/js/kolab_admin.js
index ed4feb7..8c3df3c 100644
--- a/public_html/js/kolab_admin.js
+++ b/public_html/js/kolab_admin.js
@@ -1862,7 +1862,8 @@ function kolab_admin()
         .on('change', function() {
           rights_div[$(this).val() == 'custom' ? 'show' : 'hide']();
         }),
-      epoch_input = $('<input id="acl-epoch" type="text" size="13" />'),
+// Not yet implemented
+//      epoch_input = $('<input id="acl-epoch" type="text" size="13" />'),
       subjects = 'user,anyone,anonymous'.split(','),
       options = 'all,read-only,read-write,semi-full,full,custom'.split(','),
       rights = 'l,r,s,w,i,p,k,x,t,n,e,a'.split(',');
@@ -1886,8 +1887,9 @@ function kolab_admin()
     $('td.value', rows[0]).append(subject_select).append(subject_input);
     $('td.label', rows[1]).text(this.t('acl.rights'));
     $('td.value', rows[1]).append(select).append(rights_div.append(spans));
-    $('td.label', rows[2]).text(this.t('acl.expire'));
-    $('td.value', rows[2]).append(epoch_input);
+// Not yet implemented
+//    $('td.label', rows[2]).text(this.t('acl.expire'));
+//    $('td.value', rows[2]).append(epoch_input);
 
     dialog.hide().appendTo('body');
 
@@ -1896,12 +1898,13 @@ function kolab_admin()
     // reset form elements
     subject_select.val(acl.subject.match(/^(anyone|anonymous)$/i) ? acl.subject : 'user').change();
     subject_input.val(subject_select.val() == 'user' ? acl.subject : '');
-    epoch_input.val(this.unix_to_date(acl.epoch, true));
+// Not yet implemented
+/*    epoch_input.val(this.unix_to_date(acl.epoch, true));
     epoch_input.datetimepicker({
       lang: 'en',
       format: 'Y-m-d H:i'
     });
-
+*/
     var v = $.inArray(acl.rights, options) != -1 ? acl.rights : 'custom';
     select.val(v).change();
     $.each(rights, function() {
@@ -1927,7 +1930,8 @@ function kolab_admin()
       user_input = $('#acl-subject-user'),
       user = $.trim(user_input.val()),
       rights = $('#acl-type').val(),
-      epoch = $.trim($('#acl-epoch').val()),
+// Not yet implemented
+//      epoch = $.trim($('#acl-epoch').val()),
       acl_list = $('#acl' + this.acl_dialog_name);
 
     // sanity checks
@@ -1962,7 +1966,8 @@ function kolab_admin()
       }
     }
 
-    if (epoch) {
+// Not yet implemented
+/*    if (epoch) {
       if (epoch.match(/^([0-9]{4})-([0-9]{2})-([0-9]{2}) ([0-9]{2}):([0-9]{2})$/))
         epoch = Date.UTC(RegExp.$1, RegExp.$2 - 1, RegExp.$3, RegExp.$4, RegExp.$5) / 1000;
       else if (epoch.match(/^([0-9]{4})-([0-9]{2})-([0-9]{2})$/))
@@ -1972,8 +1977,10 @@ function kolab_admin()
         return false;
       }
     }
+*/
 
-    acl = {subject: subject, rights: rights, epoch: epoch};
+//    acl = {subject: subject, rights: rights, epoch: epoch};
+    acl = {subject: subject, rights: rights};
 
     // this.log(acl);
     // this.log(this.build_acl([acl]));
@@ -3145,8 +3152,11 @@ function kolab_admin()
       // Syntax subject, rights[, epoch]
       var entry = self.explode_quoted_str(str, ',');
 
-      if (entry.length == 2 || entry.length == 3)
-        acl.push({subject: entry[0], rights: entry[1], epoch: entry[2] || 0});
+      if (entry.length == 2 || entry.length == 3) {
+// Not yet implemented
+//        acl.push({subject: entry[0], rights: entry[1], epoch: entry[2] || 0});
+        acl.push({subject: entry[0], rights: entry[1] || 0});
+      }
     });
 
     return acl;
@@ -3169,8 +3179,9 @@ function kolab_admin()
 
       tokens.push(subject);
       tokens.push(entry.rights);
-      if (entry.epoch)
-        tokens.push(entry.epoch);
+// Not yet implemented
+//      if (entry.epoch)
+//        tokens.push(entry.epoch);
 
       result.push(tokens.join(', '));
     });


commit d2c15c8de68cab0b07f9c0590e8fefe8c9c219bb
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date:   Fri Aug 1 17:17:08 2014 +0200

    Add additional labels

diff --git a/lib/locale/en_US.php b/lib/locale/en_US.php
index e36977d..5a44634 100644
--- a/lib/locale/en_US.php
+++ b/lib/locale/en_US.php
@@ -56,12 +56,16 @@ $LANG['aci.thisentry'] = 'This entry';
 $LANG['aci.selected'] = 'all selected';
 $LANG['aci.other'] = 'all except selected';
 
-$LANG['acl.read'] = 'read';
-$LANG['acl.write'] = 'write';
-$LANG['acl.post'] = 'post';
-$LANG['acl.append'] = 'append';
 $LANG['acl.all'] = 'all';
+$LANG['acl.append'] = 'append';
 $LANG['acl.custom'] = 'custom...';
+$LANG['acl.full'] = 'Full (without access control)';
+$LANG['acl.post'] = 'post';
+$LANG['acl.read'] = 'read';
+$LANG['acl.read-only'] = 'Read-Only';
+$LANG['acl.read-write'] = 'Read/Write';
+$LANG['acl.semi-full'] = 'Write new items';
+$LANG['acl.write'] = 'write';
 $LANG['acl.l'] = 'Lookup';
 $LANG['acl.r'] = 'Read messages';
 $LANG['acl.s'] = 'Keep Seen state';


commit fe46c72139e6f717ea30ef15405405dac0a8bd8e
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date:   Fri Aug 1 17:16:15 2014 +0200

    Find a resource

diff --git a/lib/api/kolab_api_service_resource.php b/lib/api/kolab_api_service_resource.php
index f5d095f..7fa454b 100644
--- a/lib/api/kolab_api_service_resource.php
+++ b/lib/api/kolab_api_service_resource.php
@@ -146,21 +146,31 @@ class kolab_api_service_resource extends kolab_api_service
     }
 
     /**
-     * User information.
+     * Find resource and return its data.
+     * It is a combination of resource.info and resources.list with search capabilities
+     * If the search returns only one record we'll return resource data.
      *
      * @param array $get   GET parameters
      * @param array $post  POST parameters
      *
-     * @return array|bool User attributes, False on error
+     * @return array|bool Resource attributes, False on error
      */
-    public function resource_info($getdata, $postdata)
+    public function resource_find($get, $post)
     {
-        if (!isset($getdata['id'])) {
+        $auth       = Auth::get_instance();
+        $attributes = array('');
+        $params     = array('page_size' => 2);
+        $search     = $this->parse_list_search($post);
+
+        // find resource(s)
+        $resources = $auth->list_resources(null, $attributes, $search, $params);
+
+        if (empty($resources) || empty($resources['list']) || $resources['count'] > 1) {
             return false;
         }
 
-        $auth   = Auth::get_instance();
-        $result = $auth->resource_info($getdata['id']);
+        // get resource data
+        $result = $auth->resource_info(key($resources['list']));
 
         // normalize result
         $result = $this->parse_result_attributes('resource', $result);
@@ -173,31 +183,21 @@ class kolab_api_service_resource extends kolab_api_service
     }
 
     /**
-     * Find resource and return its data.
-     * It is a combination of resource.info and resources.list with search capabilities
-     * If the search returns only one record we'll return resource data.
+     * User information.
      *
      * @param array $get   GET parameters
      * @param array $post  POST parameters
      *
-     * @return array|bool Resource attributes, False on error
+     * @return array|bool User attributes, False on error
      */
-    public function resource_find($get, $post)
+    public function resource_info($getdata, $postdata)
     {
-        $auth       = Auth::get_instance();
-        $attributes = array('');
-        $params     = array('page_size' => 2);
-        $search     = $this->parse_list_search($post);
-
-        // find resource(s)
-        $resources = $auth->list_resources(null, $attributes, $search, $params);
-
-        if (empty($resources) || empty($resources['list']) || $resources['count'] > 1) {
+        if (!isset($getdata['id'])) {
             return false;
         }
 
-        // get resource data
-        $result = $auth->resource_info(key($resources['list']));
+        $auth   = Auth::get_instance();
+        $result = $auth->resource_info($getdata['id']);
 
         // normalize result
         $result = $this->parse_result_attributes('resource', $result);


commit 6d7dffe35e0ae3ee09b34031c3f4f279cba2ddd1
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date:   Thu Jul 31 17:48:31 2014 +0200

    Sync the rights in the UI with the ones pykolab picks up

diff --git a/public_html/js/kolab_admin.js b/public_html/js/kolab_admin.js
index c7a803b..ed4feb7 100644
--- a/public_html/js/kolab_admin.js
+++ b/public_html/js/kolab_admin.js
@@ -1864,7 +1864,7 @@ function kolab_admin()
         }),
       epoch_input = $('<input id="acl-epoch" type="text" size="13" />'),
       subjects = 'user,anyone,anonymous'.split(','),
-      options = 'all,read,write,post,append,custom'.split(','),
+      options = 'all,read-only,read-write,semi-full,full,custom'.split(','),
       rights = 'l,r,s,w,i,p,k,x,t,n,e,a'.split(',');
 
     $.each(subjects, function() {


commit 575808e1c25b88ecae5b9ea71f5f65003e497ae2
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date:   Thu Jul 31 14:33:09 2014 +0200

    Increase the page size to the maximum default search limit

diff --git a/lib/api/kolab_api_service_ous.php b/lib/api/kolab_api_service_ous.php
index f6f4a62..0a6c754 100644
--- a/lib/api/kolab_api_service_ous.php
+++ b/lib/api/kolab_api_service_ous.php
@@ -65,6 +65,8 @@ class kolab_api_service_ous extends kolab_api_service
         $params     = $this->parse_list_params($post);
         $search     = $this->parse_list_search($post);
 
+        $params['page_size'] = 2000;
+
         $units = $auth->list_organizationalunits(null, $attributes, $search, $params);
         $units = $this->parse_list_result($units);
 




More information about the commits mailing list