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 | * wgGitHub module for xoops |
||||
14 | * |
||||
15 | * @copyright 2020 XOOPS Project (https://xooops.org) |
||||
16 | * @license GPL 2.0 or later |
||||
17 | * @package wggithub |
||||
18 | * @since 1.0 |
||||
19 | * @min_xoops 2.5.10 |
||||
20 | * @author Goffy - XOOPS Development Team - Email:<[email protected]> - Website:<https://wedega.com> |
||||
21 | */ |
||||
22 | |||||
23 | use Xmf\Request; |
||||
0 ignored issues
–
show
|
|||||
24 | use XoopsModules\Wggithub; |
||||
25 | use XoopsModules\Wggithub\Constants; |
||||
26 | use XoopsModules\Wggithub\Common; |
||||
27 | |||||
28 | use XoopsModules\Wggithub\Github\Http; |
||||
29 | use XoopsModules\Wggithub\Github\Http\BadResponseException; |
||||
30 | |||||
31 | |||||
32 | require __DIR__ . '/header.php'; |
||||
33 | // It recovered the value of argument op in URL$ |
||||
34 | $op = Request::getCmd('op', 'list'); |
||||
35 | $setId = Request::getInt('set_id'); |
||||
36 | $start = Request::getInt('start', 0); |
||||
37 | $limit = Request::getInt('limit', $helper->getConfig('adminpager')); |
||||
38 | $GLOBALS['xoopsTpl']->assign('start', $start); |
||||
39 | $GLOBALS['xoopsTpl']->assign('limit', $limit); |
||||
40 | |||||
41 | switch ($op) { |
||||
42 | case 'list': |
||||
43 | default: |
||||
44 | // Define Stylesheet |
||||
45 | $GLOBALS['xoTheme']->addStylesheet($style, null); |
||||
46 | $start = Request::getInt('start', 0); |
||||
47 | $limit = Request::getInt('limit', $helper->getConfig('adminpager')); |
||||
48 | $templateMain = 'wggithub_admin_settings.tpl'; |
||||
49 | $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('settings.php')); |
||||
50 | $adminObject->addItemButton(\_AM_WGGITHUB_ADD_SETTING, 'settings.php?op=new', 'add'); |
||||
51 | $GLOBALS['xoopsTpl']->assign('buttons', $adminObject->displayButton('left')); |
||||
52 | $settingsCount = $settingsHandler->getCountSettings(); |
||||
53 | $settingsAll = $settingsHandler->getAllSettings($start, $limit); |
||||
54 | $GLOBALS['xoopsTpl']->assign('settings_count', $settingsCount); |
||||
55 | $GLOBALS['xoopsTpl']->assign('wggithub_url', \WGGITHUB_URL); |
||||
56 | $GLOBALS['xoopsTpl']->assign('wggithub_upload_url', \WGGITHUB_UPLOAD_URL); |
||||
57 | // Table view settings |
||||
58 | if ($settingsCount > 0) { |
||||
59 | foreach (\array_keys($settingsAll) as $i) { |
||||
60 | $setting = $settingsAll[$i]->getValuesSettings(); |
||||
61 | $GLOBALS['xoopsTpl']->append('settings_list', $setting); |
||||
62 | unset($setting); |
||||
63 | } |
||||
64 | // Display Navigation |
||||
65 | if ($settingsCount > $limit) { |
||||
66 | include_once \XOOPS_ROOT_PATH . '/class/pagenav.php'; |
||||
0 ignored issues
–
show
|
|||||
67 | $pagenav = new \XoopsPageNav($settingsCount, $limit, $start, 'start', 'op=list&limit=' . $limit); |
||||
0 ignored issues
–
show
The type
XoopsPageNav was not found. Maybe you did not declare it correctly or list all dependencies?
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. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||||
68 | $GLOBALS['xoopsTpl']->assign('pagenav', $pagenav->renderNav(4)); |
||||
69 | } |
||||
70 | } else { |
||||
71 | $GLOBALS['xoopsTpl']->assign('error', \_AM_WGGITHUB_THEREARENT_SETTINGS); |
||||
72 | } |
||||
73 | break; |
||||
74 | case 'new': |
||||
75 | $templateMain = 'wggithub_admin_settings.tpl'; |
||||
76 | $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('settings.php')); |
||||
77 | $adminObject->addItemButton(\_AM_WGGITHUB_SETTINGS_LIST, 'settings.php', 'list'); |
||||
78 | $GLOBALS['xoopsTpl']->assign('buttons', $adminObject->displayButton('left')); |
||||
79 | // Form Create |
||||
80 | $settingsObj = $settingsHandler->create(); |
||||
81 | $form = $settingsObj->getFormSettings(false, $start, $limit); |
||||
82 | $GLOBALS['xoopsTpl']->assign('form', $form->render()); |
||||
83 | break; |
||||
84 | case 'save': |
||||
85 | // Security Check |
||||
86 | if (!$GLOBALS['xoopsSecurity']->check()) { |
||||
87 | \redirect_header('settings.php', 3, \implode(',', $GLOBALS['xoopsSecurity']->getErrors())); |
||||
0 ignored issues
–
show
The function
redirect_header was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
88 | } |
||||
89 | if ($setId > 0) { |
||||
90 | $settingsObj = $settingsHandler->get($setId); |
||||
91 | } else { |
||||
92 | $settingsObj = $settingsHandler->create(); |
||||
93 | } |
||||
94 | // Set Vars |
||||
95 | $settingsObj->setVar('set_username', Request::getString('set_username', '')); |
||||
96 | $settingsObj->setVar('set_token', Request::getString('set_token', '')); |
||||
97 | $settingsObj->setVar('set_options', Request::getString('set_options', '')); |
||||
98 | $settingsObj->setVar('set_primary', Request::getInt('set_primary', 0)); |
||||
99 | $settingDateObj = \DateTime::createFromFormat(_SHORTDATESTRING, Request::getString('set_date')); |
||||
0 ignored issues
–
show
|
|||||
100 | $settingsObj->setVar('set_date', $settingDateObj->getTimestamp()); |
||||
101 | $settingsObj->setVar('set_submitter', Request::getInt('set_submitter', 0)); |
||||
102 | // Insert Data |
||||
103 | if ($settingsHandler->insert($settingsObj)) { |
||||
104 | if (Request::getInt('set_primary', 0) > 0) { |
||||
105 | $newSetId = $settingsObj->getNewInsertedIdSettings(); |
||||
106 | $setId = $setId > 0 ? $setId : $newSetId; |
||||
107 | $settingsHandler->setPrimarySetting($setId); |
||||
108 | } |
||||
109 | \redirect_header('settings.php?op=list&start=' . $start . '&limit=' . $limit, 2, \_AM_WGGITHUB_FORM_OK); |
||||
110 | } |
||||
111 | // Get Form |
||||
112 | $GLOBALS['xoopsTpl']->assign('error', $settingsObj->getHtmlErrors()); |
||||
113 | $form = $settingsObj->getFormSettings(false, $start, $limit); |
||||
114 | $GLOBALS['xoopsTpl']->assign('form', $form->render()); |
||||
115 | break; |
||||
116 | case 'edit': |
||||
117 | $templateMain = 'wggithub_admin_settings.tpl'; |
||||
118 | $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('settings.php')); |
||||
119 | $adminObject->addItemButton(\_AM_WGGITHUB_ADD_SETTING, 'settings.php?op=new', 'add'); |
||||
120 | $adminObject->addItemButton(\_AM_WGGITHUB_SETTINGS_LIST, 'settings.php', 'list'); |
||||
121 | $GLOBALS['xoopsTpl']->assign('buttons', $adminObject->displayButton('left')); |
||||
122 | // Get Form |
||||
123 | $settingsObj = $settingsHandler->get($setId); |
||||
124 | $form = $settingsObj->getFormSettings(false, $start, $limit); |
||||
125 | $GLOBALS['xoopsTpl']->assign('form', $form->render()); |
||||
126 | break; |
||||
127 | case 'delete': |
||||
128 | $templateMain = 'wggithub_admin_settings.tpl'; |
||||
129 | $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('settings.php')); |
||||
130 | $settingsObj = $settingsHandler->get($setId); |
||||
131 | $setToken = $settingsObj->getVar('set_token'); |
||||
132 | if (isset($_REQUEST['ok']) && 1 == $_REQUEST['ok']) { |
||||
133 | if (!$GLOBALS['xoopsSecurity']->check()) { |
||||
134 | \redirect_header('settings.php', 3, \implode(', ', $GLOBALS['xoopsSecurity']->getErrors())); |
||||
135 | } |
||||
136 | if ($settingsHandler->delete($settingsObj)) { |
||||
137 | \redirect_header('settings.php', 3, \_AM_WGGITHUB_FORM_DELETE_OK); |
||||
138 | } else { |
||||
139 | $GLOBALS['xoopsTpl']->assign('error', $settingsObj->getHtmlErrors()); |
||||
140 | } |
||||
141 | } else { |
||||
142 | $customConfirm = new Common\Confirm( |
||||
143 | ['ok' => 1, 'set_id' => $setId, 'op' => 'delete'], |
||||
144 | $_SERVER['REQUEST_URI'], |
||||
145 | \sprintf(\_AM_WGGITHUB_FORM_SURE_DELETE, $settingsObj->getVar('set_token'))); |
||||
146 | $form = $customConfirm->getFormConfirm(); |
||||
147 | $GLOBALS['xoopsTpl']->assign('form', $form->render()); |
||||
148 | } |
||||
149 | break; |
||||
150 | case 'test': |
||||
151 | $templateMain = 'wggithub_admin_settings.tpl'; |
||||
152 | $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('settings.php')); |
||||
153 | $adminObject->addItemButton(\_AM_WGGITHUB_ADD_SETTING, 'settings.php?op=new', 'add'); |
||||
154 | $adminObject->addItemButton(\_AM_WGGITHUB_SETTINGS_LIST, 'settings.php', 'list'); |
||||
155 | $GLOBALS['xoopsTpl']->assign('buttons', $adminObject->displayButton('left')); |
||||
156 | |||||
157 | $client = Wggithub\Github\GithubClient::getInstance(); |
||||
158 | $result = $client->testApi1('emojis'); |
||||
159 | if ($result) { |
||||
160 | $info = 'Github/GithubClient testApi1 (reading github public repos) successfully finished'; |
||||
161 | } else { |
||||
162 | $info = 'Github/GithubClient testApi1 (reading github public repos) failed'; |
||||
163 | } |
||||
164 | $result = $client->testUserRepositories(); |
||||
165 | if ($result) { |
||||
166 | $info .= '<br>Github/GithubClient testUserRepositories (reading github repos of primary setting) successfully finished'; |
||||
167 | } else { |
||||
168 | $info .= '<br>Github/GithubClient testUserRepositories (reading github repos of primary setting) failed'; |
||||
169 | } |
||||
170 | |||||
171 | $GLOBALS['xoopsTpl']->assign('info1', $info); |
||||
172 | break; |
||||
173 | } |
||||
174 | require __DIR__ . '/footer.php'; |
||||
175 |
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