<?php
	if (!isset($gCms)) exit;
	if( !$this->CheckPermission( 'Modify Comments' ) ) exit;

	//Load the current articles
	$entryarray = array();

	$query = '';
	$dbresult = '';

	$query = "SELECT * FROM ".cms_db_prefix()."module_comments ORDER by comment_date DESC";
	$dbresult = $db->Execute($query);

	$rowclass = 'row1';

	while ($row = $dbresult->FetchRow())
	{
		$onerow = new stdClass();
		
		$onerow->id = $row['comment_id'];
		$data = substr($row['comment_data'], 0, 64);
		$onerow->data = $this->CreateLink($id, 'editcomment', $returnid, $data, array('commentid'=>$row['comment_id']));
		$onerow->postdate = $row['comment_date'];
		$onerow->author = $row['comment_author'];
		$onerow->pageid = ContentManager::GetPageAliasFromID($row['page_id']);
		$onerow->createdate = $row['create_date'];
		$onerow->modifydate = $row['modified_date'];
		$onerow->rowclass = $rowclass;
		
		$onerow->editlink = $this->CreateLink($id, 'editcomment', $returnid, $gCms->variables['admintheme']->DisplayImage('icons/system/edit.gif', $this->Lang('edit'),'','','systemicon'), array('commentid'=>$row['comment_id']));
		$onerow->deletelink = $this->CreateLink($id, 'deletecomment', $returnid, $gCms->variables['admintheme']->DisplayImage('icons/system/delete.gif', $this->Lang('delete'),'','','systemicon'), array('commentid'=>$row['comment_id']), $this->Lang('areyousure'));
		
		array_push($entryarray, $onerow);
		
		($rowclass=="row1"?$rowclass="row2":$rowclass="row1");
	}

	$this->smarty->assign_by_ref('items', $entryarray);
	$this->smarty->assign('itemcount', count($entryarray));

	$this->smarty->assign('authortext', $this->Lang('author'));
	$this->smarty->assign('datatext', $this->Lang('data'));
	$this->smarty->assign('postdatetext', $this->Lang('postdate'));
	$this->smarty->assign('modifydatetext', $this->Lang('modifydate'));
	$this->smarty->assign('pageidtext', $this->Lang('pageid'));

	#Display template
	echo $this->ProcessTemplate('commentlist.tpl');
		
# vim:ts=4 sw=4 noet
?>
