source: github/program/steps/addressbook/show.inc @ 83ba22c

HEADcourier-fixdev-browser-capabilitiespdorelease-0.6release-0.7release-0.8
Last change on this file since 83ba22c was 83ba22c, checked in by alecpl <alec@…>, 3 years ago
  • Unify template files naming
  • Property mode set to 100644
File size: 4.6 KB
RevLine 
[4e17e6c]1<?php
2
3/*
4 +-----------------------------------------------------------------------+
5 | program/steps/addressbook/show.inc                                    |
6 |                                                                       |
[e019f2d]7 | This file is part of the Roundcube Webmail client                     |
8 | Copyright (C) 2005-2009, Roundcube Dev. - Switzerland                 |
[30233b8]9 | Licensed under the GNU GPL                                            |
[4e17e6c]10 |                                                                       |
11 | PURPOSE:                                                              |
12 |   Show contact details                                                |
13 |                                                                       |
14 +-----------------------------------------------------------------------+
15 | Author: Thomas Bruederli <roundcube@gmail.com>                        |
16 +-----------------------------------------------------------------------+
17
18 $Id$
19
20*/
21
22
[f115416]23// read contact record
[f92aba3]24if (($cid = get_input_value('_cid', RCUBE_INPUT_GPC)) && ($record = $CONTACTS->get_record($cid, true))) {
[a79417d]25    $OUTPUT->set_env('cid', $record['ID']);
[f92aba3]26}
[4e17e6c]27
[cb7d32e]28
[4e17e6c]29function rcmail_contact_details($attrib)
[f92aba3]30{
[a79417d]31    global $CONTACTS, $RCMAIL;
[4e17e6c]32
[a79417d]33    // check if we have a valid result
34    if (!(($result = $CONTACTS->get_result()) && ($record = $result->first()))) {
35        $RCMAIL->output->show_message('contactnotfound');
36        return false;
37    }
38
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;
42
43    $microformats = array('name' => 'fn', 'email' => 'email');
44
45    $form = array(
46        'info' => array(
47            'name'    => rcube_label('contactproperties'),
48            'content' => array(
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),
53            ),
54        ),
55        'groups' => array(
56            'name'    => rcube_label('groups'),
57            'content' => '',
58        ),
59    );
60
61    // Get content of groups fieldset
62    if ($groups = rcmail_contact_record_groups($record['ID'])) {
63        $form['groups']['content'] = $groups;   
[f92aba3]64    }
[a79417d]65    else {
66        unset($form['groups']);
[f92aba3]67    }
[a79417d]68
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']));
76    }
77    foreach (array('name', 'firstname', 'surname') as $col) {
78        if ($record[$col]) {
79            $form['info']['content'][$col]['value'] = html::span($microformats[$col], Q($record[$col]));
80        }
81    }
82
83    return rcmail_contact_form($form, $record);
[f92aba3]84}
[4e17e6c]85
86
[a79417d]87function rcmail_contact_record_groups($contact_id)
[cb7d32e]88{
[a79417d]89    global $RCMAIL, $CONTACTS, $GROUPS;
90
91    $GROUPS = $CONTACTS->list_groups();
92
93    if (empty($GROUPS)) {
94        return '';
95    }
96
97    $table = new html_table(array('cols' => 2, 'cellspacing' => 0, 'border' => 0));
[cb7d32e]98
[a79417d]99    $members = $CONTACTS->get_record_groups($contact_id);
100    $checkbox = new html_checkbox(array('name' => '_gid[]',
101        'class' => 'groupmember', 'disabled' => $CONTACTS->readonly));
102
103    foreach ($GROUPS as $group) {
104        $gid = $group['ID'];
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'])));
108    }
109
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']));
112
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>';
119
120    $RCMAIL->output->add_gui_object('editform', 'form');
[cb7d32e]121 
[a79417d]122    return $form_start . $table->show() . $form_end;
[cb7d32e]123}
124
125
[f115416]126//$OUTPUT->framed = $_framed;
127$OUTPUT->add_handler('contactdetails', 'rcmail_contact_details');
[a79417d]128
[83ba22c]129$OUTPUT->send('contact');
Note: See TracBrowser for help on using the repository browser.