Moved web script classes and definitions out of web-client project and into remote-api

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@8956 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Roy Wetherall
2008-04-29 19:41:59 +00:00
parent 8d0db44bc6
commit d12effa6d6
201 changed files with 14060 additions and 11 deletions

View File

@@ -1,11 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="source/java"/>
<classpathentry kind="src" path="source/generated"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry combineaccessrules="false" kind="src" path="/Repository"/>
<classpathentry combineaccessrules="false" kind="src" path="/3rd Party"/>
<classpathentry combineaccessrules="false" kind="src" path="/Core"/>
<classpathentry combineaccessrules="false" kind="src" path="/Alfresco JLAN"/>
<classpathentry kind="output" path="build/classes"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="source/java"/>
<classpathentry kind="src" path="source/generated"/>
<classpathentry kind="src" path="config"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry combineaccessrules="false" kind="src" path="/Repository"/>
<classpathentry combineaccessrules="false" kind="src" path="/3rd Party"/>
<classpathentry combineaccessrules="false" kind="src" path="/Core"/>
<classpathentry combineaccessrules="false" kind="src" path="/Alfresco JLAN"/>
<classpathentry combineaccessrules="false" kind="src" path="/WebScript Framework"/>
<classpathentry kind="output" path="build/classes"/>
</classpath>

View File

@@ -0,0 +1,8 @@
<webscript>
<shortname>Apply AVM Custom View</shortname>
<description>Simple UI to help apply a WebScript based custom view to an AVM folder</description>
<url>/avm/applyavmcustomview</url>
<format default="html">extension</format>
<authentication>user</authentication>
<transaction>required</transaction>
</webscript>

View File

@@ -0,0 +1,52 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Apply AVM WebScript Custom View</title>
<style>
body {
font-family: Verdana, Helvetica, sans-serif;
font-size: 10pt;
}
.label {
float: left;
width: 10em;
}
.data {
float: left;
}
.field {
clear: left;
float: left;
padding: 8px;
}
</style>
</head>
<body>
<form action="${url.serviceContext}${url.match}" method="post">
<div class="field">
<span class="label">Store:</span>
<span class="data"><input type="text" name="store" size="32" /><br />e.g. website1--admin</span>
</div>
<div class="field">
<span class="label">Folder Path:</span>
<span class="data"><input type="text" name="path" size="64" /><br />e.g. /ROOT/images</span>
</div>
<div class="field">
<span class="label">WebScript URL:</span>
<span class="data"><input type="text" name="view" size="64" value="" /><br />e.g. /utils/avmview<br>A well known token {path} can be used in the url and will be replaced by the current AVM folder path at runtime.</span>
</div>
<div class="field">
<span><input type="submit" value="Apply" /></span>
</div>
</form>
</body>
</html>

View File

@@ -0,0 +1,8 @@
<webscript>
<shortname>Apply AVM Custom View POST</shortname>
<description>Simple UI to help apply a WebScript based custom view to an AVM folder</description>
<url>/avm/applyavmcustomview</url>
<format default="html">extension</format>
<authentication>user</authentication>
<transaction>required</transaction>
</webscript>

View File

@@ -0,0 +1,19 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Apply AVM WebScript Custom View - Done</title>
<style>
body {
font-family: Verdana, Helvetica, sans-serif;
font-size: 10pt;
}
</style>
</head>
<body>
<#if success>
Operation Complete.
<#else>
Operation FAILED. Unable to find store or node.
</#if>
</body>
</html>

View File

@@ -0,0 +1,27 @@
// check that search term has been provided
if (args.store == undefined || args.store.length == 0 ||
args.path == undefined || args.path.length == 0 ||
args.view == undefined || args.view.length == 0)
{
status.code = 400;
status.message = "Mandatory arguments not set - please complete all form fields.";
status.redirect = true;
}
else
{
// lookup the root on the store
var storeRootNode = avm.lookupStoreRoot(args.store);
if (storeRootNode != null)
{
var path = storeRootNode.path + args.path;
var node = avm.lookupNode(path);
if (node != null)
{
// add the custom view aspect
node.addAspect("cm:webscriptable");
node.properties["cm:webscript"] = "/wcs" + args.view;
node.save();
model.success = true;
}
}
}

View File

@@ -0,0 +1,8 @@
<webscript>
<shortname>Retrieve Day Events</shortname>
<description>Retrieve Day Events</description>
<url>/calendar/RetrieveDayEvents?d={requiredDate}&amp;s={currentSpace}</url>
<format default="html">extension</format>
<authentication>user</authentication>
<transaction>required</transaction>
</webscript>

View File

@@ -0,0 +1,234 @@
//
// Modified to include events from subscribed calendars.
//
// Author: simon@webteq.eu
//
var dateString = args.d;
var requiredDate = new Date(dateString);
var spaceRef = args.s;
var currentBaseSpace = findNodeByNodeRef(spaceRef);
var calendarSpaceArray = function() {
var c = null;
var x = new Array();
var y = currentBaseSpace.assocs["ia:subscribedCalendarList"];
if (y != null)
{
for (i=0; i<y.length; i++)
{
c = y[i].childByNamePath("CalEvents");
if (c != null) {
x[i] = c;
}
}
}
c = currentBaseSpace.childByNamePath("CalEvents");
if (c != null) {
x[x.length] = c;
}
return x;
};
calendarSpaces = calendarSpaceArray();
function Interval(start, end) {
this.start = start;
this.end = end;
};
Interval.prototype.overlaps = function(interval) {
var time = interval.start.getTime();
return (this.start.getTime() <= time) && (time < this.end.getTime());
};
function Event(name, start, end) {
this.name = name;
this.start = start;
this.end = end;
this.tabs = 0;
};
Event.prototype.getInterval = function() {
return new Interval(this.start, this.end);
};
Event.prototype.color = "#FF0000"; // default color
Event.prototype.setColor = function(color) {
this.color = color;
};
// Returns a list of events for a given date
function getEvents(eventdate) {
var datestr = eventdate.toDateString();
var eventsList = new Array();
for (var j=0; j <calendarSpaces.length; j++) {
var space = calendarSpaces[j];
var color = space.parent.properties["ia:colorEventDefault"]; // (default) color of the calendar
var edit_p = 0;
if (currentBaseSpace.name == space.parent.name) {
edit_p = 1;
}
for (var i=0; i<space.children.length; i++) {
var child = space.children[i];
if (child.type=="{com.infoaxon.alfresco.calendar}calendarEvent") {
if (datestr == child.properties["ia:fromDate"].toDateString()) {
var startdate = child.properties["ia:fromDate"];
var enddate = child.properties["ia:toDate"];
var name = child.properties["ia:whatEvent"];
var event = new Event(name, startdate, enddate);
event.nodeRef = child.nodeRef;
event.edit_p = edit_p;
if (color != null && color.length != "") {
event.setColor(color); // the color that is used to render the event
}
eventsList.push(event);
}
}
}
}
return eventsList;
};
var events = getEvents(requiredDate);
// Sort the array in order of start time
events.sort(eventCompare);
function eventCompare(a,b) {
return a.start.getTime() - b.start.getTime();
};
var HoursArray = function() {
var _arr = new Array();
_arr[0] = "00:00";
_arr[1] = "00:30";
for (i=1; i<24; i++) {
_arr[i*2] = i + ":00";
_arr[i*2+1] = i + ":30";
}
return _arr;
};
var MINUTES = 60 * 1000; // ms in a minute
var INTERVAL = 30 * MINUTES; // half an hour is the current display interval
var intervals = new Array();
//
// Construct the intervals list based on the display hours
//
var _hours = HoursArray();
for (idx in _hours) {
var time = _hours[idx].split(":");
var startdate = new Date();
startdate.setTime(requiredDate.valueOf()); // Copy date value
startdate.setHours(time[0]);
startdate.setMinutes(time[1]);
var enddate = new Date();
enddate.setTime(startdate.getTime() + INTERVAL);
intervals[idx] = new Interval(startdate, enddate);
}
function getIntervalEvents(interval) {
var html = "<div>";
var tabs = 0;
// Loop through the events list
for (j in events) {
var event = events[j];
// If the end time of the interval is less than or equal to the start time of the current event
// jump out of the loop; there is no point in checking the rest of the events as the list is sorted.
if (interval.end.getTime() <= event.start.getTime()) {
break;
}
var event_interval = event.getInterval();
if (event_interval.overlaps(interval)) {
// We have found an event in this interval
if (tabs > event.tabs) {
event.tabs = tabs;
}
// Add spacer tabs if necessary
if (event.tabs - tabs > 0) {
html += addPadding(event.tabs - tabs);
}
var style = new Array();
style[0] = "border-left: 6px solid " + event.color;
var content = "&nbsp;";
if (interval.start.getTime() == event_interval.start.getTime()) {
style[1] = "border-top: 1px solid black";
style[2] = "padding-top: 0px";
content = event.name;
} else if (interval.end.getTime() == event_interval.end.getTime()) {
style[1] = "border-bottom: 1px solid black";
style[2] = "padding-top: 0px";
}
// Add the event
html += "<div class=\"calendar_entry\"";
if (event.edit_p) {
html += " onclick=\"editEvent('" + event.nodeRef + "');\"";
}
html += " style=\"" + style.join(" ; ") + "\">" + content + "</div>";
tabs = event.tabs + 1;
}
}
html += "</div>";
return html;
}
function addPadding(amount) {
var spacertext = "";
for(z=0; z<amount; z++) {
spacertext += "<div class=\"calendar_spacer\">&nbsp;</div>";
}
return spacertext;
}
String.prototype.pad = function(l, s, t) {
return s || (s = " "), (l -= this.length) > 0 ? (s = new Array(Math.ceil(l / s.length)
+ 1).join(s)).substr(0, t = !t ? l : t == 1 ? 0 : Math.ceil(l / 2))
+ this + s.substr(0, l - t) : this;
};
function getGUIDFromNodeRef(nodeRef) {
var str = "" + nodeRef;
if (str.length > 24) {
return str.substring(24);
}
else {
return "Not a NodeRef";
}
}
function findNodeByNodeRef(nodeRef) {
var resultsArray = search.luceneSearch("ID:workspace\\://SpacesStore/" + getGUIDFromNodeRef(nodeRef));
if (resultsArray != null && resultsArray.length > 0) {
return resultsArray[0];
}
else {
return null;
}
}
var response = "<table id=\"tabDayView\" bordercolor=\"#FF00FF\" bordercolordark=\"#FFFFFF\" bordercolorlight=\"#99CCFF\" border=\"1\" cellspacing=\"0\" cellpadding=\"0\" width=\"100%\">";
var _arr = HoursArray();
for (i=0; i<_arr.length; i++)
{
var tdclass = "";
if (i % 2 == 0)
tdclass = "alternateRow";
else
tdclass = "";
response += "<TR class='" + tdclass + "'>";
response += "<TD align='right'>" + _arr[i] + "</TD>";
response += "<TD onclick='createDayTextBoxNode(event);' width='90%' style=\"border:0\">" + getIntervalEvents(intervals[i]) + "</TD>";
response += "</TR>";
}
response += "</table>";
model.result = response;
model.intervals = intervals;
model.eventList = events;

View File

@@ -0,0 +1,8 @@
<webscript>
<shortname>Retrieve Event Defaults</shortname>
<description>Retrieve Event Defaults</description>
<url>/calendar/RetrieveEventDefaults?s={spaceRef}</url>
<format default="html">extension</format>
<authentication>user</authentication>
<transaction>required</transaction>
</webscript>

View File

@@ -0,0 +1,54 @@
function getGUIDFromNodeRef(nodeRef)
{
var str = "" + nodeRef;
return str.substring(str.lastIndexOf("/")+1);
}
function findNodeByNodeRef(nodeRef)
{
var resultsArray= search.luceneSearch("ID:workspace\\://SpacesStore/" + getGUIDFromNodeRef(nodeRef));
if (resultsArray != null && resultsArray.length > 0)
{
return resultsArray[0];
}
else
{
return null;
}
}
var spaceRef = args.s;
var currentBaseSpace = findNodeByNodeRef(spaceRef);
var response = ""
var _today = new Date();
if (currentBaseSpace != null)
{
if (currentBaseSpace.properties["ia:whatEventDefault"] != null)
response += currentBaseSpace.properties["ia:whatEventDefault"] + "^";
else
response += "" + "^";
if (currentBaseSpace.properties["ia:fromDateDefault"] != null)
response += currentBaseSpace.properties["ia:fromDateDefault"] + "^";
else
response += _today.toString() + "^";
if (currentBaseSpace.properties["ia:toDateDefault"] != null)
response += currentBaseSpace.properties["ia:toDateDefault"] + "^";
else
response += _today.toString() + "^";
if (currentBaseSpace.properties["ia:whereEventDefault"] != null)
response += currentBaseSpace.properties["ia:whereEventDefault"] + "^";
else
response += "" + "^";
if (currentBaseSpace.properties["ia:colorEventDefault"] != null)
response += currentBaseSpace.properties["ia:colorEventDefault"];
else
response += "";
}
logger.log("RESPONSE: " + response);
model.result = response;

View File

@@ -0,0 +1,8 @@
<webscript>
<shortname>Retrieve Event Details</shortname>
<description>Retrieve Event Details</description>
<url>/calendar/RetrieveEventDetails?e={eventId}</url>
<format default="html">extension</format>
<authentication>user</authentication>
<transaction>required</transaction>
</webscript>

View File

@@ -0,0 +1,35 @@
var eventId = args.e;
var eventNode = search.findNode(eventId);
if (eventNode == null)
{
model.result = "Event not Found";
}
else
{
var response = "";
var _fromDate = eventNode.properties["ia:fromDate"];
var _toDate = eventNode.properties["ia:toDate"];
var _fromMonth = _fromDate.getMonth() + 1;
var _toMonth = _toDate.getMonth() + 1;
response += eventNode.properties["ia:whatEvent"] + "^";
response += _fromMonth + "/" + _fromDate.getDate() + "/" + _fromDate.getFullYear() + "^";
var frmHour = _fromDate.getHours();
if (frmHour == 0) frmHour += "0";
var frmMin = _fromDate.getMinutes();
if (frmMin == 0) frmMin += "0";
response += frmHour + ":" + frmMin + "^";
response += _toMonth + "/" + _toDate.getDate() + "/" + _toDate.getFullYear() + "^";
var toHour = _toDate.getHours();
if (toHour == 0) toHour += "0";
var toMin = _toDate.getMinutes();
if (toMin == 0) toMin += "0";
response += toHour + ":" + toMin + "^";
response += eventNode.properties["ia:whereEvent"] + "^";
response += eventNode.properties["ia:descriptionEvent"] + "^";
response += eventNode.properties["ia:colorEvent"];
model.result=response;
}

View File

@@ -0,0 +1,8 @@
<webscript>
<shortname>Retrieve Month Events</shortname>
<description>Retrieve Month Events</description>
<url>/calendar/RetrieveMonthEvents?d={requiredDate}&amp;s={currentSpace}</url>
<format default="html">extension</format>
<authentication>user</authentication>
<transaction>required</transaction>
</webscript>

View File

@@ -0,0 +1,41 @@
<#assign days = DaysArray>
<table id="tabMonthView" bordercolor="#FF00FF" bordercolordark="#FFFFFF" bordercolorlight="#99CCFF" border="1" cellspacing="0" cellpadding="2" width="100%">
<TR>
<#list days as item>
<TD align="center" valign="top" width="13%">${item}</TD>
</#list>
</TR>
<#assign i=0>
<#list eventList?chunk(7, '-') as row>
<#if i % 2 == 0>
<#assign tdclass = "alternateRow">
<#else>
<#assign tdclass = "">
</#if>
<#assign i = i+1>
<TR class="${tdclass}">
<#list row as cell>
<#if cell?exists>
<TD valign="top" width="13%">
<DIV class='divDates'>
<a href="#" onclick="CalendarUtil.setDayView(${cell.datePart}, tabView);">${cell.datePart}</a>
</DIV>
<#if cell.object?exists>
<#list cell.object as eachEvent>
<#if eachEvent.isEditable == 1>
<DIV class='eventCaption' style='border-left: 3px solid ${eachEvent.color};' title='${eachEvent.object.properties["ia:descriptionEvent"]}' onclick="editEvent('${eachEvent.object.nodeRef}')">${eachEvent.object.properties["ia:whatEvent"]}</DIV>
<#else>
<DIV class='eventCaptionNonEditable' style='border-left: 3px solid ${eachEvent.color};' title='${eachEvent.object.properties["ia:descriptionEvent"]}'>${eachEvent.object.properties["ia:whatEvent"]}</DIV>
</#if>
</#list>
</#if>
</TD>
<#else>
<TD>&nbsp;</TD>
</#if>
</#list>
</TR>
</#list>
</table>

View File

@@ -0,0 +1,221 @@
var dateString = args.d;
var _currentDateForMonthView= new Date(dateString);
var spaceRef = args.s;
var currentBaseSpace = findNodeByNodeRef(spaceRef);
var eventList = new Array();
function editableObject(obj, iseditable, color) {
this.object = obj;
this.isEditable = iseditable;
this.color = color;
}
function eventType(datepart, obj) {
this.datePart = datepart;
this.object = obj;
}
var DaysArray = function() {
var _arr = new Array();
_arr[0] = "Sunday";
_arr[1] = "Monday";
_arr[2] = "Tuesday";
_arr[3] = "Wednesday";
_arr[4] = "Thursday";
_arr[5] = "Friday";
_arr[6] = "Saturday";
return _arr;
}
var MonthsArray = function() {
var _arr = new Array();
_arr[0] = "January";
_arr[1] = "February";
_arr[2] = "March";
_arr[3] = "April";
_arr[4] = "May";
_arr[5] = "June";
_arr[6] = "July";
_arr[7] = "August";
_arr[8] = "September";
_arr[9] = "October";
_arr[10] = "November";
_arr[11] = "December";
return _arr;
}
String.prototype.pad = function(l, s, t) {
return s || (s = " "), (l -= this.length) > 0 ? (s = new Array(Math.ceil(l / s.length)
+ 1).join(s)).substr(0, t = !t ? l : t == 1 ? 0 : Math.ceil(l / 2))
+ this + s.substr(0, l - t) : this;
};
var calendarSpaceArray = function() {
var color;
var defaultColor = "#FF0000";
var c = null;
var x = new Array();
var y = currentBaseSpace.assocs["ia:subscribedCalendarList"];
if (y != null) {
for (i=0; i<y.length; i++) {
c = y[i].childByNamePath("CalEvents");
if (c != null)
if ((color = y[i].properties["ia:colorEventDefault"]) == null) {
color = defaultColor;
}
x[i] = new editableObject(c, 0, color);
}
} else {
logger.log("NOT SUBSCRIBED TO CALENDARS");
}
c = currentBaseSpace.childByNamePath("CalEvents");
if (c != null) {
if ((color = currentBaseSpace.properties["ia:colorEventDefault"]) == null) {
color = defaultColor;
}
x[x.length] = new editableObject(c, 1, color);
}
return x;
};
calendarSpaces = calendarSpaceArray();
function getDayEvents(requiredDate) {
var eventsArr = new Array();
var events = "";
var _months = MonthsArray();
if (currentBaseSpace == null)
return events;
for (var j=0; j<calendarSpaces.length; j++)
{
var currentSpace = calendarSpaces[j].object;
for (var i=0; i<currentSpace.children.length; i++)
{
var child = currentSpace.children[i];
if (child.type=="{com.infoaxon.alfresco.calendar}calendarEvent")
{
var fromDate = new Date(child.properties["ia:fromDate"]);
fromDate.setHours(0,0,0,0);
var toDate = new Date(child.properties["ia:toDate"]);
toDate.setHours(11,59,59,0);
if (fromDate <= requiredDate && toDate >= requiredDate)
{
eventsArr.push(new editableObject(child, calendarSpaces[j].isEditable, calendarSpaces[j].color));
}
}
}
}
eventsArr.sort(SortCalendarEvents);
var tempEvents = new Array();
for (var j=0; j<eventsArr.length; j++)
{
var child = eventsArr[j].object;
var fromDate = new Date(child.properties["ia:fromDate"]);
fromDate.setHours(0,0,0,0);
var toDate = new Date(child.properties["ia:toDate"]);
toDate.setHours(11,59,59,0);
var showTimeLine = "";
if (fromDate.toDateString() == requiredDate.toDateString() && toDate.toDateString() == requiredDate.toDateString())
showTimeLine = child.properties["ia:fromDate"].getHours() + ":" + child.properties["ia:fromDate"].getMinutes().toString().pad(2, "0", 1) + " - " + child.properties["ia:toDate"].getHours() + ":" + child.properties["ia:toDate"].getMinutes().toString().pad(2, "0", 1);
else
showTimeLine = child.properties["ia:fromDate"].getDate() + " " + _months[child.properties["ia:fromDate"].getMonth()] + ", " + child.properties["ia:fromDate"].getHours() + ":" + child.properties["ia:fromDate"].getMinutes().toString().pad(2, "0", 1) + " - " + child.properties["ia:toDate"].getDate() + " " + _months[child.properties["ia:toDate"].getMonth()] + ", " + child.properties["ia:toDate"].getHours() + ":" + child.properties["ia:toDate"].getMinutes().toString().pad(2, "0", 1);
tempEvents.push(new editableObject(child, eventsArr[j].isEditable, eventsArr[j].color));
}
return tempEvents;
}
function SortCalendarEvents(child1, child2)
{
return (child1.object.properties["ia:fromDate"] - child2.object.properties["ia:fromDate"]);
}
function GetMonthName()
{
var _arr = MonthsArray();
return _arr[_currentDateForMonthView.getMonth()];
}
function getGUIDFromNodeRef(nodeRef)
{
var str = "" + nodeRef;
return str.substring(str.lastIndexOf("/")+1);
}
function findNodeByNodeRef(nodeRef)
{
var resultsArray = search.luceneSearch("ID:workspace\\://SpacesStore/" + getGUIDFromNodeRef(nodeRef));
if (resultsArray != null && resultsArray.length > 0)
{
return resultsArray[0];
}
else
{
return null;
}
}
var response;
if (currentBaseSpace == null)
{
response = "Parameters passed:<BR>";
response += "Current Date: " + dateString + "<BR>";
response += "Current Space: " + spaceRef + "<BR>";
response += "<BR>Error: No Space found by this Ref";
}
else
{
calendarSpaces = calendarSpaceArray();
var _arrDay = DaysArray();
var tmpDate;
var i, j;
// Start with the first day of the month and go back if necessary to the previous Sunday.
tmpDate = new Date(Date.parse(_currentDateForMonthView));
tmpDate.setDate(1);
tmpDate.setHours(0,0,0,0);
while (tmpDate.getDay() != 0)
{
tmpDate.setDate(tmpDate.getDate() - 1);
}
for (i = 2; i <= 7; i++)
{
// Loop through a week.
for (j = 0; j < _arrDay.length; j++)
{
if (tmpDate.getMonth() == _currentDateForMonthView.getMonth())
{
eventList.push(new eventType(tmpDate.getDate(), getDayEvents(tmpDate)));
}
else
{
eventList.push(null);
}
// Go to the next day.
tmpDate.setDate(tmpDate.getDate() + 1);
}
}
}
model.DaysArray = DaysArray();
model.eventList = eventList;

View File

@@ -0,0 +1,8 @@
<webscript>
<shortname>Retrieve Week Events</shortname>
<description>Retrieve Week Events</description>
<url>/calendar/RetrieveWeekEvents?d={requiredDate}&amp;s={currentSpace}</url>
<format default="html">extension</format>
<authentication>user</authentication>
<transaction>required</transaction>
</webscript>

View File

@@ -0,0 +1,62 @@
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<TR><TD align="center"><B>${dayCaption}</B></TD></TR>
</table>
<BR>
<table id="tabWeekView" bordercolor="#FF00FF" bordercolordark="#FFFFFF" bordercolorlight="#99CCFF" border="1" cellspacing="0" cellpadding="2" width="100%">
<TR>
<TD width="7%">&nbsp;</TD>
<#list daysArray as item>
<TD align="center" valign="top" width="13%">${item}</TD>
</#list>
</TR>
<TR>
<TD width="7%" align="center"><B>All Day</B></TD>
<#list eventListAllDay as item>
<TD>
<#if item?exists>
<#list item as eachEvent>
<#if eachEvent.isEditable == 1>
<DIV class='eventCaptionAllDay' style='background-color: ${eachEvent.object.properties["ia:colorEvent"]};' title='${eachEvent.object.properties["ia:descriptionEvent"]}' onclick="editEvent('${eachEvent.object.nodeRef}')">${eachEvent.object.properties["ia:whatEvent"]}</DIV>
<#else>
<DIV class='eventCaptionAllDayNonEditable' style='background-color:${eachEvent.color};' title='${eachEvent.object.properties["ia:descriptionEvent"]}'>${eachEvent.object.properties["ia:whatEvent"]}</DIV>
</#if>
</#list>
<#else>
&nbsp;
</#if>
</TD>
</#list>
</TR>
<#assign i=0>
<#list eventList as item>
<#if i % 2 == 0>
<#assign tdclass = "alternateRow">
<#else>
<#assign tdclass = "">
</#if>
<#assign i = i+1>
<TR class="${tdclass}">
<TD align='right'>${item.timeSlot}</TD>
<#list item.object as hourEvents>
<TD valign='top' width='13%' onclick='createWeekTextBoxNode(event, ${hourEvents.timeSlot?string("yyyy")}, ${hourEvents.timeSlot?string("MM")?number-1}, ${hourEvents.timeSlot?string("dd")})'>
<#if hourEvents.object?exists>
<#list hourEvents.object as eachEvent>
<#if eachEvent.isEditable == 1>
<DIV class='eventCaption' style='border-left: 3px solid ${eachEvent.color};' title='${eachEvent.object.properties["ia:descriptionEvent"]}' onclick="editEvent('${eachEvent.object.nodeRef}')">${eachEvent.object.properties["ia:whatEvent"]}</DIV>
<#else>
<DIV class='eventCaptionNonEditable' style='border-left: 3px solid ${eachEvent.color};' title='${eachEvent.object.properties["ia:descriptionEvent"]}'>${eachEvent.object.properties["ia:whatEvent"]}</DIV>
</#if>
</#list>
<#else>
&nbsp;
</#if>
</TD>
</#list>
</TR>
</#list>
</table>

View File

@@ -0,0 +1,263 @@
var dateString = args.d;
var _currentDateForWeekView= new Date(dateString);
var spaceRef = args.s;
var currentBaseSpace = findNodeByNodeRef(spaceRef);
var eventList = new Array();
var eventListAllDay = new Array();
var days = new Array();
function editableObject(obj, iseditable, color) {
this.object = obj;
this.isEditable = iseditable;
this.color = color;
}
function eventType(obj, timeslot) {
this.object = obj;
this.timeSlot = timeslot;
}
var HoursArray = function() {
var _arr = new Array();
_arr[0] = "00:00";
_arr[1] = "00:30";
for (i=1; i<24; i++) {
_arr[i*2] = i + ":00";
_arr[i*2+1] = i + ":30";
}
return _arr;
}
var DaysArray = function() {
var _arr = new Array();
_arr[0] = "Sunday";
_arr[1] = "Monday";
_arr[2] = "Tuesday";
_arr[3] = "Wednesday";
_arr[4] = "Thursday";
_arr[5] = "Friday";
_arr[6] = "Saturday";
return _arr;
}
var MonthsArray = function() {
var _arr = new Array();
_arr[0] = "Jan";
_arr[1] = "Feb";
_arr[2] = "Mar";
_arr[3] = "Apr";
_arr[4] = "May";
_arr[5] = "Jun";
_arr[6] = "Jul";
_arr[7] = "Aug";
_arr[8] = "Sep";
_arr[9] = "Oct";
_arr[10] = "Nov";
_arr[11] = "Dec";
return _arr;
}
String.prototype.pad = function(l, s, t) {
return s || (s = " "), (l -= this.length) > 0 ? (s = new Array(Math.ceil(l / s.length)
+ 1).join(s)).substr(0, t = !t ? l : t == 1 ? 0 : Math.ceil(l / 2))
+ this + s.substr(0, l - t) : this;
};
var calendarSpaceArray = function() {
var color;
var defaultColor = "#FF0000";
var c = null;
var x = new Array();
var y = currentBaseSpace.assocs["ia:subscribedCalendarList"];
if (y != null) {
for (i=0; i<y.length; i++) {
c = y[i].childByNamePath("CalEvents");
if (c != null) {
if ((color = y[i].properties["ia:colorEventDefault"]) == null) {
color = defaultColor;
}
x[i] = new editableObject(c, 0, color);
}
}
} else {
logger.log("NOT SUBSCRIBED TO CALENDARS");
}
c = currentBaseSpace.childByNamePath("CalEvents");
if (c != null) {
if ((color = currentBaseSpace.properties["ia:colorEventDefault"]) == null) {
color = defaultColor;
}
x[x.length] = new editableObject(c, 1, color);
}
return x;
};
calendarSpaces = calendarSpaceArray();
function getDayEvents(requiredDate, requiredTime)
{
var eventArr = new Array();
var _months = MonthsArray();
if (currentBaseSpace == null)
return null;
for (var j=0; j<calendarSpaces.length; j++)
{
var currentSpace = calendarSpaces[j].object;
for (var i=0; i<currentSpace.children.length; i++)
{
var child = currentSpace.children[i];
var times = requiredTime.split(":");
if (child.type=="{com.infoaxon.alfresco.calendar}calendarEvent") {
var fromDate = new Date(child.properties["ia:fromDate"]);
fromDate.setHours(0,0,0,0);
var toDate = new Date(child.properties["ia:toDate"]);
toDate.setHours(requiredDate.getHours(),
requiredDate.getMinutes(),
requiredDate.getSeconds(),
0);
if (child.properties["ia:fromDate"].toDateString() == requiredDate.toDateString() && child.properties["ia:fromDate"].getHours() == parseInt(times[0]) && child.properties["ia:fromDate"].getMinutes() == parseInt(times[1]))
{
var showTimeLine = "";
if (toDate > requiredDate)
showTimeLine = child.properties["ia:fromDate"].getDate() + " " + _months[child.properties["ia:fromDate"].getMonth()] + ", " + child.properties["ia:fromDate"].getHours() + ":" + child.properties["ia:fromDate"].getMinutes().toString().pad(2, "0", 1) + " - " + child.properties["ia:toDate"].getDate() + " " + _months[child.properties["ia:toDate"].getMonth()] + ", " + child.properties["ia:toDate"].getHours() + ":" + child.properties["ia:toDate"].getMinutes().toString().pad(2, "0", 1);
else
showTimeLine = child.properties["ia:fromDate"].getHours() + ":" + child.properties["ia:fromDate"].getMinutes().toString().pad(2, "0", 1) + " - " + child.properties["ia:toDate"].getHours() + ":" + child.properties["ia:toDate"].getMinutes().toString().pad(2, "0", 1);
eventArr.push(new editableObject(child, calendarSpaces[j].isEditable, calendarSpaces[j].color));
}
}
}
}
if (eventArr.length == 0) { eventArr = null; }
return eventArr;
}
function getAllDayEvents(requiredDate)
{
var eventArr = new Array();
var _months = MonthsArray();
if (currentBaseSpace == null)
return null;
for (var j=0; j<calendarSpaces.length; j++)
{
var currentSpace = calendarSpaces[j].object;
for (var i=0; i<currentSpace.children.length; i++)
{
var child = currentSpace.children[i];
if (child.type=="{com.infoaxon.alfresco.calendar}calendarEvent")
{
var fromDate = new Date(child.properties["ia:fromDate"]);
fromDate.setHours(0,0,0,0);
var toDate = new Date(child.properties["ia:toDate"]);
toDate.setHours(requiredDate.getHours(),requiredDate.getMinutes(),requiredDate.getSeconds(),0);
if (child.properties["ia:fromDate"].toDateString() != child.properties["ia:toDate"].toDateString() && fromDate <= requiredDate && toDate >= requiredDate)
{
eventArr.push(new editableObject(child, calendarSpaces[j].isEditable, calendarSpaces[j].color));
}
}
}
}
if (eventArr.length == 0) { eventArr = null; }
return eventArr;
}
function SortCalendarEvents(child1, child2)
{
return (child1.properties["ia:fromDate"] - child2.properties["ia:fromDate"]);
}
function AddWeekDayRow()
{
var _currDay = _currentDateForWeekView.getDay();
var _arr = DaysArray();
for (i=0; i<_arr.length; i++)
{
var _newDate = new Date(_currentDateForWeekView);
_newDate.setDate(_currentDateForWeekView.getDate() - _currDay + i);
days.push(_newDate.toDateString());
if (i == 0) _startDateForWeekView = _newDate;
}
}
function AddAllDayEventsRow()
{
var _arr = DaysArray();
var tempDate = new Date(_startDateForWeekView);
for (i=0; i<_arr.length; i++)
{
if (i != 0) tempDate.setDate(tempDate.getDate() + 1);
eventListAllDay.push(getAllDayEvents(tempDate));
}
}
function getGUIDFromNodeRef(nodeRef)
{
var str = "" + nodeRef;
return str.substring(str.lastIndexOf("/")+1);
}
function findNodeByNodeRef(nodeRef)
{
var resultsArray = search.luceneSearch("ID:workspace\\://SpacesStore/" + getGUIDFromNodeRef(nodeRef));
if (resultsArray != null && resultsArray.length > 0)
{
return resultsArray[0];
}
else
{
return null;
}
}
var response;
if (currentBaseSpace == null) {
response = "Parameters passed:<BR>";
response += "Current Date: " + dateString + "<BR>";
response += "Current Space: " + spaceRef + "<BR>";
response += "<BR>Error: No Space found by this Ref";
} else {
AddWeekDayRow();
AddAllDayEventsRow();
var _arr = HoursArray();
var _arrDay = DaysArray();
var eventDays = new Array();
for (i=0; i<_arr.length; i++)
{
eventDays = new Array();
var tempDate = new Date(_startDateForWeekView);
for (j=0; j<_arrDay.length; j++)
{
if (j != 0) tempDate.setDate(tempDate.getDate() + 1);
var _date = tempDate.getDate();
var _month = tempDate.getMonth();
var _year = tempDate.getFullYear();
eventDays.push(new eventType(getDayEvents(tempDate, _arr[i]), new Date(tempDate)));
}
eventList.push(new eventType(eventDays, _arr[i]));
}
var _lastDate = new Date(_startDateForWeekView);
_lastDate.setDate(_lastDate.getDate() + 6);
model.dayCaption = _startDateForWeekView.toDateString() + " <I>to</I> " + _lastDate.toDateString();
}
//model.result = response;
model.daysArray = days;
model.eventList = eventList;
model.eventListAllDay = eventListAllDay;

View File

@@ -0,0 +1,8 @@
<webscript>
<shortname>Save Calendar Event</shortname>
<description>Save Calendar Event</description>
<url>/calendar/SaveCalendarEvent?what={whatEvent}&amp;where={whereEvent}&amp;desc={descriptionEvent}&amp;color={colorEvent}&amp;fd={fromDate}&amp;ft={fromTime}&amp;td={toDate}&amp;tt={toTime}&amp;e={eventId}&amp;d={toDelete}&amp;s={spaceRef}</url>
<format default="html">extension</format>
<authentication>user</authentication>
<transaction>required</transaction>
</webscript>

View File

@@ -0,0 +1,103 @@
var now = new Date();
var day = now.getDay();
var month = now.getMonth();
var year = now.getYear();
var hour = now.getHours();
var minute = now.getMinutes();
var second = now.getSeconds();
var stamp = day + month + year + hour.toString() + minute + second;
logger.log("DATE: " + args.fd + " " + args.ft);
var fromDateString = args.fd + " " + args.ft;
var fromDateDate = new Date(fromDateString);
var toDateString = args.td + " " + args.tt;
var toDateDate = new Date(toDateString);
var content = "What: " + args.what + "<BR>";
content += "When: " + args.fd + " " + args.ft + " to " + args.td + " " + args.tt + "<BR>";
content += "Where: " + args.where + "<BR>";
content += "Description: " + args.desc + "<BR>";
content += "Color: " + args.color;
var fileNode = null;
var eventId = args.e;
var toDelete = args.d;
var spaceRef = args.s;
var nodeWhereToCreate = findNodeByNodeRef(spaceRef);
var response;
if (nodeWhereToCreate != null)
{
var newFolder = nodeWhereToCreate.childByNamePath("CalEvents");
if (newFolder == null)
nodeWhereToCreate = nodeWhereToCreate.createFolder("CalEvents");
else
nodeWhereToCreate = newFolder;
if (eventId == null)
{
fileNode = nodeWhereToCreate.createNode(stamp + ".ics", "ia:calendarEvent");
saveNodeDetails();
}
else
{
fileNode = search.findNode(eventId);
if (toDelete == 'true')
{
var status = fileNode.remove();
if (status)
response = "DELETED";
else
response = "NOT DELETED";
}
else
{
saveNodeDetails();
}
}
}
else
{
response = "SPACE not found with Ref " + spaceRef;
}
model.result = response;
function saveNodeDetails()
{
fileNode.properties["ia:whatEvent"] = args.what;
fileNode.properties["ia:fromDate"] = fromDateDate;
fileNode.properties["ia:toDate"] = toDateDate;
fileNode.properties["ia:whereEvent"] = args.where;
fileNode.properties["ia:descriptionEvent"] = args.desc;
fileNode.properties["ia:colorEvent"] = args.color;
fileNode.save();
fileNode.content = content;
response = fileNode.content;
}
function getGUIDFromNodeRef(nodeRef)
{
var str = "" + nodeRef;
return str.substring(str.lastIndexOf("/")+1);
}
function findNodeByNodeRef(nodeRef)
{
var resultsArray = search.luceneSearch("ID:workspace\\://SpacesStore/" + getGUIDFromNodeRef(nodeRef));
if (resultsArray != null && resultsArray.length > 0)
{
return resultsArray[0];
}
else
{
return null;
}
}

View File

@@ -0,0 +1,6 @@
<webscript>
<shortname>Calendar Subscriptions</shortname>
<description>Calendar Subscriptions</description>
<url>/calendar/calendarRemove</url>
<authentication>user</authentication>
</webscript>

View File

@@ -0,0 +1,6 @@
<select id="subscriptions" style="width:300px" size="8" multiple="multiple">
<#list resultset as node>
<option value="${node.nodeRef}">${node.parent.name}</option>
</#list>
</select>

View File

@@ -0,0 +1,33 @@
function getGUIDFromNodeRef(nodeRef) {
var str = "" + nodeRef;
if (str.length > 24) {
return str.substring(24);
} else {
return "";
}
}
function findNodeByNodeRef(nodeRef) {
var resultsArray = search.luceneSearch("ID:workspace\\://SpacesStore/" + getGUIDFromNodeRef(nodeRef));
if (resultsArray != null && resultsArray.length > 0) {
return resultsArray[0];
} else {
return null;
}
}
var spaceRef = args.ref;
var space = findNodeByNodeRef(spaceRef);
// Resolve the calendar reference
var calendar = findNodeByNodeRef(args.calendar);
if (calendar != null) {
space.removeAssociation(calendar, "ia:subscribedCalendarList");
space.save();
}
var calendars = space.assocs["ia:subscribedCalendarList"];
if (calendars == null) {
calendars = new Array();
}
model.resultset = calendars;

View File

@@ -0,0 +1,6 @@
<webscript>
<shortname>Calendar Events</shortname>
<description>Calendar Events</description>
<url>/calendar/getCalendarEvents</url>
<authentication>user</authentication>
</webscript>

View File

@@ -0,0 +1,20 @@
<script type="text/javascript" src="/alfresco/yui/build/yahoo/yahoo.js"></script>
<script type="text/javascript" src="/alfresco/yui/build/event/event.js" ></script>
<script type="text/javascript" src="/alfresco/yui/build/dom/dom.js" ></script>
<script type="text/javascript" src="/alfresco/yui/build/calendar/calendar.js"></script>
<link type="text/css" rel="stylesheet" href="/alfresco/yui/build/calendar/assets/calendar.css">
<script type="text/javascript">
YAHOO.namespace("example.calendar");
YAHOO.example.calendar.init = function() {
YAHOO.example.calendar.cal1 = new YAHOO.widget.Calendar("cal1","cal1Container", { pagedate:"${month}/${year}" } );
<#list dates as d>
YAHOO.example.calendar.cal1.addRenderer("${d}", YAHOO.example.calendar.cal1.renderCellStyleSelected);
</#list>
YAHOO.example.calendar.cal1.render();
}
YAHOO.util.Event.onDOMReady(YAHOO.example.calendar.init);
</script>
<div id="cal1Container"></div>

View File

@@ -0,0 +1,87 @@
function getGUIDFromNodeRef(nodeRef) {
var str = "" + nodeRef;
if (str.length > 24) {
return str.substring(24);
} else {
return "";
}
}
function findNodeByNodeRef(nodeRef) {
var resultsArray = search.luceneSearch("ID:workspace\\://SpacesStore/" + getGUIDFromNodeRef(nodeRef));
if (resultsArray != null && resultsArray.length > 0) {
return resultsArray[0];
} else {
return null;
}
}
var spaceRef = args.ref;
var calendar = findNodeByNodeRef(spaceRef);
function formatANSI(datestr) {
var tmp = datestr.split("/");
var d = new Date();
d.setFullYear(tmp[0]);
d.setMonth(tmp[1]-1);
d.setDate(tmp[2]);
return d;
}
function Interval(start, end) {
this.start = start;
this.end = end;
};
Interval.prototype.overlaps = function(interval) {
// take the interval with the early start time as the one to compare against
var x, y;
if (this.start.getTime() < interval.start.getTime()) {
x = this; y = interval;
} else {
x = interval; y = this;
}
var time = y.start.getTime();
return (x.start.getTime() <= time) && (time < this.end.getTime());
};
function isLeap(year) {
return (year % 4 == 0) && ((year % 100 != 0) || (year % 400 == 0));
}
var monthToDays = [31,28,31,30,31,30,31,31,30,31,30,31];
if (isLeap(args.year)) {
monthToDays[1] = 29; // one extra day in February
}
var fromDate = args.year + "/0" + args.month + "/01";
var from = formatANSI(fromDate);
var toDate = args.year + "/0" + args.month + "/" + monthToDays[args.month - 1];
var to = formatANSI(toDate);
var time = new Interval(from, to);
var selectedDates = new Array();
var events = calendar.children;
for(var i=0; i < events.length; i++) {
var event = events[i];
var startdate = new Date(event.properties["ia:fromDate"]);
var enddate = new Date(event.properties["ia:toDate"]);
var interval = new Interval(startdate, enddate);
if (interval.overlaps(time)) {
var key = (interval.start.getMonth()+1) + "/" + interval.start.getDate();
if (selectedDates.indexOf(key) < 0) {
selectedDates.push(key);
}
}
}
model.dates = selectedDates;
// These are only used for the html view
model.month = args.month;
model.year = args.year;

View File

