| | |
| | | // add list of address sources to client env |
| | | $js_list = $RCMAIL->get_address_sources(); |
| | | |
| | | $source = get_input_value('_source', RCUBE_INPUT_GPC); |
| | | |
| | | // use first directory by default |
| | | if (!strlen($source) || !isset($js_list[$source])) |
| | | $source = $js_list[key($js_list)]['id']; |
| | | |
| | | // count all/writeable sources |
| | | $writeable = 0; |
| | | $count = 0; |
| | |
| | | $OUTPUT->set_env('search_mods', $search_mods); |
| | | $OUTPUT->set_env('address_sources', $js_list); |
| | | $OUTPUT->set_env('writable_source', $writeable); |
| | | $OUTPUT->set_env('compose_extwin', $RCMAIL->config->get('compose_extwin',false)); |
| | | |
| | | $OUTPUT->set_pagetitle(rcube_label('addressbook')); |
| | | $_SESSION['addressbooks_count'] = $count; |
| | | $_SESSION['addressbooks_count_writeable'] = $writeable; |
| | | |
| | | if (!strlen($source)) |
| | | $source = strval(key($js_list)); |
| | | // select address book |
| | | $source = get_input_value('_source', RCUBE_INPUT_GPC); |
| | | |
| | | // use first directory by default |
| | | if (!strlen($source) || !isset($js_list[$source])) { |
| | | $source = $RCMAIL->config->get('default_addressbook'); |
| | | if (!strlen($source) || !isset($js_list[$source])) { |
| | | $source = strval(key($js_list)); |
| | | } |
| | | } |
| | | |
| | | $CONTACTS = rcmail_contact_source($source, true); |
| | | } |
| | |
| | | } |
| | | |
| | | |
| | | function rcmail_default_source($writable=false) |
| | | { |
| | | global $RCMAIL; |
| | | |
| | | // get list of address sources |
| | | $first = reset($RCMAIL->get_address_sources($writable)); |
| | | |
| | | // use first directory by default |
| | | return $first['id']; |
| | | } |
| | | |
| | | function rcmail_set_sourcename($abook) |
| | | { |
| | | global $OUTPUT; |
| | |
| | | if (!$name && $source == 0) { |
| | | $name = rcube_label('personaladrbook'); |
| | | } |
| | | $OUTPUT->set_env('sourcename', $name); |
| | | $OUTPUT->set_env('sourcename', html_entity_decode($name, ENT_COMPAT, 'UTF-8')); |
| | | } |
| | | } |
| | | |
| | |
| | | if ($source['class_name']) |
| | | $class_name .= ' ' . $source['class_name']; |
| | | |
| | | $name = !empty($source['name']) ? $source['name'] : $id; |
| | | $out .= sprintf($line_templ, |
| | | html_identifier($id), |
| | | $class_name, |
| | | Q(rcmail_url(null, array('_source' => $id))), |
| | | $source['id'], |
| | | $js_id, (!empty($source['name']) ? Q($source['name']) : Q($id))); |
| | | $js_id, $name); |
| | | |
| | | $groupdata = array('out' => $out, 'jsdata' => $jsdata, 'source' => $id); |
| | | if ($source['groups']) |
| | |
| | | if (!$attrib['id']) |
| | | $attrib['id'] = 'rcmcontactframe'; |
| | | |
| | | $attrib['name'] = $attrib['id']; |
| | | |
| | | $OUTPUT->set_env('contentframe', $attrib['name']); |
| | | $OUTPUT->set_env('blankpage', $attrib['src'] ? $OUTPUT->abs_url($attrib['src']) : 'program/resources/blank.gif'); |
| | | |
| | | return html::iframe($attrib); |
| | | return $OUTPUT->frame($attrib, true); |
| | | } |
| | | |
| | | |
| | |
| | | if (empty($values) && $colprop['visible']) |
| | | $values[] = ''; |
| | | |
| | | if (!is_array($values)) { |
| | | // $values can be an object, don't use (array)$values syntax |
| | | $values = !empty($values) ? array($values) : array(); |
| | | } |
| | | |
| | | $rows = ''; |
| | | foreach ((array)$values as $i => $val) { |
| | | foreach ($values as $i => $val) { |
| | | if ($subtypes[$i]) |
| | | $subtype = $subtypes[$i]; |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | 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 |
| | | * |
| | | * @return array List of contact IDs per-source |
| | | */ |
| | | function rcmail_get_cids() |
| | | function rcmail_get_cids($filter = null) |
| | | { |
| | | // contact ID (or comma-separated list of IDs) is provided in two |
| | | // forms. If _source is an empty string then the ID is a string |
| | |
| | | |
| | | $cid = get_input_value('_cid', RCUBE_INPUT_GPC); |
| | | $source = (string) get_input_value('_source', RCUBE_INPUT_GPC); |
| | | |
| | | if (is_array($cid)) { |
| | | return $cid; |
| | | } |
| | | |
| | | if (!preg_match('/^[a-zA-Z0-9\+\/=_-]+(,[a-zA-Z0-9\+\/=_-]+)*$/', $cid)) { |
| | | return array(); |
| | |
| | | |
| | | // create per-source contact IDs array |
| | | foreach ($cid as $id) { |
| | | // if _source is not specified we'll find it from decoded ID |
| | | // extract source ID from contact ID (it's there in search mode) |
| | | // see #1488959 and #1488862 for reference |
| | | if (!$got_source) { |
| | | if ($sep = strrpos($id, '-')) { |
| | | $contact_id = substr($id, 0, $sep); |
| | | $source_id = substr($id, $sep+1); |
| | | $source_id = (string) substr($id, $sep+1); |
| | | if (strlen($source_id)) { |
| | | $result[(string)$source_id][] = $contact_id; |
| | | $result[$source_id][] = $contact_id; |
| | | } |
| | | } |
| | | } |
| | | else { |
| | | if (substr($id, -($got_source+1)) == "-$source") { |
| | | $id = substr($id, 0, -($got_source+1)); |
| | | } |
| | | $result[$source][] = $id; |
| | | } |
| | | } |
| | | |
| | | return $result; |
| | | return $filter !== null ? $result[$filter] : $result; |
| | | } |
| | | |
| | | |
| | | // register UI objects |
| | | $OUTPUT->add_handlers(array( |
| | | 'directorylist' => 'rcmail_directory_list', |