09-06-2011 02:29 PM
<import resource="classpath:alfresco/site-webscripts/org/alfresco/callutils.js">
function main()
{
// make sure we don't redirect by default
model.doRedirect = false;
// fetch the user information from the url
var inviteId = page.url.args.inviteId,
inviteTicket = page.url.args.inviteTicket,
inviteeUserName = page.url.args.inviteeUserName;
if ((inviteId == undefined) || (inviteTicket == undefined))
{
model.error = "Parameters missing!";
return;
}
// do invite request and redirect if it succeedes, show error otherwise
var theUrl, connector, result, json, data;
theUrl = '/api/invite/' + inviteId + '/' + inviteTicket + '/accept';
// for MT share
if (inviteeUserName != undefined)
{
inviteeUserName = encodeURIComponent(inviteeUserName);
theUrl = theUrl + '?inviteeUserName=' + inviteeUserName;
}
connector = remote.connect("alfresco-noauth");
result = connector.put(theUrl, "{}", "application/json");
if (result.status != status.STATUS_OK)
{
model.doRedirect = false;
json = eval('(' + result.response + ')');
model.error = json.message; // result.response;
}
else
{
// redirect to the site dashboard
// model.doRedirect = false;
data = eval('(' + result.response + ')');
model.siteShortName = data.siteShortName;
var favourites = {};
favourites[data.siteShortName] = true
var dataPass =
{ 'org' :
{ 'alfresco' :
{ 'share' :
{ 'sites' :
{ 'favourites' : favourites }
}
}
}
};
theUrl = '/api/people/' + inviteeUserName + '/preferences';
result = connector.post(theUrl, dataPass, "application/json");
if (result.status != status.STATUS_OK)
{
model.doRedirect = true;
}
else
{
model.doRedirect = false;
json = eval('(' + result.response + ')');
model.error = json.message; // result.response;
}
}
}
main();
09-06-2011 03:15 PM
any thoughts on why this seems to not work as expected.That's pretty vague - what exactly was the error and/or problem?
09-12-2011 02:52 AM
09-12-2011 06:03 PM
09-20-2011 05:58 PM
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.