From 6d50b8d861289abfc372e5690265c1f0a7aecd21 Mon Sep 17 00:00:00 2001 From: Matthias Jordan Date: Wed, 10 Sep 2003 01:18:23 +0000 Subject: [PATCH] Moved some code to User.php, where it belongs. --- includes/SpecialUserlogin.php | 23 +++++++---------------- includes/User.php | 17 +++++++++++++++++ 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/includes/SpecialUserlogin.php b/includes/SpecialUserlogin.php index 62587cc03e..0cb8a2e47c 100644 --- a/includes/SpecialUserlogin.php +++ b/includes/SpecialUserlogin.php @@ -41,7 +41,10 @@ function wfSpecialUserlogin() } $u->saveSettings(); - mailPasswordInternal($u); + if (mailPasswordInternal($u) == NULL) + { + return; + } $wgOut->setPageTitle( wfMsg( "accmailtitle" ) ); $wgOut->setRobotpolicy( "noindex,nofollow" ); @@ -78,7 +81,7 @@ function wfSpecialUserlogin() global $wgUser, $wgOut, $wpPassword, $wpRetype, $wpName, $wpRemember; global $wpEmail, $wgDeferredUpdateList; - if (!userAllowedToCreateAccount()) { + if (!$wgUser->isAllowedToCreateAccount()) { userNotPrivilegedMessage(); return; } @@ -188,7 +191,7 @@ function wfSpecialUserlogin() /* private */ function mailPasswordInternal( $u ) { - global $wgUser, $wpName, $wgDeferredUpdateList, $wgOutputEncoding; + global $wpName, $wgDeferredUpdateList, $wgOutputEncoding; global $wgPasswordSender; if ( "" == $u->getEmail() ) { @@ -240,18 +243,6 @@ function wfSpecialUserlogin() -/* private */ function userAllowedToCreateAccount() -{ - global $wgUser, $wgWhitelistAccount; - $allowed = false; - - if (!$wgWhitelistAccount) { return 1; }; // default behaviour - foreach ($wgWhitelistAccount as $right => $ok) { - $userHasRight = (!strcmp($right, "user") || in_array($right, $wgUser->getRights())); - $allowed |= ($ok && $userHasRight); - } - return $allowed; -} function userNotPrivilegedMessage() @@ -342,7 +333,7 @@ color='red'>$err\n" ); "); - if (userAllowedToCreateAccount($wgUser)) { + if ($wgUser->isAllowedToCreateAccount()) { $wgOut->addHTML("  $ypa: diff --git a/includes/User.php b/includes/User.php index 157348bac5..2881837e99 100644 --- a/includes/User.php +++ b/includes/User.php @@ -603,6 +603,23 @@ class User { $ipblock->insert(); } + + + function isAllowedToCreateAccount() + { + global $wgWhitelistAccount; + $allowed = false; + + if (!$wgWhitelistAccount) { return 1; }; // default behaviour + foreach ($wgWhitelistAccount as $right => $ok) { + $userHasRight = (!strcmp($right, "user") || in_array($right, $this->getRights())); + $allowed |= ($ok && $userHasRight); + } + return $allowed; + } + + + } ?> -- 2.20.1