Foros de discusión

6.2 Calendar Portlet Permissions

thumbnail
Brian Russell, modificado hace 9 años.

6.2 Calendar Portlet Permissions

Junior Member Mensajes: 41 Fecha de incorporación: 31/10/11 Mensajes recientes
I'm not sure if anybody else has run into this, and have been unable to find an issue or any information on it, so wanted to post here before I create a new issue. This came up while trying to add permissions to a custom role programmatically for the calendar portlet in 6.2.

The /docroot/WEB-INF/src/resources/default.xml has the following model-resource nodes:
	<model-resource>
		<model-name>com.liferay.calendar</model-name>
		<portlet-ref>
			<portlet-name>1</portlet-name>
		</portlet-ref>
		<permissions>
			<supports>
				<action-key>ADD_RESOURCE</action-key>
				<action-key>PERMISSIONS</action-key>
			</supports>
			<site-member-defaults>
				<action-key>ADD_RESOURCE</action-key>
			</site-member-defaults>
			<guest-defaults />
			<guest-unsupported>
				<action-key>ADD_RESOURCE</action-key>
				<action-key>PERMISSIONS</action-key>
			</guest-unsupported>
		</permissions>
	</model-resource>
.....
	<model-resource>
		<model-name>com.liferay.calendar.model.CalendarResource</model-name>
		<portlet-ref>
			<portlet-name>1</portlet-name>
		</portlet-ref>
		<permissions>
			<supports>
				<action-key>ADD_CALENDAR</action-key>
				<action-key>DELETE</action-key>
				<action-key>UPDATE</action-key>
				<action-key>VIEW</action-key>
			</supports>
			<site-member-defaults>
				<action-key>UPDATE</action-key>
				<action-key>VIEW</action-key>
			</site-member-defaults>
			<guest-defaults>
				<action-key>VIEW</action-key>
			</guest-defaults>
			<guest-unsupported>
				<action-key>ADD_CALENDAR</action-key>
				<action-key>DELETE</action-key>
				<action-key>UPDATE</action-key>
			</guest-unsupported>
		</permissions>
	</model-resource>


Now, should the ADD_CALENDAR action-key be under the com.liferay.calendar model name and not com.liferay.calendar.model.CalendarResource? That would seem to be the normal resource-action set up for a modeled object, no? ADD_CALENDAR makes no sense under com.liferay.calendar.model.CalendarResource.

Though I do see in com.liferay.calendar.service.impl.CalendarServiceImpl.addCalendar:
public class CalendarServiceImpl extends CalendarServiceBaseImpl {

	@Override
	public Calendar addCalendar(
			long groupId, long calendarResourceId, Map<locale, string> nameMap,
			Map<locale, string> descriptionMap, int color,
			boolean defaultCalendar, boolean enableComments,
			boolean enableRatings, ServiceContext serviceContext)
		throws PortalException, SystemException {

		CalendarResourcePermission.check(
			getPermissionChecker(), calendarResourceId,
			ActionKeys.ADD_CALENDAR);

		return calendarLocalService.addCalendar(
			getUserId(), groupId, calendarResourceId, nameMap, descriptionMap,
			color, defaultCalendar, enableComments, enableRatings,
			serviceContext);
	}</locale,></locale,>

That it uses CalendarResourcePermission to check the ADD_CALENDAR permission, so maybe it's being used correctly. Just seems like the wrong configuration to me.
On the same token, in /docroot/view_calendars.jsp:
<c:if test="<%= CalendarResourcePermission.contains(permissionChecker, calendarResource, ActionKeys.ADD_CALENDAR) %>">
	<aui:button-row>
		<liferay-portlet:renderurl var="editCalendarURL">
			<liferay-portlet:param name="mvcPath" value="/edit_calendar.jsp" />
			<liferay-portlet:param name="redirect" value="<%= currentURL %>" />
			<liferay-portlet:param name="backURL" value="<%= currentURL %>" />
			<liferay-portlet:param name="calendarResourceId" value="<%= String.valueOf(calendarResource.getCalendarResourceId()) %>" />
		</liferay-portlet:renderurl>

		<aui:button onClick="<%= editCalendarURL %>" value="add-calendar" />
	</aui:button-row>
</c:if>

With a similar usage in /docroot/view_calendar.jsp.

So I suppose if it's being used correctly, then it doesn't matter. Or am I wrong? Has anyone run into this?
thumbnail
Brian Russell, modificado hace 9 años.

RE: 6.2 Calendar Portlet Permissions

Junior Member Mensajes: 41 Fecha de incorporación: 31/10/11 Mensajes recientes
It may have something to do with a Calendar also being a CalendarResource, or a better way to say it, a CalendarResource always has a Calendar associated with it. So it is really the CalendarResource that is the "master", therefore you are really just adding a new resource (which has a calendar) when you add a new calendar.