Sender / Reciever of Private Messages - A copy for both?
Moderator: General Moderators
- allspiritseve
- DevNet Resident
- Posts: 1174
- Joined: Thu Mar 06, 2008 8:23 am
- Location: Ann Arbor, MI (USA)
Re: Sender / Reciever of Private Messages - A copy for both?
JAB Creations-- how is your code coming along? I'm actually at the point where I need to implement a PM system as well.
- JAB Creations
- DevNet Resident
- Posts: 2341
- Joined: Thu Jan 13, 2005 6:44 pm
- Location: Sarasota Florida
- Contact:
Re: Sender / Reciever of Private Messages - A copy for both?
I have saved the email notification of thread replies because frankly while I absolutely have no intention to be rude I'm still having difficulty grasping how you are portraying the BC/CC feature.
I will private message you a link...it's currently in late "Alpha". There are some important details I need to clarify in the message though I am open to working together on such a system.
I will private message you a link...it's currently in late "Alpha". There are some important details I need to clarify in the message though I am open to working together on such a system.
- allspiritseve
- DevNet Resident
- Posts: 1174
- Joined: Thu Mar 06, 2008 8:23 am
- Location: Ann Arbor, MI (USA)
Re: Sender / Reciever of Private Messages - A copy for both?
I'm not sure what you mean about the email notification, but... don't worry about the cc/bcc as far as my suggestions go... they're not important, and if you understand the rest of what I said, you should be fine. If you don't, feel free to ask questions, and I'll try my best to explain myself.JAB Creations wrote:I have saved the email notification of thread replies because frankly while I absolutely have no intention to be rude I'm still having difficulty grasping how you are portraying the BC/CC feature.
- JAB Creations
- DevNet Resident
- Posts: 2341
- Joined: Thu Jan 13, 2005 6:44 pm
- Location: Sarasota Florida
- Contact:
Re: Sender / Reciever of Private Messages - A copy for both?
Here's a screen shot...
http://img521.imageshack.us/img521/5926/messagespu9.png
...and here is the not ready for peer review in the critique forum ...code...though I will post it there in the coming weeks.
http://img521.imageshack.us/img521/5926/messagespu9.png
...and here is the not ready for peer review in the critique forum ...code...though I will post it there in the coming weeks.
Code: Select all
<?php
//error_reporting(0);
include("_header_00.php");
if (!isset($_GET['error'])) {include("themes/mysql.php");}
/*
if (isset($_POST['delete']) || $_POST['formis'] == 'signin')
{
$id = $_POST['id'];
$result = mysql_query("DELETE FROM `sys_plugin_messages` WHERE id='$id '");
if (!$result) {$_SESSION['error'] = mysql_error(); header("location:messages.php?error");}
header("location:messages.php");
}
*/
if (isset($_POST['delete']))
{
$result_del1 = mysql_query("SELECT id_for FROM `public_private_messages` WHERE id = '".mysql_real_escape_string($_POST['id'])."'");
if (!$result_del1) {$_SESSION['error'] = mysql_error(); header("location:messages.php?error=del1");}
$row1 = mysql_fetch_array($result_del1);
if ($row1['id_for'] == $_SESSION['member'])
{
$result_del2 = mysql_query("UPDATE public_private_messages SET id_for_folder='trash' WHERE (id_for = '".mysql_real_escape_string($_SESSION['member'])."' AND id = ".mysql_real_escape_string($_POST['id']).")");
if (!$result_del2) {$_SESSION['error'] = mysql_error(); header("location:messages.php?error=del2");}
}
else
{
header("location:messages.php?error=delete_permissions");
}
}
else if ($_POST['formis'] == "message")
{
include("themes/mysql.php");
$message = mysql_query("INSERT INTO public_private_messages (id_for, id_from, date_0, message, subject) VALUES ('".mysql_real_escape_string($_POST['id_for'])."', '".mysql_real_escape_string($_POST['id_from'])."', NOW(), '".mysql_real_escape_string($_POST['message'])."', '".mysql_real_escape_string($_POST['subject'])."')");
if (!$message) {$_SESSION['error'] = mysql_error(); header("location:messages.php?error");}
else {header("location:messages.php?sent");}
}
//header("Content-type: application/xhtml+xml");
$mime = (stristr($_SERVER["HTTP_ACCEPT"],"application/xhtml+xml")) ? "application/xhtml+xml" : "text/html";
header("content-type:$mime;charset=$charset");
echo'<?xml version="1.0" encoding="UTF-8"?>'."\n";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>Messages</title>
<link href="themes/style.css" media="screen" rel="stylesheet" title="Classic Theme" type="text/css" />
<link href="themes/style2.css" media="screen" rel="stylesheet" title="Classic Theme" type="text/css" />
<script src="http://www.jabcreations.com/scripts/scripts-2.8-00.js.php" type="text/javascript"></script>
<script src="http://www.jabcreations.com/scripts/scripts-2.8_functions-00.js.php" type="text/javascript"></script>
<script type="text/javascript">
//<![CDATA[
function row_blur(message_id)
{
if (document.getElementById(message_id).className == 'new new_focus') {change(message_id, 'new');}
else if (document.getElementById(message_id).className == 'read read_focus') {change(message_id, 'read');}
}
function row_focus(message_id)
{
if (document.getElementById(message_id).className == 'new') {change(message_id, 'new new_focus');}
else if (document.getElementById(message_id).className == 'read') {change(message_id, 'read read_focus');}
}
//]]>
</script>
</head>
<body>
<?php
/*****************************************Sign In*****************************************/
if (!isset($_SESSION['member'])) {include("_template_authentication.php"); exit();}
if (isset($_GET['status'])) {include("_template_status.php");}
?>
<div class="bodyaf" id="body">
<div id="content">
<div id="liquid">
<h1>JAB Creations - Messages</h1>
<div class="border">
<?php
if (isset($_GET['error'])) {include("_template_error.php"); exit();}
/*****************************************Display Message List*****************************************/
if (!isset($_GET['compose']) && !isset($_GET['message'])) {?>
<div class="width_15" id="folders">
<div class="left"><a class="message new" href="messages.php">Inbox</a></div>
<div class="left"><a class="message archive" href="messages.php?folder=archives">Archives</a></div>
<div class="left"><a class="message sent" href="messages.php?folder=sent">Sent</a></div>
<div class="left"><a class="message trash" href="messages.php?folder=trash">Trash</a></div>
</div><!-- /.width_15 -->
<div class="width_85">
<form action="messages.php" method="post">
<fieldset class="margin">
<legend><?php if (isset($_GET['folder'])) {echo ucfirst($_GET['folder']);} else {echo 'Inbox';}?></legend>
<p>Your <?php if (isset($_GET['folder'])) {echo ucfirst($_GET['folder']);} else {echo 'Inbox';}?> folder currently contains...</p>
<table summary="This table displays third party modules of the past and present.">
<colgroup style="width: 20px;"></colgroup>
<colgroup style="min-width: 120px; width: 160px;"></colgroup>
<colgroup style="min-width: 120px; width: 160px;"></colgroup>
<colgroup style="width: 70%;"></colgroup>
<thead>
<tr><td><input class="checkbox" type="checkbox" value="" /></td><td><?php if ($_GET['folder'] != "sent") {echo 'From';} else {echo 'Sent To';}?></td><td><?php if (!isset($_GET['date']) || $_GET['date'] == 'descend') {echo '<a href="messages.php?date=ascend">Date</a> (Descending)';} else {echo '<a href="messages.php?date=descend">Date</a> (Ascending)';}?></td><!--<td>IP</td>--><td>Subject</td></tr>
</thead>
<tfoot>
<tr><td><input class="checkbox" type="checkbox" value="" /></td><td><?php if ($_GET['folder'] != "sent") {echo 'From';} else {echo 'Sent To';}?></td><td><?php if (!isset($_GET['date']) || $_GET['date'] == 'descend') {echo '<a href="messages.php?date=ascend">Date</a> (Descending)';} else {echo '<a href="messages.php?date=descend">Date</a> (Ascending)';}?></td><!--<td>IP</td>--><td>Subject</td></tr>
</tfoot>
<tbody>
<?php
//$result = mysql_query("SELECT id, name, phone, address, date_0, comments, ip_0 FROM `sys_plugin_messages`") or die(mysql_error());
if ($_GET['date'] == 'ascend') {$sort = 'ASC';} else {$sort = 'DESC';}
if (!isset($_GET['folder'])) {$result1 = mysql_query("SELECT id, id_for_folder, id_from, date_0, date_1, message, subject FROM `public_private_messages` WHERE (id_for = '".$_SESSION['member']."' OR id_from = '".$_SESSION['member']."') AND (id_for_folder = 'new' OR id_for_folder = 'read') ORDER BY `public_private_messages`.`date_0` ".$sort."");} // AND id_for_folder = 'Read'
////SELECT id, id_for_folder, id_from, date_0, date_1, message, subject FROM `public_private_messages` WHERE id_for = '".$_SESSION['member']."' OR id_from = '".$_SESSION['member']."' AND id_for_folder = 'new' OR id_for_folder = 'read' ORDER BY `public_private_messages`.`date_0` DESC
//else if (!isset($_GET['folder']) && !isset($_GET['date']) || $_GET['date'] == 'ascend') {$result1 = mysql_query("SELECT id, id_for_folder, id_from, date_0, date_1, message, subject FROM `public_private_messages` WHERE id_for = '".$_SESSION['member']."' OR id_for_folder = 'New' ORDER BY `public_private_messages`.`date_0` ASC");} // AND id_for_folder = 'Read'
else if ($_GET['folder'] == "sent") {$result1 = mysql_query("SELECT id, id_for_folder, id_from, date_0, date_1, message, subject FROM `public_private_messages` WHERE id_from = '".$_SESSION['member']."'");}
else if ($_GET['folder'] == "trash") {$result1 = mysql_query("SELECT id, id_for_folder, id_from, date_0, date_1, message, subject FROM `public_private_messages` WHERE id_for = '".$_SESSION['member']."' AND id_for_folder = 'Trash'");}
else if ($_GET['folder'] == "archives") {$result1 = mysql_query("SELECT id, id_for_folder, id_from, date_0, date_1, message, subject FROM `public_private_messages` WHERE id_for = '".$_SESSION['member']."' AND id_for_folder = 'Archive'");}
if (!$result1) {$_SESSION['error'] = mysql_error(); header("location:messages.php?error");}
while($row = mysql_fetch_array($result1))
{
echo '<tr class="'.$row['id_for_folder'].'" id="message_'.$row['id'].'"><td><input class="checkbox" type="checkbox" value="" /></td>';
echo '<td>'.$row['id_from'].'</td>';
echo '<td>'.$row['date_0'].'</td>';
echo '<td><a class="message '.$row['id_for_folder'].'" href="messages.php?message='.$row['id'].'" onblur="row_blur(\'message_'.$row['id'].'\');" onfocus="row_focus(\'message_'.$row['id'].'\');">'.$row['subject'].'</a></td></tr>'."\n";
//if (strlen($row['subject']) > 72) {echo substr($row['subject'], 0, 72).'...';} else {echo $row['subject'];}
}
?>
</tbody>
</table>
</fieldset>
<fieldset class="margin">
<legend>Options</legend>
<p>options here</p>
</fieldset>
</form>
</div><!-- /.width_85 -->
<br class="clear" />
<?php }
/*****************************************Display Single Message*****************************************/
else if (isset($_GET['message']))
{
$id = $_GET['message'];
$result1 = mysql_query("SELECT id, id_for, id_for_folder, id_from, date_0, date_1, message, subject FROM `public_private_messages` WHERE id = '$id'");
if (!$result1) {$_SESSION['error'] = mysql_error(); header("location:messages.php?error=1");}
$row1 = mysql_fetch_array($result1);
$result2 = mysql_query("SELECT id, username, name FROM `public_accounts` WHERE username = '".$row1['id_from']."'");
if (!$result2) {$_SESSION['error'] = mysql_error(); header("location:messages.php?error=2");}
$row2 = mysql_fetch_array($result2);
if ($row1['id_for_folder'] == 'new')
{
$result4 = mysql_query("UPDATE public_private_messages SET id_for_folder='read' WHERE id = '$id'");
if (!$result4) {$_SESSION['error'] = mysql_error(); header("location:messages.php?error=3");}
}
?>
<form action="messages.php" method="post">
<?php
if ($row1['id_for'] != $_SESSION['member_id'] && $row1['id_from'] != $_SESSION['member']) {echo '<div><b class="bad">You should not be allowed to view this message!</b></div>';}
else {
?>
<div class="width_50">
<fieldset>
<legend>Message</legend>
<div><label for="view_from">From</label><input class="text disabled" disabled="disabled" id="view_from" type="text" value="<?php echo $row2['name'].' <'.$row2['username'].'>';?>" /></div>
<div><label for="view_sent">Sent</label><input class="text disabled" disabled="disabled" id="view_sent" type="text" value="<?php echo $row1['date_0'];?>" /></div>
<div><label for="view_subject">Subject</label><input class="text disabled" disabled="disabled" id="view_subject" type="text" value="<?php echo $row1['subject'];?>" /></div>
<div><label for="view_message">Message</label><div class="margin"><textarea class="disabled" cols="*" disabled="disabled" id="view_message" ><?php echo nl2br($row1['message']);?></textarea></div></div>
</fieldset>
</div>
<div class="width_50">
<fieldset>
<legend>Reply</legend>
<div><label for="from">From</label><input class="text disabled" disabled="disabled" id="from" name="from" type="text" value="<?php echo $_SESSION['member'].' <'.$_SESSION['member_name'].'>';?>" /></div>
<div><label for="to">To</label><input class="text disabled" disabled="disabled" id="to" name="to" type="text" value="<?php echo $row2['name'].' <'.$row2['username'].'>';?>" /></div>
<div><label for="subject">Subject</label><input class="text" id="subject" name="subject" type="text" value="Re: <?php echo $row1['subject'];?>" /></div>
<div><label for="message">Reply Messsage</label><div class="margin"><textarea id="message" name="message"></textarea></div></div>
</fieldset>
</div>
<fieldset class="clear margin">
<legend>Options</legend>
<input name="id" type="hidden" value="<?php echo $_GET['message'];?>" />
<input name="id_for" type="hidden" value="<?php echo $row2['username'];?>" />
<input name="id_from" type="hidden" value="<?php echo $_SESSION['member'];?>" />
<input name="formis" type="hidden" value="message" />
<input class="button" name="delete" type="submit" value="Delete Message" />
<input class="button" name="send" type="submit" value="Send Reply" />
</fieldset>
</form>
<?php }}
/*****************************************Compose Message*****************************************/
else if ($_GET['compose']) {?>
<form action="messages.php?compose=<?php echo $_GET['compose'];?>" method="post">
<fieldset>
<legend>Compose Message</legend>
<label for="from">From</label><input class="text disabled" disabled="disabled" id="from" name="from" type="text" value="<?php echo $_SESSION['member'];?>" />
<br />
<?php
//include("themes/mysql.php");
//$db_selected = mysql_select_db("jabcreat_members", $db);
$query1 = mysql_query("SELECT username, name FROM `public_accounts` WHERE id = '".mysql_real_escape_string($_GET['compose'])."'", $db);
if (!$query1) {$_SESSION['status'] = mysql_error(); header("location:messages.php?error");}
$row = mysql_fetch_array($query1);
?>
<label for="to">To</label><input class="text disabled" disabled="disabled" id="to" name="to" type="text" value="<?php echo $row['name'].' <'.$row['username'].'>';?>" />
<br />
<label for="subject">Subject</label><input class="text" id="subject" name="subject" type="text" value="" />
<br />
<label for="message">Message</label><textarea id="message" name="message"></textarea>
<br />
<input name="id_for" type="hidden" value="<?php echo $row['username'];?>" />
<input name="id_from" type="hidden" value="<?php echo $_SESSION['member'];?>" />
<input name="formis" type="hidden" value="message" />
<input class="button" type="submit" value="Send Message" />
</fieldset>
</form>
<?php } ?>
<?php include("_template_end_generic.php");?>