Commit 51ff7e06 authored by Lupundu Yan's avatar Lupundu Yan Committed by Adrien Mbuya Maloba
Browse files

[ADD] Preference: add new section 'Orphan Preferences' in the admin panel

parent c2671941
Pipeline #647975583 failed with stages
in 51 minutes and 4 seconds
......@@ -342,6 +342,11 @@ if ($prefs['theme_unified_admin_backend'] === 'y') {
'description' => tr('External packages installation and management'),
'help' => 'Packages',
],
'orphanprefs' => [
'title' => tr('Orphan Preferences'),
'description' => tr('Orphan (leftover) preferences'),
'help' => 'Orphan preferences',
],
],
],
];
......@@ -637,5 +642,10 @@ if ($prefs['theme_unified_admin_backend'] === 'y') {
'description' => tr('Real-time collaboration tools'),
'help' => 'RTC',
],
"orphanprefs" => [
'title' => tr('Orphan Preferences'),
'description' => tr('Orphan (leftover) preferences'),
'help' => 'Orphan preferences',
],
];
}
<?php
// (c) Copyright by authors of the Tiki Wiki CMS Groupware Project
//
// All Rights Reserved. See copyright.txt for details and a complete list of authors.
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
//this script may only be included - so its better to die if called directly.
if (strpos($_SERVER['SCRIPT_NAME'], basename(__FILE__)) !== false) {
header('location: index.php');
exit;
}
require_once('tiki-setup.php');
$prefslib = TikiLib::lib('prefs');
$tikilib = TikiLib::lib('tiki');
$orphanPrefs = $prefslib->getOrphanPrefs();
if (isset($_REQUEST['clear']) && ! empty($orphanPrefs))
{
$clear = $_REQUEST['clear'];
$msg = "";
if ($clear == "all")
{
foreach ($orphanPrefs as $p)
{
$tikilib->delete_preference($p['name']);
}
$msg = "All orphaned preference data has been successfully deleted!";
} else {
$tikilib->delete_preference($clear);
$msg = "Preference <b>$clear's</b> data has been successfully deleted!";
}
if ($msg != '') {
Feedback::success($msg);
}
$orphanPrefs = $prefslib->getOrphanPrefs();
}
$smarty->assign('orphanPrefs', $orphanPrefs);
......@@ -369,6 +369,32 @@ class PreferencesLib
return $info;
}
public function getOrphanPrefs()
{
global $prefs;
$tikilib = TikiLib::lib('tiki');
$data = $tikilib->table('tiki_preferences');
$preferences = $data->fetchAll();
$orphelines = [];
$specialPrefs = [
"display_timezone",
"internal_site_hash",
"unified_field_count",
"unified_last_rebuild",
"unified_total_fields",
];
foreach ($preferences as $pref) {
$definition = $this->getPreference($pref['name'], true, $prefs);
if (! $definition && ! in_array($pref['name'], $specialPrefs)) {
$orphelines[] = $pref;
}
}
return $orphelines;
}
private function getVoteIconParams($pref, $vote, $label)
{
$iconname = [
......
{* $Id$ *}
{remarksbox type="note" title="{tr}Tip{/tr}"}{tr}<b>Orphan preferences </b> are preferences that exist in previous versions of Tiki but for various reasons have been removed. This page allows you to view the values you have configured for these preferences and gives you the option to clear the data if necessary.{/tr}
{/remarksbox}
<div class="text-center mb-4">
<a href="tiki-admin.php?page=orphanprefs&clear=all" class="btn btn-primary" title="{tr}Delete all{/tr}">{icon name="trash"} {tr}Clear all data{/tr}</a>
</div>
<table class="table table-striped table-hover">
<thead>
<tr class="bg-info d-flex">
<th class="col-4">{tr}Preferences{/tr}</th>
<th class="col-7">{tr}Values{/tr}</th>
<th class="col-1"></th>
</tr>
</thead>
<tbody>
{if ! (empty($orphanPrefs))}
{foreach $orphanPrefs as $pref}
<tr class="d-flex">
<td class="col-4"><b>{$pref.name|escape}</br></td>
<td class="col-7">{$pref.value|truncate:55}</td>
<td class="col-1"><a href="tiki-admin.php?page=orphanprefs&clear={$pref.name|escape}" class="tips" title=":{tr}Delete{/tr}">{icon name="trash"}</a></td>
</tr>
{/foreach}
{else}
<td class="col text-center"><b>You have no orphan preferences. All is well !</br></td>
{/if}
</tbody>
</table>
<br>
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment