From 46f7b7096450939fe03c95aa81ce06ae4bfca89d Mon Sep 17 00:00:00 2001
From: Aleksander Machniak <alec@alec.pl>
Date: Mon, 28 Mar 2016 06:51:43 -0400
Subject: [PATCH] Enable reply/reply-all/forward buttons also in preview frame of message/rfc822

---
 program/lib/Roundcube/rcube_utils.php |   18 ++++++++++++------
 1 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/program/lib/Roundcube/rcube_utils.php b/program/lib/Roundcube/rcube_utils.php
index 07dc870..06f4314 100644
--- a/program/lib/Roundcube/rcube_utils.php
+++ b/program/lib/Roundcube/rcube_utils.php
@@ -469,7 +469,7 @@
 
         list($primary, $secondary) = explode('/', $mimetype);
 
-        $classes = array($primary ? $primary : 'unknown');
+        $classes = array($primary ?: 'unknown');
 
         if ($secondary) {
             $classes[] = $secondary;
@@ -579,7 +579,7 @@
         // %d - domain name without first part
         $d = preg_replace('/^[^\.]+\./', '', $_SERVER['HTTP_HOST']);
         // %h - IMAP host
-        $h = $_SESSION['storage_host'] ? $_SESSION['storage_host'] : $host;
+        $h = $_SESSION['storage_host'] ?: $host;
         // %z - IMAP domain without first part, e.g. %h=imap.domain.tld, %z=domain.tld
         $z = preg_replace('/^[^\.]+\./', '', $h);
         // %s - domain name after the '@' from e-mail address provided at login screen.
@@ -947,12 +947,18 @@
      */
     public static function words_match($haystack, $needle)
     {
-        $a_needle = self::tokenize_string($needle, 1);
-        $haystack = join(" ", self::tokenize_string($haystack, 1));
+        $a_needle  = self::tokenize_string($needle, 1);
+        $_haystack = join(" ", self::tokenize_string($haystack, 1));
+        $valid     = strlen($_haystack) > 0;
+        $hits      = 0;
 
-        $hits = 0;
         foreach ($a_needle as $w) {
-            if (stripos($haystack, $w) !== false) {
+            if ($valid) {
+                if (stripos($_haystack, $w) !== false) {
+                    $hits++;
+                }
+            }
+            else if (stripos($haystack, $w) !== false) {
                 $hits++;
             }
         }

--
Gitblit v1.9.1