<?php

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

require_once XOOPS_ROOT_PATH."/class/XCube_PageNavigator.class.php";
require_once XOOPS_MODULE_PATH."/pm/forms/DeletePmsgForm.class.php";

class PmDefaultAction extends PmAction
{
	var $mActionForm=null;
	
	var $mPmObjects=array();
	
	var $mPageNavi=null;
	
	function isSecure()
	{
		return true;
	}

	function getDefaultView(&$controller,&$xoopsUser)
	{
		$pmHandler=&xoops_gethandler('privmessage');
		$total = $pmHandler->getCountByFromUid($xoopsUser->uid());

		$this->mPageNavi=new XCube_PageNavigator("./index.php",$total,XCUBE_PAGENAVI_START);
		$this->mPageNavi->fetch();

		$this->mPmObjects =& $pmHandler->getObjectsByFromUid($xoopsUser->uid(),$this->mPageNavi->getStart());

		return PM_FRAME_VIEW_INDEX;
	}

	function executeViewIndex(&$controller,&$xoopsUser,&$renderSystem)
	{
		$renderSystem->setTemplateName("viewpmsg.html");
		$renderSystem->setAttribute("pmObjects",$this->mPmObjects);
		$renderSystem->setAttribute("total_messages",count($this->mPmObjects));
		$renderSystem->setAttribute("currentUser",$xoopsUser);
		$renderSystem->setAttribute("anonymous",$controller->getConfig('anonymous'));
		$renderSystem->setAttribute("pageNavi",$this->mPageNavi);
	}
}

?>