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
|
|
|
|
29
|
|
|
/**
|
30
|
|
|
* Class Object Handler Settings
|
31
|
|
|
*/
|
32
|
|
|
class SettingsHandler extends \XoopsPersistableObjectHandler
|
|
|
|
|
33
|
|
|
{
|
34
|
|
|
/**
|
35
|
|
|
* Constructor
|
36
|
|
|
*
|
37
|
|
|
* @param \XoopsDatabase $db
|
38
|
|
|
*/
|
39
|
|
|
public function __construct(\XoopsDatabase $db)
|
|
|
|
|
40
|
|
|
{
|
41
|
|
|
parent::__construct($db, 'wggithub_settings', Settings::class, 'set_id', 'set_token');
|
42
|
|
|
}
|
43
|
|
|
|
44
|
|
|
/**
|
45
|
|
|
* @param bool $isNew
|
46
|
|
|
*
|
47
|
|
|
* @return object
|
48
|
|
|
*/
|
49
|
|
|
public function create($isNew = true)
|
50
|
|
|
{
|
51
|
|
|
return parent::create($isNew);
|
52
|
|
|
}
|
53
|
|
|
|
54
|
|
|
/**
|
55
|
|
|
* retrieve a field
|
56
|
|
|
*
|
57
|
|
|
* @param int $i field id
|
58
|
|
|
* @param null fields
|
|
|
|
|
59
|
|
|
* @return mixed reference to the {@link Get} object
|
60
|
|
|
*/
|
61
|
|
|
public function get($i = null, $fields = null)
|
62
|
|
|
{
|
63
|
|
|
return parent::get($i, $fields);
|
64
|
|
|
}
|
65
|
|
|
|
66
|
|
|
/**
|
67
|
|
|
* get inserted id
|
68
|
|
|
*
|
69
|
|
|
* @param null
|
70
|
|
|
* @return int reference to the {@link Get} object
|
71
|
|
|
*/
|
72
|
|
|
public function getInsertId()
|
73
|
|
|
{
|
74
|
|
|
return $this->db->getInsertId();
|
75
|
|
|
}
|
76
|
|
|
|
77
|
|
|
/**
|
78
|
|
|
* Get Count Settings in the database
|
79
|
|
|
* @param int $start
|
80
|
|
|
* @param int $limit
|
81
|
|
|
* @param string $sort
|
82
|
|
|
* @param string $order
|
83
|
|
|
* @return int
|
84
|
|
|
*/
|
85
|
|
|
public function getCountSettings($start = 0, $limit = 0, $sort = 'set_id ASC, set_token', $order = 'ASC')
|
86
|
|
|
{
|
87
|
|
|
$crCountSettings = new \CriteriaCompo();
|
|
|
|
|
88
|
|
|
$crCountSettings = $this->getSettingsCriteria($crCountSettings, $start, $limit, $sort, $order);
|
89
|
|
|
return $this->getCount($crCountSettings);
|
90
|
|
|
}
|
91
|
|
|
|
92
|
|
|
/**
|
93
|
|
|
* Get All Settings in the database
|
94
|
|
|
* @param int $start
|
95
|
|
|
* @param int $limit
|
96
|
|
|
* @param string $sort
|
97
|
|
|
* @param string $order
|
98
|
|
|
* @return array
|
99
|
|
|
*/
|
100
|
|
|
public function getAllSettings($start = 0, $limit = 0, $sort = 'set_id ASC, set_token', $order = 'ASC')
|
101
|
|
|
{
|
102
|
|
|
$crAllSettings = new \CriteriaCompo();
|
103
|
|
|
$crAllSettings = $this->getSettingsCriteria($crAllSettings, $start, $limit, $sort, $order);
|
104
|
|
|
return $this->getAll($crAllSettings);
|
105
|
|
|
}
|
106
|
|
|
|
107
|
|
|
/**
|
108
|
|
|
* Get Criteria Settings
|
109
|
|
|
* @param $crSettings
|
110
|
|
|
* @param int $start
|
111
|
|
|
* @param int $limit
|
112
|
|
|
* @param string $sort
|
113
|
|
|
* @param string $order
|
114
|
|
|
* @return int
|
115
|
|
|
*/
|
116
|
|
|
private function getSettingsCriteria($crSettings, $start, $limit, $sort, $order)
|
117
|
|
|
{
|
118
|
|
|
$crSettings->setStart($start);
|
119
|
|
|
$crSettings->setLimit($limit);
|
120
|
|
|
$crSettings->setSort($sort);
|
121
|
|
|
$crSettings->setOrder($order);
|
122
|
|
|
return $crSettings;
|
123
|
|
|
}
|
124
|
|
|
|
125
|
|
|
/**
|
126
|
|
|
* Get Primary Setting
|
127
|
|
|
* @return array
|
128
|
|
|
*/
|
129
|
|
|
public function getPrimarySetting()
|
130
|
|
|
{
|
131
|
|
|
$setting = [];
|
132
|
|
|
$crSettings = new \CriteriaCompo();
|
133
|
|
|
$crSettings->add(new \Criteria('set_primary', 1));
|
|
|
|
|
134
|
|
|
$crSettings->setLimit(1);
|
135
|
|
|
$settingsAll = $this->getAll($crSettings);
|
136
|
|
|
foreach (\array_keys($settingsAll) as $i) {
|
137
|
|
|
$setting['user'] = $settingsAll[$i]->getVar('set_username');
|
138
|
|
|
$setting['token'] = $settingsAll[$i]->getVar('set_token');
|
139
|
|
|
}
|
140
|
|
|
|
141
|
|
|
return $setting;
|
142
|
|
|
}
|
143
|
|
|
|
144
|
|
|
/**
|
145
|
|
|
* Set given setting as primary
|
146
|
|
|
* @param $setId
|
147
|
|
|
* @return bool
|
148
|
|
|
*/
|
149
|
|
|
public function setPrimarySetting($setId)
|
150
|
|
|
{
|
151
|
|
|
$helper = \XoopsModules\Wggithub\Helper::getInstance();
|
152
|
|
|
$settingsObj = null;
|
153
|
|
|
$settingsHandler = $helper->getHandler('Settings');
|
154
|
|
|
if (isset($setId)) {
|
155
|
|
|
$settingsObj = $settingsHandler->get($setId);
|
156
|
|
|
} else {
|
157
|
|
|
\redirect_header('settings.php', 3, 'missing Id');
|
|
|
|
|
158
|
|
|
}
|
159
|
|
|
|
160
|
|
|
// reset all
|
161
|
|
|
$strSQL = 'UPDATE ' . $GLOBALS['xoopsDB']->prefix('wggithub_settings') . ' SET ' . $GLOBALS['xoopsDB']->prefix('wggithub_settings') . '.set_primary = 0';
|
162
|
|
|
$GLOBALS['xoopsDB']->queryF($strSQL);
|
163
|
|
|
// Set Vars
|
164
|
|
|
$settingsObj->setVar('set_primary', 1);
|
165
|
|
|
// Insert Data
|
166
|
|
|
if ($settingsHandler->insert($settingsObj)) {
|
167
|
|
|
return true;
|
168
|
|
|
}
|
169
|
|
|
return false;
|
170
|
|
|
|
171
|
|
|
}
|
172
|
|
|
}
|
173
|
|
|
|
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