summaryrefslogtreecommitdiffstats
path: root/lib/api
diff options
context:
space:
mode:
authorAleksander Machniak <machniak@kolabsys.com>2012-03-30 13:26:32 +0200
committerAleksander Machniak <machniak@kolabsys.com>2012-03-30 13:26:32 +0200
commit7906fe64d5b76d6abec033ade2d3e9fa56d9abd8 (patch)
tree9b0dbf6d00f497eb3726b79705394cdef12300c7 /lib/api
parentfe39a1887ffe4425b88613eeb384971f838103f3 (diff)
downloadwebadmin-7906fe64d5b76d6abec033ade2d3e9fa56d9abd8.tar.gz
Unified some methods: Use object_type_*() instead of separate user_type_*/group_type_*/<any>_type_*.
Unified some API calls arguments: Use object_name and type_id instead of user_type_id/group_type_id/<any>_type_id.
Diffstat (limited to 'lib/api')
-rw-r--r--lib/api/kolab_api_service_form_value.php63
-rw-r--r--lib/api/kolab_api_service_group.php6
-rw-r--r--lib/api/kolab_api_service_group_types.php2
-rw-r--r--lib/api/kolab_api_service_user.php10
-rw-r--r--lib/api/kolab_api_service_user_types.php2
5 files changed, 24 insertions, 59 deletions
diff --git a/lib/api/kolab_api_service_form_value.php b/lib/api/kolab_api_service_form_value.php
index 3f53d79..b006b84 100644
--- a/lib/api/kolab_api_service_form_value.php
+++ b/lib/api/kolab_api_service_form_value.php
@@ -52,22 +52,14 @@ class kolab_api_service_form_value extends kolab_api_service
* @param array $getdata GET parameters
* @param array $postdata POST parameters. Required parameters:
* - attributes: list of attribute names
- * - user_type_id or group_type_id: Type identifier
+ * - type_id: Type identifier
+ * - object_type: Object type (user, group, etc.)
*
* @return array Response with attribute name as a key
*/
public function generate($getdata, $postdata)
{
- if (isset($postdata['user_type_id'])) {
- $attribs = $this->user_type_attributes($postdata['user_type_id']);
- }
- else if (isset($postdata['group_type_id'])) {
- $attribs = $this->group_type_attributes($postdata['group_type_id']);
- }
- else {
- $attribs = array();
- }
-
+ $attribs = $this->object_type_attributes($postdata['object_type'], $postdata['type_id']);
$attributes = (array) $postdata['attributes'];
$result = array();
@@ -93,29 +85,18 @@ class kolab_api_service_form_value extends kolab_api_service
*
* @param array $getdata GET parameters
* @param array $postdata POST parameters. Required parameters:
- * - user_type_id or group_type_id: Type identifier
+ * - type_id: Type identifier
+ * - object_type: Object type (user, group, etc.)
*
* @return array Response with attribute name as a key
*/
public function validate($getdata, $postdata)
{
- if (isset($postdata['user_type_id'])) {
- $attribs = $this->user_type_attributes($postdata['user_type_id']);
- }
- else if (isset($postdata['group_type_id'])) {
- $attribs = $this->group_type_attributes($postdata['group_type_id']);
- }
- else {
- $attribs = array();
- }
-
- $result = array();
+ $attribs = $this->object_type_attributes($postdata['object_type'], $postdata['type_id']);
+ $result = array();
foreach ((array)$postdata as $attr_name => $attr_value) {
- if (empty($attr_name)) {
- continue;
- }
- if (preg_match('/^[a-z]+_type_id$/i', $attr_name)) {
+ if (empty($attr_name) || $attr_name == 'type_id' || $attr_name == 'object_type') {
continue;
}
@@ -138,22 +119,14 @@ class kolab_api_service_form_value extends kolab_api_service
* @param array $getdata GET parameters
* @param array $postdata POST parameters. Required parameters:
* - attributes: list of attribute names
- * - user_type_id or group_type_id: Type identifier
+ * - type_id: Type identifier
+ * - object_type: Object type (user, group, etc.)
*
* @return array Response with attribute name as a key
*/
public function select_options($getdata, $postdata)
{
- if (isset($postdata['user_type_id'])) {
- $attribs = $this->user_type_attributes($postdata['user_type_id']);
- }
- else if (isset($postdata['group_type_id'])) {
- $attribs = $this->group_type_attributes($postdata['group_type_id']);
- }
- else {
- $attribs = array();
- }
-
+ $attribs = $this->object_type_attributes($postdata['object_type'], $postdata['type_id']);
$attributes = (array) $postdata['attributes'];
$result = array();
@@ -181,22 +154,14 @@ class kolab_api_service_form_value extends kolab_api_service
* @param array $getdata GET parameters
* @param array $postdata POST parameters. Required parameters:
* - attribute: attribute name
- * - user_type_id or group_type_id: Type identifier
+ * - type_id: Type identifier
+ * - object_type: Object type (user, group, etc.)
*
* @return array Response with attribute name as a key
*/
public function list_options($getdata, $postdata)
{
- if (isset($postdata['user_type_id'])) {
- $attribs = $this->user_type_attributes($postdata['user_type_id']);
- }
- else if (isset($postdata['group_type_id'])) {
- $attribs = $this->group_type_attributes($postdata['group_type_id']);
- }
- else {
- $attribs = array();
- }
-
+ $attribs = $this->object_type_attributes($postdata['object_type'], $postdata['type_id']);
$attr_name = $postdata['attribute'];
$result = array(
// return search value, so client can match response to request
diff --git a/lib/api/kolab_api_service_group.php b/lib/api/kolab_api_service_group.php
index c1decaf..a527aa5 100644
--- a/lib/api/kolab_api_service_group.php
+++ b/lib/api/kolab_api_service_group.php
@@ -55,7 +55,7 @@ class kolab_api_service_group extends kolab_api_service
*/
public function group_add($getdata, $postdata)
{
- $gta = $this->group_type_attributes($postdata['group_type_id']);
+ $gta = $this->object_type_attributes('group', $postdata['type_id']);
$group_attributes = array();
if (isset($gta['form_fields'])) {
@@ -93,7 +93,7 @@ class kolab_api_service_group extends kolab_api_service
}
$auth = Auth::get_instance();
- $result = $auth->group_add($group_attributes, $postdata['group_type_id']);
+ $result = $auth->group_add($group_attributes, $postdata['type_id']);
if ($result) {
return $group_attributes;
@@ -150,7 +150,7 @@ class kolab_api_service_group extends kolab_api_service
$result['entrydn'] = $dn;
// add group type id to the result
- $result['group_type_id'] = $this->object_type_id('group', $result['objectclass']);
+ $result['type_id'] = $this->object_type_id('group', $result['objectclass']);
if ($result) {
return $result;
diff --git a/lib/api/kolab_api_service_group_types.php b/lib/api/kolab_api_service_group_types.php
index 7145654..e564c06 100644
--- a/lib/api/kolab_api_service_group_types.php
+++ b/lib/api/kolab_api_service_group_types.php
@@ -52,7 +52,7 @@ class kolab_api_service_group_types extends kolab_api_service
*/
public function group_types_list($get, $post)
{
- $group_types = $this->group_types();
+ $group_types = $this->object_types('group');
return array(
'list' => $group_types,
diff --git a/lib/api/kolab_api_service_user.php b/lib/api/kolab_api_service_user.php
index fea9f9d..855518f 100644
--- a/lib/api/kolab_api_service_user.php
+++ b/lib/api/kolab_api_service_user.php
@@ -59,7 +59,7 @@ class kolab_api_service_user extends kolab_api_service
*/
public function user_add($getdata, $postdata)
{
- $uta = $this->user_type_attributes($postdata['user_type_id']);
+ $uta = $this->object_type_attributes('user', $postdata['type_id']);
$form_service = $this->controller->get_service('form_value');
$user_attributes = array();
@@ -96,7 +96,7 @@ class kolab_api_service_user extends kolab_api_service
}
$auth = Auth::get_instance();
- $result = $auth->user_add($user_attributes, $postdata['user_type_id']);
+ $result = $auth->user_add($user_attributes, $postdata['type_id']);
if ($result) {
return $user_attributes;
@@ -154,12 +154,12 @@ class kolab_api_service_user extends kolab_api_service
$result['entrydn'] = $dn;
// add user type id to the result
- $result['user_type_id'] = $this->object_type_id('user', $result['objectclass']);
+ $result['type_id'] = $this->object_type_id('user', $result['objectclass']);
// Search for attributes associated with the type_id that are not part
// of the results returned earlier. Example: nsrole / nsroledn / aci, etc.
- if ($result['user_type_id']) {
- $uta = $this->user_type_attributes($result['user_type_id']);
+ if ($result['type_id']) {
+ $uta = $this->object_type_attributes('user', $result['type_id']);
$attrs = array();
foreach ($uta as $field_type => $attributes) {
diff --git a/lib/api/kolab_api_service_user_types.php b/lib/api/kolab_api_service_user_types.php
index b2adcf2..7a200ae 100644
--- a/lib/api/kolab_api_service_user_types.php
+++ b/lib/api/kolab_api_service_user_types.php
@@ -52,7 +52,7 @@ class kolab_api_service_user_types extends kolab_api_service
*/
public function user_types_list($get, $post)
{
- $user_types = $this->user_types();
+ $user_types = $this->object_types('user');
return array(
'list' => $user_types,