summaryrefslogtreecommitdiffstats
path: root/lib/api/kolab_api_service_user.php
diff options
context:
space:
mode:
authorAleksander Machniak <machniak@kolabsys.com>2012-04-02 12:50:39 +0200
committerAleksander Machniak <machniak@kolabsys.com>2012-04-02 12:50:39 +0200
commit80dfc4211d1b5f139e07c45d022319bf1b3d8ba8 (patch)
treef4ab17cdad356d0a20886c70fe2b4521cbcd1f02 /lib/api/kolab_api_service_user.php
parent77b929decec283a2440a94656ba8b2e313d1656c (diff)
downloadwebadmin-80dfc4211d1b5f139e07c45d022319bf1b3d8ba8.tar.gz
Simplify some code, don't check userpassword2 on API backend
Diffstat (limited to 'lib/api/kolab_api_service_user.php')
-rw-r--r--lib/api/kolab_api_service_user.php38
1 files changed, 8 insertions, 30 deletions
diff --git a/lib/api/kolab_api_service_user.php b/lib/api/kolab_api_service_user.php
index 91c6c69..106fe33 100644
--- a/lib/api/kolab_api_service_user.php
+++ b/lib/api/kolab_api_service_user.php
@@ -67,10 +67,7 @@ class kolab_api_service_user extends kolab_api_service
if (isset($uta['form_fields'])) {
foreach ($uta['form_fields'] as $key => $value) {
- if (
- (!isset($postdata[$key]) || empty($postdata[$key])) &&
- (!array_key_exists('optional', $value) || !$value['optional'])
- ) {
+ if (empty($postdata[$key]) && empty($value['optional'])) {
throw new Exception("Missing input value for $key", 345);
}
else {
@@ -82,9 +79,8 @@ class kolab_api_service_user extends kolab_api_service
if (isset($uta['auto_form_fields'])) {
foreach ($uta['auto_form_fields'] as $key => $value) {
if (empty($postdata[$key])) {
- console("Key $key empty in \$postdata");
// If the attribute is marked as optional, however...
- if (!array_key_exists('optional', $value) || !$value['optional']) {
+ if (empty($value['optional'])) {
$postdata['attributes'] = array($key);
$res = $form_service->generate($getdata, $postdata);
$postdata[$key] = $res[$key];
@@ -195,10 +191,7 @@ class kolab_api_service_user extends kolab_api_service
if (isset($uta['form_fields'])) {
foreach ($uta['form_fields'] as $key => $value) {
- if (
- (!isset($postdata[$key]) || empty($postdata[$key])) &&
- (!array_key_exists('optional', $value) || !$value['optional'])
- ) {
+ if (empty($postdata[$key]) && empty($value['optional'])) {
throw new Exception("Missing input value for $key", 345);
}
else {
@@ -210,26 +203,11 @@ class kolab_api_service_user extends kolab_api_service
if (isset($uta['auto_form_fields'])) {
foreach ($uta['auto_form_fields'] as $key => $value) {
if (empty($postdata[$key])) {
- switch ($key) {
- case "userpassword":
- if (!empty($postdata['userpassword']) && !empty($postdata['userpassword2'])) {
- if ($postdata['userpassword'] === $postdata['userpassword2']) {
- $user_password = $postdata['userpassword'];
- } else {
- throw new Exception("Password mismatch");
- }
- } else {
- $user_attributes[$key] = $_user[$key];
- }
- break;
- default:
- if (!array_key_exists('optional', $value) || !$value['optional']) {
- $postdata['attributes'] = array($key);
- $res = $form_service->generate($getdata, $postdata);
- $postdata[$key] = $res[$key];
- $user_attributes[$key] = $postdata[$key];
- }
- break;
+ if (empty($value['optional'])) {
+ $postdata['attributes'] = array($key);
+ $res = $form_service->generate($getdata, $postdata);
+ $postdata[$key] = $res[$key];
+ $user_attributes[$key] = $postdata[$key];
}
} else {
$user_attributes[$key] = $postdata[$key];