From 08bb20f261d8c6c6e472dc9620d175b171e220d8 Mon Sep 17 00:00:00 2001
From: Aleksander Machniak <alec@alec.pl>
Date: Sun, 02 Aug 2015 14:16:46 -0400
Subject: [PATCH] Don't use deprecated functions/constants (from bc.inc)

---
 program/steps/mail/func.inc |   66 +++++++++++++++-----------------
 1 files changed, 31 insertions(+), 35 deletions(-)

diff --git a/program/steps/mail/func.inc b/program/steps/mail/func.inc
index 48d9899..d078478 100644
--- a/program/steps/mail/func.inc
+++ b/program/steps/mail/func.inc
@@ -1,6 +1,6 @@
 <?php
 
-/*
+/**
  +-----------------------------------------------------------------------+
  | program/steps/mail/func.inc                                           |
  |                                                                       |
@@ -37,7 +37,7 @@
 }
 
 // remove mbox part from _uid
-if (($_uid  = rcube_utils::get_input_value('_uid', RCUBE_INPUT_GPC)) && !is_array($_uid) && preg_match('/^\d+-.+/', $_uid)) {
+if (($_uid  = rcube_utils::get_input_value('_uid', rcube_utils::INPUT_GPC)) && !is_array($_uid) && preg_match('/^\d+-.+/', $_uid)) {
   list($_uid, $mbox) = explode('-', $_uid, 2);
   if (isset($_GET['_uid']))  $_GET['_uid']  = $_uid;
   if (isset($_POST['_uid'])) $_POST['_uid'] = $_uid;
@@ -64,17 +64,6 @@
     $mbox_name = $RCMAIL->storage->get_folder();
 
     if (empty($RCMAIL->action)) {
-        // initialize searching result if search_filter is used
-        if ($_SESSION['search_filter'] && $_SESSION['search_filter'] != 'ALL') {
-            $RCMAIL->storage->search($mbox_name, $_SESSION['search_filter'], RCUBE_CHARSET, rcmail_sort_column());
-
-            $search_request             = md5($mbox_name.$_SESSION['search_filter']);
-            $_SESSION['search']         = $RCMAIL->storage->get_search_set();
-            $_SESSION['search_request'] = $search_request;
-
-            $OUTPUT->set_env('search_request', $search_request);
-        }
-
         $OUTPUT->set_env('search_mods', rcmail_search_mods());
 
         if (!empty($_SESSION['search_scope']))
@@ -172,12 +161,17 @@
     if (!strlen($mbox = rcube_utils::get_input_value('_mbox', rcube_utils::INPUT_GPC, true))) {
         $mbox = strlen($_SESSION['mbox']) ? $_SESSION['mbox'] : 'INBOX';
     }
-    if (!($page = intval($_GET['_page']))) {
-        $page = $_SESSION['page'] ? $_SESSION['page'] : 1;
+
+    if ($RCMAIL->action == 'list') {
+        if (!($page = intval($_GET['_page']))) {
+            $page = $_SESSION['page'] ? $_SESSION['page'] : 1;
+        }
+
+        $_SESSION['page'] = $page;
     }
 
     $RCMAIL->storage->set_folder($_SESSION['mbox'] = $mbox);
-    $RCMAIL->storage->set_page($_SESSION['page'] = $page);
+    $RCMAIL->storage->set_page($_SESSION['page']);
 
     // set default sort col/order to session
     if (!isset($_SESSION['sort_col'])) {
@@ -399,6 +393,7 @@
         $head_replace = true;
     }
 
+    $delimiter   = $RCMAIL->storage->get_hierarchy_delimiter();
     $search_set  = $RCMAIL->storage->get_search_set();
     $multifolder = $search_set && $search_set[1]->multi;
 
@@ -486,11 +481,19 @@
                 $cont = rcube::Q($cont);
             }
             else if ($col == 'size')
-                $cont = show_bytes($header->$col);
+                $cont = $RCMAIL->show_bytes($header->$col);
             else if ($col == 'date')
                 $cont = $RCMAIL->format_date($header->date);
-            else if ($col == 'folder')
-                $cont = rcube::Q(rcube_charset::convert($header->folder, 'UTF7-IMAP'));
+            else if ($col == 'folder') {
+                if ($last_folder !== $header->folder) {
+                    $last_folder      = $header->folder;
+                    $last_folder_name = rcube_charset::convert($last_folder, 'UTF7-IMAP');
+                    $last_folder_name = $RCMAIL->localize_foldername($last_folder_name, true);
+                    $last_folder_name = str_replace($delimiter, " \xC2\xBB ", $last_folder_name);
+                }
+
+                $cont = rcube::Q($last_folder_name);
+            }
             else
                 $cont = rcube::Q($header->$col);
 
@@ -1751,20 +1754,6 @@
 }
 
 /**
- * clear message composing settings
- */
-function rcmail_compose_cleanup($id)
-{
-    if (!isset($_SESSION['compose_data_'.$id])) {
-        return;
-    }
-
-    $rcmail = rcmail::get_instance();
-    $rcmail->plugins->exec_hook('attachments_cleanup', array('group' => $id));
-    $rcmail->session->remove('compose_data_'.$id);
-}
-
-/**
  * Send the MDN response
  *
  * @param mixed $message    Original message object (rcube_message) or UID
@@ -1959,9 +1948,16 @@
 // Fixes some content-type names
 function rcmail_fix_mimetype($name)
 {
+    $map = array(
+        'image/x-ms-bmp' => 'image/bmp', // #1490282
+    );
+
+    if ($alias = $map[strtolower($name)]) {
+        $name = $alias;
+    }
     // Some versions of Outlook create garbage Content-Type:
     // application/pdf.A520491B_3BF7_494D_8855_7FAC2C6C0608
-    if (preg_match('/^application\/pdf.+/', $name)) {
+    else if (preg_match('/^application\/pdf.+/', $name)) {
         $name = 'application/pdf';
     }
     // treat image/pjpeg (image/pjpg, image/jpg) as image/jpeg (#1489097)
@@ -2040,7 +2036,7 @@
     $select_filter->add($RCMAIL->gettext('priority').': '.$RCMAIL->gettext('low'), 'HEADER X-PRIORITY 4');
     $select_filter->add($RCMAIL->gettext('priority').': '.$RCMAIL->gettext('lowest'), 'HEADER X-PRIORITY 5');
 
-    $out = $select_filter->show($_SESSION['search_filter']);
+    $out = $select_filter->show($_REQUEST['_search'] ? $_SESSION['search_filter'] : 'ALL');
 
     $RCMAIL->output->add_gui_object('search_filter', $attrib['id']);
 

--
Gitblit v1.9.1