incorporate

r1651 | chrisg23 | 2007-09-18 12:30:06 +0200 (Di, 18 Sep 2007)
Geänderte Pfade:
Extension of Sourceforge patch 1679071 - add a flag to xml if user has publish privilege on the current page (only useful for non-caching sites)
------------------------------------------------------------------------
r1652 | chrisg23 | 2007-09-18 12:35:42 +0200 (Di, 18 Sep 2007) 
Sourceforge patch 1793108 - allow specific content types to be hidden from some users when creating a new item


git-svn-id: https://svn.libreccm.org/ccm/trunk@23 8810af33-2d31-482b-a856-94f89814c4df
master
pb 2008-02-15 17:17:20 +00:00
parent b4846550c0
commit 07c7ffa13a
2 changed files with 33 additions and 0 deletions

View File

@ -106,6 +106,10 @@ public class SimpleXMLGenerator implements XMLGenerator {
if (PermissionService.checkPermission(edit)) { if (PermissionService.checkPermission(edit)) {
parent.addAttribute("canEdit", "true"); 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(); String className = item.getDefaultDomainClass();
// Ensure correct subtype of ContentItem is instantiated // Ensure correct subtype of ContentItem is instantiated

View File

@ -33,7 +33,14 @@ import com.arsdigita.bebop.parameters.BigDecimalParameter;
import com.arsdigita.cms.ContentSection; import com.arsdigita.cms.ContentSection;
import com.arsdigita.cms.ContentType; import com.arsdigita.cms.ContentType;
import com.arsdigita.cms.ContentTypeCollection; import com.arsdigita.cms.ContentTypeCollection;
import com.arsdigita.cms.SecurityManager;
import com.arsdigita.globalization.GlobalizedMessage; 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.util.UncheckedWrapperException;
import com.arsdigita.xml.Element; import com.arsdigita.xml.Element;
@ -104,7 +111,27 @@ public abstract class NewItemForm extends Form {
if(!c.isEmpty()) { if(!c.isEmpty()) {
// Add content types // Add content types
while(c.next()) { while(c.next()) {
boolean list = true;
ContentType type = c.getContentType(); 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 //for dp content type label localization
//String t = type.getAssociatedObjectType(); //String t = type.getAssociatedObjectType();
String cn = type.getClassName(); String cn = type.getClassName();
@ -118,6 +145,8 @@ public abstract class NewItemForm extends Form {
(type.getID().toString(), type.getLabel())); (type.getID().toString(), type.getLabel()));
} }
} }
}
c.reset(); c.reset();
} }
} }