<?php

if (!defined('XOOPS_ROOT_PATH')) exit();

define("USER_SORT_KEY_DEFAULT",  0);
define("USER_SORT_KEY_UID",      1);
define("USER_SORT_KEY_UNAME",    2);
define("USER_SORT_KEY_NAME",     3);
define("USER_SORT_KEY_REGDATE",  4);
define("USER_SORT_KEY_LASTLOGIN",5);
define("USER_SORT_KEY_POSTS",    6);
define("USER_SORT_KEY_LEVEL",    7);

define("USER_SORT_KEY_MAXVALUE", 7);

/**
 *
 */
class UserActionFilterForm
{
	var $mSortKey=0;

	var $_mSortKeys=array(
		USER_SORT_KEY_DEFAULT    => "uid",
		USER_SORT_KEY_UID        => "uid",
		USER_SORT_KEY_UNAME      => "uname",
		USER_SORT_KEY_NAME       => "name",
		USER_SORT_KEY_REGDATE    => "user_regdate",
		USER_SORT_KEY_LASTLOGIN  => "last_login",
		USER_SORT_KEY_POSTS      => "posts",
		USER_SORT_KEY_LEVEL      => "level"
	);

	function fetch()
	{
		$this->mSortKey=isset($_REQUEST['sort']) ? intval($_REQUEST['sort']) : 0;

		if($this->mSortKey>USER_SORT_KEY_MAXVALUE)
			$this->mSortKey=0;
	}

	function getSort()
	{
		$sortkey=abs($this->mSortKey);
		return $this->_mSortKeys[$sortkey];
	}
	
	function getOrder()
	{
		return ($this->mSortKey < 0) ? "DESC" : "ASC";
	}
}

?>