summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAleksander Machniak <alec@alec.pl>2012-02-21 17:55:15 +0100
committerAleksander Machniak <alec@alec.pl>2012-02-21 17:55:15 +0100
commitb33eb6fc6b198dfd4764505f663cdf46c231185a (patch)
treee5a36a2800057d55825ac7a69fa0aa6d65b1d409
parent1bb745b3c394d1eb023d61e80593e1b489d2f4d4 (diff)
parent55ccedbce9f335aff55cce39de90cd5e7e8ac771 (diff)
downloadwebadmin-b33eb6fc6b198dfd4764505f663cdf46c231185a.tar.gz
Merge branch 'master' of ssh://git.klab.cc/git/machniak/kolab-wap
-rw-r--r--lib/Auth/LDAP.php2
-rw-r--r--lib/SQL.php8
-rw-r--r--lib/api/kolab_api_service_user.php15
3 files changed, 16 insertions, 9 deletions
diff --git a/lib/Auth/LDAP.php b/lib/Auth/LDAP.php
index 5100b13..b16c270 100644
--- a/lib/Auth/LDAP.php
+++ b/lib/Auth/LDAP.php
@@ -368,7 +368,7 @@ class LDAP
}
else {
$db = SQL::get_instance();
- $_key = $this->db->fetch_assoc($db->query("SELECT key FROM user_types WHERE id = ?", $type));
+ $_key = $db->fetch_assoc($db->query("SELECT `key` FROM user_types WHERE id = ?", $type));
$type_str = $_key['key'];
}
diff --git a/lib/SQL.php b/lib/SQL.php
index 6f4ac6b..fb27c30 100644
--- a/lib/SQL.php
+++ b/lib/SQL.php
@@ -56,11 +56,19 @@ class SQL
$result = mysql_query($query);
+ if (!$result) {
+ write_log('errors', 'SQL Error: ' . mysql_error($this->conn));
+ }
+
return $result;
}
public function fetch_assoc($result)
{
+ if (!$result) {
+ return array();
+ }
+
return mysql_fetch_assoc($result);
}
diff --git a/lib/api/kolab_api_service_user.php b/lib/api/kolab_api_service_user.php
index e6c4049..15378f8 100644
--- a/lib/api/kolab_api_service_user.php
+++ b/lib/api/kolab_api_service_user.php
@@ -21,13 +21,12 @@ 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->user_type_attributes($postdata['user_type_id']);
+ $form_service = $this->controller->get_service('form_value');
$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);
}
@@ -39,12 +38,12 @@ class kolab_api_service_user extends kolab_api_service
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];
+ if (empty($postdata[$key])) {
+ $method = 'generate_' . $key;
+ $res = $form_service->$method($getdata, $postdata);
+ $postdata[$key] = $res[$key];
}
+ $user_attributes[$key] = $postdata[$key];
}
}