made a copy
[atutor.git] / admin / instructor_login.php
1 <?php
2 /****************************************************************************/
3 /* ATutor                                                                                                                                       */
4 /****************************************************************************/
5 /* Copyright (c) 2002-2008 by Greg Gay, Joel Kronenberg & Heidi Hazelton        */
6 /* Adaptive Technology Resource Centre / University of Toronto                          */
7 /* http://atutor.ca                                                                                                                     */
8 /*                                                                                                                                                      */
9 /* This program is free software. You can redistribute it and/or                        */
10 /* modify it under the terms of the GNU General Public License                          */
11 /* as published by the Free Software Foundation.                                                        */
12 /****************************************************************************/
13 // $Id$
14
15 define('AT_INCLUDE_PATH', '../include/');
16 require(AT_INCLUDE_PATH.'vitals.inc.php');
17 admin_authenticate(AT_ADMIN_PRIV_COURSES);
18
19 if (isset($_POST['submit_yes'])) {
20         $_POST['course'] = intval($_POST['course']);
21
22         $admin_login = $_SESSION['login'];
23
24         $sql = "SELECT M.member_id, M.login, M.preferences, M.language FROM ".TABLE_PREFIX."members M, ".TABLE_PREFIX."courses C WHERE C.course_id=".$_POST['course']." and C.member_id=M.member_id";
25         $result = mysql_query($sql, $db);
26         if ($row = mysql_fetch_assoc($result)) {
27                 $_SESSION['course_id']  = 0;
28                 $_SESSION['login']              = $row['login'];
29                 $_SESSION['valid_user'] = true;
30                 $_SESSION['member_id']  = intval($row['member_id']);
31                 if ($row['preferences'] == "")
32                         assign_session_prefs(unserialize(stripslashes($_config["pref_defaults"])));
33                 else
34                         assign_session_prefs(unserialize(stripslashes($row['preferences'])));
35                 $_SESSION['is_guest']   = 0;
36                 $_SESSION['lang']               = $row['language'];
37                 $_SESSION['is_super_admin'] = $admin_login;
38                 session_write_close();
39
40                 header('Location: '.AT_BASE_HREF.'bounce.php?course='.$_POST['course']);
41                 exit;
42         }
43 } else if (isset($_POST['submit_no'])) {
44
45         $msg->addFeedback('CANCELLED');
46         header('Location: '.AT_BASE_HREF.'admin/courses.php');
47         exit;
48 }
49
50 require(AT_INCLUDE_PATH.'header.inc.php'); 
51
52         $sql = "SELECT * FROM ".TABLE_PREFIX."courses WHERE course_id=".$_REQUEST['course'];
53         $result = mysql_query($sql, $db);
54         $row = mysql_fetch_array($result);
55
56         $hidden_vars['course'] = $_GET['course'];
57
58         $msg->addConfirm(array('LOGIN_INSTRUCTOR', SITE_NAME, $row['title']), $hidden_vars);
59         $msg->printConfirm();
60
61 require(AT_INCLUDE_PATH.'footer.inc.php'); 
62 ?>