2 /************************************************************************/
4 /************************************************************************/
5 /* Copyright (c) 2002-2006 by Greg Gay, Joel Kronenberg & Heidi Hazelton*/
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 define('AT_INCLUDE_PATH', '../include/');
16 require (AT_INCLUDE_PATH.'vitals.inc.php');
17 admin_authenticate(AT_ADMIN_PRIV_USERS);
19 if ($_POST['cancel']) {
20 $msg->addFeedback('CANCELLED');
22 header('Location: users.php#feedback');
24 } else if ($_POST['submit']) {
25 $missing_fields = array();
27 $_POST['subject'] = trim($_POST['subject']);
28 $_POST['body'] = trim($_POST['body']);
30 if (($_POST['to'] == '') || ($_POST['to'] == 0)) {
31 $missing_fields[] = _AT('to');
34 if ($_POST['subject'] == '') {
35 $missing_fields[] = _AT('subject');
38 if ($_POST['body'] == '') {
39 $missing_fields[] = _AT('body');
42 if ($missing_fields) {
43 $missing_fields = implode(', ', $missing_fields);
44 $msg->addError(array('EMPTY_FIELDS', $missing_fields));
46 if (!$msg->containsErrors()) {
47 if ($_POST['to'] == 1) {
48 // choose all instructors
49 $sql = "SELECT * FROM ".TABLE_PREFIX."members WHERE status = ".AT_STATUS_INSTRUCTOR;
50 } else if ($_POST['to'] == 2) {
51 // choose all students
52 $sql = "SELECT * FROM ".TABLE_PREFIX."members WHERE status = ".AT_STATUS_STUDENT;
55 $sql = "SELECT * FROM ".TABLE_PREFIX."members WHERE status = ".AT_STATUS_INSTRUCTOR." OR status = ".AT_STATUS_STUDENT;
58 $result = mysql_query($sql,$db);
60 require(AT_INCLUDE_PATH . 'classes/phpmailer/atutormailer.class.php');
62 $mail = new ATutorMailer;
64 while ($row = mysql_fetch_assoc($result)) {
65 $mail->AddBCC($row['email']);
69 $mail->From = $_config['contact_email'];
70 $mail->FromName = $_config['site_name'];
71 $mail->AddAddress($_config['contact_email']);
72 $mail->Subject = $stripslashes($_POST['subject']);
73 $mail->Body = $stripslashes($_POST['body']);
76 //echo 'There was an error sending the message';
77 $msg->printErrors('SENDING_ERROR');
82 $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
83 header('Location: users.php');
88 $title = _AT('admin_email');
90 $onload = 'document.form.subject.focus();';
92 require(AT_INCLUDE_PATH.'header.inc.php');
94 $sql = "SELECT COUNT(*) AS cnt FROM ".TABLE_PREFIX."members ORDER BY login";
95 $result = mysql_query($sql,$db);
96 $row = mysql_fetch_array($result);
97 if ($row['cnt'] == 0) {
98 $msg->printErrors('NO_MEMBERS');
99 require(AT_INCLUDE_PATH.'footer.inc.php');
104 <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" name="form">
105 <input type="hidden" name="admin" value="admin" />
107 <div class="input-form">
109 <div class="required" title="<?php echo _AT('required_field'); ?>">*</div><?php echo _AT('to'); ?><br />
110 <input type="radio" name="to" value="3" checked="checked" id="all" /><label for="all"><?php echo _AT('all_users'); ?></label>
111 <input type="radio" name="to" value="1" id="inst" <?php if ($_POST['to'] == AT_STATUS_INSTRUCTOR) { echo 'checked="checked"'; } ?> /><label for="inst"><?php echo _AT('instructors'); ?></label>
112 <input type="radio" name="to" value="2" id="stud" <?php if ($_POST['to'] == AT_STATUS_STUDENT) { echo 'checked="checked"'; } ?> /><label for="stud"><?php echo _AT('students'); ?></label>
116 <div class="required" title="<?php echo _AT('required_field'); ?>">*</div><label for="subject"><?php echo _AT('subject'); ?></label><br />
117 <input type="text" name="subject" size="40" id="subject" value="<?php echo $_POST['subject']; ?>" />
121 <div class="required" title="<?php echo _AT('required_field'); ?>">*</div><label for="body"><?php echo _AT('body'); ?></label><br />
122 <textarea cols="55" rows="18" name="body" id="body"><?php echo $_POST['body']; ?></textarea>
125 <div class="row buttons">
126 <input type="submit" name="submit" value="<?php echo _AT('send'); ?>" accesskey="s" />
127 <input type="submit" name="cancel" value="<?php echo _AT('cancel'); ?>" />
132 <?php require(AT_INCLUDE_PATH.'footer.inc.php'); ?>