XoopsModules25x/xoopspoll

View on GitHub
extras/newbb_5x/irmtfan/polls.php

Summary

Maintainability
F
3 days
Test Coverage

File polls.php has 495 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php declare(strict_types=1);
/*
 * Newbb module
 *
 * You may not change or alter any portion of this comment or credits
Severity: Minor
Found in extras/newbb_5x/irmtfan/polls.php - About 7 hrs to fix

    Identical blocks of code found in 2 locations. Consider refactoring.
    Open

                foreach ($optionIdArray as $key => $oId) {
                    if (!empty($oId) && ($option_obj = $xpOptHandler->get($oId))) {
                        // existing option object so need to update it
                        $optionTextArray[$key] = trim($optionTextArray[$key]);
                        if ('' === $optionTextArray[$key]) {
    Severity: Major
    Found in extras/newbb_5x/irmtfan/polls.php and 1 other location - About 1 day to fix
    extras/newbb_5x/trunk_5_00/polls.php on lines 177..210

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 285.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 3 locations. Consider refactoring.
    Open

                $poll_vars = [
                    'user_id'     => Request::getInt('user_id', $GLOBALS['xoopsUser']->uid(), 'POST'),
                    'question'    => Request::getString('question', null, 'POST'),
                    'description' => Request::getText('description', null, 'POST'),
                    'mail_status' => (Constants::NOTIFICATION_ENABLED === $notify) ? Constants::POLL_NOT_MAILED : Constants::POLL_MAILED,
    Severity: Major
    Found in extras/newbb_5x/irmtfan/polls.php and 2 other locations - About 1 day to fix
    admin/main.php on lines 251..265
    extras/newbb_5x/trunk_5_00/polls.php on lines 149..163

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 256.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Identical blocks of code found in 2 locations. Consider refactoring.
    Open

            if (!empty($end_time)) {
                $timezone = ($GLOBALS['xoopsUser'] instanceof \XoopsUser) ? $GLOBALS['xoopsUser']->getVar('timezone') : null;
                //        $poll_obj->setVar("end_time", userTimeToServerTime(strtotime($end_time), $timezone));
                //Hack by irmtfan
                $poll_obj->setVar('end_time', userTimeToServerTime(method_exists('XoopsLocal', 'strtotime') ? XoopsLocal::strtotime($end_time) : strtotime($end_time), $timezone));
    Severity: Major
    Found in extras/newbb_5x/irmtfan/polls.php and 1 other location - About 1 hr to fix
    extras/newbb_5x/trunk_5_00/polls.php on lines 347..354

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 119.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Identical blocks of code found in 2 locations. Consider refactoring.
    Open

            $expire_text = new \XoopsFormText(_MD_POLL_EXPIRATION . '<br><small>' . _MD_POLL_FORMAT . '<br>' . sprintf(_MD_POLL_CURRENTTIME, formatTimestamp(time(), _DATESTRING)) . '</small>', 'end_time', 20, 19, formatTimestamp(time() + $default_poll_duration, _DATESTRING));
    Severity: Major
    Found in extras/newbb_5x/irmtfan/polls.php and 1 other location - About 1 hr to fix
    extras/newbb_5x/trunk_5_00/polls.php on lines 322..322

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 103.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Line exceeds 120 characters; contains 292 characters
    Open

                    $restart_label = new \XoopsFormLabel(_MD_POLL_EXPIRATION, sprintf(_MD_POLL_EXPIREDAT, $date) . "<br><a href='" . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/polls.php?op=restart&amp;poll_id={$poll_id}&amp;topic_id={$topic_id}'>" . _MD_POLL_RESTART . '</a>');

    Line exceeds 120 characters; contains 231 characters
    Open

                $more_label = new \XoopsFormLabel('', "<br><a href='" . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/polls.php?op=addmore&amp;poll_id={$poll_id}&amp;topic_id={$topic_id}'>" . _MD_POLL_ADDMORE . '</a>');

    Line exceeds 120 characters; contains 211 characters
    Open

                    $color_select->setExtra("onchange='showImgSelected(\"option_color_image[{$i}]\", \"option_color[" . $i . "]\", \"modules/{$pollmodules}/assets/images/colorbars\", \"\", \"" . XOOPS_URL . "\")'");

    Line exceeds 120 characters; contains 136 characters
    Open

                redirect_header(Request::getString('HTTP_REFERER', '', 'SERVER'), 2, _MD_ERROROCCURED . ': ' . _MD_POLL_POLLOPTIONS . ' !');

    Line exceeds 120 characters; contains 179 characters
    Open

                    $poll_obj->setVar('end_time', userTimeToServerTime(method_exists('XoopsLocal', 'strtotime') ? XoopsLocal::strtotime($end_time) : strtotime($end_time), $timezone));

    Line exceeds 120 characters; contains 205 characters
    Open

                    $color_select->setExtra("onchange='showImgSelected(\"option_color_image[{$i}]\", \"option_color[{$i}]\", \"modules/{$pollmodules}/assets/images/colorbars\", \"\", \"" . XOOPS_URL . "\")'");

    Line exceeds 120 characters; contains 282 characters
    Open

                    $color_label = new \XoopsFormLabel('', "<img src='" . $GLOBALS['xoops']->url("modules/{$pollmodules}/assets/images/colorbars/{$current_bar}") . "' name='option_color_image[{$i}]' id='option_color_image[{$i}]' class='alignbottom' width='30' height='15' alt=''><br>");

    Line exceeds 120 characters; contains 199 characters
    Open

                $expire_text = new \XoopsFormText(_MD_POLL_EXPIRATION . "<br><small>" . _MD_POLL_FORMAT . "<br>" . sprintf(_MD_POLL_CURRENTTIME, $currenttime) . "</small>", "end_time", 30, 19, $endtime);

    Line exceeds 120 characters; contains 123 characters
    Open

                    $option_tray->addElement(new \XoopsFormText('', 'option_text[]', 50, 255, $option->getVar('option_text')));

    Line exceeds 120 characters; contains 152 characters
    Open

                $endTimestamp     = empty($xuEndTimestamp) ? ($currentTimestamp + Constants::DEFAULT_POLL_DURATION) : userTimeToServerTime($xuEndTimestamp);

    Line exceeds 120 characters; contains 175 characters
    Open

                $poll_obj->setVar('end_time', userTimeToServerTime(method_exists('XoopsLocal', 'strtotime') ? XoopsLocal::strtotime($end_time) : strtotime($end_time), $timezone));

    Line exceeds 120 characters; contains 131 characters
    Open

                $barcolor_array = \XoopsLists::getImgListAsArray(XOOPS_ROOT_PATH . "/modules/{$pollmodules}/assets/images/colorbars/");

    Line exceeds 120 characters; contains 137 characters
    Open

                $barcolor_array = \XoopsLists::getImgListAsArray($GLOBALS['xoops']->path("modules/{$pollmodules}/assets/images/colorbars/"));

    Line exceeds 120 characters; contains 266 characters
    Open

            //    $expire_text = new \XoopsFormText(_MD_POLL_EXPIRATION . "<br><small>" . _MD_POLL_FORMAT . "<br>" . sprintf(_MD_POLL_CURRENTTIME, formatTimestamp(time(), "Y-m-d H:i:s")) . "</small>", "end_time", 20, 19, formatTimestamp(time() + 604800, "Y-m-d H:i:s"));

    Line exceeds 120 characters; contains 140 characters
    Open

        if ($topicHandler->getPermission($forum_obj, $topic_obj->getVar('topic_status'), 'addpoll')//&& $forum_obj->getVar('allow_polls') == 1 {

    Line exceeds 120 characters; contains 153 characters
    Open

            redirect_header($GLOBALS['xoops']->url("modules/".$xoopsModule->getVar("dirname")."/viewtopic.php?topic_id={$topic_id}"), 1, _MD_POLL_DBUPDATED);

    Line exceeds 120 characters; contains 137 characters
    Open

                $barcolor_array = \XoopsLists::getImgListAsArray($GLOBALS['xoops']->path("modules/{$pollmodules}/assets/images/colorbars/"));

    Line exceeds 120 characters; contains 193 characters
    Open

                $poll_obj->setVar("end_time", userTimeToServerTime(method_exists('XoopsLocal', 'strtotime') ? XoopsLocal::strtotime($_POST['end_time']) : strtotime($_POST['end_time']), $timezone));

    Line exceeds 120 characters; contains 149 characters
    Open

                        $sql = "UPDATE " . $xoopsDB->prefix("bb_topics") . " SET votes = 0, topic_haspoll = 0, poll_id = 0 WHERE topic_id = {$topic_id}";

    Line exceeds 120 characters; contains 129 characters
    Open

                echo '<h4>' . _MD_POLL_POLLCONF . "</h4>\n" . '<br>' . _MD_VIEW_LOG . "\n" . '<br>' . _MD_LOG_NOT_IMPLEMENTED . "\n";

    Line exceeds 120 characters; contains 121 characters
    Open

                $timezone = ($GLOBALS['xoopsUser'] instanceof \XoopsUser) ? $GLOBALS['xoopsUser']->getVar("timezone") : null;

    Line exceeds 120 characters; contains 122 characters
    Open

                $desc_tarea = new \XoopsFormTextarea(_MD_POLL_POLLDESC, 'description', $poll_obj->getVar('description', 'E'));

    Line exceeds 120 characters; contains 166 characters
    Open

            xoops_confirm(['op' => 'delete_ok', 'topic_id' => $topic_id, 'poll_id' => $poll_id], 'polls.php', sprintf(_MD_POLL_RUSUREDEL, $poll_obj->getVar('question')));

    Line exceeds 120 characters; contains 156 characters
    Open

        //        $sql = "UPDATE " . $GLOBALS['xoopsDB']->prefix("bb_topics") . " SET topic_haspoll = 1, poll_id = {$new_poll_id} WHERE topic_id = {$topic_id}";

    Line exceeds 120 characters; contains 136 characters
    Open

                redirect_header(Request::getString('HTTP_REFERER', '', 'SERVER'), 2, _MD_ERROROCCURED . ': ' . _MD_POLL_POLLOPTIONS . ' !');

    Line exceeds 120 characters; contains 128 characters
    Open

                $question_text = new \XoopsFormText(_MD_POLL_POLLQUESTION, 'question', 50, 255, $poll_obj->getVar('question', 'E'));

    Line exceeds 120 characters; contains 137 characters
    Open

                redirect_header(Request::getString('HTTP_REFERER', '', 'SERVER'), 2, _MD_ERROROCCURED . ': ' . _MD_POLL_POLLQUESTION . ' !');

    Line exceeds 120 characters; contains 261 characters
    Open

                $author_label = new \XoopsFormLabel(_MD_POLL_AUTHOR, "<a href='" . XOOPS_URL . '/userinfo.php?uid=' . $poll_obj->getVar('user_id') . "'>" . newbb_getUnameFromId($poll_obj->getVar('user_id'), $GLOBALS['xoopsModuleConfig']['show_realname']) . '</a>');

    Line exceeds 120 characters; contains 121 characters
    Open

                $timezone = ($GLOBALS['xoopsUser'] instanceof \XoopsUser) ? $GLOBALS['xoopsUser']->getVar('timezone') : null;

    Line exceeds 120 characters; contains 266 characters
    Open

                    $color_label = new \XoopsFormLabel("", "<img src='" . XOOPS_URL . "/modules/{$pollmodules}/assets/images/colorbars/{$current_bar}' name='option_color_image[{$i}]' id='option_color_image[{$i}]' width='30' class='alignbottom' height='15' alt=''><br>");

    Line exceeds 120 characters; contains 152 characters
    Open

                $startTimestamp   = empty($xuStartTimestamp) ? ($endTimestamp - Constants::DEFAULT_POLL_DURATION) : userTimeToServerTime($xuStartTimestamp);

    Line exceeds 120 characters; contains 133 characters
    Open

                    'mail_status' => (Constants::NOTIFICATION_ENABLED === $notify) ? Constants::POLL_NOT_MAILED : Constants::POLL_MAILED,

    Line exceeds 120 characters; contains 129 characters
    Open

                //        redirect_header("viewtopic.php?topic_id={$topic_id}", Constants::REDIRECT_DELAY_SHORT, _MD_POLL_DBUPDATED);

    Line exceeds 120 characters; contains 226 characters
    Open

                    $expire_text = new \XoopsFormText(_MD_POLL_EXPIRATION . '<br><small>' . _MD_POLL_FORMAT . '<br>' . sprintf(_MD_POLL_CURRENTTIME, formatTimestamp(time(), 'Y-m-d H:i:s')) . '</small>', 'end_time', 20, 19, $date);

    Line exceeds 120 characters; contains 136 characters
    Open

                redirect_header(Request::getString('HTTP_REFERER', '', 'SERVER'), 2, _MD_ERROROCCURED . ': ' . _MD_POLL_POLLOPTIONS . ' !');

    Line exceeds 120 characters; contains 155 characters
    Open

                redirect_header($GLOBALS['xoops']->url("modules/xoopspoll/admin/main.php?op=log&amp;poll_id={$poll_id}"), 2, _MD_LOG_XOOPSPOLL_ADMIN_REDIRECT);

    Line exceeds 120 characters; contains 124 characters
    Open

                    $current_bar = ("blank.gif" != current($barcolor_array)) ? current($barcolor_array) : next($barcolor_array);

    Line exceeds 120 characters; contains 270 characters
    Open

                        "<img src='" . $GLOBALS['xoops']->url("modules/{$pollmodules}/assets/images/colorbars/" . $option->getVar('option_color', 'E')) . "' name='option_color_image[{$i}]' id='option_color_image[{$i}]' class='alignbottom' width='30' height='15' alt=''><br>"

    Line exceeds 120 characters; contains 125 characters
    Open

                    $timezone = ($GLOBALS['xoopsUser'] instanceof \XoopsUser) ? $GLOBALS['xoopsUser']->getVar('timezone') : null;

    Line exceeds 120 characters; contains 272 characters
    Open

            $expire_text = new \XoopsFormText(_MD_POLL_EXPIRATION . '<br><small>' . _MD_POLL_FORMAT . '<br>' . sprintf(_MD_POLL_CURRENTTIME, formatTimestamp(time(), _DATESTRING)) . '</small>', 'end_time', 20, 19, formatTimestamp(time() + $default_poll_duration, _DATESTRING));

    Line exceeds 120 characters; contains 125 characters
    Open

                    $current_bar = ('blank.gif' !== current($barcolor_array)) ? current($barcolor_array) : next($barcolor_array);

    Line exceeds 120 characters; contains 205 characters
    Open

                    $color_select->setExtra("onchange='showImgSelected(\"option_color_image[{$i}]\", \"option_color[{$i}]\", \"modules/{$pollmodules}/assets/images/colorbars\", \"\", \"" . XOOPS_URL . "\")'");

    There are no issues that match your filters.

    Category
    Status