diff options
Diffstat (limited to 'program/steps')
-rw-r--r-- | program/steps/addressbook/edit.inc | 14 | ||||
-rw-r--r-- | program/steps/addressbook/func.inc | 21 | ||||
-rw-r--r-- | program/steps/addressbook/photo.inc | 91 | ||||
-rw-r--r-- | program/steps/addressbook/show.inc | 52 | ||||
-rw-r--r-- | program/steps/mail/compose.inc | 20 | ||||
-rw-r--r-- | program/steps/mail/func.inc | 4 | ||||
-rw-r--r-- | program/steps/mail/sendmail.inc | 1 | ||||
-rw-r--r-- | program/steps/settings/folders.inc | 2 | ||||
-rw-r--r-- | program/steps/settings/func.inc | 13 | ||||
-rw-r--r-- | program/steps/settings/save_prefs.inc | 2 | ||||
-rw-r--r-- | program/steps/utils/spell.inc | 2 |
11 files changed, 138 insertions, 84 deletions
diff --git a/program/steps/addressbook/edit.inc b/program/steps/addressbook/edit.inc index d175c05d9..7ddd3e516 100644 --- a/program/steps/addressbook/edit.inc +++ b/program/steps/addressbook/edit.inc @@ -43,16 +43,14 @@ if ($RCMAIL->action == 'edit') { else { $source = get_input_value('_source', RCUBE_INPUT_GPC); - if (!strlen($source)) { - // Give priority to configured default - $source = $RCMAIL->config->get('default_addressbook'); + if (strlen($source)) { + $CONTACTS = $RCMAIL->get_address_book($source, true); } - $CONTACTS = $RCMAIL->get_address_book($source, true); - - // find writable addressbook - if (!$CONTACTS || $CONTACTS->readonly) - $source = $RCMAIL->get_address_book(-1, true); + if (!$CONTACTS || $CONTACTS->readonly) { + $CONTACTS = $RCMAIL->get_address_book(-1, true); + $source = $RCMAIL->get_address_book_id($CONTACTS); + } // Initialize addressbook $CONTACTS = rcmail_contact_source($source, true); diff --git a/program/steps/addressbook/func.inc b/program/steps/addressbook/func.inc index 8ec581f9a..f94d15338 100644 --- a/program/steps/addressbook/func.inc +++ b/program/steps/addressbook/func.inc @@ -751,12 +751,28 @@ function rcmail_contact_photo($attrib) $plugin = $RCMAIL->plugins->exec_hook('contact_photo', array('record' => $record, 'data' => $record['photo'])); + // check if we have photo data from contact form + if ($GLOBALS['EDIT_RECORD']) { + $rec = $GLOBALS['EDIT_RECORD']; + if ($rec['photo'] == '-del-') { + $record['photo'] = ''; + } + else if ($_SESSION['contacts']['files'][$rec['photo']]) { + $record['photo'] = $file_id = $rec['photo']; + } + } + if ($plugin['url']) $photo_img = $plugin['url']; else 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)); + else if ($record['photo']) { + $url = array('_action' => 'photo', '_cid' => $record['ID'], '_source' => $SOURCE_ID); + if ($file_id) { + $url['_photo'] = $ff_value = $file_id; + } + $photo_img = $RCMAIL->url($url); + } else $ff_value = '-del-'; // will disable delete-photo action @@ -893,7 +909,6 @@ $OUTPUT->add_handlers(array( // register action aliases $RCMAIL->register_action_map(array( 'add' => 'edit.inc', - 'photo' => 'show.inc', 'group-create' => 'groups.inc', 'group-rename' => 'groups.inc', 'group-delete' => 'groups.inc', diff --git a/program/steps/addressbook/photo.inc b/program/steps/addressbook/photo.inc new file mode 100644 index 000000000..658027de4 --- /dev/null +++ b/program/steps/addressbook/photo.inc @@ -0,0 +1,91 @@ +<?php + +/* + +-----------------------------------------------------------------------+ + | program/steps/addressbook/photo.inc | + | | + | This file is part of the Roundcube Webmail client | + | Copyright (C) 2005-2013, 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: | + | Show contact photo | + | | + +-----------------------------------------------------------------------+ + | Author: Thomas Bruederli <roundcube@gmail.com> | + | Author: Aleksander Machniak <alec@alec.pl> | + +-----------------------------------------------------------------------+ +*/ + +// Get contact ID and source ID from request +$cids = rcmail_get_cids(); +$source = key($cids); +$cid = $cids ? array_shift($cids[$source]) : null; + +// read the referenced file +if (($file_id = get_input_value('_photo', RCUBE_INPUT_GPC)) && ($tempfile = $_SESSION['contacts']['files'][$file_id])) { + $tempfile = $RCMAIL->plugins->exec_hook('attachment_display', $tempfile); + if ($tempfile['status']) { + if ($tempfile['data']) + $data = $tempfile['data']; + else if ($tempfile['path']) + $data = file_get_contents($tempfile['path']); + } +} +else { + // by email, search for contact first + if ($email = get_input_value('_email', RCUBE_INPUT_GPC)) { + foreach ($RCMAIL->get_address_sources() as $s) { + $abook = $RCMAIL->get_address_book($s['id']); + $result = $abook->search(array('email'), $email, 1, true, true, 'photo'); + while ($result && ($record = $result->iterate())) { + if ($record['photo']) + break 2; + } + } + } + + // by contact id + if (!$record && $cid) { + // Initialize addressbook source + $CONTACTS = rcmail_contact_source($source, true); + $SOURCE_ID = $source; + // read contact record + $record = $CONTACTS->get_record($cid, true); + } + + if ($record['photo']) { + $data = is_array($record['photo']) ? $record['photo'][0] : $record['photo']; + if (!preg_match('![^a-z0-9/=+-]!i', $data)) + $data = base64_decode($data, true); + } +} + +// let plugins do fancy things with contact photos +$plugin = $RCMAIL->plugins->exec_hook('contact_photo', + array('record' => $record, 'email' => $email, 'data' => $data)); + +// redirect to url provided by a plugin +if ($plugin['url']) { + $RCMAIL->output->redirect($plugin['url']); +} +else { + $data = $plugin['data']; +} + +// deliver alt image +if (!$data && ($alt_img = get_input_value('_alt', RCUBE_INPUT_GPC)) && is_file($alt_img)) { + $data = file_get_contents($alt_img); +} + +// cache for one day if requested by email +if (!$cid && $email) { + $RCMAIL->output->future_expire_header(86400); +} + +header('Content-Type: ' . rc_image_content_type($data)); +echo $data ? $data : file_get_contents('program/resources/blank.gif'); +exit; diff --git a/program/steps/addressbook/show.inc b/program/steps/addressbook/show.inc index 950764bb1..efab5e9e5 100644 --- a/program/steps/addressbook/show.inc +++ b/program/steps/addressbook/show.inc @@ -38,58 +38,6 @@ if ($cid && ($record = $CONTACTS->get_record($cid, true))) { // get address book name (for display) rcmail_set_sourcename($CONTACTS); -// return raw photo of the given contact -if ($RCMAIL->action == 'photo') { - // search for contact first - if (!$record && ($email = get_input_value('_email', RCUBE_INPUT_GPC))) { - foreach ($RCMAIL->get_address_sources() as $s) { - $abook = $RCMAIL->get_address_book($s['id']); - $result = $abook->search(array('email'), $email, 1, true, true, 'photo'); - while ($result && ($record = $result->iterate())) { - if ($record['photo']) - break 2; - } - } - } - - // read the referenced file - if (($file_id = get_input_value('_photo', RCUBE_INPUT_GPC)) && ($tempfile = $_SESSION['contacts']['files'][$file_id])) { - $tempfile = $RCMAIL->plugins->exec_hook('attachment_display', $tempfile); - if ($tempfile['status']) { - if ($tempfile['data']) - $data = $tempfile['data']; - else if ($tempfile['path']) - $data = file_get_contents($tempfile['path']); - } - } - else if ($record['photo']) { - $data = is_array($record['photo']) ? $record['photo'][0] : $record['photo']; - if (!preg_match('![^a-z0-9/=+-]!i', $data)) - $data = base64_decode($data, true); - } - - // let plugins do fancy things with contact photos - $plugin = $RCMAIL->plugins->exec_hook('contact_photo', array('record' => $record, 'email' => $email, 'data' => $data)); - - // redirect to url provided by a plugin - if ($plugin['url']) - $RCMAIL->output->redirect($plugin['url']); - else - $data = $plugin['data']; - - // deliver alt image - if (!$data && ($alt_img = get_input_value('_alt', RCUBE_INPUT_GPC)) && is_file($alt_img)) - $data = file_get_contents($alt_img); - - // cache for one day if requested by email - if (!$cid && $email) - $RCMAIL->output->future_expire_header(86400); - - header('Content-Type: ' . rc_image_content_type($data)); - echo $data ? $data : file_get_contents('program/resources/blank.gif'); - exit; -} - function rcmail_contact_head($attrib) { diff --git a/program/steps/mail/compose.inc b/program/steps/mail/compose.inc index 246cb88bf..7068a25fd 100644 --- a/program/steps/mail/compose.inc +++ b/program/steps/mail/compose.inc @@ -529,7 +529,7 @@ function rcmail_compose_header_from($attrib) } } - $out = $select_from->show((int)$MESSAGE->compose['from']); + $out = $select_from->show($MESSAGE->compose['from']); // add signatures to client $OUTPUT->set_env('signatures', $a_signatures); @@ -947,10 +947,10 @@ function rcmail_create_forward_body($body, $bodyIsHtml) $prefix .= rcube_label('from') . ': ' . $MESSAGE->get_header('from') . "\n"; $prefix .= rcube_label('to') . ': ' . $MESSAGE->get_header('to') . "\n"; - if ($MESSAGE->headers->cc) - $prefix .= rcube_label('cc') . ': ' . $MESSAGE->get_header('cc') . "\n"; - if ($MESSAGE->headers->replyto && $MESSAGE->headers->replyto != $MESSAGE->headers->from) - $prefix .= rcube_label('replyto') . ': ' . $MESSAGE->get_header('replyto') . "\n"; + if ($cc = $MESSAGE->headers->get('cc')) + $prefix .= rcube_label('cc') . ': ' . $cc . "\n"; + if (($replyto = $MESSAGE->headers->get('reply-to')) && $replyto != $MESSAGE->get_header('from')) + $prefix .= rcube_label('replyto') . ': ' . $replyto . "\n"; $prefix .= "\n"; $body = trim($body, "\r\n"); @@ -973,15 +973,13 @@ function rcmail_create_forward_body($body, $bodyIsHtml) rcube_label('from'), Q($MESSAGE->get_header('from'), 'replace'), rcube_label('to'), Q($MESSAGE->get_header('to'), 'replace')); - if ($MESSAGE->headers->cc) + if ($cc = $MESSAGE->headers->get('cc')) $prefix .= sprintf("<tr><th align=\"right\" nowrap=\"nowrap\" valign=\"baseline\">%s: </th><td>%s</td></tr>", - rcube_label('cc'), - Q($MESSAGE->get_header('cc'), 'replace')); + rcube_label('cc'), Q($cc, 'replace')); - if ($MESSAGE->headers->replyto && $MESSAGE->headers->replyto != $MESSAGE->headers->from) + if (($replyto = $MESSAGE->headers->get('reply-to')) && $replyto != $MESSAGE->get_header('from')) $prefix .= sprintf("<tr><th align=\"right\" nowrap=\"nowrap\" valign=\"baseline\">%s: </th><td>%s</td></tr>", - rcube_label('replyto'), - Q($MESSAGE->get_header('replyto'), 'replace')); + rcube_label('replyto'), Q($replyto, 'replace')); $prefix .= "</tbody></table><br>"; } diff --git a/program/steps/mail/func.inc b/program/steps/mail/func.inc index 39037d959..018a31b84 100644 --- a/program/steps/mail/func.inc +++ b/program/steps/mail/func.inc @@ -177,7 +177,9 @@ function rcmail_message_list_smart_column_name() $sent_mbox = $RCMAIL->config->get('sent_mbox'); $drafts_mbox = $RCMAIL->config->get('drafts_mbox'); - if (strpos($mbox.$delim, $sent_mbox.$delim) === 0 || strpos($mbox.$delim, $drafts_mbox.$delim) === 0) { + if ((strpos($mbox.$delim, $sent_mbox.$delim) === 0 || strpos($mbox.$delim, $drafts_mbox.$delim) === 0) + && strtoupper($mbox) != 'INBOX' + ) { return 'to'; } diff --git a/program/steps/mail/sendmail.inc b/program/steps/mail/sendmail.inc index cf22a2af9..1a92844c0 100644 --- a/program/steps/mail/sendmail.inc +++ b/program/steps/mail/sendmail.inc @@ -455,6 +455,7 @@ if (!empty($CONFIG['useragent'])) { } // exec hook for header checking and manipulation +// Depracated: use message_before_send hook instead $data = $RCMAIL->plugins->exec_hook('message_outgoing_headers', array('headers' => $headers)); // sending aborted by plugin diff --git a/program/steps/settings/folders.inc b/program/steps/settings/folders.inc index 6d116e7d2..64af18d62 100644 --- a/program/steps/settings/folders.inc +++ b/program/steps/settings/folders.inc @@ -349,7 +349,7 @@ function rcube_subscription_form($attrib) array('value' => $folder_utf8, 'disabled' => $disabled ? 'disabled' : ''))); $a_js_folders['rcmrow'.$idx] = array($folder_utf8, - Q($display_folder), $protected || $folder['virtual']); + $display_folder, $protected || $folder['virtual']); } $RCMAIL->plugins->exec_hook('folders_list', array('table' => $table)); diff --git a/program/steps/settings/func.inc b/program/steps/settings/func.inc index f6ea79ec6..fdc07be9e 100644 --- a/program/steps/settings/func.inc +++ b/program/steps/settings/func.inc @@ -987,11 +987,12 @@ function rcmail_user_prefs($current = null) 'maxlength' => 30, 'folder_filter' => 'mail', 'folder_rights' => 'w', - // #1486114, #1488279 - 'onchange' => "if ($(this).val() == 'INBOX') $(this).val('')", )); } + // #1486114, #1488279, #1489219 + $onchange = "if ($(this).val() == 'INBOX') $(this).val('')"; + if (!isset($no_override['drafts_mbox'])) { if (!$current) { continue 2; @@ -999,7 +1000,7 @@ function rcmail_user_prefs($current = null) $blocks['main']['options']['drafts_mbox'] = array( 'title' => Q(rcube_label('drafts')), - 'content' => $select->show($config['drafts_mbox'], array('name' => "_drafts_mbox")), + 'content' => $select->show($config['drafts_mbox'], array('name' => "_drafts_mbox", 'onchange' => $onchange)), ); } @@ -1010,7 +1011,7 @@ function rcmail_user_prefs($current = null) $blocks['main']['options']['sent_mbox'] = array( 'title' => Q(rcube_label('sent')), - 'content' => $select->show($config['sent_mbox'], array('name' => "_sent_mbox")), + 'content' => $select->show($config['sent_mbox'], array('name' => "_sent_mbox", 'onchange' => '')), ); } @@ -1021,7 +1022,7 @@ function rcmail_user_prefs($current = null) $blocks['main']['options']['junk_mbox'] = array( 'title' => Q(rcube_label('junk')), - 'content' => $select->show($config['junk_mbox'], array('name' => "_junk_mbox")), + 'content' => $select->show($config['junk_mbox'], array('name' => "_junk_mbox", 'onchange' => $onchange)), ); } @@ -1032,7 +1033,7 @@ function rcmail_user_prefs($current = null) $blocks['main']['options']['trash_mbox'] = array( 'title' => Q(rcube_label('trash')), - 'content' => $select->show($config['trash_mbox'], array('name' => "_trash_mbox")), + 'content' => $select->show($config['trash_mbox'], array('name' => "_trash_mbox", 'onchange' => $onchange)), ); } break; diff --git a/program/steps/settings/save_prefs.inc b/program/steps/settings/save_prefs.inc index 19edb41d4..3e8b1d17e 100644 --- a/program/steps/settings/save_prefs.inc +++ b/program/steps/settings/save_prefs.inc @@ -160,7 +160,7 @@ switch ($CURR_SECTION) $a_user_prefs['timezone'] = (string) $a_user_prefs['timezone']; - if (isset($a_user_prefs['refresh_interval']) && !empty($CONFIG['min_refresh_interval'])) { + if (!empty($a_user_prefs['refresh_interval']) && !empty($CONFIG['min_refresh_interval'])) { if ($a_user_prefs['refresh_interval'] < $CONFIG['min_refresh_interval']) { $a_user_prefs['refresh_interval'] = $CONFIG['min_refresh_interval']; } diff --git a/program/steps/utils/spell.inc b/program/steps/utils/spell.inc index 38e4ca285..1c68e8328 100644 --- a/program/steps/utils/spell.inc +++ b/program/steps/utils/spell.inc @@ -45,7 +45,7 @@ else { if ($err = $spellchecker->error()) { rcube::raise_error(array('code' => 500, 'type' => 'php', 'file' => __FILE__, 'line' => __LINE__, - 'message' => sprintf("Spell check engine error: " . $err)), + 'message' => "Spell check engine error: " . trim($err)), true, false); } |