Passed
Push — master ( 5eecc9...7a0709 )
by Michael
14:04
created

Userlog   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 61
Duplicated Lines 0 %

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
B item() 0 35 7
1
<?php declare(strict_types=1);
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
    Helper,
18
    TopicHandler
19
};
20
//use XoopsModules\Userlog;
21
22
/** @var Helper $helper */
23
24
/**
25
 *  userlog module
26
 *
27
 * @copyright       XOOPS Project (https://xoops.org)
28
 * @license         GNU GPL 2 (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
29
 * @since           4.31
30
 * @author          irmtfan ([email protected])
31
 * @author          XOOPS Project <www.xoops.org> <www.xoops.ir>
32
 */
33
class Userlog extends Userlog\Plugin\PluginAbstract implements Userlog\Plugin\PluginInterface
0 ignored issues
show
Bug introduced by
The type XoopsModules\Newbb\Plugi...g\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...
Bug introduced by
The type XoopsModules\Newbb\Plugi...\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...
34
{
35
    /**
36
     * @param string $subscribe_from Name of the script
37
     *
38
     * 'name' => 'thread';
39
     * 'title' => _MI_NEWBB_THREAD_NOTIFY;
40
     * 'description' => _MI_NEWBB_THREAD_NOTIFYDSC;
41
     * 'subscribe_from' => 'viewtopic.php';
42
     * 'item_name' => 'topic_id';
43
     * 'allow_bookmark' => 1;
44
     *
45
     * publisher:
46
     * 'name' = 'category_item';
47
     * 'title' = _MI_PUBLISHER_CATEGORY_ITEM_NOTIFY;
48
     * 'description' = _MI_PUBLISHER_CATEGORY_ITEM_NOTIFY_DSC;
49
     * 'subscribe_from' = array('index.php', 'category.php', 'item.php');
50
     * 'item_name' = 'categoryid';
51
     * 'allow_bookmark' = 1;
52
     *
53
     * empty($subscribe_from):
54
     * @return bool|array["item_name"] name of the item = array("subscribe_from1", "subscribe_from2") Name of the script
0 ignored issues
show
Documentation Bug introduced by
The doc comment bool|array["item_name"] at position 3 could not be parsed: Expected ']' at position 3, but found '['.
Loading history...
55
     *
56
     * !empty($subscribe_from):
57
     * @return bool|array $item["item_name"] name of the item, $item["item_id"] id of the item
58
     */
59
    public function item(string $subscribe_from)
60
    {
61
        if (empty($subscribe_from)) {
62
            $script_arr             = [];
63
            $script_arr['topic_id'] = ['viewtopic.php'];
64
            $script_arr['forum']    = ['viewforum.php'];
65
66
            return $script_arr;
67
        }
68
69
        switch ($subscribe_from) {
70
            case 'viewtopic.php':
71
                /** @var TopicHandler $topicHandler */ $topicHandler = Helper::getInstance()->getHandler('Topic');
72
                $post_id                                                   = Request::getInt('post_id', 0); // !empty($_REQUEST["post_id"]) ? (int)($_REQUEST["post_id"]) : 0;
73
                $move                                                      = \mb_strtolower(Request::getString('move', '', 'GET')); // isset($_GET['move'])? strtolower($_GET['move']) : '';
74
                $topic_id                                                  = Request::getInt('topic_id', 0); // !empty($_REQUEST["topic_id"]) ? (int)($_REQUEST["topic_id"]) : 0;
75
                if (!empty($post_id)) {
76
                    $topicObject = $topicHandler->getByPost($post_id);
77
                    $topic_id    = $topicObject->getVar('topic_id');
78
                } elseif (!empty($move)) {
79
                    $forum_id    = Request::getInt('forum_id', 0); //!empty($_REQUEST["forum_id"]) ? (int)($_REQUEST["forum_id"]) : 0;
80
                    $topicObject = $topicHandler->getByMove($topic_id, ('prev' === $move) ? -1 : 1, $forum_id);
81
                    $topic_id    = $topicObject->getVar('topic_id');
82
                }
83
84
                return ['item_name' => 'topic_id', 'item_id' => $topic_id];
85
                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...
86
            case 'viewforum.php':
87
                $forum_id = Request::getInt('forum', 0); // !empty($_REQUEST["forum"]) ? (int)($_REQUEST["forum"]) : 0;
88
89
                return ['item_name' => 'forum', 'item_id' => $forum_id];
90
                break;
91
        }
92
93
        return false;
94
    }
95
}
96