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

admin/pedigree_temp.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
31
$tempHandler = Pedigree\Helper::getInstance()->getHandler('Temp');
32
33
//It recovered the value of argument op in URL$
34
$op = Request::getCmd('op', 'list');
35
switch ($op) {
36
    case 'list':
37
    default:
38
        $adminObject->displayNavigation(basename(__FILE__));
39
        $adminObject->addItemButton(_AM_PEDIGREE_NEWPEDIGREE_TEMP, 'pedigree_temp.php?op=new_pedigree_temp', 'add');
40
        $adminObject->displayButton('left');
41
        $criteria = new \CriteriaCompo();
42
        $criteria->setSort('id');
43
        $criteria->setOrder('ASC');
44
        $numrows           = $tempHandler->getCount();
45
        $pedigree_temp_arr = $tempHandler->getAll($criteria);
46
47
        //Table view
48
        if ($numrows > 0) {
49
            echo "<table cellspacing='1' class='outer width100'>
50
                <thead>
51
                <tr>
52
                    <th class='txtcenter'>" . _AM_PEDIGREE_PEDIGREE_TEMP_NAAM . "</th>
53
                        <th class='txtcenter'>" . _AM_PEDIGREE_PEDIGREE_TEMP_ID_OWNER . "</th>
54
                        <th class='txtcenter'>" . _AM_PEDIGREE_PEDIGREE_TEMP_ID_BREEDER . "</th>
55
                        <th class='txtcenter'>" . _AM_PEDIGREE_PEDIGREE_TEMP_USER . "</th>
56
                        <th class='txtcenter'>" . _AM_PEDIGREE_PEDIGREE_TEMP_ROFT . "</th>
57
                        <th class='txtcenter'>" . _AM_PEDIGREE_PEDIGREE_TEMP_MOTHER . "</th>
58
                        <th class='txtcenter'>" . _AM_PEDIGREE_PEDIGREE_TEMP_FATHER . "</th>
59
                        <th class='txtcenter'>" . _AM_PEDIGREE_PEDIGREE_TEMP_FOTO . "</th>
60
                        <th class='txtcenter width10'>" . _AM_PEDIGREE_FORMACTION . '</th>
61
                </tr>
62
                </thead>
63
                <tbody>';
64
65
            $class = 'odd';
66
67
            foreach (array_keys($pedigree_temp_arr) as $i) {
68
                if (0 == $pedigree_temp_arr[$i]->getVar('pedigree_temp_pid')) {
69
                    echo "<tr class='{$class}'>";
70
                    $class = ('even' === $class) ? 'odd' : 'even';
71
                    echo "<td class='txtcenter'>" . $pedigree_temp_arr[$i]->getVar('naam') . '</td>';
72
                    echo "<td class='txtcenter'>" . $pedigree_temp_arr[$i]->getVar('id_owner') . '</td>';
73
                    echo "<td class='txtcenter'>" . $pedigree_temp_arr[$i]->getVar('id_breeder') . '</td>';
74
                    echo "<td class='txtcenter'>" . $pedigree_temp_arr[$i]->getVar('user') . '</td>';
75
                    echo "<td class='txtcenter'>" . $pedigree_temp_arr[$i]->getVar('roft') . '</td>';
76
                    echo "<td class='txtcenter'>" . $pedigree_temp_arr[$i]->getVar('mother') . '</td>';
77
                    echo "<td class='txtcenter'>" . $pedigree_temp_arr[$i]->getVar('father') . '</td>';
78
                    echo "<td class='txtcenter'>" . $pedigree_temp_arr[$i]->getVar('foto') . '</td>';
79
                    echo "<td class-'txtcenter width10'>
80
                        <a href='pedigree_temp.php?op=edit_pedigree_temp&id=" . $pedigree_temp_arr[$i]->getVar('id') . "'><img src=" . $pathIcon16 . "/edit.png alt='" . _EDIT . "' title='" . _EDIT . "'></a>
81
                        <a href='pedigree_temp.php?op=delete_pedigree_temp&id=" . $pedigree_temp_arr[$i]->getVar('id') . "'><img src=" . $pathIcon16 . "/delete.png alt='" . _DELETE . "' title='" . _DELETE . "'></a>
82
                        </td>";
83
                    echo '</tr>';
84
                }
85
            }
86
            echo '</tbody>
87
                  </table>
88
                  <br><br>';
89
        }
90
91
        break;
92
93
    case 'new_pedigree_temp':
94
        $adminObject->displayNavigation(basename(__FILE__));
95
        $adminObject->addItemButton(_AM_PEDIGREE_PEDIGREE_TEMPLIST, 'pedigree_temp.php?op=list', 'list');
96
        $adminObject->displayButton('left');
97
98
        $tempHandler = Pedigree\Helper::getInstance()->getHandler('Temp');
99
        $obj         = $tempHandler->create();
100
        $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

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