| Author: Thomas Bruederli <roundcube@gmail.com> |
+-----------------------------------------------------------------------+
- $Id: func.inc 5165 2011-09-05 08:49:04Z thomasb $
+ $Id: func.inc 5967 2012-03-05 19:59:07Z alec $
*/
$out = $groupdata['out'];
}
- $OUTPUT->set_env('contactgroups', $jsdata);
+ $line_templ = html::tag('li', array(
+ 'id' => 'rcmliS%s', 'class' => '%s'),
+ html::a(array('href' => '#', 'rel' => 'S%s',
+ 'onclick' => "return ".JS_OBJECT_NAME.".command('listsearch', '%s', this)"), '%s'));
+
+ // Saved searches
+ $sources = $RCMAIL->user->list_searches(rcube_user::SEARCH_ADDRESSBOOK);
+ foreach ($sources as $j => $source) {
+ $id = $source['id'];
+ $js_id = JQ($id);
+
+ // set class name(s)
+ $class_name = 'contactsearch';
+ if ($current === $id)
+ $class_name .= ' selected';
+ if ($source['class_name'])
+ $class_name .= ' ' . $source['class_name'];
+
+ $out .= sprintf($line_templ,
+ html_identifier($id),
+ $class_name,
+ $id,
+ $js_id, (!empty($source['name']) ? Q($source['name']) : Q($id)));
+ }
+
+ $OUTPUT->set_env('contactgroups', $jsdata);
$OUTPUT->add_gui_object('folderlist', $attrib['id']);
// add some labels to client
$OUTPUT->add_label('deletegroupconfirm', 'groupdeleting', 'addingmember', 'removingmember');
$OUTPUT->include_script('list.js');
// add some labels to client
- $OUTPUT->add_label('deletecontactconfirm', 'copyingcontact');
+ $OUTPUT->add_label('deletecontactconfirm', 'copyingcontact', 'contactdeleting');
return $out;
}
// 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);
}
function rcmail_get_type_label($type)
{
$label = 'type'.$type;
- if (rcube_label_exists($label))
- return rcube_label($label);
+ if (rcube_label_exists($label, '*', $domain))
+ return rcube_label($label, $domain);
else if (preg_match('/\w+(\d+)$/', $label, $m)
&& ($label = preg_replace('/(\d+)$/', '', $label))
- && rcube_label_exists($label))
- return rcube_label($label) . ' ' . $m[1];
+ && rcube_label_exists($label, '*', $domain))
+ return rcube_label($label, $domain) . ' ' . $m[1];
return ucfirst($type);
}
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
+ 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);
+ }
+
$val = rcmail_get_edit_field($col, $val, $colprop, $colprop['type']);
$coltypes[$field]['count']++;
}
}
// wrap rows in fieldgroup container
- $content .= html::tag('fieldset', array('class' => 'contactfieldgroup ' . ($colprop['subtypes'] ? 'contactfieldgroupmulti ' : '') . 'contactcontroller' . $col, 'style' => ($rows ? null : 'display:none')),
- ($colprop['subtypes'] ? html::tag('legend', null, Q($colprop['label'])) : ' ') .
- $rows);
+ if ($rows) {
+ $content .= html::tag('fieldset', array('class' => 'contactfieldgroup ' . ($colprop['subtypes'] ? 'contactfieldgroupmulti ' : '') . 'contactcontroller' . $col, 'style' => ($rows ? null : 'display:none')),
+ ($colprop['subtypes'] ? html::tag('legend', null, Q($colprop['label'])) : ' ') .
+ $rows);
+ }
}
+ if (!$content)
+ continue;
+
// also render add-field selector
if ($edit_mode)
$content .= html::p('addfield', $select_add->show(null, array('style' => $select_add->_count ? null : 'display:none')));
$content = $fieldset['content'];
}
- $out .= html::tag('fieldset', null, html::tag('legend', null, Q($fieldset['name'])) . $content) ."\n";
+ if ($content)
+ $out .= html::tag('fieldset', null, html::tag('legend', null, Q($fieldset['name'])) . $content) ."\n";
}
if ($edit_mode) {
$RCMAIL->output->set_env('photo_placeholder', $photo_img);
unset($attrib['placeholder']);
- if (strpos($record['photo'], 'http:') === 0)
+ if (preg_match('!^https?://!i', $record['photo']))
$photo_img = $record['photo'];
else if ($record['photo'])
$photo_img = $RCMAIL->url(array('_action' => 'photo', '_cid' => $record['ID'], '_source' => $SOURCE_ID));
function rcmail_format_date_col($val)
{
global $RCMAIL;
- return format_date($val, $RCMAIL->config->get('date_format', 'Y-m-d'));
+ return format_date($val, $RCMAIL->config->get('date_format', 'Y-m-d'), false);
+}
+
+
+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;
}
foreach ($cid as $id) {
// if _source is not specified we'll find it from decoded ID
if (!$got_source) {
- list ($c, $s) = explode('-', $id, 2);
- if (strlen($s)) {
- $result[(string)$s][] = $c;
+ if ($sep = strrpos($id, '-')) {
+ $contact_id = substr($id, 0, $sep);
+ $source_id = substr($id, $sep+1);
+ if (strlen($source_id)) {
+ $result[(string)$source_id][] = $contact_id;
+ }
}
}
else {
'group-delete' => 'groups.inc',
'group-addmembers' => 'groups.inc',
'group-delmembers' => 'groups.inc',
+ 'search-create' => 'search.inc',
+ 'search-delete' => 'search.inc',
));