<?php
	
	if( !$this->network->id ) {
		$this->redirect('home');
	}
	if( !$this->user->is_logged ) {
		$this->redirect('home');
	}
	
	$db2->query('SELECT 1 FROM users WHERE iduser="'.$this->user->id.'" AND is_network_admin=1 LIMIT 1');
	if( 0 == $db2->num_rows() ) {
		$this->redirect('dashboard');
	}
	
	
	/*************************************************************************/
	// needed before proceeding
	require_once('_all-required-language.php');
	
	$this->load_langfile('global/global.php');	
	$this->load_langfile('inside/admin.php');

	/*************************************************************************/
	
	
	require_once('_all-required-dashboard-admin.php');
	

	/*************************************************************************/
	
	
	$D->htmlReports = '';

	$listsReports = $this->db2->fetch_all('SELECT reports.*, idcomment, idpost FROM reports, comments WHERE reports.iditem=comments.idcomment AND typeitem=2 ORDER BY reports.whendate DESC');

	foreach ($listsReports as $oneReport) {
		$D->onereport = $oneReport;

		$uinformer = $this->db2->fetch('SELECT avatar, username, firstname, lastname FROM users WHERE iduser='.$D->onereport->idinformer);		
		$D->avat_informer = $uinformer->avatar;
		$D->username_informer = $uinformer->username ;
		$D->name_informer = (empty($uinformer->firstname) || empty($uinformer->lastname) ? $uinformer->username : ($uinformer->firstname.' '.$uinformer->lastname)) ;
		
		$D->idcomment = $D->onereport->idcomment;
		$infoPost = $this->network->getInfoCommentById($D->idcomment);
		$D->codepost = $infoPost->code;
		$D->idpost = $D->onereport->idpost;
		$D->idOwnerPost = $infoPost->iduser;
		$D->usernamePost = $infoPost->username;
		$D->commentReport = stripslashes($infoPost->comment);
		
		$udenounced = $this->db2->fetch('SELECT avatar, username, firstname, lastname FROM users WHERE iduser='.$D->onereport->iddenounced);
		$D->avat_denounced = $udenounced->avatar ;
		$D->username_denounced = $udenounced->username ;
		$D->name_denounced = (empty($udenounced->firstname) || empty($udenounced->lastname) ? $udenounced->username : ($udenounced->firstname.' '.$udenounced->lastname)) ;

		$D->htmlReports .= $this->load_template('__admin-reports-one-report-comment.php', FALSE);
	}
	unset($listsReports, $oneReport);
	
	
	/*************************************************************************/

	$D->tabsmenu_active = 2;
	$D->optionactive_admin = 9;
	$this->load_template('admin_reports-comments.php');

?>