2 /************************************************************************/
4 /************************************************************************/
5 /* Copyright (c) 2002-2010 */
6 /* Inclusive Design Institute */
8 /* This program is free software. You can redistribute it and/or */
9 /* modify it under the terms of the GNU General Public License */
10 /* as published by the Free Software Foundation. */
11 /************************************************************************/
14 define('AT_INCLUDE_PATH', '../../../include/');
15 require(AT_INCLUDE_PATH.'vitals.inc.php');
16 admin_authenticate(AT_ADMIN_PRIV_USERS);
18 //check valid requester id
19 $request_id = intval($_REQUEST['id']);
20 $sql = "SELECT * FROM ".TABLE_PREFIX."members WHERE member_id=".$request_id;
21 $result = mysql_query($sql, $db);
22 if (!($row = mysql_fetch_array($result))) {
23 require(AT_INCLUDE_PATH.'header.inc.php');
24 echo _AT('no_user_found');
25 require(AT_INCLUDE_PATH.'footer.inc.php');
30 $msg_options = array (_AT('leave_blank'),
31 _AT('instructor_request_denymsg1'),
32 _AT('instructor_request_denymsg2'),
33 _AT('instructor_request_denymsg3'),
34 _AT('instructor_request_denymsg4'),
36 $other_option = count($msg_options)-1;
38 if (isset($_POST['submit'])) {
39 $sql = 'DELETE FROM '.TABLE_PREFIX.'instructor_approvals WHERE member_id='.$request_id;
40 $result = mysql_query($sql, $db);
41 write_to_log(AT_ADMIN_LOG_DELETE, 'instructor_approvals', mysql_affected_rows($db), $sql);
43 $msg->addFeedback('PROFILE_UPDATED_ADMIN');
45 /* notify the users that they have been denied: */
46 $sql = "SELECT email, first_name, last_name FROM ".TABLE_PREFIX."members WHERE member_id=".$_POST['id'];
47 $result = mysql_query($sql, $db);
48 if ($row = mysql_fetch_array($result)) {
49 $to_email = $row['email'];
51 $message = _AT('instructor_request_deny', AT_BASE_HREF)." \n";
52 if ($_POST['msg_option'] == $other_option) {
53 $message.=addslashes($_POST['other_msg']);
54 } else if ($_POST['msg_option']) {
55 $message.= "\n".$msg_options[$_POST['msg_option']];
58 if ($to_email != '') {
60 require(AT_INCLUDE_PATH . 'classes/phpmailer/atutormailer.class.php');
62 $mail = new ATutorMailer;
64 $mail->From = $_config['contact_email'];
65 $mail->AddAddress($to_email);
66 $mail->Subject = _AT('instructor_request');
67 $mail->Body = $message;
70 //echo 'There was an error sending the message';
71 $msg->printErrors('SENDING_ERROR');
78 $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
79 Header('Location: index.php');
81 } else if ($_POST['cancel']) {
82 $msg->addFeedback('CANCELLED');
83 header('Location: users.php');
87 require(AT_INCLUDE_PATH.'header.inc.php');
89 $sql = "SELECT email, first_name, last_name FROM ".TABLE_PREFIX."members WHERE member_id=".$request_id;
90 $result = mysql_query($sql, $db);
92 if ($row = mysql_fetch_array($result)) {
94 if ($row['first_name']!="") {
95 $username .= $row['first_name'].' ';
98 if ($row['last_name']!="") {
99 $username .= $row['last_name'].' ';
101 $username .= $row['email'];
103 require(AT_INCLUDE_PATH.'header.inc.php');
104 echo _AT('no_user_found');
105 require(AT_INCLUDE_PATH.'footer.inc.php');
110 <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" name="form">
111 <input type="hidden" name="action" value="process" />
112 <input type="hidden" name="id" value="<?php echo $request_id; ?>" />
114 <div class="input-form">
116 <label for="confirm">
118 echo _AT('confirm_deny_instructor');
119 echo "<ul><li>$username</li></ul>";
125 <?php echo _AT('instructor_request_enterdenymsg'); ?><br />
130 echo '<input type="radio" name="msg_option" id="c'.$i.'" value="'.$i.'" checked="checked" /><label for="c'.$i.'">'.$msg_options[$i].'</label><br />';
132 $num_msgs = count($msg_options) - 1;
133 for ($i = 1; $i<$num_msgs; $i++) {
134 echo '<input type="radio" name="msg_option" id="c'.$i.'" value="'.$i.'" /><label for="c'.$i.'">'.$msg_options[$i].'</label><br />';
137 echo '<input type="radio" name="msg_option" id="c'.$i.'" value="'.$i.'" /><label for="c'.$i.'">'.$msg_options[$i].'</label>';
139 <input type="text" class="formfield" name="other_msg" id="other_msg" size="30" onmousedown="document.form['c<?php echo $other_option; ?>'].checked = true;">
143 <div class="row buttons">
144 <input type="submit" name="submit" value="<?php echo _AT('deny'); ?>" accesskey="s" />
145 <input type="submit" name="cancel" value="<?php echo _AT('cancel'); ?>" />
150 <?php require(AT_INCLUDE_PATH.'footer.inc.php'); ?>