ggoffy /
wggithub
| 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 | $relId = Request::getInt('rel_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 | switch ($op) {
|
||||
| 38 | case 'list': |
||||
| 39 | default: |
||||
| 40 | // Define Stylesheet |
||||
| 41 | $GLOBALS['xoTheme']->addStylesheet($style, null); |
||||
| 42 | $templateMain = 'wggithub_admin_releases.tpl'; |
||||
| 43 | $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('releases.php'));
|
||||
| 44 | |||||
| 45 | $filterValue = ''; |
||||
| 46 | $crReleases = 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 Loading history...
|
|||||
| 47 | if ('filter' == $op) {
|
||||
| 48 | $operand = Request::getInt('filter_operand', 0);
|
||||
| 49 | $filterField = Request::getString('filter_field', '');
|
||||
| 50 | $filterValue = Request::getString('filter_value', 'none');
|
||||
| 51 | if (Constants::FILTER_OPERAND_EQUAL == $operand) {
|
||||
| 52 | $crReleases->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 Loading history...
|
|||||
| 53 | } elseif (Constants::FILTER_OPERAND_LIKE == $operand) {
|
||||
| 54 | $crReleases->add(new \Criteria($filterField, "%$filterValue%", 'LIKE')); |
||||
| 55 | } |
||||
| 56 | } |
||||
| 57 | $crReleases->setStart($start); |
||||
| 58 | $crReleases->setLimit($limit); |
||||
| 59 | $releasesCount = $releasesHandler->getCount($crReleases); |
||||
| 60 | $releasesAll = $releasesHandler->getAll($crReleases); |
||||
| 61 | $GLOBALS['xoopsTpl']->assign('releases_count', $releasesCount);
|
||||
| 62 | $GLOBALS['xoopsTpl']->assign('wggithub_url', \WGGITHUB_URL);
|
||||
| 63 | $GLOBALS['xoopsTpl']->assign('wggithub_upload_url', \WGGITHUB_UPLOAD_URL);
|
||||
| 64 | // Table view releases |
||||
| 65 | if ($releasesCount > 0) {
|
||||
| 66 | foreach (\array_keys($releasesAll) as $i) {
|
||||
| 67 | $release = $releasesAll[$i]->getValuesReleases(); |
||||
| 68 | $GLOBALS['xoopsTpl']->append('releases_list', $release);
|
||||
| 69 | unset($release); |
||||
| 70 | } |
||||
| 71 | // Display Navigation |
||||
| 72 | if ($releasesCount > $limit) {
|
||||
| 73 | include_once \XOOPS_ROOT_PATH . '/class/pagenav.php'; |
||||
|
0 ignored issues
–
show
|
|||||
| 74 | $pagenav = new \XoopsPageNav($releasesCount, $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 Loading history...
|
|||||
| 75 | $GLOBALS['xoopsTpl']->assign('pagenav', $pagenav->renderNav(4));
|
||||
| 76 | } |
||||
| 77 | } else {
|
||||
| 78 | if ('filter' == $op) {
|
||||
| 79 | $GLOBALS['xoopsTpl']->assign('noData', \_AM_WGGITHUB_THEREARENT_RELEASES_FILTER);
|
||||
| 80 | } else {
|
||||
| 81 | $GLOBALS['xoopsTpl']->assign('noData', \_AM_WGGITHUB_THEREARENT_RELEASES);
|
||||
| 82 | } |
||||
| 83 | } |
||||
| 84 | $form = $releasesHandler->getFormFilterReleases(false, $start, $limit, $filterValue); |
||||
| 85 | $GLOBALS['xoopsTpl']->assign('formFilter', $form->render());
|
||||
| 86 | break; |
||||
| 87 | case 'save': |
||||
| 88 | // Security Check |
||||
| 89 | if (!$GLOBALS['xoopsSecurity']->check()) {
|
||||
| 90 | \redirect_header('releases.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
Loading history...
|
|||||
| 91 | } |
||||
| 92 | if ($relId > 0) {
|
||||
| 93 | $releasesObj = $releasesHandler->get($relId); |
||||
| 94 | } else {
|
||||
| 95 | $releasesObj = $releasesHandler->create(); |
||||
| 96 | } |
||||
| 97 | // Set Vars |
||||
| 98 | $releasesObj->setVar('rel_repoid', Request::getInt('rel_repoid', 0));
|
||||
| 99 | $releasesObj->setVar('rel_type', Request::getInt('rel_type', 0));
|
||||
| 100 | $releasesObj->setVar('rel_name', Request::getString('rel_name', ''));
|
||||
| 101 | $releasePublishedatObj = \DateTime::createFromFormat(_SHORTDATESTRING, Request::getString('rel_publishedat'));
|
||||
|
0 ignored issues
–
show
|
|||||
| 102 | $releasesObj->setVar('rel_publishedat', $releasePublishedatObj->getTimestamp());
|
||||
| 103 | $releasesObj->setVar('rel_tarballurl', Request::getString('rel_tarballurl', ''));
|
||||
| 104 | $releasesObj->setVar('rel_zipballurl', Request::getString('rel_zipballurl', ''));
|
||||
| 105 | $releaseDatecreatedObj = \DateTime::createFromFormat(_SHORTDATESTRING, Request::getString('rel_datecreated'));
|
||||
| 106 | $releasesObj->setVar('rel_datecreated', $releaseDatecreatedObj->getTimestamp());
|
||||
| 107 | $releasesObj->setVar('rel_submitter', Request::getInt('rel_submitter', 0));
|
||||
| 108 | // Insert Data |
||||
| 109 | if ($releasesHandler->insert($releasesObj)) {
|
||||
| 110 | \redirect_header('releases.php?op=list&start=' . $start . '&limit=' . $limit, 2, \_AM_WGGITHUB_FORM_OK);
|
||||
| 111 | } |
||||
| 112 | // Get Form |
||||
| 113 | $GLOBALS['xoopsTpl']->assign('error', $releasesObj->getHtmlErrors());
|
||||
| 114 | $form = $releasesObj->getFormReleases(false, $start, $limit); |
||||
| 115 | $GLOBALS['xoopsTpl']->assign('form', $form->render());
|
||||
| 116 | break; |
||||
| 117 | case 'edit': |
||||
| 118 | $templateMain = 'wggithub_admin_releases.tpl'; |
||||
| 119 | $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('releases.php'));
|
||||
| 120 | $adminObject->addItemButton(\_AM_WGGITHUB_RELEASES_LIST, 'releases.php', 'list'); |
||||
| 121 | $GLOBALS['xoopsTpl']->assign('buttons', $adminObject->displayButton('left'));
|
||||
| 122 | // Get Form |
||||
| 123 | $releasesObj = $releasesHandler->get($relId); |
||||
| 124 | $form = $releasesObj->getFormReleases(false, $start, $limit); |
||||
| 125 | $GLOBALS['xoopsTpl']->assign('form', $form->render());
|
||||
| 126 | break; |
||||
| 127 | case 'delete': |
||||
| 128 | $templateMain = 'wggithub_admin_releases.tpl'; |
||||
| 129 | $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('releases.php'));
|
||||
| 130 | $releasesObj = $releasesHandler->get($relId); |
||||
| 131 | if (isset($_REQUEST['ok']) && 1 == $_REQUEST['ok']) {
|
||||
| 132 | if (!$GLOBALS['xoopsSecurity']->check()) {
|
||||
| 133 | \redirect_header('releases.php', 3, \implode(', ', $GLOBALS['xoopsSecurity']->getErrors()));
|
||||
| 134 | } |
||||
| 135 | if ($releasesHandler->delete($releasesObj)) {
|
||||
| 136 | \redirect_header('releases.php', 3, \_AM_WGGITHUB_FORM_DELETE_OK);
|
||||
| 137 | } else {
|
||||
| 138 | $GLOBALS['xoopsTpl']->assign('error', $releasesObj->getHtmlErrors());
|
||||
| 139 | } |
||||
| 140 | } else {
|
||||
| 141 | $repositoriesObj = $repositoriesHandler->get($releasesObj->getVar('rel_repoid'));
|
||||
| 142 | $customConfirm = new Common\Confirm( |
||||
| 143 | ['ok' => 1, 'rel_id' => $relId, 'op' => 'delete'], |
||||
| 144 | $_SERVER['REQUEST_URI'], |
||||
| 145 | \sprintf(\_AM_WGGITHUB_FORM_SURE_DELETE, $repositoriesObj->getVar('repo_name') . ' - ' . $releasesObj->getVar('rel_name')));
|
||||
| 146 | $form = $customConfirm->getFormConfirm(); |
||||
| 147 | $GLOBALS['xoopsTpl']->assign('form', $form->render());
|
||||
| 148 | } |
||||
| 149 | break; |
||||
| 150 | } |
||||
| 151 | require __DIR__ . '/footer.php'; |
||||
| 152 |
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