AuthMoodle: Difference between revisions
From MoodleDocs
Helen Foster (talk | contribs) m (category) |
|||
(10 intermediate revisions by 5 users not shown) | |||
Line 1: | Line 1: | ||
=AuthMoodle.php= | =AuthMoodle.php= | ||
(See also [[MediawikiSSO]]) | |||
* an extension of mediawiki's AuthPlugin class so that moodle users can sign in to a mediawiki with the same login/pw | * an extension of mediawiki's AuthPlugin class so that moodle users can sign in to a mediawiki with the same login/pw | ||
Line 5: | Line 7: | ||
* download from http://moodle.org/file.php/5/moddata/forum/366/196104/AuthMoodle.php | * download from http://moodle.org/file.php/5/moddata/forum/366/196104/AuthMoodle.php | ||
* first posted by Martin Dougiamas in april 2006 in http://moodle.org/mod/forum/post.php?reply=196104 as an attachment | * first posted by Martin Dougiamas in april 2006 in http://moodle.org/mod/forum/post.php?reply=196104 as an attachment | ||
quoting Martin's instructions based on the root folder of the wikimedia installation: | quoting Martin's instructions based on the root folder of the wikimedia installation: | ||
Line 12: | Line 13: | ||
Then you just put this in LocalSettings.php: | Then you just put this in LocalSettings.php: | ||
<pre> | |||
require_once( 'extensions/AuthMoodle.php' ); | require_once( 'extensions/AuthMoodle.php' ); | ||
$wgAuth = new AuthMoodle(); | $wgAuth = new AuthMoodle(); | ||
$wgAuth->setAuthMoodleTablePrefix(); | $wgAuth->setAuthMoodleTablePrefix(''); | ||
$wgAuth->setAuthMoodleDBServer('yoursite.org'); | $wgAuth->setAuthMoodleDBServer('yoursite.org'); | ||
$wgAuth->setAuthMoodleDBName('yourdb'); | $wgAuth->setAuthMoodleDBName('yourdb'); | ||
$wgAuth->setAuthMoodleUser('yourdbuser'); | $wgAuth->setAuthMoodleUser('yourdbuser'); | ||
$wgAuth->setAuthMoodlePassword('yourdbpass'); | $wgAuth->setAuthMoodlePassword('yourdbpass'); | ||
</pre> | |||
==Bugs with AuthMoodle in mediawiki 1.7== | |||
* preferences are no longer sticky (they pretend to save but don't really save)<br>'''fix:''' disable this '''if''' in includes/SpecialPreferences.php around line 290: | |||
'''/*''' | |||
if (!$wgAuth->updateExternalDB($wgUser)) { | |||
$this->mainPrefsForm( wfMsg( 'externaldberror' ) ); | |||
return; | |||
} | |||
'''*/''' | |||
* if the moodle database prefix is different from the mediawiki database prefix must match (or be blank)<br>'''fix:''' edit the function tableName in includes/Database.php around line 1310 and 1313: | |||
function tableName( $name ) { | |||
global $wgSharedDB''', $wgAuth'''; | |||
# Skip quoted literals | |||
if ( $name{0} != '`' ) { | |||
if ( $this->mTablePrefix !== '' && strpos( '.', $name ) === false | |||
'''&& strpos ($name, $wgAuth->mAuthMoodleTablePrefix) === false''' ) { | |||
* for mediawiki 1.7, I had to change line 33 to '''includes/'''AuthPlugin.php and comment out line 223-226 (refers to a non-existent function) | |||
==See also== | |||
* bugtracker conversation leading to creation of AuthMoodle http://moodle.org/bugs/bug.php?op=show&bugid=4666 | |||
* usage info: [[MoodleDocs:Authentication]] | |||
* based probably on http://svn.wikimedia.org/svnroot/mediawiki/trunk/extensions/auth/ | |||
[[Category:Contributed code]] | |||
[[Category:MoodleDocs]] | |||
[[Category:Developer]] |
Latest revision as of 06:06, 4 June 2008
AuthMoodle.php
(See also MediawikiSSO)
- an extension of mediawiki's AuthPlugin class so that moodle users can sign in to a mediawiki with the same login/pw
- used in this https://docs.moodle.org mediawiki production site
- download from http://moodle.org/file.php/5/moddata/forum/366/196104/AuthMoodle.php
- first posted by Martin Dougiamas in april 2006 in http://moodle.org/mod/forum/post.php?reply=196104 as an attachment
quoting Martin's instructions based on the root folder of the wikimedia installation:
Save it in extensions/AuthMoodle.php. Then you just put this in LocalSettings.php:
require_once( 'extensions/AuthMoodle.php' ); $wgAuth = new AuthMoodle(); $wgAuth->setAuthMoodleTablePrefix(''); $wgAuth->setAuthMoodleDBServer('yoursite.org'); $wgAuth->setAuthMoodleDBName('yourdb'); $wgAuth->setAuthMoodleUser('yourdbuser'); $wgAuth->setAuthMoodlePassword('yourdbpass');
Bugs with AuthMoodle in mediawiki 1.7
- preferences are no longer sticky (they pretend to save but don't really save)
fix: disable this if in includes/SpecialPreferences.php around line 290:
/* if (!$wgAuth->updateExternalDB($wgUser)) { $this->mainPrefsForm( wfMsg( 'externaldberror' ) ); return; } */
- if the moodle database prefix is different from the mediawiki database prefix must match (or be blank)
fix: edit the function tableName in includes/Database.php around line 1310 and 1313:
function tableName( $name ) { global $wgSharedDB, $wgAuth; # Skip quoted literals if ( $name{0} != '`' ) { if ( $this->mTablePrefix !== && strpos( '.', $name ) === false && strpos ($name, $wgAuth->mAuthMoodleTablePrefix) === false ) {
- for mediawiki 1.7, I had to change line 33 to includes/AuthPlugin.php and comment out line 223-226 (refers to a non-existent function)
See also
- bugtracker conversation leading to creation of AuthMoodle http://moodle.org/bugs/bug.php?op=show&bugid=4666
- usage info: MoodleDocs:Authentication
- based probably on http://svn.wikimedia.org/svnroot/mediawiki/trunk/extensions/auth/