Forums de discussion

How to disable "add event" in calendar portlet 6.2

Fmabo Mb, modifié il y a 8 années.

How to disable "add event" in calendar portlet 6.2

Junior Member Publications: 26 Date d'inscription: 10/06/15 Publications récentes
I just want the user administrator can add events, the other users can only view the events.
The problem here is that any user can add events and that's a problem for my site.
thumbnail
David H Nebinger, modifié il y a 8 années.

RE: How to disable "add event" in calendar portlet 6.2

Liferay Legend Publications: 14917 Date d'inscription: 02/09/06 Publications récentes
Use the "plugin extending a plugin" concept to extend calendar portlet and override JSP to only give admins access to the button.
Fmabo Mb, modifié il y a 8 années.

RE: How to disable "add event" in calendar portlet 6.2

Junior Member Publications: 26 Date d'inscription: 10/06/15 Publications récentes
I will do that. Thanks.
Fmabo Mb, modifié il y a 8 années.

RE: How to disable "add event" in calendar portlet 6.2

Junior Member Publications: 26 Date d'inscription: 10/06/15 Publications récentes
But, there any way to do it in the control panel?
thumbnail
David H Nebinger, modifié il y a 8 années.

RE: How to disable "add event" in calendar portlet 6.2

Liferay Legend Publications: 14917 Date d'inscription: 02/09/06 Publications récentes
No.
Fmabo Mb, modifié il y a 8 années.

RE: How to disable "add event" in calendar portlet 6.2

Junior Member Publications: 26 Date d'inscription: 10/06/15 Publications récentes
David, i've been trying to implement this https://www.liferay.com/es/community/wiki/-/wiki/Main/Plugin+to+extend+a+plugin, it says in the last line " you can find the WAR file in the /dist folder of your plugins SDK", but i can't find it!

I mean, if i want to extend the calendar plugin, where i get the war?
"Copy inside of the root folder of your new plugin the original WAR of the plugin you want to extend (for example, social-networking-portlet-6.1.10.1-ee-ga1.war)"
thumbnail
David H Nebinger, modifié il y a 8 années.

RE: How to disable "add event" in calendar portlet 6.2

Liferay Legend Publications: 14917 Date d'inscription: 02/09/06 Publications récentes
You can download the war from the marketplace. After "purchase" there is an option you can use to download the .lpkg file directly. Rename the extension to .zip and open it and you'll find the war file nestled inside.

The "find the war in dist" is where the built war will be if you use the "ant war" command, it's not where you find the war that you're going to patch.
Fmabo Mb, modifié il y a 8 années.

RE: How to disable "add event" in calendar portlet 6.2

Junior Member Publications: 26 Date d'inscription: 10/06/15 Publications récentes
Got it.

Now, following this guide https://www.liferay.com/es/community/wiki/-/wiki/Main/Plugin+to+extend+a+plugin, i did everything good, but when i run this code "ant war", the console says this : Target "war" does not exist in the project "Calendar-CMC-portlet".
I think i have to configure something, i was reading this article http://www.liferay.com/documentation/liferay-portal/6.1/development/-/ai/developing-an-ext-plug-4, but i do not know if it is correct, because the first link doesn't specify it.
juan meza, modifié il y a 8 années.

RE: How to disable "add event" in calendar portlet 6.2

Regular Member Publications: 228 Date d'inscription: 06/01/14 Publications récentes
Hi Fmabo, try using the same name as the portlet.. .i already did the same guide... this is what i did

created a portlet with the same name as calendar-portlet, deleted everything as the guide says... i copied all the jsps and jsfs into docroot, did the ant merge... i did not run the ant war ... i dont know if thats correct, but its working for me...

as for giving permissions to add event to admin only, its not that easy as to just block the add event button, because you can add events just clicking any day in the calendar... and the calendar portlet source code its very difficult... everything is made with aui tags... you bearly see any html or java code... im trying to do the same thing as you, but with no luck so far... pls update this thread if you manage to make it work... also you have to block or hide personal calendars, cuz there is no use if the user cant add events... thats the only thing ive managed to do so far! what a noob haha emoticon

@David do you have an idea of what to do to prevent regular user to add events? cuz i dont see it in the code!
thank you!
juan meza, modifié il y a 8 années.

RE: How to disable "add event" in calendar portlet 6.2

Regular Member Publications: 228 Date d'inscription: 06/01/14 Publications récentes
found it!

