<?php

// -----------------------------------------------------------------------
// This file is part of AROUNDMe
//
// Copyright (C) 2003 - 2007 Barnraiser
// http://www.barnraiser.org/
// info@barnraiser.org
//
// This program is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by the
// Free Software Foundation; either version 2, or (at your option) any
// later version.
//
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with program; see the file COPYING. If not, write to the Free
// Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
// 02110-1301, USA.
// -----------------------------------------------------------------------

$menu_section = "structure";



$output_contact_reports = selContactReports();
$body->set('contact_reports', $output_contact_reports);




/*
* selContactReports
* Tom Calthrop 29th September 2006
*/
function selContactReports() {
	
	global $db, $user, $core_config;
	
	$query = "
		SELECT contact_id, reportee_user_id, contact_report_type, 
		reportee_language_id, report_datetime, report_status_id, 
		reportee_email, assigned_user_id 
		FROM " . $db->prefix . "_contact 
		ORDER BY report_datetime desc"
	;
	
	$result = $db->Execute($query);
	
	if (isset($result->fields)) {
		
		$temp = array();

		$user->identity_type = $core_config['user']['identity']['type']['registered'];
		
		while (!$result->EOF) {
			$temp1 = $result->fields;
			
			if (!empty($temp1['reportee_user_id'])) {
				$temp1['identity'] = $user->selUserIdentity($temp1['reportee_user_id']);
			}
			else {
				$temp1['reportee_name'] = $temp1['reportee_email'];
			}

			if (!empty($temp1['assigned_user_id'])) {
				$temp1['assigned_identity'] = $user->selUserIdentity($temp1['assigned_user_id']);
			}
			
			array_push($temp, $temp1);
			
			$result->MoveNext();
		}
		
		return $temp;
	}
}
?>