@@ -0,0 +1,3 @@
{
results: [<#list dates as d>"${d}"<#if d_has_next>,</#if></#list>]
}

View File

@@ -0,0 +1,6 @@
<webscript>
<shortname>Calendar Subscriptions</shortname>
<description>Calendar Subscriptions</description>
<url>/calendar/calendarInit</url>
<authentication>user</authentication>
</webscript>

View File

@@ -0,0 +1,54 @@
<div>
<table>
<tr>
<td>
<div id="color2" style="height: 30px; width: 30px; background: ${color}; border: 1px solid black;">&nbsp;</div>
</td>
<td>
<A HREF="#" onClick="picker.show('pick2');return false;" NAME="pick2" ID="pick2">Select a color</A>
</td>
</tr>
</table>
</div>
<#-- This MUST be present -->
<DIV ID="colorPickerDiv" STYLE=\"position: absolute; left: 0px; top: 0px; z-index: 1; display:none;"> </DIV>
<table>
<tr>
<td>Available Calendars</td>
<td>&nbsp;</td>
<td>Subscribed Calendars</td>
<tr>
<td>
<table>
<tr>
<td id="availableCalendars">
<#-- Display the list of available calendars-->
<select id="availcals" style="width:300px" size="8">
<#list available as node>
<option value="${node.nodeRef}">${node.parent.name}</option>
</#list>
</select>
</td>
</tr>
</table>
<td>
<!-- middle column -->
<input class="alignMiddle" type="button" onclick="setupCalendarSubscription()" value="&gt;&gt;"/>
</td>
<td id="subscribedCalendars">
<#-- Display the list of subscribed calendars-->
<select id="subscriptions" style="width:300px" size="8">
<#list subscriptions as node>
<option value="${node.nodeRef}">${node.parent.name}</option>
</#list>
</select>
</td>
</tr>
<tr>
<td><input type="text" id="filter" value="" size="25"/><input type="button" onclick="applyFilter(document.getElementById('filter').value);" value="Filter"/></td>
<td>&nbsp;</td>
<td><input type="button" onclick="removeCalendarSubscription();" value="Remove"/></td>
</tr>
</table>

View File

@@ -0,0 +1,56 @@
function getGUIDFromNodeRef(nodeRef) {
var str = "" + nodeRef;
if (str.length > 24) {
return str.substring(24);
} else {
return "";
}
}
function findNodeByNodeRef(nodeRef) {
var resultsArray = search.luceneSearch("ID:workspace\\://SpacesStore/" + getGUIDFromNodeRef(nodeRef));
if (resultsArray != null && resultsArray.length > 0) {
return resultsArray[0];
} else {
return null;
}
}
var spaceRef = args.ref;
var calendar = findNodeByNodeRef(spaceRef);
var color = calendar.properties["ia:colorEventDefault"];
if (color == null || color.length == 0) {
color = "#FF0000"; // default
}
model.color = color;
// Get the list of calendars the user is subscribed to
var subscriptions = calendar.assocs["ia:subscribedCalendarList"]
if (subscriptions == null) {
subscriptions = new Array();
}
model.subscriptions = subscriptions;
// perform search
var nodes = search.luceneSearch('TYPE:\"{com.infoaxon.alfresco.calendar}calendar\"');
/**
var filtered = new Array();
if (nodes.length > 0) {
var re = new RegExp(args.q,"i");
var j = 0;
for(i=0; i < nodes.length; i++) {
var n = nodes[i];
if (re.test(n.parent.name)) {
filtered[j] = n;
++j;
}
}
}
**/
model.available = nodes;

View File

@@ -0,0 +1,6 @@
<webscript>
<shortname>Calendar Subscriptions</shortname>
<description>Calendar Subscriptions</description>
<url>/calendar/calendarSubscriptions</url>
<authentication>user</authentication>
</webscript>

View File

@@ -0,0 +1,6 @@
<select id="subscriptions" style="width:300px" size="8" multiple="multiple">
<#list resultset as node>
<option value="${node.nodeRef}">${node.parent.name}</option>
</#list>
</select>

View File

@@ -0,0 +1,29 @@
function getGUIDFromNodeRef(nodeRef) {
var str = "" + nodeRef;
if (str.length > 24) {
return str.substring(24);
} else {
return "";
}
}
function findNodeByNodeRef(nodeRef) {
var resultsArray = search.luceneSearch("ID:workspace\\://SpacesStore/" + getGUIDFromNodeRef(nodeRef));
if (resultsArray != null && resultsArray.length > 0) {
return resultsArray[0];
} else {
return null;
}
}
var spaceRef = args.ref;
var space = findNodeByNodeRef(spaceRef);
// Resolve the calendar reference
var calendar = findNodeByNodeRef(args.calendar);
if (calendar != null) {
space.createAssociation(calendar, "ia:subscribedCalendarList");
space.save();
}
var calendars = space.assocs["ia:subscribedCalendarList"];
model.resultset = calendars;

View File

@@ -0,0 +1,6 @@
<webscript>
<shortname>Calendar Subscriptions</shortname>
<description>Calendar Subscriptions</description>
<url>/calendar/getColor</url>
<authentication>user</authentication>
</webscript>

View File

@@ -0,0 +1,3 @@
${color}

View File

@@ -0,0 +1,31 @@
function getGUIDFromNodeRef(nodeRef) {
var str = "" + nodeRef;
if (str.length > 24) {
return str.substring(24);
} else {
return "";
}
}
function findNodeByNodeRef(nodeRef) {
var resultsArray = search.luceneSearch("ID:workspace\\://SpacesStore/" + getGUIDFromNodeRef(nodeRef));
if (resultsArray != null && resultsArray.length > 0) {
return resultsArray[0];
} else {
return null;
}
}
var spaceRef = args.ref;
var color = null;
var calendar = findNodeByNodeRef(spaceRef);
if (calendar != null) {
color = calendar.properties["ia:colorEventDefault"];
}
if (color == null || color.length == 0) {
color = "#FF0000"; // red
}
model.color = color;

View File

@@ -0,0 +1,6 @@
<webscript>
<shortname>Calendar Subscriptions</shortname>
<description>Calendar Subscriptions</description>
<url>/calendar/setColor</url>
<authentication>user</authentication>
</webscript>

View File

@@ -0,0 +1,27 @@
function getGUIDFromNodeRef(nodeRef) {
var str = "" + nodeRef;
if (str.length > 24) {
return str.substring(24);
} else {
return "";
}
}
function findNodeByNodeRef(nodeRef) {
var resultsArray = search.luceneSearch("ID:workspace\\://SpacesStore/" + getGUIDFromNodeRef(nodeRef));
if (resultsArray != null && resultsArray.length > 0) {
return resultsArray[0];
} else {
return null;
}
}
logger.log("COLOR: " + args.color + " REF: " + args.ref);
var spaceRef = args.ref;
var calendar = findNodeByNodeRef(spaceRef);
if (calendar != null) {
calendar.properties["ia:colorEventDefault"] = args.color;
calendar.save();
}

View File

@@ -0,0 +1,8 @@
<webscript>
<shortname>Blog Custom View</shortname>
<description>Collaboration Blog Space view</description>
<url>/collaboration/blogSpace?nodeRef={noderef}</url>
<format default="html"/>
<authentication>user</authentication>
<transaction>required</transaction>
</webscript>

View File

@@ -0,0 +1,176 @@
<div id="collabContainer">
<#if blogSpace.actionResult != "">
<div class="collabError">${blogSpace.actionResult}</div>
</#if>
<div class="collabHeader">
<span>Articles pending publishing (${blogSpace.pending?size})</span>
</div>
<div class="collabContent">
<table width="100%" cellpadding="0" cellspacing="0">
<tr valign="top">
<td width="1" style="background-color:#cacfd3;"></td>
<td>
<table width="100%" cellpadding="16" cellspacing="0">
<tr valign="top">
<td>
<table width="100%" cellpadding="0" cellspacing="0">
<tr class="blogRowHeader">
<td>&nbsp;</td>
<td>Name</td>
<td>Created on</td>
<td>Created by</td>
<td>Actions</td>
</tr>
<#assign rowNum = 0>
<#list blogSpace.pending as article>
<#assign n = article.node>
<#assign p = article.person>
<#assign rowNum = rowNum + 1>
<tr class="blogRowPost${(rowNum % 2 = 0)?string("Even", "Odd")}">
<td><img src="${url.context}${n.icon32}"></td>
<td>${n.name}</td>
<td>${n.properties["cm:created"]?datetime}</td>
<td>${p.properties["cm:firstName"]} ${p.properties["cm:lastName"]}</td>
<td>
<a class="blogAction" title="Post this article" href="${scripturl("?nodeRef=" + n.parent.nodeRef + "&n=" + n.nodeRef + "&a=p")}"><img src="${url.context}/images/icons/blog_post.png" alt="details"></a>
<a class="blogAction" title="Details" href="${url.context}/n/showDocDetails/${n.nodeRef.storeRef.protocol}/${n.nodeRef.storeRef.identifier}/${n.id}"><img src="${url.context}/images/icons/View_details.gif" alt="details"></a>
</td>
</tr>
</#list>
</table>
</td>
</tr>
</table>
</td>
<td width="1" style="background-color:#cacfd3;"></td>
</tr>
</table>
</div>
<div class="collabFooter">
<span>&nbsp;</span>
</div>
<div class="collabHeader">
<span>Articles to be updated (${blogSpace.updates?size})</span>
</div>
<div class="collabContent">
<table width="100%" cellpadding="0" cellspacing="0">
<tr valign="top">
<td width="1" style="background-color:#b9bec4;"></td>
<td>
<table width="100%" cellpadding="16" cellspacing="0">
<tr valign="top">
<td>
<table width="100%" cellpadding="0" cellspacing="0">
<tr class="blogRowHeader">
<td>&nbsp;</td>
<td>Name</td>
<td>Published on</td>
<td>Modified on</td>
<td>Actions</td>
</tr>
<#assign rowNum = 0>
<#list blogSpace.updates as article>
<#assign n = article.node>
<#assign p = article.person>
<#assign rowNum = rowNum + 1>
<tr class="blogRowPost${(rowNum % 2 = 0)?string("Even", "Odd")}">
<td><img src="${url.context}${n.icon32}"></td>
<td>${n.name}</td>
<td>${n.properties["blg:lastUpdate"]?datetime}</td>
<td>${n.properties["cm:modified"]?datetime}</td>
<td>
<a class="blogAction" title="Update blog" href="${scripturl("?nodeRef=" + n.parent.nodeRef + "&n=" + n.nodeRef + "&a=u")}"><img src="${url.context}/images/icons/blog_update.png"></a>
<a class="blogAction" title="Remove from blog" href="${scripturl("?nodeRef=" + n.parent.nodeRef + "&n=" + n.nodeRef + "&a=r")}"><img src="${url.context}/images/icons/blog_remove.png"></a>
<a class="blogAction" title="Details" href="${url.context}/n/showDocDetails/${n.nodeRef.storeRef.protocol}/${n.nodeRef.storeRef.identifier}/${n.id}"><img src="${url.context}/images/icons/View_details.gif" alt="details"></a>
</td>
</tr>
</#list>
</table>
</td>
</tr>
</table>
</td>
<td width="1" style="background-color:#b9bec4;"></td>
</tr>
</table>
</div>
<div class="collabFooter">
<span>&nbsp;</span>
</div>
</div>
<style>
/* Main Container elements */
#collabContainer {
width: 100%;
}
.collabError {
background-color: #FFFF90;
border: 1px dashed red;
font-weight: bold;
color: red;
padding: 4px;
margin: 4px;
}
.collabHeader {
background: url(${url.context}/images/parts/collab_topleft.png) no-repeat left top;
margin: 0px;
padding: 0px 0px 0px 2px;
}
.collabHeader span {
background: url(${url.context}/images/parts/collab_topright.png) no-repeat right top;
display: block;
float: none;
padding: 5px 15px 4px 6px;
font-weight: bold;
font-size: 10pt;
}
.collabContent {
}
.collabFooter {
background: url(${url.context}/images/parts/collab_bottomleft.png) no-repeat left top;
margin: 0px;
padding: 0px 0px 0px 4px;
}
.collabFooter span {
background: url(${url.context}/images/parts/collab_bottomright.png) no-repeat right top;
display: block;
float: none;
padding: 5px 15px 4px 6px;
}
.blogRowHeader {
}
.blogRowHeader td {
border-bottom: 1px solid #ccc;
font-size: 12px;
font-weight: bold;
}
.blogRowPostEven {
background-color: #f0f0f0;
}
.blogRowPostOdd {
}
.blogAction img {
border: none;
}
</style>

View File

@@ -0,0 +1,100 @@
/*
* blogSpace
*
* Inputs:
* mandatory: nodeRef = parent space nodeRef
* optional: n = nodeId for document to action against
* a = action
* "p" = publish
* "u" = update
* "r" = remove
*
* Outputs: blogSpace - object containing node arrays of articles pending and to be updated
*/
var actionResult = parseArgs(args["n"], args["a"]);
model.blogSpace = main(args["nodeRef"], actionResult);
function parseArgs(nodeId, action)
{
var result = "";
if ((nodeId != null) && (action != null))
{
var blog = actions.create("blog-post");
var node = search.findNode(nodeId);
if (node != null)
{
var blogAction = "";
var isPublished = false;
if ((node.hasAspect("blg:blogPost")) && (node.properties["blg:published"] == true))
{
isPublished = true;
}
switch (action)
{
case "p":
blogAction = (isPublished ? "" : "post");
break;
case "u":
blogAction = (isPublished ? "update" : "");
break;
case "r":
blogAction = (isPublished ? "remove" : "");
break;
}
if (blogAction != "")
{
blog.parameters.action = blogAction;
blog.execute(node);
result = blog.parameters["result"];
}
}
}
return result;
}
function main(nodeRef, actionResult)
{
var pending = new Array(),
updates = new Array();
var article = {};
var person;
var space = search.findNode(nodeRef);
if (space != null)
{
for each(node in space.children)
{
person = people.getPerson(node.properties["cm:creator"]);
article =
{
"node": node,
"person": person
};
if ((node.hasAspect("blg:blogPost")) && (node.properties["blg:published"] == true))
{
if (node.properties["cm:modified"] - node.properties["blg:lastUpdate"] > 5000)
{
updates.push(article);
}
}
else
{
pending.push(article);
}
}
}
var blogSpace =
{
"actionResult": actionResult,
"pending": pending,
"updates": updates
};
return blogSpace;
}

View File

@@ -0,0 +1,8 @@
<webscript>
<shortname>Blog Summary</shortname>
<description>Collaboration Blog Summary</description>
<url>/collaboration/blogSummary?nodeRef={noderef}</url>
<format default="html"/>
<authentication>user</authentication>
<transaction>required</transaction>
</webscript>

View File

@@ -0,0 +1,2 @@
${blogSummary.numUpdates} articles need updating<br>
${blogSummary.numPending} articles pending

View File

@@ -0,0 +1,53 @@
/*
* blogSummary
*
* Inputs:
* nodeRef = blog space nodeRef
*
* Outputs:
* blogSummary - object containing
* numUpdates - number of articles updated since being published
* numPending - number of unpublished articles
*/
model.blogSummary = main(args["nodeRef"]);
function main(nodeRef)
{
var numUpdates = 0,
numPending = 0;
if (nodeRef != null)
{
var space = search.findNode(nodeRef);
if (space != null)
{
// generate lucene PATH to get all child documents
var path = space.qnamePath + "//*";
var nodes = search.luceneSearch("+PATH:\"" + path + "\"" +
" +(@cm\\:content.mimetype:\"text/plain\" OR @cm\\:content.mimetype:\"text/html\")");
for each(node in nodes)
{
if ((node.hasAspect("blg:blogPost")) && (node.properties["blg:published"] == true))
{
if (node.properties["cm:modified"] - node.properties["blg:lastUpdate"] > 5000)
{
++numUpdates;
}
}
else
{
++numPending;
}
}
}
}
var blogSummary =
{
"numUpdates": numUpdates,
"numPending": numPending
};
return blogSummary;
}

View File

@@ -0,0 +1,8 @@
<webscript>
<shortname>Calendar View</shortname>
<description>Collaboration Calendar Space view</description>
<url>/collaboration/calendar?nodeRef={noderef}</url>
<format default="html"/>
<authentication>user</authentication>
<transaction>required</transaction>
</webscript>

View File

