Passed
Push — master ( b847d6...d6d54c )
by Michael
09:34 queued 05:00
created

admin/pedigree_config.php (1 issue)

Labels
Severity
1
<?php
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
 * Pedigree module for XOOPS
14
 *
15
 * @copyright       {@link http://sourceforge.net/projects/xoops/ The XOOPS Project}
16
 * @license         GPL 2.0 or later
17
 * @package         pedigree
18
 * @since           2.5.x
19
 * @author          XOOPS Module Dev Team (https://xoops.org)
20
 */
21
22
use Xmf\Request;
23
use XoopsModules\Pedigree;
24
25
require_once __DIR__ . '/admin_header.php';
26
27
xoops_cp_header();
28
//$adminObject = \Xmf\Module\Admin::getInstance();
29
30
$fieldsHandler = Pedigree\Helper::getInstance()->getHandler('Fields');
31
32
//It recovered the value of argument op in URL$
33
$op = Request::getCmd('op', 'list');
34
switch ($op) {
35
    case 'list':
36
    default:
37
        $adminObject->displayNavigation(basename(__FILE__));
38
        $adminObject->addItemButton(_AM_PEDIGREE_NEWPEDIGREE_CONFIG, 'pedigree_config.php?op=new_pedigree_config', 'add');
39
        $adminObject->displayButton('left');
40
        $criteria = new \CriteriaCompo();
41
        $criteria->setSort('id');
42
        $criteria->setOrder('ASC');
43
        $numrows             = $fieldsHandler->getCount();
44
        $pedigree_config_arr = $fieldsHandler->getAll($criteria);
45
46
        //Table view
47
        if ($numrows > 0) {
48
            echo "<table cellspacing='1' class='outer width100'>
49
                <thead>
50
                <tr>
51
                    <th class='txtcenter'>" . _AM_PEDIGREE_PEDIGREE_CONFIG_ISACTIVE . "</th>
52
                    <th class='txtcenter'>" . _AM_PEDIGREE_PEDIGREE_CONFIG_FIELDNAME . "</th>
53
                    <th class='txtcenter'>" . _AM_PEDIGREE_PEDIGREE_CONFIG_FIELDTYPE . "</th>
54
                    <th class='txtcenter'>" . _AM_PEDIGREE_PEDIGREE_CONFIG_LOOKUPTABLE . "</th>
55
                    <th class='txtcenter'>" . _AM_PEDIGREE_PEDIGREE_CONFIG_DEFAULTVALUE . "</th>
56
                    <th class='txtcenter'>" . _AM_PEDIGREE_PEDIGREE_CONFIG_FIELDEXPLANATION . "</th>
57
                    <th class='txtcenter'>" . _AM_PEDIGREE_PEDIGREE_CONFIG_HASSEARCH . "</th>
58
                    <th class='txtcenter'>" . _AM_PEDIGREE_PEDIGREE_CONFIG_LITTER . "</th>
59
                    <th class='txtcenter'>" . _AM_PEDIGREE_PEDIGREE_CONFIG_GENERALLITTER . "</th>
60
                    <th class='txtcenter'>" . _AM_PEDIGREE_PEDIGREE_CONFIG_SEARCHNAME . "</th>
61
                    <th class='txtcenter'>" . _AM_PEDIGREE_PEDIGREE_CONFIG_SEARCHEXPLANATION . "</th>
62
                    <th class='txtcenter'>" . _AM_PEDIGREE_PEDIGREE_CONFIG_VIEWINPEDIGREE . "</th>
63
                    <th class='txtcenter'>" . _AM_PEDIGREE_PEDIGREE_CONFIG_VIEWINADVANCED . "</th>
64
                    <th class='txtcenter'>" . _AM_PEDIGREE_PEDIGREE_CONFIG_VIEWINPIE . "</th>
65
                    <th class='txtcenter'>" . _AM_PEDIGREE_PEDIGREE_CONFIG_VIEWINLIST . "</th>
66
                    <th class='txtcenter width10'>" . _AM_PEDIGREE_FORMACTION . '</th>
67
                </tr>
68
                </thead>
69
                <tbody>';
70
71
            $class = 'odd';
72
73
            foreach (array_keys($pedigree_config_arr) as $i) {
74
                if (0 == $pedigree_config_arr[$i]->getVar('pedigree_config_pid')) {
75
                    echo "<tr class='{$class}'>";
76
                    $class = ('even' === $class) ? 'odd' : 'even';
77
                    echo "<td class='txtcenter'>" . $pedigree_config_arr[$i]->getVar('isactive') . '</td>';
78
                    echo "<td class='txtcenter'>" . $pedigree_config_arr[$i]->getVar('fieldname') . '</td>';
79
                    echo "<td class='txtcenter'>" . $pedigree_config_arr[$i]->getVar('fieldtype') . '</td>';
80
                    echo "<td class='txtcenter'>" . $pedigree_config_arr[$i]->getVar('lookuptable') . '</td>';
81
                    echo "<td class='txtcenter'>" . $pedigree_config_arr[$i]->getVar('defaultvalue') . '</td>';
82
                    echo "<td class='txtcenter'>" . $pedigree_config_arr[$i]->getVar('fieldexplanation') . '</td>';
83
                    echo "<td class='txtcenter'>" . $pedigree_config_arr[$i]->getVar('hassearch') . '</td>';
84
                    echo "<td class='txtcenter'>" . $pedigree_config_arr[$i]->getVar('litter') . '</td>';
85
                    echo "<td class='txtcenter'>" . $pedigree_config_arr[$i]->getVar('generallitter') . '</td>';
86
                    echo "<td class='txtcenter'>" . $pedigree_config_arr[$i]->getVar('searchname') . '</td>';
87
                    echo "<td class='txtcenter'>" . $pedigree_config_arr[$i]->getVar('searchexplanation') . '</td>';
88
                    echo "<td class='txtcenter'>" . $pedigree_config_arr[$i]->getVar('viewinpedigree') . '</td>';
89
                    echo "<td class='txtcenter'>" . $pedigree_config_arr[$i]->getVar('viewinadvanced') . '</td>';
90
                    echo "<td class='txtcenter'>" . $pedigree_config_arr[$i]->getVar('viewinpie') . '</td>';
91
                    echo "<td class='txtcenter'>" . $pedigree_config_arr[$i]->getVar('viewinlist') . '</td>';
92
                    echo "<td class='txtcenter width10'>
93
                        <a href='pedigree_config.php?op=edit_pedigree_config&id=" . $pedigree_config_arr[$i]->getVar('id') . "'><img src='{$pathIcon16}/edit.png' alt='" . _EDIT . "' title='" . _EDIT . "'></a>
94
                        <a href='pedigree_config.php?op=delete_pedigree_config&id=" . $pedigree_config_arr[$i]->getVar('id') . "'><img src='{$pathIcon16}/delete.png' alt='" . _DELETE . "' title='" . _DELETE . "'></a>
95
                        </td>";
96
                    echo '</tr>';
97
                }
98
            }
99
            echo '</tbody>
100
                  </table>
101
                  <br><br>';
102
        }
103
104
        break;
105
106
    case 'new_pedigree_config':
107
        $adminObject->displayNavigation(basename(__FILE__));
108
        $adminObject->addItemButton(_AM_PEDIGREE_PEDIGREE_CONFIGLIST, 'pedigree_config.php?op=list', 'list');
109
        $adminObject->displayButton('left');
110
111
        $obj  = $fieldsHandler->create();
112
        $form = $obj->getForm();
0 ignored issues
show
The method getForm() does not exist on XoopsObject. It seems like you code against a sub-type of XoopsObject such as XoopsModules\Pedigree\Temp or SystemSmilies or XoopsModules\Pedigree\Owner or SystemBanner or SystemBannerclient or XoopsModules\Pedigree\Tree or XoopsModules\Pedigree\Trash or XoopsModules\Pedigree\Fields or ProfileCategory or SystemUserrank or SystemGroup or SystemBlock or SystemAvatar or SystemUsers. ( Ignorable by Annotation )

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

112
        /** @scrutinizer ignore-call */ 
113
        $form = $obj->getForm();
Loading history...
113
        $form->display();
114
        break;
115
116
    case 'save_pedigree_config':
117
        if (!$GLOBALS['xoopsSecurity']->check()) {
118
            $helper->redirect('admin/pedigree_config.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors()));
119
        }
120
        $id = Request::getInt('id', 0, 'POST');
121
        if ($id) {
122
            $obj = $fieldsHandler->get($id);
123
        } else {
124
            $obj = $fieldsHandler->create();
125
        }
126
        //Form isactive
127
        $obj->setVar('isactive', Request::getInt('isActive', 0, 'POST'));
128
        //Form fieldname
129
        $obj->setVar('fieldname', Request::getString('fieldName', '', 'POST'));
130
        //Form fieldtype
131
        $obj->setVar('fieldtype', Request::getString('fieldType', 'textbox', 'POST'));
132
        //Form LookupTable
133
        $obj->setVar('lookuptable', Request::getString('lookupTable', '', 'POST'));
134
        //Form DefaultValue
135
        $obj->setVar('defaultvalue', Request::getString('defaultValue', '', 'POST'));
136
        //Form FieldExplanation
137
        $obj->setVar('fieldexplanation', Request::getString('fieldExplanation', '', 'POST'));
138
        //Form HasSearch
139
        $obj->setVar('hassearch', Request::getInt('hasSearch', 0, 'POST'));
140
        //Form Litter Types
141
        $litterType = Request::getString('litterType', 'generalLitter');
142
        if ('Litter' === $litterType) {
143
            $obj->setVar('litter', 1);
144
            $obj->setVar('generalLitter', 0);
145
        } else {
146
            $obj->setVar('litter', 0);
147
            $obj->setVar('generalLitter', 1);
148
        }
149
        //Form SearchName
150
        $obj->setVar('searchname', Request::getString('searchName', '', 'POST'));
151
        //Form SearchExplanation
152
        $obj->setVar('searchexplanation', Request::getString('searchExplanation', '', 'POST'));
153
        //Form viewinpedigree
154
        $obj->setVar('viewinpedigree', Request::getInt('viewInPedigree', 0, 'POST'));
155
        //Form ViewInAdvanced
156
        $obj->setVar('viewinadvanced', Request::getInt('viewInAdvanced', 1, 'POST'));
157
        //Form ViewInPie
158
        $obj->setVar('viewinpie', Request::getInt('viewInPie', 0, 'POST'));
159
        //Form ViewInList
160
        $obj->setVar('viewinlist', Request::getInt('viewInList', 0, 'POST'));
161
        //Form locked
162
        $obj->setVar('locked', Request::getInt('locked', 0, 'POST'));
163
        //Form order
164
        $obj->setVar('order', Request::getInt('order', 0, 'POST'));
165
166
        if ($fieldsHandler->insert($obj)) {
167
            $helper->redirect('admin/pedigree_config.php?op=list', 2, _AM_PEDIGREE_FORMOK);
168
        }
169
170
        echo $obj->getHtmlErrors();
171
        $form = $obj->getForm();
172
        $form->display();
173
        break;
174
175
    case 'edit_pedigree_config':
176
        $adminObject->displayNavigation(basename(__FILE__));
177
        $adminObject->addItemButton(_AM_PEDIGREE_NEWPEDIGREE_CONFIG, 'pedigree_config.php?op=new_pedigree_config', 'add');
178
        $adminObject->addItemButton(_AM_PEDIGREE_PEDIGREE_CONFIGLIST, 'pedigree_config.php?op=list', 'list');
179
        $adminObject->displayButton('left');
180
        $obj  = $fieldsHandler->get(Request::getInt('id', 0));
181
        $form = $obj->getForm();
182
        $form->display();
183
        break;
184
185
    case 'delete_pedigree_config':
186
        $id  = Request::getInt('id', 0);
187
        $obj = $fieldsHandler->get($id);
188
        $ok  = Request::getInt('ok', 0, 'POST');
189
        if ('0' != $ok) {
190
            //        if (isset($_REQUEST['ok']) && (1 == $_REQUEST['ok'])) {
191
            if (!$GLOBALS['xoopsSecurity']->check()) {
192
                $helper->redirect('admin/pedigree_config.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors()));
193
            }
194
            if ($fieldsHandler->delete($obj)) {
195
                $helper->redirect('admin/pedigree_config.php', 3, _AM_PEDIGREE_FORMDELOK);
196
            } else {
197
                echo $obj->getHtmlErrors();
198
            }
199
        } else {
200
            xoops_confirm(['ok' => 1, 'id' => $id, 'op' => 'delete_pedigree_config'], $_SERVER['REQUEST_URI'], sprintf(_AM_PEDIGREE_FORMSUREDEL, $obj->getVar('pedigree_config')));
201
        }
202
        break;
203
}
204
require_once __DIR__ . '/admin_footer.php';
205