summaryrefslogtreecommitdiff
path: root/program/steps/addressbook/func.inc
diff options
context:
space:
mode:
Diffstat (limited to 'program/steps/addressbook/func.inc')
-rw-r--r--program/steps/addressbook/func.inc44
1 files changed, 23 insertions, 21 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;
}