From d1382aecb2b3439a34869221ddab8018c511f7e6 Mon Sep 17 00:00:00 2001
From: Aleksander Machniak <alec@alec.pl>
Date: Tue, 13 Jan 2015 05:01:17 -0500
Subject: [PATCH] Fix so "set as default" option is hidden if identities_level > 1 (#1490226)

---
 CHANGELOG                                |    1 +
 program/steps/settings/save_identity.inc |    5 +++++
 program/steps/settings/edit_identity.inc |    5 +++++
 3 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG
index b2b6a3e..048fcb7 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -8,6 +8,7 @@
 - Fix checks based on window.ActiveXObject in IE > 10
 - Fix XSS issue in style attribute handling (#1490227)
 - Fix bug where Drafts list wasn't updated on draft-save action in new window (#1490225)
+- Fix so "set as default" option is hidden if identities_level > 1 (#1490226)
 
 RELEASE 1.1-rc
 --------------
diff --git a/program/steps/settings/edit_identity.inc b/program/steps/settings/edit_identity.inc
index cd7ba5f..298822d 100644
--- a/program/steps/settings/edit_identity.inc
+++ b/program/steps/settings/edit_identity.inc
@@ -109,6 +109,11 @@
         $IDENTITY_RECORD['signature'] = htmlspecialchars($IDENTITY_RECORD['signature'], ENT_NOQUOTES, RCUBE_CHARSET);
     }
 
+    // hide "default" checkbox if only one identity is allowed
+    if (IDENTITIES_LEVEL > 1) {
+        unset($form['addressing']['content']['standard']);
+    }
+
     // disable some field according to access level
     if (IDENTITIES_LEVEL == 1 || IDENTITIES_LEVEL == 3) {
         $form['addressing']['content']['email']['disabled'] = true;
diff --git a/program/steps/settings/save_identity.inc b/program/steps/settings/save_identity.inc
index de0c84c..ac7ef87 100644
--- a/program/steps/settings/save_identity.inc
+++ b/program/steps/settings/save_identity.inc
@@ -49,6 +49,11 @@
     }
 }
 
+// make the identity a "default" if only one identity is allowed
+if (IDENTITIES_LEVEL > 1) {
+    $save_data['standard'] = 1;
+}
+
 // unset email address if user has no rights to change it
 if (IDENTITIES_LEVEL == 1 || IDENTITIES_LEVEL == 3) {
     unset($save_data['email']);

--
Gitblit v1.9.1