17 commits - lib/api lib/Auth lib/client lib/kolab_api_service.php lib/kolab_client_task.php lib/locale lib/SQL.php public_html/js public_html/skins
Jeroen van Meeuwen
vanmeeuwen at kolabsys.com
Wed Feb 22 10:34:36 CET 2012
lib/Auth/LDAP.php | 2
lib/SQL.php | 8 +
lib/api/kolab_api_service_form_value.php | 20 ++--
lib/api/kolab_api_service_user.php | 15 +--
lib/client/kolab_client_task_main.php | 2
lib/client/kolab_client_task_user.php | 56 +++++++-----
lib/kolab_api_service.php | 2
lib/kolab_client_task.php | 4
lib/locale/en_US.php | 7 +
public_html/js/kolab_admin.js | 119 ++++++++++++++++++--------
public_html/skins/default/style.css | 13 ++
public_html/skins/default/templates/user.html | 1
12 files changed, 172 insertions(+), 77 deletions(-)
New commits:
commit 402a865574651b22071f31c2f6aa3a15b6b99b04
Author: Aleksander Machniak <alec at alec.pl>
Date: Tue Feb 21 19:52:00 2012 +0100
Handle better cn=* logins
diff --git a/lib/kolab_client_task.php b/lib/kolab_client_task.php
index 20f8acf..0f84df3 100644
--- a/lib/kolab_client_task.php
+++ b/lib/kolab_client_task.php
@@ -143,6 +143,10 @@ class kolab_client_task
$user['language'] = $res['preferredlanguage'];
$user['fullname'] = $res['cn'];
}
+ // @TODO: why user.info returns empty result for 'cn=Directory Manager' login?
+ else if (preg_match('/^cn=([a-zA-Z ]+)/', $login['username'], $m)) {
+ $user['fullname'] = $m[1];
+ }
$_SESSION['user'] = $user;
header('Location: ?');
commit 53bcfa4b7d47d67d5ed260703fbd115340a83b92
Author: Aleksander Machniak <alec at alec.pl>
Date: Tue Feb 21 19:37:11 2012 +0100
Implemented user.delete action, some improvements in user.add
diff --git a/lib/client/kolab_client_task_main.php b/lib/client/kolab_client_task_main.php
index 63735c2..c89f881 100644
--- a/lib/client/kolab_client_task_main.php
+++ b/lib/client/kolab_client_task_main.php
@@ -18,7 +18,7 @@ class kolab_client_task_main extends kolab_client_task
$this->output->set_env('watermark', $this->output->get_template('watermark'));
// assign default set of translations
- $this->output->add_translation('loading', 'servererror', 'search');
+ $this->output->add_translation('loading', 'saving', 'deleting', 'servererror', 'search');
// Create list of tasks for dashboard
// @TODO: check capabilities
diff --git a/lib/client/kolab_client_task_user.php b/lib/client/kolab_client_task_user.php
index 71450d9..c7497a0 100644
--- a/lib/client/kolab_client_task_user.php
+++ b/lib/client/kolab_client_task_user.php
@@ -133,6 +133,7 @@ class kolab_client_task_user extends kolab_client_task
$id = $this->get_input('id', 'POST');
$result = $this->api->get('user.info', array('user' => $id));
$user = $result->get($id);
+ $user['user'] = $id;
$output = $this->user_form(null, $user);
$this->output->set_object('taskcontent', $output);
@@ -415,7 +416,8 @@ class kolab_client_task_user extends kolab_client_task
$this->output->set_env('auto_fields', $auto_fields);
$this->output->set_env('form_id', $form_id);
- $this->output->add_translation('user.password.mismatch');
+ $this->output->add_translation('user.password.mismatch',
+ 'user.add.success', 'user.delete.success');
// Hide account type selector if there's only one type
if (count($accttypes) < 2) {
@@ -500,9 +502,10 @@ class kolab_client_task_user extends kolab_client_task
));
if (!$new) {
+ $user = $data['user'];
$form->add_button(array(
'value' => kolab_html::escape($this->translate('delete.button')),
- 'onclick' => "kadm.user_delete()",
+ 'onclick' => "kadm.user_delete('$user')",
));
}
diff --git a/lib/locale/en_US.php b/lib/locale/en_US.php
index e06184f..4b44c91 100644
--- a/lib/locale/en_US.php
+++ b/lib/locale/en_US.php
@@ -1,6 +1,8 @@
<?php
$LANG['loading'] = 'Loading...';
+$LANG['saving'] = 'Saving data...';
+$LANG['deleting'] = 'Deleting data...';
$LANG['error'] = 'Error';
$LANG['servererror'] = 'Server Error!';
$LANG['loginerror'] = 'Incorrect username or password!';
@@ -67,12 +69,14 @@ $LANG['user.invitation-policy'] = 'Invitation policy';
$LANG['user.delegate'] = 'Email delegates';
$LANG['user.delegate.desc'] = 'Others allowed to send emails with a "From" address of this account';
$LANG['user.smtp-recipients'] = 'Allowed recipients';
-$LANG['user.smtp-recipients.desc'] = 'Restrict allowed recipients of SMTP messages';
+$LANG['user.smtp-recipients.desc'] = 'Restricts allowed recipients of SMTP messages';
$LANG['user.uid'] = 'Unique identity (UID)';
$LANG['user.password'] = 'Password';
$LANG['user.password-confirm'] = 'Confirm password';
$LANG['user.password.mismatch'] = 'Passwords do not match!';
$LANG['user.homeserver'] = 'Mailbox home server';
+$LANG['user.add.success'] = 'User created successfully.';
+$LANG['user.delete.success'] = 'User deleted successfully.';
$LANG['group.add'] = 'Add Group';
diff --git a/public_html/js/kolab_admin.js b/public_html/js/kolab_admin.js
index 761fdab..24009b5 100644
--- a/public_html/js/kolab_admin.js
+++ b/public_html/js/kolab_admin.js
@@ -486,9 +486,20 @@ function kolab_admin()
this.http_post('user.list', props);
};
- this.user_delete = function(props)
+ this.user_delete = function(userid)
{
-
+ this.set_busy(true, 'deleting');
+ this.api_post('user.delete', {user: userid}, 'user_delete_response');
+ };
+
+ this.user_delete_response = function(response)
+ {
+ if (!this.api_response(response))
+ return;
+
+ this.display_message('user.delete.success');
+ this.set_watermark('taskcontent');
+ // @TODO: refresh the list
};
this.user_save = function()
@@ -504,6 +515,7 @@ function kolab_admin()
return;
}
+ this.set_busy(true, 'saving');
this.api_post('user.add', data, 'user_save_response');
};
@@ -511,6 +523,10 @@ function kolab_admin()
{
if (!this.api_response(response))
return;
+
+ this.display_message('user.add.success');
+ this.set_watermark('taskcontent');
+ // @TODO: refresh the list
};
};
commit 894e231599cc80a38f767ed24e31d09dbdef3782
Author: Aleksander Machniak <alec at alec.pl>
Date: Tue Feb 21 19:17:02 2012 +0100
Fixed css issue with long users list
diff --git a/public_html/skins/default/style.css b/public_html/skins/default/style.css
index 3141897..0f6a8ff 100644
--- a/public_html/skins/default/style.css
+++ b/public_html/skins/default/style.css
@@ -219,6 +219,7 @@ td.label {
color: #b0b0b0;
font-size: 9px;
margin-bottom: 10px;
+ clear: both;
}
#loading {
@@ -412,6 +413,10 @@ div.vsplitter {
/**** Common classes ****/
+.clear {
+ clear: both;
+}
+
.watermark {
padding-top: 40px;
text-align: center;
@@ -671,6 +676,7 @@ fieldset.tabbed
}
/**** Main screen elements ****/
+
#main {
padding: 5px 30px;
}
diff --git a/public_html/skins/default/templates/user.html b/public_html/skins/default/templates/user.html
index 6813003..0e7dd8f 100644
--- a/public_html/skins/default/templates/user.html
+++ b/public_html/skins/default/templates/user.html
@@ -14,3 +14,4 @@
</div>
<div class="vsplitter"> </div>
<div id="taskcontent" class="user"></div>
+<div class="clear"></div>
commit cf52c1c6343440fc9aea1bb33256625c5431c500
Author: Aleksander Machniak <alec at alec.pl>
Date: Tue Feb 21 17:56:09 2012 +0100
Don't show password in user edit form
diff --git a/lib/client/kolab_client_task_user.php b/lib/client/kolab_client_task_user.php
index 5548a3a..71450d9 100644
--- a/lib/client/kolab_client_task_user.php
+++ b/lib/client/kolab_client_task_user.php
@@ -435,6 +435,8 @@ class kolab_client_task_user extends kolab_client_task
}
else {
$title = $data['displayname'];
+ // remove password
+ $data['userpassword'] = '';
}
// Parse elements and add them to the form object
commit b33eb6fc6b198dfd4764505f663cdf46c231185a
Merge: 1bb745b 55ccedb
Author: Aleksander Machniak <alec at alec.pl>
Date: Tue Feb 21 17:55:15 2012 +0100
Merge branch 'master' of ssh://git.klab.cc/git/machniak/kolab-wap
commit 1bb745b3c394d1eb023d61e80593e1b489d2f4d4
Author: Aleksander Machniak <alec at alec.pl>
Date: Tue Feb 21 17:44:00 2012 +0100
Rename password to userpassword
diff --git a/lib/client/kolab_client_task_user.php b/lib/client/kolab_client_task_user.php
index 67d3796..5548a3a 100644
--- a/lib/client/kolab_client_task_user.php
+++ b/lib/client/kolab_client_task_user.php
@@ -280,7 +280,7 @@ class kolab_client_task_user extends kolab_client_task
'maxlength' => 50,
'required' => true,
),
- 'password' => array(
+ 'userpassword' => array(
'label' => 'user.password',
'description' => 'user.password.desc',
'type' => kolab_form::INPUT_TEXT,
@@ -288,7 +288,7 @@ class kolab_client_task_user extends kolab_client_task
'required' => true,
'system' => true,
),
- 'password2' => array(
+ 'userpassword2' => array(
'label' => 'user.password-confirm',
'description' => 'user.password-confirm.desc',
'type' => kolab_form::INPUT_TEXT,
@@ -427,8 +427,8 @@ class kolab_client_task_user extends kolab_client_task
// New user form
if ($new) {
// Pre-populate password fields
- $pass = $this->api->get('form_value.generate_password');
- $data['password'] = $data['password2'] = $pass->get('password');
+ $pass = $this->api->get('form_value.generate_userpassword');
+ $data['userpassword'] = $data['userpassword2'] = $pass->get('userpassword');
// Page title
$title = $this->translate('user.add');
diff --git a/public_html/js/kolab_admin.js b/public_html/js/kolab_admin.js
index 51c89cd..761fdab 100644
--- a/public_html/js/kolab_admin.js
+++ b/public_html/js/kolab_admin.js
@@ -498,9 +498,9 @@ function kolab_admin()
this.form_error_clear();
// check password
- if (data.password != data.password2) {
+ if (data.userpassword != data.userpassword2) {
this.display_message('user.password.mismatch', 'error');
- this.form_value_error('password2');
+ this.form_value_error('userpassword2');
return;
}
commit 55ccedbce9f335aff55cce39de90cd5e7e8ac771
Author: Aleksander Machniak <machniak at kolabsys.com>
Date: Tue Feb 21 17:41:07 2012 +0100
Generate empty auto-fields in user.add
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];
}
}
commit cb9f5ab425055e4ae5740d9674c31348c7289050
Author: Aleksander Machniak <machniak at kolabsys.com>
Date: Tue Feb 21 17:32:16 2012 +0100
Added simple SQL error handling/logging
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);
}
commit 65fb0ab82b0c83dbcf30a767d5b574cfe90e8784
Author: Aleksander Machniak <machniak at kolabsys.com>
Date: Tue Feb 21 17:27:14 2012 +0100
Fix SQL error
diff --git a/lib/Auth/LDAP.php b/lib/Auth/LDAP.php
index bce4735..b16c270 100644
--- a/lib/Auth/LDAP.php
+++ b/lib/Auth/LDAP.php
@@ -368,7 +368,7 @@ class LDAP
}
else {
$db = SQL::get_instance();
- $_key = $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'];
}
commit cea380b5161a7bcbb6e21e1ad919305a9ca6f584
Author: Aleksander Machniak <machniak at kolabsys.com>
Date: Tue Feb 21 17:14:57 2012 +0100
Fix call to undefined method
diff --git a/lib/Auth/LDAP.php b/lib/Auth/LDAP.php
index 5100b13..bce4735 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'];
}
commit db5d28fb5bcf6cd09377b0bad104c3db28372e19
Author: Aleksander Machniak <alec at alec.pl>
Date: Tue Feb 21 16:53:56 2012 +0100
Some improvements in forms
diff --git a/lib/api/kolab_api_service_form_value.php b/lib/api/kolab_api_service_form_value.php
index c914815..0f0ad74 100644
--- a/lib/api/kolab_api_service_form_value.php
+++ b/lib/api/kolab_api_service_form_value.php
@@ -56,7 +56,6 @@ class kolab_api_service_form_value extends kolab_api_service
return array("displayname" => $displayname);
}
-
}
public function generate_mail($getdata, $postdata)
diff --git a/lib/client/kolab_client_task_user.php b/lib/client/kolab_client_task_user.php
index 69bb996..67d3796 100644
--- a/lib/client/kolab_client_task_user.php
+++ b/lib/client/kolab_client_task_user.php
@@ -377,10 +377,12 @@ class kolab_client_task_user extends kolab_client_task
foreach ($auto_fields as $af_idx => $af) {
foreach ($fields as $section_idx => $section) {
foreach ($section['fields'] as $idx => $field) {
- if ($idx == $af_idx && empty($field['system'])) {
- $fields[$section_idx]['fields'][$idx]['readonly'] = true;
- $fields[$section_idx]['fields'][$idx]['disabled'] = true;
- $fields[$section_idx]['fields'][$idx]['required'] = false;
+ if ($idx == $af_idx) {
+ if (empty($field['system'])) {
+ $fields[$section_idx]['fields'][$idx]['readonly'] = true;
+ $fields[$section_idx]['fields'][$idx]['disabled'] = true;
+ $fields[$section_idx]['fields'][$idx]['required'] = false;
+ }
if (!empty($af['data'])) {
foreach ($af['data'] as $afd) {
@@ -406,12 +408,14 @@ class kolab_client_task_user extends kolab_client_task
// auto-generated field values
if (!empty($event_fields[$idx])) {
$event = json_encode(array_unique($event_fields[$idx]));
- $fields[$section_idx]['fields'][$idx]['onchange'] = "kadm.form_value_change('$form_id', $event)";
+ $fields[$section_idx]['fields'][$idx]['onchange'] = "kadm.form_value_change($event)";
}
}
}
$this->output->set_env('auto_fields', $auto_fields);
+ $this->output->set_env('form_id', $form_id);
+ $this->output->add_translation('user.password.mismatch');
// Hide account type selector if there's only one type
if (count($accttypes) < 2) {
@@ -490,13 +494,13 @@ class kolab_client_task_user extends kolab_client_task
$form->add_button(array(
'value' => kolab_html::escape($this->translate('submit.button')),
- 'onclick' => "kadm.user_save('$form_id')",
+ 'onclick' => "kadm.user_save()",
));
if (!$new) {
$form->add_button(array(
'value' => kolab_html::escape($this->translate('delete.button')),
- 'onclick' => "kadm.user_delete('$form_id')",
+ 'onclick' => "kadm.user_delete()",
));
}
diff --git a/lib/locale/en_US.php b/lib/locale/en_US.php
index c239bb7..e06184f 100644
--- a/lib/locale/en_US.php
+++ b/lib/locale/en_US.php
@@ -71,6 +71,7 @@ $LANG['user.smtp-recipients.desc'] = 'Restrict allowed recipients of SMTP messag
$LANG['user.uid'] = 'Unique identity (UID)';
$LANG['user.password'] = 'Password';
$LANG['user.password-confirm'] = 'Confirm password';
+$LANG['user.password.mismatch'] = 'Passwords do not match!';
$LANG['user.homeserver'] = 'Mailbox home server';
$LANG['group.add'] = 'Add Group';
diff --git a/public_html/js/kolab_admin.js b/public_html/js/kolab_admin.js
index 4e49f5e..51c89cd 100644
--- a/public_html/js/kolab_admin.js
+++ b/public_html/js/kolab_admin.js
@@ -390,18 +390,77 @@ function kolab_admin()
this.serialize_form = function(id)
{
- var i, query = $(id).serializeArray(),
- json = {};
+ var i, v, json = {},
+ form = $(id),
+ query = form.serializeArray(),
+ disabled = this.env.auto_fields;
for (i in query)
json[query[i].name] = query[i].value;
+ // read disabled fields too
+ for (i in disabled)
+ if (v = $('[name="'+i+'"]', form).val())
+ json[i] = v;
+
this.trigger_event('form-serialize', {id: id, json: json});
return json;
};
/*********************************************************/
+ /********* Forms *********/
+ /*********************************************************/
+
+ this.form_value_change = function(events)
+ {
+ var i, j, data, e, elem, name, elem_name,
+ form = $('#'+this.env.form_id),
+ type_id = $('[name="user_type_id"]', form).val();
+
+ this.set_busy(true, 'loading');
+
+ for (i=0; i<events.length; i++) {
+ name = events[i];
+ e = this.env.auto_fields[name];
+
+ if (!e)
+ continue;
+
+ data = {user_type_id: type_id};
+ for (j=0; j<e.data.length; j++) {
+ elem_name = e.data[j];
+ if (elem = $('[name="'+elem_name+'"]', form))
+ data[elem_name] = elem.val();
+ }
+
+ this.api_post('form_value.generate_'+name, data, 'form_value_response');
+ }
+
+ this.set_busy(false);
+ };
+
+ this.form_value_response = function(response)
+ {
+ if (!this.api_response(response))
+ return;
+
+ for (var i in response.result)
+ $('[name="'+i+'"]').val(response.result[i]);
+ };
+
+ this.form_value_error = function(name)
+ {
+ $('[name="'+name+'"]', $('#'+this.env.form_id)).addClass('error');
+ }
+
+ this.form_error_clear = function()
+ {
+ $('input,textarea', $('#'+this.env.form_id)).removeClass('error');
+
+ }
+
+ /*********************************************************/
/********* Client commands *********/
/*********************************************************/
@@ -432,57 +491,26 @@ function kolab_admin()
};
- this.user_save = function(props)
- {
- var data = this.serialize_form('#'+props);
- this.api_post('user.add', data, 'user_save_response');
- };
-
- this.user_save_response = function(response)
- {
- if (!this.api_response(response))
- return;
- };
-
- /*********************************************************/
- /********* Forms *********/
- /*********************************************************/
-
- this.form_value_change = function(form_id, events)
+ this.user_save = function()
{
- var i, j, data, e, elem, name, elem_name,
- form = $('#'+form_id),
- type_id = $('[name="user_type_id"]', form).val();
+ var data = this.serialize_form('#'+this.env.form_id);
- this.set_busy(true, 'loading');
+ this.form_error_clear();
- for (i=0; i<events.length; i++) {
- name = events[i];
- e = this.env.auto_fields[name];
-
- if (!e)
- continue;
-
- data = {user_type_id: type_id};
- for (j=0; j<e.data.length; j++) {
- elem_name = e.data[j];
- if (elem = $('[name="'+elem_name+'"]', form))
- data[elem_name] = elem.val();
- }
-
- this.api_post('form_value.generate_'+name, data, 'form_value_response');
+ // check password
+ if (data.password != data.password2) {
+ this.display_message('user.password.mismatch', 'error');
+ this.form_value_error('password2');
+ return;
}
- this.set_busy(false);
+ this.api_post('user.add', data, 'user_save_response');
};
- this.form_value_response = function(response)
+ this.user_save_response = function(response)
{
if (!this.api_response(response))
return;
-
- for (var i in response.result)
- $('[name="'+i+'"]').val(response.result[i]);
};
};
diff --git a/public_html/skins/default/style.css b/public_html/skins/default/style.css
index dd01ec5..3141897 100644
--- a/public_html/skins/default/style.css
+++ b/public_html/skins/default/style.css
@@ -109,11 +109,13 @@ table.form td {
padding: 1px 5px;
}
-table.form tr.required input {
+table.form tr.required input,
+table.form tr.required textarea {
background-color: #f0f9ff;
}
-table.form tr.error input {
+table.form tr input.error,
+table.form tr textarea.error {
background-color: #f5e3e3;
}
@@ -482,7 +484,6 @@ textarea.readonly {
background-color: #f5f5f5;
}
-
/********* Form smart inputs *********/
span.listarea {
commit 64a5c4f7a510dd7fed443ec3d5a3c4b6898eabf4
Author: Aleksander Machniak <alec at alec.pl>
Date: Tue Feb 21 13:05:14 2012 +0100
Don't hardcode user_type_id
diff --git a/public_html/js/kolab_admin.js b/public_html/js/kolab_admin.js
index 8be609c..4e49f5e 100644
--- a/public_html/js/kolab_admin.js
+++ b/public_html/js/kolab_admin.js
@@ -444,10 +444,15 @@ function kolab_admin()
return;
};
+ /*********************************************************/
+ /********* Forms *********/
+ /*********************************************************/
+
this.form_value_change = function(form_id, events)
{
var i, j, data, e, elem, name, elem_name,
- form = $('#'+form_id);
+ form = $('#'+form_id),
+ type_id = $('[name="user_type_id"]', form).val();
this.set_busy(true, 'loading');
@@ -458,7 +463,7 @@ function kolab_admin()
if (!e)
continue;
- data = {user_type_id: 1}; // @TODO: get user account type from the form
+ data = {user_type_id: type_id};
for (j=0; j<e.data.length; j++) {
elem_name = e.data[j];
if (elem = $('[name="'+elem_name+'"]', form))
commit 30998a87f6804b900d060fd66d86c53791950858
Author: Aleksander Machniak <alec at alec.pl>
Date: Tue Feb 21 12:57:03 2012 +0100
Fixed typo in serialize_form()
diff --git a/lib/client/kolab_client_task_user.php b/lib/client/kolab_client_task_user.php
index 928f30b..69bb996 100644
--- a/lib/client/kolab_client_task_user.php
+++ b/lib/client/kolab_client_task_user.php
@@ -286,6 +286,7 @@ class kolab_client_task_user extends kolab_client_task
'type' => kolab_form::INPUT_TEXT,
'maxlength' => 50,
'required' => true,
+ 'system' => true,
),
'password2' => array(
'label' => 'user.password-confirm',
@@ -293,6 +294,7 @@ class kolab_client_task_user extends kolab_client_task
'type' => kolab_form::INPUT_TEXT,
'maxlength' => 50,
'required' => true,
+ 'system' => true,
),
'kolabhomeserver' => array(
'label' => 'user.homeserver',
@@ -375,7 +377,7 @@ class kolab_client_task_user extends kolab_client_task
foreach ($auto_fields as $af_idx => $af) {
foreach ($fields as $section_idx => $section) {
foreach ($section['fields'] as $idx => $field) {
- if ($idx == $af_idx) {
+ if ($idx == $af_idx && empty($field['system'])) {
$fields[$section_idx]['fields'][$idx]['readonly'] = true;
$fields[$section_idx]['fields'][$idx]['disabled'] = true;
$fields[$section_idx]['fields'][$idx]['required'] = false;
@@ -394,7 +396,7 @@ class kolab_client_task_user extends kolab_client_task
foreach ($fields as $section_idx => $section) {
foreach ($section['fields'] as $idx => $field) {
// Disable fields not allowed for specified user type
- if (!array_key_exists($idx, $form_fields)) {
+ if (empty($field['system']) && !array_key_exists($idx, $form_fields)) {
$fields[$section_idx]['fields'][$idx]['readonly'] = true;
$fields[$section_idx]['fields'][$idx]['disabled'] = true;
$fields[$section_idx]['fields'][$idx]['required'] = false;
diff --git a/public_html/js/kolab_admin.js b/public_html/js/kolab_admin.js
index f88c34f..8be609c 100644
--- a/public_html/js/kolab_admin.js
+++ b/public_html/js/kolab_admin.js
@@ -398,7 +398,7 @@ function kolab_admin()
this.trigger_event('form-serialize', {id: id, json: json});
- return i.json;
+ return json;
};
/*********************************************************/
commit 2f73148c6c3188020968903f1ec85aefa1fe38a1
Author: Aleksander Machniak <alec at alec.pl>
Date: Tue Feb 21 12:50:20 2012 +0100
Small improvements in generate_* methods
diff --git a/lib/api/kolab_api_service_form_value.php b/lib/api/kolab_api_service_form_value.php
index 3b9270a..c914815 100644
--- a/lib/api/kolab_api_service_form_value.php
+++ b/lib/api/kolab_api_service_form_value.php
@@ -31,7 +31,9 @@ class kolab_api_service_form_value extends kolab_api_service
}
}
- return array("cn" => $postdata['givenname'] . " " . $postdata['sn']);
+ $cn = trim($postdata['givenname'] . " " . $postdata['sn']);
+
+ return array("cn" => $cn);
}
}
@@ -47,7 +49,12 @@ class kolab_api_service_form_value extends kolab_api_service
}
}
- return array("displayname" => $postdata['sn'] . ", " . $postdata['givenname']);
+ $displayname = $postdata['givenname'];
+ if ($postdata['sn']) {
+ $displayname = $postdata['sn'] . ", " . $displayname;
+ }
+
+ return array("displayname" => $displayname);
}
}
@@ -68,9 +75,11 @@ class kolab_api_service_form_value extends kolab_api_service
$sn = iconv('UTF-8', 'ASCII//TRANSLIT', $postdata['sn']);
$givenname = strtolower($givenname);
- $sn = str_replace(' ', '', $sn);
$sn = strtolower($sn);
+ $givenname = preg_replace('/[^a-z-_]/i', '', $givenname);
+ $sn = preg_replace('/[^a-z-_]/i', '', $sn);
+
$mail = $givenname . "." . $sn . "@" . $_SESSION['user']->get_domain();
$orig_mail = $mail;
@@ -109,14 +118,12 @@ class kolab_api_service_form_value extends kolab_api_service
$uid = iconv('UTF-8', 'ASCII//TRANSLIT', $postdata['sn']);
$uid = strtolower($uid);
- $uid = str_replace(' ', '', $uid);
+ $uid = preg_replace('/[^a-z-_]/i', '', $uid);
$orig_uid = $uid;
$auth = Auth::get_instance($_SESSION['user']->get_domain());
- $user = $auth->user_find_by_attribute(array('uid' => $uid));
-
$x = 2;
while ($auth->user_find_by_attribute(array('uid' => $uid))) {
$uid = $orig_uid . $x;
commit e9467f8d51a35f5a313480874f4f7549f89ad279
Author: Aleksander Machniak <alec at alec.pl>
Date: Mon Feb 20 15:37:08 2012 +0100
Fix form type detection
diff --git a/lib/client/kolab_client_task_user.php b/lib/client/kolab_client_task_user.php
index 6598865..928f30b 100644
--- a/lib/client/kolab_client_task_user.php
+++ b/lib/client/kolab_client_task_user.php
@@ -158,6 +158,7 @@ class kolab_client_task_user extends kolab_client_task
$utypes = (array) $this->user_types();
$form_id = $attribs['id'];
$accttypes = array();
+ $new = $data === null;
foreach ($utypes as $idx => $elem) {
$accttypes[$idx] = array('value' => $idx, 'content' => $elem['name']);
@@ -411,14 +412,14 @@ class kolab_client_task_user extends kolab_client_task
$this->output->set_env('auto_fields', $auto_fields);
// Hide account type selector if there's only one type
- if (count($accttypes)) {
+ if (count($accttypes) < 2) {
$fields['system']['fields']['user_type_id'] = array(
'type' => kolab_form::INPUT_HIDDEN,
);
}
// New user form
- if ($data === null) {
+ if ($new) {
// Pre-populate password fields
$pass = $this->api->get('form_value.generate_password');
$data['password'] = $data['password2'] = $pass->get('password');
@@ -490,7 +491,7 @@ class kolab_client_task_user extends kolab_client_task
'onclick' => "kadm.user_save('$form_id')",
));
- if ($data !== null) {
+ if (!$new) {
$form->add_button(array(
'value' => kolab_html::escape($this->translate('delete.button')),
'onclick' => "kadm.user_delete('$form_id')",
commit 7f90e723f6d65b7d89ad24123add1aeb8d6b7da4
Author: Aleksander Machniak <machniak at kolabsys.com>
Date: Mon Feb 20 15:34:34 2012 +0100
Fix typo
diff --git a/lib/kolab_api_service.php b/lib/kolab_api_service.php
index 06ebbb9..0372a2c 100644
--- a/lib/kolab_api_service.php
+++ b/lib/kolab_api_service.php
@@ -36,7 +36,7 @@ abstract class kolab_api_service
*/
protected function user_type_attributes($type_id, $required = true)
{
- if (empty($user_id)) {
+ if (empty($type_id)) {
if ($required) {
throw new Exception($this->controller->translate('user.notypeid'), 34);
}
commit 0395c901aefa1abce1b9f7b476786c7583b7fd6c
Author: Aleksander Machniak <alec at alec.pl>
Date: Mon Feb 20 15:23:53 2012 +0100
Fix on user_type_id
diff --git a/lib/client/kolab_client_task_user.php b/lib/client/kolab_client_task_user.php
index 9a18a74..6598865 100644
--- a/lib/client/kolab_client_task_user.php
+++ b/lib/client/kolab_client_task_user.php
@@ -160,7 +160,7 @@ class kolab_client_task_user extends kolab_client_task
$accttypes = array();
foreach ($utypes as $idx => $elem) {
- $accttypes[$idx] = array('value' => $elem['key'], 'content' => $elem['name']);
+ $accttypes[$idx] = array('value' => $idx, 'content' => $elem['name']);
}
$fields = array(
@@ -300,7 +300,7 @@ class kolab_client_task_user extends kolab_client_task
'maxlength' => 50,
'required' => true,
),
- 'accttype' => array(
+ 'user_type_id' => array(
'label' => 'user.type',
'description' => 'user.type.desc',
'type' => kolab_form::INPUT_SELECT,
@@ -357,7 +357,13 @@ class kolab_client_task_user extends kolab_client_task
$form_fields = array();
// Selected account type
- $utype = !empty($data['accttype']) ? $data['accttype'] : key($accttypes);
+ if (!empty($data['user_type_id'])) {
+ $utype = $data['user_type_id'];
+ }
+ else {
+ $utype = key($accttypes);
+ $data['user_type_id'] = $utype;
+ }
if ($utype) {
$auto_fields = (array) $utypes[$utype]['attributes']['auto_form_fields'];
@@ -404,14 +410,12 @@ class kolab_client_task_user extends kolab_client_task
$this->output->set_env('auto_fields', $auto_fields);
-/*
// Hide account type selector if there's only one type
if (count($accttypes)) {
- $fields['system']['fields']['accttype'] = array(
+ $fields['system']['fields']['user_type_id'] = array(
'type' => kolab_form::INPUT_HIDDEN,
);
}
-*/
// New user form
if ($data === null) {
More information about the commits
mailing list