diff --git a/import/module.php b/import/module.php index 4a01d84..3962d61 100644 --- a/import/module.php +++ b/import/module.php @@ -1,10 +1,10 @@ "Импорт (Облегченная версия)", + 'ModuleSysName' => "import", + 'ModuleVersion' => "2.0", + 'ModuleDescription' => "Осуществляет импорт документов из файлов различных типов", + 'ModuleAutor' => "AVE.cms Team", + 'ModuleCopyright' => "© AVE.cms Team 2016", + 'ModuleStatus' => 1, + 'ModuleIsFunction' => 0, + 'ModuleTemplate' => 0, + 'ModuleAdminEdit' => 1, + 'ModuleFunction' => 'import', + 'ModuleTag' => null, + 'ModuleTagLink' => null, + 'ModuleAveTag' => null, + 'ModulePHPTag' => null + ]; } /** - * Администрирование + * Админка */ -function module_import_autoupdate() +if (defined('ACP') && (isset($_REQUEST['moduleaction']))) { - global $AVE_DB; + // класс + require_once(BASE_DIR . '/modules/import/class.import.php'); - $sql=" - SELECT - Id, - import_default_file, - import_last_update - FROM " . PREFIX . "_module_import - WHERE import_monitor_file != 0 - "; + $import = new ModuleImport; - $res = $AVE_DB->Query($sql); - $rows = array(); + // папка с шаблонами + $import->tpl_dir = BASE_DIR . '/modules/import/templates/'; - while ($row = $res->FetchAssocArray()) - { - $rows[] = $row; - - if(file_exists(BASE_DIR . $row["import_default_file"])) - { - if(filemtime(BASE_DIR . $row["import_default_file"]) > $row['import_last_update']) - { - if (!(is_file(BASE_DIR . '/modules/import/class.import.php') && - include_once(BASE_DIR . '/modules/import/class.import.php'))) module_error(); - - $import = new import; - $import -> DoImport($row['Id']); - } - } - } -} - -if (defined('ACP') && $_REQUEST['moduleaction']) -{ - if (! (is_file(BASE_DIR . '/modules/import/class.import.php'))) - module_error(); - - include_once(BASE_DIR . '/modules/import/class.import.php'); - - $import = new import; + // ланги + $AVE_Template->config_load(BASE_DIR . '/modules/import/lang/' . $_SESSION['admin_language'] . '.txt', 'admin'); + $AVE_Template->assign('config_vars', $AVE_Template->get_config_vars()); - $tpl_dir = BASE_DIR . '/modules/import/templates/'; - $lang_file = BASE_DIR . '/modules/import/lang/' . $_SESSION['user_language'] . '.txt'; + $header_list = 'Location:index.php?do=modules&action=modedit&mod=import&moduleaction=1&cp=' . SESSION . '&page=' . $_REQUEST['page']; - $AVE_Template->config_load($lang_file); - - switch ($_REQUEST['moduleaction']) + switch($_REQUEST['moduleaction']) { case '1': - $import->importList($tpl_dir); - break; - - case 'del': - $import->importDelete($_REQUEST['id']); + $import->importsList(); break; case 'edit': - $import->importEdit(isset($_REQUEST['id']) ? $_REQUEST['id'] : null, $tpl_dir); + $import->importEdit((int)$_REQUEST['import_id']); break; - case 'saveedit': - $import->importSave(isset($_REQUEST['id']) ? $_REQUEST['id'] : null); - break; + case 'copy': + $import_id = $import->importCopy((int)$_REQUEST['import_id']); + header('Location:index.php?do=modules&action=modedit&mod=import&moduleaction=edit&import_id=' . $import_id . '&cp=' . SESSION); + exit; - case 'do': - $import->DoImport($_REQUEST['id'], false); - break; + case 'save': + $import_id = $import->importSave((int)$_REQUEST['import_id']); + if (! $_REQUEST['import_id']) + header('Location:index.php?do=modules&action=modedit&mod=import&moduleaction=edit&import_id=' . $import_id . '&cp=' . SESSION); + else + header($header_list); + exit; + + case 'delete': + $import->importDelete((int)$_REQUEST['import_id']); + header($header_list); + exit; case 'tags': - $import->DoImport(isset($_REQUEST['id']) ? $_REQUEST['id'] : null, true); - break; + $import_id = (int)$_REQUEST['import_id']; + $import->importRun($import_id, true); + header('Location:index.php?do=modules&action=modedit&mod=import&moduleaction=edit&import_id=' . $import_id . '&cp=' . SESSION); + exit; + + case 'run': + $import_id = (int)$_REQUEST['import_id']; + $import->importRun($import_id); + header('Location:index.php?do=modules&action=modedit&mod=import&moduleaction=edit&import_id=' . $import_id . '&cp=' . SESSION); + exit; } } -?> \ No newline at end of file