12-02-2009 04:50 PM
if (preferences.properties["app:dashboard"] != null)
.. this always returns null. Even for a user who has customized their dashboard. So what happens is that nothing is ever cleared since Alfresco thinks that there is no dashboard preference set.
var people = search.luceneSearch("TYPE:cm\\:person");
var notes = [];
for each (p in people)
{
logger.log("Found user: " + p.properties.userName);
notes.push("Found user " + p.properties.userName);
if (p.hasAspect("app:configurable"))
{
var config = p.childAssocs["app:configurations"][0];
var prefs = config.childrenByXPath("app:preferences");
if (prefs.length == 1)
{
var preferences = prefs[0];
if (preferences.properties["app:dashboard"] != null)
{
preferences.properties["app:dashboard"] = null;
preferences.save();
logger.log(" preferences found and cleared.");
notes.push("Cleared dashboard for " + p.properties.userName);
}
}
}
}
model.notes=notes;
resetdashboard.get.html.ftl
<html>
<head>
<title>Reset Dashboards</title>
</head>
<body>
<p> If everything worked users' dashboards should be reset to default. <a href="/share">Check yours out</a>.</p>
<p>Notes:</p>
<ul>
<#list notes as note>
<li>${note}</li>
</#list>
</ul>
</body>
</html>
resetdashboard.get.desc.xml
<webscript>
<shortname>Reset User Dashboards</shortname>
<description>Revert all user dashboards to preset-based default</description>
<url>/sample/resetdashboards</url>
<authentication>admin</authentication>
<transaction>required</transaction>
</webscript>
12-02-2009 05:55 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.