Doh, I forgot to return 'true' from the function. Insert
return true;
after the line starting with "$result = "
Greg
On 5/3/06, Gregory Szorc <gregory.szorc(a)gmail.com> wrote:
My version is as follows:
<?php
$wgExtensionFunctions[] = 'OriginalAuthorHooks';
function OriginalAuthorHooks() {
global $wgHooks;
$wgHooks['userCan'][] = 'OriginalAuthorHooks_UserCan';
}
function OriginalAuthorHooks_UserCan(&$title, &$user, $action, &$result) {
if ($action === 'edit') {
$article = new Article($title, 0); //this loads the most recent
version of article
$result = ($user->getID() == $article->getUser()) ? true : false;
}
}
?>
This will only allow editing by the user who edited the most recent
revision. To use it, save it as "OriginalAuthorEdit.php " in your
'extensions' subdirectory inside the MediaWiki installation root. Then,
insert "require_once('OriginalAuthorEdit.php')" near the bottom of
LocalSettings.php
Gregory Szorc
gregory.szorc(a)gmail.com
On 5/3/06, Christophe PROME <chprome(a)yahoo.fr> wrote:
Hello Erin,
I don't know if it will help but i've juste wrote something similar...
My extension check if the user which wants to edit a page belonging
to a special namespace is the same person who
edited it in first.
Well the code speaks for himself (sorry for the french comments) :
------------------------------------------------------------------------
-----
<?PHP
$wgExtensionFunctions[] = 'Wikinsa_Hooks';
function Wikinsa_Hooks() {
global $wgHooks;
$wgHooks['userCan'][] = 'verifDroitsUsers';
}
function verifDroitsUsers(&$title, &$user, $action, &$result) {
//--------------------------------------------------------
//
// Vérifie si il s'agit d'une requête d'EDITION
// et si l'utilisateur n'est pas un SYSOP
//
//--------------------------------------------------------
if($action == 'edit' && !$user->isSysop())
{
// ------------------------ //
// --- Page UTILISATEUR --- //
// ------------------------ //
if($title->getNamespace() == NS_USER)
{
// --- Compare les noms -- //
if ($user->getName() != $title->getText() ) {
$result = false;
}
}
// --------------------------- //
// --- Expérience de Stage --- //
// --------------------------- //
if ($title->getNamespace() == 100) {
// --- connexion au SGBD --- //
$dbw =& wfGetDB( DB_MASTER );
// --- titre de la page --- //
$titre_page = $title->getText();
$titre_page = str_replace(" ","_",
$titre_page);
// --- les tables de la base --- //
$table_1 = $dbw->tableName( 'page' );
$table_2 = $dbw->tableName( 'revision' );
// --- 1ère requête : id de la page --- //
$res1 = $dbw->query("SELECT page_id FROM
$table_1 WHERE
page_title=\"$titre_page\";");
$ligne = mysql_fetch_row($res1);
$id_page = $ligne[0];
// ---- 2ème requête : nom de l'utilisateur ---/
$res2 = $dbw->query("SELECT rev_user_text FROM
$table_2 WHERE
rev_page = \"$id_page\" LIMIT 1;");
$ligne = mysql_fetch_row($res2);
$nom_user = $ligne[0];
// --- Compare le nom du créateur et du visiteur
--- /
if($user->getName() != $nom_user && $nom_user !=
null)
$result = false;
}
}
}
?>
------------------------------------------------------------------------
-----
Christophe
_______________________________________________
MediaWiki-l mailing list
MediaWiki-l(a)Wikimedia.org
http://mail.wikipedia.org/mailman/listinfo/mediawiki-l