搞定Drupal7下AuthDrupal + MediawikiAuth用户同步问题
Drupal7下尝试了AuthDrupal + MediawikiAuth,让Drupal 7和Mediawiki用户Login和Logout同步,但是之前一直都没有起作用。参考了:http://drupal.org/node/1057708 , 因为执行patch的时候还是出错,所以自己动手改了一个,终于同步了Drupal和Mediawiki。先是修改mediawikiauth.info, 只要将6.x改成7.x就可以了,下面是修改后的内容:
; $Id: mediawikiauth.info,v 1.3 2009/04/01 20:21:15 anarcat Exp $ name = Mediawiki auth bridge description = Provides Drupal to Mediawiki login integration. package = Mediawiki core = 7.x ; Information added by drupal.org packaging script on 2009-04-01 version = "6.x-0.7" core = "7.x" project = "mediawikiauth" datestamp = "1238617559"
然后就是mediawikiauth.module,这个稍微麻烦一点,主要就是把mediawikiauth_user这个函数,拆分为mediawikiauth_user_login和mediawikiauth_user_logout,你怕麻烦的话,把mediawikiauth_user整个函数注释掉,然后把下面代码copy到你的mediawikiauth.module:
function mediawikiauth_user_login(&$edit, &$user) {
require_once('AuthDrupalEncode.php');
// switch ($op) {
// case 'login':
//mediawikiauth_load_config();
// create seperate session id so mediawiki can see the user!
$exp = time() + 2592000; // one month in seconds
$encoded_name = authdrupal_encode($user->name);
foreach( $GLOBALS['wgAuthDrupal_wiki_settings'] as $vals) {
// set the cookie that communicates the username
setcookie('DRXtrArgs', $user->name, $exp, $vals['wgCookiePath'], $vals['wgCookieDomain'] );
setcookie('DRXtrArgs2', $encoded_name, $exp, $vals['wgCookiePath'], $vals['wgCookieDomain'] );
// remove the loggedout cookie--not sure this is necessary; MW itself does not
// seem to do it when a user logs back in thru MW
setcookie( $vals['wgCookiePrefix'].'LoggedOut', '', time() - 3600, $vals['wgCookiePath'], $vals['wgCookieDomain'], $GLOBALS['wgCookieSecure'] );
}
// break;
}
function mediawikiauth_user_logout(&$edit, &$user) {
// case 'logout':
//mediawikiauth_load_config();
foreach( $GLOBALS['wgAuthDrupal_wiki_settings'] as $vals) {
// delete the cookie that communicates the username
setcookie("DRXtrArgs", "", time() - 3600, $vals['wgCookiePath'], $vals['wgCookieDomain']);
setcookie("DRXtrArgs2", "", time() - 3600, $vals['wgCookiePath'], $vals['wgCookieDomain']);
}
mediawikiauth_StaticUserLogout();
// break;
//
// }
}
其他头部的相关配置,根据你自己的情况,把wgAuthDrupal_wiki_settings相关参数修改一下就OK了~
- observer's blog
- Log in or register to post comments
© 2011 CMS中文社区.. Drupal theme by Kiwi Themes.
1 comment
下一步是把Mediawiki的头部
下一步是把Mediawiki的头部,修改为Drupal一样的Style