in scheduler.jsp, line 93, add role checking for admin, like this:
<c:if test="<%= !readOnly &amp;&amp; (userDefaultCalendar != null) &amp;&amp; permissionChecker.isOmniadmin() %>"></c:if>


and thats it! now only admin can add events...

hope it helps!
thumbnail
David H Nebinger, modifié il y a 8 années.

RE: How to disable "add event" in calendar portlet 6.2

Liferay Legend Publications: 14917 Date d'inscription: 02/09/06 Publications récentes
Omniadmin is not the same as the administrator role, but you're close...

Just get the current user roles and see if they have administrator role for the current site (current scope group id in the themedisplay object).
Fmabo Mb, modifié il y a 8 années.

RE: How to disable "add event" in calendar portlet 6.2

Junior Member Publications: 26 Date d'inscription: 10/06/15 Publications récentes
juan meza:
found it!

in scheduler.jsp, line 93, add role checking for admin, like this:
<c:if test="<%= !readOnly &amp;&amp; (userDefaultCalendar != null) &amp;&amp; permissionChecker.isOmniadmin() %>"></c:if>


and thats it! now only admin can add events...

hope it helps!


As you can see there is a problem on the above, because if a user want to see a event, he won't, the popup here is cancelled because of "permissionChecker.isOmniadmin()"
On the code there is a line like this in sheduler.jsp :
<c:if test="<%= !themeDisplay.isSignedIn() %>">
disabled: true,
</c:if>
Replace it with
<c:if test="<%= !permissionChecker.isOmniadmin() %>">
disabled: true,
</c:if>
And thats it
juan meza, modifié il y a 8 années.

RE: How to disable "add event" in calendar portlet 6.2

Regular Member Publications: 228 Date d'inscription: 06/01/14 Publications récentes
i did encounter that problem also!! thank you for sharing!

I solved it with permissions, i removed the omniadmin i suggested and hide the add event button, as you suggested also...
to view events only i went to roles - user role... and in the calendar section checked view options... and that was it.. the calendar portlet did the rest
thumbnail
Neha Goyal, modifié il y a 8 années.

RE: How to disable "add event" in calendar portlet 6.2

Regular Member Publications: 121 Date d'inscription: 14/05/13 Publications récentes
Fmabo Mb:
juan meza:
found it!

in scheduler.jsp, line 93, add role checking for admin, like this:
<c:if test="<%= !readOnly &amp;&amp; (userDefaultCalendar != null) &amp;&amp; permissionChecker.isOmniadmin() %>"></c:if>


and thats it! now only admin can add events...

hope it helps!


As you can see there is a problem on the above, because if a user want to see a event, he won't, the popup here is cancelled because of "permissionChecker.isOmniadmin()"
On the code there is a line like this in sheduler.jsp :
<c:if test="<%= !themeDisplay.isSignedIn() %>">
disabled: true,
</c:if>
Replace it with
<c:if test="<%= !permissionChecker.isOmniadmin() %>">
disabled: true,
</c:if>
And thats it


Thanks Fmabo Mb...this is what i was expecting..great job.
Fmabo Mb, modifié il y a 8 années.

RE: How to disable "add event" in calendar portlet 6.2

Junior Member Publications: 26 Date d'inscription: 10/06/15 Publications récentes
Thanks juan meza and David emoticon
I copied all the jsps and jsfs into docroot but some files have errors(i did the merge). emoticon
I will download the calendar code here https://github.com/liferay/liferay-plugins/tree/6.2.x

I hope it works. emoticon
Fmabo Mb, modifié il y a 8 années.

RE: How to disable "add event" in calendar portlet 6.2

Junior Member Publications: 26 Date d'inscription: 10/06/15 Publications récentes
Nothing.
When i copy all inside root, some files have error, any suggestion?

Did you configure build.xml inside liferay-plugins-skd?
Fmabo Mb, modifié il y a 8 années.

RE: How to disable "add event" in calendar portlet 6.2

Junior Member Publications: 26 Date d'inscription: 10/06/15 Publications récentes
Fixed it!!

Calendar porlet imported as Liferay Binary Plugin in eclipse.

Now, i will hide the add event when the user is not the admin.
Thanks juan meza and David.

Edit: put this where is the declarations variables in sheduler.jsp

...
boolean showAddEventBtn = ParamUtil.getBoolean(request, "showAddEventBtn");
String viewCalendarBookingURL = ParamUtil.getString(request, "viewCalendarBookingURL");

if(!permissionChecker.isOmniadmin()){
showAddEventBtn = false;
}
%>
...