Location: PHPKode > projects > Pal Vibes > palvibes/MessagePopup.php
<?php
/*
 * Created on ...
 * Popup page for sending messages
 */

require('includes/ApplicationTop.php');
require('includes/classes/Message.php');

$submit = false;

if(isset($referer->_get['msgId'])) {
	$msg = new Message;
	$msg->addWhereAnd(array('msg_id:=' => $referer->_get['msgId']));
	$msg->load();
	$user = new User;
	$user->addWhereAnd(array('user_id:=' => $msg->sender_id));
	$user->load();
	$titleValue = MSG_RE.': '.$msg->msg_title;
	$reply = true;
}
else {
	if(isset($referer->_get['userid'])) {
		$user = new User;
		$user->addWhereAnd(array('user_id:=' => $referer->_get['userid']));
		$user->load();
	}
	$titleValue = '';
	$reply = false;
}

if(isset($referer->_post['submit'])) {
	if(isset($referer->_post['sender'])) {
		$msg = new Message;
		$msg->save(array('msg_title' => $referer->_post['title'],
						 'msg_content' => $referer->_post['content'],
						 'sender_id' => $referer->_post['sender'],
						 'recver_id' => $referer->_post['recver'],
						 'send_time' => time()));
		$msg->addWhereAnd(array('msg_id:=' => $referer->_post['replyTo']));
		$msg->save(array('reply_time' => time(),
						 'if_read' => 1,
						 'recver_status' => STATUS_MSG_REPLIED));
	}
	else {
		$msg = new Message;
		$msg->save(array('msg_title' => $referer->_post['title'],
						 'msg_content' => $referer->_post['content'],
						 'sender_id' => $_SESSION['userInfo']['userid'],
						 'recver_id' => $referer->_post['userId'],
						 'send_time' => time()));
	}
	$submit = true;
}

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>joejoesucks</title>
<link href="includes/themes/<?php echo $config->theme_name?>/css/style.css" type="text/css" rel="stylesheet" />
<script type="text/javascript">
function checkForm() {
	if(document.getElementById('title').value == '') {
		alert('<?php echo MSG_TITLE_IS_INVALID?>');
		document.getElementById('title').focus();
		return false;
	}
	return true;
}
</script>
</head>
<body class="popup">
<?php
if($submit) {
	echo '<div style="text-align:center;">'.sprintf(MSG_SEND_SUCCESSFULLY, $referer->_post['to']).'<br><br>
			<input type="button" id="button" value="'.MSG_CLICK_TO_CLOSE_WINDOW.'" onclick="parent.tb_remove();"></div>';
}
else {
?>
<form action="<?php echo $_SERVER['PHP_SELF']?>" method="POST" onsubmit="return checkForm();">
<table cellpadding="0" cellspacing="10" border="0" id="popup">
  <tr>
  	<td nowrap><?php echo MSG_TO?>:</td>
  	<td class="formElements"><input type="text" name="to" value="<?php echo $user->user_nickname?>" readonly></td>
  </tr>
  <tr>
  	<td><?php echo MSG_TITLE?>:</td>
  	<td class="formElements"><input type="text" id="title" name="title" value="<?php echo $titleValue?>"></td>
  </tr>
  <tr>
  	<td><?php echo MSG_CONTENT?>:</td>
  	<td class="formElements"><textarea name="content" cols="45" rows="8"></textarea></td>
  </tr>
  <tr>
  	<td></td>
  	<td class="formElements"><input type="submit" id="submit" name="submit" value="<?php echo MSG_SEND?>"></td>
  </tr>
<?php
if(isset($referer->_get['msgId'])) {
?>
  <input type="hidden" name="sender" value="<?php echo $msg->recver_id?>">
  <input type="hidden" name="recver" value="<?php echo $msg->sender_id?>">
  <input type="hidden" name="replyTo" value="<?php echo $msg->msg_id?>">
<?php
}
else {
?>
  <input type="hidden" name="userId" value="<?php echo $referer->_get['userid']?>">
<?php
}
?>
</table>
</form>
<?php
}
?>
</body>
</html>
Return current item: Pal Vibes