Foros de discusión

Controlling the display of events in Calendar Events Tab

thumbnail
Thomas Rando, modificado hace 13 años.

Controlling the display of events in Calendar Events Tab

New Member Mensaje: 1 Fecha de incorporación: 30/07/10 Mensajes recientes
Hello, I am new to Liferay 5.2.4. I would like to control the list of events a user sees on the events page of the calendar. If a user does not have permission to 'view' the event, I do not want the user to see the event line.

Is there any way to keep events line (Date, Time, Title, Type) from being listed on the calendar event page, if the user does not have permissions to view the event?

Thanks
Tom
thumbnail
Zeeshan Khan, modificado hace 12 años.

RE: Controlling the display of events in Calendar Events Tab

Expert Mensajes: 349 Fecha de incorporación: 21/07/11 Mensajes recientes
Thomas Rando:
Hello, I am new to Liferay 5.2.4. I would like to control the list of events a user sees on the events page of the calendar. If a user does not have permission to 'view' the event, I do not want the user to see the event line.

Is there any way to keep events line (Date, Time, Title, Type) from being listed on the calendar event page, if the user does not have permissions to view the event?

Thanks
Tom



Hi Thomas !!

Even i am facing the same. Did u get any clue to get through this...??

Thanks !!!
Venkat Koppavolu, modificado hace 12 años.

RE: Controlling the display of events in Calendar Events Tab

Junior Member Mensajes: 85 Fecha de incorporación: 26/07/10 Mensajes recientes
As I guess there is no default functionality in life ray and it can be achieved with simple customization through hooks.

