summaryrefslogtreecommitdiffstats
path: root/lib/api/kolab_user_actions.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/api/kolab_user_actions.php')
-rw-r--r--lib/api/kolab_user_actions.php160
1 files changed, 82 insertions, 78 deletions
diff --git a/lib/api/kolab_user_actions.php b/lib/api/kolab_user_actions.php
index b0b4e53..1849663 100644
--- a/lib/api/kolab_user_actions.php
+++ b/lib/api/kolab_user_actions.php
@@ -1,105 +1,109 @@
<?php
- /**
- *
- */
- class kolab_user_actions extends kolab_api_service
+/**
+ *
+ */
+class kolab_user_actions extends kolab_api_service
+{
+ public function capabilities($domain)
{
- public function capabilities($domain)
- {
- return array(
- 'add' => 'w',
- 'delete' => 'w',
-// 'edit' => 'w',
-// 'find' => 'r',
-// 'find_by_any_attribute' => 'r',
-// 'find_by_attribute' => 'r',
-// 'find_by_attributes' => 'r',
- 'info' => 'r',
- );
- }
+ return array(
+ 'add' => 'w',
+ 'delete' => 'w',
+// 'edit' => 'w',
+// 'find' => 'r',
+// 'find_by_any_attribute' => 'r',
+// 'find_by_attribute' => 'r',
+// 'find_by_attributes' => 'r',
+ 'info' => 'r',
+ );
+ }
- public function user_add($getdata, $postdata) {
- if (!isset($postdata['user_type_id'])) {
- throw new Exception("No user type ID specified", 346781);
- }
+ public function user_add($getdata, $postdata)
+ {
+ if (!isset($postdata['user_type_id'])) {
+ throw new Exception("No user type ID specified", 346781);
+ }
- $user_type = mysql_fetch_assoc(query("SELECT attributes FROM user_types WHERE id = '" . $postdata['user_type_id'] ."'"));
+ $user_type = mysql_fetch_assoc(query("SELECT attributes FROM user_types WHERE id = '" . $postdata['user_type_id'] ."'"));
- $uta = json_decode(unserialize($user_type['attributes']), true);
+ $uta = json_decode(unserialize($user_type['attributes']), true);
- $user_attributes = Array();
+ $user_attributes = array();
- if (isset($uta['form_fields'])) {
- foreach ($uta['form_fields'] as $key => $value) {
- error_log("form field $key");
- if (!isset($postdata[$key]) || empty($postdata[$key])) {
- throw new Exception("Missing input value for $key", 345);
- } else {
- $user_attributes[$key] = $postdata[$key];
- }
+ if (isset($uta['form_fields'])) {
+ foreach ($uta['form_fields'] as $key => $value) {
+ error_log("form field $key");
+ if (!isset($postdata[$key]) || empty($postdata[$key])) {
+ throw new Exception("Missing input value for $key", 345);
}
- }
-
- if (isset($uta['auto_form_fields'])) {
- foreach ($uta['auto_form_fields'] as $key => $value) {
- if (!isset($postdata[$key])) {
- throw new Exception("Key not set: " . $key, 12356);
- } else {
- $user_attributes[$key] = $postdata[$key];
- }
+ else {
+ $user_attributes[$key] = $postdata[$key];
}
}
+ }
- if (isset($uta['fields'])) {
- foreach ($uta['fields'] as $key => $value) {
- if (!isset($postdata[$key]) || empty($postdata[$key])) {
- $user_attributes[$key] = $uta['fields'][$key];
- } else {
- $user_attributes[$key] = $postdata[$key];
- }
+ if (isset($uta['auto_form_fields'])) {
+ foreach ($uta['auto_form_fields'] as $key => $value) {
+ if (!isset($postdata[$key])) {
+ throw new Exception("Key not set: " . $key, 12356);
+ }
+ else {
+ $user_attributes[$key] = $postdata[$key];
}
}
+ }
- $auth = Auth::get_instance();
- $result = $auth->user_add($user_attributes, $postdata['user_type_id']);
- if ($result) {
- return $user_attributes;
- } else {
- return FALSE;
+ if (isset($uta['fields'])) {
+ foreach ($uta['fields'] as $key => $value) {
+ if (!isset($postdata[$key]) || empty($postdata[$key])) {
+ $user_attributes[$key] = $uta['fields'][$key];
+ } else {
+ $user_attributes[$key] = $postdata[$key];
+ }
}
}
- public function user_delete($getdata, $postdata) {
- // TODO: Input validation
- $auth = Auth::get_instance();
- if (!isset($postdata['user'])) {
- return FALSE;
- }
+ $auth = Auth::get_instance();
+ $result = $auth->user_add($user_attributes, $postdata['user_type_id']);
- $result = $auth->user_delete($postdata['user']);
- if ($result) {
- return $result;
- } else {
- return FALSE;
- }
+ if ($result) {
+ return $user_attributes;
}
- public function user_info($getdata, $postdata) {
- $auth = Auth::get_instance();
+ return FALSE;
+ }
- if (!isset($getdata['user'])) {
- return FALSE;
- }
+ public function user_delete($getdata, $postdata)
+ {
+ if (!isset($postdata['user'])) {
+ return FALSE;
+ }
- $result = $auth->user_info($getdata['user']);
+ // TODO: Input validation
+ $auth = Auth::get_instance();
+ $result = $auth->user_delete($postdata['user']);
- if ($result) {
- return $result;
- } else {
- return FALSE;
- }
+ if ($result) {
+ return $result;
}
+
+ return FALSE;
}
-?>
+ public function user_info($getdata, $postdata)
+ {
+ if (!isset($getdata['user'])) {
+ return FALSE;
+ }
+
+ $auth = Auth::get_instance();
+ $result = $auth->user_info($getdata['user']);
+
+ if ($result) {
+ return $result;
+ }
+
+ return FALSE;
+ }
+}