summaryrefslogtreecommitdiff
path: root/extensions
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2009-06-10 22:49:06 +0200
committerPierre Schmitz <pierre@archlinux.de>2009-06-10 22:49:06 +0200
commit37d7a76457d6fe20680c2eeaf0c79fd2343908bb (patch)
tree0b4ffa4c88d2eb9439af26c148e03ff7eb981a07 /extensions
parent6c5a17a2ca950c6d3bb8db2febe4c242bef8b861 (diff)
just cosmetics
Diffstat (limited to 'extensions')
-rw-r--r--extensions/LLAuthPlugin.php174
1 files changed, 88 insertions, 86 deletions
diff --git a/extensions/LLAuthPlugin.php b/extensions/LLAuthPlugin.php
index b755f373..c790e4ea 100644
--- a/extensions/LLAuthPlugin.php
+++ b/extensions/LLAuthPlugin.php
@@ -1,127 +1,129 @@
<?php
-$wgHooks['isValidPassword'][] = 'LLAuthPlugin::isValidPassword';
+$wgHooks['isValidPassword'][] = 'LLAuthPlugin::isValidPassword';
-$wgExtensionCredits['other'][] = array(
+$wgExtensionCredits['other'][] = array(
'name' => 'LLAuthPlugin',
+ 'version' => '3.2',
'description' => 'Authentifizierung am LL-Forum',
'author' => 'Pierre Schmitz',
- 'url' => 'http://www.archlinux.de',
+ 'url' => 'http://www.archlinux.de'
);
require_once('includes/AuthPlugin.php');
+
class LLAuthPlugin extends AuthPlugin {
+public static function isValidPassword($password) {
+ $length = strlen($password);
+ return ($length >= 6 && $length <= 25);
+}
- public static function isValidPassword($password) {
- $length = strlen($password);
- return ($length >= 6 && $length <= 25);
- }
+private function getUserData($username) {
+ $dbr = wfGetDB( DB_SLAVE );
- private function getUserData($username) {
- $dbr = wfGetDB( DB_SLAVE );
+ $result = $dbr->safeQuery('SELECT id, name, email, realname FROM current.users WHERE name = ?', $username);
+ $data = $result->fetchRow();
+ $result->free();
- $result = $dbr->safeQuery('SELECT id, name, email, realname FROM current.users WHERE name = ?', $username);
- $data = $result->fetchRow();
- $result->free();
+ return $data;
+}
+
+public function userExists( $username ) {
+ $dbr = wfGetDB( DB_SLAVE );
- return $data;
+ try {
+ $result = $dbr->safeQuery('SELECT id FROM current.users WHERE name = ?', $username);
+ $exists = ($result->numRows() > 0 ? true : false);
+ $result->free();
+ } catch (Exception $e) {
+ $exists = false;
}
- public function userExists( $username ) {
- $dbr = wfGetDB( DB_SLAVE );
+ return $exists;
+}
- try {
- $result = $dbr->safeQuery('SELECT id FROM current.users WHERE name = ?', $username);
- $exists = ($result->numRows() > 0 ? true : false);
- $result->free();
- } catch (Exception $e) {
- $exists = false;
- }
+public function authenticate( $username, $password ) {
+ $dbr = wfGetDB( DB_SLAVE );
- return $exists;
+ try {
+ $result = $dbr->safeQuery('SELECT id FROM current.users WHERE name = ? AND password = ?', $username, sha1($password));
+ $authenticated = ($result->numRows() > 0 ? true : false);
+ $result->free();
+ } catch (Exception $e) {
+ $authenticated = false;
}
- public function authenticate( $username, $password ) {
- $dbr = wfGetDB( DB_SLAVE );
-
- try {
- $result = $dbr->safeQuery('SELECT id FROM current.users WHERE name = ? AND password = ?', $username, sha1($password));
- $authenticated = ($result->numRows() > 0 ? true : false);
- $result->free();
- } catch (Exception $e) {
- $authenticated = false;
- }
+ return $authenticated;
+}
- return $authenticated;
- }
+public function modifyUITemplate( &$template ) {
+ $template->set( 'usedomain', false );
+ $template->set('link', 'Um Dich hier anzumelden, nutze Deine Konto-Daten aus dem <a href="http://forum.archlinux.de/">archlinux.de-Forum</a>.');
+}
- public function modifyUITemplate( &$template ) {
- $template->set( 'usedomain', false );
- $template->set('link', 'Um Dich hier anzumelden, nutze Deine Konto-Daten aus dem <a href="http://forum.archlinux.de/">archlinux.de-Forum</a>.');
- }
+public function setDomain( $domain ) {
+ $this->domain = $domain;
+}
- public function setDomain( $domain ) {
- $this->domain = $domain;
- }
+public function validDomain( $domain ) {
+ return true;
+}
- public function validDomain( $domain ) {
- return true;
- }
+public function updateUser( &$user ) {
+ return $this->initUser($user);
+}
- public function updateUser( &$user ) {
- return $this->initUser($user);
- }
+public function autoCreate() {
+ return true;
+}
- public function autoCreate() {
- return true;
- }
+public function allowPasswordChange() {
+ return false;
+}
- public function allowPasswordChange() {
- return false;
- }
+public function setPassword( $user, $password ) {
+ return false;
+}
- public function setPassword( $user, $password ) {
- return false;
- }
+public function updateExternalDB( $user ) {
+ // this way userdata is allways overwritten by external db
+ return $this->initUser($user);
+}
- public function updateExternalDB( $user ) {
- // this way userdata is allways overwritten by external db
- return $this->initUser($user);
- }
+public function canCreateAccounts() {
+ return false;
+}
- public function canCreateAccounts() {
- return false;
- }
+public function addUser( $user, $password, $email = '', $realname = '' ) {
+ return false;
+}
- public function addUser( $user, $password, $email = '', $realname = '' ) {
- return false;
- }
+public function strict() {
+ return true;
+}
- public function strict() {
- return true;
- }
+public function strictUserAuth( $username ) {
+ return true;
+}
- public function strictUserAuth( $username ) {
- return true;
+public function initUser( &$user, $autocreate=false ) {
+ try {
+ $data = $this->getUserData($user->getName());
+ $user->setEmail($data['email']);
+ $user->confirmEmail();
+ $user->setRealName($data['realname']);
+ } catch (Exception $e) {
+ return false;
}
+ return true;
+}
- public function initUser( &$user, $autocreate=false ) {
- try {
- $data = $this->getUserData($user->getName());
- $user->setEmail($data['email']);
- $user->confirmEmail();
- $user->setRealName($data['realname']);
- } catch (Exception $e) {
- return false;
- }
- return true;
- }
+public function getCanonicalName( $username ) {
+ return strtoupper(substr($username, 0, 1)).substr($username, 1);
+}
- public function getCanonicalName( $username ) {
- return strtoupper(substr($username, 0, 1)).substr($username, 1);
- }
}
?>