From b60f9950caadd8a9ed1ee9f67bcf5613192e99aa Mon Sep 17 00:00:00 2001 From: Cameron Date: Sun, 30 Sep 2018 11:29:35 -0700 Subject: [PATCH] Consolidate v2.x upgrade routines. --- e107_admin/update_routines.php | 72 ++++++++++++++++++++++------------ 1 file changed, 46 insertions(+), 26 deletions(-) diff --git a/e107_admin/update_routines.php b/e107_admin/update_routines.php index 92a9fd0743..c504c18526 100644 --- a/e107_admin/update_routines.php +++ b/e107_admin/update_routines.php @@ -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); @@ -564,7 +564,7 @@ function update_core_database($type = '') return $just_check; } - +/* function update_218_to_219($type='') { $sql = e107::getDb(); @@ -584,7 +584,7 @@ function update_218_to_219($type='') return $just_check; - } + }*/ @@ -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; @@ -629,7 +629,7 @@ function update_217_to_218($type='') - } + }*/ @@ -637,7 +637,7 @@ 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(); @@ -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.''.$val['menu'].' : '.$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; + +