<?php
include_once XOOPS_ROOT_PATH."/modules/neothemesadmin/function.php";
function xoops_module_install_neothemesadmin(&$module) {
	global  $xoopsDB;
	include_once XOOPS_ROOT_PATH . '/modules/neothemesadmin/class/themesset/defaultltheme.php';
	//建立neothemesadmin資料夾
	fileadminfunction($fileurl="",$type="4",$fileex="",$from=XOOPS_ROOT_PATH."/uploads/neothemesadmin",$fileurlnew="");
	$xoops_theme = $installtheme;
	
	$sql = "update " . $xoopsDB->prefix("config") . " set `conf_value`='{$xoops_theme}' where  conf_name = 'theme_set' ";
	$xoopsDB->queryF($sql);
	
	$sql = "update " . $xoopsDB->prefix("config") . " set `conf_value`='$theme_set_allowed' where  conf_name = 'theme_set_allowed' ";
	$xoopsDB->queryF($sql);

	//判斷tadtools有沒有安裝
	$module_handler = &xoops_gethandler('module');
	$tadtools= &$module_handler->getByDirname('tadtools');
	//empty($tadtools) ? $ifinstallation=true : $ifinstallation=false; // get TRUE
	if(!empty($tadtools)) {
		$sql = "select tt_theme from " . $xoopsDB->prefix('tadtools_setup')   . " where `tt_theme` = '{$xoops_theme}'";
		$result = $xoopsDB -> query($sql) or die($sql);
		$tt_themeNY = $xoopsDB -> getRowsNum($result);
		if(empty($tt_themeNY)) {
		$sql="insert into " . $xoopsDB->prefix('tadtools_setup') . "
        (`tt_theme`  ,  `tt_use_bootstrap` ,  `tt_bootstrap_color` ,  `tt_theme_kind`) values ('{$xoops_theme}'  ,  '1'  ,  'bootstrap3' ,  'bootstrap3')";
		$xoopsDB->query($sql);
		}
	}
	//模組加入防護模組網路爬蟲例外
	protectorexception($modulesid="neothemesadmin");
	go_update1();
	return true;
}
function  go_update1() {
	//舊位置
	$oldvar="".XOOPS_ROOT_PATH."/modules/neillibrary/patch/onInstall/system/register.php";
	//新位置
	$newvar="".XOOPS_ROOT_PATH."/register.php";
	//複製
	copy($oldvar , $newvar);
	//舊位置
	$oldvar="".XOOPS_ROOT_PATH."/modules/neillibrary/patch/onInstall/profile/register.php";
	//新位置
	$newvar="".XOOPS_ROOT_PATH."/modules/profile/register.php";
	//複製
	copy($oldvar , $newvar);
	//舊位置
	$oldvar="".XOOPS_ROOT_PATH."/modules/neillibrary/patch/onInstall/system/robots.txt";
	//新位置
	$newvar="".XOOPS_ROOT_PATH."/robots.txt";
	//複製
	copy($oldvar , $newvar);
	if(file_exists(XOOPS_ROOT_PATH."/modules/system/themes/tad/tad.php")) {
	//舊位置
	$oldvar="".XOOPS_ROOT_PATH."/modules/neillibrary/patch/onInstall/system/tad/tad.php";
	//新位置
	$newvar="".XOOPS_ROOT_PATH."/modules/system/themes/tad/tad.php";
	//複製
	copy($oldvar , $newvar);
	}
	
	//舊位置
	$oldvar="".XOOPS_ROOT_PATH."/modules/neillibrary/patch/onInstall/kernel/block.php";
	//新位置
	$newvar="".XOOPS_ROOT_PATH."/kernel/block.php";
	//複製
	copy($oldvar , $newvar);
	
}