From 07c7ffa13a81aa2f155e590307e4e0df88a4ef95 Mon Sep 17 00:00:00 2001 From: pb Date: Fri, 15 Feb 2008 17:17:20 +0000 Subject: [PATCH] =?UTF-8?q?incorporate=20r1651=20|=20chrisg23=20|=202007-0?= =?UTF-8?q?9-18=2012:30:06=20+0200=20(Di,=2018=20Sep=202007)=20Ge=C3=A4nde?= =?UTF-8?q?rte=20Pfade:=20Extension=20of=20Sourceforge=20patch=201679071?= =?UTF-8?q?=20-=20add=20a=20flag=20to=20xml=20if=20user=20has=20publish=20?= =?UTF-8?q?privilege=20on=20the=20current=20page=20(only=20useful=20for=20?= =?UTF-8?q?non-caching=20sites)=20----------------------------------------?= =?UTF-8?q?--------------------------------=20r1652=20|=20chrisg23=20|=202?= =?UTF-8?q?007-09-18=2012:35:42=20+0200=20(Di,=2018=20Sep=202007)=20Source?= =?UTF-8?q?forge=20patch=201793108=20-=20allow=20specific=20content=20type?= =?UTF-8?q?s=20to=20be=20hidden=20from=20some=20users=20when=20creating=20?= =?UTF-8?q?a=20new=20item?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: https://svn.libreccm.org/ccm/trunk@23 8810af33-2d31-482b-a856-94f89814c4df --- .../cms/dispatcher/SimpleXMLGenerator.java | 4 +++ .../cms/ui/authoring/NewItemForm.java | 29 +++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/ccm-cms/src/com/arsdigita/cms/dispatcher/SimpleXMLGenerator.java b/ccm-cms/src/com/arsdigita/cms/dispatcher/SimpleXMLGenerator.java index fb47c4fb6..b35d797c4 100755 --- a/ccm-cms/src/com/arsdigita/cms/dispatcher/SimpleXMLGenerator.java +++ b/ccm-cms/src/com/arsdigita/cms/dispatcher/SimpleXMLGenerator.java @@ -106,6 +106,10 @@ public class SimpleXMLGenerator implements XMLGenerator { if (PermissionService.checkPermission(edit)) { parent.addAttribute("canEdit", "true"); } + PermissionDescriptor publish = new PermissionDescriptor(PrivilegeDescriptor.get(SecurityManager.CMS_PUBLISH), item, currentParty); + if (PermissionService.checkPermission(publish)) { + parent.addAttribute("canPublish", "true"); + } String className = item.getDefaultDomainClass(); // Ensure correct subtype of ContentItem is instantiated diff --git a/ccm-cms/src/com/arsdigita/cms/ui/authoring/NewItemForm.java b/ccm-cms/src/com/arsdigita/cms/ui/authoring/NewItemForm.java index 6fe580737..587f4ffbf 100755 --- a/ccm-cms/src/com/arsdigita/cms/ui/authoring/NewItemForm.java +++ b/ccm-cms/src/com/arsdigita/cms/ui/authoring/NewItemForm.java @@ -33,7 +33,14 @@ import com.arsdigita.bebop.parameters.BigDecimalParameter; import com.arsdigita.cms.ContentSection; import com.arsdigita.cms.ContentType; import com.arsdigita.cms.ContentTypeCollection; +import com.arsdigita.cms.SecurityManager; import com.arsdigita.globalization.GlobalizedMessage; +import com.arsdigita.kernel.Kernel; +import com.arsdigita.kernel.Party; +import com.arsdigita.kernel.permissions.PermissionDescriptor; +import com.arsdigita.kernel.permissions.PermissionManager; +import com.arsdigita.kernel.permissions.PermissionService; +import com.arsdigita.kernel.permissions.PrivilegeDescriptor; import com.arsdigita.util.UncheckedWrapperException; import com.arsdigita.xml.Element; @@ -104,7 +111,27 @@ public abstract class NewItemForm extends Form { if(!c.isEmpty()) { // Add content types while(c.next()) { + boolean list = true; ContentType type = c.getContentType(); + if (PermissionService.getDirectGrantedPermissions(type.getOID()).size() > 0) { + // chris gilbert - allow restriction of some types to certain + // users/groups. No interface to do this, but group could be + // created and permission granted in a content type loader + // + // can't permission filter the collection because most types + // will have no permissions granted. This approach involves + // a small overhead getting the count of granted permissions for + // each type (mitigated by only checking DIRECT permissions) + + Party party = Kernel.getContext().getParty(); + if (party == null) { + party = Kernel.getPublicUser(); + } + PermissionDescriptor create = new PermissionDescriptor(PrivilegeDescriptor.get(SecurityManager.CMS_NEW_ITEM), type, party ); + list = PermissionService.checkPermission(create); + + } + if (list) { //for dp content type label localization //String t = type.getAssociatedObjectType(); String cn = type.getClassName(); @@ -118,6 +145,8 @@ public abstract class NewItemForm extends Form { (type.getID().toString(), type.getLabel())); } } + + } c.reset(); } }