4 +-----------------------------------------------------------------------+
5 | program/steps/addressbook/func.inc |
7 | This file is part of the Roundcube Webmail client |
8 | Copyright (C) 2005-2007, The Roundcube Dev Team |
9 | Licensed under the GNU GPL |
12 | Provide addressbook functionality and GUI objects |
14 +-----------------------------------------------------------------------+
15 | Author: Thomas Bruederli <roundcube@gmail.com> |
16 +-----------------------------------------------------------------------+
18 $Id: func.inc 5165 2011-09-05 08:49:04Z thomasb $
22 $SEARCH_MODS_DEFAULT = array('name'=>1, 'firstname'=>1, 'surname'=>1, 'email'=>1, '*'=>1);
24 // general definition of contact coltypes
25 $CONTACT_COLTYPES = array(
26 'name' => array('type' => 'text', 'size' => 40, 'maxlength' => 50, 'limit' => 1, 'label' => rcube_label('name'), 'category' => 'main'),
27 'firstname' => array('type' => 'text', 'size' => 19, 'maxlength' => 50, 'limit' => 1, 'label' => rcube_label('firstname'), 'category' => 'main'),
28 'surname' => array('type' => 'text', 'size' => 19, 'maxlength' => 50, 'limit' => 1, 'label' => rcube_label('surname'), 'category' => 'main'),
29 'email' => array('type' => 'text', 'size' => 40, 'maxlength' => 50, 'label' => rcube_label('email'), 'subtypes' => array('home','work','other'), 'category' => 'main'),
30 'middlename' => array('type' => 'text', 'size' => 19, 'maxlength' => 50, 'limit' => 1, 'label' => rcube_label('middlename'), 'category' => 'main'),
31 'prefix' => array('type' => 'text', 'size' => 8, 'maxlength' => 20, 'limit' => 1, 'label' => rcube_label('nameprefix'), 'category' => 'main'),
32 'suffix' => array('type' => 'text', 'size' => 8, 'maxlength' => 20, 'limit' => 1, 'label' => rcube_label('namesuffix'), 'category' => 'main'),
33 'nickname' => array('type' => 'text', 'size' => 40, 'maxlength' => 50, 'limit' => 1, 'label' => rcube_label('nickname'), 'category' => 'main'),
34 'jobtitle' => array('type' => 'text', 'size' => 40, 'maxlength' => 50, 'limit' => 1, 'label' => rcube_label('jobtitle'), 'category' => 'main'),
35 'organization' => array('type' => 'text', 'size' => 40, 'maxlength' => 50, 'limit' => 1, 'label' => rcube_label('organization'), 'category' => 'main'),
36 'department' => array('type' => 'text', 'size' => 40, 'maxlength' => 50, 'limit' => 1, 'label' => rcube_label('department'), 'category' => 'main'),
37 'gender' => array('type' => 'select', 'limit' => 1, 'label' => rcube_label('gender'), 'options' => array('male' => rcube_label('male'), 'female' => rcube_label('female')), 'category' => 'personal'),
38 'maidenname' => array('type' => 'text', 'size' => 40, 'maxlength' => 50, 'limit' => 1, 'label' => rcube_label('maidenname'), 'category' => 'personal'),
39 'phone' => array('type' => 'text', 'size' => 40, 'maxlength' => 20, 'label' => rcube_label('phone'), 'subtypes' => array('home','home2','work','work2','mobile','main','homefax','workfax','car','pager','video','assistant','other'), 'category' => 'main'),
40 'address' => array('type' => 'composite', 'label' => rcube_label('address'), 'subtypes' => array('home','work','other'), 'childs' => array(
41 'street' => array('type' => 'text', 'size' => 40, 'maxlength' => 50, 'label' => rcube_label('street'), 'category' => 'main'),
42 'locality' => array('type' => 'text', 'size' => 28, 'maxlength' => 50, 'label' => rcube_label('locality'), 'category' => 'main'),
43 'zipcode' => array('type' => 'text', 'size' => 8, 'maxlength' => 15, 'label' => rcube_label('zipcode'), 'category' => 'main'),
44 'region' => array('type' => 'text', 'size' => 12, 'maxlength' => 50, 'label' => rcube_label('region'), 'category' => 'main'),
45 'country' => array('type' => 'text', 'size' => 40, 'maxlength' => 50, 'label' => rcube_label('country'), 'category' => 'main'),
46 ), 'category' => 'main'),
47 'birthday' => array('type' => 'date', 'size' => 12, 'maxlength' => 16, 'label' => rcube_label('birthday'), 'limit' => 1, 'render_func' => 'rcmail_format_date_col', 'category' => 'personal'),
48 'anniversary' => array('type' => 'date', 'size' => 12, 'maxlength' => 16, 'label' => rcube_label('anniversary'), 'limit' => 1, 'render_func' => 'rcmail_format_date_col', 'category' => 'personal'),
49 'website' => array('type' => 'text', 'size' => 40, 'maxlength' => 50, 'label' => rcube_label('website'), 'subtypes' => array('homepage','work','blog','profile','other'), 'category' => 'main'),
50 'im' => array('type' => 'text', 'size' => 40, 'maxlength' => 50, 'label' => rcube_label('instantmessenger'), 'subtypes' => array('aim','icq','msn','yahoo','jabber','skype','other'), 'category' => 'main'),
51 'notes' => array('type' => 'textarea', 'size' => 40, 'rows' => 15, 'maxlength' => 500, 'label' => rcube_label('notes'), 'limit' => 1),
52 'photo' => array('type' => 'image', 'limit' => 1, 'category' => 'main'),
53 'assistant' => array('type' => 'text', 'size' => 40, 'maxlength' => 50, 'limit' => 1, 'label' => rcube_label('assistant'), 'category' => 'personal'),
54 'manager' => array('type' => 'text', 'size' => 40, 'maxlength' => 50, 'limit' => 1, 'label' => rcube_label('manager'), 'category' => 'personal'),
55 'spouse' => array('type' => 'text', 'size' => 40, 'maxlength' => 50, 'limit' => 1, 'label' => rcube_label('spouse'), 'category' => 'personal'),
56 // TODO: define fields for vcards like GEO, KEY
61 if (!$RCMAIL->action && !$OUTPUT->ajax_call) {
62 // add list of address sources to client env
63 $js_list = $RCMAIL->get_address_sources();
65 $source = get_input_value('_source', RCUBE_INPUT_GPC);
67 // use first directory by default
68 if (!strlen($source) || !isset($js_list[$source]))
69 $source = $js_list[key($js_list)]['id'];
71 // count all/writeable sources
74 foreach ($js_list as $sid => $s) {
76 if (!$s['readonly']) {
79 // unset hidden sources
81 unset($js_list[$sid]);
85 $search_mods = $RCMAIL->config->get('addressbook_search_mods', $SEARCH_MODS_DEFAULT);
86 $OUTPUT->set_env('search_mods', $search_mods);
87 $OUTPUT->set_env('address_sources', $js_list);
88 $OUTPUT->set_env('writable_source', $writeable);
90 $OUTPUT->set_pagetitle(rcube_label('addressbook'));
91 $_SESSION['addressbooks_count'] = $count;
92 $_SESSION['addressbooks_count_writeable'] = $writeable;
95 $source = strval(key($js_list));
97 $CONTACTS = rcmail_contact_source($source, true);
100 // remove undo information...
101 if ($undo = $_SESSION['contact_undo']) {
103 $undo_time = $RCMAIL->config->get('undo_timeout', 0);
104 if ($undo['ts'] < time() - $undo_time)
105 $RCMAIL->session->remove('contact_undo');
108 // instantiate a contacts object according to the given source
109 function rcmail_contact_source($source=null, $init_env=false, $writable=false)
111 global $RCMAIL, $OUTPUT, $CONFIG, $CONTACT_COLTYPES;
113 if (!strlen($source)) {
114 $source = get_input_value('_source', RCUBE_INPUT_GPC);
118 $CONTACTS = $RCMAIL->get_address_book($source, $writable);
119 $CONTACTS->set_pagesize($CONFIG['pagesize']);
121 // set list properties and session vars
122 if (!empty($_GET['_page']))
123 $CONTACTS->set_page(($_SESSION['page'] = intval($_GET['_page'])));
125 $CONTACTS->set_page(isset($_SESSION['page']) ? $_SESSION['page'] : 1);
127 if (!empty($_REQUEST['_gid']))
128 $CONTACTS->set_group(get_input_value('_gid', RCUBE_INPUT_GPC));
133 $OUTPUT->set_env('readonly', $CONTACTS->readonly);
134 $OUTPUT->set_env('source', $source);
136 // reduce/extend $CONTACT_COLTYPES with specification from the current $CONTACT object
137 if (is_array($CONTACTS->coltypes)) {
138 // remove cols not listed by the backend class
139 $contact_cols = $CONTACTS->coltypes[0] ? array_flip($CONTACTS->coltypes) : $CONTACTS->coltypes;
140 $CONTACT_COLTYPES = array_intersect_key($CONTACT_COLTYPES, $contact_cols);
141 // add associative coltypes definition
142 if (!$CONTACTS->coltypes[0]) {
143 foreach ($CONTACTS->coltypes as $col => $colprop)
144 $CONTACT_COLTYPES[$col] = $CONTACT_COLTYPES[$col] ? array_merge($CONTACT_COLTYPES[$col], $colprop) : $colprop;
148 $OUTPUT->set_env('photocol', is_array($CONTACT_COLTYPES['photo']));
154 function rcmail_default_source($writable=false)
158 // get list of address sources
159 $first = reset($RCMAIL->get_address_sources($writable));
161 // use first directory by default
165 function rcmail_set_sourcename($abook)
169 // get address book name (for display)
170 if ($abook && $_SESSION['addressbooks_count'] > 1) {
171 $name = $abook->get_name();
172 if (!$name && $source == 0) {
173 $name = rcube_label('personaladrbook');
175 $OUTPUT->set_env('sourcename', $name);
180 function rcmail_directory_list($attrib)
182 global $RCMAIL, $OUTPUT;
185 $attrib['id'] = 'rcmdirectorylist';
191 $line_templ = html::tag('li', array(
192 'id' => 'rcmli%s', 'class' => '%s'),
193 html::a(array('href' => '%s',
195 'onclick' => "return ".JS_OBJECT_NAME.".command('list','%s',this)"), '%s'));
197 $sources = (array) $OUTPUT->env['address_sources'];
200 // currently selected source
201 $current = get_input_value('_source', RCUBE_INPUT_GPC);
203 foreach ($sources as $j => $source) {
204 $id = strval(strlen($source['id']) ? $source['id'] : $j);
208 $class_name = 'addressbook';
209 if ($current === $id)
210 $class_name .= ' selected';
211 if ($source['readonly'])
212 $class_name .= ' readonly';
213 if ($source['class_name'])
214 $class_name .= ' ' . $source['class_name'];
216 $out .= sprintf($line_templ,
217 html_identifier($id),
219 Q(rcmail_url(null, array('_source' => $id))),
221 $js_id, (!empty($source['name']) ? Q($source['name']) : Q($id)));
223 $groupdata = array('out' => $out, 'jsdata' => $jsdata, 'source' => $id);
224 if ($source['groups'])
225 $groupdata = rcmail_contact_groups($groupdata);
226 $jsdata = $groupdata['jsdata'];
227 $out = $groupdata['out'];
230 $OUTPUT->set_env('contactgroups', $jsdata);
231 $OUTPUT->add_gui_object('folderlist', $attrib['id']);
232 // add some labels to client
233 $OUTPUT->add_label('deletegroupconfirm', 'groupdeleting', 'addingmember', 'removingmember');
235 return html::tag('ul', $attrib, $out, html::$common_attrib);
239 function rcmail_contact_groups($args)
243 $groups = $RCMAIL->get_address_book($args['source'])->list_groups();
245 if (!empty($groups)) {
246 $line_templ = html::tag('li', array(
247 'id' => 'rcmliG%s', 'class' => 'contactgroup'),
248 html::a(array('href' => '#',
250 'onclick' => "return ".JS_OBJECT_NAME.".command('listgroup',{'source':'%s','id':'%s'},this)"), '%s'));
253 foreach ($groups as $group) {
254 $args['out'] .= sprintf($line_templ,
255 html_identifier($args['source'] . $group['ID']),
256 $args['source'], $group['ID'],
257 $args['source'], $group['ID'], Q($group['name'])
259 $args['jsdata']['G'.$args['source'].$group['ID']] = array(
260 'source' => $args['source'], 'id' => $group['ID'],
261 'name' => $group['name'], 'type' => 'group');
269 // return the contacts list as HTML table
270 function rcmail_contacts_list($attrib)
272 global $CONTACTS, $OUTPUT;
274 // define list of cols to be displayed
275 $a_show_cols = array('name');
277 // add id to message list table if not specified
278 if (!strlen($attrib['id']))
279 $attrib['id'] = 'rcmAddressList';
281 // create XHTML table
282 $out = rcube_table_output($attrib, array(), $a_show_cols, $CONTACTS->primary_key);
285 $OUTPUT->add_gui_object('contactslist', $attrib['id']);
286 $OUTPUT->set_env('current_page', (int)$CONTACTS->list_page);
287 $OUTPUT->include_script('list.js');
289 // add some labels to client
290 $OUTPUT->add_label('deletecontactconfirm', 'copyingcontact');
296 function rcmail_js_contacts_list($result, $prefix='')
300 if (empty($result) || $result->count == 0)
303 // define list of cols to be displayed
304 $a_show_cols = array('name');
306 while ($row = $result->next()) {
307 $a_row_cols = array();
309 // build contact ID with source ID
310 if (isset($row['sourceid'])) {
311 $row['ID'] = $row['ID'].'-'.$row['sourceid'];
315 foreach ($a_show_cols as $col) {
317 if ($val == '' && $col == 'name') {
318 $val = rcube_addressbook::compose_display_name($row, true);
321 $a_row_cols[$col] = Q($val);
324 $OUTPUT->command($prefix.'add_contact_row', $row['ID'], $a_row_cols);
329 // similar function as /steps/settings/identities.inc::rcmail_identity_frame()
330 function rcmail_contact_frame($attrib)
335 $attrib['id'] = 'rcmcontactframe';
337 $attrib['name'] = $attrib['id'];
339 $OUTPUT->set_env('contentframe', $attrib['name']);
340 $OUTPUT->set_env('blankpage', $attrib['src'] ? $OUTPUT->abs_url($attrib['src']) : 'program/blank.gif');
342 return html::iframe($attrib);
346 function rcmail_rowcount_display($attrib)
351 $attrib['id'] = 'rcmcountdisplay';
353 $OUTPUT->add_gui_object('countdisplay', $attrib['id']);
355 return html::span($attrib, rcube_label('loading'));
359 function rcmail_get_rowcount_text($result=null)
361 global $CONTACTS, $CONFIG;
363 // read nr of contacts
365 $result = $CONTACTS->get_result();
368 if ($result->count == 0)
369 $out = rcube_label('nocontactsfound');
371 $out = rcube_label(array(
372 'name' => 'contactsfromto',
374 'from' => $result->first + 1,
375 'to' => min($result->count, $result->first + $CONFIG['pagesize']),
376 'count' => $result->count)
383 function rcmail_get_type_label($type)
385 $label = 'type'.$type;
386 if (rcube_label_exists($label))
387 return rcube_label($label);
388 else if (preg_match('/\w+(\d+)$/', $label, $m)
389 && ($label = preg_replace('/(\d+)$/', '', $label))
390 && rcube_label_exists($label))
391 return rcube_label($label) . ' ' . $m[1];
393 return ucfirst($type);
397 function rcmail_contact_form($form, $record, $attrib = null)
399 global $RCMAIL, $CONFIG;
401 // Allow plugins to modify contact form content
402 $plugin = $RCMAIL->plugins->exec_hook('contact_form', array(
403 'form' => $form, 'record' => $record));
405 $form = $plugin['form'];
406 $record = $plugin['record'];
407 $edit_mode = $RCMAIL->action != 'show';
408 $del_button = $attrib['deleteicon'] ? html::img(array('src' => $CONFIG['skin_path'] . $attrib['deleteicon'], 'alt' => rcube_label('delete'))) : rcube_label('delete');
409 unset($attrib['deleteicon']);
412 // get default coltypes
413 $coltypes = $GLOBALS['CONTACT_COLTYPES'];
414 $coltype_labels = array();
416 foreach ($coltypes as $col => $prop) {
417 if ($prop['subtypes']) {
418 $subtype_names = array_map('rcmail_get_type_label', $prop['subtypes']);
419 $select_subtype = new html_select(array('name' => '_subtype_'.$col.'[]', 'class' => 'contactselectsubtype'));
420 $select_subtype->add($subtype_names, $prop['subtypes']);
421 $coltypes[$col]['subtypes_select'] = $select_subtype->show();
423 if ($prop['childs']) {
424 foreach ($prop['childs'] as $childcol => $cp)
425 $coltype_labels[$childcol] = array('label' => $cp['label']);
429 foreach ($form as $section => $fieldset) {
430 // skip empty sections
431 if (empty($fieldset['content']))
434 $select_add = new html_select(array('class' => 'addfieldmenu', 'rel' => $section));
435 $select_add->add(rcube_label('addfield'), '');
437 // render head section with name fields (not a regular list of rows)
438 if ($section == 'head') {
441 // unset display name if it is composed from name parts
442 if ($record['name'] == rcube_addressbook::compose_display_name(array('name' => '') + (array)$record))
443 unset($record['name']);
446 $field_blocks = array(
447 'names' => array('prefix','firstname','middlename','surname','suffix'),
448 'displayname' => array('name'),
449 'nickname' => array('nickname'),
450 'organization' => array('organization'),
451 'department' => array('department'),
452 'jobtitle' => array('jobtitle'),
454 foreach ($field_blocks as $blockname => $colnames) {
456 foreach ($colnames as $col) {
457 // skip cols unknown to the backend
458 if (!$coltypes[$col])
461 // only string values are expected here
462 if (is_array($record[$col]))
463 $record[$col] = join(' ', $record[$col]);
465 if ($RCMAIL->action == 'show') {
466 if (!empty($record[$col]))
467 $fields .= html::span('namefield ' . $col, Q($record[$col])) . " ";
470 $colprop = (array)$fieldset['content'][$col] + (array)$coltypes[$col];
471 $colprop['id'] = 'ff_'.$col;
472 if (empty($record[$col]) && !$colprop['visible']) {
473 $colprop['style'] = 'display:none';
474 $select_add->add($colprop['label'], $col);
476 $fields .= rcmail_get_edit_field($col, $record[$col], $colprop, $colprop['type']);
479 $content .= html::div($blockname, $fields);
483 $content .= html::p('addfield', $select_add->show(null));
485 $out .= html::tag('fieldset', $attrib, (!empty($fieldset['name']) ? html::tag('legend', null, Q($fieldset['name'])) : '') . $content) ."\n";
490 if (is_array($fieldset['content'])) {
491 foreach ($fieldset['content'] as $col => $colprop) {
492 // remove subtype part of col name
493 list($field, $subtype) = explode(':', $col);
494 if (!$subtype) $subtype = 'home';
495 $fullkey = $col.':'.$subtype;
497 // skip cols unknown to the backend
498 if (!$coltypes[$field])
501 // merge colprop with global coltype configuration
502 $colprop += $coltypes[$field];
503 $label = isset($colprop['label']) ? $colprop['label'] : rcube_label($col);
505 // prepare subtype selector in edit mode
506 if ($edit_mode && is_array($colprop['subtypes'])) {
507 $subtype_names = array_map('rcmail_get_type_label', $colprop['subtypes']);
508 $select_subtype = new html_select(array('name' => '_subtype_'.$col.'[]', 'class' => 'contactselectsubtype'));
509 $select_subtype->add($subtype_names, $colprop['subtypes']);
512 $select_subtype = null;
514 if (!empty($colprop['value'])) {
515 $values = (array)$colprop['value'];
518 // iterate over possible subtypes and collect values with their subtype
519 if (is_array($colprop['subtypes'])) {
520 $values = $subtypes = array();
521 foreach ($colprop['subtypes'] as $i => $st) {
523 if ($record[$field.':'.$st]) {
524 $subtypes[count($values)] = $st;
525 $newval = $record[$field.':'.$st];
527 else if ($i == 0 && $record[$field]) {
528 $subtypes[count($values)] = $st;
529 $newval = $record[$field];
531 if ($newval !== false) {
532 if (is_array($newval) && isset($newval[0]))
533 $values = array_merge($values, $newval);
540 $values = $record[$fullkey] ? $record[$fullkey] : $record[$field];
545 // hack: create empty values array to force this field to be displayed
546 if (empty($values) && $colprop['visible'])
550 foreach ((array)$values as $i => $val) {
552 $subtype = $subtypes[$i];
554 // render composite field
555 if ($colprop['type'] == 'composite') {
556 $composite = array(); $j = 0;
557 $template = $RCMAIL->config->get($col . '_template', '{'.join('} {', array_keys($colprop['childs'])).'}');
558 foreach ($colprop['childs'] as $childcol => $cp) {
559 $childvalue = $val[$childcol] ? $val[$childcol] : $val[$j];
562 if ($colprop['subtypes'] || $colprop['limit'] != 1) $cp['array'] = true;
563 $composite['{'.$childcol.'}'] = rcmail_get_edit_field($childcol, $childvalue, $cp, $cp['type']) . " ";
566 $childval = $cp['render_func'] ? call_user_func($cp['render_func'], $childvalue, $childcol) : Q($childvalue);
567 $composite['{'.$childcol.'}'] = html::span('data ' . $childcol, $childval) . " ";
572 $coltypes[$field] += (array)$colprop;
573 $coltypes[$field]['count']++;
574 $val = strtr($template, $composite);
576 else if ($edit_mode) {
577 // call callback to render/format value
578 if ($colprop['render_func'])
579 $val = call_user_func($colprop['render_func'], $val, $col);
581 $coltypes[$field] = (array)$colprop + $coltypes[$field];
583 if ($colprop['subtypes'] || $colprop['limit'] != 1)
584 $colprop['array'] = true;
586 $val = rcmail_get_edit_field($col, $val, $colprop, $colprop['type']);
587 $coltypes[$field]['count']++;
589 else if ($colprop['render_func'])
590 $val = call_user_func($colprop['render_func'], $val, $col);
591 else if (is_array($colprop['options']) && isset($colprop['options'][$val]))
592 $val = $colprop['options'][$val];
596 // use subtype as label
597 if ($colprop['subtypes'])
598 $label = rcmail_get_type_label($subtype);
600 // add delete button/link
601 if ($edit_mode && !($colprop['visible'] && $colprop['limit'] == 1))
602 $val .= html::a(array('href' => '#del', 'class' => 'contactfieldbutton deletebutton', 'title' => rcube_label('delete'), 'rel' => $col), $del_button);
604 // display row with label
606 $rows .= html::div('row',
607 html::div('contactfieldlabel label', $select_subtype ? $select_subtype->show($subtype) : Q($label)) .
608 html::div('contactfieldcontent '.$colprop['type'], $val));
610 else // row without label
611 $rows .= html::div('row', html::div('contactfield', $val));
614 // add option to the add-field menu
615 if (!$colprop['limit'] || $coltypes[$field]['count'] < $colprop['limit']) {
616 $select_add->add($colprop['label'], $col);
617 $select_add->_count++;
620 // wrap rows in fieldgroup container
621 $content .= html::tag('fieldset', array('class' => 'contactfieldgroup ' . ($colprop['subtypes'] ? 'contactfieldgroupmulti ' : '') . 'contactcontroller' . $col, 'style' => ($rows ? null : 'display:none')),
622 ($colprop['subtypes'] ? html::tag('legend', null, Q($colprop['label'])) : ' ') .
626 // also render add-field selector
628 $content .= html::p('addfield', $select_add->show(null, array('style' => $select_add->_count ? null : 'display:none')));
630 $content = html::div(array('id' => 'contactsection' . $section), $content);
633 $content = $fieldset['content'];
636 $out .= html::tag('fieldset', null, html::tag('legend', null, Q($fieldset['name'])) . $content) ."\n";
640 $RCMAIL->output->set_env('coltypes', $coltypes + $coltype_labels);
641 $RCMAIL->output->set_env('delbutton', $del_button);
642 $RCMAIL->output->add_label('delete');
649 function rcmail_contact_photo($attrib)
651 global $SOURCE_ID, $CONTACTS, $CONTACT_COLTYPES, $RCMAIL, $CONFIG;
653 if (!$CONTACT_COLTYPES['photo'])
656 if ($result = $CONTACTS->get_result())
657 $record = $result->first();
659 $photo_img = $attrib['placeholder'] ? $CONFIG['skin_path'] . $attrib['placeholder'] : 'program/blank.gif';
660 $RCMAIL->output->set_env('photo_placeholder', $photo_img);
661 unset($attrib['placeholder']);
663 if (strpos($record['photo'], 'http:') === 0)
664 $photo_img = $record['photo'];
665 else if ($record['photo'])
666 $photo_img = $RCMAIL->url(array('_action' => 'photo', '_cid' => $record['ID'], '_source' => $SOURCE_ID));
668 $ff_value = '-del-'; // will disable delete-photo action
670 $img = html::img(array('src' => $photo_img, 'border' => 1, 'alt' => ''));
671 $content = html::div($attrib, $img);
673 if ($RCMAIL->action == 'edit' || $RCMAIL->action == 'add') {
674 $RCMAIL->output->add_gui_object('contactphoto', $attrib['id']);
675 $hidden = new html_hiddenfield(array('name' => '_photo', 'id' => 'ff_photo', 'value' => $ff_value));
676 $content .= $hidden->show();
683 function rcmail_format_date_col($val)
686 return format_date($val, $RCMAIL->config->get('date_format', 'Y-m-d'));
691 * Returns contact ID(s) and source(s) from GET/POST data
693 * @return array List of contact IDs per-source
695 function rcmail_get_cids()
697 // contact ID (or comma-separated list of IDs) is provided in two
698 // forms. If _source is an empty string then the ID is a string
699 // containing contact ID and source name in form: <ID>-<SOURCE>
701 $cid = get_input_value('_cid', RCUBE_INPUT_GPC);
702 $source = (string) get_input_value('_source', RCUBE_INPUT_GPC);
704 if (!preg_match('/^[a-zA-Z0-9\+\/=_-]+(,[a-zA-Z0-9\+\/=_-]+)*$/', $cid)) {
708 $cid = explode(',', $cid);
709 $got_source = strlen($source);
712 // create per-source contact IDs array
713 foreach ($cid as $id) {
714 // if _source is not specified we'll find it from decoded ID
716 list ($c, $s) = explode('-', $id, 2);
718 $result[(string)$s][] = $c;
722 $result[$source][] = $id;
729 // register UI objects
730 $OUTPUT->add_handlers(array(
731 'directorylist' => 'rcmail_directory_list',
732 // 'groupslist' => 'rcmail_contact_groups',
733 'addresslist' => 'rcmail_contacts_list',
734 'addressframe' => 'rcmail_contact_frame',
735 'recordscountdisplay' => 'rcmail_rowcount_display',
736 'searchform' => array($OUTPUT, 'search_form')
739 // register action aliases
740 $RCMAIL->register_action_map(array(
742 'photo' => 'show.inc',
743 'group-create' => 'groups.inc',
744 'group-rename' => 'groups.inc',
745 'group-delete' => 'groups.inc',
746 'group-addmembers' => 'groups.inc',
747 'group-delmembers' => 'groups.inc',