commit | author | age
|
4e17e6
|
1 |
<?php |
T |
2 |
|
a95874
|
3 |
/** |
4e17e6
|
4 |
+-----------------------------------------------------------------------+ |
T |
5 |
| program/steps/addressbook/show.inc | |
|
6 |
| | |
e019f2
|
7 |
| This file is part of the Roundcube Webmail client | |
f5d2ee
|
8 |
| Copyright (C) 2005-2013, The Roundcube Dev Team | |
7fe381
|
9 |
| | |
T |
10 |
| Licensed under the GNU General Public License version 3 or | |
|
11 |
| any later version with exceptions for skins & plugins. | |
|
12 |
| See the README file for a full license statement. | |
4e17e6
|
13 |
| | |
T |
14 |
| PURPOSE: | |
|
15 |
| Show contact details | |
|
16 |
| | |
|
17 |
+-----------------------------------------------------------------------+ |
|
18 |
| Author: Thomas Bruederli <roundcube@gmail.com> | |
|
19 |
+-----------------------------------------------------------------------+ |
|
20 |
*/ |
|
21 |
|
ecf295
|
22 |
// Get contact ID and source ID from request |
A |
23 |
$cids = rcmail_get_cids(); |
|
24 |
$source = key($cids); |
384948
|
25 |
$cid = $cids ? array_shift($cids[$source]) : null; |
ecf295
|
26 |
|
A |
27 |
// Initialize addressbook source |
c3dabf
|
28 |
$CONTACTS = rcmail_contact_source($source, true); |
A |
29 |
$SOURCE_ID = $source; |
4e17e6
|
30 |
|
a62ff1
|
31 |
// read contact record (or get the one defined in 'save' action) |
AM |
32 |
if ($cid && ($record = ($CONTACT_RECORD ?: $CONTACTS->get_record($cid, true)))) { |
4cf42f
|
33 |
$OUTPUT->set_env('readonly', $CONTACTS->readonly || $record['readonly']); |
a79417
|
34 |
$OUTPUT->set_env('cid', $record['ID']); |
765a0b
|
35 |
|
AM |
36 |
// remember current search request ID (if in search mode) |
|
37 |
if ($search = rcube_utils::get_input_value('_search', rcube_utils::INPUT_GET)) { |
|
38 |
$OUTPUT->set_env('search_request', $search); |
|
39 |
} |
f92aba
|
40 |
} |
cb7d32
|
41 |
|
cc90ed
|
42 |
// get address book name (for display) |
da89cf
|
43 |
rcmail_set_sourcename($CONTACTS); |
f5d2ee
|
44 |
|
AM |
45 |
$OUTPUT->add_handlers(array( |
|
46 |
'contacthead' => 'rcmail_contact_head', |
|
47 |
'contactdetails' => 'rcmail_contact_details', |
|
48 |
'contactphoto' => 'rcmail_contact_photo', |
|
49 |
)); |
|
50 |
|
|
51 |
$OUTPUT->send('contact'); |
|
52 |
|
cc90ed
|
53 |
|
0501b6
|
54 |
|
T |
55 |
function rcmail_contact_head($attrib) |
f92aba
|
56 |
{ |
a79417
|
57 |
global $CONTACTS, $RCMAIL; |
4e17e6
|
58 |
|
a79417
|
59 |
// check if we have a valid result |
A |
60 |
if (!(($result = $CONTACTS->get_result()) && ($record = $result->first()))) { |
f768a6
|
61 |
$RCMAIL->output->show_message('contactnotfound', 'error'); |
a79417
|
62 |
return false; |
4e17e6
|
63 |
} |
a79417
|
64 |
|
0501b6
|
65 |
$form = array( |
T |
66 |
'head' => array( // section 'head' is magic! |
24e89e
|
67 |
'name' => $RCMAIL->gettext('contactnameandorg'), |
0501b6
|
68 |
'content' => array( |
f7af22
|
69 |
'prefix' => array('type' => 'text'), |
AM |
70 |
'firstname' => array('type' => 'text'), |
|
71 |
'middlename' => array('type' => 'text'), |
|
72 |
'surname' => array('type' => 'text'), |
|
73 |
'suffix' => array('type' => 'text'), |
|
74 |
'name' => array('type' => 'text'), |
|
75 |
'nickname' => array('type' => 'text'), |
|
76 |
'organization' => array('type' => 'text'), |
|
77 |
'department' => array('type' => 'text'), |
|
78 |
'jobtitle' => array('type' => 'text'), |
0501b6
|
79 |
), |
T |
80 |
), |
|
81 |
); |
|
82 |
|
|
83 |
unset($attrib['name']); |
|
84 |
return rcmail_contact_form($form, $record, $attrib); |
|
85 |
} |
|
86 |
|
|
87 |
|
|
88 |
function rcmail_contact_details($attrib) |
|
89 |
{ |
|
90 |
global $CONTACTS, $RCMAIL, $CONTACT_COLTYPES; |
|
91 |
|
|
92 |
// check if we have a valid result |
|
93 |
if (!(($result = $CONTACTS->get_result()) && ($record = $result->first()))) { |
|
94 |
return false; |
|
95 |
} |
|
96 |
|
827159
|
97 |
$i_size = $attrib['size'] ?: 40; |
a79417
|
98 |
|
A |
99 |
$form = array( |
29aab5
|
100 |
'contact' => array( |
6b2b2e
|
101 |
'name' => $RCMAIL->gettext('properties'), |
a79417
|
102 |
'content' => array( |
0501b6
|
103 |
'email' => array('size' => $i_size, 'render_func' => 'rcmail_render_email_value'), |
T |
104 |
'phone' => array('size' => $i_size), |
|
105 |
'address' => array(), |
|
106 |
'website' => array('size' => $i_size, 'render_func' => 'rcmail_render_url_value'), |
|
107 |
'im' => array('size' => $i_size), |
fbeb46
|
108 |
), |
T |
109 |
), |
|
110 |
'personal' => array( |
6b2b2e
|
111 |
'name' => $RCMAIL->gettext('personalinfo'), |
fbeb46
|
112 |
'content' => array( |
T |
113 |
'gender' => array('size' => $i_size), |
|
114 |
'maidenname' => array('size' => $i_size), |
|
115 |
'birthday' => array('size' => $i_size), |
|
116 |
'anniversary' => array('size' => $i_size), |
|
117 |
'manager' => array('size' => $i_size), |
|
118 |
'assistant' => array('size' => $i_size), |
|
119 |
'spouse' => array('size' => $i_size), |
a79417
|
120 |
), |
A |
121 |
), |
|
122 |
); |
6b2b2e
|
123 |
|
0501b6
|
124 |
if (isset($CONTACT_COLTYPES['notes'])) { |
T |
125 |
$form['notes'] = array( |
6b2b2e
|
126 |
'name' => $RCMAIL->gettext('notes'), |
0501b6
|
127 |
'content' => array( |
T |
128 |
'notes' => array('type' => 'textarea', 'label' => false), |
|
129 |
), |
|
130 |
); |
f92aba
|
131 |
} |
6b2b2e
|
132 |
|
0501b6
|
133 |
if ($CONTACTS->groups) { |
T |
134 |
$form['groups'] = array( |
6b2b2e
|
135 |
'name' => $RCMAIL->gettext('groups'), |
0501b6
|
136 |
'content' => rcmail_contact_record_groups($record['ID']), |
T |
137 |
); |
a79417
|
138 |
} |
A |
139 |
|
|
140 |
return rcmail_contact_form($form, $record); |
0501b6
|
141 |
} |
T |
142 |
|
|
143 |
|
3725cf
|
144 |
function rcmail_render_email_value($email) |
0501b6
|
145 |
{ |
6b2b2e
|
146 |
global $RCMAIL; |
AM |
147 |
|
0501b6
|
148 |
return html::a(array( |
T |
149 |
'href' => 'mailto:' . $email, |
6b2b2e
|
150 |
'onclick' => sprintf("return %s.command('compose','%s',this)", rcmail_output::JS_OBJECT_NAME, rcube::JQ($email)), |
AM |
151 |
'title' => $RCMAIL->gettext('composeto'), |
0501b6
|
152 |
'class' => 'email', |
6b2b2e
|
153 |
), rcube::Q($email)); |
0501b6
|
154 |
} |
T |
155 |
|
|
156 |
|
3725cf
|
157 |
function rcmail_render_url_value($url) |
0501b6
|
158 |
{ |
f2e946
|
159 |
$prefix = preg_match('!^(http|ftp)s?://!', $url) ? '' : 'http://'; |
0501b6
|
160 |
return html::a(array( |
T |
161 |
'href' => $prefix . $url, |
|
162 |
'target' => '_blank', |
|
163 |
'class' => 'url', |
6b2b2e
|
164 |
), rcube::Q($url)); |
f92aba
|
165 |
} |
4e17e6
|
166 |
|
T |
167 |
|
a79417
|
168 |
function rcmail_contact_record_groups($contact_id) |
cb7d32
|
169 |
{ |
a79417
|
170 |
global $RCMAIL, $CONTACTS, $GROUPS; |
cb7d32
|
171 |
|
a79417
|
172 |
$GROUPS = $CONTACTS->list_groups(); |
A |
173 |
|
|
174 |
if (empty($GROUPS)) { |
|
175 |
return ''; |
|
176 |
} |
|
177 |
|
42b9ce
|
178 |
$members = $CONTACTS->get_record_groups($contact_id); |
AM |
179 |
$table = new html_table(array('cols' => 2, 'cellspacing' => 0, 'border' => 0)); |
a79417
|
180 |
$checkbox = new html_checkbox(array('name' => '_gid[]', |
A |
181 |
'class' => 'groupmember', 'disabled' => $CONTACTS->readonly)); |
|
182 |
|
42b9ce
|
183 |
foreach ($GROUPS as $group) { |
a79417
|
184 |
$gid = $group['ID']; |
A |
185 |
$table->add(null, $checkbox->show($members[$gid] ? $gid : null, |
|
186 |
array('value' => $gid, 'id' => 'ff_gid' . $gid))); |
6b2b2e
|
187 |
$table->add(null, html::label('ff_gid' . $gid, rcube::Q($group['name']))); |
a79417
|
188 |
} |
A |
189 |
|
6b2b2e
|
190 |
$hiddenfields = new html_hiddenfield(array('name' => '_source', 'value' => rcube_utils::get_input_value('_source', rcube_utils::INPUT_GPC))); |
c027ba
|
191 |
$hiddenfields->add(array('name' => '_cid', 'value' => $contact_id)); |
a79417
|
192 |
|
A |
193 |
$form_start = $RCMAIL->output->request_form(array( |
|
194 |
'name' => "form", 'method' => "post", |
|
195 |
'task' => $RCMAIL->task, 'action' => 'save', |
|
196 |
'request' => 'save.'.intval($contact_id), |
|
197 |
'noclose' => true), $hiddenfields->show()); |
|
198 |
$form_end = '</form>'; |
|
199 |
|
|
200 |
$RCMAIL->output->add_gui_object('editform', 'form'); |
2c77f5
|
201 |
$RCMAIL->output->add_label('addingmember', 'removingmember'); |
ecf295
|
202 |
|
aa3a9a
|
203 |
return $form_start . html::tag('fieldset', 'contactfieldgroup contactgroups', $table->show()) . $form_end; |
cb7d32
|
204 |
} |