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 | require __DIR__ . '/header.php'; |
||||
29 | // It recovered the value of argument op in URL$ |
||||
30 | $op = Request::getCmd('op', 'list'); |
||||
31 | $repoId = Request::getInt('repo_id'); |
||||
32 | $start = Request::getInt('start', 0); |
||||
33 | $limit = Request::getInt('limit', $helper->getConfig('adminpager')); |
||||
34 | $GLOBALS['xoopsTpl']->assign('start', $start); |
||||
35 | $GLOBALS['xoopsTpl']->assign('limit', $limit); |
||||
36 | |||||
37 | |||||
38 | switch ($op) { |
||||
39 | case 'list': |
||||
40 | default: |
||||
41 | // Define Stylesheet |
||||
42 | $GLOBALS['xoTheme']->addStylesheet($style, null); |
||||
43 | $templateMain = 'wggithub_admin_repositories.tpl'; |
||||
44 | $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('repositories.php')); |
||||
45 | |||||
46 | $autoApproved = (int)$helper->getConfig('autoapproved'); |
||||
47 | $GLOBALS['xoopsTpl']->assign('autoApproved', !$autoApproved); |
||||
48 | $GLOBALS['xoopsTpl']->assign('wggithub_icons_url_16', \WGGITHUB_ICONS_URL . '/16'); |
||||
49 | |||||
50 | $filterValue = ''; |
||||
51 | $filterStatus = 0; |
||||
52 | $crRepositories = new \CriteriaCompo(); |
||||
0 ignored issues
–
show
The type
CriteriaCompo 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 ![]() |
|||||
53 | if ('filter' == $op) { |
||||
54 | $operand = Request::getInt('filter_operand', 0); |
||||
55 | $filterField = Request::getString('filter_field', ''); |
||||
56 | $filterValue = Request::getString('filter_value', ''); |
||||
57 | if ('' !== $filterValue) { |
||||
58 | if (Constants::FILTER_OPERAND_EQUAL == $operand) { |
||||
59 | $crRepositories->add(new \Criteria($filterField, $filterValue)); |
||||
0 ignored issues
–
show
The type
Criteria 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 ![]() |
|||||
60 | } elseif (Constants::FILTER_OPERAND_LIKE == $operand) { |
||||
61 | $crRepositories->add(new \Criteria($filterField, "%$filterValue%", 'LIKE')); |
||||
62 | } |
||||
63 | } |
||||
64 | $filterStatus = Request::getInt('filter_status'); |
||||
65 | if ($filterStatus > 0) { |
||||
66 | $crRepositories->add(new \Criteria('repo_status', $filterStatus)); |
||||
67 | } |
||||
68 | } |
||||
69 | $crRepositories->setStart($start); |
||||
70 | $crRepositories->setLimit($limit); |
||||
71 | $repositoriesCount = $repositoriesHandler->getCount($crRepositories); |
||||
72 | $repositoriesAll = $repositoriesHandler->getAll($crRepositories); |
||||
73 | $GLOBALS['xoopsTpl']->assign('repositories_count', $repositoriesCount); |
||||
74 | $GLOBALS['xoopsTpl']->assign('wggithub_url', \WGGITHUB_URL); |
||||
75 | $GLOBALS['xoopsTpl']->assign('wggithub_upload_url', \WGGITHUB_UPLOAD_URL); |
||||
76 | // Table view repositories |
||||
77 | if ($repositoriesCount > 0) { |
||||
78 | foreach (\array_keys($repositoriesAll) as $i) { |
||||
79 | $repository = $repositoriesAll[$i]->getValuesRepositories(); |
||||
80 | $GLOBALS['xoopsTpl']->append('repositories_list', $repository); |
||||
81 | unset($repository); |
||||
82 | } |
||||
83 | // Display Navigation |
||||
84 | if ($repositoriesCount > $limit) { |
||||
85 | include_once \XOOPS_ROOT_PATH . '/class/pagenav.php'; |
||||
0 ignored issues
–
show
|
|||||
86 | $pagenav = new \XoopsPageNav($repositoriesCount, $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 ![]() |
|||||
87 | $GLOBALS['xoopsTpl']->assign('pagenav', $pagenav->renderNav(4)); |
||||
88 | } |
||||
89 | } else { |
||||
90 | if ('filter' == $op) { |
||||
91 | $GLOBALS['xoopsTpl']->assign('noData', \_AM_WGGITHUB_THEREARENT_REPOSITORIES_FILTER); |
||||
92 | } else { |
||||
93 | $GLOBALS['xoopsTpl']->assign('noData', \_AM_WGGITHUB_THEREARENT_REPOSITORIES); |
||||
94 | } |
||||
95 | } |
||||
96 | $form = $repositoriesHandler->getFormFilterRepos(false, $start, $limit, $filterValue, $filterStatus); |
||||
97 | $GLOBALS['xoopsTpl']->assign('formFilter', $form->render()); |
||||
98 | break; |
||||
99 | case 'save': |
||||
100 | // Security Check |
||||
101 | if (!$GLOBALS['xoopsSecurity']->check()) { |
||||
102 | \redirect_header('repositories.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
![]() |
|||||
103 | } |
||||
104 | if ($repoId > 0) { |
||||
105 | $repositoriesObj = $repositoriesHandler->get($repoId); |
||||
106 | } else { |
||||
107 | $repositoriesObj = $repositoriesHandler->create(); |
||||
108 | } |
||||
109 | // Set Vars |
||||
110 | $repositoriesObj->setVar('repo_nodeid', Request::getString('repo_nodeid', '')); |
||||
111 | $repositoriesObj->setVar('repo_user', Request::getString('repo_user', '')); |
||||
112 | $repositoriesObj->setVar('repo_name', Request::getString('repo_name', '')); |
||||
113 | $repositoriesObj->setVar('repo_fullname', Request::getString('repo_fullname', '')); |
||||
114 | $repositoryCreatedatObj = \DateTime::createFromFormat(_SHORTDATESTRING, Request::getString('repo_createdat')); |
||||
0 ignored issues
–
show
|
|||||
115 | $repositoriesObj->setVar('repo_createdat', $repositoryCreatedatObj->getTimestamp()); |
||||
116 | $repositoryUpdatedatObj = \DateTime::createFromFormat(_SHORTDATESTRING, Request::getString('repo_updatedat')); |
||||
117 | $repositoriesObj->setVar('repo_updatedat', $repositoryUpdatedatObj->getTimestamp()); |
||||
118 | $repositoriesObj->setVar('repo_htmlurl', Request::getString('repo_htmlurl', '')); |
||||
119 | $repositoriesObj->setVar('repo_prerelease', Request::getInt('repo_prerelease', 0)); |
||||
120 | $repositoriesObj->setVar('repo_release', Request::getInt('repo_release', 0)); |
||||
121 | $repositoriesObj->setVar('repo_status', Request::getInt('repo_status', 0)); |
||||
122 | $repositoryDatecreatedObj = \DateTime::createFromFormat(_SHORTDATESTRING, Request::getString('repo_datecreated')); |
||||
123 | $repositoriesObj->setVar('repo_datecreated', $repositoryDatecreatedObj->getTimestamp()); |
||||
124 | $repositoriesObj->setVar('repo_submitter', Request::getInt('repo_submitter', 0)); |
||||
125 | // Insert Data |
||||
126 | if ($repositoriesHandler->insert($repositoriesObj)) { |
||||
127 | \redirect_header('repositories.php?op=list&start=' . $start . '&limit=' . $limit, 2, \_AM_WGGITHUB_FORM_OK); |
||||
128 | } |
||||
129 | // Get Form |
||||
130 | $GLOBALS['xoopsTpl']->assign('error', $repositoriesObj->getHtmlErrors()); |
||||
131 | $form = $repositoriesObj->getFormRepositories(false, $start, $limit); |
||||
132 | $GLOBALS['xoopsTpl']->assign('form', $form->render()); |
||||
133 | break; |
||||
134 | case 'edit': |
||||
135 | $templateMain = 'wggithub_admin_repositories.tpl'; |
||||
136 | $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('repositories.php')); |
||||
137 | $adminObject->addItemButton(\_AM_WGGITHUB_REPOSITORIES_LIST, 'repositories.php', 'list'); |
||||
138 | $GLOBALS['xoopsTpl']->assign('buttons', $adminObject->displayButton('left')); |
||||
139 | // Get Form |
||||
140 | $repositoriesObj = $repositoriesHandler->get($repoId); |
||||
141 | $form = $repositoriesObj->getFormRepositories(false, $start, $limit); |
||||
142 | $GLOBALS['xoopsTpl']->assign('form', $form->render()); |
||||
143 | break; |
||||
144 | case 'delete': |
||||
145 | $templateMain = 'wggithub_admin_repositories.tpl'; |
||||
146 | $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('repositories.php')); |
||||
147 | $repositoriesObj = $repositoriesHandler->get($repoId); |
||||
148 | $repoName = $repositoriesObj->getVar('repo_name'); |
||||
149 | if (isset($_REQUEST['ok']) && 1 == $_REQUEST['ok']) { |
||||
150 | if (!$GLOBALS['xoopsSecurity']->check()) { |
||||
151 | \redirect_header('repositories.php', 3, \implode(', ', $GLOBALS['xoopsSecurity']->getErrors())); |
||||
152 | } |
||||
153 | if ($repositoriesHandler->delete($repositoriesObj)) { |
||||
154 | \redirect_header('repositories.php', 3, \_AM_WGGITHUB_FORM_DELETE_OK); |
||||
155 | } else { |
||||
156 | $GLOBALS['xoopsTpl']->assign('error', $repositoriesObj->getHtmlErrors()); |
||||
157 | } |
||||
158 | } else { |
||||
159 | $customConfirm = new Common\Confirm( |
||||
160 | ['ok' => 1, 'repo_id' => $repoId, 'op' => 'delete'], |
||||
161 | $_SERVER['REQUEST_URI'], |
||||
162 | \sprintf(\_AM_WGGITHUB_FORM_SURE_DELETE, $repositoriesObj->getVar('repo_fullname'))); |
||||
163 | $form = $customConfirm->getFormConfirm(); |
||||
164 | $GLOBALS['xoopsTpl']->assign('form', $form->render()); |
||||
165 | } |
||||
166 | break; |
||||
167 | case 'change_yn': |
||||
168 | if ($repoId > 0) { |
||||
169 | $repositoriesObj = $repositoriesHandler->get($repoId); |
||||
170 | $repositoriesObj->setVar(Request::getString('field'), Request::getInt('value', 0)); |
||||
171 | // Insert Data |
||||
172 | if ($repositoriesHandler->insert($repositoriesObj, true)) { |
||||
173 | \redirect_header('repositories.php?op=list&start=' . $start . '&limit=' . $limit, 2, \_AM_WGGITHUB_FORM_OK); |
||||
174 | } |
||||
175 | } |
||||
176 | break; |
||||
177 | } |
||||
178 | require __DIR__ . '/footer.php'; |
||||
179 |
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