2 /****************************************************************/
4 /****************************************************************/
5 /* Copyright (c) 2002-2008 by Greg Gay & Joel Kronenberg */
6 /* Adaptive Technology Resource Centre / University of Toronto */
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 /****************************************************************/
15 $_user_location = 'admin';
17 define('AT_INCLUDE_PATH', '../include/');
18 require(AT_INCLUDE_PATH.'vitals.inc.php');
19 admin_authenticate(AT_ADMIN_PRIV_USERS);
21 if (isset($_GET['deny']) && isset($_GET['id'])) {
22 header('Location: admin_deny.php?id='.$_GET['id']);
25 $sql = 'DELETE FROM '.TABLE_PREFIX.'instructor_approvals WHERE member_id='.intval($_GET['id']);
26 $result = mysql_query($sql, $db);
28 write_to_log(AT_ADMIN_LOG_DELETE, 'instructor_approvals', mysql_affected_rows($db), $sql);
31 } else if (isset($_GET['approve']) && isset($_GET['id'])) {
32 $id = intval($_GET['id']);
34 $sql = 'DELETE FROM '.TABLE_PREFIX.'instructor_approvals WHERE member_id='.$id;
35 $result = mysql_query($sql, $db);
37 write_to_log(AT_ADMIN_LOG_DELETE, 'instructor_approvals', mysql_affected_rows($db), $sql);
39 $sql = 'UPDATE '.TABLE_PREFIX.'members SET status='.AT_STATUS_INSTRUCTOR.', creation_date=creation_date, last_login=last_login WHERE member_id='.$id;
40 $result = mysql_query($sql, $db);
42 write_to_log(AT_ADMIN_LOG_UPDATE, 'members', mysql_affected_rows($db), $sql);
44 /* notify the users that they have been approved: */
45 $sql = "SELECT email, first_name, last_name FROM ".TABLE_PREFIX."members WHERE member_id=$id";
46 $result = mysql_query($sql, $db);
47 if ($row = mysql_fetch_assoc($result)) {
48 $to_email = $row['email'];
50 if ($row['first_name']!="" || $row['last_name']!="") {
51 $tmp_message = $row['first_name'].' '.$row['last_name'].",\n\n";
53 $tmp_message .= _AT('instructor_request_reply', AT_BASE_HREF);
55 if ($to_email != '') {
56 require(AT_INCLUDE_PATH . 'classes/phpmailer/atutormailer.class.php');
58 $mail = new ATutorMailer;
60 $mail->From = $_config['contact_email'];
61 $mail->AddAddress($to_email);
62 $mail->Subject = _AT('instructor_request');
63 $mail->Body = $tmp_message;
66 //echo 'There was an error sending the message';
67 $msg->printErrors('SENDING_ERROR');
75 $msg->addFeedback('PROFILE_UPDATED_ADMIN');
76 } else if (!empty($_GET) && !$_GET['submit']) {
77 $msg->addError('NO_ITEM_SELECTED');
80 require(AT_INCLUDE_PATH.'header.inc.php');
82 $sql = "SELECT M.login, M.first_name, M.last_name, M.email, M.member_id, A.* FROM ".TABLE_PREFIX."members M, ".TABLE_PREFIX."instructor_approvals A WHERE A.member_id=M.member_id ORDER BY M.login";
83 $result = mysql_query($sql, $db);
84 $num_pending = mysql_num_rows($result);
87 <form name="form" method="get" action="<?php echo $_SERVER['PHP_SELF']; ?>">
88 <table class="data" summary="" rules="cols">
91 <th scope="col"> </th>
92 <th scope="col"><?php echo _AT('login_name'); ?></th>
93 <th scope="col"><?php echo _AT('first_name'); ?></th>
94 <th scope="col"><?php echo _AT('last_name'); ?></th>
95 <th scope="col"><?php echo _AT('email'); ?></th>
96 <th scope="col"><?php echo _AT('notes'); ?></th>
102 <input type="submit" name="deny" value="<?php echo _AT('deny'); ?>" />
103 <input type="submit" name="approve" value="<?php echo _AT('approve'); ?>" /></td>
108 if ($row = mysql_fetch_assoc($result)) {
110 echo '<tr onmousedown="document.form[\'i'.$row['member_id'].'\'].checked = true;rowselect(this);" id="r_'.$row['member_id'].'">';
111 echo '<td><input type="radio" name="id" value="'.$row['member_id'].'" id="i'.$row['member_id'].'" /></td>';
112 echo '<td><label for="i'.$row['member_id'].'">'.AT_print($row['login'], 'members.login').'</label></td>';
113 echo '<td>'.AT_print($row['first_name'], 'members.first_name').'</td>';
114 echo '<td>'.AT_print($row['last_name'], 'members.last_name').'</td>';
115 echo '<td>'.AT_print($row['email'], 'members.email').'</td>';
117 echo '<td>'.AT_print($row['notes'], 'instructor_approvals.notes').'</td>';
120 } while ($row = mysql_fetch_assoc($result));
122 echo '<tr><td colspan="6">'._AT('none_found').'</td></tr>';
129 <?php require(AT_INCLUDE_PATH.'footer.inc.php'); ?>