DokuWiki

It's better when it's simple

User Tools

Site Tools


tips:recent_changes_by_user_2009-02-14

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
tips:recent_changes_by_user_2009-02-14 [2009-02-19 01:35] – tips:recent_changes_by_user updated for dokuwiki 2009-02-14 79.71.21.102tips:recent_changes_by_user_2009-02-14 [2024-04-19 09:56] (current) Chris75
Line 1: Line 1:
 +====== Filter recent changes ======
 +
 +===== Negatively filter recent changes by (private) namespace =====
 +
 +Suppose your wiki has a private namespace like the namespace ''user:'' for user homepages. Now you want to hide those page edits from the list of recent changes. Just go to ''/dokuwiki/inc/changelog.php'' and add the following line of code to the function ''_handleRecent($line,$ns,$flags,&$seen){ }'' at about half ways:
 +
 +
 +    // ********* hide private namespace from the list of recent changes ********* 
 +    if ( explode(':', $recent['id'])[0] == 'user' ) return false;
 +
 +
 +
 +===== Filter recent changes by user =====
 +
 +My <del>first</del> **second** ;-) attempt at hacking DokuWiki, so apologies for any rough edges or bad coding practices!
 +
 +I ( l u r c h (at) d u r g e (dot) o r g ) wanted to be able to filter the list of recent changes by username (the wiki installation I've setup is only accessible by registered users), and I found it surprisingly easy :-)
 +
 +Before making the changes below, make a backup copy in case it doesn't work or you make a typo which stops your wiki working :!:
 +
 +  - Edit ''inc/changelog.php'' and update **function _handleRecent** to support filtering by user. Change <code>function _handleRecent($line,$ns,$flags,&$seen){</code> to <code>function _handleRecent($line,$ns,$flags,&$seen,$user){</code> and then inside the function just before <code>  // filter namespace</code> add the following two lines <code>  // filter user
 +  if (($user) && ($recent['user'] != $user)) return false;</code>
 +  - Still in ''inc/changelog.php'', update **function getRecents** to support (optional) filtering by user. Change <code>function getRecents($first,$num,$ns='',$flags=0){</code> to <code>function getRecents($first,$num,$ns='',$flags=0,$user=''){</code> and then change  <code>$rec = _handleRecent($lines[$i], $ns, $flags, $seen);</code> to  <code>$rec = _handleRecent($lines[$i], $ns, $flags, $seen, $user);</code>
 +  - Still in ''inc/changelog.php'', update **function getRecentsSince** to support (optional) filtering by user. Change <code>function getRecentsSince($from,$to=null,$ns='',$flags=0){</code> to <code>function getRecentsSince($from,$to=null,$ns='',$flags=0,$user=''){</code> and then change  <code>$rec = _handleRecent($lines[$i], $ns, $flags, $seen);</code> to  <code>$rec = _handleRecent($lines[$i], $ns, $flags, $seen, $user);</code>
 +  - Now we need to edit ''inc/html.php''. Find **function html_recent** and then just after the line that says ''global $ID;'' add the following <code>$user = isset($_REQUEST['user']) ? $_REQUEST['user'] : null;</code> Then scroll down a few lines and change //both// the getRecents lines to say <code>$recents = getRecents($first,$conf['recent'] + 1,getNS($ID),0,$user);</code> (i.e. append '',0,$user'' to the argument lists)
 +
 +That's it! Now you can filter the list of recent changes page by appending a user=//<username>// parameter to the URL e.g. ''?do=recent&user=myusername'' to show just changes by ''myusername''. Without any user parameter specified, it displays recent changes by all users, just as before.
  

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki