You are not logged in.
Pages: 1
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
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
Offline
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
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
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
Personally, I think getting access to an author object, and any publication date and state meta data would be the most useful.
Offline
Cool, I'll add those to the list of methods to add.
Offline
Pages: 1