<?php
// $Id: admin.messages.html.php,v 1.11 2003/12/08 22:41:38 rcastley Exp $
/**
* Messages admin HTML
* @package Mambo Open Source
* @Copyright (C) 2000 - 2003 Miro International Pty Ltd
* @ All rights reserved
* @ Mambo Open Source is Free Software
* @ Released under GNU/GPL License : http://www.gnu.org/copyleft/gpl.html
* @version $Revision: 1.11 $
**/

class HTML_messages {
	function showMessages( &$rows, $pageNav, $search, $option ) {
?>
<form action="index2.php" method="post" name="adminForm">
  <table cellpadding="4" cellspacing="0" border="0" width="100%">
    <tr>
      <td width="100%" class="sectionname"><img src="images/mos_gel.png" width="70" height="67" align="middle">Private Messaging</td>
      <td nowrap>Display #</td>
      <td> <?php echo $pageNav->writeLimitBox(); ?> </td>
      <td>Search:</td>
      <td> <input type="text" name="search" value="<?php echo $search;?>" class="inputbox" onChange="document.adminForm.submit();" />
      </td>
    </tr>
  </table>
  <table cellpadding="4" cellspacing="0" border="0" width="100%" class="adminlist">
    <tr>
      <th width="20">#</td>
      <th width="5%" class="title"> <input type="checkbox" name="toggle" value="" onClick="checkAll(<?php echo count($rows); ?>);" />
      </th>
      <th width="60%" class="title">Subject</th>
      <th width="15%" class="title">From</th>
      <!-- <th width="20%" class="title">UserType</th> -->
      <th width="15%" class="title">Date</th>
      <th width="5%" class="title">Read</th>
    </tr>
<?php
		$k = 0;
		for ($i=0, $n=count( $rows ); $i < $n; $i++) {
			$row =& $rows[$i];
?>
    <tr class="<?php echo "row$k"; ?>">
      <td width="20"><?php echo $i+1+$pageNav->limitstart;?></td>
      <td width="5%"><input type="checkbox" id="cb<?php echo $i;?>" name="cid[]" value="<?php echo $row->message_id; ?>" onClick="isChecked(this.checked);" /></td>
      <td width="60%"> <a href="#edit" onClick="return listItemTask('cb<?php echo $i;?>','view')">
        <?php echo $row->subject; ?> </a> </td>
      <td width="15%"><?php echo $row->user_from; ?></td>
      <td width="15%"><?php echo $row->date_time; ?></td>
      <td width="15%"><?php 
	  if (intval( $row->state ) == "1") {
	  echo "Read";
	  } else {
	  echo "Unread";
	  } ?></td>
    </tr>
    <?php $k = 1 - $k;
			} ?>
    <tr>
      <th align="center" colspan="8"> <?php echo $pageNav->writePagesLinks(); ?></th>
    </tr>
    <tr>
      <td align="center" colspan="8"> <?php echo $pageNav->writePagesCounter(); ?></td>
    </tr>
  </table>
  <input type="hidden" name="option" value="<?php echo $option;?>" />
  <input type="hidden" name="task" value="" />
  <input type="hidden" name="boxchecked" value="0" />
</form>
<?php }

	function editConfig( &$vars, $option) {
?>
<table cellpadding="4" cellspacing="0" border="0" width="100%">
  <tr>
    <td width="100%" class="sectionname"><img src="images/mos_gel.png" width="70" height="67" align="middle" />Private Messaging Configuration</span></td>
  </tr>
</table>
<script language="javascript" src="js/dhtml.js"></script>
<table cellpadding="3" cellspacing="0" border="0" width="100%">
  <tr>
    <td width="" class="tabpadding">&nbsp;</td>
    <td id="tab1" class="offtab" onClick="dhtml.cycleTab(this.id)" nowrap>General</td>
    <td width="90%" class="tabpadding">&nbsp;</td>
  </tr>
</table>
<script language="javascript" type="text/javascript">
	function submitbutton(pressbutton) {
		var form = document.adminForm;
			if (pressbutton == 'saveconfig') {
				if (confirm ("Are you sure?")) {
					submitform( pressbutton );
				}
			} else {
				document.location.href = 'index2.php?option=<?php echo $option;?>';
			}
	}
</script>
<form action="index2.php" method="POST" name="adminForm">
  <div id="page1" class="pagetext">
    <table cellpadding="2" cellspacing="4" border="0" width="100%" class="adminform">
      <tr>
        <td width="20%">Lock Inbox:</td>
        <td> <?php echo $vars['lock']; ?> </td>
      </tr>
      <tr>
        <td width="20%">Mail me on new Message:</td>
        <td> <?php echo $vars['mail_on_new']; ?> </td>
      </tr>
    </table>
  </div>
  <input type="hidden" name="option" value="<?php echo $option; ?>">
  <input type="hidden" name="task" value="">
</form>
<script language="javascript" type="text/javascript">
	dhtml.cycleTab('tab1');
</script>
<?php }

	function viewMessage( &$row, $option ) {
?>
	<table cellpadding="4" cellspacing="0" border="0" width="100%">
		<tr>
			<td class="sectionname">View Private Message</td>
		</tr>
	</table>

	<form action="index2.php" method="post" name="adminForm">
	<table cellpadding="4" cellspacing="1" border="0" width="100%" class="adminform">
		<tr>
			<td width="100">From:</td>
			<td width="85%" bgcolor="#ffffff"><?php echo $row->user_from;?></td>
		</tr>
		<tr>
			<td>Posted:</td>
			<td bgcolor="#ffffff"><?php echo $row->date_time;?></td>
		</tr>
		<tr>
			<td>Subject:</td>
			<td bgcolor="#ffffff"><?php echo $row->subject;?></td>
		</tr>
		<tr>
			<td>Message:</td>
			<td width="100%" bgcolor="#ffffff"><?php echo htmlspecialchars( $row->message );?></td>
		</tr>
	</table>
	</form>
<?php }

	function newMessage($option, $recipientslist ) {
		global $my;
?>
	<script language="javascript" type="text/javascript">
		function submitbutton(pressbutton) {
			var form = document.adminForm;
			if (pressbutton == 'cancel') {
				submitform( pressbutton );
				return;
			}

			// do field validation
			if (form.subject.value == "") {
				alert( "You must provide a subject." );
			} else if (form.message.value == "") {
				alert( "You must provide a message." );
			} else if (getSelectedValue('adminForm','user_id_to') < 1) {
				alert( "You must select a recipient." );
			} else {
				submitform( pressbutton );
			}
		}
	</script>

	<table cellpadding="4" cellspacing="0" border="0" width="100%">
		<tr>
			<td class="sectionname">New Private Message</td>
		</tr>
	</table>

	<form action="index2.php" method="post" name="adminForm">
	<table cellpadding="4" cellspacing="1" border="0" width="100%" class="adminform">
		<tr>
			<td width="100">To:</td>
			<td width="85%" bgcolor="#ffffff"><?php echo $recipientslist; ?></td>
		</tr>
		<tr>
			<td>Subject:</td>
			<td bgcolor="#ffffff"> <input type="text" name="subject" size="50" maxlength="100" class="inputbox" /></td>
		</tr>
		<tr>
			<td>Message:</td>
			<td width="100%" bgcolor="#ffffff"> <input type="text" name="message" size="50" maxlength="100" class="inputbox" /></td>
		</tr>
	</table>
	<input type="hidden" name="user_id_from" value="<?php echo $my->id; ?>">
	<input type="hidden" name="option" value="<?php echo $option; ?>">
	<input type="hidden" name="task" value="">
	</form>
<?php }

}?>
