details:   https://code.openbravo.com/erp/devel/pi/rev/89f6f8bf73ef
changeset: 13610:89f6f8bf73ef
user:      Iván Perdomo <ivan.perdomo <at> openbravo.com>
date:      Mon Aug 29 10:36:20 2011 +0200
summary:   Issue 18297: Added new preference property

details:   https://code.openbravo.com/erp/devel/pi/rev/784b668c22c7
changeset: 13611:784b668c22c7
user:      Iván Perdomo <ivan.perdomo <at> openbravo.com>
date:      Mon Aug 29 10:37:35 2011 +0200
summary:   Fixes issue 18297: Added new Preference to disable G button
- Activated instances have the posibility to disable the G button in the login
  page

diffstat:

 
modules/org.openbravo.service.integration.google/src-db/database/sourcedata/AD_REF_LIST.xml
 |  15 +++++++
 src/org/openbravo/erpCommon/security/Login.java                                
             |  21 +++++++++-
 2 files changed, 34 insertions(+), 2 deletions(-)

diffs (76 lines):

diff -r 4aefc5f4d063 -r 784b668c22c7 
modules/org.openbravo.service.integration.google/src-db/database/sourcedata/AD_REF_LIST.xml
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ 
b/modules/org.openbravo.service.integration.google/src-db/database/sourcedata/AD_REF_LIST.xml
       Mon Aug 29 10:37:35 2011 +0200
@@ -0,0 +1,15 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<data>
+<!--FF808081321441D9013214697218000D--><AD_REF_LIST>
+<!--FF808081321441D9013214697218000D-->  
<AD_REF_LIST_ID><![CDATA[FF808081321441D9013214697218000D]]></AD_REF_LIST_ID>
+<!--FF808081321441D9013214697218000D-->  
<AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--FF808081321441D9013214697218000D-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--FF808081321441D9013214697218000D-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--FF808081321441D9013214697218000D-->  
<VALUE><![CDATA[OBSEIG_ShowGIcon]]></VALUE>
+<!--FF808081321441D9013214697218000D-->  <NAME><![CDATA[Enable Google Button 
in Login Page]]></NAME>
+<!--FF808081321441D9013214697218000D-->  <DESCRIPTION><![CDATA[Shows/hides the 
G button in the Login page]]></DESCRIPTION>
+<!--FF808081321441D9013214697218000D-->  
<AD_REFERENCE_ID><![CDATA[A26BA480E2014707B47257024C3CBFF7]]></AD_REFERENCE_ID>
+<!--FF808081321441D9013214697218000D-->  
<AD_MODULE_ID><![CDATA[FF8080813129ADA401312CA1222A0005]]></AD_MODULE_ID>
+<!--FF808081321441D9013214697218000D--></AD_REF_LIST>
+
+</data>
diff -r 4aefc5f4d063 -r 784b668c22c7 
src/org/openbravo/erpCommon/security/Login.java
--- a/src/org/openbravo/erpCommon/security/Login.java   Mon Aug 29 10:04:30 
2011 +0200
+++ b/src/org/openbravo/erpCommon/security/Login.java   Mon Aug 29 10:37:35 
2011 +0200
@@ -25,9 +25,11 @@
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
+import org.hibernate.criterion.Restrictions;
 import org.openbravo.base.HttpBaseServlet;
 import org.openbravo.base.secureApp.VariablesSecureApp;
 import org.openbravo.dal.core.OBContext;
+import org.openbravo.dal.service.OBCriteria;
 import org.openbravo.dal.service.OBDal;
 import org.openbravo.erpCommon.businessUtility.Preferences;
 import org.openbravo.erpCommon.obps.ActivationKey;
@@ -35,6 +37,7 @@
 import org.openbravo.erpCommon.utility.OBVersion;
 import org.openbravo.erpCommon.utility.PropertyException;
 import org.openbravo.erpCommon.utility.Utility;
+import org.openbravo.model.ad.domain.Preference;
 import org.openbravo.model.ad.module.Module;
 import org.openbravo.model.ad.system.Client;
 import org.openbravo.model.ad.system.SystemInformation;
@@ -44,6 +47,7 @@
   private static final long serialVersionUID = 1L;
 
   private static final String GOOGLE_INTEGRATION_MODULE_ID = 
"FF8080813129ADA401312CA1222A0005";
+  private static final String GOOGLE_PREFERENCE_PROPERTY = "OBSEIG_ShowGIcon";
 
   public void doPost(HttpServletRequest request, HttpServletResponse response) 
throws IOException,
       ServletException {
@@ -242,10 +246,23 @@
     String itLink = "";
     String companyLink = "";
     SystemInformation sysInfo = 
OBDal.getInstance().get(SystemInformation.class, "0");
-
     Module module = OBDal.getInstance().get(Module.class, 
GOOGLE_INTEGRATION_MODULE_ID);
 
-    showGoogleIcon = (module != null && module.isActive());
+    if (ActivationKey.getInstance().isActive()) {
+      Client systemClient = OBDal.getInstance().get(Client.class, "0");
+      OBCriteria<Preference> obc = 
OBDal.getInstance().createCriteria(Preference.class);
+      obc.setFilterOnReadableClients(false);
+      obc.setFilterOnReadableOrganization(false);
+
+      obc.add(Restrictions.eq(Preference.PROPERTY_PROPERTY, 
GOOGLE_PREFERENCE_PROPERTY));
+      obc.add(Restrictions.eq(Preference.PROPERTY_SEARCHKEY, "Y"));
+      
obc.add(Restrictions.or(Restrictions.eq(Preference.PROPERTY_VISIBLEATCLIENT, 
systemClient),
+          Restrictions.isNull(Preference.PROPERTY_VISIBLEATCLIENT)));
+
+      showGoogleIcon = obc.count() > 0;
+    } else {
+      showGoogleIcon = (module != null && module.isEnabled());
+    }
 
     if (sysInfo == null) {
       log4j.error("System information not found");

------------------------------------------------------------------------------
EMC VNX: the world's simplest storage, starting under $10K
The only unified storage solution that offers unified management 
Up to 160% more powerful than alternatives and 25% more efficient. 
Guaranteed. http://p.sf.net/sfu/emc-vnx-dev2dev
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to