<?php
// $Id: admin.users.html.php,v 1.22 2004/04/01 02:29:47 eddieajau Exp $
/**
* User 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.22 $
**/

class HTML_users {
	function showUsers( &$rows, $pageNav, $search, $option ) {
		global $mosConfig_offset;
?>
<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">User Manager</td>
      <td nowrap="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="2%" class="title">#</td>
      <th width="3%" class="title"> <input type="checkbox" name="toggle" value="" onClick="checkAll(<?php echo count($rows); ?>);" />
      </th>
      <th width="20%" class="title">Name</th>
      <th width="10%" class="title">UserID</th>
      <th width="15%" class="title">Group</th>
      <th width="15%" class="title">E-Mail</th>
      <th width="15%" class="title">Last Visit</th>
      <th width="10%" class="title">Enabled</th>
    </tr>
<?php
		$k = 0;
		for ($i=0, $n=count( $rows ); $i < $n; $i++) {
			$row =& $rows[$i];
			$img = $row->block ? 'publish_x.png' : 'tick.png';
			$task = $row->block ? 'unblock' : 'block';
?>
    <tr class="<?php echo "row$k"; ?>">
      <td><?php echo $i+1+$pageNav->limitstart;?></td>
      <td><input type="checkbox" id="cb<?php echo $i;?>" name="cid[]" value="<?php echo $row->id; ?>" onClick="isChecked(this.checked);" /></td>
      <td> <a href="#edit" onClick="return listItemTask('cb<?php echo $i;?>','edit')">
        <?php echo $row->name; ?> </a> </td>
      <td><?php echo $row->username; ?></td>
      <td><?php echo $row->groupname; ?></td>
      <td><a href="mailto:<?php echo $row->email; ?>"><?php echo $row->email; ?></a></td>
      <td><?php echo $row->lastvisitDate; ?></td>
      <td width="10%"><a href="javascript: void(0);" onClick="return listItemTask('cb<?php echo $i;?>
','<?php echo $task;?>')"><img src="images/<?php echo $img;?>" width="12" height="12" border="0" alt="" /></a></td>
    </tr>
    <?php $k = 1 - $k; } ?>
    <tr>
      <th align="center" colspan="9"> <?php echo $pageNav->writePagesLinks(); ?></th>
    </tr>
    <tr>
      <td align="center" colspan="9"> <?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 edituser( &$row, &$lists, $option, $uid ) {
		global $my, $acl;
		$canBlockUser = $acl->acl_check( 'administration', 'edit', 'users', $my->usertype, 'user properties', 'block_user' );
		$canEmailEvents = $acl->acl_check( 'workflow', 'email_events', 'users', $acl->get_group_name( $row->gid, 'ARO' ) );
?>
	<script language="javascript" type="text/javascript">
		function submitbutton(pressbutton) {
			var form = document.adminForm;
			if (pressbutton == 'cancel') {
				submitform( pressbutton );
				return;
			}
			var r = new RegExp("[^0-9A-Za-z]", "i");

			// do field validation
			if (trim(form.name.value) == "") {
				alert( "You must provide a name." );
			} else if (form.username.value == "") {
				alert( "You must provide a user login name." );
			} else if (r.exec(form.username.value)) {
				alert( "You can only have characters and number in your login name." );
			} else if (trim(form.email.value) == "") {
				alert( "You must provide an email address." );
			} else if (form.gid.value == "") {
				alert( "You must assign user to a group." );
			} else if (trim(form.password.value) != "" && form.password.value != form.password2.value){
				alert( "Password do not match." );
			} else {
				submitform( pressbutton );
			}
		}
	</script>

	<table cellpadding="4" cellspacing="0" border="0" width="100%">
		<tr>
			<td class="sectionname"><img src="images/mos_gel.png" width="70" height="67" align="middle"><?php echo $row->id ? 'Edit' : 'Add';?> User</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">Name:</td>
			<td width="85%"><input type="text" name="name" class="inputbox" size="40" value="<?php echo $row->name; ?>" /></td>
		</tr>
		<tr>
			<td>Username:</td>
			<td><input type="text" name="username" class="inputbox" size="40" value="<?php echo $row->username; ?>" /></td>
		<tr>
			<td>Email:</td>
			<td><input class="inputbox" type="text" name="email" size="40" value="<?php echo $row->email; ?>" /></td>
		</tr>
		<tr>
			<td>New Password:</td>
			<td><input class="inputbox" type="password" name="password" size="40" value="" /></td>
		</tr>
		<tr>
			<td>Verify Password:</td>
			<td><input class="inputbox" type="password" name="password2" size="40" value="" /></td>
		</tr>
		<tr>
		  <td valign="top">Group:</td>
		  <td><?php echo $lists['gid']; ?></td>
		</tr>
<?php	if ($canBlockUser) { ?>
		<tr>
		  <td>Block User</td>
		  <td><?php echo $lists['block']; ?></td>
		</tr>
<?php	}
		if ($canEmailEvents) { ?>
		<tr>
		  <td>Receive Submission Emails</td>
		  <td><?php echo $lists['sendEmail']; ?></td>
		</tr>
<?php	} ?>
<?php if( $uid ) { ?>
		<tr>
		   <td>Register Date</td>
		   <td><?php echo $row->registerDate;?></td>
		</tr>
		<tr>
		   <td>Last Visit Date</td>
		   <td><?php echo $row->lastvisitDate;?></td>
		</tr>
<?php } ?>
		<tr>
			<td colspan="2">&nbsp;</td>
		</tr>
  </table>
  <input type="hidden" name="id" value="<?php echo $row->id; ?>" />
<?php	if (!$canEmailEvents) { ?>
  <input type="hidden" name="sendEmail" value="0" />
<?php } ?>
  <input type="hidden" name="option" value="<?php echo $option; ?>" />
  <input type="hidden" name="task" value="" />
</form>
<?php }

}?>
