<?php
	if( !$this->user->is_logged ) {
		$this->redirect('home');
	}
	
	
	/*************************************************************************/
	// needed before proceeding
	require_once('_all-required-language.php');
	
	$this->load_langfile('global/global.php');	
	$this->load_langfile('inside/dashboard.php');

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

	/*************************************************************************/

	$listgroups = $this->db2->fetch_all('
	SELECT * FROM groups 
	WHERE 
	idcreator='.$this->user->id
	);

	$D->htmlGroups = '';
	
	foreach($listgroups as $onegroup) {
		$D->idgroup = $onegroup->idgroup;
		$D->codegroup = $onegroup->code;
		$D->num_members = $onegroup->num_members;
		$D->numpostsgroup = $onegroup->num_posts;
		$D->namegroup = stripslashes($onegroup->name_group);
		$D->urlgroup = $onegroup->url;
		$D->status = $onegroup->status;
		$D->privacy = $onegroup->privacy;
		$D->isMyGroup = $onegroup->idcreator == $this->user->id ? TRUE : FALSE;
		if ($D->isMyGroup) {
			$D->numrequest = $this->db1->fetch_field('SELECT count(id) FROM groups_members WHERE status=0 AND idgroup='.$D->idgroup);
		}
		$D->htmlGroups .= $this->load_template('__dashboard-one-group.php', FALSE);
	}
	
	unset($listgroups, $onegroup);
	
	/*************************************************************************/

	$D->optionactive = 12;
	$D->tab_active = 1;
	$this->load_template('dashboard-groups.php');
?>