Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Q
question2answer
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
outils
question2answer
Commits
41939057
Commit
41939057
authored
Jul 31, 2020
by
Scott
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'pr/769' into dev
parents
3be51d3e
8f65dc18
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
60 additions
and
7 deletions
+60
-7
qa-admin.js
qa-content/qa-admin.js
+7
-0
qa-lang-admin.php
qa-include/lang/qa-lang-admin.php
+1
-0
Plugins.php
qa-src/Controllers/Admin/Plugins.php
+27
-7
PluginManager.php
qa-src/Plugin/PluginManager.php
+25
-0
No files found.
qa-content/qa-admin.js
View file @
41939057
...
...
@@ -164,6 +164,13 @@ function qa_version_check(uri, version, elem, isCore)
);
}
function
qa_version_check_array
(
versionChecks
)
{
for
(
var
i
=
0
;
i
<
versionChecks
.
length
;
i
++
)
{
qa_version_check
(
versionChecks
[
i
].
uri
,
versionChecks
[
i
].
version
,
versionChecks
[
i
].
elem
,
false
)
}
}
function
qa_get_enabled_plugins_hashes
()
{
var
hashes
=
[];
...
...
qa-include/lang/qa-lang-admin.php
View file @
41939057
...
...
@@ -273,6 +273,7 @@ return array(
'users_registered'
=>
'Registered users:'
,
'users_title'
=>
'Users'
,
'users_voted'
=>
'Users who voted:'
,
'version_check'
=>
'Check for updates'
,
'version_get_x'
=>
'get ^'
,
'version_latest'
=>
'latest'
,
'version_latest_unknown'
=>
'latest unknown'
,
...
...
qa-src/Controllers/Admin/Plugins.php
View file @
41939057
...
...
@@ -68,7 +68,9 @@ class Plugins extends BaseController
$enabledPluginHashesArray
=
explode
(
';'
,
$enabledPluginHashes
);
$pluginDirectories
=
array_keys
(
array_intersect
(
$pluginHashes
,
$enabledPluginHashesArray
));
$pluginManager
->
setEnabledPlugins
(
$pluginDirectories
);
qa_redirect
(
'admin/plugins'
);
}
elseif
(
qa_clicked
(
'doversioncheck'
))
{
$pluginManager
->
performUpdateCheck
(
0
);
qa_redirect
(
'admin/plugins'
);
}
}
...
...
@@ -143,6 +145,9 @@ class Plugins extends BaseController
qa_sort_by
(
$sortedPluginFiles
,
'name'
);
$versionChecks
=
array
();
$shouldCheckForUpdate
=
$pluginManager
->
shouldCheckForUpdate
();
$pluginIndex
=
-
1
;
foreach
(
$sortedPluginFiles
as
$pluginDirectory
=>
$metadata
)
{
$pluginIndex
++
;
...
...
@@ -169,17 +174,20 @@ class Plugins extends BaseController
$authorhtml
=
'<a href="'
.
qa_html
(
$metadata
[
'author_uri'
])
.
'">'
.
$authorhtml
.
'</a>'
;
$authorhtml
=
qa_lang_html_sub
(
'main/by_x'
,
$authorhtml
);
}
else
}
else
{
$authorhtml
=
''
;
}
if
(
$metaver
&&
isset
(
$metadata
[
'update_uri'
])
&&
strlen
(
$metadata
[
'update_uri'
]))
{
if
(
$
shouldCheckForUpdate
&&
$
metaver
&&
isset
(
$metadata
[
'update_uri'
])
&&
strlen
(
$metadata
[
'update_uri'
]))
{
$elementid
=
'version_check_'
.
md5
(
$pluginDirectory
);
$
updatehtml
=
'(<span id="'
.
$elementid
.
'">...</span>)'
;
$qa_content
[
'script_onloads'
][]
=
array
(
"qa_version_check("
.
qa_js
(
$metadata
[
'update_uri'
])
.
", "
.
qa_js
(
$metadata
[
'version'
],
true
)
.
", "
.
qa_js
(
$elementid
)
.
", false);"
$
versionChecks
[]
=
array
(
'uri'
=>
$metadata
[
'update_uri'
],
'version'
=>
$metadata
[
'version'
],
'elem'
=>
$elementid
,
);
$updatehtml
=
'(<span id="'
.
$elementid
.
'">...</span>)'
;
}
else
{
$updatehtml
=
''
;
}
...
...
@@ -250,6 +258,14 @@ class Plugins extends BaseController
}
}
}
if
(
$shouldCheckForUpdate
)
{
$pluginManager
->
performUpdateCheck
();
$qa_content
[
'script_onloads'
][]
=
array
(
sprintf
(
'qa_version_check_array(%s);'
,
json_encode
(
$versionChecks
)),
);
}
}
$qa_content
[
'navigation'
][
'sub'
]
=
qa_admin_sub_navigation
();
...
...
@@ -264,6 +280,10 @@ class Plugins extends BaseController
'tags'
=>
'name="dosave"'
,
'label'
=>
qa_lang_html
(
'admin/save_options_button'
),
),
'doversioncheck'
=>
array
(
'tags'
=>
'name="doversioncheck"'
,
'label'
=>
qa_lang_html
(
'admin/version_check'
),
),
),
'hidden'
=>
array
(
...
...
qa-src/Plugin/PluginManager.php
View file @
41939057
...
...
@@ -25,6 +25,8 @@ class PluginManager
{
const
PLUGIN_DELIMITER
=
';'
;
const
OPT_ENABLED_PLUGINS
=
'enabled_plugins'
;
const
OPT_LAST_UPDATE_CHECK
=
'last_plugin_update_check'
;
const
NUMBER_OF_DAYS_TO_CHECK_FOR_UPDATE
=
14
;
private
$loadBeforeDbInit
=
array
();
private
$loadAfterDbInit
=
array
();
...
...
@@ -180,4 +182,27 @@ class PluginManager
$this
->
setEnabledPluginsOption
(
$finalEnabledPlugins
);
}
/**
* @return bool
*/
public
function
shouldCheckForUpdate
()
{
$lastUpdateCheck
=
(
int
)
qa_opt
(
self
::
OPT_LAST_UPDATE_CHECK
);
$currentTime
=
(
int
)
qa_opt
(
'db_time'
);
return
$currentTime
-
$lastUpdateCheck
>
self
::
NUMBER_OF_DAYS_TO_CHECK_FOR_UPDATE
*
24
*
60
*
60
;
}
/**
* @param int|null $time
*/
public
function
performUpdateCheck
(
$time
=
null
)
{
if
(
$time
===
null
)
{
$time
=
time
();
}
qa_opt
(
self
::
OPT_LAST_UPDATE_CHECK
,
$time
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment