2 /************************************************************************/
4 /************************************************************************/
5 /* Copyright (c) 2002-2008 by Greg Gay, Joel Kronenberg & Heidi Hazelton*/
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 define('AT_INCLUDE_PATH', '../include/');
16 require(AT_INCLUDE_PATH.'vitals.inc.php');
17 admin_authenticate(AT_ADMIN_PRIV_USERS);
19 //check valid requester id
20 $request_id = intval($_REQUEST['id']);
21 $sql = "SELECT * FROM ".TABLE_PREFIX."members WHERE member_id=".$request_id;
22 $result = mysql_query($sql, $db);
23 if (!($row = mysql_fetch_array($result))) {
24 require(AT_INCLUDE_PATH.'header.inc.php');
25 echo _AT('no_user_found');
26 require(AT_INCLUDE_PATH.'footer.inc.php');
31 $msg_options = array (_AT('leave_blank'),
32 _AT('instructor_request_denymsg1'),
33 _AT('instructor_request_denymsg2'),
34 _AT('instructor_request_denymsg3'),
35 _AT('instructor_request_denymsg4'),
37 $other_option = count($msg_options)-1;
39 if (isset($_POST['submit'])) {
40 $sql = 'DELETE FROM '.TABLE_PREFIX.'instructor_approvals WHERE member_id='.$request_id;
41 $result = mysql_query($sql, $db);
42 write_to_log(AT_ADMIN_LOG_DELETE, 'instructor_approvals', mysql_affected_rows($db), $sql);
44 $msg->addFeedback('PROFILE_UPDATED_ADMIN');
46 /* notify the users that they have been denied: */
47 $sql = "SELECT email, first_name, last_name FROM ".TABLE_PREFIX."members WHERE member_id=".$_POST['id'];
48 $result = mysql_query($sql, $db);
49 if ($row = mysql_fetch_array($result)) {
50 $to_email = $row['email'];
52 $message = _AT('instructor_request_deny', AT_BASE_HREF)." \n";
53 if ($_POST['msg_option'] == $other_option) {
54 $message.=addslashes($_POST['other_msg']);
55 } else if ($_POST['msg_option']) {
56 $message.= "\n".$msg_options[$_POST['msg_option']];
59 if ($to_email != '') {
61 require(AT_INCLUDE_PATH . 'classes/phpmailer/atutormailer.class.php');
63 $mail = new ATutorMailer;
65 $mail->From = $_config['contact_email'];
66 $mail->AddAddress($to_email);
67 $mail->Subject = _AT('instructor_request');
68 $mail->Body = $message;
71 //echo 'There was an error sending the message';
72 $msg->printErrors('SENDING_ERROR');
79 $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
80 Header('Location: index.php');
82 } else if ($_POST['cancel']) {
83 $msg->addFeedback('CANCELLED');
84 header('Location: index.php');
88 require(AT_INCLUDE_PATH.'header.inc.php');
90 $sql = "SELECT email, first_name, last_name FROM ".TABLE_PREFIX."members WHERE member_id=".$request_id;
91 $result = mysql_query($sql, $db);
93 if ($row = mysql_fetch_array($result)) {
95 if ($row['first_name']!="") {
96 $username .= $row['first_name'].' ';
99 if ($row['last_name']!="") {
100 $username .= $row['last_name'].' ';
102 $username .= $row['email'];
104 require(AT_INCLUDE_PATH.'header.inc.php');
105 echo _AT('no_user_found');
106 require(AT_INCLUDE_PATH.'footer.inc.php');
111 <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" name="form">
112 <input type="hidden" name="action" value="process" />
113 <input type="hidden" name="id" value="<?php echo $request_id; ?>" />
115 <div class="input-form">
117 <label for="confirm">
119 echo _AT('confirm_deny_instructor');
120 echo "<ul><li>$username</li></ul>";
126 <?php echo _AT('instructor_request_enterdenymsg'); ?><br />
131 echo '<input type="radio" name="msg_option" id="c'.$i.'" value="'.$i.'" checked="checked" /><label for="c'.$i.'">'.$msg_options[$i].'</label><br />';
133 $num_msgs = count($msg_options) - 1;
134 for ($i = 1; $i<$num_msgs; $i++) {
135 echo '<input type="radio" name="msg_option" id="c'.$i.'" value="'.$i.'" /><label for="c'.$i.'">'.$msg_options[$i].'</label><br />';
138 echo '<input type="radio" name="msg_option" id="c'.$i.'" value="'.$i.'" /><label for="c'.$i.'">'.$msg_options[$i].'</label>';
140 <input type="text" class="formfield" name="other_msg" id="other_msg" size="30" onmousedown="document.form['c<?php echo $other_option; ?>'].checked = true;">
144 <div class="row buttons">
145 <input type="submit" name="submit" value="<?php echo _AT('deny'); ?>" accesskey="s" />
146 <input type="submit" name="cancel" value="<?php echo _AT('cancel'); ?>" />
151 <?php require(AT_INCLUDE_PATH.'footer.inc.php'); ?>