<?php

/*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*\
<< ******************************************************************** >>
<< * ---------------------------------------------------------------- * >>
<< * Copyright ©2011-2012 Ozzy47                                      * >>
<< * All Rights Reserved. 											  * >>
<< * This file may not be redistributed in whole or significant part. * >>
<< * ---------------------------------------------------------------- * >>
<< * You are not allowed to use this on your server unless the files  * >>
<< * you downloaded were done so with permission.					  * >>
<< * ---------------------------------------------------------------- * >>
<< ******************************************************************** >>
\*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*/

self::$db->query_write("
	INSERT INTO " . TABLE_PREFIX . "phrasetype (fieldname, title, editrows, product) 
	VALUES ('dbtech_vbnavtabs', 'Dragonbyte-Tech: vBNavTabs', 3, 'dbtech_vbnavtabs')
");

		self::$db->hide_errors();
        self::$db->query_write("
	CREATE TABLE IF NOT EXISTS " . TABLE_PREFIX . "dbtech_vbnavtabs (
        tabid int(10) NOT NULL auto_increment,
        title varchar(100) NOT NULL,
        vbphrase VARCHAR( 200 ) NOT NULL DEFAULT '',
        url varchar(200) NOT NULL,
        tabmode ENUM('THIS_SCRIPT','URL','URL_PARAMETER') NOT NULL DEFAULT 'THIS_SCRIPT',
        image VARCHAR( 200 ) NOT NULL DEFAULT '',
        script varchar(100) NOT NULL,
        target enum('_blank','_parent','_self','_top') NOT NULL,
        allowedusergroup varchar(255) NOT NULL,
        blockedusergroup varchar(255) NOT NULL,
        position enum('left','center','right','navbartwo') NOT NULL,
        enable smallint(1) NOT NULL default '1',
        displayorder int(10) NOT NULL,
        notes varchar(200) NOT NULL,
        PRIMARY KEY  (tabid)
	)
");
        self::report('Added Phrases', 'cphome, dbtech_vbnavtabs, error, vbsettings');
    	self::report('Created Table', 'dbtech_vbnavtabs');
   
        self::$db->query_write("
	CREATE TABLE IF NOT EXISTS " . TABLE_PREFIX . "dbtech_vbnavtabs_childs (
        childid int(10) NOT NULL auto_increment,
        tabid int(10) NOT NULL,
        title varchar(100) not null,
        vbphrase VARCHAR( 200 ) NOT NULL DEFAULT '',
        url varchar(200) not null,
        image VARCHAR( 200 ) NOT NULL DEFAULT '',        
        target enum('_blank','_parent','_self','_top') NOT NULL,
        allowedusergroup varchar(255) NOT NULL,
        blockedusergroup varchar(255) NOT NULL,
        enable smallint(1) NOT NULL default '1',
        type enum('menuitem','submenu') NOT NULL,
        displayorder int(10) NOT NULL,
        notes varchar(200) NOT NULL,
        PRIMARY KEY  (childid)
	)
");
        self::report('Created Table', 'dbtech_vbnavtabs_childs');

        self::$db->query_write("
    INSERT INTO " . TABLE_PREFIX . "dbtech_vbnavtabs (tabid, title, url, image, script, target, allowedusergroup, blockedusergroup, enable, position, displayorder) 
    VALUES
        (1, 'Forum Scriptz', 'http://www.forumscriptz.org','dbtech/vbnavtabs/images/FSlogo.png', '', '_blank', '6', '', 1, 'left', 10),
        (2, 'Groups', 'group.php', '', 'group', '_self', '6', '', 1, 'center', 20),
        (3, 'Albums', 'album.php', '', 'album', '_self', '6', '', 1, 'right', 30)
	
");
		self::$db->hide_errors();

        self::report('Added Default Tabs', 'Forum Scriptz, Groups, Albums');      
           
require_once(DIR . '/includes/adminfunctions.php');
require_once(DIR . '/includes/functions.php');

	$tab_query = self::$db->query_read("
		SELECT 
			t.tabid,
            t.type_of_tab, 
			t.title, 
			t.vbphrase, 
			t.url, 
			t.tabmode, 
			t.image, 
			t.script, 
			t.target, 
			t.allowedusergroup, 
			t.blockedusergroup, 
			t.position, 
			t.enable, 
			c.childid, 
			c.title as ctitle, 
			c.vbphrase as cvbphrase, 
			c.url as curl,
            c.image as cimage, 
			c.target as ctarget, 
			c.allowedusergroup as callowedusergroup, 
			c.blockedusergroup as cblockedusergroup, 
			c.type, 
			c.enable as cenable
		FROM " . TABLE_PREFIX . "dbtech_vbnavtabs as t 
		LEFT JOIN " . TABLE_PREFIX . "dbtech_vbnavtabs_childs as c ON t.tabid=c.tabid 
		WHERE 
			t.enable=1 
		ORDER BY 
			t.displayorder, 
			c.type, 
			c.displayorder
	");

	while ($tabs = self::$db->fetch_array($tab_query))
	{
		$tab_cache[$tabs['tabid'] . '_' . $tabs['childid']] = $tabs;
	}

	build_datastore('dbtech_vbnavtabs_tabs', serialize($tab_cache), true);


	
/*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*\
<< ********************************************************************* >>
<< * Created: 19:30, Fri Nov 25th 2011                                 * >>
<< * VER: 1.0.0                                                        * >>
<< ********************************************************************* >>
\*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*/

?>