4 +-----------------------------------------------------------------------+
5 | program/steps/addressbook/show.inc |
7 | This file is part of the Roundcube Webmail client |
8 | Copyright (C) 2005-2009, Roundcube Dev. - Switzerland |
9 | Licensed under the GNU GPL |
12 | Show contact details |
14 +-----------------------------------------------------------------------+
15 | Author: Thomas Bruederli <roundcube@gmail.com> |
16 +-----------------------------------------------------------------------+
18 $Id: show.inc 4176 2010-11-04 09:59:55Z alec $
23 // read contact record
24 if (($cid = get_input_value('_cid', RCUBE_INPUT_GPC)) && ($record = $CONTACTS->get_record($cid, true))) {
25 $OUTPUT->set_env('cid', $record['ID']);
29 function rcmail_contact_details($attrib)
31 global $CONTACTS, $RCMAIL;
33 // check if we have a valid result
34 if (!(($result = $CONTACTS->get_result()) && ($record = $result->first()))) {
35 $RCMAIL->output->show_message('contactnotfound');
39 $i_size = !empty($attrib['size']) ? $attrib['size'] : 40;
40 $t_rows = !empty($attrib['textarearows']) ? $attrib['textarearows'] : 6;
41 $t_cols = !empty($attrib['textareacols']) ? $attrib['textareacols'] : 40;
43 $microformats = array('name' => 'fn', 'email' => 'email');
47 'name' => rcube_label('contactproperties'),
49 'name' => array('type' => 'text', 'size' => $i_size),
50 'firstname' => array('type' => 'text', 'size' => $i_size),
51 'surname' => array('type' => 'text', 'size' => $i_size),
52 'email' => array('type' => 'text', 'size' => $i_size),
56 'name' => rcube_label('groups'),
61 // Get content of groups fieldset
62 if ($groups = rcmail_contact_record_groups($record['ID'])) {
63 $form['groups']['content'] = $groups;
66 unset($form['groups']);
69 if (!empty($record['email'])) {
70 $form['info']['content']['email']['value'] = html::a(array(
71 'href' => 'mailto:' . $record['email'],
72 'onclick' => sprintf("return %s.command('compose','%s',this)", JS_OBJECT_NAME, JQ($record['email'])),
73 'title' => rcube_label('composeto'),
74 'class' => $microformats['email'],
75 ), Q($record['email']));
77 foreach (array('name', 'firstname', 'surname') as $col) {
79 $form['info']['content'][$col]['value'] = html::span($microformats[$col], Q($record[$col]));
83 return rcmail_contact_form($form, $record);
87 function rcmail_contact_record_groups($contact_id)
89 global $RCMAIL, $CONTACTS, $GROUPS;
91 $GROUPS = $CONTACTS->list_groups();
97 $table = new html_table(array('cols' => 2, 'cellspacing' => 0, 'border' => 0));
99 $members = $CONTACTS->get_record_groups($contact_id);
100 $checkbox = new html_checkbox(array('name' => '_gid[]',
101 'class' => 'groupmember', 'disabled' => $CONTACTS->readonly));
103 foreach ($GROUPS as $group) {
105 $table->add(null, $checkbox->show($members[$gid] ? $gid : null,
106 array('value' => $gid, 'id' => 'ff_gid' . $gid)));
107 $table->add(null, html::label('ff_gid' . $gid, Q($group['name'])));
110 $hiddenfields = new html_hiddenfield(array('name' => '_source', 'value' => get_input_value('_source', RCUBE_INPUT_GPC)));
111 $hiddenfields->add(array('name' => '_cid', 'value' => $record['ID']));
113 $form_start = $RCMAIL->output->request_form(array(
114 'name' => "form", 'method' => "post",
115 'task' => $RCMAIL->task, 'action' => 'save',
116 'request' => 'save.'.intval($contact_id),
117 'noclose' => true), $hiddenfields->show());
118 $form_end = '</form>';
120 $RCMAIL->output->add_gui_object('editform', 'form');
122 return $form_start . $table->show() . $form_end;
126 //$OUTPUT->framed = $_framed;
127 $OUTPUT->add_handler('contactdetails', 'rcmail_contact_details');
129 $OUTPUT->send('contact');