summaryrefslogtreecommitdiffstats
path: root/lib/api/kolab_api_service_user.php
diff options
context:
space:
mode:
authorAleksander Machniak <machniak@kolabsys.com>2012-04-03 10:38:15 +0200
committerAleksander Machniak <machniak@kolabsys.com>2012-04-03 10:38:15 +0200
commitd14e39cd189577c427b93873ec444fa65b9ae271 (patch)
tree5dc726ee6cec46be5370b9849c610ce78a2f959e /lib/api/kolab_api_service_user.php
parent0679625db10468ab399aa6750effa431c4214bd1 (diff)
downloadwebadmin-d14e39cd189577c427b93873ec444fa65b9ae271.tar.gz
Move user_edit/group_edit code into LDAP class, keep service classes backend-unaware
Diffstat (limited to 'lib/api/kolab_api_service_user.php')
-rw-r--r--lib/api/kolab_api_service_user.php53
1 files changed, 5 insertions, 48 deletions
diff --git a/lib/api/kolab_api_service_user.php b/lib/api/kolab_api_service_user.php
index b262698..fcc9128 100644
--- a/lib/api/kolab_api_service_user.php
+++ b/lib/api/kolab_api_service_user.php
@@ -103,56 +103,13 @@ class kolab_api_service_user extends kolab_api_service
{
console("\$postdata to user_edit()", $postdata);
- $user_attributes = $this->parse_input_attributes('user', $postdata);
-
- // Get the type "key" string for the next few settings.
- if ($postdata['type_id'] == null) {
- $type_str = 'user';
- }
- else {
- $db = SQL::get_instance();
- $_key = $db->fetch_assoc($db->query("SELECT `key` FROM user_types WHERE id = ?", $postdata['type_id']));
- $type_str = $_key['key'];
- }
-
- $conf = Conf::get_instance();
-
- $unique_attr = $conf->get('unique_attribute');
- if (!$unique_attr) {
- $unique_attr = 'nsuniqueid';
- }
- $user_attributes[$unique_attr] = $postdata['id'];
- unset($postdata['id']);
-
- // TODO: "rdn" is somewhat LDAP specific, but not used as something
- // LDAP specific...?
- $rdn_attr = $conf->get($type_str . '_user_name_attribute');
- if (!$rdn_attr) {
- $rdn_attr = $conf->get('user_name_attribute');
- }
- if (!$rdn_attr) {
- $rdn_attr = 'uid';
- }
+ $user_attributes = $this->parse_input_attributes('user', $postdata);
+ $user = $postdata['id'];
- // Obtain the original user's information.
- $auth = Auth::get_instance();
- $auth->connect();
-
- // Now that values have been re-generated where necessary, compare
- // the new group attributes to the original group attributes.
- $_user = $auth->user_find_by_attribute(array($unique_attr => $user_attributes[$unique_attr]));
-
- if (!$_user) {
- console("Could not find user");
- return false;
- }
-
- $_user_dn = key($_user);
- $_user = $this->user_info(array('user' => $_user_dn), array());
-
- // We should start throwing stuff over the fence here.
- $result = $auth->modify_entry($_user_dn, $_user, $user_attributes);
+ $auth = Auth::get_instance();
+ $result = $auth->user_edit($user, $user_attributes, $postdata['type_id']);
+ // @TODO: return unique attribute (?), it can change on edit
if ($result) {
return true;
}