summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAleksander Machniak <alec@alec.pl>2012-03-16 14:31:21 +0100
committerAleksander Machniak <alec@alec.pl>2012-03-16 14:31:21 +0100
commita1b3f65163e80ec7e8bae0dbc57b9af0980c5c5d (patch)
treedff6dc006e8ad7b57d25cfae47d747bcb2c60d7b
parent312fc2521b6a2a1097c877af755e4974ae26bc92 (diff)
downloadwebadmin-a1b3f65163e80ec7e8bae0dbc57b9af0980c5c5d.tar.gz
Groups UI
-rw-r--r--lib/client/kolab_client_task_group.php126
-rw-r--r--lib/locale/en_US.php3
-rw-r--r--public_html/js/kolab_admin.js38
-rw-r--r--public_html/skins/default/style.css5
4 files changed, 156 insertions, 16 deletions
diff --git a/lib/client/kolab_client_task_group.php b/lib/client/kolab_client_task_group.php
index 673bd90..23b9eb5 100644
--- a/lib/client/kolab_client_task_group.php
+++ b/lib/client/kolab_client_task_group.php
@@ -30,19 +30,25 @@ class kolab_client_task_group extends kolab_client_task
'add' => 'group.add',
);
+ /**
+ * Default action.
+ */
public function action_default()
{
- $this->output->set_object('content', '');
+ $this->output->set_object('content', 'group', true);
$this->output->set_object('task_navigation', $this->menu());
$this->action_list();
}
+ /**
+ * Groups list action.
+ */
public function action_list()
{
$page_size = 20;
$page = (int) self::get_input('page', 'POST');
- if (!$page) {
+ if (!$page || $page < 1) {
$page = 1;
}
@@ -55,35 +61,127 @@ class kolab_client_task_group extends kolab_client_task
'page' => $page,
);
- $result = $this->api->get('groups.list');
+/*
+ // search parameters
+ if (!empty($_POST['search'])) {
+ $search = self::get_input('search', 'POST', true);
+ $field = self::get_input('field', 'POST');
+ $method = self::get_input('method', 'POST');
+
+ $search_request = array(
+ $field => array(
+ 'value' => $search,
+ 'type' => $method,
+ ),
+ );
+ }
+ else if (!empty($_POST['search_request'])) {
+ $search_request = self::get_input('search_request', 'POST');
+ $search_request = @unserialize(base64_decode($search_request));
+ }
+
+ if (!empty($search_request)) {
+ $post['search'] = $search_request;
+ $post['search_operator'] = 'OR';
+ }
+*/
+ // get groups list
+ $result = $this->api->post('groups.list', null, $post);
$count = (int) $result->get('count');
$result = (array) $result->get('list');
- foreach ($result as $idx => $item) {
- if (!is_array($item) || empty($item['cn'])) {
- unset($result[$idx]);
- continue;
+ // calculate records
+ if ($count) {
+ $start = 1 + max(0, $page - 1) * $page_size;
+ $end = min($start + $page_size - 1, $count);
+ }
+
+ $rows = $head = $foot = array();
+ $cols = array('name');
+ $i = 0;
+
+ // table header
+ $head[0]['cells'][] = array('class' => 'name', 'body' => $this->translate('group.list'));
+
+ // table footer (navigation)
+ if ($count) {
+ $pages = ceil($count / $page_size);
+ $prev = max(0, $page - 1);
+ $next = $page < $pages ? $page + 1 : 0;
+
+ $count_str = kolab_html::span(array(
+ 'content' => $this->translate('group.list.records', $start, $end, $count)), true);
+ $prev = kolab_html::a(array(
+ 'class' => 'prev' . ($prev ? '' : ' disabled'),
+ 'href' => '#',
+ 'onclick' => $prev ? "kadm.command('group.list', {page: $prev})" : "return false",
+ ));
+ $next = kolab_html::a(array(
+ 'class' => 'next' . ($next ? '' : ' disabled'),
+ 'href' => '#',
+ 'onclick' => $next ? "kadm.command('group.list', {page: $next})" : "return false",
+ ));
+
+ $foot_body = kolab_html::span(array('content' => $prev . $count_str . $next));
+ }
+ $foot[0]['cells'][] = array('class' => 'listnav', 'body' => $foot_body);
+
+ // table body
+ if (!empty($result)) {
+ foreach ($result as $idx => $item) {
+ if (!is_array($item) || empty($item['cn'])) {
+ continue;
+ }
+
+ $i++;
+ $cells = array();
+ $cells[] = array('class' => 'name', 'body' => kolab_html::escape($item['cn']),
+ 'onclick' => "kadm.command('group.info', '$idx')");
+ $rows[] = array('id' => $i, 'class' => 'selectable', 'cells' => $cells);
}
- $result[$idx] = sprintf('<li><a href="#" onclick="kadm.command(\'group.info\', \'%s\')">%s</a></li>',
- $idx, $item['cn']);
}
+ else {
+ $rows[] = array('cells' => array(
+ 0 => array('class' => 'empty-body', 'body' => $this->translate('group.norecords')
+ )));
+ }
+
+ $table = kolab_html::table(array(
+ 'id' => 'grouplist',
+ 'class' => 'list',
+ 'head' => $head,
+ 'body' => $rows,
+ 'foot' => $foot,
+ ));
- $result = '<ul id="grouplist">' . implode("\n", $result) . '</ul>';
- $this->output->set_object('content', $result);
+ $this->output->set_env('search_request', $search_request ? base64_encode(serialize($search_request)) : null);
+ $this->output->set_env('list_page', $page);
+ $this->output->set_env('list_count', $count);
+
+ $this->watermark('taskcontent');
+ $this->output->set_object('grouplist', $table);
}
+ /**
+ * Group information (form) action.
+ */
public function action_info()
{
-
$id = $this->get_input('id', 'POST');
$result = $this->api->get('group.info', array('group' => $id));
+ $group = $result->get($id);
+ $group['group'] = $id;
- $group = $result->get($id);
- $this->output->set_object('content', print_r($group, true));
+ $this->output->set_object('taskcontent', print_r($group, true));
}
public function group_add()
{
}
+
+ public function search_form()
+ {
+ return '';
+ }
}
diff --git a/lib/locale/en_US.php b/lib/locale/en_US.php
index 49cdb79..2e7f4a8 100644
--- a/lib/locale/en_US.php
+++ b/lib/locale/en_US.php
@@ -89,6 +89,9 @@ $LANG['user.shell'] = 'Shell';
$LANG['user.uidnumber'] = 'User ID number';
$LANG['group.add'] = 'Add Group';
+$LANG['group.norecords'] = 'No group records found!';
+$LANG['group.list'] = 'Groups List';
+$LANG['group.list.records'] = '$1 to $2 of $3';
$LANG['MB'] = 'MB';
$LANG['days'] = 'days';
diff --git a/public_html/js/kolab_admin.js b/public_html/js/kolab_admin.js
index 69bab51..5bddf5d 100644
--- a/public_html/js/kolab_admin.js
+++ b/public_html/js/kolab_admin.js
@@ -577,6 +577,44 @@ function kolab_admin()
this.display_message('user.add.success');
this.command('user.list', {page: this.env.list_page});
};
+
+ this.group_info = function(id)
+ {
+ this.http_post('group.info', {id: id});
+ };
+
+ this.group_list = function(props)
+ {
+ if (!props)
+ props = {};
+
+ if (props.search === undefined && this.env.search_request)
+ props.search_request = this.env.search_request;
+
+ this.http_post('group.list', props);
+ };
+
+ this.group_delete = function(groupid)
+ {
+ this.set_busy(true, 'deleting');
+ this.api_post('group.delete', {group: userid}, 'group_delete_response');
+ };
+
+ this.group_delete_response = function(response)
+ {
+ if (!this.api_response(response))
+ return;
+
+ var page = this.env.list_page;
+
+ // goto previous page if last user on the current page has been deleted
+ if (this.env.list_count)
+ page -= 1;
+
+ this.display_message('group.delete.success');
+ this.command('group.list', {page: page});
+ };
+
};
var kadm = new kolab_admin();
diff --git a/public_html/skins/default/style.css b/public_html/skins/default/style.css
index ba6247a..96cfa30 100644
--- a/public_html/skins/default/style.css
+++ b/public_html/skins/default/style.css
@@ -722,8 +722,9 @@ fieldset.tabbed
vertical-align: top;
}
-/**** User task elements ****/
+/**** User/Group task elements ****/
-#userlist table {
+#userlist table,
+#grouplist table {
width: 100%;
}