@@ -0,0 +1,219 @@
<!-- Calendar Code v2.1 -->
<link rel="stylesheet" type="text/css" href="/alfresco/yui/example.css">
<link rel="stylesheet" type="text/css" href="/alfresco/yui/assets/tabview.css">
<link rel="stylesheet" type="text/css" href="/alfresco/yui/assets/round_tabs.css">
<link type="text/css" rel="stylesheet" href="/alfresco/yui/fonts.css"/>
<link type="text/css" rel="stylesheet" href="/alfresco/yui/assets/calendar.css"/>
<link type="text/css" rel="stylesheet" href="/alfresco/yui/Custom.css"/>
<script type="text/javascript" src="/alfresco/yui/yahoo.js"></script>
<script type="text/javascript" src="/alfresco/yui/event.js"></script>
<script type="text/javascript" src="/alfresco/yui/dom.js"></script>
<script type="text/javascript" src="/alfresco/yui/element-beta.js"></script>
<script type="text/javascript" src="/alfresco/yui/tabview.js"></script>
<script type="text/javascript" src="/alfresco/yui/yahoo-min.js" ></script>
<script type="text/javascript" src="/alfresco/yui/event-min.js" ></script>
<script type="text/javascript" src="/alfresco/yui/connection-min.js" ></script>
<script type="text/javascript" src="/alfresco/yui/calendar.js"></script>
<script type="text/javascript">
var tabView;
var spaceRef = '${args["nodeRef"]}';
function showColorWindow(txtColor)
{
win2 = window.open("/alfresco/images/calendar/color_picker.htm", "colorwind", "height=160,width=200,status=0");
win2.colorControl = txtColor;
}
</script>
<script type="text/javascript" src="/alfresco/scripts/calendar/calendarScripts.js" ></script>
<script type="text/javascript" src="/alfresco/scripts/calendar/initializeEventDetails.js" ></script>
<script type="text/javascript" src="/alfresco/scripts/calendar/saveEventDetails.js" ></script>
<script type="text/javascript" src="/alfresco/scripts/calendar/eventRetrieversMonthView.js" ></script>
<script type="text/javascript" src="/alfresco/scripts/calendar/eventRetrieversWeekView.js" ></script>
<script type="text/javascript" src="/alfresco/scripts/calendar/captureWeekViewEvents.js" ></script>
<script type="text/javascript" src="/alfresco/scripts/calendar/eventRetrieversDayView.js" ></script>
<script type="text/javascript" src="/alfresco/scripts/calendar/captureDayViewEvents.js" ></script>
<script type="text/javascript" src="/alfresco/scripts/calendar/eventCaptureHandlers.js" ></script>
<script type="text/javascript" src="/alfresco/scripts/calendar/editEventHandlers.js" ></script>
<script type="text/javascript" src="/alfresco/scripts/calendar/calendarSearch.js" ></script>
<script type="text/javascript" src="/alfresco/scripts/calendar/calendarUtil.js" ></script>
<script type="text/javascript" src="/alfresco/scripts/calendar/ColorPicker2.js" ></script>
<link type="text/css" rel="stylesheet" href="/alfresco/css/calendar/calendarMain.css"/>
<style type="text/css">
#demo .yui-content { padding:1em; } /* pad content container */
</style>
<div id="divCalendarMainContainer" class="yui-navset">
<ul class="yui-nav">
<li class="selected" id="lnkShowMonthEvents"><a href="#showMonthEvents"><em>Month</em></a></li>
<li id="lnkShowWeekEvents"><a href="#showWeekEvents"><em>Week</em></a></li>
<li id="lnkShowDayEvents"><a href="#showDayEvents"><em>Day</em></a></li>
<li id="lnkEventCapture"><a href="#eventCapture"><em>Create New Event</em></a></li>
<li id="lnkCalendarSubscribe"><a href="#calendarSubscribe"><em>Calendar Admin</em></a></li>
</ul>
<div class="yui-content">
<!-- Start Show and Capture Month View Events -->
<div id="showMonthEvents">
<BR>
<div style="text-align:center">
<img src="/alfresco/yui/img/prev.gif" title="Previous Year" onclick="addYearsMonthView(-1)" style="cursor:pointer" />
<img src="/alfresco/yui/img/prevMinor.gif" title="Previous Month" onclick="addMonthsMonthView(-1)" style="cursor:pointer" />
<img src="/alfresco/yui/img/now.gif" title="This Month" onclick="setCurrentMonthView(event)" style="cursor:pointer" />
<img src="/alfresco/yui/img/nextMinor.gif" title="Next Month" onclick="addMonthsMonthView(1)" style="cursor:pointer"/>
<img src="/alfresco/yui/img/next.gif" title="Next Year" onclick="addYearsMonthView(1)" style="cursor:pointer" />
<span id="spnCurrentDisplayMonth"></span>
</div>
<table id="tabMonthViewMain" border="0" cellpadding="2" cellspacing="2" width="100%">
<tr>
<th>
<span id="spnCurrentDisplayMonthMonthView"></span>
</th>
</tr>
<tr>
<td>
<div id="divMonthView"></div>
</td>
</tr>
</table>
</div>
<!-- Start Show and Capture Month View Events -->
<!-- Start Show and Capture Week View Events -->
<div id="showWeekEvents">
<BR>
<div style="text-align:center">
<img src="/alfresco/yui/img/prevMinor.gif" title="Previous Week" onclick="callLoadersWeekView(-7)" style="cursor:pointer" />
<img src="/alfresco/yui/img/now.gif" title="This Week" onclick="callLoadersWeekView(0)" style="cursor:pointer" />
<img src="/alfresco/yui/img/nextMinor.gif" title="Next Week" onclick="callLoadersWeekView(7)" style="cursor:pointer" />
<span id="spnCurrentDisplayWeek"></span>
</div>
<table id="tabWeekViewMain" border="0" cellpadding="2" cellspacing="2" width="100%">
<tr>
<th>
<span id="spnCurrentDisplayWeekWeekView"></span>
</th>
</tr>
<tr>
<td>
<div id="divWeekView">
</div>
</td>
</tr>
</table>
</div>
<!-- End Show and Capture Week View Events -->
<!-- Start Show and Capture Day View Events -->
<div id="showDayEvents">
<BR>
<div style="text-align:center">
<img src="/alfresco/yui/img/prevMinor.gif" title="Previous Day" onclick="callLoadersDayView(-1)" style="cursor:pointer" />
<img src="/alfresco/yui/img/now.gif" title="Today" onclick="callLoadersDayView(0)" style="cursor:pointer" />
<img src="/alfresco/yui/img/nextMinor.gif" title="Next Day" onclick="callLoadersDayView(1)" style="cursor:pointer" />
<span id="spnCurrentDisplayDay"></span>
</div>
<table id="tabDayViewMain" border="0" cellpadding="2" cellspacing="2" width="100%">
<tr>
<th>
<span id="spnCurrentDisplayDayDayView"></span>
</th>
</tr>
<tr>
<td>
<div id="divDayView">
</div>
</td>
</tr>
</table>
</div>
<!-- End Show and Capture Day View Events -->
<!-- Start Create/Edit Events -->
<div id="eventCapture">
<BR>
<div id="cal1Container" style="display:none; position:absolute"></div>
<input type="hidden" id="hidFromDate"/>
<input type="hidden" id="hidToDate"/>
<table id="tabEventCapture" border="0" cellpadding="4" cellspacing="1" width="100%">
<thead>
<tr>
<th colspan="2">Enter Event Information<span id="spnEventCapture"></span></th>
</tr>
</thead>
<tr class='alternateRow'>
<td>What *</td>
<td><input type="text" id="txtWhatEvent" /></td>
</tr>
<tr>
<td>When *</td>
<td>
<input type="text" id="txtFromDate" readonly="readonly" onfocus="ToggleCalendar(1, this)" />
<select id="lstFromTime"></select>
to
<input type="text" id="txtToDate" readonly="readonly" onfocus="ToggleCalendar(1, this)" />
<select id="lstToTime"></select>
</td>
</tr>
<tr class='alternateRow'>
<td>Where</td>
<td><input type="text" id="txtWhereEvent" /></td>
</tr>
<tr>
<td>Description</td>
<td><textarea id="txtDescriptionEvent" rows="4" cols="50"></textarea></td>
</tr>
<tr style="display: none;">
<td>Color</td>
<td><input type="text" size="10" maxlength="7" id="txtColor" readonly="readonly"><input type="button" class="buttonStyle" value="Color picker" onclick="showColorWindow('txtColor')"></td>
</tr>
<tr class='alternateRow'>
<td></td>
<td><input class="buttonStyle" type="button" id="btnSubmit" value="Submit" onclick="saveCalendarEvent(false)" /><input class="buttonStyle" type="button" id="btnReset" value="New" onclick="resetEventDetails()" /><input class="buttonStyle" type="button" id="btnDelete" value="Delete" onclick="saveCalendarEvent(true)" /></td>
</tr>
</table>
</div>
<!-- End Create/Edit Events -->
<!-- Start calendar subscription -->
<div id="calendarSubscribe">
<script language="JavaScript">
function colorHandler(o) {
// Success
};
function colorFailureHandler(o) {
alert("Failed to set color");
};
// Color picker functions
function pickColor(color) {
document.getElementById("color2").style.background = color;
// Update the calendar color property
var params = new Array();
params[0] = "ref=" + spaceRef;
params[1] = "color=" + escape(color);
var url = getContextPath() + "/wcservice/camden/setColor";
var colorCallback = {
success:colorHandler,
failure:colorFailureHandler,
argument: { foo:"foo", bar:"bar" }
};
var request = YAHOO.util.Connect.asyncRequest("POST", url + "?" + params.join("&"), colorCallback, null);
};
var picker = new ColorPicker();
</script>
</div> <!-- end of calendar subscription -->
</div>
</div>

View File

@@ -0,0 +1,8 @@
<webscript>
<shortname>Calendar Summary</shortname>
<description>Collaboration Calendar Summary</description>
<url>/collaboration/calendarSummary?nodeRef={noderef}</url>
<format default="html"/>
<authentication>user</authentication>
<transaction>required</transaction>
</webscript>

View File

@@ -0,0 +1,2 @@
${calendarSummary.thisWeek} events this week<br>
${calendarSummary.nextWeek} events next week

View File

@@ -0,0 +1,56 @@
/*
* calendarSummary
*
* Inputs:
* nodeRef = Calendar space nodeRef
*
* Outputs:
* calendarSummary - object containing
* eventsthis - Number of events occuring this
* eventsTomorrow - Number of events occuring tomorrow
*/
model.calendarSummary = main(args["nodeRef"]);
function main(nodeRef)
{
var thisWeek = 0,
nextWeek = 0;
if (nodeRef != null)
{
var calSpace = search.findNode(nodeRef);
if (calSpace != null)
{
// generate lucene PATH to calendar events
var path = calSpace.qnamePath + "/cm:CalEvents/*";
// find the events scheduled for this week
var fromDate = new Date();
// go back to previous Sunday
fromDate.setDate(fromDate.getDate() - fromDate.getDay());
var fromQuery = fromDate.getFullYear() + "\\-" + (fromDate.getMonth()+1) + "\\-" + fromDate.getDate();
var toDate = new Date();
toDate.setDate(fromDate.getDate() + 7);
var toQuery = toDate.getFullYear() + "\\-" + (toDate.getMonth()+1) + "\\-" + toDate.getDate();
var events = search.luceneSearch("+PATH:\"" + path + '"' +
" +@ia\\:fromDate:[" + fromQuery + "T00\\:00\\:00 TO " + toQuery + "T23\\:59\\:59]");
thisWeek = events.length;
// increment to and from dates to cover next week
fromDate.setDate(toDate.getDate());
fromQuery = fromDate.getFullYear() + "\\-" + (fromDate.getMonth()+1) + "\\-" + fromDate.getDate();
toDate.setDate(toDate.getDate() + 7);
toQuery = toDate.getFullYear() + "\\-" + (toDate.getMonth()+1) + "\\-" + toDate.getDate();
events = search.luceneSearch("+PATH:\"" + path + '"' +
" +@ia\\:fromDate:[" + fromQuery + "T00\\:00\\:00 TO " + toQuery + "T23\\:59\\:59]");
nextWeek = events.length;
}
}
var calendarSummary =
{
"thisWeek": thisWeek,
"nextWeek": nextWeek
};
return calendarSummary
}

View File

@@ -0,0 +1,8 @@
<webscript>
<shortname>Colleague Presence Custom View</shortname>
<description>Collaboration Colleague Presence view</description>
<url>/collaboration/colleaguePresence?nodeRef={noderef}</url>
<format default="html"/>
<authentication>user</authentication>
<transaction>required</transaction>
</webscript>

View File

@@ -0,0 +1,119 @@
<script type="text/javascript" src="${url.context}/scripts/ajax/project_presence.js"></script>
<div class="collabHeader">
<span>
<img id="refreshColleagues" src="${url.context}/images/icons/reset.gif" align="top" alt="Refresh">
Colleagues Online
</span>
</div>
<div class="colleagueList" rel="${colleaguePresence.colleagues?size}">
<div id="colleaguesOnline">
</div>
<div id="colleaguesNotOnline">
<#list colleaguePresence.colleagues?keys as key>
<#assign c = colleaguePresence.colleagues[key]>
<div class="colleagueRow"<#if c.nodeRef = colleaguePresence.self.nodeRef>rel="self"</#if>>
<div class="colleagueAvatar">
<#if (c.assocs["cm:avatar"]?exists)>
<#assign avatarURL = c.assocs["cm:avatar"][0].url>
<#else>
<#assign avatarURL = "images/icons/default_avatar.png">
</#if>
<img src="${url.context}/${avatarURL}" height="48" width="48" alt="avatar">
<div class="colleaguePresence" rel="${c.properties["presenceProvider"]!""}|${c.properties["presenceUsername"]!""}">
</div>
</div>
<div class="colleagueDetails">
<div class="colleagueName">${c.properties["firstName"]!""} ${c.properties["lastName"]!""}</div>
<div class="colleagueDetail">${c.properties["jobtitle"]!""}</div>
<div class="colleagueDetail">${c.properties["location"]!""}</div>
</div>
</div>
</#list>
</div>
</div>
<div class="collabFooter">
<span>&nbsp;</span>
</div>
<style>
/* Colleague Status */
#refreshColleagues {
cursor: pointer;
}
.colleagueList {
border-left: 1px solid #CACFD3;
border-right: 1px solid #CACFD3;
height: 297px;
overflow-x: hidden;
overflow-y: scroll;
}
#colleaguesOnline {
float: left;
}
#colleaguesNotOnline {
float: left;
}
.colleagueRow {
clear: both;
float: left;
min-height: 56px;
padding: 8px 8px 0px;
width: 208px;
}
.colleagueAvatar {
float: left;
position: relative;
height: 48px;
width: 48px;
padding-right: 8px;
}
.colleaguePresence {
background-image: url(${url.context}/images/icons/ajax_anim.gif);
position: absolute;
left: 32px;
top: 32px;
height: 16px;
width: 16px;
}
.colleaguePresence.skype-online
{
background-image: url(${url.context}/images/icons/presence_skype_online.png) !important;
}
.colleaguePresence.skype-offline
{
background-image: url(${url.context}/images/icons/presence_skype_offline.png) !important;
}
.colleaguePresence.yahoo-online
{
background-image: url(${url.context}/images/icons/presence_yahoo_online.png) !important;
}
.colleaguePresence.yahoo-offline
{
background-image: url(${url.context}/images/icons/presence_yahoo_offline.png) !important;
}
.colleaguePresence.unknown, .colleaguePresence.skype-unknown, .colleaguePresence.yahoo-unknown
{
background-image: url(${url.context}/images/icons/presence_status_unknown.png) !important;
}
.colleaguePresence.none
{
background-image: url(${url.context}/images/icons/presence_status_none.png) !important;
}
.colleagueDetails {
}
.colleagueName {
font-weight: bold;
}
.colleagueDetail {
}
</style>

View File

@@ -0,0 +1,68 @@
/*
* colleaguePresence
*
* Inputs:
* mandatory: nodeRef = parent space nodeRef
*
* Outputs: colleaguePresence - object containing presence data model
*/
model.colleaguePresence = main(args["nodeRef"]);
function main(nodeRef)
{
var space = search.findNode(nodeRef);
var colleagues = {};
if (space != null)
{
colleagues = parsePermissions(space);
}
var colleaguePresence =
{
"colleagues": colleagues,
"self": person
};
return colleaguePresence;
}
function parsePermissions(space)
{
var tokens, user, group;
var userHash = {};
try
{
for each(perm in space.permissions)
{
tokens = perm.split(";");
if (tokens[0] == "ALLOWED")
{
if (("AllCollaboratorContributorCoordinatorEditor").indexOf(tokens[2]) != -1)
{
user = people.getPerson(tokens[1]);
if (user != null)
{
userHash[user.name] = user;
}
else
{
group = people.getGroup(tokens[1]);
if (group != null)
{
for each(user in people.getMembers(group))
{
userHash[user.name] = user;
}
}
}
}
}
}
}
catch (e)
{
}
return userHash;
}

