<?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.					  * >>
<< * ---------------------------------------------------------------- * >>
<< ******************************************************************** >>
\*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*/

// ############################# LOG ACTION ##############################
log_admin_action();
// ############################# END LOG ACTION ##########################

print_cp_header();

if ( $_REQUEST['do'] == 'tabs'){	
	
	print_form_header('vbnavtabs', 'ordertab', 0, 1, 'modifytab');
	print_table_header($vbphrase['dbtech_vbnavtabs_tab_title'],9);
	$sql = "SELECT t.*,c.title as ctitle, c.url as curl, c.childid
			FROM " . TABLE_PREFIX . "dbtech_vbnavtabs as t
			LEFT JOIN " . TABLE_PREFIX . "dbtech_vbnavtabs_childs as c on t.tabid=c.tabid
			ORDER BY t.displayorder,c.displayorder
			";
	$result = $db->query_read($sql);

    if ($vbulletin->options['dbtech_vbnavtabs_displayusergroups'])
    {
	print_cells_row(array(
            $vbphrase['dbtech_vbnavtabs_tabid'],
			$vbphrase['dbtech_vbnavtabs_tab'],
			$vbphrase['dbtech_vbnavtabs_url'],
			$vbphrase['dbtech_vbnavtabs_mode'],
            $vbphrase['dbtech_vbnavtabs_ug_title'],
			$vbphrase['dbtech_vbnavtabs_position'],
			$vbphrase['dbtech_vbnavtabs_active'],
			$vbphrase['dbtech_vbnavtabs_display_order'],
			$vbphrase['dbtech_vbnavtabs_controls']
			), 1, '', -1);
    } else
            
    {    
	print_cells_row(array(
            $vbphrase['dbtech_vbnavtabs_tabid'],
			$vbphrase['dbtech_vbnavtabs_tab'],
			$vbphrase['dbtech_vbnavtabs_url'],
			$vbphrase['dbtech_vbnavtabs_mode'],
			$vbphrase['dbtech_vbnavtabs_position'],
			$vbphrase['dbtech_vbnavtabs_active'],
			$vbphrase['dbtech_vbnavtabs_display_order'],
			$vbphrase['dbtech_vbnavtabs_controls']
			), 1, '', -1);
    }

	if ($db->num_rows($result))
	{
	$accumulate = array();

	while( $sourceitem = $db->fetch_array( $result ) ) 
		{
			$cell = array();
			$cell[0] = $sourceitem['tabid'];
			
			if ($sourceitem['url']=='[DROPDOWN TAB]')
			{
				$cell[1] = $sourceitem['title'] . '<input name="idmasschange['.$sourceitem['tabid'].']" type="hidden" value="'.$sourceitem['tabid'].'"> <dfn><strong>Dropdown Tab</strong></dfn>';
				if ($sourceitem['childid'])
				{
				$cell[2] = "<div><a href='vbnavtabs.php?$session[sessionurl]do=editdropdown&amp;childid=$sourceitem[childid]'>$sourceitem[ctitle]</a></div>";
				}
				else
				{
				$cell[2] = "".$vbphrase['dbtech_vbnavtabs_hide_no_menu']."<br />";
				$cell[2] .= construct_link_code($vbphrase['dbtech_vbnavtabs_add_new_dropdown_item'], "vbnavtabs.php?do=newdropdown&tabid=$sourceitem[tabid]") . "";
				}
			}
			else
			{
//				if($sourceitem['image']!="")
//				{
//				$image='<img src="'.$sourceitem['image'].'">';
//				}
//				else
//				{
//				$image= '';
//				}
				$cell[1] = $sourceitem['title'] . '<input name="idmasschange['.$sourceitem['tabid'].']" type="hidden" value="'.$sourceitem['tabid'].'">';
				$cell[2] = $sourceitem['url'] . "<dfn>target = ".$sourceitem['target']."</dfn>";
			}
			
			if ($sourceitem['tabmode']=='THIS_SCRIPT')
			{
				$moreinfo='<br /> ' .$sourceitem['script'];
			}
			$cell[3] = "<strong>".$sourceitem['tabmode'] . "</strong>". $moreinfo;
            
   if ($vbulletin->options['dbtech_vbnavtabs_displayusergroups'])
			$cell[4] = "<div>".construct_phrase($vbphrase['dbtech_vbnavtabs_ug_allowed'],$sourceitem['allowedusergroup'])."</div> <div>".construct_phrase($vbphrase['dbtech_vbnavtabs_ug_not_allowed'],$sourceitem['blockedusergroup'])."</div>";
            
			$cell[5] = $sourceitem['position'];
			if ($sourceitem['enable']==1)
			{
				$check = 'checked="checked"';
			}
			else
			{
				$check = "";
			}
			
			$cell[6] = '<input name="active['.$sourceitem['tabid'].']" '.$check.' type="checkbox">';
			$cell[7] = "
						<input style=\"text-align: center\" type=\"text\" class=\"bginput\" name=\"order[" . $sourceitem['tabid'] . "]\" tabindex=\"1\" value=\"$sourceitem[displayorder]\" size=\"4\" title=\"".$vbphrase['dbtech_vbnavtabs_display_order']."\" class=\"smallfont\" />
			";
    if ($sourceitem['url']=='[DROPDOWN TAB]')
            {
			$cell[8] = "" .
					construct_link_code($vbphrase['dbtech_vbnavtabs_edit'], "vbnavtabs.php?$session[sessionurl]do=editdropdowntab&amp;tabid=$sourceitem[tabid]") .
					construct_link_code($vbphrase['dbtech_vbnavtabs_delete'], "vbnavtabs.php?$session[sessionurl]do=deletetab&tabid=$sourceitem[tabid]");
            } 
            else        
            {
           $cell[8] = "" . 
					construct_link_code($vbphrase['dbtech_vbnavtabs_edit'], "vbnavtabs.php?$session[sessionurl]do=edittab&amp;tabid=$sourceitem[tabid]") .
					construct_link_code($vbphrase['dbtech_vbnavtabs_delete'], "vbnavtabs.php?$session[sessionurl]do=deletetab&tabid=$sourceitem[tabid]");
            }
        
				if($cell[0]==$accumulate[count($accumulate)-1][0])
				{
					if ($cell[2]=='[DROPDOWN TAB]')
					{
					$accumulate[count($accumulate)-1][2].=$cell[2];
					}
					
				}
				else
				{
					$accumulate[]=$cell;
				}			
		}

		foreach ($accumulate as $key=>$row)
		{
			print_cells_row($row, 0, '', 1);
		}
	}
	else
	{
	print_description_row('<center>'.$vbphrase['dbtech_vbnavtabs_no_tabs'].'</center>',0,9);
	}
        print_submit_row($vbphrase['dbtech_vbnavtabs_save_changes'], false, count($headings), false, "<input type=\"button\" id=\"addnew\" class=\"button\" value=\"" . str_pad($vbphrase['dbtech_vbnavtabs_add_new_regular_tab'], 8, ' ', STR_PAD_BOTH) . "\" tabindex=\"1\" onclick=\"window.location = 'vbnavtabs.php?do=newtab'\" />  <input type=\"button\" id=\"addnew\" class=\"button\" value=\"" . str_pad($vbphrase['dbtech_vbnavtabs_add_new_dropdown_tab'], 8, ' ', STR_PAD_BOTH) . "\" tabindex=\"1\" onclick=\"window.location = 'vbnavtabs.php?do=newdropdowntab'\" />");  
}		

print_cp_footer();

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

?>