"Review Changes" Master Admin Module question

11 views
Skip to first unread message

The Sage Colleges Webmaster

unread,
Apr 24, 2013, 12:20:35 PM4/24/13
to reason-d...@googlegroups.com
I was looking through some of the "other links" in master admin and noticed the "review changes" module. Played with it a bit and thought it's great as we've started discussing how to best report out what pages we've recently touched in our office. I was wondering if you could help me out on something. I'd love to - as "admin" - have last_edited_by show next to the page name/owner. And, possibly, have a drop-down under "type" for "users" where I could filter it by a specific user.

Any help is greatly appreciated.

Thanks.

- Kevin Hanselman
Director of Web Strategies
The Sage Colleges

Matt Ryan

unread,
Apr 24, 2013, 8:15:54 PM4/24/13
to reason-d...@googlegroups.com
Hi, Kevin --

Glad you found that module! It's kind of tucked away, but it's pretty useful.

We can definitely add the changes you're suggesting to the Reason enhancements wishlist. That said, this sounds like a pretty well-defined and straightforward project that you or a php-savvy colleague or student could do and contribute back to the Reason project.

Caveat -- all the code below is really pseudo-code. It has not been tested, and may not compile. It's just there to get you on the right track.

That administrative module lives at reason_package/reason_4.0/lib/core/classes/admin/modules/review_changes.php.

To add the last_edited_by information, modify the function _get_changes_markup() and, where it iterates over the entities, add lines along the line of:

$lastmod = $item->get_value('last_modified_by');
if($lastmod)
{
    $user = new entity($lastmod);
   if($user->get_values())
        echo '<div class="lastmod">Last modified by: '.$user->get_value('name').'</div>';
}

To add a dropdown to filter by user is a bit more complex, but not really that hard. To do that you would need to modify two functions: run() and _get_changes_markup().

in run():

First, you get a list of all users by setting up an entity selector and grabbing everything of the user type.

Second, you transform the array of entities into an array with Reason using $this->_prep_for_disco($users).

Third, you add a select element to the disco form. You should be able to copy, paste, and modify the line that adds the site element.

Fourth, you modify the _get_changes_markup() method to take an additional parameter, for the user id, and you modify the line that calls _get_changes_markup() to pass that value along.

Finally, in _get_changes_markup(), you modify the entity selector that grabs the changed items to limit to that user, e.g.

if($last_modified_by)
    $es->add_relation('entity.last_modified_by = "'.addslashes($last_modified_by).'"');

I'd recommend trying to do it yourself -- these are pretty doable changes, and it would be a good opportunity to learn a bit more Reason programming while creating something that could be contributed back to the core.

If you feel this is a bit over your head, you might also consider coming to the Summer Reason Hack/Doc, where Reason pros could help guide you through this (and likely other enhancements you'd like to make!)

Cheers,
Matt



The Sage Colleges

--
You received this message because you are subscribed to the Google Groups "Reason Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to reason-discuss...@googlegroups.com.
To post to this group, send email to reason-d...@googlegroups.com.
Visit this group at http://groups.google.com/group/reason-discussion?hl=en-US.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

The Sage Colleges Webmaster

unread,
Apr 25, 2013, 10:57:43 AM4/25/13
to reason-d...@googlegroups.com
Thank you so much Matt, those instructions were exactly what I was looking for and I was able to edit the review_changes.php file and add the "last_edited_by" field and create a dropdown list of users. I am a bit of a novice on doing things like this in Reason and would love to learn more and the Summer Dev/Hack conference sounds like a great place to learn!

I'm attaching the file here if anyone else is interested and/or you want to put it in the core. One small note on the code that needed changes 1) the value is "last_edited_by", whereas the code had "last_modified_by".

Thanks again.

- Kevin
review_changes.php

Matt Ryan

unread,
Apr 26, 2013, 10:07:00 AM4/26/13
to reason-d...@googlegroups.com
Kevin,

Your changes look good -- I was able to integrate them back into the core with just a couple of minor tweaks. I'm including the tweaked file so you can have my changes, and it should be on the github master soon.

We'd be happy to have you at Hack/Doc! It's been a really great way for people to get up to speed on Reason customization and development. Here's the info & registration form if you'd like to come: https://apps.carleton.edu/opensource/reason/hackdoc/

Cheers,
Matt

review_changes.php

The Sage Colleges Webmaster

unread,
Apr 26, 2013, 11:29:38 AM4/26/13
to reason-d...@googlegroups.com
Thanks again Matt,
I furthered my output by adding "Last modified on [DATE/TIME]" next to the modified by. Doing so, I noticed too that the types were sorted by (I'm assuming) ID - so the list was arranged in a strange way for "general consumption" so I also just added a "sort" drop-down that allows you to sort Ascending or Descending and added a set_order('last_modified '.$sort) to the entity selector.

- Kevin
review_changes.php

Matt Ryan

unread,
Apr 26, 2013, 2:21:02 PM4/26/13
to reason-d...@googlegroups.com
Thanks, Kevin. I've merged those changes in as well. I did make one change to improve security -- basically sanity-checking the sort value before putting it in the entity selector.

The modified file is attached.

Cheers,
Matt
review_changes.php

Nathan White

unread,
Apr 29, 2013, 11:47:10 AM4/29/13
to reason-d...@googlegroups.com
The changes to review_changes.php are now in the master branch:


Thx!

Nate
Reply all
Reply to author
Forward
0 new messages