View File

@@ -0,0 +1,8 @@
<webscript>
<shortname>DocLib Custom View</shortname>
<description>Collaboration Document Library view</description>
<url>/collaboration/docLibrary?nodeRef={noderef}</url>
<format default="html"/>
<authentication>user</authentication>
<transaction>required</transaction>
</webscript>

View File

@@ -0,0 +1,120 @@
<#assign doclib = companyhome.nodeByReference[args["nodeRef"]]>
<#assign datetimeformat="EEE, dd MMM yyyy HH:mm">
<div id="collabContainer">
<div class="collabHeader">
<span>Recent Changes</span>
</div>
<table width="100%" cellpadding="0" cellspacing="0">
<tr valign="top">
<td width="1" style="background-color:#b9bec4;"></td>
<td>
<div class="collabContent">
<#assign count=0>
<#list doclib.childrenByXPath[".//*[subtypeOf('cm:content')]"] as c>
<#assign count=count+1>
<#assign curl=url.serviceContext + c.serviceUrl>
<div class="collab${(count%2=0)?string("RowEven", "RowOdd")}">
<div style="float:left">
<a href="${curl}" target="new"><img src="${url.context}${c.icon32}" width="32" height="32" border="0" alt="${c.name?html}" title="${c.name?html}"></a>
</div>
<div style="margin-left:36px;padding: 4px 0px 4px 0px">
<div>
<div class="collabNodeActions">
<a href="${url.context}/n/showDocDetails/${c.nodeRef.storeRef.protocol}/${c.nodeRef.storeRef.identifier}/${c.id}" alt="Details" title="Details"><img src="${url.context}/images/icons/View_details.gif" border="0"></a>
</div>
<a class="collabNodeLink" href="${curl}" target="new">${c.name?html}</a>
</div>
<div>
<span class="metaData"><#if c.properties.description?exists>${c.properties.description?html}</#if></span>
</div>
<div>
<span class="metaTitle">Modified:</span>&nbsp;<span class="metaData">${c.properties.modified?string(datetimeformat)}</span>&nbsp;
<span class="metaTitle">Modified&nbsp;By:</span>&nbsp;<span class="metaData">${c.properties.modifier}</span>
<span class="metaTitle">Size:</span>&nbsp;<span class="metaData">${(c.size/1000)?string("0.##")}&nbsp;KB</span>
</div>
</div>
</div>
</#list>
</div>
</td>
<td width="1" style="background-color:#b9bec4;"></td>
</tr>
</table>
<div class="collabFooter">
<span>&nbsp;</span>
</div>
</div>
<style>
/* Main Container elements */
#collabContainer {
width: 100%;
}
.collabHeader {
background: url(${url.context}/images/parts/collab_topleft.png) no-repeat left top;
margin: 0px;
padding: 0px 0px 0px 2px;
}
.collabHeader span {
background: url(${url.context}/images/parts/collab_topright.png) no-repeat right top;
display: block;
float: none;
padding: 5px 15px 4px 6px;
font-weight: bold;
font-size: 10pt;
}
.collabContent {
padding: 8px;
}
.collabFooter {
background: url(${url.context}/images/parts/collab_bottomleft.png) no-repeat left top;
margin: 0px;
padding: 0px 0px 0px 4px;
}
.collabFooter span {
background: url(${url.context}/images/parts/collab_bottomright.png) no-repeat right top;
display: block;
float: none;
padding: 5px 15px 4px 6px;
}
div.collabRowOdd {
padding: 4px 2px;
}
div.collabRowEven {
padding: 4px 2px;
background-color: #F1F7FD;
}
span.metaTitle {
font-size: 11px;
color: #666677;
}
span.metaData {
font-size: 11px;
color: #515D6B;
}
a.collabNodeLink, a.collabNodeLink:hover {
font-size: 12px;
font-weight: bold;
}
div.collabNodeActions {
float: right;
padding: 0px 4px;
}
</style>

View File

@@ -0,0 +1,8 @@
<webscript>
<shortname>Doc Summary</shortname>
<description>Collaboration Doc Summary</description>
<url>/collaboration/docSummary?nodeRef={noderef}</url>
<format default="html"/>
<authentication>user</authentication>
<transaction>required</transaction>
</webscript>

View File

@@ -0,0 +1,2 @@
${docSummary.numNew} added in the last 7 days<br>
${docSummary.numModified} modified in the last 7 days

View File

@@ -0,0 +1,59 @@
/*
* docSummary
*
* Inputs:
* nodeRef = doc space nodeRef
*
* Outputs:
* docSummary - object containing
* numNew - number new documents added in the last 7 days
* numModified - number of documents modified in the last 7 days
*/
model.docSummary = main(args["nodeRef"]);
function main(nodeRef)
{
var numNew = 0,
numModified = 0;
if (nodeRef != null)
{
var space = search.findNode(nodeRef);
if (space != null)
{
// generate lucene PATH to get all child documents
var path = space.qnamePath + "//*";
var date = new Date();
var toQuery = date.getFullYear() + "\\-" + (date.getMonth()+1) + "\\-" + date.getDate();
date.setDate(date.getDate() - 7);
var fromQuery = date.getFullYear() + "\\-" + (date.getMonth()+1) + "\\-" + date.getDate();
// documents created in the last 7 days
var docs = search.luceneSearch("+PATH:\"" + path + "\"" +
" +@cm\\:created:[" + fromQuery + "T00\\:00\\:00 TO " + toQuery + "T23\\:59\\:59]");
numNew = docs.length;
// documents modified in the last 7 days
docs = search.luceneSearch("+PATH:\"" + path + "\"" +
" +@cm\\:modified:[" + fromQuery + "T00\\:00\\:00 TO " + toQuery + "T23\\:59\\:59]");
numModified = 0;
for each(doc in docs)
{
if (doc.properties["cm:modified"] - doc.properties["cm:created"] > 1000)
{
++numModified;
}
}
}
}
var docSummary =
{
"numNew": numNew,
"numModified": numModified
};
return docSummary;
}

View File

@@ -0,0 +1,8 @@
<webscript>
<shortname>Email Summary</shortname>
<description>Collaboration Email Summary</description>
<url>/collaboration/emailSummary?nodeRef={noderef}</url>
<format default="html"/>
<authentication>user</authentication>
<transaction>required</transaction>
</webscript>

View File

@@ -0,0 +1,2 @@
${emailSummary.numToday} e-mails have arrived today<br>
${emailSummary.numWeek} e-mails in the last 7 days

View File

@@ -0,0 +1,54 @@
/*
* emailSummary
*
* Inputs:
* nodeRef = email space nodeRef
*
* Outputs:
* emailSummary - object containing
* numToday - number of articles updated since being published
* numWeek - number of unpublished articles
*/
model.emailSummary = main(args["nodeRef"]);
function main(nodeRef)
{
var numToday = 0,
numWeek = 0;
if (nodeRef != null)
{
var space = search.findNode(nodeRef);
if (space != null)
{
// generate lucene PATH to get all child documents
var path = space.qnamePath + "//*";
var date = new Date();
var toQuery = date.getFullYear() + "\\-" + (date.getMonth()+1) + "\\-" + date.getDate();
var fromQuery = toQuery;
// emails today
var docs = search.luceneSearch("+PATH:\"" + path + "\"" +
" +@cm\\:created:[" + fromQuery + "T00\\:00\\:00 TO " + toQuery + "T23\\:59\\:59]");
numToday = docs.length;
date.setDate(date.getDate() - 7);
fromQuery = date.getFullYear() + "\\-" + (date.getMonth()+1) + "\\-" + date.getDate();
// documents modified in the last 7 days
docs = search.luceneSearch("+PATH:\"" + path + "\"" +
" +@cm\\:modified:[" + fromQuery + "T00\\:00\\:00 TO " + toQuery + "T23\\:59\\:59]");
numWeek = docs.length;
}
}
var emailSummary =
{
"numToday": numToday,
"numWeek": numWeek
};
return emailSummary;
}

View File

@@ -0,0 +1,8 @@
<webscript>
<shortname>Forum Summary</shortname>
<description>Collaboration Forum Summary</description>
<url>/collaboration/forumSummary?nodeRef={noderef}</url>
<format default="html"/>
<authentication>user</authentication>
<transaction>required</transaction>
</webscript>

View File

@@ -0,0 +1,2 @@
${forumSummary.numPosts} posts in the last 7 days<br>
${forumSummary.numTopics} new topics in the last 7 days

View File

@@ -0,0 +1,59 @@
/*
* forumSummary
*
* Inputs:
* nodeRef = forum space nodeRef
*
* Outputs:
* forumSummary - object containing
* numPosts - posts in last 7 days
* numTopics - new topics in last 7 days
*/
model.forumSummary = main(args["nodeRef"]);
function main(nodeRef)
{
var numPosts = 0,
numTopics = 0;
if (nodeRef != null)
{
var space = search.findNode(nodeRef);
if (space != null)
{
// generate lucene PATH to get forums
var path = space.qnamePath + "//*";
var date = new Date();
var toQuery = date.getFullYear() + "\\-" + (date.getMonth()+1) + "\\-" + date.getDate();
date.setDate(date.getDate() - 7);
var fromQuery = date.getFullYear() + "\\-" + (date.getMonth()+1) + "\\-" + date.getDate();
// posts created in the last 7 days
var docs = search.luceneSearch("+PATH:\"" + path + "\"" +
" +TYPE:\"{http://www.alfresco.org/model/forum/1.0}post\"" +
" +@cm\\:created:[" + fromQuery + "T00\\:00\\:00 TO " + toQuery + "T23\\:59\\:59]");
numPosts = docs.length;
// topics created in the last 7 days
docs = search.luceneSearch("+PATH:\"" + path + "\"" +
" +TYPE:\"{http://www.alfresco.org/model/forum/1.0}topic\"" +
" +@cm\\:created:[" + fromQuery + "T00\\:00\\:00 TO " + toQuery + "T23\\:59\\:59]");
numTopics = docs.length;
}
}
var forumSummary =
{
"numPosts": numPosts,
"numTopics": numTopics
};
return forumSummary;
}
// var query = "TYPE:\"{http://www.alfresco.org/model/content/1.0}person\"";
// {http://www.alfresco.org/model/forum/1.0}topic
// {http://www.alfresco.org/model/forum/1.0}post

View File

@@ -0,0 +1,14 @@
<webscript>
<!-- Details of the web script -->
<shortname>Gallery Sample Data</shortname>
<description>Returns data used to populate the Flex gallery sample.</description>
<!-- Web script URL's -->
<url>/collaboration/gallery/{noderef}</url>
<format default="xml">extension</format>
<authentication>user</authentication>
<transaction>required</transaction>
</webscript>

View File

@@ -0,0 +1,9 @@
var gallery = search.findNode(url.extension);
if (gallery == undefined || gallery.isContainer == false)
{
status.code = 404;
status.message = "Gallery " + url.extension + " not found.";
status.redirect = true;
}
model.gallery = gallery;

View File

@@ -0,0 +1,21 @@
<gallery>
<name>${gallery.name}</name>
<#list gallery.children as image>
<#if image.isDocument>
<image>
<url>${absurl(url.context)}${image.url}</url>
<#if image.properties["cm:title"]?exists>
<title>${image.properties["cm:title"]}</title>
<#else>
<title/>
</#if>
<#if image.properties["cm:description"]?exists>
<description>${image.properties["cm:description"]}</description>
<#else>
<description/>
</#if>
</image>
</#if>
</#list>
</gallery>

View File

@@ -0,0 +1,8 @@
<webscript>
<shortname>Gallery Summary</shortname>
<description>Collaboration Gallery Summary</description>
<url>/collaboration/gallerySummary?nodeRef={noderef}</url>
<format default="html"/>
<authentication>user</authentication>
<transaction>required</transaction>
</webscript>

View File

@@ -0,0 +1,2 @@
${gallerySummary.numNew} added in the last 7 days<br>
${gallerySummary.numTotal} images in this gallery

View File

@@ -0,0 +1,50 @@
/*
* gallerySummary
*
* Inputs:
* nodeRef = gallery space nodeRef
*
* Outputs:
* gallerySummary - object containing
* numNew - number of new images in the last 7 days
* numTotal - total number of images
*/
model.gallerySummary = main(args["nodeRef"]);
function main(nodeRef)
{
var numNew = 0,
numTotal = 0;
if (nodeRef != null)
{
var space = search.findNode(nodeRef);
if (space != null)
{
// generate lucene PATH to all gallery images
var path = space.qnamePath + "//*";
var date = new Date();
var toQuery = date.getFullYear() + "\\-" + (date.getMonth()+1) + "\\-" + date.getDate();
date.setDate(date.getDate() - 7);
var fromQuery = date.getFullYear() + "\\-" + (date.getMonth()+1) + "\\-" + date.getDate();
// images added in the last 7 days
var images = search.luceneSearch("+PATH:\"" + path + "\"" +
" +@cm\\:created:[" + fromQuery + "T00\\:00\\:00 TO " + toQuery + "T23\\:59\\:59]");
numNew = images.length;
// total images
images = search.luceneSearch("+PATH:\"" + path + "\"");
numTotal = images.length;
}
}
var gallerySummary =
{
"numNew": numNew,
"numTotal": numTotal
};
return gallerySummary;
}

View File

@@ -0,0 +1,8 @@
<webscript>
<shortname>Project Space Custom View</shortname>
<description>Collaboration Project Space Space view</description>
<url>/collaboration/projectSpace?nodeRef={noderef}</url>
<format default="html"/>
<authentication>user</authentication>
<transaction>required</transaction>
</webscript>

View File

