Passed
Push — master ( 4761c2...696f77 )
by
unknown
05:50 queued 19s
created

admin/registrationstep.php (1 issue)

Severity
1
<?php
2
3
/**
4
 * Extended User Profile
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
 * This program is distributed in the hope that it will be useful,
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
 *
13
 * @copyright       (c) 2000-2016 XOOPS Project (www.xoops.org)
14
 * @license             GNU GPL 2 (http://www.gnu.org/licenses/gpl-2.0.html)
15
 * @package             profile
16
 * @since               2.3.0
17
 * @author              Jan Pedersen
18
 * @author              Taiwen Jiang <[email protected]>
19
 */
20
include_once __DIR__ . '/admin_header.php';
21
xoops_cp_header();
22
$adminObject->addItemButton(_AM_SUICO_STEP, 'registrationstep.php?op=new', 'add');
23
$adminObject->displayNavigation(basename(__FILE__));
24
$adminObject->displayButton('left');
25
$op      = $_REQUEST['op'] ?? (isset($_REQUEST['id']) ? 'edit' : 'list');
26
$handler = $helper->getHandler('Regstep');
27
switch ($op) {
28
    case 'list':
29
        $GLOBALS['xoopsTpl']->assign('steps', $handler->getObjects(null, true, false));
30
        $template_main = 'admin/suico_admin_registrationstep.tpl';
31
        break;
32
    case 'new':
33
        $obj = $handler->create();
34
        include_once dirname(__DIR__) . '/include/forms.php';
35
        $form = profile_getStepForm($obj);
36
        $form->display();
37
        break;
38
    case 'edit':
39
        $obj = $handler->get($_REQUEST['id']);
40
        include_once dirname(__DIR__) . '/include/forms.php';
41
        $form = suico_getStepForm($obj);
42
        $form->display();
43
        break;
44
    case 'save':
45
        if (isset($_REQUEST['id'])) {
46
            $obj = $handler->get($_REQUEST['id']);
47
        } else {
48
            $obj = $handler->create();
49
        }
50
        $obj->setVar('step_name', $_REQUEST['step_name']);
51
        $obj->setVar('step_order', $_REQUEST['step_order']);
52
        $obj->setVar('step_desc', $_REQUEST['step_desc']);
53
        $obj->setVar('step_save', $_REQUEST['step_save']);
54
        if ($handler->insert($obj)) {
55
            redirect_header('registrationstep.php', 3, sprintf(_AM_SUICO_SAVEDSUCCESS, _AM_SUICO_STEP));
56
        }
57
        echo $obj->getHtmlErrors();
58
        $form = $obj->getForm();
59
        $form->display();
60
        break;
61
    case 'delete':
62
        $obj = $handler->get($_REQUEST['id']);
63
        if (isset($_REQUEST['ok']) && 1 == $_REQUEST['ok']) {
64
            if ($handler->delete($obj)) {
65
                redirect_header('registrationstep.php', 3, sprintf(_AM_SUICO_DELETEDSUCCESS, _AM_SUICO_STEP));
66
            } else {
67
                echo $obj->getHtmlErrors();
68
            }
69
        } else {
70
            xoops_confirm(
71
                [
72
                    'ok' => 1,
73
                    'id' => $_REQUEST['id'],
74
                    'op' => 'delete',
75
                ],
76
                $_SERVER['REQUEST_URI'],
77
                sprintf(_AM_SUICO_RUSUREDEL, $obj->getVar('step_name'))
78
            );
79
        }
80
        break;
81
    case 'toggle':
82
        if (isset($_GET['step_id'])) {
83
            $field_id = (int)$_GET['step_id'];
84
            if (isset($_GET['step_save'])) {
85
                $step_save = (int)$_GET['step_save'];
86
                profile_stepsave_toggle($step_id, $step_save);
87
            }
88
        }
89
        break;
90
}
91
if (!empty($template_main)) {
92
    $GLOBALS['xoopsTpl']->display("db:{$template_main}");
93
}
94
/**
95
 * @param $step_d
96
 * @param $step_save
97
 */
98
function profile_stepsave_toggle($step_d, $step_save)
0 ignored issues
show
The parameter $step_d is not used and could be removed. ( Ignorable by Annotation )

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

98
function profile_stepsave_toggle(/** @scrutinizer ignore-unused */ $step_d, $step_save)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
99
{
100
    $helper    = XoopsModules\Suico\Helper::getInstance();
101
    $step_save = (1 == $step_save) ? 0 : 1;
102
    $handler   = $helper->getHandler('Regstep');
103
    $obj       = $handler->get($_REQUEST['step_id']);
104
    $obj->setVar('step_save', $step_save);
105
    if ($handler->insert($obj, true)) {
106
        redirect_header('registrationstep.php', 1, _AM_SUICO_SAVESTEP_TOGGLE_SUCCESS);
107
    } else {
108
        redirect_header('registrationstep.php', 1, _AM_SUICO_SAVESTEP_TOGGLE_FAILED);
109
    }
110
}
111
112
include_once __DIR__ . '/admin_footer.php';
113