From ead98f4efb712deb124655fd6fe0bf30d8e642c5 Mon Sep 17 00:00:00 2001
From: Aleksander Machniak <alec@alec.pl>
Date: Sat, 26 May 2012 04:35:26 -0400
Subject: [PATCH] Merge branch 'release-0.8' of github.com:roundcube/roundcubemail into release-0.8

---
 plugins/hide_blockquote/skins/default/style.css |    2 
 CHANGELOG                                       |    1 
 plugins/hide_blockquote/hide_blockquote.js      |    2 
 plugins/password/drivers/virtualmin.php         |    4 ++
 program/steps/settings/func.inc                 |   12 ++++++
 program/localization/en_US/labels.inc           |    3 +
 skins/default/includes/messagetoolbar.html      |   12 +----
 program/include/rcube_session.php               |   35 +++++++++--------
 plugins/password/config.inc.php.dist            |    3 +
 .htaccess                                       |    4 +-
 program/steps/settings/save_prefs.inc           |    1 
 11 files changed, 48 insertions(+), 31 deletions(-)

diff --git a/.htaccess b/.htaccess
index d5ebe4c..82afe76 100644
--- a/.htaccess
+++ b/.htaccess
@@ -30,8 +30,8 @@
 RewriteEngine On
 RewriteRule ^favicon\.ico$ skins/default/images/favicon.ico
 # security rules
-RewriteRule .git/ - [F]
-RewriteRule ^README|INSTALL|LICENSE|SQL|bin|CHANGELOG$ - [F]
+RewriteRule .git - [F]
+RewriteRule ^/?(README(.md)?|INSTALL|LICENSE|SQL|bin|CHANGELOG)$ - [F]
 </IfModule>
 
 <IfModule mod_deflate.c>
diff --git a/CHANGELOG b/CHANGELOG
index e38a509..330e90c 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,7 @@
 CHANGELOG Roundcube Webmail
 ===========================
 
+- Move messages forwarding mode setting into Preferences
 - Fix HTML entities handling in HTML editor (#1488483)
 - Fix listing shared folders on Courier IMAP (#1488466)
 
diff --git a/plugins/hide_blockquote/hide_blockquote.js b/plugins/hide_blockquote/hide_blockquote.js
index 9ab90af..20286ee 100644
--- a/plugins/hide_blockquote/hide_blockquote.js
+++ b/plugins/hide_blockquote/hide_blockquote.js
@@ -24,7 +24,7 @@
       .css({'white-space': 'nowrap', overflow: 'hidden', position: 'relative'})
       .text(res[0]);
 
-    link = $('<span class="blockquote-link">')
+    link = $('<span class="blockquote-link"></span>')
       .css({position: 'absolute', 'z-Index': 2})
       .text(rcmail.gettext('hide_blockquote.show'))
       .data('parent', div)
diff --git a/plugins/hide_blockquote/skins/default/style.css b/plugins/hide_blockquote/skins/default/style.css
index 7b3c871..198172f 100644
--- a/plugins/hide_blockquote/skins/default/style.css
+++ b/plugins/hide_blockquote/skins/default/style.css
@@ -17,7 +17,7 @@
   border-top: none;
   border-bottom-right-radius: 6px;
   border-bottom-left-radius: 6px;
-  background: #fff;
+  background: #f8f8f8;
   background: -moz-linear-gradient(top, #f8f8f8 0%, #e8e8e8 100%);
   background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#f8f8f8), color-stop(100%,#e8e8e8));
   background: -o-linear-gradient(top, #f8f8f8 0%, #e8e8e8 100%);
diff --git a/plugins/password/config.inc.php.dist b/plugins/password/config.inc.php.dist
index aed0eaf..37c7931 100644
--- a/plugins/password/config.inc.php.dist
+++ b/plugins/password/config.inc.php.dist
@@ -308,7 +308,8 @@
 // 5: domain-username
 // 6: username_domain
 // 7: domain_username
-$rcmail_config['password_virtualmin_format'] = 0;
+// 8: username@domain; mbox.username
+$rcmail_config['password_virtualmin_format'] = 8;
 
 
 // pw_usermod Driver options
diff --git a/plugins/password/drivers/virtualmin.php b/plugins/password/drivers/virtualmin.php
index b2547e0..f6b9bd4 100644
--- a/plugins/password/drivers/virtualmin.php
+++ b/plugins/password/drivers/virtualmin.php
@@ -48,6 +48,10 @@
             $pieces = explode("_", $username);
             $domain = $pieces[0];
             break;
+		case 8: // domain taken from alias, username left as it was
+			$email = $rcmail->user->data['alias'];
+			$domain = substr(strrchr($email, "@"), 1);
+			break
         default: // username@domain
             $domain = substr(strrchr($username, "@"), 1);
         }
diff --git a/program/include/rcube_session.php b/program/include/rcube_session.php
index 53042b3..4ac3954 100644
--- a/program/include/rcube_session.php
+++ b/program/include/rcube_session.php
@@ -40,7 +40,7 @@
   private $unsets = array();
   private $gc_handlers = array();
   private $cookiename = 'roundcube_sessauth';
-  private $vars = false;
+  private $vars;
   private $key;
   private $now;
   private $secret = '';
@@ -137,11 +137,10 @@
       $this->vars    = base64_decode($sql_arr['vars']);
       $this->key     = $key;
 
-      if (!empty($this->vars))
-        return $this->vars;
+      return !empty($this->vars) ? (string) $this->vars : '';
     }
 
-    return false;
+    return null;
   }
 
 
@@ -160,7 +159,7 @@
 
     // no session row in DB (db_read() returns false)
     if (!$this->key) {
-      $oldvars = false;
+      $oldvars = null;
     }
     // use internal data from read() for fast requests (up to 0.5 sec.)
     else if ($key == $this->key && (!$this->vars || $ts - $this->start < 0.5)) {
@@ -170,7 +169,7 @@
       $oldvars = $this->db_read($key);
     }
 
-    if ($oldvars !== false) {
+    if ($oldvars !== null) {
       $newvars = $this->_fixvars($vars, $oldvars);
 
       if ($newvars !== $oldvars) {
@@ -200,7 +199,7 @@
    */
   private function _fixvars($vars, $oldvars)
   {
-    if ($oldvars !== false) {
+    if ($oldvars !== null) {
       $a_oldvars = $this->unserialize($oldvars);
       if (is_array($a_oldvars)) {
         foreach ((array)$this->unsets as $k)
@@ -268,12 +267,12 @@
       $this->vars    = $arr['vars'];
       $this->key     = $key;
 
-      if (!empty($this->vars))
-        return $this->vars;
+      return !empty($this->vars) ? (string) $this->vars : '';
     }
 
-    return false;
+    return null;
   }
+
 
   /**
    * Save session data.
@@ -289,20 +288,21 @@
 
     // no session data in cache (mc_read() returns false)
     if (!$this->key)
-      $oldvars = false;
+      $oldvars = null;
     // use internal data for fast requests (up to 0.5 sec.)
     else if ($key == $this->key && (!$this->vars || $ts - $this->start < 0.5))
       $oldvars = $this->vars;
     else // else read data again
       $oldvars = $this->mc_read($key);
 
-    $newvars = $oldvars !== false ? $this->_fixvars($vars, $oldvars) : $vars;
-    
+    $newvars = $oldvars !== null ? $this->_fixvars($vars, $oldvars) : $vars;
+
     if ($newvars !== $oldvars || $ts - $this->changed > $this->lifetime / 2)
       return $this->memcache->set($key, serialize(array('changed' => time(), 'ip' => $this->ip, 'vars' => $newvars)), MEMCACHE_COMPRESSED, $this->lifetime);
-    
+
     return true;
   }
+
 
   /**
    * Handler for session_destroy() with memcache backend
@@ -352,7 +352,7 @@
   {
     session_regenerate_id($destroy);
 
-    $this->vars = false;
+    $this->vars = null;
     $this->key  = session_id();
 
     return true;
@@ -375,13 +375,14 @@
 
     return true;
   }
-  
+
+
   /**
    * Kill this session
    */
   public function kill()
   {
-    $this->vars = false;
+    $this->vars = null;
     $this->ip = $_SERVER['REMOTE_ADDR']; // update IP (might have changed)
     $this->destroy(session_id());
     rcmail::setcookie($this->cookiename, '-del-', time() - 60);
diff --git a/program/localization/en_US/labels.inc b/program/localization/en_US/labels.inc
index 277f1a9..94bae19 100644
--- a/program/localization/en_US/labels.inc
+++ b/program/localization/en_US/labels.inc
@@ -457,6 +457,9 @@
 $labels['spellcheckignorecaps'] = 'Ignore words with all letters capitalized';
 $labels['addtodict'] = 'Add to dictionary';
 $labels['mailtoprotohandler'] = 'Register protocol handler for mailto: links';
+$labels['forwardmode'] = 'Messages forwarding';
+$labels['inline'] = 'inline';
+$labels['asattachment'] = 'as attachment';
 
 $labels['folder']  = 'Folder';
 $labels['folders']  = 'Folders';
diff --git a/program/steps/settings/func.inc b/program/steps/settings/func.inc
index d2db1df..dc7c68e 100644
--- a/program/steps/settings/func.inc
+++ b/program/steps/settings/func.inc
@@ -620,6 +620,18 @@
       );
     }
 
+    if (!isset($no_override['forward_attachment'])) {
+      $field_id = 'rcmfd_forward_attachment';
+      $select = new html_select(array('name' => '_forward_attachment', 'id' => $field_id));
+      $select->add(rcube_label('inline'), 0);
+      $select->add(rcube_label('asattachment'), 1);
+
+      $blocks['main']['options']['forward_attachment'] = array(
+        'title' => html::label($field_id, Q(rcube_label('forwardmode'))),
+        'content' => $select->show(intval($config['forward_attachment'])),
+      );
+    }
+
     if (!isset($no_override['default_font'])) {
       $field_id     = 'rcmfd_default_font';
       $fonts        = rcube_fontdefs();
diff --git a/program/steps/settings/save_prefs.inc b/program/steps/settings/save_prefs.inc
index f521f4f..cacc359 100644
--- a/program/steps/settings/save_prefs.inc
+++ b/program/steps/settings/save_prefs.inc
@@ -89,6 +89,7 @@
       'strip_existing_sig' => isset($_POST['_strip_existing_sig']),
       'sig_above'          => !empty($_POST['_sig_above']) && !empty($_POST['_top_posting']),
       'default_font'       => get_input_value('_default_font', RCUBE_INPUT_POST),
+      'forward_attachment' => !empty($_POST['_forward_attachment']),
     );
 
   break;
diff --git a/skins/default/includes/messagetoolbar.html b/skins/default/includes/messagetoolbar.html
index 57bed8a..3f4995b 100644
--- a/skins/default/includes/messagetoolbar.html
+++ b/skins/default/includes/messagetoolbar.html
@@ -26,15 +26,9 @@
 </div>
 
 <div id="forwardmenu" class="popupmenu">
-    <ul class="toolbarmenu">
-        <li class="block">
-            <input type="radio" name="forwardtype" value="0" onchange="rcmail.command('save-pref', {name: 'forward_attachment', value: 0, env: 'forward_attachment'});" />
-            <roundcube:button command="forward" label="forwardinline" prop="sub" classAct="forwardlink active" class="forwardlink" />
-        </li>
-        <li class="block">
-            <input type="radio" name="forwardtype" value="1" onchange="rcmail.command('save-pref', {name: 'forward_attachment', value: 1, env: 'forward_attachment'})" />
-            <roundcube:button command="forward-attachment" label="forwardattachment" prop="sub" classAct="forwardattachmentlink active" class="forwardattachmentlink" />
-        </li>    
+    <ul>
+        <li><roundcube:button command="forward" label="forwardinline" prop="sub" classAct="forwardlink active" class="forwardlink" /></li>
+        <li><roundcube:button command="forward-attachment" label="forwardattachment" prop="sub" classAct="forwardattachmentlink active" class="forwardattachmentlink" /></li>
         <roundcube:container name="forwardmenu" id="forwardmenu" />
     </ul>
 </div>

--
Gitblit v1.9.1