<?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->codcat = '';
	if ($this->param('c')) $D->codcat = $this->param('c');

	$D->optionactive_admin = 7;

	if (!empty($D->codcat)) {
		
		$D->namecat = $this->db2->fetch_field('SELECT name FROM pages_cat WHERE idcategory='.$D->codcat.' AND idfather=0 LIMIT 1');
		if (!$D->namecat) $this->redirect($C->SITE_URL.'admin/pages/categories');
		
		$D->htmlSubCatPages = '';
		$r = $this->db2->query('SELECT * FROM pages_cat WHERE idfather='.$D->codcat);
		while( $obj = $this->db2->fetch_object($r) ) {
			$D->name = $obj->name;
			$D->idcategory = $obj->idcategory;
			$D->idfather = $obj->idfather;
			$D->htmlSubCatPages .= $this->load_template('__admin-pagescat-one-subcat.php', FALSE);
		}
	
		unset($r, $obj);
		
		$D->tab_sub = 2;
		$this->load_template('admin_pages-subcategories.php');
	} else {

		$D->htmlCatPages = '';
		$r = $this->db2->query('SELECT * FROM pages_cat WHERE idfather=0');
		while( $obj = $this->db2->fetch_object($r) ) {
			$D->name = $obj->name;
			$D->idcategory = $obj->idcategory;
			$D->numchildren = $obj->num_children;
			$D->htmlCatPages .= $this->load_template('__admin-pagescat-one-cat.php', FALSE);
		}
	
		unset($r, $obj);
		
		$D->tab_sub = 2;
		$this->load_template('admin_pages-categories.php');
	}

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


?>