|
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
|
|
|
* @copyright XOOPS Project (https://xoops.org) |
|
14
|
|
|
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU Public License |
|
15
|
|
|
* @package Mymenus |
|
16
|
|
|
* @since 1.0 |
|
17
|
|
|
* @author trabis <[email protected]>, bleekk <[email protected]> |
|
18
|
|
|
*/ |
|
19
|
|
|
|
|
20
|
|
|
use Xmf\Request; |
|
|
|
|
|
|
21
|
|
|
use XoopsModules\Mymenus; |
|
22
|
|
|
|
|
23
|
|
|
require __DIR__ . '/admin_header.php'; |
|
24
|
|
|
|
|
25
|
|
|
$currentFile = basename(__FILE__); |
|
26
|
|
|
|
|
27
|
|
|
$mymenusTpl = new \XoopsTpl(); // will be removed??? |
|
|
|
|
|
|
28
|
|
|
$mymenusAdminPage = 'links.php'; // will be removed??? |
|
29
|
|
|
|
|
30
|
|
|
$menusCriteria = new \CriteriaCompo(); |
|
|
|
|
|
|
31
|
|
|
$menusCriteria->setSort('id'); |
|
32
|
|
|
$menusCriteria->setOrder('ASC'); |
|
33
|
|
|
$menusList = $helper->getHandler('Menus')->getList($menusCriteria); |
|
34
|
|
|
if (!$menusList) { |
|
35
|
|
|
redirect_header('menus.php', 1, _AM_MYMENUS_MSG_NOMENUS); |
|
|
|
|
|
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
$valid_menu_ids = array_keys($menusList); |
|
39
|
|
|
$mid = Request::getInt('mid', Request::getInt('mid', '', 'POST'), 'GET'); |
|
40
|
|
|
if ($mid && in_array($mid, $valid_menu_ids)) { |
|
41
|
|
|
$menuTitle = $menusList[$mid]; |
|
42
|
|
|
} else { |
|
43
|
|
|
$keys = array_keys($menusList); |
|
44
|
|
|
$mid = $valid_menu_ids[0]; //force menu id to first valid menu id in the list |
|
45
|
|
|
$menuTitle = $menusList[$mid]; // and get it's title |
|
46
|
|
|
} |
|
47
|
|
|
$mymenusTpl->assign('mid', $mid); |
|
48
|
|
|
$mymenusTpl->assign('menuTitle', $menuTitle); |
|
49
|
|
|
$mymenusTpl->assign('menus_list', $menusList); |
|
50
|
|
|
|
|
51
|
|
|
$id = Request::getInt('id', 0); |
|
52
|
|
|
$pid = Request::getInt('pid', 0); |
|
53
|
|
|
$start = Request::getInt('start', 0); |
|
54
|
|
|
$weight = Request::getInt('weight', 0); |
|
55
|
|
|
$visible = Request::getInt('visible', 0); |
|
56
|
|
|
|
|
57
|
|
|
$op = Request::getString('op', 'list'); |
|
58
|
|
|
switch ($op) { |
|
59
|
|
|
|
|
60
|
|
|
/* |
|
61
|
|
|
case 'form': |
|
62
|
|
|
xoops_cp_header(); |
|
63
|
|
|
$adminObject = \Xmf\Module\Admin::getInstance(); |
|
64
|
|
|
$adminObject->displayNavigation($currentFile); |
|
65
|
|
|
// |
|
66
|
|
|
echo editLink(null, $pid, $mid); |
|
67
|
|
|
// |
|
68
|
|
|
require __DIR__ . '/admin_footer.php'; |
|
69
|
|
|
break; |
|
70
|
|
|
*/ |
|
71
|
|
|
|
|
72
|
|
|
case 'edit': |
|
73
|
|
|
echo Mymenus\LinksUtility::editLink($id, null, $mid); |
|
74
|
|
|
break; |
|
75
|
|
|
|
|
76
|
|
|
case 'add': |
|
77
|
|
|
Mymenus\LinksUtility::addLink($mid); |
|
78
|
|
|
break; |
|
79
|
|
|
|
|
80
|
|
|
case 'save': |
|
81
|
|
|
Mymenus\LinksUtility::saveLink($id, $mid); |
|
82
|
|
|
break; |
|
83
|
|
|
|
|
84
|
|
|
case 'delete': |
|
85
|
|
|
$id = Request::getInt('id', null); |
|
86
|
|
|
$linksObj = $helper->getHandler('Links')->get($id); |
|
87
|
|
|
if (true === Request::getBool('ok', false, 'POST')) { |
|
88
|
|
|
if (!$GLOBALS['xoopsSecurity']->check()) { |
|
89
|
|
|
redirect_header($currentFile, 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors())); |
|
90
|
|
|
} |
|
91
|
|
|
//get sub item |
|
92
|
|
|
$linksCriteria = new \CriteriaCompo(); |
|
93
|
|
|
$linksCriteria->add(new \Criteria('id', $id)); |
|
|
|
|
|
|
94
|
|
|
$linksCriteria->add(new \Criteria('pid', $id), 'OR'); |
|
95
|
|
|
//first delete links level 2 |
|
96
|
|
|
$query = 'DELETE FROM ' . $GLOBALS['xoopsDB']->prefix('mymenus_links'); |
|
97
|
|
|
$query .= ' WHERE pid = (SELECT id FROM (SELECT * FROM ' . $GLOBALS['xoopsDB']->prefix('mymenus_links') . " WHERE pid = {$id}) AS sec);"; |
|
98
|
|
|
$result = $GLOBALS['xoopsDB']->queryF($query); |
|
99
|
|
|
//delete links level 0 and 1 |
|
100
|
|
|
if (!$helper->getHandler('Links')->deleteAll($linksCriteria)) { |
|
101
|
|
|
xoops_cp_header(); |
|
|
|
|
|
|
102
|
|
|
xoops_error(_AM_MYMENUS_MSG_ERROR, $linksObj->getVar('id')); |
|
|
|
|
|
|
103
|
|
|
xoops_cp_footer(); |
|
|
|
|
|
|
104
|
|
|
exit(); |
|
105
|
|
|
} |
|
106
|
|
|
redirect_header($currentFile, 3, _AM_MYMENUS_MSG_DELETE_LINK_SUCCESS); |
|
107
|
|
|
} else { |
|
108
|
|
|
xoops_cp_header(); |
|
109
|
|
|
xoops_confirm(['ok' => true, 'id' => $id, 'op' => 'delete'], // $_SERVER['REQUEST_URI'], |
|
|
|
|
|
|
110
|
|
|
Request::getString('REQUEST_URI', '', 'SERVER'), sprintf(_AM_MYMENUS_LINKS_SUREDEL, $linksObj->getVar('title'))); |
|
111
|
|
|
require __DIR__ . '/admin_footer.php'; |
|
112
|
|
|
} |
|
113
|
|
|
break; |
|
114
|
|
|
|
|
115
|
|
|
case 'move': |
|
116
|
|
|
xoops_cp_header(); |
|
117
|
|
|
$adminObject = \Xmf\Module\Admin::getInstance(); |
|
|
|
|
|
|
118
|
|
|
$adminObject->displayNavigation($currentFile); |
|
119
|
|
|
// |
|
120
|
|
|
Mymenus\LinksUtility::moveLink($id, $weight); |
|
121
|
|
|
echo Mymenus\LinksUtility::listLinks($start, $mid); |
|
122
|
|
|
// |
|
123
|
|
|
require __DIR__ . '/admin_footer.php'; |
|
124
|
|
|
break; |
|
125
|
|
|
|
|
126
|
|
|
case 'toggle': |
|
127
|
|
|
Mymenus\LinksUtility::toggleLinkVisibility($id, $visible); |
|
128
|
|
|
break; |
|
129
|
|
|
|
|
130
|
|
|
case 'order': |
|
131
|
|
|
$test = []; |
|
132
|
|
|
$order = Request::getString('mod', '', 'POST'); |
|
133
|
|
|
parse_str($order, $test); |
|
134
|
|
|
$i = 1; |
|
135
|
|
|
foreach ($test['mod'] as $order => $value) { |
|
136
|
|
|
$linksObj = $helper->getHandler('Links')->get($order); |
|
137
|
|
|
$linksObj->setVar('weight', ++$i); |
|
138
|
|
|
// Set submenu |
|
139
|
|
|
if (isset($value)) { |
|
140
|
|
|
$linksObj->setVar('pid', $value); |
|
141
|
|
|
} else { |
|
142
|
|
|
$linksObj->setVar('pid', 0); |
|
143
|
|
|
} |
|
144
|
|
|
$helper->getHandler('Links')->insert($linksObj); |
|
145
|
|
|
$helper->getHandler('Links')->updateWeights($linksObj); |
|
146
|
|
|
} |
|
147
|
|
|
break; |
|
148
|
|
|
|
|
149
|
|
|
case 'list': |
|
150
|
|
|
default: |
|
151
|
|
|
xoops_cp_header(); |
|
152
|
|
|
$adminObject = \Xmf\Module\Admin::getInstance(); |
|
153
|
|
|
$adminObject->displayNavigation($currentFile); |
|
154
|
|
|
// Add module stylesheet |
|
155
|
|
|
$GLOBALS['xoTheme']->addStylesheet(XOOPS_URL . '/modules/system/css/ui/' . xoops_getModuleOption('jquery_theme', 'system') . '/ui.all.css'); |
|
|
|
|
|
|
156
|
|
|
$GLOBALS['xoTheme']->addStylesheet(XOOPS_URL . "/modules/{$helper->getDirname()}/assets/css/admin.css"); |
|
157
|
|
|
$GLOBALS['xoTheme']->addStylesheet(XOOPS_URL . '/Frameworks/moduleclasses/moduleadmin/css/admin.css'); |
|
158
|
|
|
// Define scripts |
|
159
|
|
|
$GLOBALS['xoTheme']->addScript('browse.php?Frameworks/jquery/plugins/jquery.ui.js'); |
|
160
|
|
|
$GLOBALS['xoTheme']->addScript(XOOPS_URL . "/modules/{$helper->getDirname()}/assets/js/nestedSortable.js"); |
|
161
|
|
|
//$GLOBALS['xoTheme']->addScript(XOOPS_URL . '/modules/{$mymenus->dirname}/assets/js/switchButton.js'); |
|
162
|
|
|
$GLOBALS['xoTheme']->addScript(XOOPS_URL . "/modules/{$helper->getDirname()}/assets/js/links.js"); |
|
163
|
|
|
echo Mymenus\LinksUtility::listLinks($start, $mid); |
|
164
|
|
|
// Disable xoops debugger in dialog window |
|
165
|
|
|
// require $GLOBALS['xoops']->path('/class/logger/xoopslogger.php'); |
|
166
|
|
|
xoops_load('xoopslogger'); |
|
|
|
|
|
|
167
|
|
|
$xoopsLogger = XoopsLogger::getInstance(); |
|
|
|
|
|
|
168
|
|
|
$xoopsLogger->activated = true; |
|
169
|
|
|
error_reporting(-1); |
|
170
|
|
|
// |
|
171
|
|
|
require __DIR__ . '/admin_footer.php'; |
|
172
|
|
|
break; |
|
173
|
|
|
} |
|
174
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths