]> git.donarmstrong.com Git - roundcube.git/blob - program/steps/addressbook/show.inc
Imported Upstream version 0.2~stable
[roundcube.git] / program / steps / addressbook / show.inc
1 <?php
2
3 /*
4  +-----------------------------------------------------------------------+
5  | program/steps/addressbook/show.inc                                    |
6  |                                                                       |
7  | This file is part of the RoundCube Webmail client                     |
8  | Copyright (C) 2005-2008, RoundCube Dev. - Switzerland                 |
9  | Licensed under the GNU GPL                                            |
10  |                                                                       |
11  | PURPOSE:                                                              |
12  |   Show contact details                                                |
13  |                                                                       |
14  +-----------------------------------------------------------------------+
15  | Author: Thomas Bruederli <roundcube@gmail.com>                        |
16  +-----------------------------------------------------------------------+
17
18  $Id: show.inc 1615 2008-07-29 12:32:19Z thomasb $
19
20 */
21
22
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']);
26 }
27
28 function rcmail_contact_details($attrib)
29 {
30   global $CONTACTS, $OUTPUT;
31
32   // check if we have a valid result
33   if (!(($result = $CONTACTS->get_result()) && ($record = $result->first()))) {
34     $OUTPUT->show_message('contactnotfound');
35     return false;
36   }
37   
38   // a specific part is requested
39   if ($attrib['part']) {
40     return Q($record[$attrib['part']]);
41   }
42
43   // return the complete address record as table
44   $table = new html_table(array('cols' => 2));
45
46   $a_show_cols = array('name', 'firstname', 'surname', 'email');
47   $microformats = array('name' => 'fn', 'email' => 'email');
48
49   foreach ($a_show_cols as $col) {
50     if ($col == 'email' && !empty($record[$col])) {
51       $value = html::a(array(
52         'href' => 'mailto:' . $record[$col],
53         'onclick' => sprintf("return %s.command('compose','%s',this)", JS_OBJECT_NAME, JQ($record[$col])),
54         'title' => rcube_label('composeto'),
55         'class' => $microformats[$col],
56       ), Q($record[$col]));
57     }
58     else if (!empty($record[$col])) {
59       $value = html::span($microformats[$col], Q($record[$col]));
60     }
61     else
62       $value = '';
63     
64     $table->add('title', Q(rcube_label($col)));
65     $table->add(null, $value);
66   }
67   
68   return $table->show($attrib + array('class' => 'vcard'));
69 }
70
71
72 //$OUTPUT->framed = $_framed;
73 $OUTPUT->add_handler('contactdetails', 'rcmail_contact_details');
74 $OUTPUT->send('showcontact');
75 ?>