|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* |
|
5
|
|
|
* Module: SmartPartner |
|
6
|
|
|
* Author: The SmartFactory <www.smartfactory.ca> |
|
7
|
|
|
* Licence: GNU |
|
8
|
|
|
*/ |
|
9
|
|
|
|
|
10
|
|
|
include_once __DIR__ . '/admin_header.php'; |
|
11
|
|
|
|
|
12
|
|
|
$op = 'none'; |
|
13
|
|
|
|
|
14
|
|
|
if (isset($_GET['op'])) { |
|
15
|
|
|
$op = $_GET['op']; |
|
16
|
|
|
} |
|
17
|
|
|
if (isset($_POST['op'])) { |
|
18
|
|
|
$op = $_POST['op']; |
|
19
|
|
|
} |
|
20
|
|
|
|
|
21
|
|
|
global $xoopsDB, $xoopsModule; |
|
|
|
|
|
|
22
|
|
|
|
|
23
|
|
|
switch ($op) { |
|
24
|
|
|
|
|
25
|
|
|
case 'importExecute': |
|
26
|
|
|
$importfile = isset($_POST['importfile']) ? $_POST['importfile'] : 'nonselected'; |
|
27
|
|
|
$importfile_path = XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/admin/' . $importfile . '.php'; |
|
28
|
|
|
if (!file_exists($importfile_path)) { |
|
29
|
|
|
$errs[] = sprintf(_AM_SPARTNER_IMPORT_FILE_NOT_FOUND, $importfile_path); |
|
30
|
|
|
$error = true; |
|
31
|
|
|
} else { |
|
32
|
|
|
include_once($importfile_path); |
|
33
|
|
|
} |
|
34
|
|
|
foreach ($msgs as $m) { |
|
35
|
|
|
echo $m . '<br>'; |
|
36
|
|
|
} |
|
37
|
|
|
echo '<br>'; |
|
38
|
|
|
if ($error == true) { |
|
|
|
|
|
|
39
|
|
|
$endMsg = _AM_SPARTNER_IMPORT_ERROR; |
|
40
|
|
|
} else { |
|
41
|
|
|
$endMsg = _AM_SPARTNER_IMPORT_SUCCESS; |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
echo $endMsg; |
|
45
|
|
|
echo '<br><br>'; |
|
46
|
|
|
echo "<a href='import.php'>" . _AM_SPARTNER_IMPORT_BACK . '</a>'; |
|
47
|
|
|
echo '<br><br>'; |
|
48
|
|
|
break; |
|
49
|
|
|
|
|
50
|
|
|
case 'default': |
|
51
|
|
|
default: |
|
|
|
|
|
|
52
|
|
|
|
|
53
|
|
|
$importfile = 'none'; |
|
54
|
|
|
|
|
55
|
|
|
smartpartner_xoops_cp_header(); |
|
56
|
|
|
$indexAdmin = new ModuleAdmin(); |
|
57
|
|
|
echo $indexAdmin->addNavigation(basename(__FILE__)); |
|
58
|
|
|
|
|
59
|
|
|
smartpartner_collapsableBar('bottomtable', 'bottomtableicon', _AM_SPARTNER_IMPORT_TITLE, _AM_SPARTNER_IMPORT_INFO); |
|
60
|
|
|
|
|
61
|
|
|
global $xoopsUser, $xoopsUser, $xoopsConfig, $xoopsDB, $modify, $xoopsModuleConfig, $xoopsModule, $XOOPS_URL, $myts; |
|
|
|
|
|
|
62
|
|
|
|
|
63
|
|
|
include_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; |
|
64
|
|
|
|
|
65
|
|
|
$moduleHandler = xoops_getHandler('module'); |
|
66
|
|
|
if ($moduleHandler->getByDirname('xoopspartners')) { |
|
67
|
|
|
$importfile_select_array['xoopspartners'] = _AM_SPARTNER_IMPORT_XOOPSPARTNERS_110; |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
if (isset($importfile_select_array) && count($importfile_select_array) > 0) { |
|
71
|
|
|
$sform = new XoopsThemeForm(_AM_SPARTNER_IMPORT_SELECTION, 'op', xoops_getenv('PHP_SELF')); |
|
72
|
|
|
$sform->setExtra('enctype="multipart/form-data"'); |
|
73
|
|
|
|
|
74
|
|
|
// Partners to import |
|
75
|
|
|
$importfile_select = new XoopsFormSelect('', 'importfile', $importfile); |
|
76
|
|
|
$importfile_select->addOptionArray($importfile_select_array); |
|
77
|
|
|
$importfile_tray = new XoopsFormElementTray(_AM_SPARTNER_IMPORT_SELECT_FILE, ' '); |
|
78
|
|
|
$importfile_tray->addElement($importfile_select); |
|
79
|
|
|
$importfile_tray->setDescription(_AM_SPARTNER_IMPORT_SELECT_FILE_DSC); |
|
80
|
|
|
$sform->addElement($importfile_tray); |
|
81
|
|
|
|
|
82
|
|
|
// Buttons |
|
83
|
|
|
$button_tray = new XoopsFormElementTray('', ''); |
|
84
|
|
|
$hidden = new XoopsFormHidden('op', 'importExecute'); |
|
85
|
|
|
$button_tray->addElement($hidden); |
|
86
|
|
|
|
|
87
|
|
|
$butt_import = new XoopsFormButton('', '', _AM_SPARTNER_IMPORT, 'submit'); |
|
88
|
|
|
$butt_import->setExtra('onclick="this.form.elements.op.value=\'importExecute\'"'); |
|
89
|
|
|
$button_tray->addElement($butt_import); |
|
90
|
|
|
|
|
91
|
|
|
$butt_cancel = new XoopsFormButton('', '', _AM_SPARTNER_CANCEL, 'button'); |
|
92
|
|
|
$butt_cancel->setExtra('onclick="history.go(-1)"'); |
|
93
|
|
|
$button_tray->addElement($butt_cancel); |
|
94
|
|
|
|
|
95
|
|
|
$sform->addElement($button_tray); |
|
96
|
|
|
$sform->display(); |
|
97
|
|
|
unset($hidden); |
|
98
|
|
|
} else { |
|
99
|
|
|
echo "<span style=\"color: #567; margin: 3px 0 12px 0; font-weight: bold; font-size: small; display: block; \">" . _AM_SPARTNER_IMPORT_NO_MODULE . '</span>'; |
|
100
|
|
|
} |
|
101
|
|
|
|
|
102
|
|
|
// End of collapsable bar |
|
103
|
|
|
smartpartner_close_collapsable('bottomtable', 'bottomtableicon'); |
|
104
|
|
|
|
|
105
|
|
|
break; |
|
106
|
|
|
} |
|
107
|
|
|
|
|
108
|
|
|
//smart_modFooter(); |
|
|
|
|
|
|
109
|
|
|
//xoops_cp_footer(); |
|
110
|
|
|
include_once __DIR__ . '/admin_footer.php'; |
|
111
|
|
|
|
Instead of relying on
globalstate, we recommend one of these alternatives:1. Pass all data via parameters
2. Create a class that maintains your state