1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
* **************************************************************************** |
4
|
|
|
* - A Project by Developers TEAM For Xoops - ( https://xoops.org ) |
5
|
|
|
* **************************************************************************** |
6
|
|
|
* XNEWSLETTER - MODULE FOR XOOPS |
7
|
|
|
* Copyright (c) 2007 - 2012 |
8
|
|
|
* Goffy ( wedega.com ) |
9
|
|
|
* |
10
|
|
|
* You may not change or alter any portion of this comment or credits |
11
|
|
|
* of supporting developers from this source code or any supporting |
12
|
|
|
* source code which is considered copyrighted (c) material of the |
13
|
|
|
* original comment or credit authors. |
14
|
|
|
* |
15
|
|
|
* This program is distributed in the hope that it will be useful, |
16
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
17
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
18
|
|
|
* GNU General Public License for more details. |
19
|
|
|
* **************************************************************************** |
20
|
|
|
*/ |
21
|
|
|
/** |
22
|
|
|
* @copyright Goffy |
23
|
|
|
* @link http://wedega.com Wedega |
24
|
|
|
* @license GPL 2.0 |
25
|
|
|
* @package xnewsletter |
26
|
|
|
* @author Goffy <[email protected]> |
27
|
|
|
* |
28
|
|
|
*/ |
29
|
|
|
// defined("XOOPS_ROOT_PATH") || die("XOOPS root path not defined"); |
30
|
|
|
include_once dirname(__DIR__) . '/include/common.php'; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @return array |
34
|
|
|
*/ |
35
|
|
View Code Duplication |
function xnewsletter_plugin_getinfo_simplenewsletter() { |
36
|
|
|
global $xoopsDB; |
37
|
|
|
|
38
|
|
|
$pluginInfo = []; |
39
|
|
|
$pluginInfo['name'] = 'simplenewsletter'; |
40
|
|
|
$pluginInfo['icon'] = XOOPS_URL . '/modules/simplenewsletter/images/news_subscribe.png'; |
41
|
|
|
$pluginInfo['tables'][0] = $xoopsDB->prefix('simplenewsletter_members'); |
42
|
|
|
$pluginInfo['descr'] = 'Import from simplenewsletter'; |
43
|
|
|
$pluginInfo['hasform'] = 0; |
44
|
|
|
|
45
|
|
|
return $pluginInfo; |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* @param $cat_id |
50
|
|
|
* @param $action_after_read |
51
|
|
|
* @param $limitcheck |
52
|
|
|
* @param $skipcatsubscrexist |
53
|
|
|
* |
54
|
|
|
* @return int |
|
|
|
|
55
|
|
|
*/ |
56
|
|
|
function xnewsletter_plugin_getdata_simplenewsletter($cat_id, $action_after_read, $limitcheck, $skipcatsubscrexist) { |
57
|
|
|
global $xoopsDB; |
58
|
|
|
$helper = \XoopsModules\Xnewsletter\Helper::getInstance(); |
59
|
|
|
|
60
|
|
|
$import_status = (0 == $action_after_read) ? 1 : 0; |
61
|
|
|
$i = 0; |
62
|
|
|
$j = 0; |
63
|
|
|
|
64
|
|
|
$sql = 'SELECT `member_email`, `member_firstname`, `member_lastname`'; |
65
|
|
|
$sql .= " FROM {$xoopsDB->prefix('simplenewsletter_members')}"; |
66
|
|
|
$sql .= " WHERE (`member_email` IS NOT NULL AND NOT(`member_email`=''))"; |
67
|
|
|
if (!$result_users = $xoopsDB->query($sql)) die ('MySQL-Error: ' . $xoopsDB->error()); |
68
|
|
|
while (false !== ($lineArray = $xoopsDB->fetchBoth($result_users))) { |
69
|
|
|
++$i; |
70
|
|
|
$email = substr($lineArray[0], 0, 100); // only allow 1st 100 chars |
71
|
|
|
$email = checkEmail($email); // make sure truncated string is valid email addr |
72
|
|
|
$email = (false === $email) ? '' : $email; |
73
|
|
|
$sex = ''; |
74
|
|
|
$firstname = substr($lineArray[1], 0, 100); // only allow 1st 100 chars |
75
|
|
|
$lastname = substr($lineArray[2], 0, 100); // only allow 1st 100 chars |
76
|
|
|
|
77
|
|
|
$subscr_id = xnewsletter_pluginCheckEmail($email); |
78
|
|
|
$catsubscr_id = xnewsletter_pluginCheckCatSubscr($subscr_id, $cat_id); |
79
|
|
|
|
80
|
|
|
if (((1 == $skipcatsubscrexist) && ($catsubscr_id > 0)) || ('' == $email)) { |
81
|
|
|
//skip existing subscriptions |
82
|
|
|
} else { |
83
|
|
|
// if (((1 != $skipcatsubscrexist) || ($catsubscr_id <= 0)) && ('' != $email)) { |
84
|
|
|
$currcatid = $catsubscr_id > 0 ? 0 : $cat_id; |
85
|
|
|
$importObj = $helper->getHandler('Import')->create(); |
86
|
|
|
$importObj->setVar('import_email', $email); |
87
|
|
|
$importObj->setVar('import_sex', $sex); |
88
|
|
|
$importObj->setVar('import_firstname', $firstname); |
89
|
|
|
$importObj->setVar('import_lastname', $lastname); |
90
|
|
|
$importObj->setVar('import_cat_id', $currcatid); |
91
|
|
|
$importObj->setVar('import_subscr_id', $subscr_id); |
92
|
|
|
$importObj->setVar('import_catsubscr_id', $catsubscr_id); |
93
|
|
|
$importObj->setVar('import_status', $import_status); |
94
|
|
|
if (!$helper->getHandler('Import')->insert($importObj)) { |
95
|
|
|
echo $importObj->getHtmlErrors(); |
96
|
|
|
exit(); |
97
|
|
|
} |
98
|
|
|
++$j; |
99
|
|
|
} |
100
|
|
|
++$i; |
101
|
|
|
if (100000 == $j) break; //maximum number of processing to avoid cache overflow |
102
|
|
|
if ($limitcheck > 0 && $j == $limitcheck) $import_status = 0; |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
return $j; |
106
|
|
|
} |
107
|
|
|
|
This check compares the return type specified in the
@return
annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.