[Mediawiki-l] For hooks, how to tell if user is in edit mode?

Kelly Jones kelly.terry.jones at gmail.com
Tue May 29 01:18:46 UTC 2007


I'm writing a ArticleAfterFetchContent hook:

$wgHooks['ArticleAfterFetchContent'][] = 'myArticleAfterFetchContent';

function myArticleAfterFetchContent (&$article) { ... }

Inside myArticleAfterFetchContent, how do I tell if the user is
in edit/view source mode?

A hacky way that almost works: if (isset($article->mMinorEdit)) {...}

This works fine if the user has permission to edit, but not when I'm
using the "view source" hack (user who can't edit can still view the
source):

$wgHooks['userCan'][] = 'fnMyUserCan';
function fnMyUserCan ($title, $user, $action, $result) {
 if (($action == 'edit') && $user->isAnon()) {$result = false;}
}

What's the correct way of telling if a user is edit mode, even if he's
viewing the source? I don't want my hook to run in this case, because
I want people to see/edit what's stored in the MySQL backend *before*
my hook processes it.

-- 
We're just a Bunch Of Regular Guys, a collective group that's trying
to understand and assimilate technology. We feel that resistance to
new ideas and technology is unwise and ultimately futile.



More information about the MediaWiki-l mailing list