2021-08-17 21:25:45 +00:00
|
|
|
<?php
|
2021-09-02 19:43:35 +00:00
|
|
|
/**
|
|
|
|
* @brief licenseBootstrap, a plugin for Dotclear 2
|
2022-11-20 21:36:32 +00:00
|
|
|
*
|
2021-09-02 19:43:35 +00:00
|
|
|
* @package Dotclear
|
|
|
|
* @subpackage Plugin
|
2022-11-20 21:36:32 +00:00
|
|
|
*
|
2021-09-02 19:43:35 +00:00
|
|
|
* @author Jean-Christian Denis
|
2022-11-20 21:36:32 +00:00
|
|
|
*
|
2021-09-02 19:43:35 +00:00
|
|
|
* @copyright Jean-Christian Denis
|
|
|
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
|
|
|
*/
|
2021-08-17 21:25:45 +00:00
|
|
|
if (!defined('DC_CONTEXT_ADMIN')) {
|
2021-08-17 21:46:17 +00:00
|
|
|
return null;
|
2021-08-17 21:25:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
dcPage::checkSuper();
|
|
|
|
|
|
|
|
# Queries
|
2022-11-20 21:36:32 +00:00
|
|
|
$action = $_POST['action'] ?? '';
|
|
|
|
$type = isset($_POST['type']) && in_array($_POST['type'], ['plugins', 'themes']) ? $_POST['type'] : '';
|
2021-08-17 21:25:45 +00:00
|
|
|
|
|
|
|
# Settings
|
2022-12-22 21:28:04 +00:00
|
|
|
$s = dcCore::app()->blog->settings->addNamespace(basename(__DIR__));
|
2021-08-17 21:25:45 +00:00
|
|
|
|
|
|
|
# Modules
|
2022-11-20 21:36:32 +00:00
|
|
|
if (!isset(dcCore::app()->themes)) {
|
|
|
|
dcCore::app()->themes = new dcThemes();
|
|
|
|
dcCore::app()->themes->loadModules(dcCore::app()->blog->themes_path, null);
|
2021-08-17 21:25:45 +00:00
|
|
|
}
|
2022-11-20 21:36:32 +00:00
|
|
|
$themes = dcCore::app()->themes;
|
|
|
|
$plugins = dcCore::app()->plugins;
|
2021-08-17 21:25:45 +00:00
|
|
|
|
|
|
|
# Rights
|
2022-11-20 21:36:32 +00:00
|
|
|
$is_editable = !empty($type)
|
|
|
|
&& !empty($_POST['modules'])
|
2021-08-17 21:46:17 +00:00
|
|
|
&& is_array($_POST['modules']);
|
2021-08-17 21:25:45 +00:00
|
|
|
|
|
|
|
# Actions
|
2022-11-20 21:36:32 +00:00
|
|
|
try {
|
2021-08-17 21:46:17 +00:00
|
|
|
# Add license to modules
|
|
|
|
if ($action == 'addlicense' && $is_editable) {
|
|
|
|
$modules = array_keys($_POST['modules']);
|
2021-08-17 21:25:45 +00:00
|
|
|
|
2021-08-17 21:46:17 +00:00
|
|
|
foreach ($modules as $id) {
|
|
|
|
if (!${$type}->moduleExists($id)) {
|
|
|
|
throw new Exception('No such module');
|
|
|
|
}
|
2021-08-17 21:25:45 +00:00
|
|
|
|
2022-11-20 21:36:32 +00:00
|
|
|
$module = ${$type}->getModules($id);
|
|
|
|
$module['id'] = $id;
|
2021-08-17 21:46:17 +00:00
|
|
|
$module['type'] = $type == 'themes' ? 'theme' : 'plugin';
|
2021-08-17 21:25:45 +00:00
|
|
|
|
2022-11-20 21:36:32 +00:00
|
|
|
licenseBootstrap::addLicense($module);
|
2021-08-17 21:46:17 +00:00
|
|
|
}
|
2021-08-17 21:25:45 +00:00
|
|
|
|
2022-11-20 21:36:32 +00:00
|
|
|
dcAdminNotices::addSuccessNotice(
|
2021-08-17 21:46:17 +00:00
|
|
|
__('License successfully added.')
|
|
|
|
);
|
2022-11-20 21:36:32 +00:00
|
|
|
http::redirect(
|
|
|
|
empty($_POST['redir']) ?
|
|
|
|
dcCore::app()->admin->getPageURL() : $_POST['redir']
|
2021-08-17 21:46:17 +00:00
|
|
|
);
|
|
|
|
}
|
2022-11-20 21:36:32 +00:00
|
|
|
} catch(Exception $e) {
|
|
|
|
dcCore::app()->error->add($e->getMessage());
|
2021-08-17 21:25:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# Display
|
2022-11-20 21:36:32 +00:00
|
|
|
echo
|
2021-08-17 21:46:17 +00:00
|
|
|
'<html><head><title>' . __('License bootstrap') . '</title>' .
|
|
|
|
dcPage::jsPageTabs() .
|
2022-12-22 21:28:04 +00:00
|
|
|
dcPage::jsModuleLoad(basename(__DIR__) . '/js/licensebootstrap.js') .
|
2021-08-17 21:25:45 +00:00
|
|
|
|
|
|
|
# --BEHAVIOR-- licenseBootstrapAdminHeader
|
2022-11-20 21:36:32 +00:00
|
|
|
dcCore::app()->callBehavior('licenseBootstrapAdminHeader') .
|
2021-08-17 21:25:45 +00:00
|
|
|
|
2021-08-17 21:46:17 +00:00
|
|
|
'</head><body>' .
|
2021-08-17 21:25:45 +00:00
|
|
|
|
|
|
|
dcPage::breadcrumb(
|
2022-11-20 21:36:32 +00:00
|
|
|
[
|
|
|
|
__('Plugins') => '',
|
|
|
|
__('License bootstrap') => '',
|
|
|
|
]
|
2021-08-17 21:46:17 +00:00
|
|
|
) .
|
2021-08-17 21:25:45 +00:00
|
|
|
dcPage::notices();
|
|
|
|
|
|
|
|
libLicenseBootstrap::modules(
|
2021-08-17 21:46:17 +00:00
|
|
|
$plugins->getModules(),
|
|
|
|
'plugins',
|
|
|
|
__('Installed plugins')
|
2021-08-17 21:25:45 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
libLicenseBootstrap::modules(
|
2021-08-17 21:46:17 +00:00
|
|
|
$themes->getModules(),
|
|
|
|
'themes',
|
|
|
|
__('Installed themes')
|
2021-08-17 21:25:45 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
dcPage::helpBlock('licenseBootstrap');
|
|
|
|
|
2022-11-20 21:36:32 +00:00
|
|
|
echo
|
|
|
|
'</body></html>';
|