2021-08-17 21:25:45 +00:00
|
|
|
<?php
|
2021-09-02 19:43:35 +00:00
|
|
|
/**
|
|
|
|
* @brief licenseBootstrap, a plugin for Dotclear 2
|
|
|
|
*
|
|
|
|
* @package Dotclear
|
|
|
|
* @subpackage Plugin
|
|
|
|
*
|
|
|
|
* @author Jean-Christian Denis
|
|
|
|
*
|
|
|
|
* @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
|
|
|
|
$p_url = 'plugin.php?p=licenseBootstrap';
|
|
|
|
$action = isset($_POST['action']) ? $_POST['action'] : '';
|
2021-08-17 21:46:17 +00:00
|
|
|
$type = isset($_POST['type']) && in_array($_POST['type'], array('plugins', 'themes')) ? $_POST['type'] : '';
|
2021-08-17 21:25:45 +00:00
|
|
|
|
|
|
|
# Settings
|
|
|
|
$core->blog->settings->addNamespace('licenseBootstrap');
|
|
|
|
$s = $core->blog->settings->licenseBootstrap;
|
|
|
|
|
|
|
|
# Modules
|
|
|
|
if (!isset($core->themes)) {
|
2021-08-17 21:46:17 +00:00
|
|
|
$core->themes = new dcThemes($core);
|
|
|
|
$core->themes->loadModules($core->blog->themes_path, null);
|
2021-08-17 21:25:45 +00:00
|
|
|
}
|
|
|
|
$themes = $core->themes;
|
|
|
|
$plugins = $core->plugins;
|
|
|
|
|
|
|
|
# Rights
|
|
|
|
$is_editable =
|
2021-08-17 21:46:17 +00:00
|
|
|
!empty($type)
|
|
|
|
&& !empty($_POST['modules'])
|
|
|
|
&& is_array($_POST['modules']);
|
2021-08-17 21:25:45 +00:00
|
|
|
|
|
|
|
# Actions
|
|
|
|
try
|
|
|
|
{
|
2021-08-17 21:46:17 +00:00
|
|
|
# Add license to modules
|
|
|
|
if ($action == 'addlicense' && $is_editable) {
|
2021-08-17 21:25:45 +00:00
|
|
|
|
2021-08-17 21:46:17 +00:00
|
|
|
$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) {
|
2021-08-17 21:25:45 +00:00
|
|
|
|
2021-08-17 21:46:17 +00:00
|
|
|
if (!${$type}->moduleExists($id)) {
|
|
|
|
throw new Exception('No such module');
|
|
|
|
}
|
2021-08-17 21:25:45 +00:00
|
|
|
|
2021-08-17 21:46:17 +00:00
|
|
|
$module = ${$type}->getModules($id);
|
|
|
|
$module['id'] = $id;
|
|
|
|
$module['type'] = $type == 'themes' ? 'theme' : 'plugin';
|
2021-08-17 21:25:45 +00:00
|
|
|
|
2021-08-17 21:46:17 +00:00
|
|
|
licenseBootstrap::addLicense($core, $module);
|
|
|
|
}
|
2021-08-17 21:25:45 +00:00
|
|
|
|
2021-08-17 21:46:17 +00:00
|
|
|
dcPage::addSuccessNotice(
|
|
|
|
__('License successfully added.')
|
|
|
|
);
|
|
|
|
http::redirect(empty($_POST['redir']) ?
|
|
|
|
$p_url : $_POST['redir']
|
|
|
|
);
|
|
|
|
}
|
2021-08-17 21:25:45 +00:00
|
|
|
}
|
|
|
|
catch(Exception $e) {
|
2021-08-17 21:46:17 +00:00
|
|
|
$core->error->add($e->getMessage());
|
2021-08-17 21:25:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# Display
|
|
|
|
echo
|
2021-08-17 21:46:17 +00:00
|
|
|
'<html><head><title>' . __('License bootstrap') . '</title>' .
|
|
|
|
dcPage::jsPageTabs() .
|
|
|
|
dcPage::jsLoad('index.php?pf=licenseBootstrap/js/licensebootstrap.js') .
|
2021-08-17 21:25:45 +00:00
|
|
|
|
|
|
|
# --BEHAVIOR-- licenseBootstrapAdminHeader
|
2021-08-17 21:46:17 +00:00
|
|
|
$core->callBehavior('licenseBootstrapAdminHeader', $core) .
|
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(
|
2021-08-17 21:46:17 +00:00
|
|
|
array(
|
|
|
|
__('Plugins') => '',
|
|
|
|
__('License bootstrap') => ''
|
|
|
|
)
|
|
|
|
) .
|
2021-08-17 21:25:45 +00:00
|
|
|
dcPage::notices();
|
|
|
|
|
|
|
|
libLicenseBootstrap::modules(
|
2021-08-17 21:46:17 +00:00
|
|
|
$core,
|
|
|
|
$plugins->getModules(),
|
|
|
|
'plugins',
|
|
|
|
__('Installed plugins')
|
2021-08-17 21:25:45 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
libLicenseBootstrap::modules(
|
2021-08-17 21:46:17 +00:00
|
|
|
$core,
|
|
|
|
$themes->getModules(),
|
|
|
|
'themes',
|
|
|
|
__('Installed themes')
|
2021-08-17 21:25:45 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
dcPage::helpBlock('licenseBootstrap');
|
|
|
|
|
|
|
|
echo
|
2021-08-17 21:46:17 +00:00
|
|
|
'</body></html>';
|