forumlist: dbupdate - new try

This commit is contained in:
rabuzarus 2015-11-12 16:42:27 +01:00
parent 666e1198d4
commit dd2ed42863

View file

@ -1662,34 +1662,41 @@ function update_1188() {
function update_1190() {
require_once('include/plugins.php');
require_once('include/plugin.php');
set_config('system', 'maintenance', 1);
if (plugin_enabled('forumlist')) {
$plugin = 'forumlist';
$plugins = get_config('system','addon');
$plugins_arr = array();
if($plugins) {
$plugins_arr = explode(',',str_replace(' ', '',$plugins));
$plugins_arr = explode(",",str_replace(" ", "",$plugins));
$idx = array_search($plugin, $plugins_arr);
if ($idx !== false){
unset($plugins_arr[$idx]);
uninstall_plugin($plugin);
set_config('system','addon', implode(', ',$plugins_arr));
set_config('system','addon', implode(", ",$plugins_arr));
}
}
}
$r = q("SELECT `uid`, `cat`, `k`, `v` FROM `pconfig` WHERE `cat` = '%d' ",
// select old formlist addon entries
$r = q("SELECT `uid`, `cat`, `k`, `v` FROM `pconfig` WHERE `cat` = '%s' ",
dbesc('forumlist')
);
// convert old forumlist addon entries in new config entries
if (count($r)) {
foreach ($r as $rr) {
$uid = $rr['uid'];
$family = $rr['cat'];
$key = $rr['k'];
$value = $rr['v'];
if ($key === 'randomize')
if ($key === 'randomise')
del_pconfig($uid,$family,$key);
if ($key === 'show_on_profile') {
@ -1701,9 +1708,15 @@ function update_1190() {
if ($key === 'show_on_network') {
if ($value)
set_pconfig($uid,feature,forumlist,$value);
set_pconfig($uid,feature,forumlist_widget,$value);
del_pconfig($uid,$family,$key);
}
}
}
set_config('system', 'maintenance', 0);
return UPDATE_SUCCESS;
}