Username:
Password:
Search for Plugins: Advanced
Please Sign in, Register or Resend Activation Email

Forums

  e107 Coders.org :: Forums :: E107 Plugins :: Current Plugin Projects
 
<< Previous thread | Next thread >>  
Integration of Mediawiki v1.5.6 into e107 v0.7+     Go to page   <<        >>        
Author Post
[TKS]
Mon May 29 2006, 03:39PM
Registered Member #14680
Joined: Thu Aug 19 2004, 11:50PM
Location:
Posts: 20
Got everything working fine with the latest mediawiki...users authenticate across databases and things work well.

The problem I'm facing is that this doesn't pop into an iframe...it just redirects to the mediawiki front page. Is this what it is supposed to do?

The other thing is wiki.php....I assumed that this was to be placed inside the e107 public directory and not the wiki/ directory...hopefully I'm right about this.

If I could figure out how e107 creates its cookies, I'd begin on integrating the cookies between sites. But the documentation on this subject is somewhat thin and questions at the main site go unanswered on this subject.
Back to top
Website
Daddy Cool
Mon May 29 2006, 04:42PM

Registered Member #27909
Joined: Sun Jul 03 2005, 09:05PM
Location: France
Posts: 30
Have you change the file wiki/skins/monobook/wikibits.js ?

You need to put comma at a certain line to prevent mediawiki popping out of the iframe...
Back to top
Website
rokinus
Thu Jun 01 2006, 02:18PM
Registered Member #51856
Joined: Mon May 15 2006, 02:54PM
Location:
Posts: 7
[TKS wrote ...
]
Got everything working fine with the latest mediawiki...users authenticate across databases and things work well.

The problem I'm facing is that this doesn't pop into an iframe...it just redirects to the mediawiki front page. Is this what it is supposed to do?

The other thing is wiki.php....I assumed that this was to be placed inside the e107 public directory and not the wiki/ directory...hopefully I'm right about this.

If I could figure out how e107 creates its cookies, I'd begin on integrating the cookies between sites. But the documentation on this subject is somewhat thin and questions at the main site go unanswered on this subject.


I've done some development around e107 cookie to automaticaly login user into mediawiki but it's not really clean. You can look to the function init_session() in class.php to have an overview of how the cookie is processed to login into e107.

Here is my code:
it is the same installation process, you just have to change some code. Make sure that the name of your e107 cookie is "e107cookie".
Instead of using the original Auth_e107.php, use this one:
<?php

$wgGroupPermissions
['*'    ]['createaccount']   = false;
$wgGroupPermissions['*'    ]['createaccount']   = false;
$wgGroupPermissions['*'    ]['edit']            = false;

# use new MediaWiki hooks instead of hacking lots of Core code!
function Auth_e107_user_hook() {
    global 
$wgUser;
    global 
$wgRequest;
    global 
$_REQUEST;

    
// For a few special pages, don't do anything.
    
$title $wgRequest->getVal('title') ;
    if (
$title == 'Special:Userlogout' || $title == 'Special:Userlogin') {
      return;
    }

   
$ret ""// Lets be safe - anti- brute force attacks
   
include('e107.php');

   if (
$wgUser->isLoggedIn() && $wgUser->getName()==$ret['user_name'] ) {
      
$wgUser User::loadFromSession();
      return;
   }

   if ( 
$ret != "" ) {
       global 
$wgUser;
       
$wgUser User::newFromName$ret['user_name'] );

       if ( 
$wgUser->getID() == 0)  {
                  
$wgUser->addToDatabase();
                  
$wgUser->setPassword$ret['user_password']);
                  
$wgUser->setEmail$ret['user_email'] );
                  
$wgUser->setToken();
       }
       
$wgUser->setCookies();
       
$wgUser->saveSettings();
       return;
    }
    return;
}

require_once( 
'AuthPlugin.php' );

class 
Auth_e107extends AuthPlugin {

        function 
Auth_e107() {

                
# Define the table to be used
                // If there is a e107 cookie, call the user hook
                
if (isset($_COOKIE["e107cookie"]) ) {
                  global 
$wgExtensionFunctions;
                  if (!isset(
$wgExtensionFunctions)) {
                    
$wgExtensionFunctions = array();
                  } else if (!
is_array($wgExtensionFunctions)) {
                    
$wgExtensionFunctions = array( $wgExtensionFunctions );
                  }
                  
array_push($wgExtensionFunctions'Auth_e107_user_hook');
                }
                return;
        }

  
//return whether $username is a valid username
  
function userExists($username) {
    
// in media wiki 1.5.5 this should always be true for autocreate() to work right
     
return true;
  }

  
//whether the given username and password authenticate
  
function authenticate($username$password) {
     return isset(
$_COOKIE["e107cookie"]);
  }

  
//The authorization is external, so autocreate accounts as necessary
  
function autoCreate() {
     return 
true;
  }

  
//tell MediaWiki to not look in its database for user authentication and
  // that our authentication method is all that counts
  
function strict() {
     return 
true;
  }

  
//this function gets called when the user is created
  //$user is an instance of the User class (see includes/User.php)
  
function initUser(&$user) {
    
//unless you want the person to be nameless, you should probably populate
    // info about this user here
    //turn on e-mail notifications by default
    
$user->setOption('enotifwatchlistpages'1);
    
$user->setOption('enotifusertalkpages'1);
    
$user->setOption('enotifminoredits'1);
    
$user->setOption('enotifrevealaddr'1);
  }

  
//if using MediaWiki 1.5, we have a new function to modify the UI template!
  
function modifyUITemplate(&$template) {
    
//disable the mail new password box
    
$template->set("useemail"false);
    
//disable 'remember me' box
    
$template->set("remember"false);
    
$template->set("create"false);
    
$template->set("domain"false);
  }
}


