Daniel Hoffend
2015-06-03 8fab64e594f60f28b94814244cfc9a4aca1334f6
commit | author | age
992009 1 <?php
AM 2
3 /*
4  +-----------------------------------------------------------------------+
5  | program/steps/addressbook/print.inc                                   |
6  |                                                                       |
7  | This file is part of the Roundcube Webmail client                     |
8  | Copyright (C) 2005-2015, The Roundcube Dev Team                       |
9  | Copyright (C) 2011-2015, Kolab Systems AG                             |
10  |                                                                       |
11  | Licensed under the GNU General Public License version 3 or            |
12  | any later version with exceptions for skins & plugins.                |
13  | See the README file for a full license statement.                     |
14  |                                                                       |
15  | PURPOSE:                                                              |
16  |   Print contact details                                               |
17  |                                                                       |
18  +-----------------------------------------------------------------------+
19  | Author: Thomas Bruederli <roundcube@gmail.com>                        |
20  | Author: Aleksander Machniak <machniak@kolabsys.com>                   |
21  +-----------------------------------------------------------------------+
22 */
23
24 // Get contact ID and source ID from request
25 $cids   = rcmail_get_cids();
26 $source = key($cids);
27 $cid    = $cids ? array_shift($cids[$source]) : null;
28
29 // Initialize addressbook source
30 $CONTACTS  = rcmail_contact_source($source, true);
31 $SOURCE_ID = $source;
32
33 // read contact record
34 if ($cid && $CONTACTS) {
35     $record = $CONTACTS->get_record($cid, true);
36 }
37
38 $OUTPUT->add_handlers(array(
39     'contacthead'    => 'rcmail_contact_head',
40     'contactdetails' => 'rcmail_contact_details',
41     'contactphoto'   => 'rcmail_contact_photo',
42 ));
43
44 $OUTPUT->send('contactprint');
45
46
47
48 function rcmail_contact_head($attrib)
49 {
50     global $CONTACTS, $RCMAIL;
51
52     // check if we have a valid result
53     if (!(($result = $CONTACTS->get_result()) && ($record = $result->first()))) {
54         $RCMAIL->output->show_message('contactnotfound', 'error');
55         return false;
56     }
57
58     $form = array(
59         'head' => array(  // section 'head' is magic!
60             'name' => $RCMAIL->gettext('contactnameandorg'),
61             'content' => array(
62                 'prefix'     => array(),
63                 'name'       => array(),
64                 'firstname'  => array(),
65                 'middlename' => array(),
66                 'surname'    => array(),
67                 'suffix'     => array(),
68             ),
69         ),
70     );
71
72     unset($attrib['name']);
73     return rcmail_contact_form($form, $record, $attrib);
74 }
75
76
77 function rcmail_contact_details($attrib)
78 {
79     global $CONTACTS, $RCMAIL, $CONTACT_COLTYPES;
80
81     // check if we have a valid result
82     if (!(($result = $CONTACTS->get_result()) && ($record = $result->first()))) {
83         return false;
84     }
85
86     $i_size = !empty($attrib['size']) ? $attrib['size'] : 40;
87
88     $form = array(
89         'contact' => array(
90             'name'    => $RCMAIL->gettext('properties'),
91             'content' => array(
92                 'organization' => array(),
93                 'department'   => array(),
94                 'jobtitle'     => array(),
95                 'email'        => array(),
96                 'phone'        => array(),
97                 'address'      => array(),
98                 'website'      => array(),
99                 'im'           => array(),
8fab64 100                 'groups'       => array(),
992009 101             ),
AM 102         ),
103         'personal' => array(
104             'name'    => $RCMAIL->gettext('personalinfo'),
105             'content' => array(
106                 'nickname'    => array(),
107                 'gender'      => array(),
108                 'maidenname'  => array(),
109                 'birthday'    => array(),
110                 'anniversary' => array(),
111                 'manager'     => array(),
112                 'assistant'   => array(),
113                 'spouse'      => array(),
114             ),
115         ),
116     );
117
118     if (isset($CONTACT_COLTYPES['notes'])) {
119         $form['notes'] = array(
120             'name'    => $RCMAIL->gettext('notes'),
121             'content' => array(
122                 'notes' => array('type' => 'textarea', 'label' => false),
123             ),
124         );
125     }
126
127     if ($CONTACTS->groups) {
128         $groups = $CONTACTS->get_record_groups($record['ID']);
129         if (!empty($groups)) {
130             $form['contact']['content']['groups'] = array(
131                 'value' => rcube::Q(implode(', ', $groups)),
132                 'label' => $RCMAIL->gettext('groups')
133             );
134         }
135     }
136
137     return rcmail_contact_form($form, $record);
138 }