summaryrefslogtreecommitdiff
path: root/program/steps
diff options
context:
space:
mode:
Diffstat (limited to 'program/steps')
-rw-r--r--program/steps/addressbook/func.inc44
-rw-r--r--program/steps/addressbook/groups.inc8
2 files changed, 27 insertions, 25 deletions
diff --git a/program/steps/addressbook/func.inc b/program/steps/addressbook/func.inc
index ec0662b24..060185010 100644
--- a/program/steps/addressbook/func.inc
+++ b/program/steps/addressbook/func.inc
@@ -50,7 +50,8 @@ if (!empty($_REQUEST['_search']) && isset($_SESSION['search'][$_REQUEST['_search
// set data source env
$OUTPUT->set_env('source', $source ? $source : '0');
$OUTPUT->set_env('readonly', $CONTACTS->readonly, false);
-$OUTPUT->set_env('address_sources', $js_list);
+if(! $OUTPUT->ajax_call)
+ $OUTPUT->set_env('address_sources', $js_list);
function rcmail_directory_list($attrib)
@@ -62,6 +63,7 @@ function rcmail_directory_list($attrib)
$out = '';
$local_id = '0';
+ $jsdata = array();
$current = get_input_value('_source', RCUBE_INPUT_GPC);
$line_templ = html::tag('li', array('id' => 'rcmli%s', 'class' => 'addressbook %s'),
html::a(array('href' => '%s', 'onclick' => "return ".JS_OBJECT_NAME.".command('list','%s',this)"), '%s'));
@@ -81,37 +83,37 @@ function rcmail_directory_list($attrib)
$dom_id = preg_replace('/[^a-z0-9\-_]/i', '', $id);
$out .= sprintf($line_templ, $dom_id, ($current == $id ? 'selected' : ''),
Q(rcmail_url(null, array('_source' => $id))), $js_id, (!empty($source['name']) ? Q($source['name']) : Q($id)));
+ $groupdata = rcmail_contact_groups(array('out' => $out, 'jsdata' => $jsdata, 'source' => $id));
+ $jsdata = $groupdata['jsdata'];
+ $out = $groupdata['out'];
}
-
- $out .= rcmail_contact_groups(array('items' => true));
+ $OUTPUT->set_env('contactgroups', $jsdata);
$OUTPUT->add_gui_object('folderlist', $attrib['id']);
return html::tag('ul', $attrib, $out, html::$common_attrib);
}
-function rcmail_contact_groups($attrib)
+function rcmail_contact_groups($args)
{
- global $CONTACTS, $OUTPUT;
-
- if (!$attrib['id'])
- $attrib['id'] = 'rcmgroupslist';
-
- $groups = $CONTACTS->list_groups();
- $line_templ = html::tag('li', array('id' => 'rcmliG%s', 'class' => 'contactgroup'),
- html::a(array('href' => '#', 'onclick' => "return ".JS_OBJECT_NAME.".command('listgroup','%s',this)"), '%s'));
+ global $RCMAIL;
- $jsdata = array();
- foreach ($groups as $group) {
- $out .= sprintf($line_templ, $group['ID'], $group['ID'], Q($group['name']));
- $jsdata['G'.$group['ID']] = array('id' => $group['ID'], 'name' => $group['name'], 'type' => 'group');
+ $groups = $RCMAIL->get_address_book($args['source'])->list_groups();
+
+ if (!empty($groups)) {
+ $line_templ = html::tag('li', array('id' => 'rcmliG%s%s', 'class' => 'contactgroup'),
+ html::a(array('href' => '#', 'onclick' => "return ".JS_OBJECT_NAME.".command('listgroup',{'source':'%s','id':'%s'},this)"), '%s'));
+
+ $jsdata = array();
+ foreach ($groups as $group) {
+ $args['out'] .= sprintf($line_templ, $args['source'], $group['ID'], $args['source'], $group['ID'], Q($group['name']));
+ $args['jsdata']['G'.$args['source'].$group['ID']] = array(
+ 'source' => $args['source'], 'id' => $group['ID'], 'name' => $group['name'], 'type' => 'group');
+ }
}
-
- $OUTPUT->set_env('contactgroups', $jsdata);
- //$OUTPUT->add_gui_object('groupslist', $attrib['id']);
-
- return $attrib['items'] ? $out : html::tag('ul', $attrib, $out, html::$common_attrib);
+
+ return $args;
}
diff --git a/program/steps/addressbook/groups.inc b/program/steps/addressbook/groups.inc
index eda258c6e..c98d4d840 100644
--- a/program/steps/addressbook/groups.inc
+++ b/program/steps/addressbook/groups.inc
@@ -19,7 +19,6 @@
*/
-
if ($CONTACTS->readonly || !$CONTACTS->groups) {
$OUTPUT->show_message('sourceisreadonly', 'warning');
$OUTPUT->send();
@@ -62,6 +61,7 @@ else if ($RCMAIL->action == 'group-create') {
}
if ($created && $OUTPUT->ajax_call) {
+ $created['source'] = $source;
$OUTPUT->command('insert_contact_group', $created);
}
else if (!$created) {
@@ -77,7 +77,7 @@ else if ($RCMAIL->action == 'group-rename') {
}
if ($newname && $OUTPUT->ajax_call)
- $OUTPUT->command('update_contact_group', $gid, $newname);
+ $OUTPUT->command('update_contact_group', array('source' => $source, 'id' => $gid, 'name' => $newname));
else if (!$newname)
$OUTPUT->show_message($plugin['message'] ? $plugin['message'] : 'errorsaving', 'error');
}
@@ -90,7 +90,7 @@ else if ($RCMAIL->action == 'group-delete') {
}
if ($deleted)
- $OUTPUT->command('remove_group_item', $gid);
+ $OUTPUT->command('remove_group_item', array('source' => $source, 'id' => $gid));
else
$OUTPUT->show_message($plugin['message'] ? $plugin['message'] : 'errorsaving', 'error');
}
@@ -98,4 +98,4 @@ else if ($RCMAIL->action == 'group-delete') {
// send response
$OUTPUT->send();
-?> \ No newline at end of file
+?>