diff --git a/framework/common/webcommon/WEB-INF/actions/includes/GetParentPortalPageId.groovy b/framework/common/webcommon/WEB-INF/actions/includes/GetParentPortalPageId.groovy new file mode 100644 index 0000000000..b3e1014d52 --- /dev/null +++ b/framework/common/webcommon/WEB-INF/actions/includes/GetParentPortalPageId.groovy @@ -0,0 +1,57 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.ofbiz.entity.*; +import org.ofbiz.base.util.*; +import org.ofbiz.entity.condition.*; + +// executes only on startup when no parameters.portalPageId is available +if (parameters.parentPortalPageId && !parameters.portalPageId) { + // look for system page according the current securitygroup + //get the security group + userLoginSecurityGroupId = null; + condSec = EntityCondition.makeCondition([ + EntityCondition.makeCondition("groupId", EntityOperator.LIKE, parameters.parentPortalPageId + "%"), + EntityCondition.makeCondition("userLoginId", EntityOperator.EQUALS, parameters.userLogin.userLoginId) + ],EntityOperator.AND); + userLoginSecurityGroups = delegator.findList("UserLoginSecurityGroup", condSec, null, null, null, false); + if (UtilValidate.isNotEmpty(userLoginSecurityGroups)) { + userLoginSecurityGroupId = userLoginSecurityGroups.get(0).get("groupId"); + } + Debug.log("=====security group found: " + userLoginSecurityGroupId); + //get the portal page + cond1 = EntityCondition.makeCondition([ + EntityCondition.makeCondition("portalPageId", EntityOperator.LIKE, parameters.parentPortalPageId + "%"), + EntityCondition.makeCondition("securityGroupId", EntityOperator.EQUALS, userLoginSecurityGroupId), + EntityCondition.makeCondition("ownerUserLoginId", EntityOperator.EQUALS, "_NA_"), + EntityCondition.makeCondition("parentPortalPageId", EntityOperator.EQUALS, null) + ],EntityOperator.AND); + portalMainPages = delegator.findList("PortalPage", cond1, null, null, null, false); + if (portalMainPages) { + portalPage = portalMainPages.get(0); + Debug.log("=====page found: " + portalPage.portalPageId); + if ("_NA_".equals(portalPage.ownerUserLoginId)) { + context.parameters.parentPortalPageId = portalPage.portalPageId; + } else { + context.parameters.parentPortalPageId = portalPage.orginalPortalPageId; + } + context.parameters.portalPageId = portalPage.portalPageId; //make sure we have a starting portalPageId + context.headerItem = portalPage.portalPageId; // and the menu item is highlighted + } +} diff --git a/framework/common/webcommon/WEB-INF/actions/includes/ListPortalPages.groovy b/framework/common/webcommon/WEB-INF/actions/includes/ListPortalPages.groovy index 3d004dd01a..c66f21a93d 100644 --- a/framework/common/webcommon/WEB-INF/actions/includes/ListPortalPages.groovy +++ b/framework/common/webcommon/WEB-INF/actions/includes/ListPortalPages.groovy @@ -22,7 +22,6 @@ import org.ofbiz.base.util.*; import org.ofbiz.entity.condition.*; // only execute when a user is logged in if (parameters.userLogin) { - // find userLoginSecurityGroupId = null; condSec = EntityCondition.makeCondition([ EntityCondition.makeCondition("groupId", EntityOperator.LIKE, parameters.parentPortalPageId + "%"), @@ -34,7 +33,7 @@ if (parameters.userLogin) { userLoginSecurityGroupId = userLoginSecurityGroups.get(0).get("groupId"); } - //get the portal page + //get the portal mainpage cond1 = EntityCondition.makeCondition([ EntityCondition.makeCondition("portalPageId", EntityOperator.LIKE, parameters.parentPortalPageId + "%"), EntityCondition.makeCondition("securityGroupId", EntityOperator.EQUALS, userLoginSecurityGroupId), @@ -45,7 +44,7 @@ if (parameters.userLogin) { if (portalMainPages) { parentPortalPageId = portalMainPages.get(0).portalPageId; } - + // get user and system pages ppCond = EntityCondition.makeCondition([ EntityCondition.makeCondition([ @@ -72,6 +71,5 @@ if (parameters.userLogin) { context.portalPages = portalPages; context.userLoginSecurityGroupId = userLoginSecurityGroupId; - parameters.parentPortalPageId = parentPortalPageId } diff --git a/framework/common/webcommon/WEB-INF/actions/includes/ShowPortalPage.groovy b/framework/common/webcommon/WEB-INF/actions/includes/ShowPortalPage.groovy deleted file mode 100644 index a86663927b..0000000000 --- a/framework/common/webcommon/WEB-INF/actions/includes/ShowPortalPage.groovy +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.ofbiz.entity.*; -import org.ofbiz.base.util.*; -import org.ofbiz.entity.condition.*; - -portalPage = null; -portalPageId = parameters.portalPageId; -if(!portalPageId){ - portalPageId = parameters.parentPortalPageId; -} - -if (portalPageId) { - portalPage = delegator.findByPrimaryKey("PortalPage", [portalPageId : portalPageId]); - if (portalPage && portalPage.parentPortalPageId && !parameters.parentPortalPageId) { - parameters.parentPortalPageId = portalPage.parentPortalPageId; - } -} - -if (!portalPage) { - // find the user private main page - condPrivat = EntityCondition.makeCondition([ - EntityCondition.makeCondition("originalPortalPageId", EntityOperator.LIKE, portalPageId + "%"), - EntityCondition.makeCondition("ownerUserLoginId", EntityOperator.EQUALS, parameters.userLogin.userLoginId) - ],EntityOperator.AND); - privatPortalPages = delegator.findList("PortalPage", condPrivat, null, null, null, false); - - if (privatPortalPages) { - portalPage = privatPortalPages.get(0); - } else { - // look for system page according the current securitygroup - //get the security group - userLoginSecurityGroupId = null; - condSec = EntityCondition.makeCondition([ - EntityCondition.makeCondition("groupId", EntityOperator.LIKE, portalPageId + "%"), - EntityCondition.makeCondition("userLoginId", EntityOperator.EQUALS, parameters.userLogin.userLoginId) - ],EntityOperator.AND); - userLoginSecurityGroups = delegator.findList("UserLoginSecurityGroup", condSec, null, null, null, false); - if (UtilValidate.isNotEmpty(userLoginSecurityGroups)) { - userLoginSecurityGroupId = userLoginSecurityGroups.get(0).get("groupId"); - } - //get the portal page - cond1 = EntityCondition.makeCondition([ - EntityCondition.makeCondition("portalPageId", EntityOperator.LIKE, portalPageId + "%"), - EntityCondition.makeCondition("securityGroupId", EntityOperator.EQUALS, userLoginSecurityGroupId), - EntityCondition.makeCondition("ownerUserLoginId", EntityOperator.EQUALS, "_NA_"), - EntityCondition.makeCondition("parentPortalPageId", EntityOperator.EQUALS, null) - ],EntityOperator.AND); - portalMainPages = delegator.findList("PortalPage", cond1, null, null, null, false); - if (portalMainPages) { - portalPage = portalMainPages.get(0); - } - } -} - -if (portalPage) { - parameters.portalPageId = portalPage.portalPageId; - context.portalPage = portalPage; - context.portalPageColumns = portalPage.getRelated("PortalPageColumn"); - context.portalPagePortlets = delegator.findByAnd("PortalPagePortletView", [portalPageId : portalPage.portalPageId], ["columnSeqId", "sequenceNum"]); -} diff --git a/framework/common/widget/PortalPageScreens.xml b/framework/common/widget/PortalPageScreens.xml index ae003193a9..200f55297c 100644 --- a/framework/common/widget/PortalPageScreens.xml +++ b/framework/common/widget/PortalPageScreens.xml @@ -25,18 +25,28 @@ under the License.
-