Entries::getGroupsSubmit()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 5
rs 10
c 1
b 0
f 0
1
<?php
2
3
namespace XoopsModules\Lexikon;
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
/**
16
 * Module: lexikon
17
 *
18
 * @category        Module
19
 * @package         lexikon
20
 * @author          XOOPS Development Team <[email protected]> - <https://xoops.org>
21
 * @copyright       {@link https://xoops.org/ XOOPS Project}
22
 * @license         GPL 2.0 or later
23
 * @link            https://xoops.org/
24
 * @since           1.0.0
25
 */
26
27
use Xmf\Module\Helper\Permission;
28
use XoopsModules\Lexikon;
29
30
require_once \dirname(__DIR__) . '/include/common.php';
31
32
$moduleDirName = \basename(\dirname(__DIR__));
33
34
$permHelper = new \Xmf\Module\Helper\Permission($moduleDirName);
35
36
/**
37
 * Class LexikonEntries
38
 */
39
class Entries extends \XoopsObject
40
{
41
    /**
42
     * Constructor
43
     *
44
     * @param null
45
     */
46
    public function __construct()
47
    {
48
        parent::__construct();
49
        $this->initVar('entryID', \XOBJ_DTYPE_INT);
50
        $this->initVar('categoryID', \XOBJ_DTYPE_INT);
51
        $this->initVar('term', \XOBJ_DTYPE_TXTBOX);
52
        $this->initVar('init', \XOBJ_DTYPE_TXTBOX);
53
        $this->initVar('definition', \XOBJ_DTYPE_OTHER);
54
        $this->initVar('ref', \XOBJ_DTYPE_OTHER);
55
        $this->initVar('url', \XOBJ_DTYPE_TXTBOX);
56
        $this->initVar('uid', \XOBJ_DTYPE_INT);
57
        $this->initVar('submit', \XOBJ_DTYPE_INT);
58
        $this->initVar('datesub', \XOBJ_DTYPE_INT, \time(), false);
59
        $this->initVar('counter', \XOBJ_DTYPE_INT);
60
        $this->initVar('html', \XOBJ_DTYPE_INT);
61
        $this->initVar('smiley', \XOBJ_DTYPE_INT);
62
        $this->initVar('xcodes', \XOBJ_DTYPE_INT);
63
        $this->initVar('breaks', \XOBJ_DTYPE_INT);
64
        $this->initVar('block', \XOBJ_DTYPE_INT);
65
        $this->initVar('offline', \XOBJ_DTYPE_INT);
66
        $this->initVar('notifypub', \XOBJ_DTYPE_INT);
67
        $this->initVar('request', \XOBJ_DTYPE_INT);
68
        $this->initVar('comments', \XOBJ_DTYPE_INT);
69
        //        $this->initVar('item_tag', XOBJ_DTYPE_OTHER);
70
    }
71
72
    /**
73
     * Get form
74
     *
75
     * @param null
76
     * @return Form\EntriesForm
77
     */
78
    public function getForm()
79
    {
80
        //        require_once XOOPS_ROOT_PATH . '/modules/lexikon/class/form/entries.php';
81
82
        $form = new Form\EntriesForm($this);
83
84
        return $form;
85
    }
86
87
    /**
88
     * @return \XoopsThemeForm
89
     */
90
    public function getFormFilter()
91
    {
92
        global $xoopsUser, $xoopsDB, $xoopsModule, $xoopsConfig;
93
94
        $helper = Helper::getInstance();
95
96
        $grouppermHandler = \xoops_getHandler('groupperm');
97
        $groups           = \is_object($xoopsUser) ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS;
98
        $action = $_SERVER['REQUEST_URI'];
0 ignored issues
show
Unused Code introduced by
The assignment to $action is dead and can be removed.
Loading history...
99
100
        // Get Theme Form
101
        \xoops_load('XoopsFormLoader');
102
        $form = new \XoopsThemeForm(_MD_LEXIKON_LOOKON, 'form', 'search.php', 'post', true);
103
        $form->setExtra('enctype="multipart/form-data"');
104
        // Form select search type
105
        $searchTypeSelect = new \XoopsFormSelect(\_MD_LEXIKON_LOOKON, 'type', $type);
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $type seems to be never defined.
Loading history...
106
        $searchTypeSelect->addOption('1', _MD_LEXIKON_TERMS);
107
        $searchTypeSelect->addOption('2', _MD_LEXIKON_DEFINS);
108
        $searchTypeSelect->addOption('3', _MD_LEXIKON_TERMSDEFS);
109
        $form->addElement($searchTypeSelect);
110
        // form select cats
111
        if (1 == $helper->getConfig('multicats')) {
112
            $resultcat  = $xoopsDB->query('SELECT categoryID, name FROM ' . $xoopsDB->prefix('lxcategories') . ' ORDER BY categoryID');
113
            $searchCatSelect = new \XoopsFormSelect(\_MD_LEXIKON_LOOKON, 'categoryID', $categoryID);
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $categoryID seems to be never defined.
Loading history...
114
            $searchCatSelect->addOption(0, _MD_LEXIKON_ALLOFTHEM);
115
            while (list($categoryID, $name) = $xoopsDB->fetchRow($resultcat)) {
116
                if ($grouppermHandler->checkRight('lexikon_view', (int)$categoryID, $groups, $xoopsModule->getVar('mid'))) {
0 ignored issues
show
Bug introduced by
The method checkRight() does not exist on XoopsObjectHandler. It seems like you code against a sub-type of XoopsObjectHandler such as XoopsGroupPermHandler or XoopsPersistableObjectHandler. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

116
                if ($grouppermHandler->/** @scrutinizer ignore-call */ checkRight('lexikon_view', (int)$categoryID, $groups, $xoopsModule->getVar('mid'))) {
Loading history...
117
                    $searchCatSelect->addOption($categoryID, $categoryID . ' : ' . $name);
118
                }
119
            }
120
            $form->addElement($searchCatSelect);
121
        }
122
        // Form Text term
123
        $form->addElement(new \XoopsFormText(\_MD_LEXIKON_TERM, 'term', 30, 255, $term), true);
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $term seems to be never defined.
Loading history...
124
        // To Save
125
        $form->addElement(new \XoopsFormHidden('op', 'save'));
126
        $form->addElement(new \XoopsFormButton('', 'submit', \_MD_LEXIKON_SEARCH, 'submit'));
127
128
        return $form;
129
    }
130
131
    /**
132
     * @return array|null
133
     */
134
    public function getGroupsRead()
135
    {
136
        global $permHelper;
137
        //return $this->publisher->getHandler('permission')->getGrantedGroupsById('entries_read', entryID);
138
        return $permHelper->getGroupsForItem('sbcolumns_read', $this->getVar('entryID'));
139
    }
140
141
    /**
142
     * @return array|null
143
     */
144
    public function getGroupsSubmit()
145
    {
146
        global $permHelper;
147
        //        return $this->publisher->getHandler('permission')->getGrantedGroupsById('entries_submit', entryID);
148
        return $permHelper->getGroupsForItem('sbcolumns_submit', $this->getVar('entryID'));
149
    }
150
151
    /**
152
     * @return array|null
153
     */
154
    public function getGroupsModeration()
155
    {
156
        global $permHelper;
157
        //        return $this->publisher->getHandler('permission')->getGrantedGroupsById('entries_moderation', entryID);
158
        return $permHelper->getGroupsForItem('sbcolumns_moderation', $this->getVar('entryID'));
159
    }
160
}
161