i'm working on a small project to get the current user spaces in alfresco. i searched in the few days buts no result.
can any one help me to get the current user spaces using webscript in alfresco.
thanks you
Do you mean the user's home folder? In java you can do it like this:
NodeRef personNode = personService.getPerson(userName);
NodeRef homeFolderNode = nodeService.getProperty(personNode, ContentModel.PROP_HOMEFOLDER);
In javascript you could get it like this:
var userhome = companyhome.childByNamePath("User Homes/" + userName);
If you're looking for something other than that, please comment.
Related
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.
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
I am new at this and I do not know how to get info from site and show it in UI. I have tried using plugins but do not know how to. I want to get the numbers showing on the site which are constantly updated to be shown in a UI field when refresh button is click. Can someone please help I am stuck over here.
The site is results site which revise the numbers on it daily bases. The numbers are changing and its a active server page.
As Vancete said, WWW could be used to solve this.
Create a Coroutine, load the data from the webpage and then do something with it.
IEnumerator GetDataFromWebpage (string url)
{
WWW webpage = new WWW(url);
while (!webpage.isDone) yield return false;
string content = webpage.text;
. . .
// Do something with <content>
}
You can take a look here:
https://docs.unity3d.com/ScriptReference/WWW.html
So you should create an WWW object with the desired URL, wait for the response, then load the object.text property. After all, do a substring of what you need and you are done!
Feel free to ask if you need some more help.
I am new to SiteFinity. This is the first time I have ever seen it.
I am trying to find out how to check to see if the user is logged in and if they are, do not load certain javascript files (we have a conflict that is causing problems with sitefinity's page editor)
So in the header I want to do something like
if(user_logged_in())
... load js file here
Also I am trying to do this in the master template files.
Version 6.1 FYI
You can try:
ClaimsManager.GetCurrentIdentity().IsAuthenticated
This will return whether or not the user is logged in but it sounds like you need to know if they are a backend user so maybe try:
ClaimsManager.GetCurrentIdentity().IsBackendUser
You'll need this using directive:
using Telerik.Sitefinity.Security.Claims;
I think this might work for you. If the user is authenticated it will load you your .js file.
var isValidUser = SecurityManager.AuthenticateUser(UserManager.GetDefaultProviderName(), userName, userPassword, true);
if (isValidUser == UserLoggingReason.Success){
JavaScriptEmbedControl scriptToEmbed = new JavaScriptEmbedControl();
scriptToEmbed.Url = "path-to-file.js";
scriptToEmbed.ScriptEmbedPosition = Telerik.Sitefinity.Web.UI.PublicControls.Enums.ScriptEmbedPosition.InPlace;
this.form1.Controls.Add(scriptToEmbed);
}
I built a site using the starter site template in Webmatrix that uses a log in. After a user logs in, it displays near the top "Hello, (email address)!"
Looking at the html code, I see
Hello, <a id="logname" class="email" href="~/Account/Manage" title="Manage">#WebSecurity.CurrentUserName</a>!
I'm just a beginner with asp.net but can work things out following logic, so what I have done is added a 'Name' field to the database where the email and password is stored and edited the registration page so users can enter their name as well, it writes to the database no problems.
Now I assumed it's just a matter of finding where #WebSecurity.CurrentUserName is referring to the user's email address and make it point to the Name field instead. However I've searched high and low and can not seem to find it anywhere.
So my next approach was to use code from a Bakery database tutorial that fetches data from a field and modify it to grab the name and display it where I want, the code I tried to use here:
#foreach(var row in db.Query(selectQueryString))
This appeared to work at first, It displayed "Hello, Ben!" but then if I made any more accounts it started to display them too, so after a while I was getting "Hello, Ben, Steve, Grace, etc..."
Even though I'm a beginner I do realize that this code isn't quite what I need, but something similar that takes that single Name field but only from the currently logged in user... I've googled and searched and seen many people wanting the same thing, except it's using PHP or VB or something that isn't Webmatrix.
If it's a quick answer I'd appreciate the code I need, or otherwise pointed in the right direction, any help would be greatly appreciated. Thanks in advance..
OK ironically I find the solution moments after posting the question, so here goes..
This is the code needed to be put at the very top of the file _SiteLayout.chtml
#{
var authenticatedUser = "";
if (WebSecurity.IsAuthenticated) {
authenticatedUser = WebSecurity.CurrentUserName;
var db = Database.Open("StarterSite");
var UserData = db.QuerySingle("SELECT Name FROM UserProfile WHERE LOWER(Email) = LOWER(#0)", authenticatedUser);
authenticatedUser = UserData.Name;
}
}
StarterSite is the name of the database, and UserProfile is the name of the Table, and I labeled the name field Name (explained for the purpose of beginners like me who might be reading this)
Then in the html markup I changed #WebSecurity.CurrentUserName to #authenticatedUser so now it reads:
Hello, <a id="logname" class="email" href="~/Account/Manage" title="Manage">#authenticatedUser</a>!
resulting in the desired outcome of it now displaying the user's name instead of their email address.