<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><%-- #RevizeProperties USE REVIZE MENU (DOCUMENT PROPERTIES) TO EDIT DATA BELOW:
status=edit
options=
server=localhost:8080
projectName=calendar_app
label=
location=calendar_app/editpages/calendar_list.jsp
version=
docType=editpage
subType=list
moduleName=
fieldName=
channels=|
description=
--%><%-- #BeginRZ-PageHeader --%><%@
page language="java" %><%@
include file="/util/setup_editlist_header.jsp"
%><%-- #EndRZ-PageHeader --%>
<head>
<title>Calendar Administration for a Group</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><%--
___________________________________________________________________________________

This Edit Page deviates from standard Revize editform as follows:
___________________________________________________________________________________
--%><%@ include file="/util/setup_editlist_javascript.jsp" 
%><%@ include file="/plugins/calendar/calendar.version_include.jsp" %><%

//----- Page specific JSP code
String groupid = StringUtils.getParameter(request,"groupid");

%><%--
//-------------------------------------------------------------------------------\\
Following script, link and style tags just for DW reference, They are NOT published.
Javascript functions run from homepage; CSS cloned from the homepage during setup().
--%><% 
if (false) { %>
<script type="text/javascript" src="../js/calendar_app_loading.js"></script>
<script type="text/javascript" src="../js/calendar_app_view_common.js"></script>
<script type="text/javascript" src="../js/calendar_app_view_full.js"></script>
<link type="text/css" href="../css/calendar_loading.css" rel="stylesheet"/>
<link type="text/css" href="../css/calendar_style.css" rel="stylesheet"/><%
//-------------------------------------------------------------------------------//
} 
%><script type="text/javascript"><%--
___________________________________________________________________________________

Page specific JavaScript
___________________________________________________________________________________

--%>
onedit = function()
{
	debugger;
	return {windowName: RZ.calendar.winNames.eventDetailEditForm};
}
//----- Setup ondelete handler called when delete button clicked and confirmed. 
//		Sets flag to run above code after delete completes and reloads this page.
ondelete = function()
{
	RZ.calendar.isDataLoaded = false;
	RZ.calendar.openaction = RZ.calendar.constants.deleteEvent + eventId;
	RZ.calendar.mappingLog.push(RZ.calendar.constants.deleteEvent + eventId);
	closeWindow(false);
}
/*--------------------------------------------------------------------------------
Code to set the permission module depending on the logged-in user
---------------------------------------------------------------------------------*/
if (RZwinaccess(opener)
&& opener.topframe.mainFrame.RZisValidCalendarAdministrator() )
	RZ.permits.modules.calendar_names='crud';
else
	RZ.permits.modules.calendar_names='r';
