ALF-3709: User Status on Profile. Added cm:userStatusTime datetime property to cm:person and exposed the current value via the GET userprofile webscript. Time property is updated by userprofile webscript if status property is updated. Also added userstatus POST webscript.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@21405 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Mike Hatfield
2010-07-26 11:10:33 +00:00
parent 7eef4234aa
commit a10012c49b
5 changed files with 50 additions and 3 deletions

View File

@@ -24,6 +24,7 @@
"skype": <#if person.properties.skype??>"${person.properties.skype}"<#else>null</#if>, "skype": <#if person.properties.skype??>"${person.properties.skype}"<#else>null</#if>,
"instantmsg": <#if person.properties.instantmsg??>"${person.properties.instantmsg}"<#else>null</#if>, "instantmsg": <#if person.properties.instantmsg??>"${person.properties.instantmsg}"<#else>null</#if>,
"userStatus": <#if person.properties.userStatus??>"${person.properties.userStatus}"<#else>null</#if>, "userStatus": <#if person.properties.userStatus??>"${person.properties.userStatus}"<#else>null</#if>,
"userStatusTime": <#if person.properties.userStatusTime??>{ "iso8601": ${xmldate(person.properties.userStatusTime)}}<#else>null</#if>,
"googleusername": <#if person.properties.googleusername??>"${person.properties.googleusername}"<#else>null</#if>, "googleusername": <#if person.properties.googleusername??>"${person.properties.googleusername}"<#else>null</#if>,
"quota": <#if person.properties.sizeQuota??>${person.properties.sizeQuota?c}<#else>-1</#if>, "quota": <#if person.properties.sizeQuota??>${person.properties.sizeQuota?c}<#else>-1</#if>,
"sizeCurrent": <#if person.properties.sizeCurrent??>${person.properties.sizeCurrent?c}<#else>0</#if>, "sizeCurrent": <#if person.properties.sizeCurrent??>${person.properties.sizeCurrent?c}<#else>0</#if>,

View File

@@ -54,6 +54,12 @@ function main()
// set simple text properties // set simple text properties
user.properties[propname] = propval; user.properties[propname] = propval;
// update userStatusTime if updating userStatus
if (propname.toLowerCase() == "cm:userstatus")
{
user.properties["cm:userStatusTime"] = new Date();
}
} }
} }
} }
@@ -73,10 +79,10 @@ function main()
user.properties[propname].content = propval; user.properties[propname].content = propval;
} }
} }
}
user.save(); user.save();
model.success = true; model.success = true;
} }
}
main(); main();

View File

@@ -0,0 +1,8 @@
<webscript>
<shortname>User Status</shortname>
<description>User Status POST for update</description>
<format default="json" />
<authentication>user</authentication>
<transaction>required</transaction>
<url>/slingshot/profile/userstatus</url>
</webscript>

View File

@@ -0,0 +1,3 @@
{
"success": ${success?string}
}

View File

@@ -0,0 +1,29 @@
/**
* User Status REST Update method
*
* @method POST
* @param json {string}
* {
* status: "value"
* }
*/
function main()
{
model.success = false;
if (json.has("status"))
{
var newStatus = json.get("status");
if (newStatus != null)
{
person.properties["cm:userStatus"] = newStatus;
person.properties["cm:userStatusTime"] = new Date();
}
person.save();
model.success = true;
}
}
main();