b_suico_friends_edit()   A
last analyzed

Complexity

Conditions 5
Paths 4

Size

Total Lines 17
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 5
eloc 12
nc 4
nop 1
dl 0
loc 17
rs 9.5555
c 0
b 0
f 0
1
<?php declare(strict_types=1);
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
 * @category        Module
14
 * @copyright       {@link https://xoops.org/ XOOPS Project}
15
 * @license         GNU GPL 2.0 or later (https://www.gnu.org/licenses/gpl-2.0.html)
16
 * @author          Marcello Brandão aka  Suico, Mamba, LioMJ  <https://xoops.org>
17
 */
18
19
use XoopsModules\Suico\{
20
    FriendshipHandler,
21
    Helper};
22
/** @var Helper $helper */
23
24
if (!defined('XOOPS_ROOT_PATH')) {
25
    exit();
26
}
27
//require_once XOOPS_ROOT_PATH."/class/criteria.php";
28
//require_once XOOPS_ROOT_PATH . '/modules/suico/class/Friendship.php';
29
/**
30
 * @param $options
31
 * @return array|false
32
 */
33
function b_suico_friends_show($options)
34
{
35
    global $xoopsDB, $xoopsModule, $xoopsModuleConfig, $xoopsUser;
36
37
    /** @var Helper $helper */
38
    if (!class_exists(Helper::class)) {
39
        return false;
40
    }
41
42
    $helper = Helper::getInstance();
43
    $helper->loadLanguage('main');
44
45
    $myts  = \MyTextSanitizer::getInstance();
0 ignored issues
show
Unused Code introduced by
The assignment to $myts is dead and can be removed.
Loading history...
46
    $block = [];
47
    if ($xoopsUser) {
48
        /**
49
         * Filter for fetch votes ishot and isnothot
50
         */
51
        $criteria2 = new Criteria(
52
            'friend1_uid',
53
            $xoopsUser->getVar(
54
                'uid'
55
            )
56
        );
57
        /**
58
         * Creating factories of pictures and votes
59
         */
60
        //$albumFactory      = new ImagesHandler($xoopsDB);
61
        $friendsFactory           = new FriendshipHandler($xoopsDB);
62
        $block['friends']         = $friendsFactory->getFriends($options[0], $criteria2);
63
        $block['lang_allfriends'] = _MB_SUICO_ALLFRIENDS;
64
        $block['lang_nofriends']  = _MB_SUICO_NOFRIENDSYET;
65
        $block['enablepm']        = $options[1] ?? '';
66
67
        return $block;
68
    }
69
}
70
71
/**
72
 * @param array $options
73
 * @return string
74
 */
75
function b_suico_friends_edit($options)
76
{
77
    $chk = '';
78
    $form = _MB_SUICO_TOTALFRIENDSTOSHOW . '&nbsp;';
79
    $form .= "<input type='text' name='options[0]' value='" . $options[0] . "'><br>";
80
    $form .= _MB_SUICO_ENABLEPM . '&nbsp;';
81
    if (isset($options[1]) && 1 === $options[1]) {
82
        $chk = ' checked';
83
    }
84
    $form .= "<input type='radio' name='options[1]' value='1'" . $chk . '>&nbsp;' . _YES . '';
85
    $chk  = '';
86
    if (!isset($options[1]) || 0 === $options[1]) {
87
        $chk = ' checked';
88
    }
89
    $form .= "&nbsp;<input type='radio' name='options[1]' value='0'" . $chk . '>' . _NO . '<br>';
90
91
    return $form;
92
}
93