I have modified the code in the select_calendar.html to filter for calendars the user has VIEW and ADD_EVENT permissions. This mod works great if the filter returns two or more calendars. If only one calendar is returned and I try to continue I get a error box stating
! Select a calendar before continuing
The code I modified was:
********************************
<% foreach $cal (sort {$a->{name} cmp $b->{name}} @$calendars) { %>
<%
# only show calendars user has permissions to view
next unless ($User->hasPermission($cal->{'key'},"VIEW")) && ($User->hasPermission($cal->{'key'},"ADD_EVENT"));
%>
<% if ($user->isCalendarAdmin($cal->{'key'})) { %>
*********************************
I think the error is coming from the code below:
*********************************
function dosubmit() {
var theform = document.forms["mainform"];
<% if ($count>1) { %>
if (getInputValue(theform["calendar"]) == "") {
alert("Select a calendar before continuing");
return false;
}
<% } %>
theform.submit();
}
********************************
I have tried chanding the ($count>1) value to 0 or 2 but not success. I am not sure if I am even changing the right thing.
Any ideas!
Thanks