1. Create jsp hook for to override event_iterator.jspf
2. Add below lines of code in event search results iterating
for (int i = 0; i < results.size(); i++) {

CalEvent event = (CalEvent)results.get(i);

boolean viewEventPermission = CalEventPermission.contains(permissionChecker, event, ActionKeys.VIEW);

if(viewEventPermission){
// Liferay code as it is
}
3. deploy the hook.

Note: Permission checking condition is placed in event_action.jsp level at line 50 ( we are using same code)

Hope this will give you some direction to get it work for your problem.
thumbnail
Zeeshan Khan, modificado hace 12 años.

RE: Controlling the display of events in Calendar Events Tab

Expert Mensajes: 349 Fecha de incorporación: 21/07/11 Mensajes recientes
Venkat Koppavolu:
As I guess there is no default functionality in life ray and it can be achieved with simple customization through hooks.

1. Create jsp hook for to override event_iterator.jspf
2. Add below lines of code in event search results iterating
for (int i = 0; i < results.size(); i++) {

CalEvent event = (CalEvent)results.get(i);

boolean viewEventPermission = CalEventPermission.contains(permissionChecker, event, ActionKeys.VIEW);

if(viewEventPermission){
// Liferay code as it is
}
3. deploy the hook.

Note: Permission checking condition is placed in event_action.jsp level at line 50 ( we are using same code)

Hope this will give you some direction to get it work for your problem.




Hi Venkat !!
i have tried with the JSP hook but no luck...please find my event_iterator.jspf and have a look at this file whether it is correct or not....



<%
/**
* Copyright (c) 2000-2011 Liferay, Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 2.1 of the License, or (at your option)
* any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*/
%>

<%
List<String> headerNames = new ArrayList<String>();

headerNames.add("time");
headerNames.add("title");
headerNames.add("type");
headerNames.add(StringPool.BLANK);

SearchContainer searchContainer = new SearchContainer(renderRequest, null, null, SearchContainer.DEFAULT_CUR_PARAM, SearchContainer.DEFAULT_DELTA, portletURL, headerNames, "there-are-no-events-on-this-day");

List results = CalEventLocalServiceUtil.getEvents(scopeGroupId, selCal, eventType);

results = ListUtil.sort(results, new EventTimeComparator(timeZone, locale));

searchContainer.setTotal(results.size());

results = ListUtil.subList(results, searchContainer.getStart(), searchContainer.getEnd());

searchContainer.setResults(results);

List resultRows = searchContainer.getResultRows();

for (int i = 0; i < results.size(); i++) {
CalEvent event = (CalEvent)results.get(i);


boolean viewEventPermission = CalEventPermission.contains(permissionChecker, event, ActionKeys.VIEW);

if(viewEventPermission){

event = event.toEscapedModel();

ResultRow row = new ResultRow(event, event.getEventId(), i);

PortletURL rowURL = renderResponse.createRenderURL();

rowURL.setParameter("struts_action", "/calendar/view_event");
rowURL.setParameter("redirect", currentURL);
rowURL.setParameter("eventId", String.valueOf(event.getEventId()));

// Time

boolean allDay = CalUtil.isAllDay(event, timeZone, locale);

if (allDay) {
row.addText(LanguageUtil.get(pageContext, "all-day"), rowURL);
}
else {
if (event.isTimeZoneSensitive()) {
row.addText(dateFormatTime.format(Time.getDate(event.getStartDate(), timeZone)) + " &#150; " + dateFormatTime.format(Time.getDate(CalUtil.getEndTime(event), timeZone)), rowURL);
}
else {
row.addText(dateFormatTime.format(event.getStartDate()) + " &#150; " + dateFormatTime.format(CalUtil.getEndTime(event)), rowURL);
}
}

// Title and type

row.addText(event.getTitle(), rowURL);
row.addText(LanguageUtil.get(pageContext, HtmlUtil.unescape(event.getType())), rowURL);

// Action

row.addJSP("right", SearchEntry.DEFAULT_VALIGN, "/html/portlet/calendar/event_action.jsp");

// Add result row

resultRows.add(row);
}

}
%>

<%
boolean showAddEventButtonButton = CalendarPermission.contains(permissionChecker, scopeGroupId, ActionKeys.ADD_EVENT);
boolean showPermissionsButton = GroupPermissionUtil.contains(permissionChecker, scopeGroupId, ActionKeys.PERMISSIONS);
%>

<c:if test="<%= showAddEventButtonButton || showPermissionsButton %>">
<c:if test="<%= showAddEventButtonButton %>">
<portlet:renderURL var="editEventURL">
<portlet:param name="struts_action" value="/calendar/edit_event" />
<portlet:param name="redirect" value="<%= currentURL %>" />
<portlet:param name="month" value="<%= String.valueOf(selMonth) %>" />
<portlet:param name="day" value="<%= String.valueOf(selDay) %>" />
<portlet:param name="year" value="<%= String.valueOf(selYear) %>" />
</portlet:renderURL>

<aui:button onClick="<%= editEventURL %>" value="add-event" />
</c:if>

<c:if test="<%= showPermissionsButton %>">
<liferay-security:permissionsURL
modelResource="com.liferay.portlet.calendar"
modelResourceDescription="<%= HtmlUtil.escape(themeDisplay.getScopeGroupName()) %>"
resourcePrimKey="<%= String.valueOf(scopeGroupId) %>"
var="permissionsURL"
/>

<aui:button onClick="<%= permissionsURL %>" value="permissions" />
</c:if>

<br /><br />
</c:if>

<liferay-ui:search-iterator searchContainer="<%= searchContainer %>" />
Venkat Koppavolu, modificado hace 12 años.

RE: Controlling the display of events in Calendar Events Tab

Junior Member Mensajes: 85 Fecha de incorporación: 26/07/10 Mensajes recientes
I have tested the code which you posted, it working as i expected.
I added one System.out.println to check wht is happening at line no: 44
System.out.println("event Id:" + event.getEventId() + " has view permission::" + viewEventPermission);

Is your hook deployed correctly?
Check your <TOMCAT_HOME>webapps\ROOT\html\portlet\calendar\event_iterator.jspf for modified code ( event_iterator.portal.jspf is original portal file)

Here is the procedure I did
1. Create a page called Calender Permissions
1. Render Calendar portlet
2. Add event called TEST
3. Remove Guest permission to created event by using permission menu link
4. Sign out from portal
5. Access particular page where you render calendar port let
6. Logged as admin and Add another event called "VISIBLE"
7. Since it's public page and default GUEST has view permission on this event
8. Signed out from system and access the calender permission page ( You will see one event, if you login u will get 2 events)
Please refer the attached document for your reference.

Is this what we are trying to achieve? Hope this will help you.
thumbnail
Zeeshan Khan, modificado hace 12 años.

RE: Controlling the display of events in Calendar Events Tab

Expert Mensajes: 349 Fecha de incorporación: 21/07/11 Mensajes recientes
Venkat Koppavolu:
I have tested the code which you posted, it working as i expected.
I added one System.out.println to check wht is happening at line no: 44
System.out.println("event Id:" + event.getEventId() + " has view permission::" + viewEventPermission);

Is your hook deployed correctly?
Check your <TOMCAT_HOME>webapps\ROOT\html\portlet\calendar\event_iterator.jspf for modified code ( event_iterator.portal.jspf is original portal file)

Here is the procedure I did
1. Create a page called Calender Permissions
1. Render Calendar portlet
2. Add event called TEST
3. Remove Guest permission to created event by using permission menu link
4. Sign out from portal
5. Access particular page where you render calendar port let
6. Logged as admin and Add another event called "VISIBLE"
7. Since it's public page and default GUEST has view permission on this event
8. Signed out from system and access the calender permission page ( You will see one event, if you login u will get 2 events)
Please refer the attached document for your reference.

Is this what we are trying to achieve? Hope this will help you.




yeah exactly i am trying to achieve this.....i checked my tomcat folder and a file event_iterator.portal and init.portal has been created automatically....first i tried to create the Hook under the existing project, doesnt work....then created the hook externally, i mean created another liferay project then created Hook and applied the logic u mentioned.....after this nothing is coming under the page where i had put the Calendar portlet......this all i have been doing fro almost 5 hours now......still no luck.....emoticon emoticon

thanks Venkat !!