2 /************************************************************************/
4 /************************************************************************/
5 /* Copyright (c) 2002-2010 */
6 /* Inclusive Design Institute */
8 /* This program is free software. You can redistribute it and/or */
9 /* modify it under the terms of the GNU General Public License */
10 /* as published by the Free Software Foundation. */
11 /************************************************************************/
12 // $Id: admin_email.php 7208 2008-01-09 16:07:24Z greg $
14 define('AT_INCLUDE_PATH', '../../../include/');
15 require (AT_INCLUDE_PATH.'vitals.inc.php');
16 admin_authenticate(AT_ADMIN_PRIV_USERS);
18 if ($_POST['cancel']) {
19 $msg->addFeedback('CANCELLED');
21 header('Location: users.php#feedback');
23 } else if ($_POST['submit']) {
24 $missing_fields = array();
26 $_POST['subject'] = trim($_POST['subject']);
27 $_POST['body'] = trim($_POST['body']);
29 if (($_POST['to'] == '') || ($_POST['to'] == 0)) {
30 $missing_fields[] = _AT('to');
33 if ($_POST['subject'] == '') {
34 $missing_fields[] = _AT('subject');
37 if ($_POST['body'] == '') {
38 $missing_fields[] = _AT('body');
41 if ($missing_fields) {
42 $missing_fields = implode(', ', $missing_fields);
43 $msg->addError(array('EMPTY_FIELDS', $missing_fields));
45 if (!$msg->containsErrors()) {
46 if ($_POST['to'] == 1) {
47 // choose all instructors
48 $sql = "SELECT * FROM ".TABLE_PREFIX."members WHERE status = ".AT_STATUS_INSTRUCTOR;
49 } else if ($_POST['to'] == 2) {
50 // choose all students
51 $sql = "SELECT * FROM ".TABLE_PREFIX."members WHERE status = ".AT_STATUS_STUDENT;
54 $sql = "SELECT * FROM ".TABLE_PREFIX."members WHERE status = ".AT_STATUS_INSTRUCTOR." OR status = ".AT_STATUS_STUDENT;
57 $result = mysql_query($sql,$db);
59 require(AT_INCLUDE_PATH . 'classes/phpmailer/atutormailer.class.php');
61 $mail = new ATutorMailer;
63 while ($row = mysql_fetch_assoc($result)) {
64 $mail->AddBCC($row['email']);
68 $mail->From = $_config['contact_email'];
69 $mail->FromName = $_config['site_name'];
70 $mail->AddAddress($_config['contact_email']);
71 $mail->Subject = $stripslashes($_POST['subject']);
72 $mail->Body = $stripslashes($_POST['body']);
75 //echo 'There was an error sending the message';
76 $msg->printErrors('SENDING_ERROR');
81 $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
82 header('Location: users.php');
87 $title = _AT('admin_email');
89 $onload = 'document.form.subject.focus();';
91 require(AT_INCLUDE_PATH.'header.inc.php');
93 $sql = "SELECT COUNT(*) AS cnt FROM ".TABLE_PREFIX."members ORDER BY login";
94 $result = mysql_query($sql,$db);
95 $row = mysql_fetch_array($result);
96 if ($row['cnt'] == 0) {
97 $msg->printErrors('NO_MEMBERS');
98 require(AT_INCLUDE_PATH.'footer.inc.php');
103 <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" name="form">
104 <input type="hidden" name="admin" value="admin" />
106 <div class="input-form">
108 <span class="required" title="<?php echo _AT('required_field'); ?>">*</span><?php echo _AT('to'); ?><br />
109 <input type="radio" name="to" value="3" checked="checked" id="all" /><label for="all"><?php echo _AT('all_users'); ?></label>
110 <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>
111 <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>
115 <span class="required" title="<?php echo _AT('required_field'); ?>">*</span><label for="subject"><?php echo _AT('subject'); ?></label><br />
116 <input type="text" name="subject" size="40" id="subject" value="<?php echo $_POST['subject']; ?>" />
120 <span class="required" title="<?php echo _AT('required_field'); ?>">*</span><label for="body"><?php echo _AT('body'); ?></label><br />
121 <textarea cols="55" rows="18" name="body" id="body"><?php echo $_POST['body']; ?></textarea>
124 <div class="row buttons">
125 <input type="submit" name="submit" value="<?php echo _AT('send'); ?>" accesskey="s" />
126 <input type="submit" name="cancel" value="<?php echo _AT('cancel'); ?>" />
131 <?php require(AT_INCLUDE_PATH.'footer.inc.php'); ?>