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 if ($_REQUEST['from_browse']) {
16 $page = 'browse_courses';
21 $_user_location = 'users';
22 define('AT_INCLUDE_PATH', '../include/');
23 require(AT_INCLUDE_PATH.'vitals.inc.php');
25 if ($_POST['cancel']) {
26 if ($_POST['from_browse']) {
27 header('Location: browse.php');
29 header('Location: index.php');
34 require(AT_INCLUDE_PATH.'header.inc.php');
36 echo '<h2>'._AT('contact_instructor').'</h2>';
38 $sql = "SELECT first_name, last_name, email FROM ".TABLE_PREFIX."members WHERE member_id=$_SESSION[member_id]";
39 $result = mysql_query($sql, $db);
40 if ($row = mysql_fetch_array($result)) {
41 $student_name = $row['last_name'];
42 $student_name .= ($row['first_name'] ? ', '.$row['first_name'] : '');
44 $student_email = $row['email'];
46 $msg->printErrors('STUD_INFO_NOT_FOUND');
47 require(AT_INCLUDE_PATH.'footer.inc.php');
51 if ($_GET['course']) {
52 $course = intval($_GET['course']);
54 $course = intval($_POST['course']);
57 $sql = "SELECT M.first_name, M.last_name, M.email, C.title FROM ".TABLE_PREFIX."members M, ".TABLE_PREFIX."courses C WHERE M.member_id=C.member_id AND C.course_id=$course";
58 $result = mysql_query($sql, $db);
60 if ($row = mysql_fetch_array($result)) {
61 $instructor_name = $row['last_name'];
62 $instructor_name .= ($row['first_name'] ? ', '.$row['first_name'] : '');
64 $instructor_email = $row['email'];
66 $msg->printErrors('INST_INFO_NOT_FOUND');
67 require(AT_INCLUDE_PATH.'footer.inc.php');
71 if ($_POST['submit']) {
72 $missing_fields = array();
74 $to_email = $instructor_email;
75 $_POST['subject'] = trim($_POST['subject']);
76 $_POST['body'] = trim($_POST['body']);
78 if ($_POST['subject'] == '') {
79 $missing_fields[] = _AT('subject');
81 if ($_POST['body'] == '') {
82 $missing_fields[] = _AT('body');
85 if ($missing_fields) {
86 $missing_fields = implode(', ', $missing_fields);
87 $msg->addError(array('EMPTY_FIELDS', $missing_fields));
89 if (!$msg->containsErrors()) {
90 $tmp_message = _AT('from_atutor', $row['title'])."\n\n";
91 $tmp_message .= $_POST['body']."\n\n";
93 if ($to_email != '') {
94 require(AT_INCLUDE_PATH . 'classes/phpmailer/atutormailer.class.php');
96 $mail = new ATutorMailer;
98 $mail->From = $_POST['from_email'];
99 $mail->FromName = $_POST['from'];
100 $mail->AddAddress($to_email);
101 $mail->Subject = $_POST['subject'];
102 $mail->Body = $tmp_message;
105 //echo 'There was an error sending the message';
106 $msg->printErrors('SENDING_ERROR');
112 $msg->printFeedbacks('ACTION_COMPLETED_SUCCESSFULLY');
113 require(AT_INCLUDE_PATH.'footer.inc.php');
122 <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
123 <input type="hidden" name="course" value="<?php echo $course; ?>" />
124 <input type="hidden" name="from_browse" value="<?php echo $_REQUEST['from_browse']; ?>" />
125 <table cellspacing="1" cellpadding="0" border="0" summary="" width="85%" class="bodyline" align="center">
127 <th colspan="2" align="left" class="cyan"><?php echo _AT('instructor_contact_form'); ?></th>
130 <td class="row1" align="right"><b><?php echo _AT('contact_name'); ?>:</b></td>
131 <td class="row1"><?php echo $row[title]; ?></td>
133 <tr><td height="1" class="row2" colspan="2"></td></tr>
135 <td class="row1" align="right"><b><?php echo _AT('to_name'); ?>:</b></td>
136 <td class="row1"><?php echo $instructor_name; ?> (<?php echo _AT('course_instructor'); ?>)</td>
138 <tr><td height="1" class="row2" colspan="2"></td></tr>
140 <td class="row1" align="right"><b><?php echo _AT('to_email'); ?>:</b></td>
141 <td class="row1"><i><?php echo _AT('hidden'); ?></i></td>
143 <tr><td height="1" class="row2" colspan="2"></td></tr>
145 <td class="row1" align="right"><label for="from"><b><?php echo _AT('from_name'); ?>:</b></label></td>
146 <td class="row1"><input type="text" class="formfield" name="from" id="from" size="40" value="<?php echo $student_name;?>" /></td>
148 <tr><td height="1" class="row2" colspan="2"></td></tr>
150 <td class="row1" align="right"><label for="from_email"><b><?php echo _AT('from_email'); ?>:</b></label></td>
151 <td class="row1"><input type="text" class="formfield" name="from_email" id="from_email" size="40" value="<?php echo $student_email;?>" /></td>
153 <tr><td height="1" class="row2" colspan="2"></td></tr>
155 <td class="row1" align="right"><label for="subject"><b><?php echo _AT('subject'); ?>:</b></label></td>
156 <td class="row1"><input type="text" class="formfield" name="subject" id="subject" size="40" value="<?php echo $_POST['subject']; ?>" /></td>
158 <tr><td height="1" class="row2" colspan="2"></td></tr>
160 <td class="row1" align="right" valign="top"><label for="body"><b><?php echo _AT('body'); ?>:</b></label></td>
161 <td class="row1"><textarea class="formfield" cols="55" rows="15" id="body" name="body"><?php echo $_POST['body']; ?></textarea><br /><br /></td>
163 <tr><td height="1" class="row2" colspan="2"></td></tr>
164 <tr><td height="1" class="row2" colspan="2"></td></tr>
166 <td class="row1" align="center" colspan="2"><input type="submit" name="submit" class="button" value="<?php echo _AT('send'); ?> [Alt-s]" accesskey="s" /> <input type="submit" name="cancel" class="button" value="<?php echo _AT('cancel'); ?>" /></td>
173 require(AT_INCLUDE_PATH.'footer.inc.php');