mirror of
https://github.com/maxpozdeev/mytinytodo.git
synced 2026-03-11 08:55:27 +00:00
* can deactivate missing extension
This commit is contained in:
parent
fb33a74f69
commit
167fc489d1
1 changed files with 14 additions and 2 deletions
|
|
@ -72,9 +72,10 @@ else if (isset($_POST['activate']))
|
|||
$ext = _post('ext');
|
||||
|
||||
$exts = MTTExtensionLoader::bundles();
|
||||
$a = Config::get('extensions');
|
||||
if (!is_array($a)) $a = [];
|
||||
|
||||
if (in_array($ext, $exts)) {
|
||||
$a = Config::get('extensions');
|
||||
if (!is_array($a)) $a = [];
|
||||
if ($activate) {
|
||||
try {
|
||||
MTTExtensionLoader::loadExtension($ext);
|
||||
|
|
@ -89,6 +90,11 @@ else if (isset($_POST['activate']))
|
|||
Config::set('extensions', $a);
|
||||
Config::save();
|
||||
}
|
||||
else if (!$activate && in_array($ext, $a)) {
|
||||
$a = array_diff($a, [$ext]);
|
||||
Config::set('extensions', $a);
|
||||
Config::save();
|
||||
}
|
||||
$t['saved'] = 1;
|
||||
jsonExit($t);
|
||||
}
|
||||
|
|
@ -193,12 +199,18 @@ function listExtensions()
|
|||
if ($instance instanceof MTTExtensionSettingsInterface) {
|
||||
$out .= " <a href='#' data-settings-link='ext-index' data-ext='". htmlspecialchars($ext). "'>". __('a_settings', true). "</a>";
|
||||
}
|
||||
$activatedExts = array_diff($activatedExts, [$ext]);
|
||||
}
|
||||
else {
|
||||
$out .= "<a href='#' data-settings-link='ext-activate' data-ext='". htmlspecialchars($ext). "'>". __('set_activate', true). '</a>';
|
||||
}
|
||||
$a[] = $out;
|
||||
}
|
||||
// removed and not deactivated
|
||||
foreach ($activatedExts as $ext) {
|
||||
$out = "$ext <not found> "."<a href='#' data-settings-link='ext-deactivate' data-ext='". htmlspecialchars($ext). "'>". __('set_deactivate', true). '</a>';
|
||||
$a[] = $out;
|
||||
}
|
||||
print( implode("<br>\n", $a) );
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue