diff options
-rw-r--r-- | .gitignore | 6 | ||||
-rw-r--r-- | phpBB/adm/style/acp_users_prefs.html | 10 | ||||
-rw-r--r-- | phpBB/docs/events.md | 48 | ||||
-rw-r--r-- | phpBB/language/en/acp/board.php | 2 | ||||
-rw-r--r-- | phpBB/phpbb/avatar/driver/upload.php | 2 | ||||
-rw-r--r-- | phpBB/phpbb/db/migration/data/v310/timezone.php | 45 | ||||
-rw-r--r-- | tests/migrator/convert_timezones_test.php | 94 | ||||
-rw-r--r-- | tests/migrator/fixtures/convert_timezones.xml | 80 |
8 files changed, 269 insertions, 18 deletions
diff --git a/.gitignore b/.gitignore index 06b13923f5..25a6352f8d 100644 --- a/.gitignore +++ b/.gitignore @@ -5,9 +5,7 @@ /phpBB/cache/*.php /phpBB/cache/*.lock /phpBB/composer.phar -/phpBB/config.php -/phpBB/config_dev.php -/phpBB/config_test.php +/phpBB/config*.php /phpBB/ext/* /phpBB/files/* /phpBB/images/avatars/gallery/* @@ -15,5 +13,5 @@ /phpBB/store/* /phpBB/vendor /tests/phpbb_unit_tests.sqlite2 -/tests/test_config.php +/tests/test_config*.php /tests/tmp/* diff --git a/phpBB/adm/style/acp_users_prefs.html b/phpBB/adm/style/acp_users_prefs.html index d1e389ca04..14715f59e4 100644 --- a/phpBB/adm/style/acp_users_prefs.html +++ b/phpBB/adm/style/acp_users_prefs.html @@ -5,9 +5,10 @@ </script> <form id="user_prefs" method="post" action="{U_ACTION}"> - + <!-- EVENT acp_users_prefs_prepend --> <fieldset> <legend>{L_UCP_PREFS_PERSONAL}</legend> + <!-- EVENT acp_users_prefs_personal_prepend --> <dl> <dt><label for="viewemail">{L_SHOW_EMAIL}{L_COLON}</label></dt> <dd><label><input type="radio" class="radio" name="viewemail" value="1"<!-- IF VIEW_EMAIL --> id="viewemail" checked="checked"<!-- ENDIF --> /> {L_YES}</label> @@ -53,10 +54,12 @@ <dd><select name="dateoptions" id="dateoptions" onchange="if(this.value=='custom'){phpbb.toggleDisplay('custom_date',1);}else{phpbb.toggleDisplay('custom_date',-1);} if (this.value == 'custom') { document.getElementById('dateformat').value = default_dateformat; } else { document.getElementById('dateformat').value = this.value; }">{S_DATEFORMAT_OPTIONS}</select></dd> <dd><div id="custom_date"<!-- IF not S_CUSTOM_DATEFORMAT --> style="display:none;"<!-- ENDIF -->><input type="text" name="dateformat" id="dateformat" value="{DATE_FORMAT}" maxlength="30" /></div></dd> </dl> + <!-- EVENT acp_users_prefs_personal_append --> </fieldset> <fieldset> <legend>{L_UCP_PREFS_POST}</legend> + <!-- EVENT acp_users_prefs_post_prepend --> <dl> <dt><label for="bbcode">{L_DEFAULT_BBCODE}{L_COLON}</label></dt> <dd><label><input type="radio" class="radio" name="bbcode" value="1"<!-- IF BBCODE --> id="bbcode" checked="checked"<!-- ENDIF --> /> {L_YES}</label> @@ -77,10 +80,12 @@ <dd><label><input type="radio" class="radio" name="notify" value="1"<!-- IF NOTIFY --> id="notify" checked="checked"<!-- ENDIF --> /> {L_YES}</label> <label><input type="radio" class="radio" name="notify" value="0"<!-- IF not NOTIFY --> id="notify" checked="checked"<!-- ENDIF --> /> {L_NO}</label></dd> </dl> + <!-- EVENT acp_users_prefs_post_append --> </fieldset> <fieldset> <legend>{L_UCP_PREFS_VIEW}</legend> + <!-- EVENT acp_users_prefs_view_prepend --> <dl> <dt><label for="view_images">{L_VIEW_IMAGES}{L_COLON}</label></dt> <dd><label><input type="radio" class="radio" name="view_images" value="1"<!-- IF VIEW_IMAGES --> id="view_images" checked="checked"<!-- ENDIF --> /> {L_YES}</label> @@ -135,8 +140,9 @@ <dt><label>{L_VIEW_POSTS_DIR}{L_COLON}</label></dt> <dd>{S_POST_SORT_DIR}</dd> </dl> + <!-- EVENT acp_users_prefs_view_append --> </fieldset> - + <!-- EVENT acp_users_prefs_append --> <fieldset class="quick"> <input class="button1" type="submit" name="update" value="{L_SUBMIT}" /> {S_FORM_TOKEN} diff --git a/phpBB/docs/events.md b/phpBB/docs/events.md index a1637046cc..67fa96ffbc 100644 --- a/phpBB/docs/events.md +++ b/phpBB/docs/events.md @@ -76,6 +76,54 @@ acp_users_overview_options_append * Since: 3.1.0-a1 * Purpose: Add options and settings on user overview page +acp_users_prefs_append +=== +* Location: adm/style/acp_users_prefs.html +* Since: 3.1.0-b3 +* Purpose: Add user options fieldset to the bottom of ACP users prefs settings + +acp_users_prefs_prepend +=== +* Location: adm/style/acp_users_prefs.html +* Since: 3.1.0-b3 +* Purpose: Add user options fieldset to the top of ACP users prefs settings + +acp_users_prefs_personal_append +=== +* Location: adm/style/acp_users_prefs.html +* Since: 3.1.0-b3 +* Purpose: Add user options fieldset to the bottom of ACP users personal prefs settings + +acp_users_prefs_personal_prepend +=== +* Location: adm/style/acp_users_prefs.html +* Since: 3.1.0-b3 +* Purpose: Add user options fieldset to the top of ACP users personal prefs settings + +acp_users_prefs_post_append +=== +* Location: adm/style/acp_users_prefs.html +* Since: 3.1.0-b3 +* Purpose: Add user options fieldset to the bottom of ACP users post prefs settings + +acp_users_prefs_post_prepend +=== +* Location: adm/style/acp_users_prefs.html +* Since: 3.1.0-b3 +* Purpose: Add user options fieldset to the top of ACP users post prefs settings + +acp_users_prefs_view_append +=== +* Location: adm/style/acp_users_prefs.html +* Since: 3.1.0-b3 +* Purpose: Add user options fieldset to the bottom of ACP users view prefs settings + +acp_users_prefs_view_prepend +=== +* Location: adm/style/acp_users_prefs.html +* Since: 3.1.0-b3 +* Purpose: Add user options fieldset to the top of ACP users view prefs settings + acp_users_signature_editor_buttons_after === * Locations: diff --git a/phpBB/language/en/acp/board.php b/phpBB/language/en/acp/board.php index 696e82324c..e21d959e40 100644 --- a/phpBB/language/en/acp/board.php +++ b/phpBB/language/en/acp/board.php @@ -111,7 +111,7 @@ $lang = array_merge($lang, array( 'AVATAR_GALLERY_PATH' => 'Avatar gallery path', 'AVATAR_GALLERY_PATH_EXPLAIN' => 'Path under your phpBB root directory for pre-loaded images, e.g. <samp>images/avatars/gallery</samp>.', 'AVATAR_STORAGE_PATH' => 'Avatar storage path', - 'AVATAR_STORAGE_PATH_EXPLAIN' => 'Path under your phpBB root directory, e.g. <samp>images/avatars/upload</samp>.', + 'AVATAR_STORAGE_PATH_EXPLAIN' => 'Path under your phpBB root directory, e.g. <samp>images/avatars/upload</samp>.<br />Avatar uploading <strong>will not be available</strong> if this path is not writable.', 'MAX_AVATAR_SIZE' => 'Maximum avatar dimensions', 'MAX_AVATAR_SIZE_EXPLAIN' => 'Width x Height in pixels.', 'MAX_FILESIZE' => 'Maximum avatar file size', diff --git a/phpBB/phpbb/avatar/driver/upload.php b/phpBB/phpbb/avatar/driver/upload.php index 1e50e135e4..f77ef1332b 100644 --- a/phpBB/phpbb/avatar/driver/upload.php +++ b/phpBB/phpbb/avatar/driver/upload.php @@ -147,7 +147,7 @@ class upload extends \phpbb\avatar\driver\driver return array( 'allow_avatar_remote_upload'=> array('lang' => 'ALLOW_REMOTE_UPLOAD', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), 'avatar_filesize' => array('lang' => 'MAX_FILESIZE', 'validate' => 'int:0', 'type' => 'number:0', 'explain' => true, 'append' => ' ' . $user->lang['BYTES']), - 'avatar_path' => array('lang' => 'AVATAR_STORAGE_PATH', 'validate' => 'rwpath', 'type' => 'text:20:255', 'explain' => true), + 'avatar_path' => array('lang' => 'AVATAR_STORAGE_PATH', 'validate' => 'rpath', 'type' => 'text:20:255', 'explain' => true), ); } diff --git a/phpBB/phpbb/db/migration/data/v310/timezone.php b/phpBB/phpbb/db/migration/data/v310/timezone.php index c1da2f4998..2efedd4514 100644 --- a/phpBB/phpbb/db/migration/data/v310/timezone.php +++ b/phpBB/phpbb/db/migration/data/v310/timezone.php @@ -39,23 +39,48 @@ class timezone extends \phpbb\db\migration\migration ); } - public function update_timezones() + public function update_timezones($start) { - // Update user timezones - $sql = 'SELECT user_dst, user_timezone - FROM ' . $this->table_prefix . 'users - GROUP BY user_timezone, user_dst'; - $result = $this->db->sql_query($sql); + $start = (int) $start; + $limit = 500; + $converted = 0; + + $update_blocks = array(); + $sql = 'SELECT user_id, user_timezone, user_dst + FROM ' . $this->table_prefix . 'users + ORDER BY user_id ASC'; + $result = $this->db->sql_query_limit($sql, $limit, $start); while ($row = $this->db->sql_fetchrow($result)) { + $converted++; + + // In case this is somehow run twice on a row. + // Otherwise it would just end up as UTC on the second run + if (is_numeric($row['user_timezone'])) + { + $update_blocks[$row['user_timezone'] . ':' . $row['user_dst']][] = (int) $row['user_id']; + } + } + $this->db->sql_freeresult($result); + + // Update blocks of users who share the same timezone/dst + foreach ($update_blocks as $timezone => $user_ids) + { + $timezone = explode(':', $timezone); + $converted_timezone = $this->convert_phpbb30_timezone($timezone[0], $timezone[1]); + $sql = 'UPDATE ' . $this->table_prefix . "users - SET user_timezone = '" . $this->db->sql_escape($this->convert_phpbb30_timezone($row['user_timezone'], $row['user_dst'])) . "' - WHERE user_timezone = '" . $this->db->sql_escape($row['user_timezone']) . "' - AND user_dst = " . (int) $row['user_dst']; + SET user_timezone = '" . $this->db->sql_escape($converted_timezone) . "' + WHERE " . $this->db->sql_in_set('user_id', $user_ids); $this->sql_query($sql); } - $this->db->sql_freeresult($result); + + if ($converted == $limit) + { + // There are still more to convert + return $start + $limit; + } // Update board default timezone $sql = 'UPDATE ' . $this->table_prefix . "config diff --git a/tests/migrator/convert_timezones_test.php b/tests/migrator/convert_timezones_test.php new file mode 100644 index 0000000000..a1eed1dbdf --- /dev/null +++ b/tests/migrator/convert_timezones_test.php @@ -0,0 +1,94 @@ +<?php +/** +* +* @package testing +* @copyright (c) 2013 phpBB Group +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +* +*/ + +class phpbb_migrator_convert_timezones_test extends phpbb_database_test_case +{ + protected $notifications, $db, $container, $user, $config, $auth, $cache; + + public function getDataSet() + { + $this->db = $this->new_dbal(); + $db_tools = new \phpbb\db\tools($this->db); + + // user_dst doesn't exist anymore, must re-add it to test this + $db_tools->sql_column_add('phpbb_users', 'user_dst', array('BOOL', 1)); + + return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/convert_timezones.xml'); + } + + public function revert_schema() + { + return array( + 'drop_columns' => array( + $this->table_prefix . 'users' => array( + 'user_dst', + ), + ), + ); + } + + public function update_schema() + { + return array( + 'add_columns' => array( + $this->table_prefix . 'users' => array( + 'user_dst' => array('BOOL', 0), + ), + ), + ); + } + + protected function setUp() + { + parent::setUp(); + + global $phpbb_root_path, $phpEx; + + $this->db = $this->new_dbal(); + + $this->migration = new \phpbb\db\migration\data\v310\timezone( + new \phpbb\config\config(array()), + $this->db, + new \phpbb\db\tools($this->db), + $phpbb_root_path, + $phpEx, + 'phpbb_' + ); + } + + protected $expected_results = array( + //user_id => user_timezone + 1 => 'Etc/GMT+12', + 2 => 'Etc/GMT+11', + 3 => 'Etc/GMT-3', + 4 => 'Etc/GMT-4', + 5 => 'America/St_Johns', + 6 => 'Australia/Eucla', + ); + + public function test_convert() + { + $this->migration->update_timezones(0); + + $sql = 'SELECT user_id, user_timezone + FROM phpbb_users + ORDER BY user_id ASC'; + $result = $this->db->sql_query($sql); + while ($row = $this->db->sql_fetchrow($result)) + { + $this->assertEquals($this->expected_results[$row['user_id']], $row['user_timezone']); + } + $this->db->sql_freeresult($result); + + $db_tools = new \phpbb\db\tools($this->db); + + // Remove the user_dst field again + $db_tools->sql_column_remove('phpbb_users', 'user_dst'); + } +} diff --git a/tests/migrator/fixtures/convert_timezones.xml b/tests/migrator/fixtures/convert_timezones.xml new file mode 100644 index 0000000000..ce941d8b74 --- /dev/null +++ b/tests/migrator/fixtures/convert_timezones.xml @@ -0,0 +1,80 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<dataset> + <table name="phpbb_users"> + <column>user_id</column> + <column>username</column> + <column>username_clean</column> + <column>user_permissions</column> + <column>user_sig</column> + <column>user_occ</column> + <column>user_interests</column> + <column>user_timezone</column> + <column>user_dst</column> + <row> + <value>1</value> + <value>1</value> + <value>1</value> + <value></value> + <value></value> + <value></value> + <value></value> + <value>-12</value> + <value>0</value> + </row> + <row> + <value>2</value> + <value>2</value> + <value>2</value> + <value></value> + <value></value> + <value></value> + <value></value> + <value>-12</value> + <value>1</value> + </row> + <row> + <value>3</value> + <value>3</value> + <value>3</value> + <value></value> + <value></value> + <value></value> + <value></value> + <value>3</value> + <value>0</value> + </row> + <row> + <value>4</value> + <value>4</value> + <value>4</value> + <value></value> + <value></value> + <value></value> + <value></value> + <value>3</value> + <value>1</value> + </row> + <row> + <value>5</value> + <value>5</value> + <value>5</value> + <value></value> + <value></value> + <value></value> + <value></value> + <value>-3.5</value> + <value>0</value> + </row> + <row> + <value>6</value> + <value>6</value> + <value>6</value> + <value></value> + <value></value> + <value></value> + <value></value> + <value>8.75</value> + <value>0</value> + </row> + </table> +</dataset> |