6 commits - lib/client lib/kolab_client_task.php lib/locale public_html/skins
Aleksander Machniak
machniak at kolabsys.com
Thu Mar 22 12:43:37 CET 2012
lib/client/kolab_client_task_group.php | 16 +------
lib/client/kolab_client_task_user.php | 5 --
lib/kolab_client_task.php | 70 ++++++++++++++++++++++++++++++---
lib/locale/en_US.php | 4 +
public_html/skins/default/style.css | 13 ++++++
5 files changed, 88 insertions(+), 20 deletions(-)
New commits:
commit c4230788ffd11c709097129ddbcfa24b8d94ddef
Author: Aleksander Machniak <alec at alec.pl>
Date: Thu Mar 22 12:42:35 2012 +0100
Support new result type of *.info API calls
diff --git a/lib/client/kolab_client_task_group.php b/lib/client/kolab_client_task_group.php
index 7d0dc77..9b57b99 100644
--- a/lib/client/kolab_client_task_group.php
+++ b/lib/client/kolab_client_task_group.php
@@ -168,9 +168,7 @@ class kolab_client_task_group extends kolab_client_task
{
$id = $this->get_input('id', 'POST');
$result = $this->api->get('group.info', array('group' => $id));
- $group = $result->get($id);
-
- $group['dn'] = $id;
+ $group = $result->get();
$output = $this->group_form(null, $group);
$this->output->set_object('taskcontent', $output);
@@ -216,7 +214,7 @@ class kolab_client_task_group extends kolab_client_task
// Prepare fields
list($fields, $types, $type) = $this->form_prepare('group', $data);
- $add_mode = empty($data['dn']);
+ $add_mode = empty($data['entrydn']);
$accttypes = array();
foreach ($types as $idx => $elem) {
@@ -262,7 +260,7 @@ class kolab_client_task_group extends kolab_client_task
}
}
if (!empty($attr_name)) {
- $result = $this->api->get('group.members_list', array('group' => $data['dn']));
+ $result = $this->api->get('group.members_list', array('group' => $data['entrydn']));
$list = (array) $result->get('list');
$data[$attr_name] = $this->parse_members($list);
}
diff --git a/lib/client/kolab_client_task_user.php b/lib/client/kolab_client_task_user.php
index 2f5d05a..4765fb6 100644
--- a/lib/client/kolab_client_task_user.php
+++ b/lib/client/kolab_client_task_user.php
@@ -168,8 +168,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['dn'] = $id;
+ $user = $result->get();
$output = $this->user_form(null, $user);
$this->output->set_object('taskcontent', $output);
@@ -247,7 +246,7 @@ class kolab_client_task_user extends kolab_client_task
// Prepare fields
list($fields, $types, $type) = $this->form_prepare('user', $data, array('userpassword2'));
- $add_mode = empty($data['dn']);
+ $add_mode = empty($data['entrydn']);
$accttypes = array();
foreach ($types as $idx => $elem) {
diff --git a/lib/kolab_client_task.php b/lib/kolab_client_task.php
index 920d8ae..dd5a304 100644
--- a/lib/kolab_client_task.php
+++ b/lib/kolab_client_task.php
@@ -176,7 +176,7 @@ class kolab_client_task
$res = $this->api->get('user.info', array('user' => $login['username']));
$res = $res->get();
- if (is_array($res) && ($res = array_shift($res))) {
+ if (is_array($res) && !empty($res)) {
$user['language'] = $res['preferredlanguage'];
$user['fullname'] = $res['cn'];
}
@@ -502,9 +502,9 @@ class kolab_client_task
}
$result = $this->api->get('user.info', array('user' => $dn));
- $user = $result->get($dn);
+ $username = $result->get('displayname');
- if (empty($user) || empty($user['displayname'])) {
+ if (empty($username)) {
if (preg_match('/^cn=([a-zA=Z ]+)/', $dn, $m)) {
$username = ucwords($m[1]);
}
@@ -672,7 +672,7 @@ class kolab_client_task
{
$types = (array) $this->{$name . '_types'}();
$form_id = $attribs['id'];
- $add_mode = empty($data['dn']);
+ $add_mode = empty($data['entrydn']);
$event_fields = array();
$auto_fields = array();
@@ -917,7 +917,7 @@ class kolab_client_task
'onclick' => "kadm.{$name}_save()",
));
- if (!empty($data['dn'])) {
+ if (!empty($data['entrydn'])) {
$id = $data[$name];
$form->add_button(array(
'value' => kolab_html::escape($this->translate('delete.button')),
commit 4d0ff765cb0ad3d5e9dd5a580ade084d583ba40a
Merge: 18617e0 1f2c4ec
Author: Aleksander Machniak <alec at alec.pl>
Date: Thu Mar 22 12:42:27 2012 +0100
Merge branch 'master' of ssh://git.kolab.org/git/kolab-wap
commit 18617e0d67760e3868feeecae583305c5c961618
Author: Aleksander Machniak <alec at alec.pl>
Date: Thu Mar 22 11:41:25 2012 +0100
Small improvement in unknown user name handling
diff --git a/lib/kolab_client_task.php b/lib/kolab_client_task.php
index 2a49344..920d8ae 100644
--- a/lib/kolab_client_task.php
+++ b/lib/kolab_client_task.php
@@ -182,7 +182,7 @@ class kolab_client_task
}
// @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];
+ $user['fullname'] = ucwords($m[1]);
}
// Save user data
@@ -501,13 +501,13 @@ class kolab_client_task
return $this->cache['user_names'][$dn];
}
- if (preg_match('/^cn=([a-z ]+)$/i', $dn, $m)) {
- $username = $m[1];
- }
- else {
- $result = $this->api->get('user.info', array('user' => $dn));
- $user = $result->get($dn);
- $username = $user['displayname'];
+ $result = $this->api->get('user.info', array('user' => $dn));
+ $user = $result->get($dn);
+
+ if (empty($user) || empty($user['displayname'])) {
+ if (preg_match('/^cn=([a-zA=Z ]+)/', $dn, $m)) {
+ $username = ucwords($m[1]);
+ }
}
return $this->cache['user_names'][$dn] = $username;
commit 2b00ad6155b346a5c40392b2f31f9ee917f3f4fc
Author: Aleksander Machniak <alec at alec.pl>
Date: Thu Mar 22 11:34:35 2012 +0100
Add created/modified by information in edit form
diff --git a/lib/kolab_client_task.php b/lib/kolab_client_task.php
index d8c3fd8..2a49344 100644
--- a/lib/kolab_client_task.php
+++ b/lib/kolab_client_task.php
@@ -39,6 +39,7 @@ class kolab_client_task
protected $ajax_only = false;
protected $page_title = 'Kolab Admin Panel';
protected $menu = array();
+ protected $cache = array();
protected static $translation = array();
@@ -488,6 +489,31 @@ class kolab_client_task
}
/**
+ * Returns user name.
+ *
+ * @param string $dn User DN attribute value
+ *
+ * @return string User name (displayname)
+ */
+ protected function user_name($dn)
+ {
+ if (!empty($this->cache['user_names']) && isset($this->cache['user_names'][$dn])) {
+ return $this->cache['user_names'][$dn];
+ }
+
+ if (preg_match('/^cn=([a-z ]+)$/i', $dn, $m)) {
+ $username = $m[1];
+ }
+ else {
+ $result = $this->api->get('user.info', array('user' => $dn));
+ $user = $result->get($dn);
+ $username = $user['displayname'];
+ }
+
+ return $this->cache['user_names'][$dn] = $username;
+ }
+
+ /**
* Returns list of system capabilities.
*
* @return array List of system capabilities
@@ -745,6 +771,27 @@ class kolab_client_task
}
}
else {
+ // Add common information fields
+ $add_fields = array(
+ 'creatorsname' => 'createtimestamp',
+ 'modifiersname' => 'modifytimestamp',
+ );
+ foreach ($add_fields as $idx => $val) {
+ if (!empty($data[$idx])) {
+ if ($value = $this->user_name($data[$idx])) {
+ if ($data[$val]) {
+ $value .= ' (' . strftime('%x %X', strtotime($data[$val])) . ')';
+ }
+
+ $fields[$idx] = array(
+ 'label' => $idx,
+ 'section' => 'system',
+ 'value' => $value,
+ );
+ }
+ }
+ }
+
// Add debug information
ksort($data);
$debug = kolab_html::escape(print_r($data, true));
@@ -752,9 +799,9 @@ class kolab_client_task
$debug = str_replace("\n ", "\n", $debug);
$debug = '<pre class="debug">' . $debug . '</pre>';
$fields['debug'] = array(
- 'label' => 'debug',
+ 'label' => 'debug',
'section' => 'system',
- 'value' => $debug,
+ 'value' => $debug,
);
}
@@ -816,7 +863,7 @@ class kolab_client_task
$field['description'] = "$name.$idx.desc";
$field['section'] = $section_idx;
- if (!empty($data[$idx])) {
+ if (empty($field['value']) && !empty($data[$idx])) {
$field['value'] = $data[$idx];
// Convert data for the list field with autocompletion
diff --git a/lib/locale/en_US.php b/lib/locale/en_US.php
index aaaee08..773810b 100644
--- a/lib/locale/en_US.php
+++ b/lib/locale/en_US.php
@@ -10,6 +10,9 @@ $LANG['internalerror'] = 'Internal system error!';
$LANG['welcome'] = 'Welcome to the Kolab Groupware Server Maintenance';
$LANG['reqtime'] = 'Request time: $1 sec.';
$LANG['debug'] = 'Debug info';
+$LANG['info'] = 'Information';
+$LANG['creatorsname'] = 'Created by';
+$LANG['modifiersname'] = 'Modified by';
$LANG['login.username'] = 'Username:';
$LANG['login.password'] = 'Password:';
commit a70979b8555b6c009c882766fb434884c9371dc9
Author: Aleksander Machniak <alec at alec.pl>
Date: Thu Mar 22 10:33:32 2012 +0100
Unify 'dn' item usage
diff --git a/lib/client/kolab_client_task_group.php b/lib/client/kolab_client_task_group.php
index 2882163..7d0dc77 100644
--- a/lib/client/kolab_client_task_group.php
+++ b/lib/client/kolab_client_task_group.php
@@ -170,7 +170,7 @@ class kolab_client_task_group extends kolab_client_task
$result = $this->api->get('group.info', array('group' => $id));
$group = $result->get($id);
- $group['group'] = $id;
+ $group['dn'] = $id;
$output = $this->group_form(null, $group);
$this->output->set_object('taskcontent', $output);
@@ -216,7 +216,7 @@ class kolab_client_task_group extends kolab_client_task
// Prepare fields
list($fields, $types, $type) = $this->form_prepare('group', $data);
- $add_mode = empty($data['group']);
+ $add_mode = empty($data['dn']);
$accttypes = array();
foreach ($types as $idx => $elem) {
@@ -254,7 +254,7 @@ class kolab_client_task_group extends kolab_client_task
}
// Members (get member names)
- if (!empty($data['group'])) {
+ if (!$add_mode) {
// find members attribute name
foreach (array('member', 'uniquemember') as $attr) {
if (isset($fields[$attr]) && isset($data[$attr])) {
@@ -262,7 +262,7 @@ class kolab_client_task_group extends kolab_client_task
}
}
if (!empty($attr_name)) {
- $result = $this->api->get('group.members_list', array('group' => $data['group']));
+ $result = $this->api->get('group.members_list', array('group' => $data['dn']));
$list = (array) $result->get('list');
$data[$attr_name] = $this->parse_members($list);
}
diff --git a/lib/client/kolab_client_task_user.php b/lib/client/kolab_client_task_user.php
index d53318d..2f5d05a 100644
--- a/lib/client/kolab_client_task_user.php
+++ b/lib/client/kolab_client_task_user.php
@@ -169,7 +169,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;
+ $user['dn'] = $id;
$output = $this->user_form(null, $user);
$this->output->set_object('taskcontent', $output);
@@ -247,7 +247,7 @@ class kolab_client_task_user extends kolab_client_task
// Prepare fields
list($fields, $types, $type) = $this->form_prepare('user', $data, array('userpassword2'));
- $add_mode = empty($data['user']);
+ $add_mode = empty($data['dn']);
$accttypes = array();
foreach ($types as $idx => $elem) {
diff --git a/lib/kolab_client_task.php b/lib/kolab_client_task.php
index a9c835e..d8c3fd8 100644
--- a/lib/kolab_client_task.php
+++ b/lib/kolab_client_task.php
@@ -646,7 +646,7 @@ class kolab_client_task
{
$types = (array) $this->{$name . '_types'}();
$form_id = $attribs['id'];
- $add_mode = empty($data[$name]);
+ $add_mode = empty($data['dn']);
$event_fields = array();
$auto_fields = array();
@@ -746,6 +746,7 @@ class kolab_client_task
}
else {
// Add debug information
+ ksort($data);
$debug = kolab_html::escape(print_r($data, true));
$debug = preg_replace('/(^Array\n\(|\n*\)$|\t)/', '', $debug);
$debug = str_replace("\n ", "\n", $debug);
@@ -869,7 +870,7 @@ class kolab_client_task
'onclick' => "kadm.{$name}_save()",
));
- if ($data[$name]) {
+ if (!empty($data['dn'])) {
$id = $data[$name];
$form->add_button(array(
'value' => kolab_html::escape($this->translate('delete.button')),
commit 5d0cf20bd602428c5ed79f2807ebf12f9d15c19d
Author: Aleksander Machniak <alec at alec.pl>
Date: Thu Mar 22 10:28:07 2012 +0100
Unified debug information in edit forms
diff --git a/lib/client/kolab_client_task_group.php b/lib/client/kolab_client_task_group.php
index dd6e0e4..2882163 100644
--- a/lib/client/kolab_client_task_group.php
+++ b/lib/client/kolab_client_task_group.php
@@ -268,12 +268,6 @@ class kolab_client_task_group extends kolab_client_task
}
}
-$fields['debug'] = array(
- 'label' => 'debug',
- 'section' => 'system',
- 'value' => '<pre>'.kolab_html::escape(print_r($data, true)).'</pre>',
-);
-
// Create form object and populate with fields
$form = $this->form_create('group', $attribs, $sections, $fields, $fields_map, $data);
diff --git a/lib/kolab_client_task.php b/lib/kolab_client_task.php
index 6ee696f..a9c835e 100644
--- a/lib/kolab_client_task.php
+++ b/lib/kolab_client_task.php
@@ -744,6 +744,18 @@ class kolab_client_task
$data = array_merge((array)$data, (array)$resp->get());
}
}
+ else {
+ // Add debug information
+ $debug = kolab_html::escape(print_r($data, true));
+ $debug = preg_replace('/(^Array\n\(|\n*\)$|\t)/', '', $debug);
+ $debug = str_replace("\n ", "\n", $debug);
+ $debug = '<pre class="debug">' . $debug . '</pre>';
+ $fields['debug'] = array(
+ 'label' => 'debug',
+ 'section' => 'system',
+ 'value' => $debug,
+ );
+ }
return array($fields, $types, $type);
}
diff --git a/lib/locale/en_US.php b/lib/locale/en_US.php
index ca1ecde..aaaee08 100644
--- a/lib/locale/en_US.php
+++ b/lib/locale/en_US.php
@@ -9,6 +9,7 @@ $LANG['loginerror'] = 'Incorrect username or password!';
$LANG['internalerror'] = 'Internal system error!';
$LANG['welcome'] = 'Welcome to the Kolab Groupware Server Maintenance';
$LANG['reqtime'] = 'Request time: $1 sec.';
+$LANG['debug'] = 'Debug info';
$LANG['login.username'] = 'Username:';
$LANG['login.password'] = 'Password:';
diff --git a/public_html/skins/default/style.css b/public_html/skins/default/style.css
index 74cca9c..beddecc 100644
--- a/public_html/skins/default/style.css
+++ b/public_html/skins/default/style.css
@@ -495,6 +495,19 @@ input.maxsize {
width: 368px; /* span.listarea width - 2px */
}
+pre.debug {
+ border: 1px solid #d0d0d0;
+ border-radius: 3px;
+ -moz-border-radius: 3px;
+ -webkit-border-radius: 3px;
+ background-color: white;
+ padding: 2px;
+ width: 500px;
+ height: 200px;
+ margin: 0;
+ overflow: auto;
+}
+
/********* Form smart inputs *********/
span.listarea {
More information about the commits
mailing list