summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorAleksander Machniak <machniak@kolabsys.com>2014-02-27 14:17:01 +0100
committerAleksander Machniak <machniak@kolabsys.com>2014-02-27 14:17:01 +0100
commit4a55f2c1d856a3e7d44ab03d31ceca7bee86afda (patch)
treea88b0279c6283d17a831036b604a986b4d6f657d /lib
parent52e47e63d2c46206dff28a3d1cec782f0d5b1f23 (diff)
downloadwebadmin-4a55f2c1d856a3e7d44ab03d31ceca7bee86afda.tar.gz
Return ID (unique attribute) after adding an object (Request #2829)
Diffstat (limited to 'lib')
-rw-r--r--lib/Auth/LDAP.php6
-rw-r--r--lib/api/kolab_api_service_group.php13
-rw-r--r--lib/api/kolab_api_service_ou.php13
-rw-r--r--lib/api/kolab_api_service_resource.php18
-rw-r--r--lib/api/kolab_api_service_role.php19
-rw-r--r--lib/api/kolab_api_service_sharedfolder.php18
-rw-r--r--lib/api/kolab_api_service_user.php15
7 files changed, 58 insertions, 44 deletions
diff --git a/lib/Auth/LDAP.php b/lib/Auth/LDAP.php
index 5e708cd..898a60d 100644
--- a/lib/Auth/LDAP.php
+++ b/lib/Auth/LDAP.php
@@ -1123,7 +1123,11 @@ class LDAP extends Net_LDAP3 {
{
$this->bind($_SESSION['user']->user_bind_dn, $_SESSION['user']->user_bind_pw);
- return $this->add_entry($entry_dn, $attrs);
+ if ($this->add_entry($entry_dn, $attrs)) {
+ return $entry_dn;
+ }
+
+ return false;
}
/**
diff --git a/lib/api/kolab_api_service_group.php b/lib/api/kolab_api_service_group.php
index b1fc2ad..0e40867 100644
--- a/lib/api/kolab_api_service_group.php
+++ b/lib/api/kolab_api_service_group.php
@@ -76,13 +76,16 @@ class kolab_api_service_group extends kolab_api_service
*/
public function group_add($getdata, $postdata)
{
- $group_attributes = $this->parse_input_attributes('group', $postdata);
-
- $auth = Auth::get_instance();
- $result = $auth->group_add($group_attributes, $postdata['type_id']);
+ $attributes = $this->parse_input_attributes('group', $postdata);
+ $auth = Auth::get_instance();
+ $result = $auth->group_add($attributes, $postdata['type_id']);
if ($result) {
- return $group_attributes;
+ if ($id = $this->unique_attribute_value($result)) {
+ $attributes['id'] = $id;
+ }
+
+ return $attributes;
}
return FALSE;
diff --git a/lib/api/kolab_api_service_ou.php b/lib/api/kolab_api_service_ou.php
index fdfd9ee..015d736 100644
--- a/lib/api/kolab_api_service_ou.php
+++ b/lib/api/kolab_api_service_ou.php
@@ -74,13 +74,16 @@ class kolab_api_service_ou extends kolab_api_service
*/
public function ou_add($getdata, $postdata)
{
- $unit_attributes = $this->parse_input_attributes('ou', $postdata);
-
- $auth = Auth::get_instance();
- $result = $auth->organizationalunit_add($unit_attributes, $postdata['type_id']);
+ $attributes = $this->parse_input_attributes('ou', $postdata);
+ $auth = Auth::get_instance();
+ $result = $auth->organizationalunit_add($attributes, $postdata['type_id']);
if ($result) {
- return $unit_attributes;
+ if ($id = $this->unique_attribute_value($result)) {
+ $attributes['id'] = $id;
+ }
+
+ return $attributes;
}
return FALSE;
diff --git a/lib/api/kolab_api_service_resource.php b/lib/api/kolab_api_service_resource.php
index 149fe57..ac04f3b 100644
--- a/lib/api/kolab_api_service_resource.php
+++ b/lib/api/kolab_api_service_resource.php
@@ -75,18 +75,16 @@ class kolab_api_service_resource extends kolab_api_service
*/
public function resource_add($getdata, $postdata)
{
- //console("resource_add()", $postdata);
-
- $resource_attributes = $this->parse_input_attributes('resource', $postdata);
-
- //console("resource_add()", $resource_attributes);
-
- // TODO: The cn needs to be unique
- $auth = Auth::get_instance();
- $result = $auth->resource_add($resource_attributes, $postdata['type_id']);
+ $attributes = $this->parse_input_attributes('resource', $postdata);
+ $auth = Auth::get_instance();
+ $result = $auth->resource_add($attributes, $postdata['type_id']);
if ($result) {
- return $resource_attributes;
+ if ($id = $this->unique_attribute_value($result)) {
+ $attributes['id'] = $id;
+ }
+
+ return $attributes;
}
return false;
diff --git a/lib/api/kolab_api_service_role.php b/lib/api/kolab_api_service_role.php
index 6ca2231..31c3a8b 100644
--- a/lib/api/kolab_api_service_role.php
+++ b/lib/api/kolab_api_service_role.php
@@ -76,16 +76,19 @@ class kolab_api_service_role extends kolab_api_service
*/
public function role_add($getdata, $postdata)
{
- $role_attributes = $this->parse_input_attributes('role', $postdata);
-
- $auth = Auth::get_instance();
- $result = $auth->role_add($role_attributes, $postdata['type_id']);
+ $attributes = $this->parse_input_attributes('role', $postdata);
+ $auth = Auth::get_instance();
+ $result = $auth->role_add($attributes, $postdata['type_id']);
if ($result) {
- return $role_attributes;
+ if ($id = $this->unique_attribute_value($result)) {
+ $attributes['id'] = $id;
+ }
+
+ return $attributes;
}
- return FALSE;
+ return false;
}
/**
@@ -99,7 +102,7 @@ class kolab_api_service_role extends kolab_api_service
public function role_delete($getdata, $postdata)
{
if (empty($postdata['id'])) {
- return FALSE;
+ return false;
}
// TODO: Input validation
@@ -110,7 +113,7 @@ class kolab_api_service_role extends kolab_api_service
return $result;
}
- return FALSE;
+ return false;
}
public function role_edit($getdata, $postdata)
diff --git a/lib/api/kolab_api_service_sharedfolder.php b/lib/api/kolab_api_service_sharedfolder.php
index 6d3a3dd..23518b3 100644
--- a/lib/api/kolab_api_service_sharedfolder.php
+++ b/lib/api/kolab_api_service_sharedfolder.php
@@ -75,18 +75,16 @@ class kolab_api_service_sharedfolder extends kolab_api_service
*/
public function sharedfolder_add($getdata, $postdata)
{
- //console("sharedfolder_add()", $postdata);
-
- $sharedfolder_attributes = $this->parse_input_attributes('sharedfolder', $postdata);
-
- //console("sharedfolder_add()", $sharedfolder_attributes);
-
- // TODO: The cn needs to be unique
- $auth = Auth::get_instance();
- $result = $auth->sharedfolder_add($sharedfolder_attributes, $postdata['type_id']);
+ $attributes = $this->parse_input_attributes('sharedfolder', $postdata);
+ $auth = Auth::get_instance();
+ $result = $auth->sharedfolder_add($attributes, $postdata['type_id']);
if ($result) {
- return $sharedfolder_attributes;
+ if ($id = $this->unique_attribute_value($result)) {
+ $attributes['id'] = $id;
+ }
+
+ return $attributes;
}
return false;
diff --git a/lib/api/kolab_api_service_user.php b/lib/api/kolab_api_service_user.php
index 4d985bb..6cf4483 100644
--- a/lib/api/kolab_api_service_user.php
+++ b/lib/api/kolab_api_service_user.php
@@ -81,15 +81,19 @@ class kolab_api_service_user extends kolab_api_service
{
Log::trace("user_add()", $postdata);
- $user_attributes = $this->parse_input_attributes('user', $postdata);
+ $attributes = $this->parse_input_attributes('user', $postdata);
- Log::trace("user_add()", $user_attributes);
+ Log::trace("user_add()", $attributes);
- $auth = Auth::get_instance();
- $result = $auth->user_add($user_attributes, $postdata['type_id']);
+ $auth = Auth::get_instance();
+ $result = $auth->user_add($attributes, $postdata['type_id']);
if ($result) {
- return $user_attributes;
+ if ($id = $this->unique_attribute_value($result)) {
+ $attributes['id'] = $id;
+ }
+
+ return $attributes;
}
return false;
@@ -146,6 +150,7 @@ class kolab_api_service_user extends kolab_api_service
{
$auth = Auth::get_instance();
$effective_rights = $auth->list_rights(empty($getdata['id']) ? 'user' : $getdata['id']);
+
return $effective_rights;
}