2 /****************************************************************/
4 /****************************************************************/
5 /* Copyright (c) 2002-2010 */
6 /* Inclusive Design Institute */
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 = 'public';
17 define('AT_INCLUDE_PATH', 'include/');
18 require(AT_INCLUDE_PATH.'vitals.inc.php');
20 if (isset($_SESSION['member_id']) && $_SESSION['member_id']) {
21 $to = $_base_href . 'users/browse.php';
23 $to = $_base_href . 'browse.php';
27 if (isset($_POST['cancel'])) {
28 $msg->addFeedback('CANCELLED');
29 header('Location: ' . $to);
35 $id = intval($_REQUEST['id']);
36 if (isset($system_courses[$id], $system_courses[$id]['member_id'])) {
37 $sql = "SELECT M.member_id, M.first_name, M.last_name, M.email FROM ".TABLE_PREFIX."members M WHERE M.member_id={$system_courses[$id][member_id]}";
38 $result = mysql_query($sql, $db);
39 $row = mysql_fetch_assoc($result);
43 $instructor_name = get_display_name($row['member_id']);
44 $instructor_email = AT_print($row['email'], 'members.email');
46 $msg->addError('INST_INFO_NOT_FOUND');
47 header('Location: ' . $to);
51 if (isset($_POST['submit'])) {
52 $missing_fields = array();
54 $to_email = $_POST['email'];
55 $_POST['subject'] = trim($_POST['subject']);
56 $_POST['body'] = trim($_POST['body']);
58 if ($_POST['subject'] == '') {
59 $missing_fields[] = _AT('subject');
62 if ($_POST['body'] == '') {
63 $missing_fields[] = _AT('body');
66 if ($missing_fields) {
67 $missing_fields = implode(', ', $missing_fields);
68 $msg->addError(array('EMPTY_FIELDS', $missing_fields));
71 if (!$msg->containsErrors()) {
73 require(AT_INCLUDE_PATH . 'classes/phpmailer/atutormailer.class.php');
75 if (empty($_POST['from_email'])) {
76 $_POST['from_email'] = $instructor_email;
78 if (empty($_POST['from'])) {
82 $mail = new ATutorMailer;
84 $mail->From = $_POST['from_email'];
85 $mail->FromName = $_POST['from'];
86 $mail->AddAddress($instructor_email, $instructor_name);
87 $mail->Subject = stripslashes($addslashes($_POST['subject']));
88 $mail->Body = stripslashes($addslashes($_POST['body']));
91 $msg->addError('SENDING_ERROR');
92 header('Location: ' . $to);
97 $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
98 header('Location: ' . $to);
104 require (AT_INCLUDE_PATH.'header.inc.php');
107 $savant->display('contact_instructor.tmpl.php');
108 require(AT_INCLUDE_PATH.'footer.inc.php'); ?>