mirror of
https://github.com/scratchfoundation/swiki-confirmaccount.git
synced 2024-12-03 20:31:22 -05:00
Merge pull request #7 from jacob-g/master
Added a few fixes, including detection of Scratch Team members
This commit is contained in:
commit
b585046ae5
6 changed files with 134 additions and 84 deletions
|
@ -1,81 +1,91 @@
|
|||
<?php
|
||||
/*
|
||||
(c) Aaron Schulz 2007, GPL
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
http://www.gnu.org/copyleft/gpl.html
|
||||
*/
|
||||
|
||||
if ( !defined( 'MEDIAWIKI' ) ) {
|
||||
echo "ConfirmAccount extension\n";
|
||||
exit( 1 ) ;
|
||||
}
|
||||
|
||||
$wgExtensionCredits['specialpage'][] = array(
|
||||
'path' => __FILE__,
|
||||
'name' => 'Confirm User Accounts',
|
||||
'descriptionmsg' => 'confirmedit-desc',
|
||||
'author' => 'Aaron Schulz and Jacob G.',
|
||||
'url' => 'https://www.mediawiki.org/wiki/Extension:ConfirmAccount',
|
||||
);
|
||||
|
||||
# Load default config variables
|
||||
require( dirname( __FILE__ ) . '/ConfirmAccount.config.php' );
|
||||
|
||||
# Define were PHP files and i18n files are located
|
||||
require( dirname( __FILE__ ) . '/ConfirmAccount.setup.php' );
|
||||
ConfirmAccountSetup::defineSourcePaths( $wgAutoloadClasses, $wgExtensionMessagesFiles );
|
||||
|
||||
# Define JS/CSS modules and file locations
|
||||
ConfirmAccountUISetup::defineResourceModules( $wgResourceModules );
|
||||
|
||||
# Let some users confirm account requests and view credentials for created accounts
|
||||
$wgAvailableRights[] = 'confirmaccount'; // user can confirm account requests
|
||||
$wgAvailableRights[] = 'requestips'; // user can see IPs in request queue
|
||||
$wgAvailableRights[] = 'lookupcredentials'; // user can lookup info on confirmed users
|
||||
|
||||
# Actually register special pages
|
||||
ConfirmAccountUISetup::defineSpecialPages( $wgSpecialPages, $wgSpecialPageGroups );
|
||||
|
||||
# ####### HOOK CALLBACK FUNCTIONS #########
|
||||
|
||||
# UI-related hook handlers
|
||||
ConfirmAccountUISetup::defineHookHandlers( $wgHooks );
|
||||
|
||||
# Check for account name collisions
|
||||
$wgHooks['AbortNewAccount'][] = 'ConfirmAccountUIHooks::checkIfAccountNameIsPending';
|
||||
|
||||
# Schema changes
|
||||
$wgHooks['LoadExtensionSchemaUpdates'][] = 'ConfirmAccountUpdaterHooks::addSchemaUpdates';
|
||||
|
||||
# ####### END HOOK CALLBACK FUNCTIONS #########
|
||||
|
||||
# Load the extension after setup is finished
|
||||
$wgExtensionFunctions[] = 'efLoadConfirmAccount';
|
||||
|
||||
/**
|
||||
* This function is for setup that has to happen in Setup.php
|
||||
* when the functions in $wgExtensionFunctions get executed.
|
||||
* @return void
|
||||
*/
|
||||
function efLoadConfirmAccount() {
|
||||
global $wgEnableEmail;
|
||||
# This extension needs email enabled!
|
||||
# Otherwise users can't get their passwords...
|
||||
if ( !$wgEnableEmail ) {
|
||||
echo "ConfirmAccount extension requires \$wgEnableEmail set to true.\n";
|
||||
exit( 1 ) ;
|
||||
}
|
||||
}
|
||||
<?php
|
||||
|
||||
/*
|
||||
|
||||
(c) Aaron Schulz 2007, GPL
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
http://www.gnu.org/copyleft/gpl.html
|
||||
|
||||
*/
|
||||
|
||||
if ( !defined( 'MEDIAWIKI' ) ) {
|
||||
echo "ConfirmAccount extension\n";
|
||||
exit( 1 ) ;
|
||||
}
|
||||
|
||||
$wgExtensionCredits['specialpage'][] = array(
|
||||
'path' => __FILE__,
|
||||
'name' => 'Confirm User Accounts',
|
||||
'descriptionmsg' => 'confirmedit-desc',
|
||||
'author' => 'Aaron Schulz and Jacob G.',
|
||||
'url' => 'https://www.mediawiki.org/wiki/Extension:ConfirmAccount',
|
||||
);
|
||||
|
||||
# Load default config variables
|
||||
require( dirname( __FILE__ ) . '/ConfirmAccount.config.php' );
|
||||
|
||||
# Define were PHP files and i18n files are located
|
||||
require( dirname( __FILE__ ) . '/ConfirmAccount.setup.php' );
|
||||
|
||||
ConfirmAccountSetup::defineSourcePaths( $wgAutoloadClasses, $wgExtensionMessagesFiles );
|
||||
|
||||
# Define JS/CSS modules and file locations
|
||||
require( dirname( __FILE__ ) . '/frontend/ConfirmAccountUI.setup.php' );
|
||||
ConfirmAccountUISetup::defineResourceModules( $wgResourceModules );
|
||||
|
||||
# Let some users confirm account requests and view credentials for created accounts
|
||||
$wgAvailableRights[] = 'confirmaccount'; // user can confirm account requests
|
||||
$wgAvailableRights[] = 'requestips'; // user can see IPs in request queue
|
||||
$wgAvailableRights[] = 'lookupcredentials'; // user can lookup info on confirmed users
|
||||
|
||||
# Actually register special pages
|
||||
ConfirmAccountUISetup::defineSpecialPages( $wgSpecialPages, $wgSpecialPageGroups );
|
||||
|
||||
# ####### HOOK CALLBACK FUNCTIONS #########
|
||||
|
||||
# UI-related hook handlers
|
||||
ConfirmAccountUISetup::defineHookHandlers( $wgHooks );
|
||||
|
||||
# Check for account name collisions
|
||||
$wgHooks['AbortNewAccount'][] = 'ConfirmAccountUIHooks::checkIfAccountNameIsPending';
|
||||
|
||||
# Schema changes
|
||||
$wgHooks['LoadExtensionSchemaUpdates'][] = 'ConfirmAccountUpdaterHooks::addSchemaUpdates';
|
||||
|
||||
# ####### END HOOK CALLBACK FUNCTIONS #########
|
||||
|
||||
# Load the extension after setup is finished
|
||||
$wgExtensionFunctions[] = 'efLoadConfirmAccount';
|
||||
|
||||
/**
|
||||
|
||||
* This function is for setup that has to happen in Setup.php
|
||||
* when the functions in $wgExtensionFunctions get executed.
|
||||
* @return void
|
||||
|
||||
*/
|
||||
|
||||
function efLoadConfirmAccount() {
|
||||
global $wgEnableEmail;
|
||||
|
||||
# This extension needs email enabled!
|
||||
# Otherwise users can't get their passwords...
|
||||
|
||||
/*if ( !$wgEnableEmail ) {
|
||||
echo "ConfirmAccount extension requires \$wgEnableEmail set to true.\n";
|
||||
exit( 1 ) ;
|
||||
}*/
|
||||
}
|
||||
|
||||
|
|
|
@ -294,10 +294,10 @@ class AccountConfirmSubmission {
|
|||
}
|
||||
|
||||
# Actually send out the email (@TODO: rollback on failure including $wgAuth)
|
||||
$result = $user->sendMail(
|
||||
/*$result = $user->sendMail(
|
||||
$context->msg( 'confirmaccount-email-subj' )->inContentLanguage()->text(),
|
||||
$ebody
|
||||
);
|
||||
);*/
|
||||
|
||||
# Update user count
|
||||
$ssUpdate = new SiteStatsUpdate( 0, 0, 0, 0, 1 );
|
||||
|
|
|
@ -112,7 +112,7 @@ class AccountRequestSubmission {
|
|||
return;
|
||||
}
|
||||
$success = false;
|
||||
preg_match_all('%<div id="comments-\d+" class="comment +" data-comment-id="\d+">.*?<div class="actions-wrap">.*?<div class="name">\s+<a href="/users/(([a-zA-Z0-9]|-|_)+)">(([a-zA-Z0-9]|-|_)+)</a>\s+</div>\s+<div class="content">(.*?)</div>%ms', $data, $matches);
|
||||
preg_match_all('%<div id="comments-\d+" class="comment +" data-comment-id="\d+">.*?<div class="actions-wrap">.*?<div class="name">\s+<a href="/users/(([a-zA-Z0-9]|-|_)+)">(([a-zA-Z0-9]|-|_|\*)+)</a>\s+</div>\s+<div class="content">(.*?)</div>%ms', $data, $matches);
|
||||
unset($matches[2]);
|
||||
unset($matches[3]);
|
||||
unset($matches[4]);
|
||||
|
|
|
@ -135,6 +135,8 @@ There may be contact lists on site that you can use if you want to know more abo
|
|||
$2
|
||||
|
||||
There may be contact lists on site that you can use if you want to know more about user account policy.',
|
||||
'confirmaccount-altwarning' => 'The following accounts have made edits from the same IP address as this user:',
|
||||
'confirmaccount-warning' => 'Warning',
|
||||
|
||||
);
|
||||
|
||||
|
|
|
@ -1123,6 +1123,15 @@ Este código de confirmación caducará el $4.',
|
|||
La dirección de correo electrónico ha sido confirmada. Puedes confirmar la solicitud aquí "$2".',
|
||||
'acct_request_throttle_hit' => 'Perdón, ya has solicitado {{PLURAL:$1|1 cuenta|$1 cuentas}}.
|
||||
No puedes hacer ninguna otra solicitud.',
|
||||
|
||||
//Scratch-specific stuff
|
||||
'requestaccount-user-verification' => 'Verificion de usuario',
|
||||
'requestaccount-code-troubleshoot' => '\'\'\'Aviso:\'\'\' Si tienes problemas con el sistema de verificacion, por favor lee la [[Scratch_Wiki:Become a contributor/Verification code troubleshooting|pagina de soluciones]].',
|
||||
'requestaccount-set-pwd' => 'Decide la contrasena',
|
||||
'requestaccount-project-info' => 'Por favor ve al [$1 proyecto de verificacion] y comenta el codigo siguiente:<br />\'\'\'$2\'\'\'',
|
||||
'requestaccount-project-link' => 'http://scratch.mit.edu/projects/10135908/',
|
||||
'requestaccount-nocomment-error' => 'No aparece como hayas comentado el codigo.',
|
||||
'requestaccount-api-failed' => 'Estamos teniendo problemas con el servidor. Por favor trata de registrarte otra vez en un tiempo diferente.',
|
||||
);
|
||||
|
||||
/** Estonian (eesti)
|
||||
|
|
|
@ -421,6 +421,20 @@ class ConfirmAccountsPage extends SpecialPage {
|
|||
}
|
||||
$form .= '</fieldset>';
|
||||
}
|
||||
|
||||
//search for possible alt accounts
|
||||
$ip = $accountReq->getIP();
|
||||
$alts = $this->getUsersFromIP($ip);
|
||||
if (!empty($alts)) {
|
||||
foreach ($alts as &$user) {
|
||||
|
||||
}
|
||||
$form .= '<fieldset>';
|
||||
$form .= '<legend style="color:#F00; font-weight:bold">' . $this->msg('confirmaccount-warning') . '</legend>';
|
||||
$form .= '<strong>' . $this->msg('confirmaccount-altwarning') . '</strong>';
|
||||
$form .= '<ul><li>' . implode('</li><li>', $alts) . '</li></ul>';
|
||||
$form .= '</fieldset>';
|
||||
}
|
||||
|
||||
$form .= '<fieldset>';
|
||||
$form .= '<legend>' . $this->msg( 'confirmaccount-legend' )->escaped() . '</legend>';
|
||||
|
@ -746,6 +760,21 @@ class ConfirmAccountsPage extends SpecialPage {
|
|||
|
||||
return $r;
|
||||
}
|
||||
|
||||
function getUsersFromIP($ip) {
|
||||
global $wgShowExceptionDetails ;
|
||||
$wgShowExceptionDetails = true;
|
||||
$dbr = wfGetDB( DB_SLAVE );
|
||||
$result = $dbr->select('recentchanges', array('DISTINCT(rc_user_text)'), 'rc_ip=\'' . $ip . '\'');
|
||||
|
||||
$return = array();
|
||||
foreach ($result as $row) {
|
||||
$return[] = (string)$row->rc_user_text;
|
||||
}
|
||||
array_unique($return);
|
||||
|
||||
return $return;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue