remove old readme
[atutor.git] / docs / help / contact_support.php
1 <?php
2 /****************************************************************/
3 /* ATutor                                                                                                               */
4 /****************************************************************/
5 /* Copyright (c) 2002-2010                                      */
6 /* Inclusive Design Institute                                   */
7 /* http://atutor.ca                                                                                             */
8 /*                                                              */
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$
14
15 $_user_location = 'public';
16
17 define('AT_INCLUDE_PATH', '../include/');
18 require(AT_INCLUDE_PATH.'vitals.inc.php');
19
20 if (isset($_POST['cancel'])) {
21         $msg->addFeedback('CANCELLED');
22         header('Location: index.php');
23         exit;
24 }
25
26 $onload = 'document.form.from.focus();';
27 require(AT_INCLUDE_PATH.'header.inc.php');
28
29 if ($_SESSION['member_id']) {
30         $sql    = "SELECT first_name, last_name, email FROM ".TABLE_PREFIX."members WHERE member_id=$_SESSION[member_id]";
31         $result = mysql_query($sql, $db);
32         if ($row = mysql_fetch_array($result)) {
33                 $student_name = AT_print($row['last_name'], 'members.last_name');
34                 $student_name .= (AT_print($row['first_name'], 'members.first_name') ? ', '.AT_print($row['first_name'], 'members.first_name') : '');
35
36                 $student_email = AT_print($row['email'], 'members.email');
37         }
38 }
39
40 if (!$_config['contact_email']) {
41         $msg->printErrors('CONTACT_INFO_NOT_FOUND');
42         require(AT_INCLUDE_PATH.'footer.inc.php');
43         exit;
44 }
45
46 if (isset($_POST['submit'])) {
47         $missing_fields = array();
48
49         $_POST['subject'] = trim($_POST['subject']);
50         $_POST['body']    = trim($_POST['body']);
51
52         if ($_POST['from'] == '') {
53                 $missing_fields[] = _AT('from_name');
54         }
55
56         if ($_POST['from_email'] == '') {
57                 $missing_fields[] = _AT('from_email');
58         } else if (!preg_match("/^[a-z0-9\._-]+@+[a-z0-9\._-]+\.+[a-z]{2,6}$/i", $_POST['from_email'])) {
59                 $msg->addError('EMAIL_INVALID');
60         }
61
62         if ($_POST['subject'] == '') {
63                 $missing_fields[] = _AT('subject');
64         }
65                 
66         if ($_POST['body'] == '') {
67                 $missing_fields[] = _AT('body');
68         }
69
70         if ($missing_fields) {
71                 $missing_fields = implode(', ', $missing_fields);
72                 $msg->addError(array('EMPTY_FIELDS', $missing_fields));
73         }
74
75         if (!$msg->containsErrors()) {
76
77                 require(AT_INCLUDE_PATH . 'classes/phpmailer/atutormailer.class.php');
78
79                 $mail = new ATutorMailer;
80
81                 $mail->From     = $_POST['from_email'];
82                 $mail->FromName = $stripslashes($_POST['from']);
83                 $mail->AddAddress($_config['contact_email']);
84                 $mail->Subject = $stripslashes($_POST['subject']);
85                 $mail->Body    = $stripslashes($_POST['body']);
86
87                 if(!$mail->Send()) {
88                    $msg->printErrors('SENDING_ERROR');
89                    exit;
90                 }
91                 unset($mail);
92                 
93                 $msg->printFeedbacks('ACTION_COMPLETED_SUCCESSFULLY');
94                 require(AT_INCLUDE_PATH.'footer.inc.php');
95                 exit;
96         }
97 }
98
99 $msg->printErrors();
100 ?>
101 <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" name="form">
102 <div class="input-form">
103         <div class="row">
104                 <span class="required" title="<?php echo _AT('required_field'); ?>">*</span><label for="from"><?php echo _AT('from_name'); ?></label><br />
105                 <input type="text" name="from" id="from" size="40" value="<?php echo htmlspecialchars($stripslashes($_POST['from'])); ?>" />
106         </div>
107
108         <div class="row">
109                 <span class="required" title="<?php echo _AT('required_field'); ?>">*</span><label for="from_email"><?php echo _AT('from_email'); ?></label><br />
110                 <input type="text" name="from_email" id="from_email" size="40" value="<?php echo htmlspecialchars($stripslashes($_POST['from_email'])); ?>" />
111         </div>
112
113         <div class="row">
114                 <span class="required" title="<?php echo _AT('required_field'); ?>">*</span><label for="subject"><?php echo _AT('subject'); ?></label><br />
115                 <input type="text" name="subject" id="subject" size="40" value="<?php echo htmlspecialchars($stripslashes($_POST['subject'])); ?>" />
116         </div>
117
118         <div class="row">
119                 <span class="required" title="<?php echo _AT('required_field'); ?>">*</span><label for="body_text"><?php echo _AT('body'); ?></label><br />
120                 <textarea cols="55" rows="15" id="body_text" name="body"><?php echo htmlspecialchars($stripslashes($_POST['body'])); ?></textarea>
121         </div>
122
123         <div class="row buttons">
124                 <input type="submit" name="submit" value="<?php echo _AT('send'); ?>" accesskey="s" /> 
125                 <input type="submit" name="cancel" value="<?php echo _AT('cancel'); ?>" />
126         </div>
127 </div>
128 </form>
129
130 <?php require(AT_INCLUDE_PATH.'footer.inc.php'); ?>