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

admin/pedigree_trash.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
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
$trashHandler = Pedigree\Helper::getInstance()->getHandler('Trash');
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_TRASH, 'pedigree_trash.php?op=new_pedigree_trash', 'add');
39
        //        $adminObject->displayButton('left');
40
        $criteria = new \CriteriaCompo();
41
        $criteria->setSort('id');
42
        $criteria->setOrder('ASC');
43
        $numrows            = $trashHandler->getCount();
44
        $pedigree_trash_arr = $trashHandler->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_TRASH_NAAM . "</th>
52
                        <th class='txtcenter'>" . _AM_PEDIGREE_PEDIGREE_TRASH_ID_OWNER . "</th>
53
                        <th class='txtcenter'>" . _AM_PEDIGREE_PEDIGREE_TRASH_ID_BREEDER . "</th>
54
                        <th class='txtcenter'>" . _AM_PEDIGREE_PEDIGREE_TRASH_USER . "</th>
55
                        <th class='txtcenter'>" . _AM_PEDIGREE_PEDIGREE_TRASH_ROFT . "</th>
56
                        <th class='txtcenter'>" . _AM_PEDIGREE_PEDIGREE_TRASH_MOTHER . "</th>
57
                        <th class='txtcenter'>" . _AM_PEDIGREE_PEDIGREE_TRASH_FATHER . "</th>
58
                        <th class='txtcenter'>" . _AM_PEDIGREE_PEDIGREE_TRASH_FOTO . "</th>
59
                        <th class='txtcenter'>" . _AM_PEDIGREE_PEDIGREE_TRASH_COI . "</th>
60
61
                    <th align='center' width='10%'>" . _AM_PEDIGREE_FORMACTION . '</th>
62
                </tr>
63
                </thead>
64
                <tbody>';
65
66
            $class = 'odd';
67
68
            foreach (array_keys($pedigree_trash_arr) as $i) {
69
                if (0 == $pedigree_trash_arr[$i]->getVar('pedigree_trash_pid')) {
70
                    echo "<tr class='{$class}'>";
71
                    $class = ('even' === $class) ? 'odd' : 'even';
72
                    echo "<td class='txtcenter'>" . $pedigree_trash_arr[$i]->getVar('naam') . '</td>';
73
                    echo "<td class='txtcenter'>" . $pedigree_trash_arr[$i]->getVar('id_owner') . '</td>';
74
                    echo "<td class='txtcenter'>" . $pedigree_trash_arr[$i]->getVar('id_breeder') . '</td>';
75
                    echo "<td class='txtcenter'>" . $pedigree_trash_arr[$i]->getVar('user') . '</td>';
76
                    echo "<td class='txtcenter'>" . $pedigree_trash_arr[$i]->getVar('roft') . '</td>';
77
                    echo "<td class='txtcenter'>" . $pedigree_trash_arr[$i]->getVar('mother') . '</td>';
78
                    echo "<td class='txtcenter'>" . $pedigree_trash_arr[$i]->getVar('father') . '</td>';
79
                    echo "<td class='txtcenter'>" . $pedigree_trash_arr[$i]->getVar('foto') . '</td>';
80
                    echo "<td class='txtcenter'>" . $pedigree_trash_arr[$i]->getVar('coi') . '</td>';
81
                    echo "<td class'txtcenter width10'>
82
                        <a href='pedigree_trash.php?op=edit_pedigree_trash&id=" . $pedigree_trash_arr[$i]->getVar('id') . "'><img src='{$pathIcon16}/edit.png' alt='" . _EDIT . "' title='" . _EDIT . "'></a>
83
                        <a href='pedigree_trash.php?op=delete_pedigree_trash&id=" . $pedigree_trash_arr[$i]->getVar('id') . "'><img src='{$pathIcon16}/delete.png' alt='" . _DELETE . "' title='" . _DELETE . "'></a>
84
                        </td>";
85
                    echo '</tr>';
86
                }
87
            }
