These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | /** |
||
3 | * **************************************************************************** |
||
4 | * - A Project by Developers TEAM For Xoops - ( http://www.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 | * @copyright Goffy ( wedega.com ) |
||
21 | * @license GPL 2.0 |
||
22 | * @package xnewsletter |
||
23 | * @author Goffy ( [email protected] ) |
||
24 | * |
||
25 | * Version : $Id $ |
||
26 | * **************************************************************************** |
||
27 | */ |
||
28 | |||
29 | $currentFile = basename(__FILE__); |
||
30 | include_once __DIR__ . "/header.php"; |
||
31 | |||
32 | $op = XoopsRequest::getString('op', 'welcome'); |
||
33 | |||
34 | switch ($op) { |
||
35 | case "welcome" : |
||
0 ignored issues
–
show
|
|||
36 | default : |
||
0 ignored issues
–
show
There must be no space before the colon in a DEFAULT statement
As per the PSR-2 coding standard, there must not be a space in front of the colon in the default statement. switch ($expr) {
default : //wrong
doSomething();
break;
}
switch ($expr) {
default: //right
doSomething();
break;
}
To learn more about the PSR-2 coding standard, please refer to the PHP-Fig. ![]() |
|||
37 | $xoopsOption['template_main'] = "{$xnewsletter->getModule()->dirname()}_index.tpl"; |
||
38 | include XOOPS_ROOT_PATH . "/header.php"; |
||
39 | |||
40 | $xoTheme->addStylesheet(XNEWSLETTER_URL . '/assets/css/module.css'); |
||
41 | $xoTheme->addMeta('meta', 'keywords', $xnewsletter->getConfig('keywords')); // keywords only for index page |
||
42 | $xoTheme->addMeta('meta', 'description', strip_tags(_MA_XNEWSLETTER_DESC)); // description |
||
43 | |||
44 | // Breadcrumb |
||
45 | $breadcrumb = new XnewsletterBreadcrumb(); |
||
46 | $breadcrumb->addLink($xnewsletter->getModule()->getVar('name'), XNEWSLETTER_URL); |
||
47 | $xoopsTpl->assign('xnewsletter_breadcrumb', $breadcrumb->render()); |
||
48 | |||
49 | $xoopsTpl->assign('welcome_message', $xnewsletter->getConfig('welcome_message')); |
||
50 | $xoopsTpl->assign('xnewsletter_content', _MA_XNEWSLETTER_WELCOME); // this definition is not removed for backward compatibility issues |
||
51 | break; |
||
52 | |||
53 | case "show_preview" : |
||
0 ignored issues
–
show
There must be no space before the colon in a CASE statement
As per the PSR-2 coding standard, there must not be a space in front of the colon in case statements. switch ($selector) {
case "A": //right
doSomething();
break;
case "B" : //wrong
doSomethingElse();
break;
}
To learn more about the PSR-2 coding standard, please refer to the PHP-Fig. ![]() |
|||
54 | case "show_letter_preview" : |
||
0 ignored issues
–
show
There must be no space before the colon in a CASE statement
As per the PSR-2 coding standard, there must not be a space in front of the colon in case statements. switch ($selector) {
case "A": //right
doSomething();
break;
case "B" : //wrong
doSomethingElse();
break;
}
To learn more about the PSR-2 coding standard, please refer to the PHP-Fig. ![]() |
|||
55 | $xoopsOption['template_main'] = "{$xnewsletter->getModule()->dirname()}_letter_preview.tpl"; |
||
56 | include XOOPS_ROOT_PATH . "/header.php"; |
||
57 | |||
58 | $xoTheme->addStylesheet(XNEWSLETTER_URL . '/assets/css/module.css'); |
||
59 | $xoTheme->addMeta('meta', 'keywords', $xnewsletter->getConfig('keywords')); // keywords only for index page |
||
60 | $xoTheme->addMeta('meta', 'description', strip_tags(_MA_XNEWSLETTER_DESC)); // description |
||
61 | |||
62 | // Breadcrumb |
||
63 | $breadcrumb = new XnewsletterBreadcrumb(); |
||
64 | $breadcrumb->addLink($xnewsletter->getModule()->getVar('name'), XNEWSLETTER_URL); |
||
65 | $xoopsTpl->assign('xnewsletter_breadcrumb', $breadcrumb->render()); |
||
66 | |||
67 | $xoopsTpl->assign('welcome_message', $xnewsletter->getConfig('welcome_message')); |
||
68 | |||
69 | // get letter_id |
||
70 | $letter_id = XoopsRequest::getInt('letter_id', 0); |
||
71 | // get letter object |
||
72 | $letterObj = $xnewsletter->getHandler('letter')->get($letter_id); |
||
73 | // subscr data |
||
74 | $xoopsTpl->assign('sex', _AM_XNEWSLETTER_SUBSCR_SEX_PREVIEW); |
||
75 | $xoopsTpl->assign('salutation', _AM_XNEWSLETTER_SUBSCR_SEX_PREVIEW); // new from v1.3 |
||
76 | $xoopsTpl->assign('firstname', _AM_XNEWSLETTER_SUBSCR_FIRSTNAME_PREVIEW); |
||
77 | $xoopsTpl->assign('lastname', _AM_XNEWSLETTER_SUBSCR_LASTNAME_PREVIEW); |
||
78 | $xoopsTpl->assign('subscr_email', _AM_XNEWSLETTER_SUBSCR_EMAIL_PREVIEW); |
||
79 | $xoopsTpl->assign('email', _AM_XNEWSLETTER_SUBSCR_EMAIL_PREVIEW); // new from v1.3 |
||
80 | // letter data |
||
81 | $xoopsTpl->assign('title', $letterObj->getVar('letter_title', 'n')); // new from v1.3 |
||
82 | $xoopsTpl->assign('content', $letterObj->getVar('letter_content', 'n')); |
||
83 | // extra data |
||
84 | $xoopsTpl->assign('date', time()); // new from v1.3 |
||
85 | $xoopsTpl->assign('unsubscribe_url', XOOPS_URL . '/modules/xnewsletter/'); |
||
86 | $xoopsTpl->assign('catsubscr_id', '0'); |
||
87 | |||
88 | $letter_array = $letterObj->toArray(); |
||
89 | |||
90 | preg_match('/db:([0-9]*)/', $letterObj->getVar("letter_template"), $matches); |
||
91 | View Code Duplication | if(isset($matches[1]) && ($templateObj = $xnewsletter->getHandler('template')->get((int)$matches[1]))) { |
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
92 | // get template from database |
||
93 | $htmlBody = $xoopsTpl->fetchFromData($templateObj->getVar('template_content', "n")); |
||
94 | } else { |
||
95 | // get template from filesystem |
||
96 | $template_path = XOOPS_ROOT_PATH . '/modules/xnewsletter/language/' . $GLOBALS['xoopsConfig']['language'] . '/templates/'; |
||
97 | if (!is_dir($template_path)) $template_path = XOOPS_ROOT_PATH . '/modules/xnewsletter/language/english/templates/'; |
||
98 | $template = $template_path . $letterObj->getVar("letter_template") . ".tpl"; |
||
99 | $htmlBody = $xoopsTpl->fetch($template); |
||
100 | } |
||
101 | $textBody = xnewsletter_html2text($htmlBody); // new from v1.3 |
||
102 | |||
103 | $letter_array['letter_content_templated'] = $htmlBody; |
||
104 | $letter_array['letter_content_templated_html'] = $htmlBody; |
||
105 | $letter_array['letter_content_templated_text'] = $textBody; // new from v1.3 |
||
106 | $letter_array['letter_created_timestamp'] = formatTimestamp($letterObj->getVar('letter_created'), $xnewsletter->getConfig('dateformat')); |
||
107 | $letter_array['letter_submitter_name'] = XoopsUserUtility::getUnameFromId($letterObj->getVar('letter_submitter')); |
||
108 | $xoopsTpl->assign('letter', $letter_array); |
||
109 | break; |
||
110 | |||
111 | case "list_letter" : |
||
0 ignored issues
–
show
There must be no space before the colon in a CASE statement
As per the PSR-2 coding standard, there must not be a space in front of the colon in case statements. switch ($selector) {
case "A": //right
doSomething();
break;
case "B" : //wrong
doSomethingElse();
break;
}
To learn more about the PSR-2 coding standard, please refer to the PHP-Fig. ![]() |
|||
112 | exit("IN_PROGRESS: use op=list_letters instead of op=list_letter"); |
||
113 | break; |
||
114 | case "list_letters" : |
||
0 ignored issues
–
show
There must be no space before the colon in a CASE statement
As per the PSR-2 coding standard, there must not be a space in front of the colon in case statements. switch ($selector) {
case "A": //right
doSomething();
break;
case "B" : //wrong
doSomethingElse();
break;
}
To learn more about the PSR-2 coding standard, please refer to the PHP-Fig. ![]() |
|||
115 | $xoopsOption['template_main'] = "{$xnewsletter->getModule()->dirname()}_index_list_letters.tpl"; |
||
116 | include XOOPS_ROOT_PATH . "/header.php"; |
||
117 | |||
118 | $xoTheme->addStylesheet(XNEWSLETTER_URL . '/assets/css/module.css'); |
||
119 | $xoTheme->addMeta('meta', 'keywords', $xnewsletter->getConfig('keywords')); // keywords only for index page |
||
120 | $xoTheme->addMeta('meta', 'description', strip_tags(_MA_XNEWSLETTER_DESC)); // description |
||
121 | |||
122 | // Breadcrumb |
||
123 | $breadcrumb = new XnewsletterBreadcrumb(); |
||
124 | $breadcrumb->addLink($xnewsletter->getModule()->getVar('name'), XNEWSLETTER_URL); |
||
125 | $breadcrumb->addLink(_MD_XNEWSLETTER_LIST, ''); |
||
126 | $xoopsTpl->assign('xnewsletter_breadcrumb', $breadcrumb->render()); |
||
127 | |||
128 | $xoopsTpl->assign('welcome_message', $xnewsletter->getConfig('welcome_message')); |
||
129 | |||
130 | // get letters array |
||
131 | $criteria = new CriteriaCompo(); |
||
132 | $criteria->setSort("letter_id"); |
||
133 | $criteria->setOrder("DESC"); |
||
134 | $letterObjs = $xnewsletter->getHandler('letter')->getAll($criteria); |
||
135 | |||
136 | if ($xnewsletter->getHandler('letter')->getCount() > 0) { |
||
137 | // get newsletters available for current user |
||
138 | $gperm_handler = xoops_gethandler('groupperm'); |
||
139 | $groups = is_object($xoopsUser) ? $xoopsUser->getGroups() : array(0 => XOOPS_GROUP_ANONYMOUS); |
||
140 | |||
141 | $letters_array = array(); |
||
142 | foreach ($letterObjs as $letterObj) { |
||
143 | $letter_array = $letterObj->toArray(); |
||
144 | $letter_array['letter_content'] = $myts->undoHtmlSpecialChars($letterObj->getVar('letter_content')); //needed when using GUI editors (e.g. tinymce) |
||
145 | $letter_array['letter_created_timestamp'] = formatTimestamp($letterObj->getVar('letter_created'), $xnewsletter->getConfig('dateformat')); |
||
146 | $letter_array['letter_submitter_name'] = XoopsUserUtility::getUnameFromId($letterObj->getVar('letter_submitter')); |
||
147 | $catsAvailableCount = 0; |
||
148 | $cats_string = ''; |
||
149 | $cat_ids = explode('|' , $letterObj->getVar('letter_cats')); |
||
150 | View Code Duplication | foreach ($cat_ids as $cat_id) { |
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
151 | $catObj = $xnewsletter->getHandler('cat')->get($cat_id); |
||
152 | if ($gperm_handler->checkRight('newsletter_read_cat', $catObj->getVar('cat_id'), $groups, $xnewsletter->getModule()->mid())) { |
||
153 | ++$catsAvailableCount; |
||
154 | unset($letter_array['letter_cats']); |
||
155 | $letter_array['letter_cats'][] = $catObj->toArray(); |
||
156 | } |
||
157 | unset($catObj); |
||
158 | } |
||
159 | if ($catsAvailableCount > 0) { |
||
160 | $letters_array[] = $letter_array; |
||
161 | } |
||
162 | } |
||
163 | if (count($letters_array) == 0) { |
||
164 | redirect_header("index.php", 3, _MA_XNEWSLETTER_LETTER_NONEAVAIL); |
||
165 | } |
||
166 | $xoopsTpl->assign('letters', $letters_array); |
||
167 | } else { |
||
168 | redirect_header("index.php", 3, _MA_XNEWSLETTER_LETTER_NONEAVAIL); |
||
169 | } |
||
170 | break; |
||
171 | } |
||
172 | |||
173 | include __DIR__ . '/footer.php'; |
||
174 |
As per the PSR-2 coding standard, there must not be a space in front of the colon in case statements.
To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.