1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* |
5
|
|
|
* Module: SmartPartner |
6
|
|
|
* Author: Marius Scurtescu <[email protected]> |
7
|
|
|
* Licence: GNU |
8
|
|
|
* |
9
|
|
|
* Import script from XoopsPartners to SmartPartner. |
10
|
|
|
* |
11
|
|
|
* It was tested with XoosPartners version 1.1 and SmartPartner version 1.0 beta |
12
|
|
|
* |
13
|
|
|
*/ |
14
|
|
|
|
15
|
|
|
include_once __DIR__ . '/admin_header.php'; |
16
|
|
|
|
17
|
|
|
$importFromModuleName = 'XoopsPartners'; |
18
|
|
|
$scriptname = 'xoopspartners.php'; |
19
|
|
|
|
20
|
|
|
$op = 'start'; |
21
|
|
|
|
22
|
|
|
if (isset($_POST['op']) && ($_POST['op'] === 'go')) { |
23
|
|
|
$op = $_POST['op']; |
24
|
|
|
} |
25
|
|
|
|
26
|
|
|
if ($op === 'start') { |
27
|
|
|
smartpartner_xoops_cp_header(); |
28
|
|
|
include_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; |
29
|
|
|
|
30
|
|
|
$result = $xoopsDB->query('select count(*) from ' . $xoopsDB->prefix('partners')); |
31
|
|
|
list($totalpartners) = $xoopsDB->fetchRow($result); |
32
|
|
|
smartpartner_collapsableBar('bottomtable', 'bottomtableicon', sprintf(_AM_SPARTNER_IMPORT_FROM, $importFromModuleName), |
33
|
|
|
sprintf(_AM_SPARTNER_IMPORT_MODULE_FOUND, $importFromModuleName, $totalpartners)); |
34
|
|
|
|
35
|
|
|
$form = new XoopsThemeForm(_AM_SPARTNER_IMPORT_SETTINGS, 'import_form', XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/admin/' . $scriptname); |
36
|
|
|
|
37
|
|
|
// Auto-Approve |
38
|
|
|
$form->addElement(new XoopsFormLabel(_AM_SPARTNER_SMARTPARTNER_IMPORT_SETTINGS, _AM_SPARTNER_SMARTPARTNER_IMPORT_SETTINGS_VALUE)); |
39
|
|
|
|
40
|
|
|
$form->addElement(new XoopsFormHidden('op', 'go')); |
41
|
|
|
$form->addElement(new XoopsFormButton('', 'import', _AM_SPARTNER_IMPORT, 'submit')); |
42
|
|
|
$form->display(); |
43
|
|
|
|
44
|
|
|
//exit (); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
if ($op === 'go') { |
48
|
|
|
include_once __DIR__ . '/admin_header.php'; |
49
|
|
|
|
50
|
|
|
smartpartner_xoops_cp_header(); |
51
|
|
|
smartpartner_collapsableBar('bottomtable', 'bottomtableicon', sprintf(_AM_SPARTNER_IMPORT_FROM, $importFromModuleName), _AM_SPARTNER_IMPORT_RESULT); |
52
|
|
|
$cnt_imported_partner = 0; |
53
|
|
|
|
54
|
|
|
$smartPartnerPartnerHandler = smartpartner_gethandler('partner'); |
55
|
|
|
|
56
|
|
|
$resultPartners = $xoopsDB->query('select * from ' . $xoopsDB->prefix('partners') . ' '); |
57
|
|
|
while ($arrPartners = $xoopsDB->fetchArray($resultPartners)) { |
58
|
|
|
extract($arrPartners, EXTR_PREFIX_ALL, 'xpartner'); |
59
|
|
|
|
60
|
|
|
// insert partner into SmartPartner |
61
|
|
|
$partnerObj = $smartPartnerPartnerHandler->create(); |
62
|
|
|
|
63
|
|
|
if ($xpartner_status == 0) { |
64
|
|
|
$xpartner_status = _SPARTNER_STATUS_INACTIVE; |
65
|
|
|
} elseif ($xpartner_status == 1) { |
66
|
|
|
$xpartner_status = _SPARTNER_STATUS_ACTIVE; |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
$partnerObj->setVar('weight', $xpartner_weight); |
70
|
|
|
$partnerObj->setVar('hits', $xpartner_hits); |
71
|
|
|
$partnerObj->setVar('url', $xpartner_url); |
72
|
|
|
$partnerObj->setVar('image_url', $xpartner_image); |
73
|
|
|
$partnerObj->setVar('title', $xpartner_title); |
74
|
|
|
$partnerObj->setVar('summary', $xpartner_description); |
75
|
|
|
$partnerObj->setVar('status', $xpartner_status); |
76
|
|
|
|
77
|
|
|
if (!$partnerObj->store(false)) { |
78
|
|
|
echo sprintf(' ' . _AM_SPARTNER_IMPORT_PARTNER_ERROR, $xpartner_title) . '<br>'; |
79
|
|
|
continue; |
80
|
|
|
} else { |
81
|
|
|
echo ' ' . sprintf(_AM_SPARTNER_IMPORTED_PARTNER, $partnerObj->title()) . '<br>'; |
82
|
|
|
++$cnt_imported_partner; |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
echo '<br>'; |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
echo 'Done.<br>'; |
89
|
|
|
echo sprintf(_AM_SPARTNER_IMPORTED_PARTNERS, $cnt_imported_partner) . '<br>'; |
90
|
|
|
|
91
|
|
|
//exit (); |
92
|
|
|
} |
93
|
|
|
echo '</div>'; |
94
|
|
|
//smart_modFooter(); |
|
|
|
|
95
|
|
|
//xoops_cp_footer(); |
96
|
|
|
include_once __DIR__ . '/admin_footer.php'; |
97
|
|
|
exit(); |
98
|
|
|
|
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.