240 lines
8.5 KiB
PHP
240 lines
8.5 KiB
PHP
<?php
|
|
require_once("include/globals.php");
|
|
|
|
if (SessionActive() != 1 || ! UserLoggedIn()) {
|
|
header("Location: /");
|
|
exit();
|
|
}
|
|
|
|
|
|
// Ensure that only admin users have access to this module
|
|
$AllowedUserTypes = array('SuperUser','System Administrator','Application Administrator','Volunteer Administrator','Communications Administrator','Financial','Financial Team');
|
|
if (checkPermission($AllowedUserTypes) != 1) {
|
|
$error_message = getLanguageText('ERRORMSG-ACCESS-DENIED');
|
|
header("Location: /?error_message=".urlencode($error_message));
|
|
exit();
|
|
}
|
|
|
|
|
|
if (isset($record_num)) $record_num = intval($record_num);
|
|
else $record_num = 0;
|
|
|
|
|
|
//
|
|
// Process next action requests
|
|
//
|
|
switch ($naction) {
|
|
case "add":
|
|
include "email-message-edit.html";
|
|
break;
|
|
|
|
case "insert":
|
|
$content_id = db_escape_string(stripslashes($_POST['content_id']));
|
|
$date_added = date("Y-m-d",time());
|
|
$date_modified = date("Y-m-d",time());
|
|
$content = stripslashes($_POST['content']);
|
|
if (array_key_exists('attachments',$_POST)) $attachments = $_POST['attachments'];
|
|
$post_active = 'Y';
|
|
|
|
if (array_key_exists('post_from_date', $_POST) && strlen($_POST['post_from_date'])) $post_from_date = db_escape_string($_POST['post_from_date']);
|
|
if (array_key_exists('post_to_date', $_POST) && strlen($_POST['post_to_date'])) $post_to_date = db_escape_string($_POST['post_to_date']);
|
|
if (array_key_exists('post_active', $_POST) && strlen($_POST['post_active'])) $post_active = db_escape_string($_POST['post_active']);
|
|
|
|
if (!$content_id) $content_id = "No Subject Defined";
|
|
|
|
// Cleanup the content before saving
|
|
$content = str_ireplace('<p"></p">','',$content);
|
|
$content = str_ireplace('<p">','<p>',$content);
|
|
$content = str_ireplace('</p">','</p>',$content);
|
|
|
|
$content = str_ireplace('{<b>','<b>{',$content);
|
|
$content = str_ireplace('</b>}','}</b>',$content);
|
|
|
|
$content = str_ireplace('{<i>','<i>{',$content);
|
|
$content = str_ireplace('</i>}','}</i>',$content);
|
|
|
|
$content = str_ireplace('{<strong>','<strong>{',$content);
|
|
$content = str_ireplace('</strong>}','}</strong>',$content);
|
|
|
|
$content = preg_replace("#<span[^<]*Emoji[^<]*</span>#",'',$content);
|
|
|
|
$content = db_escape_string($content);
|
|
|
|
$content_type = 'E';
|
|
if ($_SESSION['UserInfo']['type'] == 'SuperUser' && $school_num == 3) $content_type = 'S';
|
|
|
|
// Insert the new email message
|
|
if (!isset($post_from_date)) {
|
|
$query = "insert into formatted_content " .
|
|
"(school_num,content_id,date_added,date_modified,content_type,content) " .
|
|
"values($school_num,'$content_id','$date_modified','$date_modified','$content_type','$content')";
|
|
}
|
|
else {
|
|
$query = "insert into formatted_content " .
|
|
"(school_num,content_id,date_added,date_modified,content_type,content,post_from_date,post_to_date,post_active) " .
|
|
"values($school_num,'$content_id','$date_modified','$date_modified','$content_type','$content','$post_from_date','$post_to_date','$post_active')";
|
|
}
|
|
db_query($query);
|
|
$mid = db_insert_id();
|
|
|
|
include "email-messages-list.php";
|
|
break;
|
|
|
|
case "edit":
|
|
case "copy":
|
|
if ($record_num == 0) {
|
|
$error_message = getLanguageText('TEXT-INVALID-ACCESS');
|
|
header("Location: /?error_message=".urlencode($error_message));
|
|
exit();
|
|
}
|
|
|
|
$query = "select * from formatted_content where record_num = '$record_num'";
|
|
$results = db_query($query);
|
|
$row = db_fetch_array($results);
|
|
|
|
$content_id = stripslashes($row["content_id"]);
|
|
$content_type = $row["content_type"];
|
|
$date_added = $row["date_added"];
|
|
$date_modified = date("Y-m-d",time());
|
|
$content = stripslashes($row["content"]);
|
|
$post_from_date = $row['post_from_date'];
|
|
$post_to_date = $row['post_to_date'];
|
|
$post_active = $row['post_active'];
|
|
|
|
include "email-message-edit.html";
|
|
break;
|
|
|
|
case "update":
|
|
extract($_POST);
|
|
|
|
if ($record_num == 0) {
|
|
$error_message = getLanguageText('TEXT-INVALID-ACCESS');
|
|
header("Location: /?error_message=".urlencode($error_message));
|
|
exit();
|
|
}
|
|
|
|
$content_id = db_escape_string(stripslashes($_POST['content_id']));
|
|
$date_modified = date("Y-m-d",time());
|
|
$content = stripslashes($_POST['content']);
|
|
|
|
if (array_key_exists('post_from_date', $_POST) && strlen($_POST['post_from_date'])) $post_from_date = db_escape_string($_POST['post_from_date']);
|
|
if (array_key_exists('post_to_date', $_POST) && strlen($_POST['post_to_date'])) $post_to_date = db_escape_string($_POST['post_to_date']);
|
|
if (array_key_exists('post_active', $_POST) && strlen($_POST['post_active'])) $post_active = db_escape_string($_POST['post_active']);
|
|
|
|
// Cleanup the content before saving
|
|
$content = str_ireplace('<p"></p">','',$content);
|
|
$content = str_ireplace('<p">','<p>',$content);
|
|
$content = str_ireplace('</p">','</p>',$content);
|
|
|
|
$content = str_ireplace('{<b>','<b>{',$content);
|
|
$content = str_ireplace('</b>}','}</b>',$content);
|
|
|
|
$content = str_ireplace('{<i>','<i>{',$content);
|
|
$content = str_ireplace('</i>}','}</i>',$content);
|
|
|
|
$content = str_ireplace('{<strong>','<strong>{',$content);
|
|
$content = str_ireplace('</strong>}','}</strong>',$content);
|
|
|
|
$content = preg_replace("#<span[^<]*Emoji[^<]*</span>#",'',$content);
|
|
|
|
$content = db_escape_string($content);
|
|
|
|
$attachments = NULL;
|
|
if (array_key_exists('attachments', $_POST)) $attachments = $_POST['attachments'];
|
|
|
|
$content_type = 'E';
|
|
if ($_SESSION['UserInfo']['type'] == 'SuperUser' && $school_num == 3) $content_type = 'S';
|
|
|
|
if (!isset($post_active)) $post_active = 'N';
|
|
|
|
// Save the new content
|
|
if (!isset($post_from_date)) {
|
|
$query = "update formatted_content " .
|
|
"set content_id = '$content_id', " .
|
|
"content = '$content', " .
|
|
"content_type = '$content_type', " .
|
|
"date_modified = '$date_modified' " .
|
|
"where record_num = '$record_num'";
|
|
}
|
|
else {
|
|
$query = "update formatted_content " .
|
|
"set content_id = '$content_id', " .
|
|
"content = '$content', " .
|
|
"content_type = '$content_type', " .
|
|
"post_from_date = '$post_from_date', " .
|
|
"post_to_date = '$post_to_date', " .
|
|
"post_active = '$post_active', " .
|
|
"date_modified = '$date_modified' " .
|
|
"where record_num = '$record_num'";
|
|
}
|
|
db_query($query);
|
|
|
|
include "email-messages-list.php";
|
|
break;
|
|
|
|
case "delete":
|
|
if ($record_num == 0) {
|
|
$error_message = getLanguageText('TEXT-INVALID-ACCESS');
|
|
header("Location: /?error_message=".urlencode($error_message));
|
|
exit();
|
|
}
|
|
|
|
$query = "select * from formatted_content where record_num = '$record_num'";
|
|
$results = db_query($query);
|
|
if (db_num_rows($results) == 0) {
|
|
$error_message = getLanguageText('TEXT-INVALID-ACCESS');
|
|
}
|
|
|
|
$row = db_fetch_array($results);
|
|
|
|
$content_id = stripslashes($row["content_id"]);
|
|
$content = stripslashes($row["content"]);
|
|
|
|
?>
|
|
<form method='post' action='/'>
|
|
<table width='700' cellpadding='5' cellspacing='0' border='0'>
|
|
<tr>
|
|
<td align='left'>
|
|
<h2>Confirm Delete of Email Message</h2>
|
|
<p><b>Subject:</b> <?php echo($content_id) ?></p>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td align='left' bgcolor='#ffffff'>
|
|
<?php echo($content) ?>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td align='center'>
|
|
<br>
|
|
<input type='submit' class='btn btn--primary' value="<?php displayLanguageText('TEXT-CONFIRM-DELETE'); ?>">
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
<input type='hidden' name='action' value='email-messages'>
|
|
<input type='hidden' name='naction' value='delete-confirmed'>
|
|
<input type='hidden' name='record_num' value='<?php echo($record_num) ?>'>
|
|
</form>
|
|
<?php
|
|
break;
|
|
|
|
case "delete-confirmed":
|
|
if ($record_num == 0) {
|
|
$error_message = getLanguageText('TEXT-INVALID-ACCESS');
|
|
header("Location: /?error_message=".urlencode($error_message));
|
|
exit();
|
|
}
|
|
|
|
$query = "delete from formatted_content where record_num = '$record_num'";
|
|
db_query($query);
|
|
|
|
include "email-messages-list.php";
|
|
break;
|
|
|
|
default:
|
|
include "email-messages-list.php";
|
|
break;
|
|
}
|
|
|
|
?>
|