Skip to content

Commit

Permalink
Consolidate v2.x upgrade routines.
Browse files Browse the repository at this point in the history
  • Loading branch information
CaMer0n committed Sep 30, 2018
1 parent 1d6a957 commit b60f995
Showing 1 changed file with 46 additions and 26 deletions.
72 changes: 46 additions & 26 deletions e107_admin/update_routines.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,11 @@
$LAN_UPDATE_4 = deftrue('LAN_UPDATE_4',"Update from [x] to [y]"); // in case language-pack hasn't been upgraded.
$LAN_UPDATE_5 = deftrue('LAN_UPDATE_5', "Core database structure");

$dbupdate['218_to_219'] = array('master'=>false, 'title'=> e107::getParser()->lanVars($LAN_UPDATE_4, array('2.1.8','2.1.9')), 'message'=> null, 'hide_when_complete'=>true);
// $dbupdate['218_to_219'] = array('master'=>false, 'title'=> e107::getParser()->lanVars($LAN_UPDATE_4, array('2.1.8','2.1.9')), 'message'=> null, 'hide_when_complete'=>true);

$dbupdate['217_to_218'] = array('master'=>false, 'title'=> e107::getParser()->lanVars($LAN_UPDATE_4, array('2.1.7','2.1.8')), 'message'=> null, 'hide_when_complete'=>true);
// $dbupdate['217_to_218'] = array('master'=>false, 'title'=> e107::getParser()->lanVars($LAN_UPDATE_4, array('2.1.7','2.1.8')), 'message'=> null, 'hide_when_complete'=>true);

$dbupdate['214_to_215'] = array('master'=>false, 'title'=> e107::getParser()->lanVars($LAN_UPDATE_4, array('2.1.4','2.1.5')), 'message'=> null, 'hide_when_complete'=>true);
$dbupdate['20x_to_220'] = array('master'=>false, 'title'=> e107::getParser()->lanVars($LAN_UPDATE_4, array('2.x','2.2.0')), 'message'=> null, 'hide_when_complete'=>false);

$dbupdate['706_to_800'] = array('master'=>true, 'title'=> e107::getParser()->lanVars($LAN_UPDATE_4, array('1.x','2.0')), 'message'=> LAN_UPDATE_29, 'hide_when_complete'=>true);

Expand Down Expand Up @@ -564,7 +564,7 @@ function update_core_database($type = '')
return $just_check;
}


/*
function update_218_to_219($type='')
{
$sql = e107::getDb();
Expand All @@ -584,7 +584,7 @@ function update_218_to_219($type='')
return $just_check;
}
}*/



Expand All @@ -593,7 +593,7 @@ function update_218_to_219($type='')
* @param string $type
* @return bool true = no update required, and false if update required.
*/
function update_217_to_218($type='')
/* function update_217_to_218($type='')
{
$just_check = ($type == 'do') ? false : true;
Expand Down Expand Up @@ -629,15 +629,15 @@ function update_217_to_218($type='')
}
}*/



/**
* @param string $type
* @return bool true = no update required, and false if update required.
*/
function update_214_to_215($type='')
function update_20x_to_220($type='')
{

$sql = e107::getDb();
Expand Down Expand Up @@ -683,30 +683,50 @@ function update_214_to_215($type='')



return $just_check;
$e_user_list = e107::getPref('e_user_list');

// List of changed menu locations.
/*
$changeMenuPaths = array(
e107::getPlug()->clearCache()->buildAddonPrefLists();
if(empty($e_user_list['user'])) // check e107_plugins/user/e_user.php is registered.
{
if($just_check)
{
return update_needed("user/e_user.php need to be registered"); // NO LAN.
}

array('oldpath' => 'comment_menu', 'newpath' => 'comment', 'menu' => 'comment_menu'),
);
}

if(!empty($changeMenuPaths))

// Make sure, that the pref "post_script" contains one of the allowed userclasses
// Close possible security hole
if (!array_key_exists(e107::getPref('post_script'), e107::getUserClass()->uc_required_class_list('nobody,admin,main,classes,no-excludes', true)))
{
foreach($changeMenuPaths as $val)
if ($just_check)
{
$qry = "SELECT menu_path FROM `#menus` WHERE menu_name = '".$val['menu']."' AND (menu_path='".$val['oldpath']."' || menu_path='".$val['oldpath']."/' ) LIMIT 1";
if($sql->gen($qry))
{
if ($just_check) return update_needed('Menu path changed required: '.$val['menu'].' ');
$updqry = "menu_path='".$val['newpath']."/' WHERE menu_name = '".$val['menu']."' AND (menu_path='".$val['oldpath']."' || menu_path='".$val['oldpath']."/' ) ";
$status = $sql->update('menus', $updqry) ? E_MESSAGE_DEBUG : E_MESSAGE_ERROR;
$log->logMessage(LAN_UPDATE_23.'<b>'.$val['menu'].'</b> : '.$val['oldpath'].' => '.$val['newpath'], $status); // LAN_UPDATE_25;
// catch_error($sql);
}
return update_needed("Pref 'Class which can post < script > and similar tags' contains an invalid value"); // NO LAN.
}
}*/
else
{
e107::getConfig()->setPref('post_script', 255)->save(false, true);
}
}


// add common video and audio media categories if missing.
$count = $sql->select("core_media_cat","*","media_cat_category = '_common_video' LIMIT 1 ");

if(!$count)
{
if ($just_check) return update_needed('Media-Manager is missing the video and audio categories and needs to be updated.');

$sql->gen("INSERT INTO `".MPREFIX."core_media_cat` VALUES(0, '_common', '_common_video', '(Common Videos)', '', 'Media in this category will be available in all areas of admin. ', 253, '', 0);");
$sql->gen("INSERT INTO `".MPREFIX."core_media_cat` VALUES(0, '_common', '_common_audio', '(Common Audio)', '', 'Media in this category will be available in all areas of admin. ', 253, '', 0);");
}



return $just_check;





Expand Down

0 comments on commit b60f995

Please sign in to comment.