forked from atutor/ATutor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
contact_instructor.php
109 lines (85 loc) · 2.88 KB
/
contact_instructor.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<?php
/****************************************************************/
/* ATutor */
/****************************************************************/
/* Copyright (c) 2002-2010 */
/* Inclusive Design Institute */
/* http://atutor.ca */
/* */
/* This program is free software. You can redistribute it and/or*/
/* modify it under the terms of the GNU General Public License */
/* as published by the Free Software Foundation. */
/****************************************************************/
// $Id$
$_user_location = 'public';
define('AT_INCLUDE_PATH', 'include/');
require(AT_INCLUDE_PATH.'vitals.inc.php');
if (isset($_SESSION['member_id']) && $_SESSION['member_id']) {
$to = $_base_href . 'users/browse.php';
} else {
$to = $_base_href . 'browse.php';
}
if (isset($_POST['cancel'])) {
$msg->addFeedback('CANCELLED');
header('Location: ' . $to);
exit;
}
$row = array();
$id = intval($_REQUEST['id']);
if (isset($system_courses[$id], $system_courses[$id]['member_id'])) {
$sql = "SELECT M.member_id, M.first_name, M.last_name, M.email FROM %smembers M WHERE M.member_id={$system_courses[$id][member_id]}";
$row = queryDB($sql, array(TABLE_PREFIX), TRUE);
}
if ($row) {
$instructor_name = get_display_name($row['member_id']);
$instructor_email = AT_print($row['email'], 'members.email');
} else {
$msg->addError('INST_INFO_NOT_FOUND');
header('Location: ' . $to);
exit;
}
if (isset($_POST['submit'])) {
$missing_fields = array();
$to_email = $_POST['email'];
$_POST['subject'] = trim($_POST['subject']);
$_POST['body'] = trim($_POST['body']);
if ($_POST['subject'] == '') {
$missing_fields[] = _AT('subject');
}
if ($_POST['body'] == '') {
$missing_fields[] = _AT('body');
}
if ($missing_fields) {
$missing_fields = implode(', ', $missing_fields);
$msg->addError(array('EMPTY_FIELDS', $missing_fields));
}
if (!$msg->containsErrors()) {
require(AT_INCLUDE_PATH . 'classes/phpmailer/atutormailer.class.php');
if (empty($_POST['from_email'])) {
$_POST['from_email'] = $instructor_email;
}
if (empty($_POST['from'])) {
$_POST['from'] = '';
}
$mail = new ATutorMailer;
$mail->From = $_POST['from_email'];
$mail->FromName = $_POST['from'];
$mail->AddAddress($instructor_email, $instructor_name);
$mail->Subject = stripslashes($addslashes($_POST['subject']));
$mail->Body = stripslashes($addslashes($_POST['body']));
if(!$mail->Send()) {
$msg->addError('SENDING_ERROR');
header('Location: ' . $to);
exit;
}
unset($mail);
$msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
header('Location: ' . $to);
exit;
}
}
require (AT_INCLUDE_PATH.'header.inc.php');
?>
<?php
$savant->display('contact_instructor.tmpl.php');
require(AT_INCLUDE_PATH.'footer.inc.php'); ?>