Completed
Branch master (1b2f30)
by Michael
06:29 queued 03:22
created

include/notification.inc.php (2 issues)

Upgrade to new PHP Analysis Engine

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
 * Module: SmartFAQ
5
 * Author: The SmartFactory <www.smartfactory.ca>
6
 * Licence: GNU
7
 * @param $category
8
 * @param $item_id
9
 * @return mixed
10
 */
11
12
function smartfaq_notify_iteminfo($category, $item_id)
13
{
14
    global $xoopsModule, $xoopsModuleConfig, $xoopsConfig;
15
16
    if (empty($xoopsModule) || $xoopsModule->getVar('dirname') !== 'smartfaq') {
17
        $moduleHandler = xoops_getHandler('module');
18
        $module        = &$moduleHandler->getByDirname('smartfaq');
19
        $configHandler = xoops_getHandler('config');
20
        $config        = &$configHandler->getConfigsByCat(0, $module->getVar('mid'));
21
    } else {
22
        $module = &$xoopsModule;
23
        $config = &$xoopsModuleConfig;
24
    }
25
26
    if ($category === 'global') {
27
        $item['name'] = '';
28
        $item['url']  = '';
29
30
        return $item;
31
    }
32
33
    global $xoopsDB;
34
35 View Code Duplication
    if ($category === 'category') {
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.

Loading history...
36
        // Assume we have a valid category id
37
        $sql          = 'SELECT name FROM ' . $xoopsDB->prefix('smartfaq_categories') . ' WHERE categoryid  = ' . $item_id;
38
        $result       = $xoopsDB->query($sql); // TODO: error check
39
        $result_array = $xoopsDB->fetchArray($result);
40
        $item['name'] = $result_array['name'];
41
        $item['url']  = XOOPS_URL . '/modules/' . $module->getVar('dirname') . '/category.php?categoryid=' . $item_id;
42
43
        return $item;
44
    }
45
46 View Code Duplication
    if ($category === 'faq') {
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.

Loading history...
47
        // Assume we have a valid story id
48
        $sql          = 'SELECT question FROM ' . $xoopsDB->prefix('smartfaq_faq') . ' WHERE faqid = ' . $item_id;
49
        $result       = $xoopsDB->query($sql); // TODO: error check
50
        $result_array = $xoopsDB->fetchArray($result);
51
        $item['name'] = $result_array['question'];
52
        $item['url']  = XOOPS_URL . '/modules/' . $module->getVar('dirname') . '/faq.php?faqid=' . $item_id;
53
54
        return $item;
55
    }
56
}
57