/*
Jorge - frontend for mod_logdb - ejabberd server-side message archive module.
Copyright (C) 2009 Zbigniew Zolkiewski
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
of the License, 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 this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*/
require_once("headers.php");
require_once("upper.php");
$html->set_overview('
'.$con_head[$lang].'
'.$con_notice[$lang].'');
if ($_POST) {
	while (array_keys($_POST)) {
			$jid = base64_decode(str_replace("kezyt2s0", "+", key($_POST)));
			$val = array_shift($_POST);
			if ($val=="n") {
				$do_not_log_list .=$jid."\n";
			
			}
	}
	
	if ($db->update_log_list($do_not_log_list) === true) {
			$html->status_message($con_saved[$lang]);
		}
		else {
			$html->alert_message($oper_fail[$lang]);
	}
}
// sorting options
$get_sort = $_GET['sort'];
$get_dir = $_GET['o'];
// validate
if (!ctype_digit($get_sort) AND !ctype_digit($get_dir)) { unset($get_sort); unset($get_dir); }
if ($get_dir === "1") {
		$dir = "za";
		$get_dir = "2";
	
	}
	elseif($get_dir === "2"){
		$dir = "az";
		$get_dir = "1";
	}
	else{
		$dir = "az";
		$get_dir = "2";
	}
if ($get_sort === "1") {
		$ejabberd_roster->sort_by_jid($dir);
	
	}
	elseif($get_sort === "2") {
		$ejabberd_roster->sort_by_nick($dir);
	
	}
	elseif($get_sort === "3") {
		$ejabberd_roster->sort_by_group($dir);
	}
	else{
		$ejabberd_roster->sort_by_nick_group();
	}
$roster_con = $ejabberd_roster->get_roster();
if ($roster_con) {
	$db->get_log_list();
	$do_notlog_list = $db->result;
	$html->set_body('
		');
	}
	else {
		$html->status_message(''.$no_contacts[$lang].'
');
}
require_once("footer.php");
?>