XoopsModules25x /
oledrion
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | /* |
||
| 3 | You may not change or alter any portion of this comment or credits |
||
| 4 | of supporting developers from this source code or any supporting source code |
||
| 5 | which is considered copyrighted (c) material of the original comment or credit authors. |
||
| 6 | |||
| 7 | This program is distributed in the hope that it will be useful, |
||
| 8 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
| 9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
||
| 10 | */ |
||
| 11 | |||
| 12 | /** |
||
| 13 | * oledrion |
||
| 14 | * |
||
| 15 | * @copyright {@link https://xoops.org/ XOOPS Project} |
||
| 16 | * @license {@link http://www.fsf.org/copyleft/gpl.html GNU public license} |
||
| 17 | * @author Hervé Thouzard (http://www.herve-thouzard.com/) |
||
| 18 | */ |
||
| 19 | |||
| 20 | /** |
||
| 21 | * Création du contenu d'une newsletter (dans l'administration) |
||
| 22 | */ |
||
| 23 | if (!defined('OLEDRION_ADMIN')) { |
||
| 24 | exit(); |
||
| 25 | } |
||
| 26 | switch ($action) { |
||
| 27 | // **************************************************************************************************************** |
||
| 28 | case 'default': // Création de la newsletter |
||
| 29 | // **************************************************************************************************************** |
||
| 30 | xoops_cp_header(); |
||
| 31 | $adminObject = \Xmf\Module\Admin::getInstance(); |
||
| 32 | $adminObject->displayNavigation('index.php?op=newsletter'); |
||
| 33 | // OledrionUtility::htitle(_MI_OLEDRION_ADMENU7, 4); |
||
|
0 ignored issues
–
show
|
|||
| 34 | |||
| 35 | require_once OLEDRION_PATH . 'class/tree.php'; |
||
| 36 | $sform = new XoopsThemeForm(_MI_OLEDRION_ADMENU7, 'frmnewsletter', $baseurl); |
||
| 37 | $datesTray = new XoopsFormElementTray(_AM_OLEDRION_NEWSLETTER_BETWEEN); |
||
| 38 | $minDate = $maxDate = 0; |
||
| 39 | $h_oledrion_products->getMinMaxPublishedDate($minDate, $maxDate); |
||
| 40 | $date1 = new XoopsFormTextDateSelect('', 'date1', 15, $minDate); |
||
| 41 | $date2 = new XoopsFormTextDateSelect(_AM_OLEDRION_EXPORT_AND, 'date2', 15, $maxDate); |
||
| 42 | $datesTray->addElement($date1); |
||
| 43 | $datesTray->addElement($date2); |
||
| 44 | $sform->addElement($datesTray); |
||
| 45 | |||
| 46 | $categories = $h_oledrion_cat->getAllCategories(new Oledrion_parameters()); |
||
| 47 | $mytree = new Oledrion_XoopsObjectTree($categories, 'cat_cid', 'cat_pid'); |
||
| 48 | |||
| 49 | if (OledrionUtility::checkVerXoops($module, '2.5.9')) { |
||
|
0 ignored issues
–
show
The method
checkVerXoops() does not seem to exist on object<OledrionUtility>.
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. Loading history...
|
|||
| 50 | $htmlSelect = $mytree->makeSelectElement('cat_cid', 'cat_title', '-', 0, true, 0, _AM_OLEDRION_ALL, _AM_OLEDRION_IN_CATEGORY); |
||
| 51 | $form->addElement($htmlSelect); |
||
| 52 | } else { |
||
| 53 | $htmlSelect = $mytree->makeSelBox('cat_cid', 'cat_title', '-', 0, _AM_OLEDRION_ALL); |
||
|
0 ignored issues
–
show
The method
Oledrion_XoopsObjectTree::makeSelBox() has been deprecated with message: since 2.5.9, please use makeSelectElement()
This method has been deprecated. The supplier of the class has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead. Loading history...
|
|||
| 54 | $sform->addElement(new XoopsFormLabel(_AM_OLEDRION_IN_CATEGORY, $htmlSelect), true); |
||
| 55 | } |
||
| 56 | |||
| 57 | $sform->addElement(new XoopsFormHidden('op', 'newsletter'), false); |
||
| 58 | $sform->addElement(new XoopsFormHidden('action', 'launch'), false); |
||
| 59 | $sform->addElement(new XoopsFormRadioYN(_AM_OLEDRION_REMOVE_BR, 'removebr', 1), false); |
||
| 60 | $sform->addElement(new XoopsFormRadioYN(_AM_OLEDRION_NEWSLETTER_HTML_TAGS, 'removehtml', 0), false); |
||
| 61 | $sform->addElement(new XoopsFormTextArea(_AM_OLEDRION_NEWSLETTER_HEADER, 'header', '', 4, 70), false); |
||
| 62 | $sform->addElement(new XoopsFormTextArea(_AM_OLEDRION_NEWSLETTER_FOOTER, 'footer', '', 4, 70), false); |
||
| 63 | $button_tray = new XoopsFormElementTray('', ''); |
||
| 64 | $submit_btn = new XoopsFormButton('', 'post', _SUBMIT, 'submit'); |
||
| 65 | $button_tray->addElement($submit_btn); |
||
| 66 | $sform->addElement($button_tray); |
||
| 67 | $sform =& OledrionUtility::formMarkRequiredFields($sform); |
||
| 68 | $sform->display(); |
||
| 69 | require_once OLEDRION_ADMIN_PATH . 'admin_footer.php'; |
||
| 70 | break; |
||
| 71 | |||
| 72 | // **************************************************************************************************************** |
||
| 73 | case 'launch': // Création effective de la newsletter |
||
| 74 | // **************************************************************************************************************** |
||
| 75 | xoops_cp_header(); |
||
| 76 | $adminObject = \Xmf\Module\Admin::getInstance(); |
||
| 77 | $adminObject->displayNavigation('index.php?op=newsletter'); |
||
| 78 | // OledrionUtility::htitle(_MI_OLEDRION_ADMENU7, 4); |
||
|
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
55% of this comment could be valid code. Did you maybe forget this after debugging?
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. Loading history...
|
|||
| 79 | |||
| 80 | $newsletterTemplate = ''; |
||
| 81 | View Code Duplication | if (file_exists(OLEDRION_PATH . 'language/' . $xoopsConfig['language'] . '/newsletter.php')) { |
|
| 82 | require_once OLEDRION_PATH . 'language/' . $xoopsConfig['language'] . '/newsletter.php'; |
||
| 83 | } else { |
||
| 84 | require_once OLEDRION_PATH . 'language/english/newsletter.php'; |
||
| 85 | } |
||
| 86 | echo '<br>'; |
||
| 87 | $removeBr = $removeHtml = false; |
||
| 88 | $removeBr = isset($_POST['removebr']) ? (int)$_POST['removebr'] : 0; |
||
| 89 | $removeHtml = isset($_POST['removehtml']) ? (int)$_POST['removehtml'] : 0; |
||
| 90 | $header = isset($_POST['header']) ? $_POST['header'] : ''; |
||
| 91 | $footer = isset($_POST['footer']) ? $_POST['footer'] : ''; |
||
| 92 | $date1 = strtotime($_POST['date1']); |
||
| 93 | $date2 = strtotime($_POST['date2']); |
||
| 94 | $cat_id = (int)$_POST['cat_cid']; |
||
| 95 | $products = $categories = array(); |
||
| 96 | $products = $h_oledrion_products->getProductsForNewsletter(new Oledrion_parameters(array( |
||
| 97 | 'startingDate' => $date1, |
||
| 98 | 'endingDate' => $date2, |
||
| 99 | 'category' => $cat_id |
||
| 100 | ))); |
||
| 101 | $newsfile = OLEDRION_NEWSLETTER_PATH; |
||
| 102 | $categories = $h_oledrion_cat->getAllCategories(new Oledrion_parameters(array( |
||
| 103 | 'start' => 0, |
||
| 104 | 'limit' => 0, |
||
| 105 | 'sort' => 'cat_title', |
||
| 106 | 'order' => 'ASC', |
||
| 107 | 'idaskey' => true |
||
| 108 | ))); |
||
| 109 | $vats = $h_oledrion_vat->getAllVats(new Oledrion_parameters()); |
||
| 110 | |||
| 111 | $fp = fopen($newsfile, 'w'); |
||
| 112 | if (!$fp) { |
||
| 113 | OledrionUtility::redirect(_AM_OLEDRION_ERROR_7, $baseurl . '?op=newsletter', 5); |
||
| 114 | } |
||
| 115 | if (xoops_trim($header) != '') { |
||
| 116 | fwrite($fp, $header); |
||
| 117 | } |
||
| 118 | foreach ($products as $item) { |
||
| 119 | $content = $newsletterTemplate; |
||
| 120 | $tblTmp = $tblTmp2 = array(); |
||
| 121 | $criteria = new CriteriaCompo(); |
||
| 122 | $criteria->add(new Criteria('pm_product_id', $item->getVar('product_id'), '=')); |
||
| 123 | $tblTmp = $h_oledrion_productsmanu->getObjects($criteria); |
||
| 124 | foreach ($tblTmp as $productManufacturer) { |
||
| 125 | $tblTmp2[] = $productManufacturer->getVar('pm_manu_id'); |
||
| 126 | } |
||
| 127 | $manufacturers = $h_oledrion_manufacturer->getObjects(new Criteria('manu_id', '(' . implode(',', $tblTmp2) . ')', 'IN'), true); |
||
| 128 | $tblTmp = array(); |
||
| 129 | foreach ($manufacturers as $manufacturer) { |
||
| 130 | $tblTmp[] = $manufacturer->getVar('manu_commercialname') . ' ' . $manufacturer->getVar('manu_name'); |
||
| 131 | } |
||
| 132 | |||
| 133 | $search = array( |
||
| 134 | '%title%', |
||
| 135 | '%category%', |
||
| 136 | '%author%', |
||
| 137 | '%published%', |
||
| 138 | '%price%', |
||
| 139 | '%money%', |
||
| 140 | '%hometext%', |
||
| 141 | '%fulltext%', |
||
| 142 | '%discountprice%', |
||
| 143 | '%link%', |
||
| 144 | '%product_sku%', |
||
| 145 | '%product_extraid%', |
||
| 146 | '%product_width%', |
||
| 147 | '%product_date%', |
||
| 148 | '%product_shipping_price%', |
||
| 149 | '%product_stock%', |
||
| 150 | '%product_unitmeasure1%', |
||
| 151 | '%product_weight%', |
||
| 152 | '%product_unitmeasure2%', |
||
| 153 | '%product_download_url%', |
||
| 154 | '%product_length%' |
||
| 155 | ); |
||
| 156 | $replace = array( |
||
| 157 | $item->getVar('product_title'), |
||
| 158 | $categories[$item->getVar('product_cid')]->getVar('cat_title'), |
||
| 159 | implode(', ', $tblTmp), |
||
| 160 | formatTimestamp($item->getVar('product_submitted'), 's'), |
||
| 161 | OledrionUtility::getTTC($item->getVar('product_price'), $vats[$item->getVar('product_vat_id')]->getVar('vat_rate')), |
||
| 162 | OledrionUtility::getModuleOption('money_full'), |
||
| 163 | $item->getVar('product_summary'), |
||
| 164 | $item->getVar('product_description'), |
||
| 165 | OledrionUtility::getTTC($item->getVar('product_discount_price'), $vats[$item->getVar('product_vat_id')]->getVar('vat_rate')), |
||
| 166 | $item->getLink(), |
||
| 167 | $item->getVar('product_sku'), |
||
| 168 | $item->getVar('product_extraid'), |
||
| 169 | $item->getVar('product_width'), |
||
| 170 | $item->getVar('product_date'), |
||
| 171 | $item->getVar('product_shipping_price'), |
||
| 172 | $item->getVar('product_stock'), |
||
| 173 | $item->getVar('product_unitmeasure1'), |
||
| 174 | $item->getVar('product_weight'), |
||
| 175 | $item->getVar('product_unitmeasure2'), |
||
| 176 | $item->getVar('product_download_url'), |
||
| 177 | $item->getVar('product_length') |
||
| 178 | ); |
||
| 179 | $content = str_replace($search, $replace, $content); |
||
| 180 | if ($removeBr) { |
||
| 181 | $content = str_replace('<br>', "\r\n", $content); |
||
| 182 | } |
||
| 183 | if ($removeHtml) { |
||
| 184 | $content = strip_tags($content); |
||
| 185 | } |
||
| 186 | fwrite($fp, $content); |
||
| 187 | } |
||
| 188 | if (xoops_trim($footer) != '') { |
||
| 189 | fwrite($fp, $footer); |
||
| 190 | } |
||
| 191 | fclose($fp); |
||
| 192 | $newsfile = OLEDRION_NEWSLETTER_URL; |
||
| 193 | echo "<a href='$newsfile' target='_blank'>" . _AM_OLEDRION_NEWSLETTER_READY . '</a>'; |
||
| 194 | require_once OLEDRION_ADMIN_PATH . 'admin_footer.php'; |
||
| 195 | break; |
||
| 196 | } |
||
| 197 |
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.