88
            echo '</tbody>
89
                  </table>
90
                  <br><br>';
91
        }
92
93
        break;
94
95
    case 'new_pedigree_trash':
96
        $adminObject->displayNavigation(basename(__FILE__));
97
        $adminObject->addItemButton(_AM_PEDIGREE_PEDIGREE_TRASHLIST, 'pedigree_trash.php?op=list', 'list');
98
        $adminObject->displayButton('left');
99
100
        $obj  = $trashHandler->create();
101
        $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

101
        /** @scrutinizer ignore-call */ 
102
        $form = $obj->getForm();
Loading history...
102
        $form->display();
103
        break;
104
105
    case 'save_pedigree_trash':
106
        if (!$GLOBALS['xoopsSecurity']->check()) {
107
            $helper->redirect('admin/pedigree_trash.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors()));
108
        }
109
        if (isset($_REQUEST['id'])) {
110
            $obj = $trashHandler->get($_REQUEST['id']);
111
        } else {
112
            $obj = $trashHandler->create();
113
        }
114
115
        //Form naam
116
        $obj->setVar('naam', $_REQUEST['naam']);
117
        //Form id_owner
118
        $obj->setVar('id_owner', $_REQUEST['id_owner']);
119
        //Form id_breeder
120
        $obj->setVar('id_breeder', $_REQUEST['id_breeder']);
121
        //Form user
122
        $obj->setVar('user', $_REQUEST['user']);
123
        //Form roft
124
        $obj->setVar('roft', $_REQUEST['roft']);
125
        //Form mother
126
        $obj->setVar('mother', $_REQUEST['mother']);
127
        //Form father
128
        $obj->setVar('father', $_REQUEST['father']);
129
        //Form foto
130
        $obj->setVar('foto', $_REQUEST['foto']);
131
        //Form coi
132
        $obj->setVar('coi', $_REQUEST['coi']);
133
134
        if ($trashHandler->insert($obj)) {
135
            $helper->redirect('admin/pedigree_trash.php?op=list', 2, _AM_PEDIGREE_FORMOK);
136
        }
137
138
        echo $obj->getHtmlErrors();
139
        $form = $obj->getForm();
140
        $form->display();
141
        break;
142
143
    case 'edit_pedigree_trash':
144
        $adminObject->displayNavigation(basename(__FILE__));
145
        $adminObject->addItemButton(_AM_PEDIGREE_NEWPEDIGREE_TRASH, 'pedigree_trash.php?op=new_pedigree_trash', 'add');
146
        $adminObject->addItemButton(_AM_PEDIGREE_PEDIGREE_TRASHLIST, 'pedigree_trash.php?op=list', 'list');
147
        $adminObject->displayButton('left');
148
        $obj  = $trashHandler->get($_REQUEST['id']);
149
        $form = $obj->getForm();
150
        $form->display();
151
        break;
152
153
    case 'delete_pedigree_trash':
154
        $obj = $trashHandler->get($_REQUEST['id']);
155
        if (isset($_REQUEST['ok']) && 1 == $_REQUEST['ok']) {
156
            if (!$GLOBALS['xoopsSecurity']->check()) {
157
                $helper->redirect('admin/pedigree_trash.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors()));
158
            }
159
            if ($trashHandler->delete($obj)) {
160
                $helper->redirect('admin/pedigree_trash.php', 3, _AM_PEDIGREE_FORMDELOK);
161
            } else {
162
                echo $obj->getHtmlErrors();
163
            }
164
        } else {
165
            xoops_confirm(['ok' => 1, 'id' => $_REQUEST['id'], 'op' => 'delete_pedigree_trash'], $_SERVER['REQUEST_URI'], sprintf(_AM_PEDIGREE_FORMSUREDEL, $obj->getVar('pedigree_trash')));
166
        }
167
        break;
168
}
169
require_once __DIR__ . '/admin_footer.php';
170