View file veppa_wallpaper/sys/app/views/admin/users.php

File size: 2Kb
<?php echo $this->validation()->messages() ?>

<h1><?php echo $pending?__('Pending users'):__('Users');?></h1>

<?php echo $paginator;?>

<table class="grid">
	<tr>
		<th><?php echo __('Username')?></th>
		<th><?php echo __('Email')?></th>
		<th><?php echo __('Permission')?></th>
		<?php 
		if($pending)
		{
		?>
		<th><?php echo __('Verified')?></th>
		<?php 
		}
		?>
		<th><?php echo __('Edit')?></th>
		<th><?php echo __('Delete')?></th>
	</tr>
	<?php 
	if($users)
	{
		foreach($users as $u)
		{
			echo '<tr class="r'.($tr_row++%2).'">';
			echo '<td>'.View::escape($u->username).'</td>';
			echo '<td>'.View::escape($u->email).'</td>';
			echo '<td>'.User::getLevel($u->level).'</td>';
			if($pending)
			{
				echo '<td><a href="#active" class="activate button small" u_id="'.$u->id.'">'.($u->activation?__('no'):__('yes')).'</a></td>';
			}
			echo '<td><a href="'.get_url('admin/users/edit/'.$u->id.'/').'" class="button small">'.__('edit').'</a></td>';
			echo '<td><a href="#delete" class="delete button small red" u_id="'.$u->id.'">'.__('delete').'</a></td>';
			echo '</tr>';
		}
	}
	else
	{
		echo '<tr><td colspan="'.($pending?6:5).'">'.__('No users found.').'</td></tr>';
	}
	?>
</table>

<?php echo $paginator;?>

<script>
$(function(){ 
	$('.activate').click(verifyUser); 
	$('.delete').click(deleteUser); 
});

function verifyUser()
{
	var $me = $(this);
	var id = $me.attr('u_id');
	var $tr = $me.parents('tr:first');
	$.post(URL_BASE+'admin/users/verify/',{id:id},function(data){
		if(data=='ok')
		{
			$tr.remove();
		}
		else
		{
			alert('Error: '+data);
		}
	});
	return false;
}

function deleteUser()
{
	var $me = $(this);
	var id = $me.attr('u_id');
	var $tr = $me.parents('tr:first');

	if(confirm('Do you wnat to delete this user?'))
	{
		$.post(URL_BASE+'admin/users/delete/',{id:id},function(data){
			if(data=='ok')
			{
				$tr.remove();
			}
			else
			{
				alert('Error: '+data);
			}
		});
	}
	return false;
}
</script>