Hello Out There,
 
my english isn't that good, I've added the discription of my problem in german 
below.
 
I'm trying to integrate multiple MediaWikis into my own page. I've some own 
login-structures and mutiple projects which can have a wiki. If a user is a 
member in a project holding a wiki, he may access this trough my own site.
The wiki-farm is set up via database-prefixes, so every "sub-wiki" has its own 
prefix. I think I need this, because I have to generate new wikis in runtime 
from my page. When calling the wiki (via IFrame from my own site) I'm adding an 
get-parameter which indicates which wiki should be loaded and set the 
database-prefix as needed. In Mediawiki's config I'm saving this parameter in a 
Cookie, so that wiki-internal links will work (they don't have the 
get-parameter). Like this it's possible to access multiple wikis at the moment.
 
One Issue here: If a user accesses my page via multiple tabs or 
browser-windows, they get strange errors if editing a page on one tab and 
surfing an other wiki on an other tab. Like this they get the cookie of the 
other wiki while editing the first. If they hit save on the first tab, it seams 
that they override the content in the second wiki (second tab) with the one 
supposed to come to the first. It seams logic that this happens, but I have no 
clue how to prevent this. Is it possible to add an additional parameter to 
every wiki-generated link, so that I can add the "db-prefix" into every link? 
That way I wouldn't need the Cookie.
 
Additionally I have some (not completly working) autentication-extension 
running that checks if the sessionCookie of my own site is set properly and if 
this user may have access to the actual wiki. If everything is ok, I'm checking 
If the user is currently logged in and if not I try to do so. This seams to 
work, but sometimes users get an error while editing a wiki saying that 
"Session-Data" is lost and that they should try to log off and on. Mostly its 
enough to cklick "save" again and everything works as expected.
This is why I think that there could be some errors in my 
authentication-function.
After hours of reading documentation and other working examples I came to the 
following. But because of missing documentation (or me not finding it) I'm not 
sure if this is the right approach to login a User correctly.
 
Now my login-hook looks that way: (sorry for some german comments)
function Auth_internal_user_hook() {
    global $wgUser;
    global $wgRequest;
    global $_REQUEST;
    global $wikiName;
 
    // For a few special pages, don't do anything.
    $title = $wgRequest->getVal('title') ;
    if ($title == 'Special:Userlogout' || $title == 'Special:Userlogin') {
         return;
    }
 
    //Prüfen ob eine session existiert.
    $wgUser = User::newFromSession();
    if ($wgUser->isLoggedIn()) {
      if ($username != $wgUser->mName) {
        //hier ist der falsche am Werk
        $wgUser->logout();
      }
    }
    
    if ((isset($_COOKIE['INTERNAL_SESSION_ID']) && $SID = 
$_COOKIE['INTERNAL_SESSION_ID']) || (isset($_GET['sid']) && $SID = 
$_GET['sid'])){
      $user = db_getUserBySessionId($SID);
      $project = db_getProjectByWikiName($wikiName);
      if (is_array($project) && is_array($user)){
        if (db_isActiveUserInProject($user['UId'], $project['PId'])){
          $username = $user['userName'];
        } else {
          //keiner eingeloggt
          $wgUser->logout();
          return;
        }
      } else {
        //keiner eingeloggt
        $wgUser->logout();
        return;
      }
    } else {
      //keiner eingeloggt
      $wgUser->logout();
      return;
    }   
   
   //Benutzer anlegen
    $u = User::newFromName( $username );
    if (is_null($u)) {
        # Invalid username or some other error
        return;
    }
 
    //und diesen Benutzer als 'normalen' user fürs System setzen
    $wgUser = $u;
    //wenn der user in der WikiDB existiert hat er da auch eine id.
    if ($u->getId() != 0) {
        # also return, but user is known. set Cookies, et al
        $wgUser->setCookies();
        $wgUser->saveSettings();
        return;
    }
 
    //er hat keine Id, also müssen wir den erst erstellen.
    include 'includes/SpecialUserlogin.php';
    $form = new LoginForm( $wgRequest );
    $form->initUser( $wgUser );
    $wgUser->saveSettings();
    
    return;
}
 
Has anyone an Idea how to fix this Issue? Maybe I have to do it an other way?
 
I hope you can understand my problems.
 
Thanks,
Markus
 
---
 
Und alles nochmal auf Deutsch:
Ich arbeite Momentan an einer Seite in der mehrere Mediawikis eingebunden 
werden sollen. Ein user kann dort Mitglied in mehreren Projekten sein, die 
ihrerseits ein wiki haben können. Da bereits zum Eintritt in meine seite ein 
Login erfolgt, möchte ich den vom Media-Wiki umgehen.
Ruft ein Benutzer meine eigene Seite auf, in der das Wiki eingebunden wird (per 
IFrame), hänge ich an die Iframe-src einen get-Parameter an, mit dem ich an die 
Wiki-Software übermittle welches wiki der Farm geladen werden soll. Alle wikis 
haben also die selben Source-Dateien, und werden über verschiedene 
Datenbank-Prefixe getrennt. Das ist notwendig, weil ich zur Laufzeit neue Wikis 
erstellen muss.
Aus dem angesprochenen Get-Parameter wird also der DB-Prefix erstellt und damit 
die DB geladen. Damit auch weitere Seitenaufrufe intern funktionieren (die 
links vom Media-wiki haben ja meinen Parameter nicht) setze ich einen Cookie 
der alternativ abgefragt wird.
Ich stoße hiermit natürlich an Grenzen, wenn jemand über mehrere Fenster in 
meiner Seite surft. Öffnet er in Tab1 eine Wiki-seite zum editieren, beginnt 
damit und öffnet in Tab2 eine Seite eines anderen wikis meiner Farm, so ändert 
sich der Cookie und beim Speichern in Tab1 wird der Inhalt vom Wiki aus Tab2 
überschrieben, sofern es dort eine gleichnamige Seite gibt. Zumindest ist das 
meine Erklärung für einige Bug-Berichte meiner User. Hat hier jemand eine Idee 
wie man das Problem lösen kann? Gibt es eine Möglichkeit an alle intern 
erstellten Links einen eigenen Parameter anzuhängen?
 
Ein Weiteres Problem scheint vom Login her zu kommen. Ich umgehe die 
Login-Routinen, indem ich über eine Extension in "$wgExtensionFunctions[]" eine 
funktion (siehe oben) aufrufe, die meinem Verständnis nach den User einloggen 
sollte. Die Dokumentation ist da aber nicht berauschend, oder ich habe sie 
nicht gefunden. Das Problem ist folgendes:
Wenn ich ein wiki aufrufe funktioniert alles Einwandfrei. Ich kann dort alles 
lesen wie ich soll, funktioniert. Editiere ich jetzt eine Seite, klappt auch 
alles, bis zum Speichern. Dort bekomme ich einen Fehler, dass "Sitzungsdaten 
verloren gegangen" sind. Ein erneuter Klick auf Speichern funktioniert dann 
aber meistens und die Daten sind korrekt gespeichert. Leider war es mir nicht 
möglich das Problem noch weiter einzugrenzen. Wenn mir jemand von euch sagen 
kann wie ich einen User korrekt einlogge, bzw wenn er nicht existiert einen 
entsprechenden in der Wiki-software erstelle oder einen anderen Ansatz hat um 
mein Problem zu lösen würde mich das sehr freuen.
 
Vielen Dank für eure Mühe
Markus

_______________________________________________
MediaWiki-l mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-l

Reply via email to