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 /****************************************************************/
13 // $Id: contact_instructor.php 10055 2010-06-29 20:30:24Z cindy $
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');
106 <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
107 <input type="hidden" name="id" value="<?php echo $id; ?>" />
109 <div class="input-form">
111 <?php echo _AT('to'); ?><br />
112 <?php echo $instructor_name; ?>
116 <label for="from"><?php echo _AT('from_name'); ?></label><br />
117 <input type="text" class="formfield" name="from" id="from" size="40" value="<?php echo $student_name;?>" />
121 <label for="from_email"><?php echo _AT('from_email'); ?></label><br />
122 <input type="text" class="formfield" name="from_email" id="from_email" size="40" value="<?php echo $student_email;?>" />
126 <span class="required" title="<?php echo _AT('required_field'); ?>">*</span><label for="subject"><?php echo _AT('subject'); ?></label><br />
127 <input type="text" class="formfield" name="subject" id="subject" size="40" value="<?php echo $_POST['subject']; ?>" />
131 <span class="required" title="<?php echo _AT('required_field'); ?>">*</span><label for="body"><?php echo _AT('body'); ?></label><br />
132 <textarea class="formfield" cols="55" rows="15" id="body" name="body" wrap="wrap"><?php echo $_POST['body']; ?></textarea>
135 <div class="buttons row">
136 <input type="submit" name="submit" class="button" value="<?php echo _AT('send_message'); ?>" accesskey="s" />
137 <input type="submit" name="cancel" class="button" value="<?php echo _AT('cancel'); ?>" />
142 <?php require(AT_INCLUDE_PATH.'footer.inc.php'); ?>