More CS fixes, replace global $CONFIG usage with $RCMAIL->config->get()

pull/160/head
Aleksander Machniak 11 years ago
parent ddc161721c
commit f5d2eef55c

@ -979,6 +979,19 @@ class rcmail extends rcube
}
/**
* Set environment variables for specified config options
*/
public function set_env_config($options)
{
foreach ((array) $options as $option) {
if ($this->config->get($option)) {
$this->output->set_env($option, true);
}
}
}
/**
* Returns RFC2822 formatted current date in user's timezone
*

@ -5,7 +5,7 @@
| program/steps/addressbook/copy.inc |
| |
| This file is part of the Roundcube Webmail client |
| Copyright (C) 2007, The Roundcube Dev Team |
| Copyright (C) 2007-2013, The Roundcube Dev Team |
| |
| Licensed under the GNU General Public License version 3 or |
| any later version with exceptions for skins & plugins. |
@ -32,8 +32,7 @@ $success = 0;
$errormsg = 'copyerror';
$maxnum = $RCMAIL->config->get('max_group_members', 0);
foreach ($cids as $source => $cid)
{
foreach ($cids as $source => $cid) {
// Something wrong, target not specified
if (!strlen($target)) {
break;

@ -5,7 +5,7 @@
| program/steps/addressbook/delete.inc |
| |
| This file is part of the Roundcube Webmail client |
| Copyright (C) 2005-2009, The Roundcube Dev Team |
| 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. |
@ -30,8 +30,7 @@ $delcnt = 0;
$undo_time = $RCMAIL->config->get('undo_timeout', 0);
$RCMAIL->session->remove('contact_undo');
foreach ($cids as $source => $cid)
{
foreach ($cids as $source => $cid) {
$CONTACTS = rcmail_contact_source($source);
if ($CONTACTS->readonly) {

@ -59,6 +59,25 @@ else {
$SOURCE_ID = $source;
rcmail_set_sourcename($CONTACTS);
$OUTPUT->add_handlers(array(
'contactedithead' => 'rcmail_contact_edithead',
'contacteditform' => 'rcmail_contact_editform',
'contactphoto' => 'rcmail_contact_photo',
'photouploadform' => 'rcmail_upload_photo_form',
'sourceselector' => 'rcmail_source_selector',
'filedroparea' => 'rcmail_photo_drop_area',
));
if ($RCMAIL->action == 'add' && $OUTPUT->template_exists('contactadd')) {
$OUTPUT->send('contactadd');
}
// this will be executed if no template for addcontact exists
$OUTPUT->send('contactedit');
function rcmail_get_edit_record()
{
global $RCMAIL, $CONTACTS;
@ -289,19 +308,3 @@ function rcmail_photo_drop_area($attrib)
$OUTPUT->set_env('filedrop', array('action' => 'upload-photo', 'fieldname' => '_photo', 'single' => 1, 'filter' => '^image/.+'));
}
}
$OUTPUT->add_handlers(array(
'contactedithead' => 'rcmail_contact_edithead',
'contacteditform' => 'rcmail_contact_editform',
'contactphoto' => 'rcmail_contact_photo',
'photouploadform' => 'rcmail_upload_photo_form',
'sourceselector' => 'rcmail_source_selector',
'filedroparea' => 'rcmail_photo_drop_area',
));
if ($RCMAIL->action == 'add' && $OUTPUT->template_exists('contactadd'))
$OUTPUT->send('contactadd');
// this will be executed if no template for addcontact exists
$OUTPUT->send('contactedit');

@ -6,7 +6,7 @@
| |
| This file is part of the Roundcube Webmail client |
| Copyright (C) 2008-2013, The Roundcube Dev Team |
| Copyright (C) 2011, Kolab Systems AG |
| Copyright (C) 2011-2013, Kolab Systems AG |
| |
| Licensed under the GNU General Public License version 3 or |
| any later version with exceptions for skins & plugins. |
@ -21,49 +21,8 @@
+-----------------------------------------------------------------------+
*/
/**
* Copy contact record properties into a vcard object
*/
function prepare_for_export(&$record, $source = null)
{
$groups = $source && $source->groups && $source->export_groups ? $source->get_record_groups($record['ID']) : null;
if (empty($record['vcard'])) {
$vcard = new rcube_vcard();
if ($source) {
$vcard->extend_fieldmap($source->vcard_map);
}
$vcard->load($record['vcard']);
$vcard->reset();
foreach ($record as $key => $values) {
list($field, $section) = explode(':', $key);
foreach ((array)$values as $value) {
if (is_array($value) || @strlen($value)) {
$vcard->set($field, $value, strtoupper($section));
}
}
}
// append group names
if ($groups) {
$vcard->set('groups', join(',', $groups), null);
}
$record['vcard'] = $vcard->export(true);
}
// patch categories to alread existing vcard block
else if ($record['vcard'] && !empty($groups) && !strpos($record['vcard'], 'CATEGORIES:')) {
$vgroups = 'CATEGORIES:' . rcube_vcard::vcard_quote(join(',', $groups));
$record['vcard'] = str_replace('END:VCARD', $vgroups . rcube_vcard::$eol . 'END:VCARD', $record['vcard']);
}
}
// Use search result
if (!empty($_REQUEST['_search']) && isset($_SESSION['search'][$_REQUEST['_search']]))
{
if (!empty($_REQUEST['_search']) && isset($_SESSION['search'][$_REQUEST['_search']])) {
$sort_col = $RCMAIL->config->get('addressbook_sort_col', 'name');
$search = (array)$_SESSION['search'][$_REQUEST['_search']];
$records = array();
@ -153,3 +112,42 @@ while ($result && ($row = $result->next())) {
}
exit;
/**
* Copy contact record properties into a vcard object
*/
function prepare_for_export(&$record, $source = null)
{
$groups = $source && $source->groups && $source->export_groups ? $source->get_record_groups($record['ID']) : null;
if (empty($record['vcard'])) {
$vcard = new rcube_vcard();
if ($source) {
$vcard->extend_fieldmap($source->vcard_map);
}
$vcard->load($record['vcard']);
$vcard->reset();
foreach ($record as $key => $values) {
list($field, $section) = explode(':', $key);
foreach ((array)$values as $value) {
if (is_array($value) || @strlen($value)) {
$vcard->set($field, $value, strtoupper($section));
}
}
}
// append group names
if ($groups) {
$vcard->set('groups', join(',', $groups), null);
}
$record['vcard'] = $vcard->export(true);
}
// patch categories to alread existing vcard block
else if ($record['vcard'] && !empty($groups) && !strpos($record['vcard'], 'CATEGORIES:')) {
$vgroups = 'CATEGORIES:' . rcube_vcard::vcard_quote(join(',', $groups));
$record['vcard'] = str_replace('END:VCARD', $vgroups . rcube_vcard::$eol . 'END:VCARD', $record['vcard']);
}
}

@ -109,6 +109,31 @@ if ($undo = $_SESSION['contact_undo']) {
$RCMAIL->session->remove('contact_undo');
}
// register UI objects
$OUTPUT->add_handlers(array(
'directorylist' => 'rcmail_directory_list',
// 'groupslist' => 'rcmail_contact_groups',
'addresslist' => 'rcmail_contacts_list',
'addresslisttitle' => 'rcmail_contacts_list_title',
'addressframe' => 'rcmail_contact_frame',
'recordscountdisplay' => 'rcmail_rowcount_display',
'searchform' => array($OUTPUT, 'search_form')
));
// register action aliases
$RCMAIL->register_action_map(array(
'add' => 'edit.inc',
'group-create' => 'groups.inc',
'group-rename' => 'groups.inc',
'group-delete' => 'groups.inc',
'group-addmembers' => 'groups.inc',
'group-delmembers' => 'groups.inc',
'search-create' => 'search.inc',
'search-delete' => 'search.inc',
));
// instantiate a contacts object according to the given source
function rcmail_contact_source($source=null, $init_env=false, $writable=false)
{
@ -895,27 +920,3 @@ function rcmail_get_cids($filter = null)
return $filter !== null ? $result[$filter] : $result;
}
// register UI objects
$OUTPUT->add_handlers(array(
'directorylist' => 'rcmail_directory_list',
// 'groupslist' => 'rcmail_contact_groups',
'addresslist' => 'rcmail_contacts_list',
'addresslisttitle' => 'rcmail_contacts_list_title',
'addressframe' => 'rcmail_contact_frame',
'recordscountdisplay' => 'rcmail_rowcount_display',
'searchform' => array($OUTPUT, 'search_form')
));
// register action aliases
$RCMAIL->register_action_map(array(
'add' => 'edit.inc',
'group-create' => 'groups.inc',
'group-rename' => 'groups.inc',
'group-delete' => 'groups.inc',
'group-addmembers' => 'groups.inc',
'group-delmembers' => 'groups.inc',
'search-create' => 'search.inc',
'search-delete' => 'search.inc',
));

@ -20,164 +20,6 @@
+-----------------------------------------------------------------------+
*/
/**
* Handler function to display the import/upload form
*/
function rcmail_import_form($attrib)
{
global $RCMAIL, $OUTPUT;
$target = rcube_utils::get_input_value('_target', rcube_utils::INPUT_GPC);
$attrib += array('id' => "rcmImportForm");
$writable_books = $RCMAIL->get_address_sources(true, true);
$upload = new html_inputfield(array(
'type' => 'file',
'name' => '_file[]',
'id' => 'rcmimportfile',
'size' => 40,
'multiple' => 'multiple',
));
$form = html::p(null, html::label('rcmimportfile', $RCMAIL->gettext('importfromfile')) . $upload->show());
$table = new html_table(array('cols' => 2));
// addressbook selector
if (count($writable_books) > 1) {
$select = new html_select(array('name' => '_target', 'id' => 'rcmimporttarget', 'is_escaped' => true));
foreach ($writable_books as $book) {
$select->add($book['name'], $book['id']);
}
$table->add('title', html::label('rcmimporttarget', $RCMAIL->gettext('importtarget')));
$table->add(null, $select->show($target));
}
else {
$abook = new html_hiddenfield(array('name' => '_target', 'value' => key($writable_books)));
$form .= $abook->show();
}
// selector for group import options
if (count($writable_books) >= 1 || $writable_books[0]->groups) {
$select = new html_select(array('name' => '_groups', 'id' => 'rcmimportgroups', 'is_escaped' => true));
$select->add($RCMAIL->gettext('none'), '0');
$select->add($RCMAIL->gettext('importgroupsall'), '1');
$select->add($RCMAIL->gettext('importgroupsexisting'), '2');
$table->add('title', html::label('rcmimportgroups', $RCMAIL->gettext('importgroups')));
$table->add(null, $select->show(rcube_utils::get_input_value('_groups', rcube_utils::INPUT_GPC)));
}
// checkbox to replace the entire address book
$check_replace = new html_checkbox(array('name' => '_replace', 'value' => 1, 'id' => 'rcmimportreplace'));
$table->add('title', html::label('rcmimportreplace', $RCMAIL->gettext('importreplace')));
$table->add(null, $check_replace->show(rcube_utils::get_input_value('_replace', rcube_utils::INPUT_GPC)));
$form .= $table->show(array('id' => null) + $attrib);
$OUTPUT->set_env('writable_source', !empty($writable_books));
$OUTPUT->add_label('selectimportfile','importwait');
$OUTPUT->add_gui_object('importform', $attrib['id']);
$out = html::p(null, rcube::Q($RCMAIL->gettext('importdesc'), 'show'))
. $OUTPUT->form_tag(array(
'action' => $RCMAIL->url('import'),
'method' => 'post',
'enctype' => 'multipart/form-data') + $attrib,
$form);
return $out;
}
/**
* Render the confirmation page for the import process
*/
function rcmail_import_confirm($attrib)
{
global $IMPORT_STATS, $RCMAIL;
$vars = get_object_vars($IMPORT_STATS);
$vars['names'] = $vars['skipped_names'] = '';
$content = html::p(null, $RCMAIL->gettext(array(
'name' => 'importconfirm',
'nr' => $IMPORT_STATS->inserted,
'vars' => $vars,
)) . ($IMPORT_STATS->names ? ':' : '.'));
if ($IMPORT_STATS->names) {
$content .= html::p('em', join(', ', array_map('Q', $IMPORT_STATS->names)));
}
if ($IMPORT_STATS->skipped) {
$content .= html::p(null, $RCMAIL->gettext(array(
'name' => 'importconfirmskipped',
'nr' => $IMPORT_STATS->skipped,
'vars' => $vars,
)) . ':')
. html::p('em', join(', ', array_map('Q', $IMPORT_STATS->skipped_names)));
}
return html::div($attrib, $content);
}
/**
* Create navigation buttons for the current import step
*/
function rcmail_import_buttons($attrib)
{
global $IMPORT_STATS, $OUTPUT;
$target = rcube_utils::get_input_value('_target', rcube_utils::INPUT_GPC);
$attrib += array('type' => 'input');
unset($attrib['name']);
if (is_object($IMPORT_STATS)) {
$attrib['class'] = trim($attrib['class'] . ' mainaction');
$out = $OUTPUT->button(array('command' => 'list', 'prop' => $target, 'label' => 'done') + $attrib);
}
else {
$out = $OUTPUT->button(array('command' => 'list', 'label' => 'cancel') + $attrib);
$out .= ' ';
$attrib['class'] = trim($attrib['class'] . ' mainaction');
$out .= $OUTPUT->button(array('command' => 'import', 'label' => 'import') + $attrib);
}
return $out;
}
/**
* Returns the matching group id. If group doesn't exist, it'll be created if allowed.
*/
function rcmail_import_group_id($group_name, $CONTACTS, $create, &$import_groups)
{
$group_id = 0;
foreach ($import_groups as $key => $group) {
if (strtolower($group['name']) == strtolower($group_name)) {
$group_id = $group['ID'];
break;
}
}
// create a new group
if (!$group_id && $create) {
$new_group = $CONTACTS->create_group($group_name);
if (!$new_group['ID'])
$new_group['ID'] = $new_group['id'];
$import_groups[] = $new_group;
$group_id = $new_group['ID'];
}
return $group_id;
}
/** The import process **/
$importstep = 'rcmail_import_form';
@ -343,3 +185,159 @@ $OUTPUT->add_handlers(array(
// render page
$OUTPUT->send('importcontacts');
/**
* Handler function to display the import/upload form
*/
function rcmail_import_form($attrib)
{
global $RCMAIL, $OUTPUT;
$target = rcube_utils::get_input_value('_target', rcube_utils::INPUT_GPC);
$attrib += array('id' => "rcmImportForm");
$writable_books = $RCMAIL->get_address_sources(true, true);
$upload = new html_inputfield(array(
'type' => 'file',
'name' => '_file[]',
'id' => 'rcmimportfile',
'size' => 40,
'multiple' => 'multiple',
));
$form = html::p(null, html::label('rcmimportfile', $RCMAIL->gettext('importfromfile')) . $upload->show());
$table = new html_table(array('cols' => 2));
// addressbook selector
if (count($writable_books) > 1) {
$select = new html_select(array('name' => '_target', 'id' => 'rcmimporttarget', 'is_escaped' => true));
foreach ($writable_books as $book) {
$select->add($book['name'], $book['id']);
}
$table->add('title', html::label('rcmimporttarget', $RCMAIL->gettext('importtarget')));
$table->add(null, $select->show($target));
}
else {
$abook = new html_hiddenfield(array('name' => '_target', 'value' => key($writable_books)));
$form .= $abook->show();
}
// selector for group import options
if (count($writable_books) >= 1 || $writable_books[0]->groups) {
$select = new html_select(array('name' => '_groups', 'id' => 'rcmimportgroups', 'is_escaped' => true));
$select->add($RCMAIL->gettext('none'), '0');
$select->add($RCMAIL->gettext('importgroupsall'), '1');
$select->add($RCMAIL->gettext('importgroupsexisting'), '2');
$table->add('title', html::label('rcmimportgroups', $RCMAIL->gettext('importgroups')));
$table->add(null, $select->show(rcube_utils::get_input_value('_groups', rcube_utils::INPUT_GPC)));
}
// checkbox to replace the entire address book
$check_replace = new html_checkbox(array('name' => '_replace', 'value' => 1, 'id' => 'rcmimportreplace'));
$table->add('title', html::label('rcmimportreplace', $RCMAIL->gettext('importreplace')));
$table->add(null, $check_replace->show(rcube_utils::get_input_value('_replace', rcube_utils::INPUT_GPC)));
$form .= $table->show(array('id' => null) + $attrib);
$OUTPUT->set_env('writable_source', !empty($writable_books));
$OUTPUT->add_label('selectimportfile','importwait');
$OUTPUT->add_gui_object('importform', $attrib['id']);
$out = html::p(null, rcube::Q($RCMAIL->gettext('importdesc'), 'show'))
. $OUTPUT->form_tag(array(
'action' => $RCMAIL->url('import'),
'method' => 'post',
'enctype' => 'multipart/form-data') + $attrib,
$form);
return $out;
}
/**
* Render the confirmation page for the import process
*/
function rcmail_import_confirm($attrib)
{
global $IMPORT_STATS, $RCMAIL;
$vars = get_object_vars($IMPORT_STATS);
$vars['names'] = $vars['skipped_names'] = '';
$content = html::p(null, $RCMAIL->gettext(array(
'name' => 'importconfirm',
'nr' => $IMPORT_STATS->inserted,
'vars' => $vars,
)) . ($IMPORT_STATS->names ? ':' : '.'));
if ($IMPORT_STATS->names) {
$content .= html::p('em', join(', ', array_map('Q', $IMPORT_STATS->names)));
}
if ($IMPORT_STATS->skipped) {
$content .= html::p(null, $RCMAIL->gettext(array(
'name' => 'importconfirmskipped',
'nr' => $IMPORT_STATS->skipped,
'vars' => $vars,
)) . ':')
. html::p('em', join(', ', array_map('Q', $IMPORT_STATS->skipped_names)));
}
return html::div($attrib, $content);
}
/**
* Create navigation buttons for the current import step
*/
function rcmail_import_buttons($attrib)
{
global $IMPORT_STATS, $OUTPUT;
$target = rcube_utils::get_input_value('_target', rcube_utils::INPUT_GPC);
$attrib += array('type' => 'input');
unset($attrib['name']);
if (is_object($IMPORT_STATS)) {
$attrib['class'] = trim($attrib['class'] . ' mainaction');
$out = $OUTPUT->button(array('command' => 'list', 'prop' => $target, 'label' => 'done') + $attrib);
}
else {
$out = $OUTPUT->button(array('command' => 'list', 'label' => 'cancel') + $attrib);
$out .= ' ';
$attrib['class'] = trim($attrib['class'] . ' mainaction');
$out .= $OUTPUT->button(array('command' => 'import', 'label' => 'import') + $attrib);
}
return $out;
}
/**
* Returns the matching group id. If group doesn't exist, it'll be created if allowed.
*/
function rcmail_import_group_id($group_name, $CONTACTS, $create, &$import_groups)
{
$group_id = 0;
foreach ($import_groups as $key => $group) {
if (strtolower($group['name']) == strtolower($group_name)) {
$group_id = $group['ID'];
break;
}
}
// create a new group
if (!$group_id && $create) {
$new_group = $CONTACTS->create_group($group_name);
if (!$new_group['ID'])
$new_group['ID'] = $new_group['id'];
$import_groups[] = $new_group;
$group_id = $new_group['ID'];
}
return $group_id;
}

@ -5,7 +5,7 @@
| program/steps/addressbook/mailto.inc |
| |
| This file is part of the Roundcube Webmail client |
| Copyright (C) 2007, The Roundcube Dev Team |
| Copyright (C) 2007-2013, The Roundcube Dev Team |
| |
| Licensed under the GNU General Public License version 3 or |
| any later version with exceptions for skins & plugins. |
@ -19,24 +19,21 @@
+-----------------------------------------------------------------------+
*/
$cids = rcmail_get_cids();
$mailto = array();
$cids = rcmail_get_cids();
$mailto = array();
$recipients = null;
foreach ($cids as $source => $cid)
{
foreach ($cids as $source => $cid) {
$CONTACTS = $RCMAIL->get_address_book($source);
if ($CONTACTS->ready)
{
if ($CONTACTS->ready) {
$CONTACTS->set_page(1);
$CONTACTS->set_pagesize(count($cid) + 2); // +2 to skip counting query
$recipients = $CONTACTS->search($CONTACTS->primary_key, $cid, 0, true, true, 'email');
}
}
if (!empty($_REQUEST['_gid']) && isset($_REQUEST['_source']))
{
if (!empty($_REQUEST['_gid']) && isset($_REQUEST['_source'])) {
$source = rcube_utils::get_input_value('_source', rcube_utils::INPUT_GPC);
$CONTACTS = $RCMAIL->get_address_book($source);
@ -55,16 +52,14 @@ if (!empty($_REQUEST['_gid']) && isset($_REQUEST['_source']))
}
}
if ($recipients)
{
if ($recipients) {
while (is_object($recipients) && ($rec = $recipients->iterate())) {
$emails = $CONTACTS->get_col_values('email', $rec, true);
$mailto[] = format_email_recipient($emails[0], $rec['name']);
}
}
if (!empty($mailto))
{
if (!empty($mailto)) {
$mailto_str = join(', ', $mailto);
$mailto_id = substr(md5($mailto_str), 0, 16);
$_SESSION['mailto'][$mailto_id] = urlencode($mailto_str);

@ -5,7 +5,7 @@
| program/steps/addressbook/show.inc |
| |
| This file is part of the Roundcube Webmail client |
| Copyright (C) 2005-2012, The Roundcube Dev Team |
| 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. |
@ -38,6 +38,15 @@ if ($cid && ($record = $CONTACTS->get_record($cid, true))) {
// get address book name (for display)
rcmail_set_sourcename($CONTACTS);
$OUTPUT->add_handlers(array(
'contacthead' => 'rcmail_contact_head',
'contactdetails' => 'rcmail_contact_details',
'contactphoto' => 'rcmail_contact_photo',
));
$OUTPUT->send('contact');
function rcmail_contact_head($attrib)
{
@ -183,12 +192,3 @@ function rcmail_contact_record_groups($contact_id)
return $form_start . html::tag('fieldset', 'contactfieldgroup contactgroups', $table->show()) . $form_end;
}
$OUTPUT->add_handlers(array(
'contacthead' => 'rcmail_contact_head',
'contactdetails' => 'rcmail_contact_details',
'contactphoto' => 'rcmail_contact_photo',
));
$OUTPUT->send('contact');

@ -5,7 +5,7 @@
| program/steps/addressbook/undo.inc |
| |
| This file is part of the Roundcube Webmail client |
| Copyright (C) 2011, Kolab Systems AG |
| Copyright (C) 2011-2013, Kolab Systems AG |
| |
| Licensed under the GNU General Public License version 3 or |
| any later version with exceptions for skins & plugins. |
@ -20,14 +20,14 @@
*/
// process ajax requests only
if (!$OUTPUT->ajax_call)
if (!$OUTPUT->ajax_call) {
return;
}
$undo = $_SESSION['contact_undo'];
$delcnt = 0;
foreach ((array)$undo['data'] as $source => $cid)
{
foreach ((array)$undo['data'] as $source => $cid) {
$CONTACTS = rcmail_contact_source($source);
$plugin = $RCMAIL->plugins->exec_hook('contact_undelete', array(

@ -121,10 +121,13 @@ $OUTPUT->set_env('mailbox', $RCMAIL->storage->get_folder());
$OUTPUT->set_env('top_posting', intval($RCMAIL->config->get('reply_mode')) > 0);
$OUTPUT->set_env('recipients_separator', trim($RCMAIL->config->get('recipients_separator', ',')));
$drafts_mbox = $RCMAIL->config->get('drafts_mbox');
$config_show_sig = $RCMAIL->config->get('show_sig', 1);
// add config parameters to client script
if (!empty($CONFIG['drafts_mbox'])) {
$OUTPUT->set_env('drafts_mailbox', $CONFIG['drafts_mbox']);
$OUTPUT->set_env('draft_autosave', $CONFIG['draft_autosave']);
if (strlen($drafts_mbox)) {
$OUTPUT->set_env('drafts_mailbox', $drafts_mbox);
$OUTPUT->set_env('draft_autosave', $RCMAIL->config->get('draft_autosave'));
}
// default font for HTML editor
@ -142,7 +145,7 @@ if ($font_size = $RCMAIL->config->get('default_font_size')) {
if ($msg_uid = $COMPOSE['param']['draft_uid']) {
$compose_mode = RCUBE_COMPOSE_DRAFT;
$OUTPUT->set_env('draft_id', $msg_uid);
$RCMAIL->storage->set_folder($CONFIG['drafts_mbox']);
$RCMAIL->storage->set_folder($drafts_mbox);
}
else if ($msg_uid = $COMPOSE['param']['reply_uid']) {
$compose_mode = RCUBE_COMPOSE_REPLY;
@ -159,7 +162,6 @@ else if ($msg_uid = $COMPOSE['param']['uid']) {
$COMPOSE['mode'] = $compose_mode;
$OUTPUT->set_env('compose_mode', $compose_mode);
$config_show_sig = $RCMAIL->config->get('show_sig', 1);
if ($compose_mode == RCUBE_COMPOSE_EDIT || $compose_mode == RCUBE_COMPOSE_DRAFT) {
// don't add signature in draft/edit mode, we'll also not remove the old-one
// but only on page display, later we should be able to change identity/sig (#1489229)
@ -186,7 +188,9 @@ if (!empty($msg_uid) && empty($COMPOSE['as_attachment'])) {
$RCMAIL->config->set('prefer_html', $_SESSION['msg_formats'][$mbox_name.':'.$msg_uid]);
}
else {
$prefer_html = $CONFIG['prefer_html'] || $CONFIG['htmleditor'] || $compose_mode == RCUBE_COMPOSE_DRAFT || $compose_mode == RCUBE_COMPOSE_EDIT;
$prefer_html = $RCMAIL->config->get('prefer_html') || $RCMAIL->config->get('htmleditor')
|| $compose_mode == RCUBE_COMPOSE_DRAFT || $compose_mode == RCUBE_COMPOSE_EDIT;
$RCMAIL->config->set('prefer_html', $prefer_html);
}
@ -849,7 +853,7 @@ function rcmail_compose_part_body($part, $isHtml = false)
function rcmail_compose_body($attrib)
{
global $RCMAIL, $CONFIG, $OUTPUT, $HTML_MODE, $MESSAGE_BODY;
global $RCMAIL, $OUTPUT, $HTML_MODE, $MESSAGE_BODY;
list($form_start, $form_end) = get_form_tags($attrib);
unset($attrib['form']);
@ -901,7 +905,7 @@ function rcmail_compose_body($attrib)
$RCMAIL->html_editor();
// Set language list
if (!empty($CONFIG['enable_spellcheck'])) {
if ($RCMAIL->config->get('enable_spellcheck')) {
$engine = new rcube_spellchecker();
$dictionary = (bool) $RCMAIL->config->get('spellcheck_dictionary');
$spellcheck_langs = $engine->languages();
@ -1453,20 +1457,21 @@ function rcmail_compose_subject($attrib)
function rcmail_compose_attachment_list($attrib)
{
global $RCMAIL, $OUTPUT, $CONFIG, $COMPOSE;
global $RCMAIL, $OUTPUT, $COMPOSE;
// add ID if not given
if (!$attrib['id'])
$attrib['id'] = 'rcmAttachmentList';
$out = "\n";
$jslist = array();
$button = '';
$out = "\n";
$jslist = array();
$button = '';
$skin_path = $RCMAIL->config->get('skin_path');
if (is_array($COMPOSE['attachments'])) {
if ($attrib['deleteicon']) {
$button = html::img(array(
'src' => $CONFIG['skin_path'] . $attrib['deleteicon'],
'src' => $skin_path . $attrib['deleteicon'],
'alt' => $RCMAIL->gettext('delete')
));
}
@ -1503,13 +1508,13 @@ function rcmail_compose_attachment_list($attrib)
}
if ($attrib['deleteicon'])
$COMPOSE['deleteicon'] = $CONFIG['skin_path'] . $attrib['deleteicon'];
$COMPOSE['deleteicon'] = $skin_path . $attrib['deleteicon'];
else if (rcube_utils::get_boolean($attrib['textbuttons']))
$COMPOSE['textbuttons'] = true;
if ($attrib['cancelicon'])
$OUTPUT->set_env('cancelicon', $CONFIG['skin_path'] . $attrib['cancelicon']);
$OUTPUT->set_env('cancelicon', $skin_path . $attrib['cancelicon']);
if ($attrib['loadingicon'])
$OUTPUT->set_env('loadingicon', $CONFIG['skin_path'] . $attrib['loadingicon']);
$OUTPUT->set_env('loadingicon', $skin_path . $attrib['loadingicon']);
$OUTPUT->set_env('attachments', $jslist);
$OUTPUT->add_gui_object('attachmentlist', $attrib['id']);

File diff suppressed because it is too large Load Diff

@ -4,7 +4,7 @@
| program/steps/mail/mark.inc |
| |
| This file is part of the Roundcube Webmail client |
| Copyright (C) 2005-2009, The Roundcube Dev Team |
| 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. |
@ -19,112 +19,123 @@
*/
// only process ajax requests
if (!$OUTPUT->ajax_call)
return;
$a_flags_map = array(
'undelete' => 'UNDELETED',
'delete' => 'DELETED',
'read' => 'SEEN',
'unread' => 'UNSEEN',
'flagged' => 'FLAGGED',
'unflagged' => 'UNFLAGGED');
$threading = (bool) $RCMAIL->storage->get_threading();
if (($uids = rcube_utils::get_input_value('_uid', rcube_utils::INPUT_POST)) && ($flag = rcube_utils::get_input_value('_flag', rcube_utils::INPUT_POST)))
{
$flag = $a_flags_map[$flag] ? $a_flags_map[$flag] : strtoupper($flag);
if ($flag == 'DELETED' && $CONFIG['skip_deleted'] && $_POST['_from'] != 'show') {
// count messages before changing anything
$old_count = $RCMAIL->storage->count(NULL, $threading ? 'THREADS' : 'ALL');
$old_pages = ceil($old_count / $RCMAIL->storage->get_pagesize());
$count = sizeof(explode(',', $uids));
}
$marked = $RCMAIL->storage->set_flag($uids, $flag);
if (!$marked) {
// send error message
if ($_POST['_from'] != 'show')
$OUTPUT->command('list_mailbox');
$RCMAIL->display_server_error('errormarking');
$OUTPUT->send();
exit;
}
else if (empty($_POST['_quiet'])) {
$OUTPUT->show_message('messagemarked', 'confirmation');
}
if ($flag == 'DELETED' && $CONFIG['read_when_deleted'] && !empty($_POST['_ruid'])) {
$ruids = rcube_utils::get_input_value('_ruid', rcube_utils::INPUT_POST);
$read = $RCMAIL->storage->set_flag($ruids, 'SEEN');
if ($read && !$CONFIG['skip_deleted'])
$OUTPUT->command('flag_deleted_as_read', $ruids);
}
if ($flag == 'SEEN' || $flag == 'UNSEEN' || ($flag == 'DELETED' && !$CONFIG['skip_deleted'])) {
rcmail_send_unread_count($RCMAIL->storage->get_folder());
}
else if ($flag == 'DELETED' && $CONFIG['skip_deleted']) {
if ($_POST['_from'] == 'show') {
if ($next = rcube_utils::get_input_value('_next_uid', rcube_utils::INPUT_GPC))
$OUTPUT->command('show_message', $next);
else
$OUTPUT->command('command', 'list');
} else {
$search_request = rcube_utils::get_input_value('_search', rcube_utils::INPUT_GPC);
// refresh saved search set after moving some messages
if ($search_request && $RCMAIL->storage->get_search_set()) {
$_SESSION['search'] = $RCMAIL->storage->refresh_search();
}
$msg_count = $RCMAIL->storage->count(NULL, $threading ? 'THREADS' : 'ALL');
$page_size = $RCMAIL->storage->get_pagesize();
$page = $RCMAIL->storage->get_page();
$pages = ceil($msg_count / $page_size);
$nextpage_count = $old_count - $page_size * $page;
$remaining = $msg_count - $page_size * ($page - 1);
// jump back one page (user removed the whole last page)
if ($page > 1 && $remaining == 0) {
$page -= 1;
$RCMAIL->storage->set_page($page);
$_SESSION['page'] = $page;
$jump_back = true;
}
// update message count display
$OUTPUT->set_env('messagecount', $msg_count);
$OUTPUT->set_env('current_page', $page);
$OUTPUT->set_env('pagecount', $pages);
// update mailboxlist
$mbox = $RCMAIL->storage->get_folder();
$unseen_count = $msg_count ? $RCMAIL->storage->count($mbox, 'UNSEEN') : 0;
$old_unseen = rcmail_get_unseen_count($mbox);
if ($old_unseen != $unseen_count) {
$OUTPUT->command('set_unread_count', $mbox, $unseen_count, ($mbox == 'INBOX'));
rcmail_set_unseen_count($mbox, $unseen_count);
}
$OUTPUT->command('set_rowcount', rcmail_get_messagecount_text($msg_count), $mbox);
if ($threading) {
$count = rcube_utils::get_input_value('_count', rcube_utils::INPUT_POST);
}
// add new rows from next page (if any)
if ($count && $uids != '*' && ($jump_back || $nextpage_count > 0)) {
$a_headers = $RCMAIL->storage->list_messages($mbox, NULL,
rcmail_sort_column(), rcmail_sort_order(), $jump_back ? NULL : $count);
rcmail_js_message_list($a_headers, false);
}
if (!$OUTPUT->ajax_call) {
return;
}
$threading = (bool) $RCMAIL->storage->get_threading();
$skip_deleted = (bool) $RCMAIL->config->get('skip_deleted');
$read_deleted = (bool) $RCMAIL->config->get('read_when_deleted');
$a_flags_map = array(
'undelete' => 'UNDELETED',
'delete' => 'DELETED',
'read' => 'SEEN',
'unread' => 'UNSEEN',
'flagged' => 'FLAGGED',
'unflagged' => 'UNFLAGGED',
);
if (($uids = rcube_utils::get_input_value('_uid', rcube_utils::INPUT_POST))
&& ($flag = rcube_utils::get_input_value('_flag', rcube_utils::INPUT_POST))
) {
$flag = $a_flags_map[$flag] ? $a_flags_map[$flag] : strtoupper($flag);
if ($flag == 'DELETED' && $skip_deleted && $_POST['_from'] != 'show') {
// count messages before changing anything
$old_count = $RCMAIL->storage->count(NULL, $threading ? 'THREADS' : 'ALL');
$old_pages = ceil($old_count / $RCMAIL->storage->get_pagesize());
$count = sizeof(explode(',', $uids));
}
$marked = $RCMAIL->storage->set_flag($uids, $flag);
if (!$marked) {
// send error message
if ($_POST['_from'] != 'show') {
$OUTPUT->command('list_mailbox');
}
$RCMAIL->display_server_error('errormarking');
$OUTPUT->send();
exit;
}
else if (empty($_POST['_quiet'])) {
$OUTPUT->show_message('messagemarked', 'confirmation');
}
if ($flag == 'DELETED' && $read_deleted && !empty($_POST['_ruid'])) {
$ruids = rcube_utils::get_input_value('_ruid', rcube_utils::INPUT_POST);
$read = $RCMAIL->storage->set_flag($ruids, 'SEEN');
if ($read && !$skip_deleted) {
$OUTPUT->command('flag_deleted_as_read', $ruids);
}
}
if ($flag == 'SEEN' || $flag == 'UNSEEN' || ($flag == 'DELETED' && !$skip_deleted)) {
rcmail_send_unread_count($RCMAIL->storage->get_folder());
}
else if ($flag == 'DELETED' && $skip_deleted) {
if ($_POST['_from'] == 'show') {
if ($next = rcube_utils::get_input_value('_next_uid', rcube_utils::INPUT_GPC))
$OUTPUT->command('show_message', $next);
else
$OUTPUT->command('command', 'list');
}
else {
$search_request = rcube_utils::get_input_value('_search', rcube_utils::INPUT_GPC);
// refresh saved search set after moving some messages
if ($search_request && $RCMAIL->storage->get_search_set()) {
$_SESSION['search'] = $RCMAIL->storage->refresh_search();
}
$msg_count = $RCMAIL->storage->count(NULL, $threading ? 'THREADS' : 'ALL');
$page_size = $RCMAIL->storage->get_pagesize();
$page = $RCMAIL->storage->get_page();
$pages = ceil($msg_count / $page_size);
$nextpage_count = $old_count - $page_size * $page;
$remaining = $msg_count - $page_size * ($page - 1);
// jump back one page (user removed the whole last page)
if ($page > 1 && $remaining == 0) {
$page -= 1;
$RCMAIL->storage->set_page($page);
$_SESSION['page'] = $page;
$jump_back = true;
}
// update message count display
$OUTPUT->set_env('messagecount', $msg_count);
$OUTPUT->set_env('current_page', $page);
$OUTPUT->set_env('pagecount', $pages);
// update mailboxlist
$mbox = $RCMAIL->storage->get_folder();
$unseen_count = $msg_count ? $RCMAIL->storage->count($mbox, 'UNSEEN') : 0;
$old_unseen = rcmail_get_unseen_count($mbox);
if ($old_unseen != $unseen_count) {
$OUTPUT->command('set_unread_count', $mbox, $unseen_count, ($mbox == 'INBOX'));
rcmail_set_unseen_count($mbox, $unseen_count);
}
$OUTPUT->command('set_rowcount', rcmail_get_messagecount_text($msg_count), $mbox);
if ($threading) {
$count = rcube_utils::get_input_value('_count', rcube_utils::INPUT_POST);
}
// add new rows from next page (if any)
if ($count && $uids != '*' && ($jump_back || $nextpage_count > 0)) {
$a_headers = $RCMAIL->storage->list_messages($mbox, NULL,
rcmail_sort_column(), rcmail_sort_order(), $jump_back ? NULL : $count);
rcmail_js_message_list($a_headers, false);
}
}
}
}
}
else {
$OUTPUT->show_message('internalerror', 'error');

@ -35,14 +35,19 @@ if ($prev) {
$OUTPUT->set_env('prev_uid', $prev);
$OUTPUT->command('enable_command', 'previousmessage', 'firstmessage', true);
}
if ($next) {
$OUTPUT->set_env('next_uid', $next);
$OUTPUT->command('enable_command', 'nextmessage', 'lastmessage', true);
}
if ($first)
if ($first) {
$OUTPUT->set_env('first_uid', $first);
if ($last)
}
if ($last) {
$OUTPUT->set_env('last_uid', $last);
}
// Don't need a real messages count value
$OUTPUT->set_env('messagecount', 1);
@ -54,4 +59,3 @@ $OUTPUT->command('set_rowcount', $RCMAIL->gettext(array(
)));
$OUTPUT->send();

@ -1,14 +1,18 @@
<?php
/*
+-----------------------------------------------------------------------+
| steps/mail/search.inc |
| |
| Search functions for rc webmail |
| 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: |
| Mail messages search action |
+-----------------------------------------------------------------------+
| Author: Benjamin Smith <defitro@gmail.com> |
| Thomas Bruederli <roundcube@gmail.com> |
@ -41,110 +45,108 @@ $search_str = $filter && $filter != 'ALL' ? $filter : '';
$_SESSION['search_filter'] = $filter;
// Check the search string for type of search
if (preg_match("/^from:.*/i", $str))
{
list(,$srch) = explode(":", $str);
$subject['from'] = "HEADER FROM";
if (preg_match("/^from:.*/i", $str)) {
list(,$srch) = explode(":", $str);
$subject['from'] = "HEADER FROM";
}
else if (preg_match("/^to:.*/i", $str))
{
list(,$srch) = explode(":", $str);
$subject['to'] = "HEADER TO";
else if (preg_match("/^to:.*/i", $str)) {
list(,$srch) = explode(":", $str);
$subject['to'] = "HEADER TO";
}
else if (preg_match("/^cc:.*/i", $str))
{
list(,$srch) = explode(":", $str);
$subject['cc'] = "HEADER CC";
else if (preg_match("/^cc:.*/i", $str)) {
list(,$srch) = explode(":", $str);
$subject['cc'] = "HEADER CC";
}
else if (preg_match("/^bcc:.*/i", $str))
{
list(,$srch) = explode(":", $str);
$subject['bcc'] = "HEADER BCC";
else if (preg_match("/^bcc:.*/i", $str)) {
list(,$srch) = explode(":", $str);
$subject['bcc'] = "HEADER BCC";
}
else if (preg_match("/^subject:.*/i", $str))
{
list(,$srch) = explode(":", $str);
$subject['subject'] = "HEADER SUBJECT";
else if (preg_match("/^subject:.*/i", $str)) {
list(,$srch) = explode(":", $str);
$subject['subject'] = "HEADER SUBJECT";
}
else if (preg_match("/^body:.*/i", $str))
{
list(,$srch) = explode(":", $str);
$subject['body'] = "BODY";
else if (preg_match("/^body:.*/i", $str)) {
list(,$srch) = explode(":", $str);
$subject['body'] = "BODY";
}
else if (strlen(trim($str)))
{
if ($headers) {
foreach (explode(',', $headers) as $header) {
if ($header == 'text') {
// #1488208: get rid of other headers when searching by "TEXT"
$subject = array('text' => 'TEXT');
break;
}
else {
$subject[$header] = ($header != 'body' ? 'HEADER ' : '') . strtoupper($header);
}
else if (strlen(trim($str))) {
if ($headers) {
foreach (explode(',', $headers) as $header) {
if ($header == 'text') {
// #1488208: get rid of other headers when searching by "TEXT"
$subject = array('text' => 'TEXT');
break;
}
else {
$subject[$header] = ($header != 'body' ? 'HEADER ' : '') . strtoupper($header);
}
}
// save search modifiers for the current folder to user prefs
$search_mods = rcmail_search_mods();
$search_mods[$mbox] = array_fill_keys(array_keys($subject), 1);
$RCMAIL->user->save_prefs(array('search_mods' => $search_mods));
}
else {
// search in subject by default
$subject['subject'] = 'HEADER SUBJECT';
}
// save search modifiers for the current folder to user prefs
$search_mods = $RCMAIL->config->get('search_mods', $SEARCH_MODS_DEFAULT);
$search_mods[$mbox] = array_fill_keys(array_keys($subject), 1);
$RCMAIL->user->save_prefs(array('search_mods' => $search_mods));
}
else {
// search in subject by default
$subject['subject'] = 'HEADER SUBJECT';
}
}
$search = isset($srch) ? trim($srch) : trim($str);
if (!empty($subject)) {
$search_str .= str_repeat(' OR', count($subject)-1);
foreach ($subject as $sub)
$search_str .= ' ' . $sub . ' ' . rcube_imap_generic::escape($search);
$search_str .= str_repeat(' OR', count($subject)-1);
foreach ($subject as $sub) {
$search_str .= ' ' . $sub . ' ' . rcube_imap_generic::escape($search);
}
}
$search_str = trim($search_str);
$sort_column = rcmail_sort_column();
// execute IMAP search
if ($search_str)
$RCMAIL->storage->search($mbox, $search_str, $imap_charset, $sort_column);
if ($search_str) {
$RCMAIL->storage->search($mbox, $search_str, $imap_charset, $sort_column);
}
// save search results in session
if (!is_array($_SESSION['search']))
$_SESSION['search'] = array();
if (!is_array($_SESSION['search'])) {
$_SESSION['search'] = array();
}
if ($search_str) {
$_SESSION['search'] = $RCMAIL->storage->get_search_set();
$_SESSION['last_text_search'] = $str;
$_SESSION['search'] = $RCMAIL->storage->get_search_set();
$_SESSION['last_text_search'] = $str;
}
$_SESSION['search_request'] = $search_request;
// Get the headers
$result_h = $RCMAIL->storage->list_messages($mbox, 1, $sort_column, rcmail_sort_order());
$count = $RCMAIL->storage->count($mbox, $RCMAIL->storage->get_threading() ? 'THREADS' : 'ALL');
$count = $RCMAIL->storage->count($mbox, $RCMAIL->storage->get_threading() ? 'THREADS' : 'ALL');
// Make sure we got the headers
if (!empty($result_h)) {
rcmail_js_message_list($result_h);
if ($search_str)
$OUTPUT->show_message('searchsuccessful', 'confirmation', array('nr' => $RCMAIL->storage->count(NULL, 'ALL')));
// remember last HIGHESTMODSEQ value (if supported)
// we need it for flag updates in check-recent
$data = $RCMAIL->storage->folder_data($mbox_name);
if (!empty($data['HIGHESTMODSEQ'])) {
$_SESSION['list_mod_seq'] = $data['HIGHESTMODSEQ'];
}
rcmail_js_message_list($result_h);
if ($search_str) {
$OUTPUT->show_message('searchsuccessful', 'confirmation', array('nr' => $RCMAIL->storage->count(NULL, 'ALL')));
}
// remember last HIGHESTMODSEQ value (if supported)
// we need it for flag updates in check-recent
$data = $RCMAIL->storage->folder_data($mbox_name);
if (!empty($data['HIGHESTMODSEQ'])) {
$_SESSION['list_mod_seq'] = $data['HIGHESTMODSEQ'];
}
}
// handle IMAP errors (e.g. #1486905)
else if ($err_code = $RCMAIL->storage->get_error_code()) {
$RCMAIL->display_server_error();
$RCMAIL->display_server_error();
}
else {
$OUTPUT->show_message('searchnomatch', 'notice');
$OUTPUT->show_message('searchnomatch', 'notice');
}
// update message count display

@ -60,236 +60,6 @@ if (!$savedraft) {
}
/****** message sending functions ********/
// encrypt parts of the header
function rcmail_encrypt_header($what)
{
global $RCMAIL;
if (!$RCMAIL->config->get('http_received_header_encrypt')) {
return $what;
}
return $RCMAIL->encrypt($what);
}
// get identity record
function rcmail_get_identity($id)
{
global $RCMAIL, $message_charset;
if ($sql_arr = $RCMAIL->user->get_identity($id)) {
$out = $sql_arr;
if ($message_charset != RCUBE_CHARSET) {
foreach ($out as $k => $v) {
$out[$k] = rcube_charset::convert($v, RCUBE_CHARSET, $message_charset);
}
}
$out['mailto'] = $sql_arr['email'];
$out['string'] = format_email_recipient($sql_arr['email'], $sql_arr['name']);
return $out;
}
return false;
}
/**
* go from this:
* <img src="http[s]://.../tiny_mce/plugins/emotions/images/smiley-cool.gif" border="0" alt="Cool" title="Cool" />
*
* to this:
*
* <img src="/path/on/server/.../tiny_mce/plugins/emotions/images/smiley-cool.gif" border="0" alt="Cool" title="Cool" />
*/
function rcmail_fix_emoticon_paths($mime_message)
{
global $RCMAIL;
$body = $mime_message->getHTMLBody();
// remove any null-byte characters before parsing
$body = preg_replace('/\x00/', '', $body);
$searchstr = 'program/js/tiny_mce/plugins/emotions/img/';
$offset = 0;
// keep track of added images, so they're only added once
$included_images = array();
if (preg_match_all('# src=[\'"]([^\'"]+)#', $body, $matches, PREG_OFFSET_CAPTURE)) {
foreach ($matches[1] as $m) {
// find emoticon image tags
if (preg_match('#'.$searchstr.'(.*)$#', $m[0], $imatches)) {
$image_name = $imatches[1];
// sanitize image name so resulting attachment doesn't leave images dir
$image_name = preg_replace('/[^a-zA-Z0-9_\.\-]/i', '', $image_name);
$img_file = INSTALL_PATH . '/' . $searchstr . $image_name;
if (! in_array($image_name, $included_images)) {
// add the image to the MIME message
if (!$mime_message->addHTMLImage($img_file, 'image/gif', '', true, $image_name)) {
$RCMAIL->output->show_message("emoticonerror", 'error');
}
array_push($included_images, $image_name);
}
$body = substr_replace($body, $img_file, $m[1] + $offset, strlen($m[0]));
$offset += strlen($img_file) - strlen($m[0]);
}
}
}
$mime_message->setHTMLBody($body);
}
/**
* Extract image attachments from HTML content (data URIs)
*/
function rcmail_extract_inline_images($mime_message, $from)
{
$body = $mime_message->getHTMLBody();
$offset = 0;
$list = array();
$regexp = '# src=[\'"](data:(image/[a-z]+);base64,([a-z0-9+/=\r\n]+))([\'"])#i';
// get domain for the Content-ID, must be the same as in Mail_Mime::get()
if (preg_match('#@([0-9a-zA-Z\-\.]+)#', $from, $matches)) {
$domain = $matches[1];
} else {
$domain = 'localhost';
}
if (preg_match_all($regexp, $body, $matches, PREG_OFFSET_CAPTURE)) {
foreach ($matches[1] as $idx => $m) {
$data = preg_replace('/\r\n/', '', $matches[3][$idx][0]);
$data = base64_decode($data);
if (empty($data)) {
continue;
}
$hash = md5($data) . '@' . $domain;
$mime_type = $matches[2][$idx][0];
$name = $list[$hash];
// add the image to the MIME message
if (!$name) {
$ext = preg_replace('#^[^/]+/#', '', $mime_type);
$name = substr($hash, 0, 8) . '.' . $ext;
$list[$hash] = $name;
$mime_message->addHTMLImage($data, $mime_type, $name, false, $hash);
}
$body = substr_replace($body, $name, $m[1] + $offset, strlen($m[0]));
$offset += strlen($name) - strlen($m[0]);
}
}
$mime_message->setHTMLBody($body);
}
/**
* Parse and cleanup email address input (and count addresses)
*
* @param string Address input
* @param boolean Do count recipients (saved in global $RECIPIENT_COUNT)
* @param boolean Validate addresses (errors saved in global $EMAIL_FORMAT_ERROR)
* @return string Canonical recipients string separated by comma
*/
function rcmail_email_input_format($mailto, $count=false, $check=true)
{
global $RCMAIL, $EMAIL_FORMAT_ERROR, $RECIPIENT_COUNT;
// simplified email regexp, supporting quoted local part
$email_regexp = '(\S+|("[^"]+"))@\S+';
$delim = trim($RCMAIL->config->get('recipients_separator', ','));
$regexp = array("/[,;$delim]\s*[\r\n]+/", '/[\r\n]+/', "/[,;$delim]\s*\$/m", '/;/', '/(\S{1})(<'.$email_regexp.'>)/U');
$replace = array($delim.' ', ', ', '', $delim, '\\1 \\2');
// replace new lines and strip ending ', ', make address input more valid
$mailto = trim(preg_replace($regexp, $replace, $mailto));
$items = rcube_utils::explode_quoted_string($delim, $mailto);
$result = array();
foreach ($items as $item) {
$item = trim($item);
// address in brackets without name (do nothing)
if (preg_match('/^<'.$email_regexp.'>$/', $item)) {
$item = rcube_utils::idn_to_ascii(trim($item, '<>'));
$result[] = $item;
}
// address without brackets and without name (add brackets)
else if (preg_match('/^'.$email_regexp.'$/', $item)) {
$item = rcube_utils::idn_to_ascii($item);
$result[] = $item;
}
// address with name (handle name)
else if (preg_match('/<*'.$email_regexp.'>*$/', $item, $matches)) {
$address = $matches[0];
$name = trim(str_replace($address, '', $item));
if ($name[0] == '"' && $name[count($name)-1] == '"') {
$name = substr($name, 1, -1);
}
$name = stripcslashes($name);
$address = rcube_utils::idn_to_ascii(trim($address, '<>'));
$result[] = format_email_recipient($address, $name);
$item = $address;
}
else if (trim($item)) {
continue;
}
// check address format
$item = trim($item, '<>');
if ($item && $check && !rcube_utils::check_email($item)) {
$EMAIL_FORMAT_ERROR = $item;
return;
}
}
if ($count) {
$RECIPIENT_COUNT += count($result);
}
return implode(', ', $result);
}
function rcmail_generic_message_footer($isHtml)
{
global $RCMAIL;
if ($isHtml && ($file = $RCMAIL->config->get('generic_message_footer_html'))) {
$html_footer = true;
}
else {
$file = $RCMAIL->config->get('generic_message_footer');
$html_footer = false;
}
if ($file && realpath($file)) {
// sanity check
if (!preg_match('/\.(php|ini|conf)$/', $file) && strpos($file, '/etc/') === false) {
$footer = file_get_contents($file);
if ($isHtml && !$html_footer) {
$footer = '<pre>' . $footer . '</pre>';
}
return $footer;
}
}
return false;
}
/****** compose message ********/
if (empty($COMPOSE['param']['message-id'])) {
@ -911,3 +681,233 @@ else {
}
$OUTPUT->send('iframe');
/****** message sending functions ********/
// encrypt parts of the header
function rcmail_encrypt_header($what)
{
global $RCMAIL;
if (!$RCMAIL->config->get('http_received_header_encrypt')) {
return $what;
}
return $RCMAIL->encrypt($what);
}
// get identity record
function rcmail_get_identity($id)
{
global $RCMAIL, $message_charset;
if ($sql_arr = $RCMAIL->user->get_identity($id)) {
$out = $sql_arr;
if ($message_charset != RCUBE_CHARSET) {
foreach ($out as $k => $v) {
$out[$k] = rcube_charset::convert($v, RCUBE_CHARSET, $message_charset);
}
}
$out['mailto'] = $sql_arr['email'];
$out['string'] = format_email_recipient($sql_arr['email'], $sql_arr['name']);
return $out;
}
return false;
}
/**
* go from this:
* <img src="http[s]://.../tiny_mce/plugins/emotions/images/smiley-cool.gif" border="0" alt="Cool" title="Cool" />
*
* to this:
*
* <img src="/path/on/server/.../tiny_mce/plugins/emotions/images/smiley-cool.gif" border="0" alt="Cool" title="Cool" />
*/
function rcmail_fix_emoticon_paths($mime_message)
{
global $RCMAIL;
$body = $mime_message->getHTMLBody();
// remove any null-byte characters before parsing
$body = preg_replace('/\x00/', '', $body);
$searchstr = 'program/js/tiny_mce/plugins/emotions/img/';
$offset = 0;
// keep track of added images, so they're only added once
$included_images = array();
if (preg_match_all('# src=[\'"]([^\'"]+)#', $body, $matches, PREG_OFFSET_CAPTURE)) {
foreach ($matches[1] as $m) {
// find emoticon image tags
if (preg_match('#'.$searchstr.'(.*)$#', $m[0], $imatches)) {
$image_name = $imatches[1];
// sanitize image name so resulting attachment doesn't leave images dir
$image_name = preg_replace('/[^a-zA-Z0-9_\.\-]/i', '', $image_name);
$img_file = INSTALL_PATH . '/' . $searchstr . $image_name;
if (! in_array($image_name, $included_images)) {
// add the image to the MIME message
if (!$mime_message->addHTMLImage($img_file, 'image/gif', '', true, $image_name)) {
$RCMAIL->output->show_message("emoticonerror", 'error');
}
array_push($included_images, $image_name);
}
$body = substr_replace($body, $img_file, $m[1] + $offset, strlen($m[0]));
$offset += strlen($img_file) - strlen($m[0]);
}
}
}
$mime_message->setHTMLBody($body);
}
/**
* Extract image attachments from HTML content (data URIs)
*/
function rcmail_extract_inline_images($mime_message, $from)
{
$body = $mime_message->getHTMLBody();
$offset = 0;
$list = array();
$regexp = '# src=[\'"](data:(image/[a-z]+);base64,([a-z0-9+/=\r\n]+))([\'"])#i';
// get domain for the Content-ID, must be the same as in Mail_Mime::get()
if (preg_match('#@([0-9a-zA-Z\-\.]+)#', $from, $matches)) {
$domain = $matches[1];
} else {
$domain = 'localhost';
}
if (preg_match_all($regexp, $body, $matches, PREG_OFFSET_CAPTURE)) {
foreach ($matches[1] as $idx => $m) {
$data = preg_replace('/\r\n/', '', $matches[3][$idx][0]);
$data = base64_decode($data);
if (empty($data)) {
continue;
}
$hash = md5($data) . '@' . $domain;
$mime_type = $matches[2][$idx][0];
$name = $list[$hash];
// add the image to the MIME message
if (!$name) {
$ext = preg_replace('#^[^/]+/#', '', $mime_type);
$name = substr($hash, 0, 8) . '.' . $ext;
$list[$hash] = $name;
$mime_message->addHTMLImage($data, $mime_type, $name, false, $hash);
}
$body = substr_replace($body, $name, $m[1] + $offset, strlen($m[0]));
$offset += strlen($name) - strlen($m[0]);
}
}
$mime_message->setHTMLBody($body);
}
/**
* Parse and cleanup email address input (and count addresses)
*
* @param string Address input
* @param boolean Do count recipients (saved in global $RECIPIENT_COUNT)
* @param boolean Validate addresses (errors saved in global $EMAIL_FORMAT_ERROR)
* @return string Canonical recipients string separated by comma
*/
function rcmail_email_input_format($mailto, $count=false, $check=true)
{
global $RCMAIL, $EMAIL_FORMAT_ERROR, $RECIPIENT_COUNT;
// simplified email regexp, supporting quoted local part
$email_regexp = '(\S+|("[^"]+"))@\S+';
$delim = trim($RCMAIL->config->get('recipients_separator', ','));
$regexp = array("/[,;$delim]\s*[\r\n]+/", '/[\r\n]+/', "/[,;$delim]\s*\$/m", '/;/', '/(\S{1})(<'.$email_regexp.'>)/U');
$replace = array($delim.' ', ', ', '', $delim, '\\1 \\2');
// replace new lines and strip ending ', ', make address input more valid
$mailto = trim(preg_replace($regexp, $replace, $mailto));
$items = rcube_utils::explode_quoted_string($delim, $mailto);
$result = array();
foreach ($items as $item) {
$item = trim($item);
// address in brackets without name (do nothing)
if (preg_match('/^<'.$email_regexp.'>$/', $item)) {
$item = rcube_utils::idn_to_ascii(trim($item, '<>'));
$result[] = $item;
}
// address without brackets and without name (add brackets)
else if (preg_match('/^'.$email_regexp.'$/', $item)) {
$item = rcube_utils::idn_to_ascii($item);
$result[] = $item;
}
// address with name (handle name)
else if (preg_match('/<*'.$email_regexp.'>*$/', $item, $matches)) {
$address = $matches[0];
$name = trim(str_replace($address, '', $item));
if ($name[0] == '"' && $name[count($name)-1] == '"') {
$name = substr($name, 1, -1);
}
$name = stripcslashes($name);
$address = rcube_utils::idn_to_ascii(trim($address, '<>'));
$result[] = format_email_recipient($address, $name);
$item = $address;
}
else if (trim($item)) {
continue;
}
// check address format
$item = trim($item, '<>');
if ($item && $check && !rcube_utils::check_email($item)) {
$EMAIL_FORMAT_ERROR = $item;
return;
}
}
if ($count) {
$RECIPIENT_COUNT += count($result);
}
return implode(', ', $result);
}
function rcmail_generic_message_footer($isHtml)
{
global $RCMAIL;
if ($isHtml && ($file = $RCMAIL->config->get('generic_message_footer_html'))) {
$html_footer = true;
}
else {
$file = $RCMAIL->config->get('generic_message_footer');
$html_footer = false;
}
if ($file && realpath($file)) {
// sanity check
if (!preg_match('/\.(php|ini|conf)$/', $file) && strpos($file, '/etc/') === false) {
$footer = file_get_contents($file);
if ($isHtml && !$html_footer) {
$footer = '<pre>' . $footer . '</pre>';
}
return $footer;
}
}
return false;
}

@ -5,7 +5,7 @@
| program/steps/mail/show.inc |
| |
| This file is part of the Roundcube Webmail client |
| Copyright (C) 2005-2009, The Roundcube Dev Team |
| 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. |
@ -23,12 +23,12 @@ $PRINT_MODE = $RCMAIL->action == 'print' ? TRUE : FALSE;
// Read browser capabilities and store them in session
if ($caps = rcube_utils::get_input_value('_caps', rcube_utils::INPUT_GET)) {
$browser_caps = array();
foreach (explode(',', $caps) as $cap) {
$cap = explode('=', $cap);
$browser_caps[$cap[0]] = $cap[1];
}
$_SESSION['browser_caps'] = $browser_caps;
$browser_caps = array();
foreach (explode(',', $caps) as $cap) {
$cap = explode('=', $cap);
$browser_caps[$cap[0]] = $cap[1];
}
$_SESSION['browser_caps'] = $browser_caps;
}
$uid = rcube_utils::get_input_value('_uid', rcube_utils::INPUT_GET);
@ -36,298 +36,319 @@ $mbox_name = $RCMAIL->storage->get_folder();
// similar code as in program/steps/mail/get.inc
if ($uid) {
// set message format (need to be done before rcube_message construction)
if (!empty($_GET['_format'])) {
$prefer_html = $_GET['_format'] == 'html';
$RCMAIL->config->set('prefer_html', $prefer_html);
$_SESSION['msg_formats'][$mbox_name.':'.$uid] = $prefer_html;
}
else if (isset($_SESSION['msg_formats'][$mbox_name.':'.$uid])) {
$RCMAIL->config->set('prefer_html', $_SESSION['msg_formats'][$mbox_name.':'.$uid]);
}
$MESSAGE = new rcube_message($uid);
// if message not found (wrong UID)...
if (empty($MESSAGE->headers)) {
rcmail_message_error($uid);
}
// show images?
rcmail_check_safe($MESSAGE);
// set message charset as default
if (!empty($MESSAGE->headers->charset))
$RCMAIL->storage->set_charset($MESSAGE->headers->charset);
$OUTPUT->set_pagetitle(abbreviate_string($MESSAGE->subject, 128, '...', true));
// give message uid to the client
$OUTPUT->set_env('uid', $MESSAGE->uid);
// set environement
$OUTPUT->set_env('safemode', $MESSAGE->is_safe);
$OUTPUT->set_env('sender', $MESSAGE->sender['string']);
$OUTPUT->set_env('permaurl', $RCMAIL->url(array('_action' => 'show', '_uid' => $MESSAGE->uid, '_mbox' => $mbox_name)));
$OUTPUT->set_env('delimiter', $RCMAIL->storage->get_hierarchy_delimiter());
$OUTPUT->set_env('mailbox', $mbox_name);
$OUTPUT->set_env('compose_extwin', $RCMAIL->config->get('compose_extwin',false));
// mimetypes supported by the browser (default settings)
$mimetypes = (array)$RCMAIL->config->get('client_mimetypes');
// Remove unsupported types, which makes that attachment which cannot be
// displayed in a browser will be downloaded directly without displaying an overlay page
if (empty($_SESSION['browser_caps']['pdf']) && ($key = array_search('application/pdf', $mimetypes)) !== false) {
unset($mimetypes[$key]);
}
if (empty($_SESSION['browser_caps']['flash']) && ($key = array_search('application/x-shockwave-flash', $mimetypes)) !== false) {
unset($mimetypes[$key]);
}
if (empty($_SESSION['browser_caps']['tif']) && ($key = array_search('image/tiff', $mimetypes)) !== false) {
// we can convert tiff to jpeg
if (!$RCMAIL->config->get('im_convert_path')) {
unset($mimetypes[$key]);
// set message format (need to be done before rcube_message construction)
if (!empty($_GET['_format'])) {
$prefer_html = $_GET['_format'] == 'html';
$RCMAIL->config->set('prefer_html', $prefer_html);
$_SESSION['msg_formats'][$mbox_name.':'.$uid] = $prefer_html;
}
}
$OUTPUT->set_env('mimetypes', array_values($mimetypes));
if ($CONFIG['drafts_mbox'])
$OUTPUT->set_env('drafts_mailbox', $CONFIG['drafts_mbox']);
if ($CONFIG['trash_mbox'])
$OUTPUT->set_env('trash_mailbox', $CONFIG['trash_mbox']);
if ($CONFIG['junk_mbox'])
$OUTPUT->set_env('junk_mailbox', $CONFIG['junk_mbox']);
if ($CONFIG['delete_junk'])
$OUTPUT->set_env('delete_junk', true);
if ($CONFIG['flag_for_deletion'])
$OUTPUT->set_env('flag_for_deletion', true);
if ($CONFIG['read_when_deleted'])
$OUTPUT->set_env('read_when_deleted', true);
if ($CONFIG['skip_deleted'])
$OUTPUT->set_env('skip_deleted', true);
if ($CONFIG['display_next'])
$OUTPUT->set_env('display_next', true);
if ($MESSAGE->headers->get('list-post', false))
$OUTPUT->set_env('list_post', true);
if ($CONFIG['forward_attachment'])
$OUTPUT->set_env('forward_attachment', true);
if (!$OUTPUT->ajax_call)
$OUTPUT->add_label('checkingmail', 'deletemessage', 'movemessagetotrash',
'movingmessage', 'deletingmessage', 'markingmessage', 'replyall', 'replylist');
$prefer_html = $RCMAIL->config->get('prefer_html');
if ($MESSAGE->has_html_part()) {
$OUTPUT->set_env('optional_format', $prefer_html ? 'text' : 'html');
}
// check for unset disposition notification
if ($MESSAGE->headers->mdn_to
&& empty($MESSAGE->headers->flags['MDNSENT'])
&& empty($MESSAGE->headers->flags['SEEN'])
&& ($RCMAIL->storage->check_permflag('MDNSENT') || $RCMAIL->storage->check_permflag('*'))
&& $mbox_name != $CONFIG['drafts_mbox']
&& $mbox_name != $CONFIG['sent_mbox']
) {
$mdn_cfg = intval($CONFIG['mdn_requests']);
if ($mdn_cfg == 1 || (($mdn_cfg == 3 || $mdn_cfg == 4) && rcmail_contact_exists($MESSAGE->sender['mailto']))) {
// Send MDN
if (rcmail_send_mdn($MESSAGE, $smtp_error))
$OUTPUT->show_message('receiptsent', 'confirmation');
else if ($smtp_error)
$OUTPUT->show_message($smtp_error['label'], 'error', $smtp_error['vars']);
else
$OUTPUT->show_message('errorsendingreceipt', 'error');
else if (isset($_SESSION['msg_formats'][$mbox_name.':'.$uid])) {
$RCMAIL->config->set('prefer_html', $_SESSION['msg_formats'][$mbox_name.':'.$uid]);
}
else if ($mdn_cfg != 2 && $mdn_cfg != 4) {
// Ask user
$OUTPUT->add_label('mdnrequest');
$OUTPUT->set_env('mdn_request', true);
$MESSAGE = new rcube_message($uid);
// if message not found (wrong UID)...
if (empty($MESSAGE->headers)) {
rcmail_message_error($uid);
}
}
if (empty($MESSAGE->headers->flags['SEEN'])
&& ($RCMAIL->action == 'show' || ($RCMAIL->action == 'preview' && intval($CONFIG['preview_pane_mark_read']) == 0))
) {
$RCMAIL->plugins->exec_hook('message_read', array('uid' => $MESSAGE->uid,
'mailbox' => $mbox_name, 'message' => $MESSAGE));
}
}
// show images?
rcmail_check_safe($MESSAGE);
function rcmail_message_attachments($attrib)
{
global $PRINT_MODE, $MESSAGE, $RCMAIL;
$out = $ol = '';
$attachments = array();
if (sizeof($MESSAGE->attachments)) {
foreach ($MESSAGE->attachments as $attach_prop) {
$filename = rcmail_attachment_name($attach_prop, true);
if ($PRINT_MODE) {
$size = $RCMAIL->message_part_size($attach_prop);
$ol .= html::tag('li', null, rcube::Q(sprintf("%s (%s)", $filename, $size)));
}
else {
if ($attrib['maxlength'] && mb_strlen($filename) > $attrib['maxlength']) {
$title = $filename;
$filename = abbreviate_string($filename, $attrib['maxlength']);
// set message charset as default
if (!empty($MESSAGE->headers->charset)) {
$RCMAIL->storage->set_charset($MESSAGE->headers->charset);
}
$OUTPUT->set_pagetitle(abbreviate_string($MESSAGE->subject, 128, '...', true));
// set message environment
$OUTPUT->set_env('uid', $MESSAGE->uid);
$OUTPUT->set_env('safemode', $MESSAGE->is_safe);
$OUTPUT->set_env('sender', $MESSAGE->sender['string']);
$OUTPUT->set_env('mailbox', $mbox_name);
$OUTPUT->set_env('permaurl', $RCMAIL->url(array('_action' => 'show', '_uid' => $MESSAGE->uid, '_mbox' => $mbox_name)));
if ($MESSAGE->headers->get('list-post', false)) {
$OUTPUT->set_env('list_post', true);
}
// set environment
$OUTPUT->set_env('delimiter', $RCMAIL->storage->get_hierarchy_delimiter());
// set configuration
$RCMAIL->set_env_config(array('delete_junk', 'flag_for_deletion', 'read_when_deleted',
'skip_deleted', 'display_next', 'compose_extwin', 'forward_attachment'));
// set special folders
foreach (array('drafts', 'trash', 'junk') as $mbox) {
if ($folder = $RCMAIL->config->get($mbox . '_mbox')) {
$OUTPUT->set_env($mbox . '_mailbox', $folder);
}
else {
$title = '';
}
// mimetypes supported by the browser (default settings)
$mimetypes = (array)$RCMAIL->config->get('client_mimetypes');
// Remove unsupported types, which makes that attachment which cannot be
// displayed in a browser will be downloaded directly without displaying an overlay page
if (empty($_SESSION['browser_caps']['pdf']) && ($key = array_search('application/pdf', $mimetypes)) !== false) {
unset($mimetypes[$key]);
}
if (empty($_SESSION['browser_caps']['flash']) && ($key = array_search('application/x-shockwave-flash', $mimetypes)) !== false) {
unset($mimetypes[$key]);
}
if (empty($_SESSION['browser_caps']['tif']) && ($key = array_search('image/tiff', $mimetypes)) !== false) {
// we can convert tiff to jpeg
if (!$RCMAIL->config->get('im_convert_path')) {
unset($mimetypes[$key]);
}
}
$mimetype = rcmail_fix_mimetype($attach_prop->mimetype);
$class = rcube_utils::file2class($mimetype, $filename);
$id = 'attach' . $attach_prop->mime_id;
$link = html::a(array(
'href' => $MESSAGE->get_part_url($attach_prop->mime_id, false),
'onclick' => sprintf('return %s.command(\'load-attachment\',\'%s\',this)',
rcmail_output::JS_OBJECT_NAME, $attach_prop->mime_id),
'onmouseover' => $title ? '' : 'rcube_webmail.long_subject_title_ex(this, 0)',
'title' => rcube::Q($title),
), rcube::Q($filename));
$ol .= html::tag('li', array('class' => $class, 'id' => $id), $link);
$attachments[$attach_prop->mime_id] = $mimetype;
}
$OUTPUT->set_env('mimetypes', array_values($mimetypes));
if ($MESSAGE->has_html_part()) {
$prefer_html = $RCMAIL->config->get('prefer_html');
$OUTPUT->set_env('optional_format', $prefer_html ? 'text' : 'html');
}
if (!$OUTPUT->ajax_call) {
$OUTPUT->add_label('checkingmail', 'deletemessage', 'movemessagetotrash',
'movingmessage', 'deletingmessage', 'markingmessage', 'replyall', 'replylist');
}
$out = html::tag('ul', $attrib, $ol, html::$common_attrib);
$RCMAIL->output->set_env('attachments', $attachments);
}
// check for unset disposition notification
if ($MESSAGE->headers->mdn_to
&& empty($MESSAGE->headers->flags['MDNSENT'])
&& empty($MESSAGE->headers->flags['SEEN'])
&& ($RCMAIL->storage->check_permflag('MDNSENT') || $RCMAIL->storage->check_permflag('*'))
&& $mbox_name != $RCMAIL->config->get('drafts_mbox')
&& $mbox_name != $RCMAIL->config->get('sent_mbox')
) {
$mdn_cfg = intval($RCMAIL->config->get('mdn_requests'));
if ($mdn_cfg == 1 || (($mdn_cfg == 3 || $mdn_cfg == 4) && rcmail_contact_exists($MESSAGE->sender['mailto']))) {
// Send MDN
if (rcmail_send_mdn($MESSAGE, $smtp_error))
$OUTPUT->show_message('receiptsent', 'confirmation');
else if ($smtp_error)
$OUTPUT->show_message($smtp_error['label'], 'error', $smtp_error['vars']);
else
$OUTPUT->show_message('errorsendingreceipt', 'error');
}
else if ($mdn_cfg != 2 && $mdn_cfg != 4) {
// Ask user
$OUTPUT->add_label('mdnrequest');
$OUTPUT->set_env('mdn_request', true);
}
}
return $out;
if (empty($MESSAGE->headers->flags['SEEN'])
&& ($RCMAIL->action == 'show' || ($RCMAIL->action == 'preview' && intval($RCMAIL->config->get('preview_pane_mark_read')) == 0))
) {
$RCMAIL->plugins->exec_hook('message_read', array(
'uid' => $MESSAGE->uid,
'mailbox' => $mbox_name,
'message' => $MESSAGE,
));
}
}
function rcmail_remote_objects_msg()
$OUTPUT->add_handlers(array(
'messageattachments' => 'rcmail_message_attachments',
'mailboxname' => 'rcmail_mailbox_name_display',
'messageobjects' => 'rcmail_message_objects',
'contactphoto' => 'rcmail_message_contactphoto',
));
if ($RCMAIL->action == 'print' && $OUTPUT->template_exists('messageprint'))
$OUTPUT->send('messageprint', false);
else if ($RCMAIL->action == 'preview' && $OUTPUT->template_exists('messagepreview'))
$OUTPUT->send('messagepreview', false);
else
$OUTPUT->send('message', false);
// mark message as read
if ($MESSAGE && $MESSAGE->headers && empty($MESSAGE->headers->flags['SEEN']) &&
($RCMAIL->action == 'show' || ($RCMAIL->action == 'preview' && intval($RCMAIL->config->get('preview_pane_mark_read')) == 0))
) {
if ($RCMAIL->storage->set_flag($MESSAGE->uid, 'SEEN')) {
if ($count = rcmail_get_unseen_count($mbox_name)) {
rcmail_set_unseen_count($mbox_name, $count - 1);
}
}
}
exit;
function rcmail_message_attachments($attrib)
{
global $MESSAGE, $RCMAIL;
global $PRINT_MODE, $MESSAGE, $RCMAIL;
$out = $ol = '';
$attachments = array();
if (sizeof($MESSAGE->attachments)) {
foreach ($MESSAGE->attachments as $attach_prop) {
$filename = rcmail_attachment_name($attach_prop, true);
if ($PRINT_MODE) {
$size = $RCMAIL->message_part_size($attach_prop);
$ol .= html::tag('li', null, rcube::Q(sprintf("%s (%s)", $filename, $size)));
}
else {
if ($attrib['maxlength'] && mb_strlen($filename) > $attrib['maxlength']) {
$title = $filename;
$filename = abbreviate_string($filename, $attrib['maxlength']);
}
else {
$title = '';
}
$mimetype = rcmail_fix_mimetype($attach_prop->mimetype);
$class = rcube_utils::file2class($mimetype, $filename);
$id = 'attach' . $attach_prop->mime_id;
$link = html::a(array(
'href' => $MESSAGE->get_part_url($attach_prop->mime_id, false),
'onclick' => sprintf('return %s.command(\'load-attachment\',\'%s\',this)',
rcmail_output::JS_OBJECT_NAME, $attach_prop->mime_id),
'onmouseover' => $title ? '' : 'rcube_webmail.long_subject_title_ex(this, 0)',
'title' => rcube::Q($title),
), rcube::Q($filename));
$ol .= html::tag('li', array('class' => $class, 'id' => $id), $link);
$attachments[$attach_prop->mime_id] = $mimetype;
}
}
$attrib['id'] = 'remote-objects-message';
$attrib['class'] = 'notice';
$attrib['style'] = 'display: none';
$out = html::tag('ul', $attrib, $ol, html::$common_attrib);
$msg = rcube::Q($RCMAIL->gettext('blockedimages')) . '&nbsp;';
$msg .= html::a(array('href' => "#loadimages", 'onclick' => rcmail_output::JS_OBJECT_NAME.".command('load-images')"), rcube::Q($RCMAIL->gettext('showimages')));
$RCMAIL->output->set_env('attachments', $attachments);
}
return $out;
}
function rcmail_remote_objects_msg()
{
global $MESSAGE, $RCMAIL;
$attrib['id'] = 'remote-objects-message';
$attrib['class'] = 'notice';
$attrib['style'] = 'display: none';
$msg = rcube::Q($RCMAIL->gettext('blockedimages')) . '&nbsp;';
$msg .= html::a(array(
'href' => "#loadimages",
'onclick' => rcmail_output::JS_OBJECT_NAME.".command('load-images')"
),
rcube::Q($RCMAIL->gettext('showimages')));
// add link to save sender in addressbook and reload message
if ($MESSAGE->sender['mailto'] && $RCMAIL->config->get('show_images') == 1) {
$msg .= ' ' . html::a(array(
'href' => "#alwaysload",
'onclick' => rcmail_output::JS_OBJECT_NAME.".command('always-load')",
'style' => "white-space:nowrap"
),
rcube::Q($RCMAIL->gettext(array('name' => 'alwaysshow', 'vars' => array('sender' => $MESSAGE->sender['mailto'])))));
}
// add link to save sender in addressbook and reload message
if ($MESSAGE->sender['mailto'] && $RCMAIL->config->get('show_images') == 1) {
$msg .= ' ' . html::a(array('href' => "#alwaysload", 'onclick' => rcmail_output::JS_OBJECT_NAME.".command('always-load')", 'style' => "white-space:nowrap"),
rcube::Q($RCMAIL->gettext(array('name' => 'alwaysshow', 'vars' => array('sender' => $MESSAGE->sender['mailto'])))));
}
$RCMAIL->output->add_gui_object('remoteobjectsmsg', $attrib['id']);
$RCMAIL->output->add_gui_object('remoteobjectsmsg', $attrib['id']);
return html::div($attrib, $msg);
return html::div($attrib, $msg);
}
function rcmail_message_buttons()
{
global $RCMAIL;
global $RCMAIL;
$mbox = $RCMAIL->storage->get_folder();
$delim = $RCMAIL->storage->get_hierarchy_delimiter();
$dbox = $RCMAIL->config->get('drafts_mbox');
$mbox = $RCMAIL->storage->get_folder();
$delim = $RCMAIL->storage->get_hierarchy_delimiter();
$dbox = $RCMAIL->config->get('drafts_mbox');
// the message is not a draft
if ($mbox != $dbox && strpos($mbox, $dbox.$delim) !== 0) {
return '';
}
// the message is not a draft
if ($mbox != $dbox && strpos($mbox, $dbox.$delim) !== 0) {
return '';
}
$attrib['id'] = 'message-buttons';
$attrib['class'] = 'notice';
$attrib['id'] = 'message-buttons';
$attrib['class'] = 'notice';
$msg = rcube::Q($RCMAIL->gettext('isdraft')) . '&nbsp;';
$msg .= html::a(array('href' => "#edit", 'onclick' => rcmail_output::JS_OBJECT_NAME.".command('edit')"), rcube::Q($RCMAIL->gettext('edit')));
$msg = rcube::Q($RCMAIL->gettext('isdraft')) . '&nbsp;';
$msg .= html::a(array(
'href' => "#edit",
'onclick' => rcmail_output::JS_OBJECT_NAME.".command('edit')"
),
rcube::Q($RCMAIL->gettext('edit')));
return html::div($attrib, $msg);
return html::div($attrib, $msg);
}
function rcmail_message_objects($attrib)
{
global $RCMAIL, $MESSAGE;
global $RCMAIL, $MESSAGE;
if (!$attrib['id'])
$attrib['id'] = 'message-objects';
if (!$attrib['id'])
$attrib['id'] = 'message-objects';
$content = array(
rcmail_message_buttons(),
rcmail_remote_objects_msg(),
);
$content = array(
rcmail_message_buttons(),
rcmail_remote_objects_msg(),
);
$plugin = $RCMAIL->plugins->exec_hook('message_objects',
array('content' => $content, 'message' => $MESSAGE));
$plugin = $RCMAIL->plugins->exec_hook('message_objects',
array('content' => $content, 'message' => $MESSAGE));
$content = implode("\n", $plugin['content']);
$content = implode("\n", $plugin['content']);
return html::div($attrib, $content);
return html::div($attrib, $content);
}
function rcmail_contact_exists($email)
{
global $RCMAIL;
global $RCMAIL;
if ($email) {
// @TODO: search in all address books?
$CONTACTS = $RCMAIL->get_address_book(-1, true);
if ($email) {
// @TODO: search in all address books?
$CONTACTS = $RCMAIL->get_address_book(-1, true);
if (is_object($CONTACTS)) {
$existing = $CONTACTS->search('email', $email, true, false);
if ($existing->count) {
return true;
}
if (is_object($CONTACTS)) {
$existing = $CONTACTS->search('email', $email, true, false);
if ($existing->count) {
return true;
}
}
}
}
return false;
return false;
}
function rcmail_message_contactphoto($attrib)
{
global $RCMAIL, $MESSAGE;
global $RCMAIL, $MESSAGE;
$placeholder = $attrib['placeholder'] ? $RCMAIL->config->get('skin_path') . $attrib['placeholder'] : null;
if ($MESSAGE->sender)
$photo_img = $RCMAIL->url(array('_task' => 'addressbook', '_action' => 'photo', '_email' => $MESSAGE->sender['mailto'], '_alt' => $placeholder));
else
$photo_img = $placeholder ? $placeholder : 'program/resources/blank.gif';
$placeholder = $attrib['placeholder'] ? $RCMAIL->config->get('skin_path') . $attrib['placeholder'] : null;
return html::img(array('src' => $photo_img) + $attrib);
}
$OUTPUT->add_handlers(array(
'messageattachments' => 'rcmail_message_attachments',
'mailboxname' => 'rcmail_mailbox_name_display',
'messageobjects' => 'rcmail_message_objects',
'contactphoto' => 'rcmail_message_contactphoto',
));
if ($RCMAIL->action == 'print' && $OUTPUT->template_exists('messageprint'))
$OUTPUT->send('messageprint', false);
else if ($RCMAIL->action == 'preview' && $OUTPUT->template_exists('messagepreview'))
$OUTPUT->send('messagepreview', false);
else
$OUTPUT->send('message', false);
// mark message as read
if ($MESSAGE && $MESSAGE->headers && empty($MESSAGE->headers->flags['SEEN']) &&
($RCMAIL->action == 'show' || ($RCMAIL->action == 'preview' && intval($CONFIG['preview_pane_mark_read']) == 0)))
{
if ($RCMAIL->storage->set_flag($MESSAGE->uid, 'SEEN')) {
if ($count = rcmail_get_unseen_count($mbox_name)) {
rcmail_set_unseen_count($mbox_name, $count - 1);
if ($MESSAGE->sender) {
$photo_img = $RCMAIL->url(array(
'_task' => 'addressbook',
'_action' => 'photo',
'_email' => $MESSAGE->sender['mailto'],
'_alt' => $placeholder
));
}
else {
$photo_img = $placeholder ? $placeholder : 'program/resources/blank.gif';
}
}
}
exit;
return html::img(array('src' => $photo_img) + $attrib);
}

@ -5,7 +5,7 @@
| program/steps/mail/viewsource.inc |
| |
| This file is part of the Roundcube Webmail client |
| Copyright (C) 2005-2009, The Roundcube Dev Team |
| 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. |
@ -22,39 +22,39 @@
ob_end_clean();
// similar code as in program/steps/mail/get.inc
if ($uid = rcube_utils::get_input_value('_uid', rcube_utils::INPUT_GET))
{
$headers = $RCMAIL->storage->get_message_headers($uid);
$charset = $headers->charset ? $headers->charset : $CONFIG['default_charset'];
header("Content-Type: text/plain; charset={$charset}");
if (!empty($_GET['_save'])) {
$subject = rcube_mime::decode_header($headers->subject, $headers->charset);
$filename = ($subject ? $subject : $RCMAIL->config->get('product_name', 'email')) . '.eml';
$browser = $RCMAIL->output->browser;
if ($browser->ie && $browser->ver < 7)
$filename = rawurlencode(abbreviate_string($filename, 55));
else if ($browser->ie)
$filename = rawurlencode($filename);
else
$filename = addcslashes($filename, '"');
header("Content-Length: {$headers->size}");
header("Content-Disposition: attachment; filename=\"$filename\"");
}
$RCMAIL->storage->print_raw_body($uid, empty($_GET['_save']));
if ($uid = rcube_utils::get_input_value('_uid', rcube_utils::INPUT_GET)) {
$headers = $RCMAIL->storage->get_message_headers($uid);
$charset = $headers->charset ? $headers->charset : $RCMAIL->config->get('default_charset');
header("Content-Type: text/plain; charset={$charset}");
if (!empty($_GET['_save'])) {
$subject = rcube_mime::decode_header($headers->subject, $headers->charset);
$filename = ($subject ? $subject : $RCMAIL->config->get('product_name', 'email')) . '.eml';
$browser = $RCMAIL->output->browser;
if ($browser->ie && $browser->ver < 7)
$filename = rawurlencode(abbreviate_string($filename, 55));
else if ($browser->ie)
$filename = rawurlencode($filename);
else
$filename = addcslashes($filename, '"');
header("Content-Length: {$headers->size}");
header("Content-Disposition: attachment; filename=\"$filename\"");
}
$RCMAIL->storage->print_raw_body($uid, empty($_GET['_save']));
}
else
{
rcube::raise_error(array(
'code' => 500,
'type' => 'php',
'file' => __FILE__, 'line' => __LINE__,
'message' => 'Message UID '.$uid.' not found'),
true, true);
else {
rcube::raise_error(array(
'code' => 500,
'type' => 'php',
'file' => __FILE__,
'line' => __LINE__,
'message' => "Message UID $uid not found"
),
true, true);
}
exit;

@ -5,7 +5,7 @@
| program/steps/settings/folders.inc |
| |
| This file is part of the Roundcube Webmail client |
| Copyright (C) 2005-2009, The Roundcube Dev Team |
| 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. |
@ -26,9 +26,9 @@
$STORAGE = $RCMAIL->get_storage();
// subscribe mailbox
if ($RCMAIL->action == 'subscribe')
{
if ($RCMAIL->action == 'subscribe') {
$mbox = rcube_utils::get_input_value('_mbox', rcube_utils::INPUT_POST, true, 'UTF7-IMAP');
if (strlen($mbox)) {
$result = $STORAGE->subscribe(array($mbox));
@ -56,10 +56,8 @@ if ($RCMAIL->action == 'subscribe')
$RCMAIL->display_server_error('errorsaving');
}
}
// unsubscribe mailbox
else if ($RCMAIL->action == 'unsubscribe')
{
else if ($RCMAIL->action == 'unsubscribe') {
$mbox = rcube_utils::get_input_value('_mbox', rcube_utils::INPUT_POST, true, 'UTF7-IMAP');
if (strlen($mbox)) {
$result = $STORAGE->unsubscribe(array($mbox));
@ -69,10 +67,8 @@ else if ($RCMAIL->action == 'unsubscribe')
$RCMAIL->display_server_error('errorsaving');
}
}
// delete an existing mailbox
else if ($RCMAIL->action == 'delete-folder')
{
else if ($RCMAIL->action == 'delete-folder') {
$mbox_utf8 = rcube_utils::get_input_value('_mbox', rcube_utils::INPUT_POST, true);
$mbox = rcube_charset::convert($mbox_utf8, RCUBE_CHARSET, 'UTF7-IMAP');
@ -104,10 +100,8 @@ else if ($RCMAIL->action == 'delete-folder')
$RCMAIL->display_server_error('errorsaving');
}
}
// rename an existing mailbox
else if ($RCMAIL->action == 'rename-folder')
{
else if ($RCMAIL->action == 'rename-folder') {
$name_utf8 = trim(rcube_utils::get_input_value('_folder_newname', rcube_utils::INPUT_POST, true));
$oldname_utf8 = rcube_utils::get_input_value('_folder_oldname', rcube_utils::INPUT_POST, true);
@ -125,17 +119,16 @@ else if ($RCMAIL->action == 'rename-folder')
$RCMAIL->display_server_error('errorsaving');
}
}
// clear mailbox
else if ($RCMAIL->action == 'purge')
{
$mbox_utf8 = rcube_utils::get_input_value('_mbox', rcube_utils::INPUT_POST, true);
$mbox = rcube_charset::convert($mbox_utf8, RCUBE_CHARSET, 'UTF7-IMAP');
$delimiter = $STORAGE->get_hierarchy_delimiter();
$trash_regexp = '/^' . preg_quote($CONFIG['trash_mbox'] . $delimiter, '/') . '/';
else if ($RCMAIL->action == 'purge') {
$mbox_utf8 = rcube_utils::get_input_value('_mbox', rcube_utils::INPUT_POST, true);
$mbox = rcube_charset::convert($mbox_utf8, RCUBE_CHARSET, 'UTF7-IMAP');
$delimiter = $STORAGE->get_hierarchy_delimiter();
$trash_mbox = $RCMAIL->config->get('trash_mbox');
$trash_regexp = '/^' . preg_quote($trash . $delimiter, '/') . '/';
// we should only be purging trash (or their subfolders)
if (!strlen($CONFIG['trash_mbox']) || $mbox == $CONFIG['trash_mbox']
if (!strlen($trash_mbox) || $mbox === $trash_mbox
|| preg_match($trash_regexp, $mbox)
) {
$success = $STORAGE->delete_message('*', $mbox);
@ -143,7 +136,7 @@ else if ($RCMAIL->action == 'purge')
}
// copy to Trash
else {
$success = $STORAGE->move_message('1:*', $CONFIG['trash_mbox'], $mbox);
$success = $STORAGE->move_message('1:*', $trash_mbox, $mbox);
$delete = false;
}
@ -163,10 +156,8 @@ else if ($RCMAIL->action == 'purge')
$RCMAIL->display_server_error('errorsaving');
}
}
// get mailbox size
else if ($RCMAIL->action == 'folder-size')
{
else if ($RCMAIL->action == 'folder-size') {
$name = rcube_utils::get_input_value('_mbox', rcube_utils::INPUT_POST, true);
$size = $STORAGE->folder_size($name);
@ -181,8 +172,29 @@ else if ($RCMAIL->action == 'folder-size')
}
}
if ($OUTPUT->ajax_call)
if ($OUTPUT->ajax_call) {
$OUTPUT->send();
}
$OUTPUT->set_pagetitle($RCMAIL->gettext('folders'));
$OUTPUT->include_script('list.js');
$OUTPUT->set_env('prefix_ns', $STORAGE->get_namespace('prefix'));
if ($STORAGE->get_capability('QUOTA')) {
$OUTPUT->set_env('quota', true);
}
// add some labels to client
$OUTPUT->add_label('deletefolderconfirm', 'purgefolderconfirm', 'folderdeleting',
'foldermoving', 'foldersubscribing', 'folderunsubscribing', 'quota');
// register UI objects
$OUTPUT->add_handlers(array(
'foldersubscription' => 'rcube_subscription_form',
'folderframe' => 'rcmail_folder_frame',
'quotadisplay' => array($RCMAIL, 'quota_display'),
));
$OUTPUT->send('folders');
// build table with all folders listed by server
@ -417,23 +429,3 @@ function rcmail_rename_folder($oldname, $newname)
return false;
}
$OUTPUT->set_pagetitle($RCMAIL->gettext('folders'));
$OUTPUT->include_script('list.js');
$OUTPUT->set_env('prefix_ns', $STORAGE->get_namespace('prefix'));
if ($STORAGE->get_capability('QUOTA')) {
$OUTPUT->set_env('quota', true);
}
// add some labels to client
$OUTPUT->add_label('deletefolderconfirm', 'purgefolderconfirm', 'folderdeleting',
'foldermoving', 'foldersubscribing', 'folderunsubscribing', 'quota');
// register UI objects
$OUTPUT->add_handlers(array(
'foldersubscription' => 'rcube_subscription_form',
'folderframe' => 'rcmail_folder_frame',
'quotadisplay' => array($RCMAIL, 'quota_display'),
));
$OUTPUT->send('folders');

Loading…
Cancel
Save