3 This is the main page for the ATutor+Mahara module page.
\r
4 It checks if the current user is registered with Mahara by checking
\r
5 ATutor's 'mahara' table. If registered, an iframe is created to display
\r
6 the Mahara page ('mahara_login.php', a login script to the page also gets called).
\r
7 If not registered, 'new_account.php' is called which automatically sets up an
\r
8 account with Mahara and saves the user information in ATutor's mahara table.
\r
9 The page then automatically gets refreshed.
\r
15 $_user_location = 'public';
\r
17 ob_start(); // we need this to be able to set cookies
\r
19 define('AT_INCLUDE_PATH', '../../include/');
\r
20 require (AT_INCLUDE_PATH.'vitals.inc.php');
\r
23 if ($_SESSION['is_guest'])
\r
24 $msg->addFeedback ("MAHARA_LOGIN");
\r
26 require (AT_INCLUDE_PATH.'header.inc.php');
\r
29 // Check if user is logged in as a guest
\r
30 if (!($_SESSION['is_guest'])) {
\r
31 // Read login info for Mahara
\r
32 $sql = "SELECT username, SHA1(password) FROM ".TABLE_PREFIX."mahara WHERE at_login='".$_SESSION['login']."'";
\r
33 $result = mysql_query($sql, $db);
\r
36 if (!($row = @mysql_fetch_array($result))) {
\r
37 define('new_account', 1);
\r
39 // if not configured with ATutor, automatically register for account now
\r
40 require('new_account.php');
\r
43 header('Location: index.php');
\r
46 $username = $row[0];
\r
47 $password = $row[1];
\r
53 ATutor.setcookie("ATutor_Mahara[at_login]", $_SESSION['login'], time()+1200);
\r
54 ATutor.setcookie("ATutor_Mahara[username]", $username, time()+1200);
\r
55 ATutor.setcookie("ATutor_Mahara[password]", $password, time()+1200);
\r
58 if (function_exists('url_rewrite')) { // if "pretty url" feature supported (from ATutor 1.6.1)
\r
59 $url = url_rewrite('mods/mahara/mahara_login.php', AT_PRETTY_URL_IS_HEADER); // to be directly called in an iframe
\r
60 $url_cookie_forward = url_rewrite('mods/mahara/cookie.php', AT_PRETTY_URL_IS_HEADER); // to be used in a new window and redirect to mahara_login.php
\r
62 $url = AT_BASE_HREF.'mods/mahara/mahara_login.php';
\r
63 $url_cookie_forward = AT_BASE_HREF.'mods/mahara/cookie.php';
\r
67 <script language='javascript' type='text/javascript'>
\r
68 function iFrameHeight() {
\r
70 if ( !document.all ) {
\r
71 h = document.getElementById('ATutorMahara').contentDocument.height;
\r
72 document.getElementById('ATutorMahara').style.height = h + 60 + 'px';
\r
73 } else if( document.all ) {
\r
74 h = document.frames('ATutorMahara').document.body.scrollHeight;
\r
75 document.all.ATutorMahara.style.height = h + 20 + 'px';
\r
78 function stopFrame(url, name, button) {
\r
80 var ifr = document.getElementById(name);
\r
82 ifr.parentNode.removeChild(ifr);
\r
85 var btn = document.getElementById(button);
\r
87 btn.value = '<?=_AT('mahara_opened')?>';
\r
88 btn.disabled = true;
\r
91 // open in new window
\r
95 <div align="center">
\r
96 <input type="button" name="new_win" id="new_win" value= "<?=_AT('mahara_new_win')?>" onClick="stopFrame('<?php echo $url_cookie_forward;?>', 'ATutorMahara', 'new_win')" class="button" /><br /><br />
\r
98 <iframe onload='iFrameHeight()' id='ATutorMahara' name='ATutorMahara'
\r
99 src='<?=$url?>' width='100%' height='500' scrolling='auto' align='top' frameborder='0'>
\r
109 <?php require (AT_INCLUDE_PATH.'footer.inc.php'); ?>
\r