/*-------------------------------------------------------------------------------
Called by onload handler; if delete occured, delete child calendar entries.
--------------------------------------------------------------------------------*/
function setup()
{
	var action = topframe.RZ.calendar.openaction;
	if (action.indexOf(RZ.calendar.constants.deleteCalendar) != -1)
	{
		topframe.RZ.calendar.openaction = '';
		var calId = action.substring(RZ.calendar.constants.deleteCalendar.length);

		//Build url call to calendar_calendar_delete.jsp for events deletion
		RZ.parameters = RZ.page.pathname + "/calendar_calendar_delete.jsp";
		RZaddUrlParameter('calendarid=' + calId);
		RZaddUrlParameter('fromurl=' + escape(location.href));
		if (topframe.RZ.debug) RZaddUrlParameter('debug');

		location.href = RZ.parameters;
		return;
	}
	RZsetuphandler("ondelete", "onDelete()" )
	RZloadingDone();	//needed if RZloadResources() called with callback function
}
/*-------------------------------------------------------------------------------
onDelete handler is called when delete button clicked and confirmed.
Sets flag to delete calendars after delete completed.
--------------------------------------------------------------------------------*/
function onDelete()
{
	if (RZwinaccess(opener))
	{
		topframe.RZ.calendar.openaction = RZ.calendar.constants.deleteCalendar + RZ.recordid;
		return true;
	}

	RZnote('Delete Request not processed because calendar window not accessible')
	return false;
}
/*-----------------------------------------------------------------------------------------------
//method to display rollup settings
-----------------------------------------------------------------------------------------------*/
function listRollupTo(cal_name)
{
	if (!RZwinaccess(opener)) return '';

	// var toReturn = '<table><tr><td wrap><u>Events of this calendar<br/> can display in</u></td></tr>';
	var toReturn='';

	var obj = homeframe.calendar_heading.calendarName;	//header drop down object
	text =  new Array();

	for (var io = 0; io < obj.options.length; io++)
	{
		if(obj.options.item(io).text.indexOf("--") == 0)
			text[io] = obj.options.item(io).text.substring(2);
		else
			text[io] = obj.options.item(io).text;
	}

	 for (var i = 0; i < obj.options.length; i++)
	 {
		if(cal_name == text[i])
		{
			var calendar_id = obj.options.item(i).value;
			var show_all = obj.options.item(i).showall;
			var show_in_all = obj.options.item(i).show_in_all;

			var rollup_list = [];
			if (obj.options.item(i).rolluplist)
				rollup_list = obj.options.item(i).rolluplist.split("|");

			var restricted_list = [];
			if (obj.options.item(i).restrictedlist)
				restricted_list = obj.options.item(i).restrictedlist.split("|");

			if(show_in_all == "yes")
			{
				for (var j = 0; j < obj.options.length; j++)
				{
					if(obj.options.item(j).restrictedlist.indexOf(calendar_id) != -1 )
						toReturn += '<font color="red">' + text[j] + '</font></br>';
					else if(cal_name != text[j])
						toReturn += text[j] + '</br>';
				}
			}
			else
			{
				for(var r=0; r<rollup_list.length; r++)
				{
					for (var k = 0; k < obj.options.length; k++)
					{
						if(obj.options.item(k).value == rollup_list[r])
						{
							if(obj.options.item(k).restrictedlist.indexOf(calendar_id) != -1)
								toReturn += '<font color="red">' + text[k] + '</font></br>';
							else if(cal_name != text[k])
								toReturn += text[k] + '</br>';
						}
					}
				}
			}
		}
	}
	if (toReturn == '') toReturn = '&nbsp;'
	return toReturn;
}
/*-----------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------*/
function listRollupFrom(cal_name)
{
	if (!RZwinaccess(opener)) return '';

	//var toReturn = '<table><tr><td nowrap><u>Calendars whose events<br/> can appear in this<br/> calendar</u></td></tr>';
	//var toReturn='<table><tr><td wrap>';
	var toReturn='';
	var obj = homeframe.calendar_heading.calendarName;
	text = new Array();

	for (var iss = 0; iss < obj.options.length; iss++)
	{
		if(obj.options.item(iss).text.indexOf("--") == 0)
			text[iss] = obj.options.item(iss).text.substring(2);
		else
			text[iss] = obj.options.item(iss).text;
	}

	var masterCalendar_name = topframe.RZ.calendar.default_name;
	if(cal_name == masterCalendar_name)
	{
		for (var mas = 0; mas < obj.options.length; mas++)
			toReturn += '' + text[mas] + '<br>';
			//toReturn += '<tr><td>' + text[mas] + '</td></tr>';
	}
	else
	{
		for (var is = 0; is < obj.options.length; is++)
		{
			if(cal_name == text[is])
			{
				var calendar_id = obj.options.item(is).value;
				var show_all = obj.options.item(is).showall;
				var show_in_all = obj.options.item(is).show_in_all;

				var rollup_list = [];
				if (obj.options.item(is).rolluplist)
					rollup_list = obj.options.item(is).rolluplist.split("|");
	
				var restricted_list = [];
				if (obj.options.item(is).restrictedlist)
					restricted_list = obj.options.item(is).restrictedlist.split("|");

				if(show_all == "yes")
				{
					for (var js = 0; js < obj.options.length; js++)
					{
						if(obj.options.item(js).rolluplist.indexOf(calendar_id) != -1
						|| obj.options.item(js).show_in_all !="yes")
						{
							if(cal_name != text[js])
								toReturn += '' + text[js] + '<br>';
						}
						else if(cal_name != text[js])
							toReturn += '<font color="red">' + text[js] + '</font><br>';
					}
				}
				else
				{
					for (var ks = 0; ks< obj.options.length; ks++)
					{
						var restrict = "true";

						for(var rs=0; rs<restricted_list.length; rs++)
						{
							if(obj.options.item(ks).value == restricted_list[rs])
								restrict = "false";
						}
						if(restrict == "false")
						{
							if(obj.options.item(ks).rolluplist.indexOf(calendar_id) != -1
							|| obj.options.item(js).show_in_all !="yes")
							{
								if(cal_name != text[ks])
									toReturn += '' + text[ks] + '<br>';
							}
							else if(cal_name != text[ks])
								toReturn += '<font color="red">' + text[ks] + '</font><br>';
						}
					}
				}
			}
		}
	}
	//toReturn += '</table>';
	if (toReturn == '') toReturn = '&nbsp;'
	return toReturn;
}
/*-----------------------------------------------------------------------------------------------
END OF JAVASCRIPT FUNCTIONS
-----------------------------------------------------------------------------------------------*/
</script>
<%-- @@no-source-format@@
/***************************************************/
/**/ .RZhidden class hides elements in browser   /**/
/**/ ...BUT allows DW to show in design view...  /**/
/**/ /* Following css does not get published */  /**/
/**/ --%><% if (false){                          /**/
/**/ %><style type=text/css>                     /**/
/**/ /* DW uses these in design view */          /**/
/**/ .RZhidden, .RZhidden * {                    /**/ 
/**/     display:block !IMPORTANT;               /**/
/**/     background-color:#D5D5D5 !IMPORTANT;    /**/
/**/ }                                           /**/ 
/**/ span.RZhidden, .RZhidden span {             /**/
/**/	display:inline !IMPORTANT;               /**/
/**/ }                                           /**/
/**/ </style><% }                                /**/
/**/ /* Following IS published for Browsers */   /**/
/**/ %><style type=text/css>                     /**/
/**/ .RZhidden {display:none;}                   /**/
/**/ </style><%--                                /**/
/***************************************************/
@@no-source-format@@ --%>
<style type="text/css">		/* page specific css */
select {
 width='1.6 in';
 background-color='#FFFFE0';
}
</style>
</head>
<body class="adminPage" onLoad="RZloadResources(setup);">
<%if(false){%><div style="position:absolute; width:475px; right: 0px; bottom: 0px;" class="RZhidden">
NOTE: blocks with class=RZhidden show with this background in DW only; they are
hidden when page displays in browser unless changed by javascript or other CSS.
</div><%}%>
<%@ include file="/plugins/calendar/calendar.loading_layer_include.jsp" %>
<div class="loadingHide">
<table align="CENTER" border="0">
  <tr>
    <td align="CENTER">
      <h3><font face="helvetica,arial" color="#616055"><strong>
	  <a href="javascript:topframe.setDebug(window)"><font color="#FFFFFF">&nbsp;&nbsp;&nbsp;</font></a> List of Calendars for Group: <rz:fetch module="calendar_groups" field="group_name" output="html"
		options="size=30,wrap=Virtual"/> <a href="javascript:topframe.RZstartDebugger()"><font color="#FFFFFF">&nbsp;&nbsp;&nbsp;</font></a>
      <script>
		if (topframe.RZ.debug) document.write('<br /><font color="red">Debug Mode</font>')
	  </script>
	  </strong></font></h3>
	</td>
  </tr>
  <tr>
    <td align="CENTER" height="40">
      <%-- #BeginRZ-ActionImage --%>
      <%-- Option:type=EditListInsertImage --%>
      <%-- Option:imageSrcURL=../images/buttons/new.gif --%>
      <script>
      RZ.module = 'calendar_names'; RZ.linkname = '';
      RZ.recordid = 'new';
      RZ.nexturl = 'calendar_list-editform.jsp';
      RZ.popupwidth = ''; RZ.popupheight = ''; RZ.popupscroll = '';
      RZ.img = '<rz:link file="/calendar_app/images/buttons/new.gif" alt="New Item" border="0" />';
      RZ.set = 'calendar_names.groupid=<%=rz.editrecordid%>';
      RZ.options = '';
      if (typeof RZaction != 'undefined') RZaction('newitem');
      </script>
      <%-- #EndRZ-ActionImage --%>
      <%-- #BeginRZ-ActionImage --%>
      <%-- Option:type=EditListExitImage --%>
      <%-- Option:forwardURL= --%>
      <%-- Option:imageSrcURL=../images/buttons/cancel.gif --%>
      <script>
      RZ.nexturl = 'calendar_groups.jsp';
      RZ.img = '<rz:link file="/calendar_app/images/buttons/cancel.gif" alt="Exit Screen" border="0" />';
      RZ.options = '';
      if (typeof RZaction != 'undefined') RZaction('exit');
      </script>
      <%-- #EndRZ-ActionImage --%>
    </td>
  </tr>