?>


This file requires the file e107.php (to copy in the same folder too):
<?php
# e107.php

function connect()
{
  
// Check if the e107 tables are in a different database then the Wiki.
  
if ($GLOBALS['wge107_UseExtDatabase'] == true) {
    
// Connect to database.
    
$fresMySQLConnection = @mysql_connect($GLOBALS['wge107_MySQL_Host'],    //<-
                                           
$GLOBALS['wge107_MySQL_Username'], //<-
                                           
$GLOBALS['wge107_MySQL_Password']);

    
// Check if we are connected to the database.
    
if (!$fresMySQLConnection) {
       
mySQLError('There was a problem when connecting to the e107 database.<br />' //<-
                  
'Check your Host, user_name, and Password settings.<br />');
    } 
// End: if (!$fresMySQLConnection)

    // Select Database
    
$db_selected mysql_select_db($GLOBALS['wge107_MySQL_Database'], $fresMySQLConnection);

    
// Check if we were able to select the database.
    
if (!$db_selected) {
      
mySQLError('There was a problem when connecting to the e107 database.<br />' .
                 
'The database ' $GLOBALS['wge107_MySQL_Database'] . ' was not found.<br />');
    } 
// End: if (!$db_selected)

  
} else {
    
// Connect to database.
    
$fresMySQLConnection mysql_connect($GLOBALS['wgDBserver'], $GLOBALS['wgDBuser'], $GLOBALS['wgDBpassword']);

    
// Check if we are connected to the database.
    
if (!$fresMySQLConnection) {
      
mySQLError('There was a problem when connecting to the e107 database.<br />' //<-
                 
'Check your Host, user_name, and Password settings.<br />');
    } 
// End: if (!$fresMySQLConnection)

    // Select Database: This assumes the wiki and e107 are in the same database.
    
$db_selected mysql_select_db($GLOBALS['wgDBname']);

    
// Check if we were able to select the database.
    
if (!$db_selected) {
      
mySQLError('There was a problem when connecting to the e107 database.<br />' .
                 
'The database ' $GLOBALS['wgDBname'] . ' was not found.<br />');
    } 
// End: if (!$db_selected)
  
// End: if ($GLOBALS['wge107_UseExtDatabase'] == true)

  //$GLOBALS['gstrMySQLVersion'] = substr(mysql_get_server_info(), 0, 3); // Get the mysql version.

  
return $fresMySQLConnection;
// End: connect


        
function get_user_data($uid)
        {
          
$fresMySQLConnection connect();
          
$uid intval($uid);
          
$var = array();

          if(
$uid == 0) { return $var; }
            
$fstrMySQLQuery 'SELECT * FROM `'$GLOBALS['wge107_UserTB'] .'` AS u WHERE u.user_id= '$uid .'';

            
// Query Database.
            
$fresMySQLResult mysql_query($fstrMySQLQuery$fresMySQLConnection//<-
              
or die(mySQLError('Unable to view external table'));

            if (
$fresMySQLResult) {
              while(
$faryMySQLResult mysql_fetch_array($fresMySQLResult)){
                
$var['user_email']  = $faryMySQLResult['user_email']; // Set Email Address.
                
$var['user_name']   = $faryMySQLResult['user_loginname'];  // Set Real Name.*/
                
$var['user_password'] = $faryMySQLResult['user_password'];
              } 
// End: while($faryMySQLResult = mysql_fetch_array($fresMySQLResult))
              
return $var;
            }
            return 
FALSE;
         }


        function 
e107session() {
               
                list(
$uid$upw)=(explode("."$_COOKIE["e107cookie"]));

                if (empty(
$uid) || empty($upw)) {
                  return 
"";
                }
                else {
                  
$result get_user_data($uid);
                  if(
is_array($result) && md5($result['user_password']) == $upw)
                  {
                    return 
$result;
                  }
                  else {
                    return 
"";
                  }
                }
        }

$ret e107session();

?>


Then you will have to hack the user registration process of e107 because mediawiki doesnt accept nicknames using special caracters (I spoke about that above).
And finally, you can modify the userlogin page of mediawiki (includes/templates/userlogin.php).


[ Edited Thu Jun 01 2006, 02:22PM ]
Back to top
[TKS]
Fri Jun 02 2006, 06:46PM
Registered Member #14680
Joined: Thu Aug 19 2004, 11:50PM
Location:
Posts: 20
Thanks much, I'll take a gander at this when I get moved into my new apt. (moving sux!)
Back to top
Website
[TKS]
Sat Jun 03 2006, 06:01AM
Registered Member #14680
Joined: Thu Aug 19 2004, 11:50PM
Location:
Posts: 20
tested this out by dropping an e107.php into the extensions directory along with your altered auth_e107.php...however, I get an echo of auth_e107.php in full when viewing the wiki (full text echo). I also get an error posted is calling out line 134 in localsettings.php...I'll look more into this later when I get my computer setup...working from a public computer right now
Back to top
Website
Clarendon
Sat Jun 03 2006, 05:18PM
Registered Member #52956
Joined: Sun May 28 2006, 03:48PM
Location:
Posts: 6
[TKS wrote ...
]
Got everything working fine with the latest mediawiki...users authenticate across databases and things work well.

The problem I'm facing is that this doesn't pop into an iframe...it just redirects to the mediawiki front page. Is this what it is supposed to do?

The other thing is wiki.php....I assumed that this was to be placed inside the e107 public directory and not the wiki/ directory...hopefully I'm right about this.

If I could figure out how e107 creates its cookies, I'd begin on integrating the cookies between sites. But the documentation on this subject is somewhat thin and questions at the main site go unanswered on this subject.



TKS:
Yes, I also put wiki.php into the e107 directory. This cofused me as well.

I am having the same "pop-out" problem from the Iframe - but only in firefox! It works fine in IE and stays in the Iframe. I did make the javascript changes by copying Daddy Cool's wikibits.js file into the directory. I just loaded the whole thing yesterday so I'm using the latest version WikiMedia.

Anyone else having a similar problem?
Back to top
Daddy Cool
Mon Jun 05 2006, 03:55PM

Registered Member #27909
Joined: Sun Jul 03 2005, 09:05PM
Location: France
Posts: 30
I see you've been busy around here :)
I'm gonna finish my exam the week then go into that coding you've just add , Thanks ;)

----
By the way, if you are not using Mediawiki v1.6.2, I recommend that you keep the file wikibits.js and put comma // to the section :

// Un-trap us from framesets
// if (window.top != window)
// window.top.location = window.location;

(copy this exactly) It should solve your problem of popping out of iframe ;)
Back to top
Website
rokinus
Thu Jun 29 2006, 10:06PM
Registered Member #51856
Joined: Mon May 15 2006, 02:54PM
Location:
Posts: 7
so anynews about the development of that?
Back to top
MGenovese
Fri Jun 30 2006, 01:25AM
Registered Member #47043
Joined: Fri Mar 24 2006, 09:10PM
Location:
Posts: 12
Sorry I've been out of the loop here. I'm also interested in the progress made, and if the Mediawiki auto-login / cookies are working. I have been busy getting my own site up and running with e107 + Mediawiki (user still must login separately with e107 u/p). Would love to use a cookie-type solution so one e107 cookie allows access to the wiki.

As an aside, feel free to take a gander here to see how I've integrated Mediawiki so far. Open to ideas and suggestions. The big thorn in my side is how to pull in Wiki content seamless into e107 so it doesn't necessarily look like part of the wiki. I don't want to do this for all wiki pages, but just some where I just want the wiki content without the wiki look....if that makes sense. Using the "printable=yes" URL option works well for "The Daily Briefing" page on my site, but not for everything. Guess that's a separate topic.

Thanks!

[ Edited Fri Jun 30 2006, 01:31AM ]
Back to top
Clarendon
Fri Jun 30 2006, 10:37AM
Registered Member #52956
Joined: Sun May 28 2006, 03:48PM
Location:
Posts: 6
MGenovese,

Great looking site. I really like the logo and concept. I'm running into similar problems trying to get mine running. Essentially I want to have user-created content integrated into my site. My concern with the wiki solutions is that the type of audience I want to address (mostly non-technical, often older people) will get lost in the navigation of jumping between two different usability frameworks. I don't think people who are not familiar with wikis will understand how to navigate around.

So for the moment I'm trying to achieve the same goal with the Content Manager plugin from lisa. As you'll see from several of my posts, I'm having a hard time getting it running at the moment.

Anyway, please let me know if you want to collaborate offline. I tried to send you a private messaget but you don't have it enabled.
Back to top
Go to page   <<        >>   

Jump:     Back to top

Syndicate this thread: rss 0.92 Syndicate this thread: rss 2.0 Syndicate this thread: RDF
Powered by e107 Forum System
Render time: 0.2284 sec, 0.1271 of that for queries. DB queries: 48.