| | |
| | | | program/steps/addressbook/func.inc | |
| | | | | |
| | | | This file is part of the Roundcube Webmail client | |
| | | | Copyright (C) 2005-2007, The Roundcube Dev Team | |
| | | | Licensed under the GNU GPL | |
| | | | Copyright (C) 2005-2012, The Roundcube Dev Team | |
| | | | | |
| | | | Licensed under the GNU General Public License version 3 or | |
| | | | any later version with exceptions for skins & plugins. | |
| | | | See the README file for a full license statement. | |
| | | | | |
| | | | PURPOSE: | |
| | | | Provide addressbook functionality and GUI objects | |
| | |
| | | // TODO: define fields for vcards like GEO, KEY |
| | | ); |
| | | |
| | | $PAGE_SIZE = $RCMAIL->config->get('addressbook_pagesize'); |
| | | if (!$PAGE_SIZE) { |
| | | $PAGE_SIZE = $RCMAIL->config->get('pagesize', 50); |
| | | } |
| | | $PAGE_SIZE = $RCMAIL->config->get('addressbook_pagesize', $RCMAIL->config->get('pagesize', 50)); |
| | | |
| | | // Addressbook UI |
| | | if (!$RCMAIL->action && !$OUTPUT->ajax_call) { |
| | |
| | | 'rel' => '%s', |
| | | 'onclick' => "return ".JS_OBJECT_NAME.".command('list','%s',this)"), '%s')); |
| | | |
| | | $sources = (array) $OUTPUT->env['address_sources']; |
| | | $sources = (array) $OUTPUT->get_env('address_sources'); |
| | | reset($sources); |
| | | |
| | | // currently selected source |
| | |
| | | |
| | | while ($row = $result->next()) { |
| | | $a_row_cols = array(); |
| | | $classes = array('person'); // org records will follow some day |
| | | |
| | | // build contact ID with source ID |
| | | if (isset($row['sourceid'])) { |
| | |
| | | |
| | | // format each col |
| | | foreach ($a_show_cols as $col) { |
| | | $val = $row[$col]; |
| | | if ($val == '' && $col == 'name') { |
| | | $val = rcube_addressbook::compose_display_name($row, true); |
| | | } |
| | | |
| | | $val = $col == 'name' ? rcube_addressbook::compose_list_name($row) : $row[$col]; |
| | | $a_row_cols[$col] = Q($val); |
| | | } |
| | | } |
| | | |
| | | $OUTPUT->command($prefix.'add_contact_row', $row['ID'], $a_row_cols); |
| | | if ($row['readonly']) |
| | | $classes[] = 'readonly'; |
| | | |
| | | $OUTPUT->command($prefix.'add_contact_row', $row['ID'], $a_row_cols, join(' ', $classes)); |
| | | } |
| | | } |
| | | |
| | |
| | | function rcmail_contact_form($form, $record, $attrib = null) |
| | | { |
| | | global $RCMAIL, $CONFIG; |
| | | static $jqueryui_loaded = 0; |
| | | |
| | | // Allow plugins to modify contact form content |
| | | $plugin = $RCMAIL->plugins->exec_hook('contact_form', array( |
| | |
| | | if ($colprop['subtypes'] || $colprop['limit'] != 1) |
| | | $colprop['array'] = true; |
| | | |
| | | // load jquery UI datepickert for date fields |
| | | // load jquery UI datepicker for date fields |
| | | if ($colprop['type'] == 'date') { |
| | | if (!$jqueryui_loaded++) { |
| | | $RCMAIL->plugins->load_plugin('jqueryui'); |
| | | $RCMAIL->output->set_env('date_format', strtr($RCMAIL->config->get('date_format', 'Y-m-d'), array('y'=>'y', 'Y'=>'yy', 'm'=>'mm', 'n'=>'m', 'd'=>'dd', 'j'=>'d'))); |
| | | foreach (array('jan','feb','mar','apr','may','jun','jul','aug','sep','oct','nov','dec') as $month) |
| | | $month_names[] = rcube_label($month); |
| | | $RCMAIL->output->set_env('month_names', $month_names); |
| | | } |
| | | $colprop['class'] .= ($colprop['class'] ? ' ' : '') . 'datepicker'; |
| | | $val = format_date($val, $RCMAIL->config->get('date_format', 'Y-m-d'), false); |
| | | if (!$colprop['render_func']) |
| | | $val = rcmail_format_date_col($val); |
| | | } |
| | | |
| | | $val = rcmail_get_edit_field($col, $val, $colprop, $colprop['type']); |
| | |
| | | } |
| | | } |
| | | |
| | | if (!$content) |
| | | if (!$content && (!$edit_mode || !$select_add->_count)) |
| | | continue; |
| | | |
| | | // also render add-field selector |
| | |
| | | } |
| | | |
| | | |
| | | function rcmail_contact_key($row, $sort_col) |
| | | { |
| | | $key = $row[$sort_col] . ':' . $row['sourceid']; |
| | | |
| | | // add email to a key to not skip contacts with the same name (#1488375) |
| | | if (!empty($row['email'])) { |
| | | if (is_array($row['email'])) { |
| | | $key .= ':' . implode(':', $row['email']); |
| | | } |
| | | else { |
| | | $key .= ':' . $row['email']; |
| | | } |
| | | } |
| | | |
| | | return $key; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Returns contact ID(s) and source(s) from GET/POST data |
| | | * |