1
|
|
|
<?php declare(strict_types=1); |
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 (https://www.gnu.org/licenses/gpl-2.0.html) |
15
|
|
|
* @since 2.3.0 |
16
|
|
|
* @author Jan Pedersen |
17
|
|
|
* @author Taiwen Jiang <[email protected]> |
18
|
|
|
*/ |
19
|
|
|
|
20
|
|
|
|
21
|
|
|
use XoopsModules\Suico\{ |
22
|
|
|
Form\StepForm, |
23
|
|
|
Regstep, |
24
|
|
|
RegstepHandler |
25
|
|
|
}; |
26
|
|
|
|
27
|
|
|
require_once __DIR__ . '/admin_header.php'; |
28
|
|
|
xoops_cp_header(); |
29
|
|
|
$adminObject->addItemButton(_AM_SUICO_STEP, 'registrationstep.php?op=new', 'add'); |
30
|
|
|
$adminObject->displayNavigation(basename(__FILE__)); |
31
|
|
|
$adminObject->displayButton('left'); |
32
|
|
|
$op = $_REQUEST['op'] ?? (isset($_REQUEST['id']) ? 'edit' : 'list'); |
33
|
|
|
/** @var RegstepHandler $regstepHandler */ |
34
|
|
|
$regstepHandler = $helper->getHandler('Regstep'); |
35
|
|
|
switch ($op) { |
36
|
|
|
case 'list': |
37
|
|
|
$GLOBALS['xoopsTpl']->assign('steps', $regstepHandler->getObjects(null, true, false)); |
38
|
|
|
$template_main = 'admin/suico_admin_registrationstep.tpl'; |
39
|
|
|
break; |
40
|
|
|
case 'new': |
41
|
|
|
/** @var Regstep $obj */ |
42
|
|
|
$obj = $regstepHandler->create(); |
43
|
|
|
$form = new StepForm($obj); |
44
|
|
|
$form->display(); |
45
|
|
|
break; |
46
|
|
|
case 'edit': |
47
|
|
|
$obj = $regstepHandler->get($_REQUEST['id']); |
48
|
|
|
$form = new StepForm($obj); |
49
|
|
|
$form->display(); |
50
|
|
|
break; |
51
|
|
|
case 'save': |
52
|
|
|
if (isset($_REQUEST['id'])) { |
53
|
|
|
$obj = $regstepHandler->get($_REQUEST['id']); |
54
|
|
|
} else { |
55
|
|
|
$obj = $regstepHandler->create(); |
56
|
|
|
} |
57
|
|
|
$obj->setVar('step_name', $_REQUEST['step_name']); |
58
|
|
|
$obj->setVar('step_order', $_REQUEST['step_order']); |
59
|
|
|
$obj->setVar('step_desc', $_REQUEST['step_desc']); |
60
|
|
|
$obj->setVar('step_save', $_REQUEST['step_save']); |
61
|
|
|
if ($regstepHandler->insert($obj)) { |
62
|
|
|
redirect_header('registrationstep.php', 3, sprintf(_AM_SUICO_SAVEDSUCCESS, _AM_SUICO_STEP)); |
63
|
|
|
} |
64
|
|
|
echo $obj->getHtmlErrors(); |
65
|
|
|
$form = $obj->getForm(); |
66
|
|
|
$form->display(); |
67
|
|
|
break; |
68
|
|
|
case 'delete': |
69
|
|
|
$obj = $regstepHandler->get($_REQUEST['id']); |
70
|
|
|
if (isset($_REQUEST['ok']) && 1 == $_REQUEST['ok']) { |
71
|
|
|
if ($regstepHandler->delete($obj)) { |
72
|
|
|
redirect_header('registrationstep.php', 3, sprintf(_AM_SUICO_DELETEDSUCCESS, _AM_SUICO_STEP)); |
73
|
|
|
} else { |
74
|
|
|
echo $obj->getHtmlErrors(); |
75
|
|
|
} |
76
|
|
|
} else { |
77
|
|
|
xoops_confirm( |
78
|
|
|
[ |
79
|
|
|
'ok' => 1, |
80
|
|
|
'id' => $_REQUEST['id'], |
81
|
|
|
'op' => 'delete', |
82
|
|
|
], |
83
|
|
|
$_SERVER['REQUEST_URI'], |
84
|
|
|
sprintf(_AM_SUICO_RUSUREDEL, $obj->getVar('step_name')) |
85
|
|
|
); |
86
|
|
|
} |
87
|
|
|
break; |
88
|
|
|
case 'toggle': |
89
|
|
|
if (isset($_GET['step_id'])) { |
90
|
|
|
$field_id = (int)$_GET['step_id']; |
91
|
|
|
if (isset($_GET['step_save'])) { |
92
|
|
|
$step_save = (int)$_GET['step_save']; |
93
|
|
|
profile_stepsave_toggle($step_id, $step_save); |
94
|
|
|
} |
95
|
|
|
} |
96
|
|
|
break; |
97
|
|
|
} |
98
|
|
|
if (!empty($template_main)) { |
99
|
|
|
$GLOBALS['xoopsTpl']->display("db:{$template_main}"); |
100
|
|
|
} |
101
|
|
|
/** |
102
|
|
|
* @param $step_d |
103
|
|
|
* @param $step_save |
104
|
|
|
*/ |
105
|
|
|
function profile_stepsave_toggle($step_d, $step_save): void |
|
|
|
|
106
|
|
|
{ |
107
|
|
|
$helper = XoopsModules\Suico\Helper::getInstance(); |
108
|
|
|
$step_save = (1 == $step_save) ? 0 : 1; |
109
|
|
|
$regstepHandler = $helper->getHandler('Regstep'); |
110
|
|
|
$obj = $regstepHandler->get($_REQUEST['step_id']); |
111
|
|
|
$obj->setVar('step_save', $step_save); |
112
|
|
|
if ($regstepHandler->insert($obj, true)) { |
|
|
|
|
113
|
|
|
redirect_header('registrationstep.php', 1, _AM_SUICO_SAVESTEP_TOGGLE_SUCCESS); |
114
|
|
|
} else { |
115
|
|
|
redirect_header('registrationstep.php', 1, _AM_SUICO_SAVESTEP_TOGGLE_FAILED); |
116
|
|
|
} |
117
|
|
|
} |
118
|
|
|
|
119
|
|
|
require_once __DIR__ . '/admin_footer.php'; |
120
|
|
|
|
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.