<?php 
	
	// We check in which language we will work
	if (isset($_SESSION["DATAGLOBAL"][0]) && !empty($_SESSION["DATAGLOBAL"][0])) $C->LANGUAGE = $_SESSION["DATAGLOBAL"][0];

	$this->load_langfile('inside/admin.php');

	// We are here only if you're logged in
	if (!$this->user->is_logged || !$this->user->info->is_network_admin) {
		echo('0: '.$this->lang('admin_no_session'));
		die();
	}

	$errored = 0;
	$txterror = '';
	
	$action=0;
	
	if (isset($_POST["todo"]) && $_POST["todo"] != '') $action = $this->db1->e($_POST["todo"]);
	if (!is_numeric($action)) {
		$errored = 1;
		$txterror .= 'Error... ';
		echo('0: '.$txterror);
		die();
	}

	// edit group
	if ($action == 1)	{

		$namegroup = $description= $cgroup = '';
		$privacy = $status = 0;
		
		if (isset($_POST["ng"]) && !empty($_POST["ng"])) $namegroup = $this->db1->e(htmlspecialchars($_POST["ng"]));
		if (isset($_POST["dg"]) && !empty($_POST["dg"])) $description = $this->db1->e(htmlspecialchars($_POST["dg"]));
		if (isset($_POST["priv"])) $privacy = $this->db1->e($_POST["priv"]);
		if (isset($_POST["stat"])) $status = $this->db1->e($_POST["stat"]);
		if (isset($_POST["cg"]) && !empty($_POST["cg"])) $cgroup = $this->db1->e($_POST["cg"]);
		
		if (empty($cgroup)) { $errored = 1; $txterror .= 'Error... '; }
		if (empty($namegroup)) { $errored = 1; $txterror .= 'Error... '; }
		if (!is_numeric($privacy)) { $errored = 1; $txterror .= 'Error... '; }
		if (!is_numeric($status)) { $errored = 1; $txterror .= 'Error... '; }
				
	}

	
	if ($errored == 1) {
		echo('0: '.$txterror);
	} else {

		if ($action == 1) {
			$this->db1->query("UPDATE groups SET status=".$status.", privacy=".$privacy.", name_group='".$namegroup."', about_group='".$description."'  WHERE code='".$cgroup."' LIMIT 1");
			$txtreturn = $this->lang('admin_groups_update_txt_msgok');
			echo('1: '.$txtreturn);
			return;
		}
			
	}
?>