ReferenceError: people is not defined in Alfresco Community - alfresco

I am using Alfresco Community 5.0.d and I'm getting below error.
ReferenceError: people is not defined
For following code in people-finder.js file:
var currentUser = people.getPerson(person);
I want to use the people methods for further process. Is there anyway to achieve this?
Also my target is to get all groups for the current user and the search result too.
One way I know is making ajax call to /alfresco/service/api/people/{people}?groups=true but this is an expensive way to achieve this.
Is there an alternative to achieve this?
Thanks

The "people" root object as well as any other that depends on repository tier services can not be accessed directly from a web script running in Alfresco Share.

if you wanted to get all the current user details in share webscript then you can get it using user Object
example:
Currently i have logged in with admin user
my webscript files
test.get.js
model.user=user;
test.get.html.ftl
${user}
Output ::
{lastName=, userStatus=null, alfUserLoaded=1489745903574,
userStatusTime=null,
alfUserGroups=GROUP_ALFRESCO_ADMINISTRATORS,GROUP_ALFRESCO_MODEL_ADMINISTRATORS,GROUP_ALFRESCO_SEARCH_ADMINISTRATORS,GROUP_EMAIL_CONTRIBUTORS,GROUP_SITE_ADMINISTRATORS,
firstName=Administrator,
userHome=workspace://SpacesStore/7338666a-7a02-4ab6-aa3b-5a46d06074ee,
id=admin, email=admin#alfresco.com}
list of groups in output::
GROUP_ALFRESCO_ADMINISTRATORS,GROUP_ALFRESCO_MODEL_ADMINISTRATORS,GROUP_ALFRESCO_SEARCH_ADMINISTRATORS,GROUP_EMAIL_CONTRIBUTORS,GROUP_SITE_ADMINISTRATORS
By repo webscript
if you wanted to get all the current user details in repo webscript then you can get it by using
example:
Currently i have logged in with admin user
my repo webscript files
test1.get.js
var users = people.getPerson(person.properties.userName);
var groups=people.getContainerGroups(users);
model["groups"] = groups;
test1.get.html.ftl file
<#list groups as g>
${g.name}
</#list>
output::
GROUP_ALFRESCO_ADMINISTRATORS GROUP_ALFRESCO_MODEL_ADMINISTRATORS
GROUP_ALFRESCO_SEARCH_ADMINISTRATORS GROUP_EMAIL_CONTRIBUTORS
GROUP_SITE_ADMINISTRATORS

Related

find alfresco nodeRef without using luceneSearch

I have a js webscript who return a list of documents from a specific repository in Alfresco. i used the luceneSearch to get the nodeRef of the repository, this works fine.
The repository primary path is: /app:company_home/app:dictionary/cm:StarXpert_x0020_Workflow/cm:fichiers_x0020_JSON and i used the luceneSearch like this to get the nodeRef from the primary path
var nodes = search.luceneSearch("PATH:\"/app:company_home/app:dictionary/cm:StarXpert_x0020_Workflow/cm:fichiers_x0020_JSON//*\" AND TYPE:\"cm:content\"","#cm:name", true);
But when i execute my code in the server side, i have an error, that my webScript can't get the nodes from the path i took it. I searched and i found that the problem is an indexation problem on the server alfresco version.
So my question is: can us get a nodeRef from a primary path, whithout using luceneSearch?
Thanks for any help
If I understand the documentation, you can use other methods with the search root object. The xpathSearch seems interesting :
org.mozilla.javascript.Scriptable xpathSearch(String search)
Execute a XPath search
The selectNodes(String search) might be interesting too.

Looking for suitable way to customize Alfresco share

I have a unique requirement by my company to have a page for each sub-folder in a particular folder of alfresco share. So basically there would be hundreds of sub-folders and corresponding hundreds of pages representing it. The page for that folder should have links to its sub-folders and maybe even documents within it in the form of a collapsible list as shown:
Folder 1
-Category 1
Doc 1
Doc 2
-Category 2
-Sub-category 1
doc 3
I want to have something like shown above on one side of the page and the other side should have all the recent activities related to the folder, like who added a doc, what edits were made, were there any comments, etc. I searched a lot related to this but I am not sure if alfresco supports this kind of customization. I found some really good tutorials on creating custom pages in share using JSON widgets but don't think it would help in this case. Other option would be generate an html page for every new folder created and populate it using javascript. But this method won't have much flexibility in terms of designing the page. Does anyone know of a better approach or idea for this requirement ? I would really appreciate any thoughts on this.
I'll just write it as an answer (relating to my previous comment). I've done something similar in this way (using the link provided in the comments:
create a simple alfresco web script that returns a json of what you need (in you case recently modified documents). I've done it with listing a folder, this is mywebscript.get.json.ftl:
{
"docprop" : [
<#list companyhome.childByNamePath["MyFolder"].children as child>
{
"name" : "${child.properties.name}" ,
"author" : "${child.properties["cm:author"]}",
"CreatedDate" : "${child.properties.created?datetime}"
}
<#if child_has_next> , </#if>
</#list>
]
}
create Share widget controller file where you call this web script with retrievedoc.get.js:
var connector = remote.connect("alfresco");
var data = connector.get("/mywebscript.json"); //the url is declared in your `mywebscript.get.desc.xml`
// create json object from data
var result = eval('(' + data + ')');
model.docprop = result["docprop"];
create Share widget presentation template with retrievedoc.get.html.ftl:
<div class="dashlet">
<div class="title">${msg("header.retrievedocTitle")}</div>
<div class="body retrievedoc">
<table>
<tr>
<th>Name: </th>
<thAuthor: </th>
<th>Created: </th>
</tr>
<#list docprop as t>
<tr>
<td>${t.name}</td>
<td>${t.author}</td>
<td>${t.CreatedDate}</td>
</tr>
</#list>
</table>
</div>
You then need to register your widget in Share, and use it in your dashboard. It will call the Alfresco script and populate the widget with the results. Obviously you need to change your Alfresco script to return recent activities (you could make a query like: all documents modified in the last 24 hours, or something like this. But the method is the same.
Hope it helps.
You could create new folder tree component in alfresco share to meetup your requirement.
Alfresco share page madeup of multiple comoponents which are kind of self sufficient components in terms of data and dependancy(Excluding few alfresco common dependancy).
Here is the outline for the approch
Create one folder tree comopnent in alfresco, which will be nothing
but a webscript which render related webscripts output on page in
which component is included.
Create one Dynamic YUI tree with some dummy data and check weather
you are able to generate or not.(Just to make sure you have all
depenency included).
Create one data webscript on repository side which will fetch folder
structure related data from repository.Make it in such way that if
you pass folder noderef if will return all childrens under
that.There is one similar webscript also avilable out of box may be
you could reuse that.
Once you have that webscript working properly call that repository
webscript to populate your dynamic tree and remove all dummy data.
I hope this gives you good starting point.
You will certainly find documentation for each of these steps.

Getting the site name in alfresco email notification

I am trying to notify users whenever a site is created in alfresco share. I created a rule for the site folder in the repository.
In Define Rule, I selected:
When: Items are created or entered in the folder
If all criteria are met: Description contains "a"
Perform Action: Send email
But in the message of the email I need to give the site name.
For example:
A new site named "Sample" is created. Click the link to join the site.
How can I get the site name and corresponding link to join the site?
You can do something like this.
var currentSite = Alfresco.constants.SITE;
var siteObject = siteService.getSite(currentSite );
If you are using javascript directly to send mail you you will have site object available .
You can also try this
siteId = page.url.templateArgs.site;
If you are using ftl you can probably pass sitename from script file to FTL file.
You have multiple options to get current site name depending on the context where you are trying to access it.

SqlProfileProvider - can you use Profile.GetProfile() in a project?

I am attempting to use the SqlProfileProvider in an application and can't seem to use it the way I want to. I would like to be able to simply call up a profile like this:
Profile p = Profile.GetProfile("naspinski");
p.Organization = "new_org";
but I can't seem to find the correct way to use the GetProfile() that I seem to see scattered around the net. Is there a way to grab, read and modify profiles?
I am using it in MVC 3 and will not be actually logging in as the specific user, this will be pulling users from the db that are specified. Thank you.
To retrieve the profile:
var profile = ProfileBase.Create(HttpContext.Profile.UserName, true);
And here's the MSDN documentation. And a nice blog post about custom profiles.

How do I list all nodes created by user specified in argument using Views in Drupal?

I have been trying to create a page using views that will list down all the nodes authored by a specific user.
The user name will be specified in the path (like - stuff/[user-name] )
Can someone please tell me how to do this using Views.
I am stuck on a dead end
for the views url path specify: stuff/%
in the arguments section add: user -> user: name
Should do it, but I'm not sure if it isn't buggy (see this issue: http://drupal.org/node/744468)
If you use user:id instead of username, you will be fine.

Resources