</table>
<table border="1" align="CENTER" cellpadding="3" cellspacing="0">
  <tr bgcolor="#FFFFFF" align="LEFT">
    <th valign="top" class="bordermiddle"><strong><font color="#000000" size="2" face="Arial, Helvetica, sans-serif">Action</font></strong></th>
    <th valign="top" class="bordermiddle"><strong><font color="#000000" size="2" face="Arial, Helvetica, sans-serif">Calendar Name<br>
      click to view events </font></strong></th>
    <th valign="top" class="bordermiddle"><strong><font color="#000000" size="2" face="Arial, Helvetica, sans-serif">Calendar<br>
      Administrators</font></strong></th>
    <th valign="top" class="bordermiddle"><p><strong><font color="#000000" size="2" face="Arial, Helvetica, sans-serif">Calendar<br>
    </font></strong><strong><font color="#000000" size="2" face="Arial, Helvetica, sans-serif">Editors</font></strong></p></th>
    <th valign="top" nowrap class="bordermiddle"><strong><font color="#000000" size="2" face="Arial, Helvetica, sans-serif">Other Calendars <br>
      that can place events<br>
      in this calendar</font></strong></th>
    <th valign="top" nowrap class="bordermiddle"><strong><font color="#000000" size="2" face="Arial, Helvetica, sans-serif">Other</font><font color="#000000" size="2" face="Arial, Helvetica, sans-serif"> Calendars<br>
      that can show this<br>
      Calendar's Events</font></strong></th>
  </tr>
  <rz:list module="calendar_names" sort="calendar_name asc" output="none"
   options="" filter="<%="calendar_names.groupid="+groupid%>"><% 
   while ( rz.listnext() )
   {
		if (rz.listindex < 0) break; //no active records (e.g. no information available)
		%><rz:listbody>
  <tr>
    <td colspan="6" valign="top" nowrap class="bordermiddlez"></td>
  </tr>
  <tr>
    <td valign="top" nowrap class="bordermiddle">
      <%-- #BeginRZ-ActionImage --%>
      <%-- Option:type=EditListEditImage --%>
      <%-- Option:imageSrcURL=../images/buttons/edit_sm.gif --%>
      <!--Revize-- Edit Item -->
      <script>
		RZ.module = '<%=rz.listmodule%>'; RZ.linkname = '';
		RZ.recordid = '<%=rz.listitemid()%>';
		RZ.nexturl = 'calendar_list-editform.jsp';
		RZ.popupwidth = ''; RZ.popupheight = ''; RZ.popupscroll = '';
		RZ.img = '<rz:link file="/calendar_app/images/buttons/edit_sm.gif" alt="Edit Item" border="0"/>';
		RZ.set = '';
		RZ.options = '';
		if (RZwinaccess(opener))
		{
			if (opener.topframe.mainFrame.RZisAdministrator()
			|| RZ.recordid == topframe.RZ.calendar.id)
				RZaction('edititem');
		}
	  </script>
      <%-- #EndRZ-ActionImage --%>
      <%-- #BeginRZ-ActionImage --%>
      <%-- Option:type=EditListDeleteImage --%>
      <%-- Option:forwardURL= --%>
      <%-- Option:imageSrcURL=../images/buttons/delete_sm.gif --%>
      <script>
		RZ.module = '<%=rz.listmodule%>';
		RZ.recordid = '<%=rz.listitemid()%>';
		RZ.name = 'RZdelete' + RZ.recordid;
		RZ.img = '<rz:link file="/calendar_app/images/buttons/delete_sm.gif" alt="Edit Item" border="0"/>';
		RZ.options = '';
		if (RZwinaccess(opener))
		{
			if (opener.topframe.mainFrame.RZisAdministrator()
			|| RZ.recordid == topframe.RZ.calendar.id)
				RZaction('delete');
		}
		</script>
      <%-- #EndRZ-ActionImage --%>
    </td>
    <td align="left" valign="TOP" nowrap class="bordermiddle"> <font size="2" face="Arial, Helvetica, sans-serif"> 
		<rz:fetch module="calendar_names" field="calendar_name" output="none" options="" /><a
         href="calendar_display_events.jsp?groupid=<%=groupid%>&calendarid=<%=rz.recordid%>"><%=rz.content%></a><%
			String calname = rz.content;
			calname = calname.replaceAll("%20"," ");
			calname = calname.replaceAll("&sqout","'");
			calname = StringUtils.convertStringForSource(calname);
		%>
        </font></td>
    <td align="left" valign="TOP" class="bordermiddle"> <font size="2" face="Arial, Helvetica, sans-serif"> <% out.println(addRoleUserOptions( rz.fetch("calendar_names", "administrators"),"admins" )); %> &nbsp;</font></td>
    <td align="left" valign="TOP" class="bordermiddle"> <font size="2" face="Arial, Helvetica, sans-serif"> <% out.println(addRoleUserOptions( rz.fetch("calendar_names", "editors"),"editors" )); %> &nbsp;</font></td>
    <td align="LEFT" valign="TOP" class="bordermiddle"> <font size="2" face="Arial, Helvetica, sans-serif">
      <script>document.write(listRollupTo(<%=calname%>));</script>
    </font></td>
    <td align="LEFT" valign="TOP" class="bordermiddle"><font size="2" face="Arial, Helvetica, sans-serif">
      <script>document.write(listRollupFrom(<%=calname%>));</script>
    </font></td>
  </tr>
  </rz:listbody><%
  }%></rz:list>
  <tr>
    <td colspan="6" align="center" class="bordermiddle"> </td>
  </tr>
</table>
</div>
</body>
</html>
<%!
	String addRoleUserOptions( String inList, String flag )
	{
		//String toReturn = "<table border=\"0\">";
		String toReturn = "";
		int lenList = inList.length();
		if ( (0 < lenList) && ( !("|".equals(inList)) ) ) {
			String item = "";
			int indexPipe = -1;
			int i = 0;
			while (true) {
				indexPipe = inList.indexOf('|', i);
				if ( 0 < indexPipe ) {
					item = inList.substring(i, indexPipe);
					if( item.startsWith( "_" ) ) {
						toReturn += "" + item.substring(1)+ "<br>";
					} else {
						toReturn += "" + item + "<br>";
					}
					i = indexPipe + 1;
				} else if ( i < lenList ) {
					item = inList.substring(i, lenList);
					if( item.startsWith( "_" ) ) {
						toReturn += "" + item.substring(1) + "<br>";
					} else {
						toReturn += "" + item + "<br>";
					}
					break;
				}
			}
		}
		//toReturn += "</table>";
		return toReturn;
	}
%>