changed git call from https to git readonly
[atutor.git] / mods / mediawiki / README
1 ## MediaWiki Integration module for ATutor
2
3 ####################
4
5 This module allows you to manage MediaWiki as a course tool and open MediaWiki in an iframe within ATutor courses, and MyStart areas. It is a community wiki, meaning all users in all courses can access it. It also creates a single sign-on. When a user logs into ATutor, they  are automatically logged into Mediawiki.
6
7 **MediaWiki needs to be installed and configured before installing this module. See the MediaWiki documentation for instructions on installing and configuring it. MediaWiki needs to be installed on the same server as ATutor, though it may be installed in its own database.
8
9 http://www.mediawiki.org/wiki/Installation
10
11
12 ####################
13 Installing the ATutor MediaWiki Module:
14
15 1. Unzip the atutor_mediawiki.x.x.x.zip module file into the ATutor mods/ directory to create a "mediawiki/" directory.
16 2. Login to ATutor as the admin, click on the Modules tab then click Install Modules. Mediawiki should be listed. Select it and press the Install button.
17 3. Follow the installer instructions.
18 4. Once the module is installed, select the Mediawiki module now listed in the available modules in the Module Manager, then press the Enable button. This inserts another main navigation tab above.
19 5. Click the MediaWiki tab then enter the URL to the base directory under which Mediawiki is run (e.g. http://myserver.com/mediawiki/ , including the trailing slash), then press the Save button. MediaWiki should then appear below.
20 6. Next set the database access information for MediaWiki in the mw_config.php file in the  module directory (e.g mods/mediawiki), then save the file. This information is required if you intended on using the module detailed view to display recent changes in the wiki on the course home page, or on the student tools page.
21
22
23 #####################
24 Authenticate MediaWiki Users from the ATutor Members table (Single Sign-on)
25
26 This section is optional. If not implented, users will need to create an account on MediaWiki, and they'll need to manually login.
27
28 To remove the need to setup separate accounts in MediaWiki and ATutor, you can install the Auth viaMySQL extention. This effectively creates a single sign-on between ATutor and MediaWiki based on ATutor member accounts.
29
30 Extention details can be found at:
31 http://www.mediawiki.org/wiki/Extension:Auth_viaMySQL
32 (Just for information about the extension's origin. Instead follow the instructions below)
33
34 Note that you will probably want to install this extension before you start using MediaWiki with ATutor. Otherwise you may have conflicts between ATutor users and independent Mediawiki users owbership of content. The only account that should exist before installing the extension is the admin account created during the MediaWiki installation.
35
36 Copy Auth_viaMySQL.php, CacheTimer_viaMySQL.php, and  MySQLActiveUser.php from the ATutor MediaWiki module directory (mods/mediawiki/MySQL_Auth/) to the MediaWiki installation directory as follows:
37
38 MediaWiki/extensions/Auth_viaMySQL/Auth_viaMySQL.php
39 MediaWiki/extensions/Auth_viaMySQL/CacheTimer_viaMySQL.php
40 MediaWiki/MySQLActiveUser.php
41
42 (**You'll probably need to create the extensions/Auth_viaMySQL directory, and depending on how MediaWiki was installed, you may need root access to do that and to copy the files into the MediaWiki directory)
43
44 After the files are copied to the MediaWiki installation directory, copy the following code and paste it immediately before the first instance of the "$msg->addFeedback('LOGIN_SUCCESS');" statement of the login.php file located in the root directory of ATutor. This sets the MediaWiki authentication cookie for student and instructor users, but not for admin users. The admin user must login manually using the "MediaWiki Login" link under the MediaWiki tab in the admin area, using the admin login information created during the MediaWiki installation.
45
46 #####
47 # adjust the path in the first line below to the location of your MediaWiki installation directory. 
48
49         $mediawiki_install_path = "/var/lib/mediawiki/";
50         require_once($mediawiki_install_path.'MySQLActiveUser.php');
51         global $MySQLActiveUserData ;
52         global $db ;
53
54         $userName = $_POST['login'] ;
55         $command = "SELECT * FROM ".TABLE_PREFIX."members WHERE login='".$userName."';" ;
56         $result = mysql_query($command, $db);
57         $account = mysql_fetch_assoc($result) ;
58         if ($account)
59         {
60                 $current_mw_timecode = gmdate( 'YmdHis' ) ;
61                 $MySQLActiveUserData->set_cookie($account['login'],
62                                                                                         $account['member_id'],
63                                                                                         $account['password'],
64                                                                                         $account['email'],
65                                                                                         $current_mw_timecode) ;
66         }
67 #####
68
69 Copy the following code and paste it immediately after the "require(AT_INCLUDE_PATH.'vitals.inc.php');" statement of the logout.php file located in the root directory of ATutor. This deletes the MediaWiki authentication cookie when a user logs out of ATutor.
70
71 #####
72 # adjust the path in the first line below to the location of your MediaWiki installation directory. 
73
74         $mediawiki_install_path = "/var/lib/mediawiki/";
75         require_once($mediawiki_install_path.'MySQLActiveUser.php');
76         global $MySQLActiveUserData ;
77         $MySQLActiveUserData->clear_cookie() ;
78
79 #####
80
81 Add the following lines to the end of the MediaWiki LocalSettings.php file
82
83 #####
84
85         require_once($IP."/extensions/Auth_viaMySQL/Auth_viaMySQL.php");
86         require_once($IP."/extensions/Auth_viaMySQL/CacheTimer_viaMySQL.php");
87
88         $local_var_login_time = CacheTimer_viaMySQL() ;
89         $wgCacheEpoch = max( $wgCacheEpoch, $local_var_login_time ) ;
90         $wgCachePages = false ;
91         $wgEditPageFrameOptions='SAMEORIGIN';
92
93 #####
94
95
96