<?
global $MESS;
$PathInstall = str_replace("\\", "/", __FILE__);
$PathInstall = substr($PathInstall, 0, strlen($PathInstall)-strlen("/index.php"));
IncludeModuleLangFile($PathInstall."/install.php");
include($PathInstall."/version.php");

if(class_exists("directoriya_modulcreator")) return;
Class directoriya_modulcreator extends CModule{
	var $MODULE_ID = "directoriya.modulcreator";
	var $MODULE_VERSION;
	var $MODULE_VERSION_DATE;
	var $MODULE_NAME;
	var $MODULE_DESCRIPTION;
	var $PARTNER_NAME;
	var $PARTNER_URI;
	var $MODULE_GROUP_RIGHTS = "Y";
	
	function __construct(){
        $arModuleVersion = array();
		$path = str_replace("\\", "/", __FILE__);
		$path = substr($path, 0, strlen($path) - strlen("/index.php"));
		include($path."/version.php");
		if (is_array($arModuleVersion) && array_key_exists("VERSION", $arModuleVersion)){
			$this->MODULE_VERSION = $arModuleVersion["VERSION"];
			$this->MODULE_VERSION_DATE = $arModuleVersion["VERSION_DATE"];
		}else{
			$this->MODULE_VERSION = MODULCREATOR_VERSION;
			$this->MODULE_VERSION_DATE = MODULCREATOR_VERSION_DATE;
		}
		$this->PARTNER_NAME = GetMessage("MODULCREATOR_PARTNER_NAME");
		$this->PARTNER_URI = "https://d-ya.ru/";
		$this->MODULE_NAME = GetMessage("MODULCREATOR_MODULE_NAME");
		$this->MODULE_DESCRIPTION = GetMessage("MODULCREATOR_DESCRIPTION");
	}
    function InstallDB(){
        return true;
    }
    function UnInstallDB(){
        return true;
    }
	function DoInstall(){
		global $APPLICATION;
		$MODULCREATOR_RIGHT = $APPLICATION->GetGroupRight("directoriya.modulcreator");
		if ($MODULCREATOR_RIGHT == "W"){
            $this->InstallDB();
			$APPLICATION->IncludeAdminFile(GetMessage("MODULCREATOR_INSTALL_TITLE"), $_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/directoriya.modulcreator/install/step1.php");
		}
	}

	function DoUninstall(){
		global $APPLICATION, $step, $DB;
		$MODULCREATOR_RIGHT = $APPLICATION->GetGroupRight("directoriya.modulcreator");
		if ($MODULCREATOR_RIGHT == "W"){
            $this->UnInstallDB();
			$step = intval($step);
			if ($step < 2){
				$APPLICATION->IncludeAdminFile(GetMessage("MODULCREATOR_UNINSTALL_TITLE"), $_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/directoriya.modulcreator/install/unstep1.php");
			}elseif ($step == 2){
				$APPLICATION->IncludeAdminFile(GetMessage("MODULCREATOR_UNINSTALL_TITLE"), $_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/directoriya.modulcreator/install/unstep2.php");
			}
		}
	}

	function GetModuleRightList(){
		$arr = array(
			"reference_id" => array("D", "R", "W"),
			"reference" => array(
				"[D] ".GetMessage("MODULCREATOR_DENIED"),
				"[R] ".GetMessage("MODULCREATOR_VIEW"),
				"[W] ".GetMessage("MODULCREATOR_WRITE"))
			);
		return $arr;
	}
}
?>