From a10012c49ba3dd7b0da89516c92fff2c20fccc9f Mon Sep 17 00:00:00 2001 From: Mike Hatfield Date: Mon, 26 Jul 2010 11:10:33 +0000 Subject: [PATCH] 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 --- .../alfresco/repository/person/person.lib.ftl | 1 + .../profile/userprofile.post.json.js | 12 ++++++-- .../profile/userstatus.post.desc.xml | 8 +++++ .../profile/userstatus.post.json.ftl | 3 ++ .../slingshot/profile/userstatus.post.json.js | 29 +++++++++++++++++++ 5 files changed, 50 insertions(+), 3 deletions(-) create mode 100644 config/alfresco/templates/webscripts/org/alfresco/slingshot/profile/userstatus.post.desc.xml create mode 100644 config/alfresco/templates/webscripts/org/alfresco/slingshot/profile/userstatus.post.json.ftl create mode 100644 config/alfresco/templates/webscripts/org/alfresco/slingshot/profile/userstatus.post.json.js diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/person/person.lib.ftl b/config/alfresco/templates/webscripts/org/alfresco/repository/person/person.lib.ftl index 4fc413b7bb..30cb3e23f2 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/person/person.lib.ftl +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/person/person.lib.ftl @@ -24,6 +24,7 @@ "skype": <#if person.properties.skype??>"${person.properties.skype}"<#else>null, "instantmsg": <#if person.properties.instantmsg??>"${person.properties.instantmsg}"<#else>null, "userStatus": <#if person.properties.userStatus??>"${person.properties.userStatus}"<#else>null, + "userStatusTime": <#if person.properties.userStatusTime??>{ "iso8601": ${xmldate(person.properties.userStatusTime)}}<#else>null, "googleusername": <#if person.properties.googleusername??>"${person.properties.googleusername}"<#else>null, "quota": <#if person.properties.sizeQuota??>${person.properties.sizeQuota?c}<#else>-1, "sizeCurrent": <#if person.properties.sizeCurrent??>${person.properties.sizeCurrent?c}<#else>0, diff --git a/config/alfresco/templates/webscripts/org/alfresco/slingshot/profile/userprofile.post.json.js b/config/alfresco/templates/webscripts/org/alfresco/slingshot/profile/userprofile.post.json.js index 71d3e9ee4b..4e547fa63d 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/slingshot/profile/userprofile.post.json.js +++ b/config/alfresco/templates/webscripts/org/alfresco/slingshot/profile/userprofile.post.json.js @@ -54,6 +54,12 @@ function main() // set simple text properties 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.save(); - model.success = true; } + + user.save(); + model.success = true; } main(); \ No newline at end of file diff --git a/config/alfresco/templates/webscripts/org/alfresco/slingshot/profile/userstatus.post.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/slingshot/profile/userstatus.post.desc.xml new file mode 100644 index 0000000000..875da15b32 --- /dev/null +++ b/config/alfresco/templates/webscripts/org/alfresco/slingshot/profile/userstatus.post.desc.xml @@ -0,0 +1,8 @@ + + User Status + User Status POST for update + + user + required + /slingshot/profile/userstatus + \ No newline at end of file diff --git a/config/alfresco/templates/webscripts/org/alfresco/slingshot/profile/userstatus.post.json.ftl b/config/alfresco/templates/webscripts/org/alfresco/slingshot/profile/userstatus.post.json.ftl new file mode 100644 index 0000000000..c85c20f2b4 --- /dev/null +++ b/config/alfresco/templates/webscripts/org/alfresco/slingshot/profile/userstatus.post.json.ftl @@ -0,0 +1,3 @@ +{ + "success": ${success?string} +} \ No newline at end of file diff --git a/config/alfresco/templates/webscripts/org/alfresco/slingshot/profile/userstatus.post.json.js b/config/alfresco/templates/webscripts/org/alfresco/slingshot/profile/userstatus.post.json.js new file mode 100644 index 0000000000..c94a922bdf --- /dev/null +++ b/config/alfresco/templates/webscripts/org/alfresco/slingshot/profile/userstatus.post.json.js @@ -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(); \ No newline at end of file