#1 May 23, 2012 4:27am

philp
Member
Registered: April 5, 2012
Posts: 25

Displaying an admin author

I've checked the docs, and had a quick dig around in the code, but can't find what I'm looking for: is there any quick and easy way to display the admin author for a module item?

Offline

#2 May 23, 2012 11:02am

timbuckingham
Administrator
From: Baltimore, MD
Registered: April 2, 2012
Posts: 974

Re: Displaying an admin author

There are two ways you could go about doing this.  The first way is to use the bigtree_audit_trail table to find out who created a module item by querying for the table, entry id, and the "created" type.  If you wanted to show that in a view you would add a custom view column and add a parser that looks something like:

$f = sqlfetch(sqlquery("SELECT bigtree_users.name FROM bigtree_audit_trail JOIN bigtree_users ON bigtree_audit_trail.user = bigtree_users.id WHERE entry = '".$item["id"]."' AND table = 'whatever_table' AND type = 'created'"));
$value = $f["name"];

The other way to do it would be to create a custom field type to manually save the author (and if you want to display it in the form as well, you'll need a custom field type) by setting the returned value to $admin->ID (or if you just want to store their name you could query for their name and store that).

Let me know if this doesn't make any sense or it's not a good solution and I'll do some more thinking smile

Offline

#3 May 24, 2012 3:29am

philp
Member
Registered: April 5, 2012
Posts: 25

Re: Displaying an admin author

Thanks Tim.


The first option looks quite expensive in terms of SQl queries, and likely to break if you make changes to the table structure in the future.


The second option is something we thought about and might be the route we have to take for the moment.


What would be really nice is for the user to be returned as an object property of the item being retrieved.

Offline

#4 October 25, 2012 4:44am

philp
Member
Registered: April 5, 2012
Posts: 25

Re: Displaying an admin author

I've just referenced this discussion after coming up against the same requirement again, on another project.

In the end, we actually ended up implementing your first suggestion: creating a method on the module class to do an SQL query on the audit table.


I'm just curious to know if there are any plans to make this a bit more elegant for retrieving publishing metadata for all BigTree content?

Offline

#5 October 25, 2012 10:27am

timbuckingham
Administrator
From: Baltimore, MD
Registered: April 2, 2012
Posts: 974

Re: Displaying an admin author

We're planning on adding some kind of interface to the audit trail in the admin area in the 4.1 release but there aren't any solid plans for what will be involved yet.  I'll add the request to build audit information-gathering into the BigTreeModule class in some way in 4.1 as well.  If there are any specific methods you're interested in let me know!

Offline

#6 October 25, 2012 10:38am

philp
Member
Registered: April 5, 2012
Posts: 25

Re: Displaying an admin author

Personally, I think getting access to an author object, and any publication date and state meta data would be the most useful.

Offline

#7 October 25, 2012 10:43am

timbuckingham
Administrator
From: Baltimore, MD
Registered: April 2, 2012
Posts: 974

Re: Displaying an admin author

Cool, I'll add those to the list of methods to add.

Offline

Board footer

Powered by FluxBB

The Discussion Forum is not available on displays of this size.