Plugin   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 61
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 26
dl 0
loc 61
rs 10
c 0
b 0
f 0
wmc 7

1 Method

Rating   Name   Duplication   Size   Complexity  
B item() 0 35 7
1
<?php
2
3
namespace XoopsModules\Newbb\Plugin;
4
5
/*
6
 You may not change or alter any portion of this comment or credits
7
 of supporting developers from this source code or any supporting source code
8
 which is considered copyrighted (c) material of the original comment or credit authors.
9
10
 This program is distributed in the hope that it will be useful,
11
 but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13
*/
14
15
use Xmf\Request;
16
use XoopsModules\Newbb;
17
use XoopsModules\Userlog;
0 ignored issues
show
Bug introduced by
The type XoopsModules\Userlog was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
18
19
/**
20
 *  userlog module
21
 *
22
 * @copyright       XOOPS Project (https://xoops.org)
23
 * @license         GNU GPL 2 (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
24
 * @package         newbb class plugin
25
 * @since           4.31
26
 * @author          irmtfan ([email protected])
27
 * @author          XOOPS Project <www.xoops.org> <www.xoops.ir>
28
 */
29
30
31
class Plugin extends Userlog\Plugin\PluginAbstract implements Userlog\Plugin\PluginInterface
0 ignored issues
show
Bug introduced by
The type XoopsModules\Userlog\Plugin\PluginInterface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
Bug introduced by
The type XoopsModules\Userlog\Plugin\PluginAbstract was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
32
{
33
    /**
34
     * @param string $subscribe_from Name of the script
35
     *
36
     * 'name' => 'thread';
37
     * 'title' => _MI_NEWBB_THREAD_NOTIFY;
38
     * 'description' => _MI_NEWBB_THREAD_NOTIFYDSC;
39
     * 'subscribe_from' => 'viewtopic.php';
40
     * 'item_name' => 'topic_id';
41
     * 'allow_bookmark' => 1;
42
     *
43
     * publisher:
44
     * 'name' = 'category_item';
45
     * 'title' = _MI_PUBLISHER_CATEGORY_ITEM_NOTIFY;
46
     * 'description' = _MI_PUBLISHER_CATEGORY_ITEM_NOTIFY_DSC;
47
     * 'subscribe_from' = array('index.php', 'category.php', 'item.php');
48
     * 'item_name' = 'categoryid';
49
     * 'allow_bookmark' = 1;
50
     *
51
     * empty($subscribe_from):
52
     * @return bool|array $script_arr["item_name"] name of the item = array("subscribe_from1", "subscribe_from2") Name of the script
53
     *
54
     * !empty($subscribe_from):
55
     * @return bool|array $item["item_name"] name of the item, $item["item_id"] id of the item
56
     */
57
    public function item($subscribe_from)
58
    {
59
        if (empty($subscribe_from)) {
60
            $script_arr             = [];
61
            $script_arr['topic_id'] = ['viewtopic.php'];
62
            $script_arr['forum']    = ['viewforum.php'];
63
64
            return $script_arr;
65
        }
66
67
        switch ($subscribe_from) {
68
            case 'viewtopic.php':
69
                /** @var Newbb\TopicHandler $topicHandler */ $topicHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Topic');
70
                $post_id                                                   = Request::getInt('post_id', 0); // !empty($_REQUEST["post_id"]) ? (int)($_REQUEST["post_id"]) : 0;
71
                $move                                                      = mb_strtolower(Request::getString('move', '', 'GET')); // isset($_GET['move'])? strtolower($_GET['move']) : '';
72
                $topic_id                                                  = Request::getInt('topic_id', 0); // !empty($_REQUEST["topic_id"]) ? (int)($_REQUEST["topic_id"]) : 0;
73
                if (!empty($post_id)) {
74
                    $topicObject = $topicHandler->getByPost($post_id);
75
                    $topic_id    = $topicObject->getVar('topic_id');
76
                } elseif (!empty($move)) {
77
                    $forum_id    = Request::getInt('forum_id', 0); //!empty($_REQUEST["forum_id"]) ? (int)($_REQUEST["forum_id"]) : 0;
78
                    $topicObject = $topicHandler->getByMove($topic_id, ('prev' === $move) ? -1 : 1, $forum_id);
79
                    $topic_id    = $topicObject->getVar('topic_id');
80
                }
81
82
                return ['item_name' => 'topic_id', 'item_id' => $topic_id];
83
                break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
84
            case 'viewforum.php':
85
                $forum_id = Request::getInt('forum', 0); // !empty($_REQUEST["forum"]) ? (int)($_REQUEST["forum"]) : 0;
86
87
                return ['item_name' => 'forum', 'item_id' => $forum_id];
88
                break;
89
        }
90
91
        return false;
92
    }
93
}
94