From 179c77ccddcd8bd4df2f29d05b460c6365396d49 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Mon, 9 Jul 2007 11:33:14 +0000 Subject: [PATCH] - do not include if there are no files fetched with glob() - allow options for merged files on update (merge, new file, old file) git-svn-id: file:///svn/phpbb/trunk@7848 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/adm/style/install_update.html | 28 ++++++++- phpBB/adm/style/install_update_diff.html | 7 ++- phpBB/docs/CHANGELOG.html | 3 +- phpBB/includes/functions_module.php | 8 ++- phpBB/install/install_update.php | 80 ++++++++++++++++++++++-- phpBB/language/en/install.php | 3 + 6 files changed, 117 insertions(+), 12 deletions(-) diff --git a/phpBB/adm/style/install_update.html b/phpBB/adm/style/install_update.html index 6b361ec3f1..c9a8e4e6c1 100644 --- a/phpBB/adm/style/install_update.html +++ b/phpBB/adm/style/install_update.html @@ -185,10 +185,34 @@
{L_NUM_CONFLICTS}: {files.NUM_CONFLICTS} -
[ {files.L_SHOW_DIFF} ]{L_BINARY_FILE}
+
 [ {files.L_SHOW_DIFF} ]{L_BINARY_FILE}
+ + + +
+
+
[ {files.L_SHOW_DIFF} ]{L_BINARY_FILE}
+
+
+
+
[{L_SHOW_DIFF_FINAL}] 
+
+
+
+
[{L_SHOW_DIFF_FINAL}] 
+
+ + + +
+ {files.L_STATUS} + + + +
@@ -218,7 +242,7 @@ -
+ diff --git a/phpBB/adm/style/install_update_diff.html b/phpBB/adm/style/install_update_diff.html index 54242d94b4..799ca34292 100644 --- a/phpBB/adm/style/install_update_diff.html +++ b/phpBB/adm/style/install_update_diff.html @@ -42,11 +42,16 @@ function resize_panel() width: 99%; } +#diff_content { + padding: 30px 10px 10px; +} + div#codepanel { overflow: auto; width: 100%; height: 350px; + display: inline-block; } div#codepanel { @@ -230,7 +235,7 @@ table.hrdiff caption span {
-
+
diff --git a/phpBB/docs/CHANGELOG.html b/phpBB/docs/CHANGELOG.html index bb1ace4c49..1b4cbf8f91 100644 --- a/phpBB/docs/CHANGELOG.html +++ b/phpBB/docs/CHANGELOG.html @@ -188,6 +188,7 @@ p a { @@ -209,7 +210,7 @@ p a {
  • [Fix] Correct approval of posts in global announcements (Bug #12699)
  • [Sec] Do not allow setup spiders/robots to post, even if permissions are given. We see no reason why this should be possible. (Thanks to Frank Rizzo for convincing us regarding this)
  • [Sec] Do not display the last active column within the memberlist if u_viewonline permission is not given (Bug #12797)
  • -
  • [Fix] Display custom profile field "date" based on users language (Bug #12787)
  • +
  • [Fix] Display custom profile field "date" based on users language (Bug #12787)
  • [Fix] Allow adding of help language files within subdirectories (Bug #12783)
  • [Fix] Correctly apply smileys on posting having # within their emotion code
  • [Fix] Correctly convert smileys having double quotes within their emotion code (Bug #12731)
  • diff --git a/phpBB/includes/functions_module.php b/phpBB/includes/functions_module.php index 1010de643b..073dfa60ad 100644 --- a/phpBB/includes/functions_module.php +++ b/phpBB/includes/functions_module.php @@ -127,10 +127,14 @@ class p_master if (file_exists($user->lang_path . 'mods')) { $add_files = array(); + $info_files = glob($user->lang_path . 'mods/info_' . strtolower($this->p_class) . '_*.' . $phpEx, GLOB_NOSORT); - foreach (glob($user->lang_path . 'mods/info_' . strtolower($this->p_class) . '_*.' . $phpEx, GLOB_NOSORT) as $file) + if ($info_files !== false && sizeof($info_files)) { - $add_files[] = 'mods/' . substr(basename($file), 0, -(strlen($phpEx) + 1)); + foreach ($info_files as $file) + { + $add_files[] = 'mods/' . substr(basename($file), 0, -(strlen($phpEx) + 1)); + } } if (sizeof($add_files)) diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php index bf1912076f..3a7cbaf37b 100644 --- a/phpBB/install/install_update.php +++ b/phpBB/install/install_update.php @@ -82,7 +82,7 @@ class install_update extends module require($phpbb_root_path . 'includes/db/' . $dbms . '.' . $phpEx); require($phpbb_root_path . 'includes/constants.' . $phpEx); - // Special options for conflicts + // Special options for conflicts/modified files define('MERGE_NO_MERGE_NEW', 1); define('MERGE_NO_MERGE_MOD', 2); define('MERGE_NEW_FILE', 3); @@ -476,11 +476,23 @@ class install_update extends module $this->page_title = 'STAGE_UPDATE_FILES'; $s_hidden_fields = ''; - foreach (request_var('conflict', array('' => 0)) as $filename => $merge_option) + $conflicts = request_var('conflict', array('' => 0)); + $modified = request_var('modified', array('' => 0)); + + foreach ($conflicts as $filename => $merge_option) { $s_hidden_fields .= ''; } + foreach ($modified as $filename => $merge_option) + { + if (!$merge_option) + { + continue; + } + $s_hidden_fields .= ''; + } + $no_update = request_var('no_update', array(0 => '')); foreach ($no_update as $index => $filename) @@ -645,6 +657,7 @@ class install_update extends module $update_list = $cache->get('_update_list'); $conflicts = request_var('conflict', array('' => 0)); + $modified = request_var('modified', array('' => 0)); if ($update_list === false) { @@ -672,6 +685,28 @@ class install_update extends module $conflicts = $new_conflicts; } + // Build list for modifications + if (sizeof($modified)) + { + $modified_filenames = array(); + foreach ($update_list['modified'] as $files) + { + $modified_filenames[] = $files['filename']; + } + + $new_modified = array(); + foreach ($modified as $filename => $diff_method) + { + if (in_array($filename, $modified_filenames)) + { + $new_modified[$filename] = $diff_method; + } + } + + $modified = $new_modified; + } + + // Check number of conflicting files, they need to be equal. For modified files the number can differ if (sizeof($update_list['conflict']) != sizeof($conflicts)) { trigger_error($user->lang['MERGE_SELECT_ERROR'], E_USER_ERROR); @@ -729,10 +764,25 @@ class install_update extends module case 'modified': - $diff = $this->return_diff($this->old_location . $original_filename, $phpbb_root_path . $file_struct['filename'], $this->new_location . $original_filename); + $option = (isset($modified[$file_struct['filename']])) ? $modified[$file_struct['filename']] : 0; - $contents = implode("\n", $diff->merged_output()); - unset($diff); + switch ($option) + { + case MERGE_NO_MERGE_NEW: + $contents = file_get_contents($this->new_location . $original_filename); + break; + + case MERGE_NO_MERGE_MOD: + $contents = file_get_contents($phpbb_root_path . $file_struct['filename']); + break; + + default: + $diff = $this->return_diff($this->old_location . $original_filename, $phpbb_root_path . $file_struct['filename'], $this->new_location . $original_filename); + + $contents = implode("\n", $diff->merged_output()); + unset($diff); + break; + } if ($update_mode == 'download') { @@ -921,7 +971,25 @@ class install_update extends module break; case 'modified': - $diff = $this->return_diff($this->old_location . $original_file, $phpbb_root_path . $original_file, $this->new_location . $file); + $option = request_var('op', 0); + + switch ($option) + { + case MERGE_NO_MERGE_NEW: + case MERGE_NO_MERGE_MOD: + + $diff = $this->return_diff(array(), ($option == MERGE_NO_MERGE_NEW) ? $this->new_location . $original_file : $phpbb_root_path . $file); + + $template->assign_var('S_DIFF_NEW_FILE', true); + $diff_mode = 'inline'; + $this->page_title = 'VIEWING_FILE_CONTENTS'; + + break; + + default: + $diff = $this->return_diff($this->old_location . $original_file, $phpbb_root_path . $original_file, $this->new_location . $file); + break; + } break; case 'not_modified': diff --git a/phpBB/language/en/install.php b/phpBB/language/en/install.php index 180157d5e0..8fd95bc0ae 100755 --- a/phpBB/language/en/install.php +++ b/phpBB/language/en/install.php @@ -421,6 +421,9 @@ $lang = array_merge($lang, array( 'LOGIN_UPDATE_EXPLAIN' => 'In order to update your installation you need to login first.', 'MAPPING_FILE_STRUCTURE' => 'To ease the upload here are the file locations which map your phpBB installation.', + + 'MERGE_MODIFICATIONS_OPTION' => 'Merge modifications', + 'MERGE_NO_MERGE_NEW_OPTION' => 'Do not merge - use new file', 'MERGE_NO_MERGE_MOD_OPTION' => 'Do not merge - use currently installed file', 'MERGE_MOD_FILE_OPTION' => 'Merge differences and use modified code within conflicting block',