summaryrefslogtreecommitdiff
path: root/program/steps
diff options
context:
space:
mode:
authorthomascube <thomas@roundcube.net>2010-10-22 15:24:39 +0000
committerthomascube <thomas@roundcube.net>2010-10-22 15:24:39 +0000
commitcb7d32ebdd1c783f201e2f3fa6c52f1fafdc6fcf (patch)
treef82963865616671696c87c3ff5a4ca577941bf7c /program/steps
parent6a16031d043ab1a3999ecae6181ecb50cb6f1636 (diff)
List groups in address detail view and allow to subscribe/unsubscribe from there (#1486753)
Diffstat (limited to 'program/steps')
-rw-r--r--program/steps/addressbook/show.inc35
1 files changed, 35 insertions, 0 deletions
diff --git a/program/steps/addressbook/show.inc b/program/steps/addressbook/show.inc
index c714ce139..c5784d61d 100644
--- a/program/steps/addressbook/show.inc
+++ b/program/steps/addressbook/show.inc
@@ -25,6 +25,10 @@ if (($cid = get_input_value('_cid', RCUBE_INPUT_GPC)) && ($record = $CONTACTS->g
$OUTPUT->set_env('cid', $record['ID']);
}
+$GROUPS = $CONTACTS->list_groups();
+$OUTPUT->set_env('groups', !empty($GROUPS));
+
+
function rcmail_contact_details($attrib)
{
global $CONTACTS, $OUTPUT;
@@ -69,6 +73,37 @@ function rcmail_contact_details($attrib)
}
+function rcmail_contact_record_groups($attrib)
+{
+ global $RCMAIL, $CONTACTS, $GROUPS;
+
+ // check if we have a valid result
+ if (!(($result = $CONTACTS->get_result()) && ($record = $result->first())))
+ return false;
+
+ $table = new html_table(array('cols' => 2, 'cellspacing' => 0, 'border' => 0));
+
+ $members = $CONTACTS->get_record_groups($record['ID']);
+ $checkbox = new html_checkbox(array('name' => '_gid[]', 'class' => 'groupmember', 'disabled' => $CONTACTS->readonly));
+ foreach ($GROUPS as $group) {
+ $gid = $group['ID'];
+ $table->add(null, $checkbox->show($members[$gid] ? $gid : null, array('value' => $gid, 'id' => 'ff_gid' . $gid)));
+ $table->add(null, html::label('ff_gid' . $gid, Q($group['name'])));
+ }
+
+ $hiddenfields = new html_hiddenfield(array('name' => '_source', 'value' => get_input_value('_source', RCUBE_INPUT_GPC)));
+ $hiddenfields->add(array('name' => '_cid', 'value' => $record['ID']));
+
+ $form_start = $RCMAIL->output->request_form(array('name' => "form", 'method' => "post", 'task' => $RCMAIL->task, 'action' => 'save', 'request' => 'save.'.intval($record['ID']), 'noclose' => true) + $attrib, $hiddenfields->show());
+ $form_end = !strlen($attrib['form']) ? '</form>' : '';
+
+ $RCMAIL->output->add_gui_object('editform', !empty($attrib['form']) ? $attrib['form'] : 'form');
+
+ return $form_start . $table->show($attrib) . $form_end;
+}
+
+
//$OUTPUT->framed = $_framed;
$OUTPUT->add_handler('contactdetails', 'rcmail_contact_details');
+$OUTPUT->add_handler('contactgroups', 'rcmail_contact_record_groups');
$OUTPUT->send('showcontact');