6 commits - lib/api lib/kolab_client_task.php
Jeroen van Meeuwen
vanmeeuwen at kolabsys.com
Mon Apr 9 16:45:44 CEST 2012
lib/api/kolab_api_service_form_value.php | 68 ++++++++++++++++++++-----------
lib/kolab_client_task.php | 9 +++-
2 files changed, 53 insertions(+), 24 deletions(-)
New commits:
commit c60c67c360d441bc40ca2017c1d0358301b0e10e
Merge: 0f4ab65 6a72d8d
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date: Mon Apr 9 16:38:15 2012 +0200
Merge branch 'master' of ssh://git.kolab.org/git/kolab-wap
Conflicts:
lib/api/kolab_api_service_form_value.php
commit 0f4ab65529e6be6a31c67c39b46da9f195ec7598
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date: Mon Apr 9 16:35:31 2012 +0200
Keep the uidnumber and gidnumber aligned - either highest one will cause the other to be bumped.
Usefull for private user groups, where group 'vanmeeuwen' has the same gidnumber as the uidnumber for user 'vanmeeuwen'.
diff --git a/lib/api/kolab_api_service_form_value.php b/lib/api/kolab_api_service_form_value.php
index 0bf12a2..7164246 100644
--- a/lib/api/kolab_api_service_form_value.php
+++ b/lib/api/kolab_api_service_form_value.php
@@ -283,7 +283,7 @@ class kolab_api_service_form_value extends kolab_api_service
$highest_gidnumber = $conf->get('gidnumber_lower_barrier');
if (!$highest_gidnumber) {
- $highest_gidnumber = 1000;
+ $highest_gidnumber = 999;
}
foreach ($groups as $dn => $attributes) {
@@ -296,9 +296,14 @@ class kolab_api_service_form_value extends kolab_api_service
}
}
- //$users = $auth->list_users();
- //console($groups);
- return ($highest_gidnumber + 1);
+ $gidnumber = ($highest_gidnumber + 1);
+ $postdata['gidnumber'] = $gidnumber;
+ if (empty($postdata['uidnumber'])) {
+ $uidnumber = $this->generate_uidnumber($postdata, $attribs);
+ $gidnumber = $this->_highest_of_two($uidnumber, $gidnumber);
+ }
+
+ return $gidnumber;
}
}
@@ -451,6 +456,8 @@ class kolab_api_service_form_value extends kolab_api_service
private function generate_uid($postdata, $attribs = array())
{
+ //console("generate_uid() \$postdata", $postdata);
+
$conf = Conf::get_instance();
$unique_attr = $conf->get('unique_attribute');
if (!$unique_attr) {
@@ -485,11 +492,13 @@ class kolab_api_service_form_value extends kolab_api_service
$x = 2;
while (($user_found = $auth->user_find_by_attribute(array('uid' => $uid)))) {
- $user_found_dn = key($user_found);
- $user_found_unique_attr = $auth->get_attribute($user_found_dn, $unique_attr);
- //console("user that i found info", $user_found_unique_attr);
- if ($user_found_unique_attr == $postdata[$unique_attr]) {
- break;
+ if (!empty($postdata['id'])) {
+ $user_found_dn = key($user_found);
+ $user_found_unique_attr = $auth->get_attribute($user_found_dn, $unique_attr);
+ //console("user with uid $uid found", $user_found_unique_attr);
+ if ($user_found_unique_attr == $postdata['id']) {
+ break;
+ }
}
$uid = $orig_uid . $x;
@@ -519,7 +528,7 @@ class kolab_api_service_form_value extends kolab_api_service
$highest_uidnumber = $conf->get('uidnumber_lower_barrier');
if (!$highest_uidnumber) {
- $highest_uidnumber = 1000;
+ $highest_uidnumber = 999;
}
foreach ($users as $dn => $attributes) {
@@ -531,7 +540,15 @@ class kolab_api_service_form_value extends kolab_api_service
$highest_uidnumber = $attributes['uidnumber'];
}
}
- return ($highest_uidnumber + 1);
+
+ $uidnumber = ($highest_uidnumber + 1);
+ $postdata['uidnumber'] = $uidnumber;
+ if (empty($postdata['gidnumber'])) {
+ $gidnumber = $this->generate_gidnumber($postdata, $attribs);
+ $uidnumber = $this->_highest_of_two($uidnumber, $gidnumber);
+ }
+
+ return $uidnumber;
}
}
@@ -730,4 +747,13 @@ class kolab_api_service_form_value extends kolab_api_service
return $list;
}
+ private function _highest_of_two($one, $two) {
+ if ($one > $two) {
+ return $one;
+ } elseif ($one == $two) {
+ return $one;
+ } else {
+ return $two;
+ }
+ }
}
commit dc74cc38b50e3d8d144c844fd837cadf77fb86e4
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date: Mon Apr 9 02:10:25 2012 +0200
Clause the overriding of readonly fields with more administrator rights
diff --git a/lib/kolab_client_task.php b/lib/kolab_client_task.php
index 7f14df4..e8fa114 100644
--- a/lib/kolab_client_task.php
+++ b/lib/kolab_client_task.php
@@ -877,8 +877,13 @@ class kolab_client_task
}
}
else {
- // No entry level rights, check on attribute level
- if (!in_array('write', $attribute_rights[$idx])) {
+ if (in_array('add', $entry_rights) && in_array('delete', $entry_rights)) {
+ if ($admin_auto_fields_rw) {
+ $fields[$idx]['readonly'] = false;
+ }
+ }
+ // Explicit attribute level rights, check for 'write'
+ elseif (!in_array('write', $attribute_rights[$idx])) {
$fields[$idx]['readonly'] = true;
}
}
commit 5e24d0e51906654f1fb4e1bc42c18f61f182ffc6
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date: Sun Apr 8 17:42:51 2012 +0200
Revert "Re-prepopulate the form fields for which the value is automatically generated after reloading the form for a type change (#690)"
This reverts commit 4627654b97c274626a34f11fc5a71239fb59058b.
diff --git a/public_html/js/kolab_admin.js b/public_html/js/kolab_admin.js
index 864ce36..d37c011 100644
--- a/public_html/js/kolab_admin.js
+++ b/public_html/js/kolab_admin.js
@@ -1070,11 +1070,6 @@ function kolab_admin()
if (reload) {
data.section = section;
this.http_post('user.' + action, {data: data});
- a_fields = [];
- for (i in this.env.auto_fields) {
- a_fields.push(i);
- }
- this.form_value_change(a_fields)
return;
}
commit 4627654b97c274626a34f11fc5a71239fb59058b
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date: Sun Apr 8 17:16:07 2012 +0200
Re-prepopulate the form fields for which the value is automatically generated after reloading the form for a type change (#690)
diff --git a/public_html/js/kolab_admin.js b/public_html/js/kolab_admin.js
index d37c011..864ce36 100644
--- a/public_html/js/kolab_admin.js
+++ b/public_html/js/kolab_admin.js
@@ -1070,6 +1070,11 @@ function kolab_admin()
if (reload) {
data.section = section;
this.http_post('user.' + action, {data: data});
+ a_fields = [];
+ for (i in this.env.auto_fields) {
+ a_fields.push(i);
+ }
+ this.form_value_change(a_fields)
return;
}
commit 745d1e86142e50231ccead6095bb5c427e376af6
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date: Sun Apr 8 17:03:40 2012 +0200
Set the default OU for adding new users
diff --git a/lib/api/kolab_api_service_form_value.php b/lib/api/kolab_api_service_form_value.php
index 694a1d8..0bf12a2 100644
--- a/lib/api/kolab_api_service_form_value.php
+++ b/lib/api/kolab_api_service_form_value.php
@@ -623,16 +623,16 @@ class kolab_api_service_form_value extends kolab_api_service
$base_dn = $conf->get('base_dn');
}
- $subject = $auth->search($base_dn, '(' . $unique_attr . '=' . $postdata['id'] . ')');
-
- $subject_dn = $subject[0];
-
- $subject_dn_components = ldap_explode_dn($subject_dn, 0);
- unset($subject_dn_components['count']);
-
- array_shift($subject_dn_components);
-
- $subject_parent_ou = strtolower(implode(',', $subject_dn_components));
+ if (!empty($postdata['id'])) {
+ $subject = $auth->search($base_dn, '(' . $unique_attr . '=' . $postdata['id'] . ')');
+ $subject_dn = $subject[0];
+ $subject_dn_components = ldap_explode_dn($subject_dn, 0);
+ unset($subject_dn_components['count']);
+ array_shift($subject_dn_components);
+ $default = strtolower(implode(',', $subject_dn_components));
+ } else {
+ $default = $base_dn;
+ }
$ous = $auth->search($base_dn, '(objectclass=organizationalunit)');
@@ -644,7 +644,7 @@ class kolab_api_service_form_value extends kolab_api_service
sort($_ous);
- $_ous['default'] = $subject_parent_ou;
+ $_ous['default'] = strtolower($default);
return $_ous;
}
More information about the commits
mailing list