|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace XoopsModules\Wggithub; |
|
4
|
|
|
|
|
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
|
|
|
|
|
10
|
|
|
This program is distributed in the hope that it will be useful, |
|
11
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
13
|
|
|
*/ |
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* wgGitHub module for xoops |
|
17
|
|
|
* |
|
18
|
|
|
* @copyright 2020 XOOPS Project (https://xooops.org) |
|
19
|
|
|
* @license GPL 2.0 or later |
|
20
|
|
|
* @package wggithub |
|
21
|
|
|
* @since 1.0 |
|
22
|
|
|
* @min_xoops 2.5.10 |
|
23
|
|
|
* @author Goffy - XOOPS Development Team - Email:<[email protected]> - Website:<https://wedega.com> |
|
24
|
|
|
*/ |
|
25
|
|
|
|
|
26
|
|
|
use XoopsModules\Wggithub; |
|
27
|
|
|
|
|
28
|
|
|
\defined('XOOPS_ROOT_PATH') || die('Restricted access'); |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* Class Object Logs |
|
32
|
|
|
*/ |
|
33
|
|
|
class Logs extends \XoopsObject |
|
|
|
|
|
|
34
|
|
|
{ |
|
35
|
|
|
/** |
|
36
|
|
|
* Constructor |
|
37
|
|
|
* |
|
38
|
|
|
* @param null |
|
39
|
|
|
*/ |
|
40
|
|
|
public function __construct() |
|
41
|
|
|
{ |
|
42
|
|
|
$this->initVar('log_id', XOBJ_DTYPE_INT); |
|
|
|
|
|
|
43
|
|
|
$this->initVar('log_type', XOBJ_DTYPE_INT); |
|
44
|
|
|
$this->initVar('log_details', XOBJ_DTYPE_TXTBOX); |
|
|
|
|
|
|
45
|
|
|
$this->initVar('log_result', XOBJ_DTYPE_TXTAREA); |
|
|
|
|
|
|
46
|
|
|
$this->initVar('log_datecreated', XOBJ_DTYPE_INT); |
|
47
|
|
|
$this->initVar('log_submitter', XOBJ_DTYPE_INT); |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* @static function &getInstance |
|
52
|
|
|
* |
|
53
|
|
|
* @param null |
|
54
|
|
|
*/ |
|
55
|
|
|
public static function getInstance() |
|
56
|
|
|
{ |
|
57
|
|
|
static $instance = false; |
|
58
|
|
|
if (!$instance) { |
|
59
|
|
|
$instance = new self(); |
|
60
|
|
|
} |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* The new inserted $Id |
|
65
|
|
|
* @return inserted id |
|
|
|
|
|
|
66
|
|
|
*/ |
|
67
|
|
|
public function getNewInsertedIdLogs() |
|
68
|
|
|
{ |
|
69
|
|
|
$newInsertedId = $GLOBALS['xoopsDB']->getInsertId(); |
|
70
|
|
|
return $newInsertedId; |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
/** |
|
74
|
|
|
* @public function getForm |
|
75
|
|
|
* @param bool $action |
|
76
|
|
|
* @return \XoopsThemeForm |
|
77
|
|
|
*/ |
|
78
|
|
|
public function getFormLogs($action = false) |
|
79
|
|
|
{ |
|
80
|
|
|
$helper = \XoopsModules\Wggithub\Helper::getInstance(); |
|
|
|
|
|
|
81
|
|
|
if (!$action) { |
|
82
|
|
|
$action = $_SERVER['REQUEST_URI']; |
|
83
|
|
|
} |
|
84
|
|
|
// Title |
|
85
|
|
|
$title = $this->isNew() ? \sprintf(_AM_WGGITHUB_LOG_ADD) : \sprintf(_AM_WGGITHUB_LOG_EDIT); |
|
86
|
|
|
// Get Theme Form |
|
87
|
|
|
\xoops_load('XoopsFormLoader'); |
|
|
|
|
|
|
88
|
|
|
$form = new \XoopsThemeForm($title, 'form', $action, 'post', true); |
|
|
|
|
|
|
89
|
|
|
$form->setExtra('enctype="multipart/form-data"'); |
|
90
|
|
|
|
|
91
|
|
|
$logTypeSelect = new \XoopsFormSelect(_AM_WGGITHUB_LOG_TYPE, 'log_type', $this->getVar('log_type')); |
|
|
|
|
|
|
92
|
|
|
$logTypeSelect->addOption(Constants::LOG_TYPE_NONE, _AM_WGGITHUB_LOG_TYPE_NONE); |
|
93
|
|
|
$logTypeSelect->addOption(Constants::LOG_TYPE_UPDATE_START, _AM_WGGITHUB_LOG_TYPE_UPDATE_START); |
|
94
|
|
|
$logTypeSelect->addOption(Constants::LOG_TYPE_UPDATE_END, _AM_WGGITHUB_LOG_TYPE_UPDATE_END); |
|
95
|
|
|
$form->addElement($logTypeSelect); |
|
96
|
|
|
// Form Text logDetails |
|
97
|
|
|
$form->addElement(new \XoopsFormText(_AM_WGGITHUB_LOG_DETAILS, 'log_details', 50, 255, $this->getVar('log_details')), true); |
|
|
|
|
|
|
98
|
|
|
// Form Text logResult |
|
99
|
|
|
$form->addElement(new \XoopsFormTextArea(_AM_WGGITHUB_LOG_RESULT, 'log_result', $this->getVar('log_result', 'e'), 4, 47)); |
|
|
|
|
|
|
100
|
|
|
// Form Text Date Select logDatecreated |
|
101
|
|
|
$logDatecreated = $this->isNew() ?: $this->getVar('log_datecreated'); |
|
102
|
|
|
$form->addElement(new \XoopsFormTextDateSelect(_AM_WGGITHUB_LOG_DATECREATED, 'log_datecreated', '', $logDatecreated)); |
|
|
|
|
|
|
103
|
|
|
// Form Select User reqSubmitter |
|
104
|
|
|
$form->addElement(new \XoopsFormSelectUser(_AM_WGGITHUB_LOG_SUBMITTER, 'log_submitter', false, $this->getVar('log_submitter'))); |
|
|
|
|
|
|
105
|
|
|
// To Save |
|
106
|
|
|
$form->addElement(new \XoopsFormHidden('op', 'save')); |
|
|
|
|
|
|
107
|
|
|
$form->addElement(new \XoopsFormButtonTray('', _SUBMIT, 'submit', '', false)); |
|
|
|
|
|
|
108
|
|
|
return $form; |
|
109
|
|
|
} |
|
110
|
|
|
|
|
111
|
|
|
/** |
|
112
|
|
|
* Get Values |
|
113
|
|
|
* @param null $keys |
|
|
|
|
|
|
114
|
|
|
* @param null $format |
|
|
|
|
|
|
115
|
|
|
* @param null $maxDepth |
|
|
|
|
|
|
116
|
|
|
* @return array |
|
117
|
|
|
*/ |
|
118
|
|
|
public function getValuesLogs($keys = null, $format = null, $maxDepth = null) |
|
119
|
|
|
{ |
|
120
|
|
|
$helper = \XoopsModules\Wggithub\Helper::getInstance(); |
|
121
|
|
|
$utility = new \XoopsModules\Wggithub\Utility(); |
|
122
|
|
|
$editorMaxchar = $helper->getConfig('editor_maxchar'); |
|
123
|
|
|
$ret = $this->getValues($keys, $format, $maxDepth); |
|
124
|
|
|
$ret['id'] = $this->getVar('log_id'); |
|
125
|
|
|
$ret['type'] = $this->getVar('log_type'); |
|
126
|
|
|
switch ($ret['type']) { |
|
127
|
|
|
case Constants::LOG_TYPE_NONE: |
|
128
|
|
|
default: |
|
129
|
|
|
$type_text = \_AM_WGGITHUB_LOG_TYPE_NONE; |
|
130
|
|
|
break; |
|
131
|
|
|
case Constants::LOG_TYPE_UPDATE_START: |
|
132
|
|
|
$type_text = \_AM_WGGITHUB_LOG_TYPE_UPDATE_START; |
|
133
|
|
|
break; |
|
134
|
|
|
case Constants::LOG_TYPE_UPDATE_END: |
|
135
|
|
|
$type_text = \_AM_WGGITHUB_LOG_TYPE_UPDATE_END; |
|
136
|
|
|
break; |
|
137
|
|
|
case Constants::LOG_TYPE_REQUEST: |
|
138
|
|
|
$type_text = \_AM_WGGITHUB_LOG_TYPE_REQUEST; |
|
139
|
|
|
break; |
|
140
|
|
|
} |
|
141
|
|
|
$ret['type_text'] = $type_text; |
|
142
|
|
|
$ret['details'] = $this->getVar('log_details'); |
|
143
|
|
|
$ret['result'] = \strip_tags($this->getVar('log_result', 'e')); |
|
144
|
|
|
$ret['result_short'] = $utility::truncateHtml($ret['result'], $editorMaxchar); |
|
145
|
|
|
$ret['datecreated'] = \formatTimestamp($this->getVar('log_datecreated'), 'm'); |
|
|
|
|
|
|
146
|
|
|
$ret['submitter'] = \XoopsUser::getUnameFromId($this->getVar('log_submitter')); |
|
|
|
|
|
|
147
|
|
|
return $ret; |
|
148
|
|
|
} |
|
149
|
|
|
|
|
150
|
|
|
/** |
|
151
|
|
|
* Returns an array representation of the object |
|
152
|
|
|
* |
|
153
|
|
|
* @return array |
|
154
|
|
|
*/ |
|
155
|
|
|
public function toArrayRequests() |
|
156
|
|
|
{ |
|
157
|
|
|
$ret = []; |
|
158
|
|
|
$vars = $this->getVars(); |
|
159
|
|
|
foreach (\array_keys($vars) as $var) { |
|
160
|
|
|
$ret[$var] = $this->getVar('"{$var}"'); |
|
161
|
|
|
} |
|
162
|
|
|
return $ret; |
|
163
|
|
|
} |
|
164
|
|
|
} |
|
165
|
|
|
|
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