@@ -0,0 +1,150 @@
<script type="text/javascript" src="${url.context}/scripts/ajax/project_space.js"></script>
<div class="collabHeader">
<span>
<img id="refreshProjectSpace" src="${url.context}/images/icons/reset.gif" align="top" alt="Refresh">
${projectSpace.title} Summary
</span>
</div>
<div class="collabContainer">
<table width="100%" cellpadding="0" cellspacing="0">
<tr valign="top">
<td width="1" style="background-color:#cacfd3;"></td>
<td>
<table width="100%" cellpadding="8" cellspacing="0">
<tr valign="top">
<td>
<#assign panelCount = 0>
<#list projectSpace.subSpaces?keys?sort as key>
<#assign node = projectSpace.subSpaces[key]>
<#assign summary = node.properties["cm:summaryWebscript"]!"">
<div class="projectSpace">
<span>
<a class="projectSpaceArrow" href="${url.context}${node.url}"><img src="${url.context}/images/parts/collab_arrow.png" height="16" width="16" alt=">"></a>
<div class="projectSpaceIcon">
<a href="${url.context}${node.url}"><img src="${url.context}${node.icon64}" height="64" width="64"></a>
</div>
<div><a class="projectSpaceTitle" href="${url.context}${node.url}">${node.name}</a></div>
<div class="projectSpaceSummary" rel="<#if summary != "">${url.context}${summary}?nodeRef=${node.nodeRef}</#if>"></div>
</span>
</div>
<#assign panelCount = panelCount + 1>
<#if (panelCount % 2 = 0)>
<div style="clear:left;"></div>
</#if>
</#list>
</td>
</tr>
</table>
</td>
<td width="1" style="background-color:#cacfd3;"></td>
</tr>
</table>
</div>
<div class="collabFooter">
<span>&nbsp;</span>
</div>
<style>
/* Main Container elements */
#projectContainer {
width: 100%;
}
#projectContainer a img {
border: none;
}
#projectSummary {
vertical-align: top;
}
#projectColleagues {
vertical-align: top;
width: 240px;
}
/* Project Summary */
.projectTitle {
font-family: "Trebuchet MS", Verdana, Helvetica, sans-serif;
font-size: medium;
font-weight: bold;
margin: -8px 0px 4px;
float: left;
}
.collabHeader {
background: url(${url.context}/images/parts/collab_topleft.png) no-repeat left top;
margin: 0px;
padding: 0px 0px 0px 2px;
}
.collabHeader span {
background: url(${url.context}/images/parts/collab_topright.png) no-repeat right top;
display: block;
float: none;
padding: 5px 15px 4px 6px;
font-weight: bold;
font-size: 10pt;
}
#refreshProjectSpace {
cursor: pointer;
}
.collabContainer {
min-height: 289px;
}
.projectSpace {
background: url(${url.context}/images/parts/collab_gradleft.png) no-repeat left top;
float: left;
margin: 1em 0px;
padding: 0px;
width: 50%;
}
.projectSpace span {
background: url(${url.context}/images/parts/collab_gradright.png) no-repeat right top;
display: block;
float: none;
margin: 0px 0px 0px 16px;
padding: 8px 0px 0px;
}
.projectSpaceArrow {
float: right;
margin: 0px 16px 0px 0px;
}
.projectSpaceIcon {
float: left;
padding-right: 8px;
}
a.projectSpaceTitle:link, a.projectSpaceTitle:visited {
font-weight: bold;
font-size: 10pt;
}
a.projectSpaceTitle:hover {
font-weight: bold;
font-size: 10pt;
text-decoration: underline;
}
.projectSpaceSummary {
margin: 0px 8px;
}
.collabFooter {
background: url(${url.context}/images/parts/collab_bottomleft.png) no-repeat left top;
margin: 0px;
padding: 0px 0px 0px 4px;
}
.collabFooter span {
background: url(${url.context}/images/parts/collab_bottomright.png) no-repeat right top;
display: block;
float: none;
padding: 5px 15px 4px 6px;
}
</style>

View File

@@ -0,0 +1,36 @@
/*
* projectSpace
*
* Inputs:
* mandatory: nodeRef = parent space nodeRef
*
* Outputs: projectSpace - object containing pproject space details
*/
model.projectSpace = main(args["nodeRef"]);
function main(nodeRef)
{
var title = "";
var subSpaces = {};
var space = search.findNode(nodeRef);
if (space != null)
{
title = space.name;
// Discover the nodeRef of each project subspace
for each(node in space.children)
{
if (node.hasAspect("{http://www.alfresco.org/model/content/1.0}projectsummary"))
{
subSpaces[node.name] = node;
}
}
}
var projectSpace =
{
"title": title,
"subSpaces": subSpaces
};
return projectSpace;
}

View File

@@ -0,0 +1,8 @@
<webscript>
<shortname>Tagging Actions</shortname>
<description>Add and remove tags to nodes</description>
<url>/collaboration/tagActions</url>
<format default="html"/>
<authentication>user</authentication>
<transaction>required</transaction>
</webscript>

View File

@@ -0,0 +1,52 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Tagging Test UI</title>
<style>
body {
font-family: Verdana, Helvetica, sans-serif;
font-size: 10pt;
}
.label {
float: left;
width: 10em;
}
.data {
float: left;
}
.field {
clear: left;
float: left;
padding: 8px;
}
.action {
color: green;
font-weight: bold;
float: left;
clear: both;
}
</style>
</head>
<body>
<h3>Tagging Test UI</h3>
<form action="${url.serviceContext}${url.match}" method="post">
<div class="field">
<span class="label">Space nodeRef:</span>
<span class="data"><input type="text" name="n" size="64" /><br />e.g. &quot;e3741425-35cf-11dc-9762-4b73d0280543&quot;</span>
</div>
<div class="field">
<span class="label">Tag:</span>
<span class="data"><input type="text" name="t" size="64" value="" /></span>
</div>
<div class="field">
<span><input type="submit" value="Add" name="add" /></span>
<span><input type="submit" value="Remove" name="remove" /></span>
</div>
</form>
</body>
</html>

View File

@@ -0,0 +1,8 @@
<webscript>
<shortname>Tagging Actions</shortname>
<description>Add and remove tags to nodes</description>
<url>/collaboration/tagActions</url>
<format default="html"/>
<authentication>user</authentication>
<transaction>required</transaction>
</webscript>

View File

@@ -0,0 +1,5 @@
{
"statusString":"${tagActions.resultString}",
"statusCode":${tagActions.resultCode?string},
"newTag":"${tagActions.newTag?string}"
}

View File

@@ -0,0 +1,150 @@
model.tagActions = tagActions(args.a, args.n, args.t);
function tagActions(action, nodeId, tagName)
{
var resultString = "Action failed";
var resultCode = false;
var node = null;
var newTag = null;
var newTagNodeRef = "";
if ((tagName != "") && (tagName != null))
{
tagName = tagName.toLowerCase();
if (action == "add")
{
// Make sure the tag is in the repo
newTag = createTag(tagName);
if (newTag != null)
{
resultString = "Tag added";
resultCode = true;
newTagNodeRef = newTag.nodeRef.toString();
}
else
{
resultString = "Tag '" + tagName + "' not indexed";
}
}
// Adding/removing the tag to/from a node?
if ((nodeId != "") && (nodeId != null))
{
var node = search.findNode("workspace://SpacesStore/" + nodeId);
if (node != null)
{
try
{
var tags;
if (action == "add")
{
// Must have newTag node
if (newTag != null)
{
resultString = "Already tagged with '" + tagName + "'";
tags = node.properties["cm:taggable"];
if (tags == null)
{
tags = new Array();
}
// Check node doesn't already have this tag
var hasTag = false;
for each (tag in tags)
{
if (tag != null)
{
if (tag.name == tagName)
{
hasTag = true;
break;
}
}
}
if (!hasTag)
{
// Add it to our node
tags.push(newTag);
tagsArray = new Array();
tagsArray["cm:taggable"] = tags;
node.addAspect("cm:taggable", tagsArray);
resultString = "Document tagged";
resultCode = true;
}
}
}
else if (action == "remove")
{
resultString = "Could not remove tag";
var oldTags = node.properties["cm:taggable"];
if (oldTags == null)
{
oldTags = new Array();
}
tags = new Array();
// Find this tag
for each (tag in oldTags)
{
if (tag != null)
{
if (tag.name != tagName)
{
tags.push(tag);
}
}
}
// Removed tag?
if (oldTags.length > tags.length)
{
tagsArray = new Array();
tagsArray["cm:taggable"] = tags;
node.addAspect("cm:taggable", tagsArray);
resultString = "Tag removed";
resultCode = true;
}
else
{
resultString = "Not tagged with '" + tagName + "'";
}
}
else
{
resultString = "Unknown action";
}
}
catch(e)
{
resultString = "Action failed due to exception [" + e.toString() + "]";
}
}
}
}
var result =
{
"resultString": resultString,
"resultCode": resultCode,
"newTag": newTagNodeRef
};
return result;
}
/*
* Create a new tag if the passed-in one doesn't exist
*/
function createTag(tagName)
{
var existingTags = classification.getRootCategories("cm:taggable");
for each (existingTag in existingTags)
{
if (existingTag.name == tagName)
{
return existingTag;
}
}
var tagNode = classification.createRootCategory("cm:taggable", tagName);
return tagNode;
}

View File

@@ -0,0 +1,8 @@
<webscript>
<shortname>Tagging Query</shortname>
<description>Query tag usage</description>
<url>/collaboration/tagQuery</url>
<format default="html"/>
<authentication>user</authentication>
<transaction>required</transaction>
</webscript>

View File

@@ -0,0 +1,13 @@
{
"countMin": "${tagQuery.countMin}",
"countMax": "${tagQuery.countMax}",
"tags":
<#assign n=0>
[
<#list tagQuery.tags as tag>
<#if (n > 0)>,</#if>
{"name": "${tag.name}", "count": "${tag.count}"}
<#assign n=n+1>
</#list>
]
}

View File

@@ -0,0 +1,104 @@
model.tagQuery = tagQuery(args["n"], args["m"]);
function tagQuery(nodeRef, maxResults)
{
var tags = new Array();
var countMin = Number.MAX_VALUE,
countMax = 0;
/* nodeRef input */
var node = null;
if ((nodeRef != null) && (nodeRef != ""))
{
node = search.findNode(nodeRef);
}
if (node == null)
{
node = companyhome;
}
/* maxResults input */
if ((maxResults == null) || (maxResults == ""))
{
maxResults = -1;
}
/* Query for tagged node(s) */
var query = "PATH:\"" + node.qnamePath;
if (node.isContainer)
{
query += "//*";
}
query += "\" AND ASPECT:\"{http://www.alfresco.org/model/content/1.0}taggable\"";
var taggedNodes = search.luceneSearch(query);
if (taggedNodes.length == 0)
{
countMin = 0;
}
else
{
/* Build a hashtable of tags and tag count */
var tagHash = {};
var count;
for each (taggedNode in taggedNodes)
{
for each(tag in taggedNode.properties["cm:taggable"])
{
if (tag != null)
{
count = tagHash[tag.name];
tagHash[tag.name] = count ? count+1 : 1;
}
}
}
/* Convert the hashtable into an array of objects */
for (key in tagHash)
{
tag =
{
name: key,
count: tagHash[key],
toString: function()
{
return this.name;
}
};
tags.push(tag);
}
/* Sort the results by count (descending) */
tags.sort(sortByCountDesc);
/* Trim the results to maxResults if specified */
if (maxResults > -1)
{
tags = tags.slice(0, maxResults);
}
/* Calculate the min and max tag count values */
for each(tag in tags)
{
countMin = Math.min(countMin, tag.count);
countMax = Math.max(countMax, tag.count);
}
/* Sort the results by tag name (ascending) */
tags.sort();
}
var results =
{
"countMin": countMin,
"countMax": countMax,
"tags": tags
};
return results;
}
function sortByCountDesc(a, b)
{
return (b.count - a.count);
}

View File

@@ -0,0 +1,14 @@
<webscript>
<!-- Details of the web script -->
<shortname>Views the specified gallery</shortname>
<description>Views the specified gallery.</description>
<!-- Web script URL's -->
<url>/collaboration/gallery/view/{noderef}</url>
<format default="html">extension</format>
<authentication>user</authentication>
<transaction>required</transaction>
</webscript>

View File

@@ -0,0 +1,28 @@
<#assign dataURL=absurl(url.context) + "/wcs/collaboration/gallery/" + path>
<html lang="en">
<head>
</head>
<body scroll='no' height="100%" width="100%">
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
id="Flexbook" width="100%" height="100%"
codebase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab">
<param name="movie" value="/alfresco/swf/Flexbook.swf?dataURL=${dataURL?url}&ticket=${ticket}" />
<param name="quality" value="high" />
<param name="bgcolor" value="#282828" />
<param name="allowScriptAccess" value="sameDomain" />
<embed src="/alfresco/swf/Flexbook.swf?dataURL=${dataURL?url}&ticket=${ticket}" quality="high" bgcolor="#000000"
width="100%" height="310" name="Flexbook" align="middle"
play="true"
loop="false"
quality="high"
allowScriptAccess="sameDomain"
type="application/x-shockwave-flash"
pluginspage="http://www.adobe.com/go/getflashplayer">
</embed>
</object>
</body>
</html>

View File

@@ -0,0 +1,3 @@
model.ticket = session.ticket;
model.path = url.extension;

View File

@@ -0,0 +1,6 @@
<webscript>
<shortname>Javascript Debugger</shortname>
<description>Javascript Debugger</description>
<url>/api/javascript/debugger</url>
<authentication>admin</authentication>
</webscript>

View File

@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Alfresco Javascript Debugger</title>
<link rel="stylesheet" href="${url.context}/css/main.css" TYPE="text/css">
</head>
<body>
<form action="${url.serviceContext}${url.match}" method="post">
<input type="hidden" name="visible" value="<#if visible>false<#else>true</#if>">
<table>
<tr>
<td><img src="${url.context}/images/logo/AlfrescoLogo32.png" alt="Alfresco" /></td>
<td><nobr><span class="mainTitle">Alfresco Javascript Debugger</span></nobr></td>
</tr>
<tr><td><td>Alfresco ${server.edition} v${server.version}
<tr><td><td>Currently <#if visible>enabled<#else>disabled</#if>.
<input type="submit" name="submit" value="<#if visible>Disable<#else>Enable</#if>">
</table>
</form>
</body>
</html>

View File

@@ -0,0 +1,6 @@
<webscript>
<shortname>Javascript Debugger Maintenance</shortname>
<description>Javascript Debugger Maintenance</description>
<url>/api/javascript/debugger?active={active?}</url>
<authentication>admin</authentication>
</webscript>

View File

@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Alfresco Javascript Debugger</title>
<link rel="stylesheet" href="${url.context}/css/main.css" TYPE="text/css">
</head>
<body>
<form action="${url.serviceContext}${url.match}" method="post">
<input type="hidden" name="visible" value="<#if visible>false<#else>true</#if>">
<table>
<tr>
<td><img src="${url.context}/images/logo/AlfrescoLogo32.png" alt="Alfresco" /></td>
<td><nobr><span class="mainTitle">Alfresco Javascript Debugger</span></nobr></td>
</tr>
<tr><td><td>Alfresco ${server.edition} v${server.version}
<tr><td><td>Currently <#if visible>enabled<#else>disabled</#if>.
<input type="submit" name="submit" value="<#if visible>Disable<#else>Enable</#if>">
</table>
</form>
</body>
</html>

View File

@@ -0,0 +1,7 @@
<webscript>
<shortname>Document Actions (Office Add-In)</shortname>
<description>Used by the Office Add-In to perform actions on managed documents</description>
<url>/office/docActions</url>
<authentication>user</authentication>
<transaction>required</transaction>
</webscript>

View File

@@ -0,0 +1,4 @@
{
"statusString":"${resultString}",
"statusCode":${resultCode?string}
}

View File

@@ -0,0 +1,158 @@
// Client has requested server-side action
/* Inputs */
var runAction = args.a;
/* Outputs */
var resultString = "Action failed",
resultCode = false;
// Is this action targetting a document?
var docNodeId = args.n;
if ((docNodeId != "") && (docNodeId != null))
{
var docNode = search.findNode("workspace://SpacesStore/" + docNodeId);
if (docNode != null && docNode.isDocument)
{
try
{
if (runAction == "makepdf")
{
resultString = "Could not convert document";
var nodeTrans = docNode.transformDocument("application/pdf");
if (nodeTrans != null)
{
resultString = "Document converted";
resultCode = true;
}
}
else if (runAction == "delete")
{
resultString = "Could not delete document";
if (docNode.remove())
{
resultString = "Document deleted";
resultCode = true;
}
}
else if (runAction == "checkout")
{
var workingCopy = docNode.checkout();
if (workingCopy != null)
{
resultString = "Document checked out";
resultCode = true;
}
}
else if (runAction == "checkin")
{
var originalDoc = docNode.checkin();
if (originalDoc != null)
{
resultString = "Document checked in";
resultCode = true;
}
}
else if (runAction == "makeversion")
{
resultString = "Could not version document";
if (docNode.addAspect("cm:versionable"))
{
resultString = "Document versioned";
resultCode = true;
}
}
else if (runAction == "workflow")
{
var workflowType = "jbpm$wf:" + args.wt;
var assignTo = people.getPerson(args.at);
var dueDate = new Date(args.dd);
var description = args.desc;
var workflow = actions.create("start-workflow");
workflow.parameters.workflowName = workflowType;
workflow.parameters["bpm:workflowDescription"] = description;
workflow.parameters["bpm:assignee"] = assignTo;
if ((args.dd) && (args.dd != ""))
{
workflow.parameters["bpm:workflowDueDate"] = dueDate;
}
workflow.execute(docNode);
resultString = "New workflow started";
resultCode = true;
}
else if (runAction == "test")
{
resultString = "Tested ok.";
resultCode = true;
}
else
{
resultString = "Unknown action";
}
}
catch(e)
{
resultString = "Action failed due to exception";
}
}
}
else // Non document-based actions
{
try
{
if (runAction == "newspace")
{
resultString = "Could not create space";
var parentNodeId = args.p,
spaceName = args.sn,
spaceTitle = (args.st == "undefined") ? "" : args.st,
spaceDescription = (args.sd == "undefined") ? "" : args.sd,
templateId = args.t;
var nodeNew;
if ((spaceName == null) || (spaceName == ""))
{
resultString = "Space must have a Name";
}
else
{
var nodeParent = search.findNode("workspace://SpacesStore/" + parentNodeId);
// Copy from template?
if ((templateId != null) && (templateId != ""))
{
nodeTemplate = search.findNode("workspace://SpacesStore/" + templateId);
nodeNew = nodeTemplate.copy(nodeParent, true);
nodeNew.name = spaceName;
}
else
{
nodeNew = nodeParent.createFolder(spaceName);
}
// Always add title & description, default icon
nodeNew.properties["cm:title"] = spaceTitle;
nodeNew.properties["cm:description"] = spaceDescription;
nodeNew.properties["app:icon"] = "space-icon-default";
nodeNew.save();
// Add uifacets aspect for the web client
nodeNew.addAspect("app:uifacets");
if (nodeNew != null)
{
resultString = "New space created";
resultCode = true;
}
}
}
else
{
resultString = "Unknown action";
}
}
catch(e)
{
resultString = "Action failed due to exception";
}
}
model.resultString = resultString;
model.resultCode = resultCode;

View File

@@ -0,0 +1,7 @@
<webscript>
<shortname>Document Details (Office Add-In)</shortname>
<description>Generate the Office Add-In Document Details page</description>
<url>/office/documentDetails?p={path?}</url>
<authentication>user</authentication>
<transaction>required</transaction>
</webscript>

View File

@@ -0,0 +1,263 @@
<#assign doc_actions="${url.serviceContext}/office/docActions">
<#if args.p?exists><#assign path=args.p><#else><#assign path=""></#if>
<#if args.e?exists><#assign extn=args.e><#else><#assign extn="doc"></#if><#assign extnx=extn+"x">
<#if args.n?exists><#assign nav=args.n><#else><#assign nav=""></#if>
<#-- resolve the path (from Company Home) into a node -->
<#if companyhome.childByNamePath[path]?exists>
<#assign d=companyhome.childByNamePath[path]>
<#else>
<#assign d=companyhome>
</#if>
<#assign defaultQuery="?p=" + path?url + "&e=" + extn + "&n=" + nav>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>${message("office.title.document_details")}</title>
<link rel="stylesheet" type="text/css" href="${url.context}/css/office.css" />
<!--[if IE 6]>
<link rel="stylesheet" type="text/css" href="${url.context}/css/office_ie6.css" />
<![endif]-->
<script type="text/javascript" src="${url.context}/scripts/ajax/mootools.v1.11.js"></script>
<script type="text/javascript" src="${url.context}/scripts/office/office_addin.js"></script>
<script type="text/javascript" src="${url.context}/scripts/office/doc_details.js"></script>
<script type="text/javascript">//<![CDATA[
OfficeAddin.defaultQuery = '${defaultQuery}';
//]]></script>
</head>
<body>
<div class="tabBar">
<ul>
<li><a title="${message("office.title.my_alfresco")}" href="${url.serviceContext}/office/myAlfresco${defaultQuery?html}"><span><img src="${url.context}/images/office/my_alfresco.gif" alt="${message("office.title.my_alfresco")}" /></span></a></li>
<li><a title="${message("office.title.navigation")}" href="${url.serviceContext}/office/navigation${defaultQuery?html}"><span><img src="${url.context}/images/office/navigator.gif" alt="${message("office.title.navigation")}" /></span></a></li>
<li><a title="${message("office.title.search")}" href="${url.serviceContext}/office/search${defaultQuery?html}"><span><img src="${url.context}/images/office/search.gif" alt="${message("office.title.search")}" /></span></a></li>
<li id="current"><a title="${message("office.title.document_details")}" href="${url.serviceContext}/office/documentDetails${defaultQuery?html}"><span><img src="${url.context}/images/office/document_details.gif" alt="${message("office.title.document_details")}" /></span></a></li>
<li><a title="${message("office.title.my_tasks")}" href="${url.serviceContext}/office/myTasks${defaultQuery?html}"><span><img src="${url.context}/images/office/my_tasks.gif" alt="${message("office.title.my_tasks")}" /></span></a></li>
<li><a title="${message("office.title.document_tags")}" href="${url.serviceContext}/office/tags${defaultQuery?html}"><span><img src="${url.context}/images/office/tag.gif" alt="${message("office.title.document_tags")}" /></span></a></li>
</ul>
</div>
<div class="header">Current Document Details</div>
<div class="containerMedium">
<div id="nonStatusText">
<table width="265">
<tbody>
<tr>
<td valign="top">
<#if d.isDocument>
<img src="${url.context}${d.icon32}" alt="${d.name}" />
</td>
<td style="padding-top: 4px;">
<span style="font-weight:bold; vertical-align: top;">
<#if d.isLocked >
<img src="${url.context}/images/office/lock.gif" alt="Locked" title="Locked" style="margin: -2px 0px;" />
</#if>
${d.name}
</span>
<br />
<table style="margin-top: 4px;">
<#if d.properties.title?exists>
<tr><td valign="top">Title:</td><td>${d.properties.title}</td></tr>
<#else>
<tr><td valign="top">Title:</td><td>&nbsp;</td></tr>
</#if>
<#if d.properties.description?exists>
<tr><td valign="top">Description:</td><td>${d.properties.description}</td></tr>
<#else>
<tr><td valign="top">Description:</td><td>&nbsp;</td></tr>
</#if>
<tr><td>Creator:</td><td>${d.properties.creator}</td></tr>
<tr><td>Created:</td><td>${d.properties.created?datetime}</td></tr>
<tr><td>Modifier:</td><td>${d.properties.modifier}</td></tr>
<tr><td>Modified:</td><td>${d.properties.modified?datetime}</td></tr>
<tr><td>Size:</td><td>${d.size / 1024} Kb</td></tr>
<tr><td valign="top">Categories:</td>
<td>
<#if d.properties.categories?exists>
<#list d.properties.categories as category>
${category.name}<#if category != d.properties.categories?last>,</#if>
</#list>
<#else>
None.
</#if>
</td>
</tr>
</table>
<#else>
The current document is not managed by Alfresco.
</#if>
</td>
</tr>
</tbody>
</table>
</div>
<div id="statusText"></div>
</div>
<div class="tabBarInline">
<ul>
<li class="current"><a id="tabLinkTags" title="Document Tags" href="#"><span><img src="${url.context}/images/office/document_tag.gif" alt="Document Tags" /></span></a></li>
<li><a id="tabLinkVersion" title="Version History" href="#"><span><img src="${url.context}/images/office/version.gif" alt="Version History" /></span></a></li>
</ul>
</div>
<div id="panelTags" class="tabPanel">
<div class="tabHeader">Tags<#if d.isDocument> for ${d.name}</#if></div>
<div id="tagList" class="containerTabMedium">
<#if d.isDocument >
<div class="addTagIcon"></div>
<div id="addTagLinkContainer">
<a href="#" onclick="OfficeDocDetails.showAddTagForm(); return false;">Add a tag</a>
</div>
<div id="addTagFormContainer">
<form id="addTagForm" action="#" onsubmit="return OfficeDocDetails.addTag('${d.id}', this.tag.value);">
<fieldset class="addTagFieldset">
<input id="addTagBox" name="tag" type="text" />
<input class="addTagImage" type="image" src="${url.context}/images/office/action_successful.gif" onclick="return ($('addTagBox').value.length > 0);" />
<input class="addTagImage" type="image" src="${url.context}/images/office/action_failed.gif" onclick="return OfficeDocDetails.hideAddTagForm();" />
</fieldset>
</form>
</div>
<#if d.hasAspect("cm:taggable")>
<#if (d.properties["cm:taggable"]?size > 0)>
<#list d.properties["cm:taggable"]?sort_by("name") as tag>
<#if tag?exists>
<div class="tagListEntry">
<a class="tagListDelete" href="#" title="Remove tag &quot;${tag.name}&quot;" onclick="OfficeDocDetails.removeTag('${d.id}', '${tag.name}');">[x]</a>
<a class="tagListName" href="${url.serviceContext}/office/tags${defaultQuery?html}&amp;tag=${tag.name}">${tag.name}</a>
</div>
</#if>
</#list>
</#if>
</#if>
<#else>
<table width="265">
<tr>
<td valign="top">
The current document is not managed by Alfresco.
</td>
</tr>
</table>
</#if>
</div>
</div>
<div id="panelVersion" class="tabPanel tabPanelHidden">
<div class="tabHeader">Version History<#if d.isDocument> for ${d.name}</#if></div>
<div id="versionList" class="containerTabMedium">
<table width="265">
<#if d.isDocument >
<#if d.hasAspect("cm:versionable")>
<#assign versionRow=0>
<#list d.versionHistory?sort_by("versionLabel")?reverse as record>
<#assign versionRow=versionRow+1>
<tr class="${(versionRow % 2 = 0)?string("odd", "even")}">
<td valign="top">
<a title="Download ${record.versionLabel}" href="${url.context}${record.url}?ticket=${session.ticket}"><img src="${url.context}/images/office/document.gif" alt="Open ${record.versionLabel}" /></a>
</td>
<td>
<a title="Download ${record.versionLabel}" href="${url.context}${record.url}?ticket=${session.ticket}"><span style="font-weight:bold;">${record.versionLabel}</span></a><br />
Author: ${record.creator}<br />
Date: ${record.createdDate?datetime}<br />
<#if record.description?exists>
Notes: ${record.description}<br />
</#if>
<#-- Only Word supports document compare -->
<#if extn = "doc">
<a class="bold" href="#" onclick="window.external.compareDocument('${record.url}')" title="Compare with current">Compare with current</a><br />
</#if>
</td>
</tr>
</#list>
<#else>
<tr>
<td valign="top">
The current document is not versioned.<br />
<br />
<ul>
<li><a title="Make Versionable" href="#" onclick="OfficeAddin.getAction('${doc_actions}','makeversion','${d.id}',null,null,'version=1');">
<img src="${url.context}/images/office/make_versionable.gif" alt="Make Versionable" /> Make Versionable
</a></li>
</ul>
</td>
</tr>
</#if>
<#else>
<tr>
<td valign="top">
The current document is not managed by Alfresco.
</td>
</tr>
</#if>
</table>
</div>
</div>
<div class="header">Document Actions</div>
<div id="documentActions" class="actionsPanel">
<ul>
<#if d.isDocument>
<#if d.isLocked >
<#elseif d.hasAspect("cm:workingcopy")>
<li>
<a href="#" onclick="OfficeAddin.getAction('${doc_actions}','checkin','${d.id}');">
<img src="${url.context}/images/office/checkin.gif" alt="Check In">
Check In
</a>
<br />Check in the current document.
</li>
<#else>
<li>
<a href="#" onclick="OfficeAddin.getAction('${doc_actions}','checkout','${d.id}');">
<img src="${url.context}/images/office/checkout.gif" alt="Check Out" />
Check Out
</a>
<br />Check out the current document to a working copy.
</li>
</#if>
<li>
<a href="${url.serviceContext}/office/myTasks${defaultQuery?html}&amp;w=new">
<img src="${url.context}/images/office/new_workflow.gif" alt="Start Workflow" />
Start Workflow
</a>
<br />Start Advanced Workflow for the current document.
</li>
<#if d.name?ends_with(extn) || d.name?ends_with(extnx)>
<li>
<a href="#" onclick="OfficeAddin.getAction('${doc_actions}','makepdf','${d.id}');">
<img src="${url.context}/images/office/makepdf.gif" alt="Transform to PDF" />
Transform to PDF
</a>
<br />Transform the current document to Adobe PDF format.
</li>
</#if>
<li>
<a href="${url.context}/navigate/showDocDetails/workspace/SpacesStore/${d.id}?ticket=${session.ticket}" rel="_blank">
<img src="${url.context}/images/office/document_details.gif" alt="Open Full Details" />
Open Full Details
</a>
<br />Open the document details in the Alfresco Web Client.
</li>
<#else>
<li>
<a title="Save to Alfresco" href="${url.serviceContext}/office/navigation${defaultQuery?html}">
<img src="${url.context}/images/office/save_to_alfresco.gif" alt="Save to Alfresco" />
Save to Alfresco
</a>
<br />Allows you to place the current document under Alfresco management.
</li>
</#if>
</ul>
</div>
<#if args.version?exists>
<script>
window.addEvent("domready", function(){$('tabLinkVersion').fireEvent('click');});
</script>
</#if>
</body>
</html>

View File

@@ -0,0 +1,7 @@
<webscript>
<shortname>Get Users (Office Add-In)</shortname>
<description>Used by the Office Add-In to query for users</description>
<url>/office/getUsers?s={searchTerm}</url>
<authentication>user</authentication>
<transaction>required</transaction>
</webscript>

View File

@@ -0,0 +1,7 @@
<#assign n=0>
<#list searchResults as result>
<#if (n > 0)>,<#else>[</#if>
"${"${result.properties.firstName} ${result.properties.lastName}"?trim} (${result.properties.userName})"
<#assign n=n+1>
</#list>
]

View File

@@ -0,0 +1,18 @@
var query = "TYPE:\"{http://www.alfresco.org/model/content/1.0}person\"";
if ((args.s) && (args.s != ""))
{
query += " AND (";
var terms = args.s.split(" ");
for (i = 0; i < terms.length; i++)
{
term = terms[i];
query += "((@\\{http\\://www.alfresco.org/model/content/1.0\\}firstName:*" + term;
query += "*) OR (@\\{http\\://www.alfresco.org/model/content/1.0\\}lastName:*" + term;
query += "*) OR (@\\{http\\://www.alfresco.org/model/content/1.0\\}userName:" + term;
query += "*)) "; // final space here is important as default OR separator
}
query += ")";
}
model.searchResults = search.luceneSearch(query);

Some files were not shown because too many files have changed in this diff Show More