Get user who is performing an Action (ActionHandler) Options
darrenjferguson
Posted: Monday, June 16, 2008 1:45:47 PM

Rank: Fanatic

Joined: 3/19/2008
Posts: 219
Location: London, UK
Hello all,

I have an actionhandler which fires on document publish.

I get the action and the document passed to me as objects.....

Code:
Boolean IActionHandler.Execute(Document doc, IAction action)


Is there any way to get hold of the user who is performing the action?

At the moment I do the following:

Code:
foreach (DocumentVersionList dl in doc.GetVersions())
{
to = dl.User.Email;
}


which gives me the latest user to modify the document.
It seems like a hack somehow!

Darren Ferguson - Umbraco level 2 certified
www.darren-ferguson.com - www.fergusonmoriyama.com
Dirk
Posted: Monday, June 16, 2008 10:38:11 PM

Rank: Addict

Joined: 9/27/2007
Posts: 977
Location: Belgium
Hi Darren,

Just had a quick look at the source and the apiDocs, and could find some interesting stuff in umbraco.BasePages.BasePage class. Found some functions and methods that deal with the user being currently logged in.

Hope that helps.

Regards,
/Dirk


level 1 certified - umbraco blog at netaddicts.be - working on an integrated forum4umbraco
Shandem
Posted: Tuesday, June 17, 2008 1:09:47 AM
Rank: Enthusiast

Joined: 8/13/2007
Posts: 36
Location: Sydney, Australia
you can use:

UmbracoEnsuredPage bp = new UmbracoEnsuredPage();
User u = bp.getUser();

enjoy!
Shandem
Posted: Tuesday, June 17, 2008 1:12:47 AM
Rank: Enthusiast

Joined: 8/13/2007
Posts: 36
Location: Sydney, Australia
Also... if you are going to iterate through the business logic object in Umbraco, it make a TON of requests to the database (use SQL Server Profiler and you'll see). If you want to iterate over the content nodes, best to use XSLT and using the umbraco.library.GetXmlNodeByXPath method
darrenjferguson
Posted: Tuesday, June 17, 2008 10:10:02 AM

Rank: Fanatic

Joined: 3/19/2008
Posts: 219
Location: London, UK
Thanks,

using the ensured page works well.

Shandem wrote:
Also... if you are going to iterate through the business logic object in Umbraco, it make a TON of requests to the database (use SQL Server Profiler and you'll see). If you want to iterate over the content nodes, best to use XSLT and using the umbraco.library.GetXmlNodeByXPath method


Nope, my intention was never to do that :) As I said, I knew what I was doing was a hack.....




Darren Ferguson - Umbraco level 2 certified
www.darren-ferguson.com - www.fergusonmoriyama.com
Users browsing this topic
Guest


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.