From 4c699e0d0acc0aafab37e36206a92b1919282dac Mon Sep 17 00:00:00 2001 From: Cullen Walsh Date: Sun, 17 Apr 2011 19:29:28 -0700 Subject: [PATCH 0001/2494] [feature/avatars] Modularized Avatars A modularized avatar system that easily allows plugins to be created for various avatar services, such as Gravatar. This inital commit includes module support and is backwards compatible with 3.0 avatars, but does notcontain ACP or UCP modules for manipulating new avatars. PHPBB3-10018 --- phpBB/includes/acp/acp_groups.php | 2 +- phpBB/includes/acp/acp_users.php | 2 +- phpBB/includes/avatars/avatar_base.php | 75 +++++++++++++ phpBB/includes/functions_display.php | 128 +++++++++++++++++++--- phpBB/includes/mcp/mcp_notes.php | 2 +- phpBB/includes/mcp/mcp_warn.php | 4 +- phpBB/includes/ucp/ucp_groups.php | 2 +- phpBB/includes/ucp/ucp_pm_viewmessage.php | 2 +- phpBB/includes/ucp/ucp_profile.php | 2 +- phpBB/memberlist.php | 7 +- phpBB/viewtopic.php | 4 +- 11 files changed, 198 insertions(+), 32 deletions(-) create mode 100644 phpBB/includes/avatars/avatar_base.php diff --git a/phpBB/includes/acp/acp_groups.php b/phpBB/includes/acp/acp_groups.php index 607254adb5..9ad157f78a 100644 --- a/phpBB/includes/acp/acp_groups.php +++ b/phpBB/includes/acp/acp_groups.php @@ -553,7 +553,7 @@ class acp_groups $type_closed = ($group_type == GROUP_CLOSED) ? ' checked="checked"' : ''; $type_hidden = ($group_type == GROUP_HIDDEN) ? ' checked="checked"' : ''; - $avatar_img = (!empty($group_row['group_avatar'])) ? get_user_avatar($group_row['group_avatar'], $group_row['group_avatar_type'], $group_row['group_avatar_width'], $group_row['group_avatar_height'], 'GROUP_AVATAR') : ''; + $avatar_img = (!empty($group_row['group_avatar'])) ? get_group_avatar($group_row) : ''; $display_gallery = (isset($_POST['display_gallery'])) ? true : false; diff --git a/phpBB/includes/acp/acp_users.php b/phpBB/includes/acp/acp_users.php index 97f4b1b5fd..390e421a51 100644 --- a/phpBB/includes/acp/acp_users.php +++ b/phpBB/includes/acp/acp_users.php @@ -1715,7 +1715,7 @@ class acp_users } // Generate users avatar - $avatar_img = ($user_row['user_avatar']) ? get_user_avatar($user_row['user_avatar'], $user_row['user_avatar_type'], $user_row['user_avatar_width'], $user_row['user_avatar_height'], 'USER_AVATAR', true) : ''; + $avatar_img = ($user_row['user_avatar']) ? get_user_avatar($user_row, 'USER_AVATAR', true) : ''; $display_gallery = (isset($_POST['display_gallery'])) ? true : false; $avatar_select = basename(request_var('avatar_select', '')); diff --git a/phpBB/includes/avatars/avatar_base.php b/phpBB/includes/avatars/avatar_base.php new file mode 100644 index 0000000000..c84a6e8a7f --- /dev/null +++ b/phpBB/includes/avatars/avatar_base.php @@ -0,0 +1,75 @@ +user_row = $user_row; + } + + /** + * Get the avatar url and dimensions + * + * @param $ignore_config Whether $user or global avatar visibility settings + * should be ignored + * @return array Avatar data + */ + public function get_data($ignore_config = false) + { + return array( + 'src' => '', + 'width' => 0, + 'height' => 0, + ); + } + + /** + * Returns custom html for displaying this avatar. + * Only called if $custom_html is true. + * + * @param $ignore_config Whether $user or global avatar visibility settings + * should be ignored + * @return string HTML + */ + public function get_custom_html($ignore_config = false) + { + return ''; + } +} diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php index 9335cabc15..eba123be9d 100644 --- a/phpBB/includes/functions_display.php +++ b/phpBB/includes/functions_display.php @@ -1272,52 +1272,144 @@ function get_user_rank($user_rank, $user_posts, &$rank_title, &$rank_img, &$rank /** * Get user avatar * -* @param string $avatar Users assigned avatar name -* @param int $avatar_type Type of avatar -* @param string $avatar_width Width of users avatar -* @param string $avatar_height Height of users avatar +* @param array $user_row Row from the users table * @param string $alt Optional language string for alt tag within image, can be a language key or text * @param bool $ignore_config Ignores the config-setting, to be still able to view the avatar in the UCP * -* @return string Avatar image +* @return string Avatar html */ -function get_user_avatar($avatar, $avatar_type, $avatar_width, $avatar_height, $alt = 'USER_AVATAR', $ignore_config = false) +function get_user_avatar(&$user_row, $alt = 'USER_AVATAR', $ignore_config = false) { - global $user, $config, $phpbb_root_path, $phpEx; + global $user, $config, $cache, $phpbb_root_path, $phpEx; - if (empty($avatar) || !$avatar_type || (!$config['allow_avatar'] && !$ignore_config)) + if (!$config['allow_avatar'] && !$ignore_config) { return ''; } - $avatar_img = ''; - - switch ($avatar_type) + $avatar_data = array( + 'src' => $user_row['user_avatar'], + 'width' => $user_row['user_avatar_width'], + 'height' => $user_row['user_avatar_height'], + ); + + switch ($user_row['user_avatar_type']) { case AVATAR_UPLOAD: + // Compatibility with old avatars if (!$config['allow_avatar_upload'] && !$ignore_config) { - return ''; + $avatar_data['src'] = ''; + } + else + { + $avatar_data['src'] = $phpbb_root_path . "download/file.$phpEx?avatar=" . $avatar_data['src']; + $avatar_data['src'] = str_replace(' ', '%20', $avatar_data['src']); } - $avatar_img = $phpbb_root_path . "download/file.$phpEx?avatar="; break; case AVATAR_GALLERY: + // Compatibility with old avatars if (!$config['allow_avatar_local'] && !$ignore_config) { - return ''; + $avatar_data['src'] = ''; + } + else + { + $avatar_data['src'] = $phpbb_root_path . $config['avatar_gallery_path'] . '/' . $avatar_data['src']; + $avatar_data['src'] = str_replace(' ', '%20', $avatar_data['src']); } - $avatar_img = $phpbb_root_path . $config['avatar_gallery_path'] . '/'; break; case AVATAR_REMOTE: + // Compatibility with old avatars if (!$config['allow_avatar_remote'] && !$ignore_config) { - return ''; + $avatar_data['src'] = ''; + } + else + { + $avatar_data['src'] = str_replace(' ', '%20', $avatar_data['src']); } break; + + default: + $class = 'phpbb_avatar_' . $user_row['user_avatar_type']; + + if (!class_exists($class)) + { + $avatar_types = $cache->get('avatar_types'); + + if (empty($avatar_types)) + { + $avatar_types = array(); + + if ($dh = @opendir($phpbb_root_path . 'includes/avatars')) + { + while ($file = @readdir($dh)) + { + if (preg_match("/avatar_(.*)\.$phpEx/", $file, $match)) + { + $avatar_types[] = $match[1]; + } + } + + @closedir($dh); + + sort($avatar_types); + $cache->put('avatar_types', $avatar_types); + } + } + + if (in_array($user_row['user_avatar_type'], $avatar_types)) + { + require_once($phpbb_root_path . 'includes/avatars/avatar_' . $user_row['user_avatar_type'] . '.' . $phpEx); + } + } + + $avatar = new $class($user_row); + + if ($avatar->custom_html) + { + return $avatar->get_custom_html($ignore_config); + } + + $avatar_data = $avatar->get_data($ignore_config); + + break; } - $avatar_img .= $avatar; - return '' . ((!empty($user->lang[$alt])) ? $user->lang[$alt] : $alt) . ''; + $html = ''; + + if (!empty($avatar_data['src'])) + { + $html = ''; + } + + return $html; +} + +/** +* Get group avatar +* +* @param array $group_row Row from the groups table +* @param string $alt Optional language string for alt tag within image, can be a language key or text +* @param bool $ignore_config Ignores the config-setting, to be still able to view the avatar in the UCP +* +* @return string Avatar html +*/ +function get_group_avatar(&$group_row, $alt = 'GROUP_AVATAR', $ignore_config = false) +{ + // Kind of abusing this functionality... + $avatar_row = array( + 'user_avatar' => $group_row['group_avatar'], + 'user_avatar_type' => $group_row['group_avatar_type'], + 'user_avatar_width' => $group_row['group_avatar_width'], + 'user_avatar_height' => $group_row['group_avatar_height'], + ); + + return get_user_avatar($group_row, $alt, $ignore_config); } diff --git a/phpBB/includes/mcp/mcp_notes.php b/phpBB/includes/mcp/mcp_notes.php index 99dbb8d86d..fe5be5dc0b 100644 --- a/phpBB/includes/mcp/mcp_notes.php +++ b/phpBB/includes/mcp/mcp_notes.php @@ -179,7 +179,7 @@ class mcp_notes } $rank_title = $rank_img = ''; - $avatar_img = get_user_avatar($userrow['user_avatar'], $userrow['user_avatar_type'], $userrow['user_avatar_width'], $userrow['user_avatar_height']); + $avatar_img = get_user_avatar($userrow); $limit_days = array(0 => $user->lang['ALL_ENTRIES'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']); $sort_by_text = array('a' => $user->lang['SORT_USERNAME'], 'b' => $user->lang['SORT_DATE'], 'c' => $user->lang['SORT_IP'], 'd' => $user->lang['SORT_ACTION']); diff --git a/phpBB/includes/mcp/mcp_warn.php b/phpBB/includes/mcp/mcp_warn.php index d8e655000f..3af021565f 100644 --- a/phpBB/includes/mcp/mcp_warn.php +++ b/phpBB/includes/mcp/mcp_warn.php @@ -308,7 +308,7 @@ class mcp_warn } $rank_title = $rank_img = ''; - $avatar_img = get_user_avatar($user_row['user_avatar'], $user_row['user_avatar_type'], $user_row['user_avatar_width'], $user_row['user_avatar_height']); + $avatar_img = get_user_avatar($user_row); $template->assign_vars(array( 'U_POST_ACTION' => $this->u_action, @@ -413,7 +413,7 @@ class mcp_warn } $rank_title = $rank_img = ''; - $avatar_img = get_user_avatar($user_row['user_avatar'], $user_row['user_avatar_type'], $user_row['user_avatar_width'], $user_row['user_avatar_height']); + $avatar_img = get_user_avatar($user_row); // OK, they didn't submit a warning so lets build the page for them to do so $template->assign_vars(array( diff --git a/phpBB/includes/ucp/ucp_groups.php b/phpBB/includes/ucp/ucp_groups.php index a7c6479759..98bdf17d3f 100644 --- a/phpBB/includes/ucp/ucp_groups.php +++ b/phpBB/includes/ucp/ucp_groups.php @@ -438,7 +438,7 @@ class ucp_groups $group_name = $group_row['group_name']; $group_type = $group_row['group_type']; - $avatar_img = (!empty($group_row['group_avatar'])) ? get_user_avatar($group_row['group_avatar'], $group_row['group_avatar_type'], $group_row['group_avatar_width'], $group_row['group_avatar_height'], 'GROUP_AVATAR') : ''; + $avatar_img = (!empty($group_row['group_avatar'])) ? get_group_avatar($group_row) : ''; $template->assign_vars(array( 'GROUP_NAME' => ($group_type == GROUP_SPECIAL) ? $user->lang['G_' . $group_name] : $group_name, diff --git a/phpBB/includes/ucp/ucp_pm_viewmessage.php b/phpBB/includes/ucp/ucp_pm_viewmessage.php index c55e8850a6..a807e3a537 100644 --- a/phpBB/includes/ucp/ucp_pm_viewmessage.php +++ b/phpBB/includes/ucp/ucp_pm_viewmessage.php @@ -350,7 +350,7 @@ function get_user_information($user_id, $user_row) include($phpbb_root_path . 'includes/functions_display.' . $phpEx); } - $user_row['avatar'] = ($user->optionget('viewavatars')) ? get_user_avatar($user_row['user_avatar'], $user_row['user_avatar_type'], $user_row['user_avatar_width'], $user_row['user_avatar_height']) : ''; + $user_row['avatar'] = ($user->optionget('viewavatars')) ? get_user_avatar($user_row) : ''; get_user_rank($user_row['user_rank'], $user_row['user_posts'], $user_row['rank_title'], $user_row['rank_image'], $user_row['rank_image_src']); diff --git a/phpBB/includes/ucp/ucp_profile.php b/phpBB/includes/ucp/ucp_profile.php index 9d81503f0a..f61e692f32 100644 --- a/phpBB/includes/ucp/ucp_profile.php +++ b/phpBB/includes/ucp/ucp_profile.php @@ -587,7 +587,7 @@ class ucp_profile $template->assign_vars(array( 'ERROR' => (sizeof($error)) ? implode('
', $error) : '', - 'AVATAR' => get_user_avatar($user->data['user_avatar'], $user->data['user_avatar_type'], $user->data['user_avatar_width'], $user->data['user_avatar_height'], 'USER_AVATAR', true), + 'AVATAR' => get_user_avatar($user->data, 'USER_AVATAR', true), 'AVATAR_SIZE' => $config['avatar_filesize'], 'U_GALLERY' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=profile&mode=avatar&display_gallery=1'), diff --git a/phpBB/memberlist.php b/phpBB/memberlist.php index 741ac2f430..a2bac28be3 100644 --- a/phpBB/memberlist.php +++ b/phpBB/memberlist.php @@ -554,7 +554,7 @@ switch ($mode) $member['user_sig'] = smiley_text($member['user_sig']); } - $poster_avatar = get_user_avatar($member['user_avatar'], $member['user_avatar_type'], $member['user_avatar_width'], $member['user_avatar_height']); + $poster_avatar = get_user_avatar($member); // We need to check if the modules 'zebra' ('friends' & 'foes' mode), 'notes' ('user_notes' mode) and 'warn' ('warn_user' mode) are accessible to decide if we can display appropriate links $zebra_enabled = $friends_enabled = $foes_enabled = $user_notes_enabled = $warn_user_enabled = false; @@ -1219,8 +1219,7 @@ switch ($mode) break; } - // Misusing the avatar function for displaying group avatars... - $avatar_img = get_user_avatar($group_row['group_avatar'], $group_row['group_avatar_type'], $group_row['group_avatar_width'], $group_row['group_avatar_height'], 'GROUP_AVATAR'); + $avatar_img = get_group_avatar($group_row); $rank_title = $rank_img = $rank_img_src = ''; if ($group_row['group_rank']) @@ -1716,7 +1715,7 @@ function show_profile($data, $user_notes_enabled = false, $warn_user_enabled = f 'A_USERNAME' => addslashes(get_username_string('username', $user_id, $username, $data['user_colour'])), - 'AVATAR_IMG' => get_user_avatar($data['user_avatar'], $data['user_avatar_type'], $data['user_avatar_width'], $data['user_avatar_height']), + 'AVATAR_IMG' => get_user_avatar($data), 'ONLINE_IMG' => (!$config['load_onlinetrack']) ? '' : (($online) ? $user->img('icon_user_online', 'ONLINE') : $user->img('icon_user_offline', 'OFFLINE')), 'S_ONLINE' => ($config['load_onlinetrack'] && $online) ? true : false, 'RANK_IMG' => $rank_img, diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index 7cb6df3660..4ad80210f8 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -1055,7 +1055,7 @@ while ($row = $db->sql_fetchrow($result)) 'sig_bbcode_bitfield' => '', 'online' => false, - 'avatar' => ($user->optionget('viewavatars')) ? get_user_avatar($row['user_avatar'], $row['user_avatar_type'], $row['user_avatar_width'], $row['user_avatar_height']) : '', + 'avatar' => ($user->optionget('viewavatars')) ? get_user_avatar($row) : '', 'rank_title' => '', 'rank_image' => '', 'rank_image_src' => '', @@ -1107,7 +1107,7 @@ while ($row = $db->sql_fetchrow($result)) 'viewonline' => $row['user_allow_viewonline'], 'allow_pm' => $row['user_allow_pm'], - 'avatar' => ($user->optionget('viewavatars')) ? get_user_avatar($row['user_avatar'], $row['user_avatar_type'], $row['user_avatar_width'], $row['user_avatar_height']) : '', + 'avatar' => ($user->optionget('viewavatars')) ? get_user_avatar($row) : '', 'age' => '', 'rank_title' => '', From 1bd3d40121960c203d0dabb4b1a04c16c564b6f1 Mon Sep 17 00:00:00 2001 From: Cullen Walsh Date: Sun, 17 Apr 2011 19:29:41 -0700 Subject: [PATCH 0002/2494] [feature/avatars] Refactor avatars to use manager Manager now stores singletons of each driver to speed loading. PHPBB3-10018 --- .../avatar_base.php => avatar/driver.php} | 34 +++++-- phpBB/includes/avatar/manager.php | 91 +++++++++++++++++++ phpBB/includes/functions_display.php | 55 ++++------- 3 files changed, 133 insertions(+), 47 deletions(-) rename phpBB/includes/{avatars/avatar_base.php => avatar/driver.php} (62%) create mode 100644 phpBB/includes/avatar/manager.php diff --git a/phpBB/includes/avatars/avatar_base.php b/phpBB/includes/avatar/driver.php similarity index 62% rename from phpBB/includes/avatars/avatar_base.php rename to phpBB/includes/avatar/driver.php index c84a6e8a7f..777b225e84 100644 --- a/phpBB/includes/avatars/avatar_base.php +++ b/phpBB/includes/avatar/driver.php @@ -1,7 +1,7 @@ user_row = $user_row; + $this->config = $config; + $this->phpbb_root_path = $phpbb_root_path; + $this->php_ext = $php_ext; } /** @@ -51,7 +65,7 @@ class phpbb_avatar_base * should be ignored * @return array Avatar data */ - public function get_data($ignore_config = false) + public function get_data($user_row, $ignore_config = false) { return array( 'src' => '', @@ -68,7 +82,7 @@ class phpbb_avatar_base * should be ignored * @return string HTML */ - public function get_custom_html($ignore_config = false) + public function get_custom_html($user_row, $ignore_config = false) { return ''; } diff --git a/phpBB/includes/avatar/manager.php b/phpBB/includes/avatar/manager.php new file mode 100644 index 0000000000..04a4d8f425 --- /dev/null +++ b/phpBB/includes/avatar/manager.php @@ -0,0 +1,91 @@ +phpbb_root_path = $phpbb_root_path; + $this->php_ext = $php_ext; + $this->config = $config; + $this->cache = $cache; + } + + public function get_singleton($avatar_type) + { + if (self::$valid_drivers === false) + { + $this->load_valid_drivers(); + } + + if (isset(self::$valid_drivers[$avatar_type])) + { + if (!is_object(self::$valid_drivers[$avatar_type])) + { + $class_name = 'phpbb_avatar_driver_' . $avatar_type; + self::$valid_drivers[$avatar_type] = new $class_name($this->config, $this->phpbb_root_path, $this->php_ext); + } + + return self::$valid_drivers[$avatar_type]; + } + else + { + return null; + } + } + + private function load_valid_drivers() + { + require_once($this->phpbb_root_path . 'includes/avatar/driver.' . $this->php_ext); + + if ($this->cache) + { + self::$valid_drivers = $this->cache->get('avatar_drivers'); + } + + if (empty($this->valid_drivers)) + { + self::$valid_drivers = array(); + + $iterator = new DirectoryIterator($this->phpbb_root_path . 'includes/avatar/driver'); + + foreach ($iterator as $file) + { + if (preg_match("/^(.*)\.{$this->php_ext}$/", $file, $match)) + { + self::$valid_drivers[] = $match[1]; + } + } + + self::$valid_drivers = array_flip(self::$valid_drivers); + + if ($this->cache) + { + $this->cache->put('avatar_drivers', self::$valid_drivers); + } + } + } +} diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php index eba123be9d..3aeee5f704 100644 --- a/phpBB/includes/functions_display.php +++ b/phpBB/includes/functions_display.php @@ -1278,10 +1278,12 @@ function get_user_rank($user_rank, $user_posts, &$rank_title, &$rank_img, &$rank * * @return string Avatar html */ -function get_user_avatar(&$user_row, $alt = 'USER_AVATAR', $ignore_config = false) +function get_user_avatar($user_row, $alt = 'USER_AVATAR', $ignore_config = false) { global $user, $config, $cache, $phpbb_root_path, $phpEx; + static $avatar_manager = null; + if (!$config['allow_avatar'] && !$ignore_config) { return ''; @@ -1334,47 +1336,26 @@ function get_user_avatar(&$user_row, $alt = 'USER_AVATAR', $ignore_config = fals break; default: - $class = 'phpbb_avatar_' . $user_row['user_avatar_type']; - - if (!class_exists($class)) + if (empty($avatar_manager)) { - $avatar_types = $cache->get('avatar_types'); - - if (empty($avatar_types)) - { - $avatar_types = array(); - - if ($dh = @opendir($phpbb_root_path . 'includes/avatars')) - { - while ($file = @readdir($dh)) - { - if (preg_match("/avatar_(.*)\.$phpEx/", $file, $match)) - { - $avatar_types[] = $match[1]; - } - } - - @closedir($dh); - - sort($avatar_types); - $cache->put('avatar_types', $avatar_types); - } - } - - if (in_array($user_row['user_avatar_type'], $avatar_types)) - { - require_once($phpbb_root_path . 'includes/avatars/avatar_' . $user_row['user_avatar_type'] . '.' . $phpEx); - } + $avatar_manager = new phpbb_avatar_manager($phpbb_root_path, $phpEx, $config, $cache->get_driver()); } - $avatar = new $class($user_row); + $avatar = $avatar_manager->get_singleton($user_row['user_avatar_type']); - if ($avatar->custom_html) + if ($avatar) { - return $avatar->get_custom_html($ignore_config); - } + if ($avatar->custom_html) + { + return $avatar->get_html($user_row, $ignore_config); + } - $avatar_data = $avatar->get_data($ignore_config); + $avatar_data = $avatar->get_data($user_row, $ignore_config); + } + else + { + $avatar_data['src'] = ''; + } break; } @@ -1401,7 +1382,7 @@ function get_user_avatar(&$user_row, $alt = 'USER_AVATAR', $ignore_config = fals * * @return string Avatar html */ -function get_group_avatar(&$group_row, $alt = 'GROUP_AVATAR', $ignore_config = false) +function get_group_avatar($group_row, $alt = 'GROUP_AVATAR', $ignore_config = false) { // Kind of abusing this functionality... $avatar_row = array( From 16bb0f00b79102aed7da984cbca8a4b1741c62af Mon Sep 17 00:00:00 2001 From: Cullen Walsh Date: Sun, 17 Apr 2011 19:29:48 -0700 Subject: [PATCH 0003/2494] [feature/avatars] Add drivers for standard avatar types Adding drivers for gallery, uploaded, and remote avatars. These may be used as examples for others to develop their own avatar drivers. PHPBB3-10018 --- phpBB/includes/avatar/driver/gallery.php | 50 ++++++++++++++++++++++++ phpBB/includes/avatar/driver/remote.php | 50 ++++++++++++++++++++++++ phpBB/includes/avatar/driver/upload.php | 50 ++++++++++++++++++++++++ 3 files changed, 150 insertions(+) create mode 100644 phpBB/includes/avatar/driver/gallery.php create mode 100644 phpBB/includes/avatar/driver/remote.php create mode 100644 phpBB/includes/avatar/driver/upload.php diff --git a/phpBB/includes/avatar/driver/gallery.php b/phpBB/includes/avatar/driver/gallery.php new file mode 100644 index 0000000000..b937332b2d --- /dev/null +++ b/phpBB/includes/avatar/driver/gallery.php @@ -0,0 +1,50 @@ +config['allow_avatar_local']) + { + return array( + 'src' => $this->phpbb_root_path . $this->config['avatar_gallery_path'] . '/' . $user_row['user_avatar'], + 'width' => $user_row['user_avatar_width'], + 'height' => $user_row['user_avatar_height'], + ); + } + else + { + return array( + 'src' => '', + 'width' => 0, + 'height' => 0, + ); + } + } +} diff --git a/phpBB/includes/avatar/driver/remote.php b/phpBB/includes/avatar/driver/remote.php new file mode 100644 index 0000000000..dbd567124d --- /dev/null +++ b/phpBB/includes/avatar/driver/remote.php @@ -0,0 +1,50 @@ +config['allow_avatar_remote']) + { + return array( + 'src' => $user_row['user_avatar'], + 'width' => $user_row['user_avatar_width'], + 'height' => $user_row['user_avatar_height'], + ); + } + else + { + return array( + 'src' => '', + 'width' => 0, + 'height' => 0, + ); + } + } +} diff --git a/phpBB/includes/avatar/driver/upload.php b/phpBB/includes/avatar/driver/upload.php new file mode 100644 index 0000000000..777c9c2060 --- /dev/null +++ b/phpBB/includes/avatar/driver/upload.php @@ -0,0 +1,50 @@ +config['allow_avatar_upload']) + { + return array( + 'src' => $this->phpbb_root_path . 'download/file.' . $this->php_ext . '?avatar=' . $user_row['user_avatar'], + 'width' => $user_row['user_avatar_width'], + 'height' => $user_row['user_avatar_height'], + ); + } + else + { + return array( + 'src' => '', + 'width' => 0, + 'height' => 0, + ); + } + } +} From 24379f1297d092141f04ccb55013e85e9b494a83 Mon Sep 17 00:00:00 2001 From: Cullen Walsh Date: Sun, 17 Apr 2011 20:11:36 -0700 Subject: [PATCH 0004/2494] [feature/avatars] Rename gallery avatar driver Renaming gallery avatar driver to better work with existing config options. PHPBB3-10018 --- phpBB/includes/avatar/driver/{gallery.php => local.php} | 2 +- phpBB/includes/avatar/driver/upload.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename phpBB/includes/avatar/driver/{gallery.php => local.php} (93%) diff --git a/phpBB/includes/avatar/driver/gallery.php b/phpBB/includes/avatar/driver/local.php similarity index 93% rename from phpBB/includes/avatar/driver/gallery.php rename to phpBB/includes/avatar/driver/local.php index b937332b2d..4014f29cbe 100644 --- a/phpBB/includes/avatar/driver/gallery.php +++ b/phpBB/includes/avatar/driver/local.php @@ -19,7 +19,7 @@ if (!defined('IN_PHPBB')) * Handles avatars selected from the board gallery * @package avatars */ -class phpbb_avatar_driver_gallery extends phpbb_avatar_driver +class phpbb_avatar_driver_local extends phpbb_avatar_driver { /** * Get the avatar url and dimensions diff --git a/phpBB/includes/avatar/driver/upload.php b/phpBB/includes/avatar/driver/upload.php index 777c9c2060..da12d52d40 100644 --- a/phpBB/includes/avatar/driver/upload.php +++ b/phpBB/includes/avatar/driver/upload.php @@ -30,7 +30,7 @@ class phpbb_avatar_driver_upload extends phpbb_avatar_driver */ public function get_data($user_row, $ignore_config = false) { - if (ignore_config || $this->config['allow_avatar_upload']) + if ($ignore_config || $this->config['allow_avatar_upload']) { return array( 'src' => $this->phpbb_root_path . 'download/file.' . $this->php_ext . '?avatar=' . $user_row['user_avatar'], From 7abded081d5ae3d231148b0485c8605b44973229 Mon Sep 17 00:00:00 2001 From: Cullen Walsh Date: Sun, 17 Apr 2011 21:58:51 -0700 Subject: [PATCH 0005/2494] [feature/avatars] UCP Avatar Interface This stubs out the avatar form fields and how form processing will occur. Form processing is not yet implemented, but shouldn't be too hard. After this I will refactor/duplicate some of the logic for the ACP. PHPBB3-10018 --- phpBB/includes/avatar/driver.php | 8 ++ phpBB/includes/avatar/driver/local.php | 73 ++++++++++++ phpBB/includes/avatar/driver/remote.php | 15 +++ phpBB/includes/avatar/driver/upload.php | 27 +++++ phpBB/includes/avatar/manager.php | 21 ++++ phpBB/includes/ucp/ucp_profile.php | 107 +++++++++++------- .../template/ucp_avatar_options.html | 69 ++++------- .../template/ucp_avatar_options_local.html | 14 +++ .../template/ucp_avatar_options_remote.html | 4 + .../template/ucp_avatar_options_upload.html | 11 ++ .../template/ucp_profile_avatar.html | 10 +- 11 files changed, 265 insertions(+), 94 deletions(-) create mode 100644 phpBB/styles/prosilver/template/ucp_avatar_options_local.html create mode 100644 phpBB/styles/prosilver/template/ucp_avatar_options_remote.html create mode 100644 phpBB/styles/prosilver/template/ucp_avatar_options_upload.html diff --git a/phpBB/includes/avatar/driver.php b/phpBB/includes/avatar/driver.php index 777b225e84..016f9e94a8 100644 --- a/phpBB/includes/avatar/driver.php +++ b/phpBB/includes/avatar/driver.php @@ -86,4 +86,12 @@ abstract class phpbb_avatar_driver { return ''; } + + /** + * @TODO + **/ + public function handle_form($template, &$error = array(), $submitted = false) + { + return false; + } } diff --git a/phpBB/includes/avatar/driver/local.php b/phpBB/includes/avatar/driver/local.php index 4014f29cbe..0a3ae51a48 100644 --- a/phpBB/includes/avatar/driver/local.php +++ b/phpBB/includes/avatar/driver/local.php @@ -47,4 +47,77 @@ class phpbb_avatar_driver_local extends phpbb_avatar_driver ); } } + + /** + * @TODO + **/ + public function handle_form($template, &$error = array(), $submitted = false) + { + if ($submitted) { + $error[] = 'TODO'; + return ''; + } + + $avatar_list = array(); + $path = $this->phpbb_root_path . $this->config['avatar_gallery_path']; + + $dh = @opendir($path); + + if (!$dh) + { + return $avatar_list; + } + + while (($cat = readdir($dh)) !== false) { + if ($cat[0] != '.' && preg_match('#^[^&"\'<>]+$#i', $cat) && is_dir("$path/$cat")) + { + if ($ch = @opendir("$path/$cat")) + { + while (($image = readdir($ch)) !== false) + { + if (preg_match('#^[^&\'"<>]+\.(?:gif|png|jpe?g)$#i', $image)) + { + $avatar_list[$cat][] = array( + 'file' => rawurlencode($cat) . '/' . rawurlencode($image), + 'filename' => rawurlencode($image), + 'name' => ucfirst(str_replace('_', ' ', preg_replace('#^(.*)\..*$#', '\1', $image))), + ); + } + } + @closedir($ch); + } + } + } + @closedir($dh); + + @ksort($avatar_list); + + $category = request_var('av_local_cat', ''); + $categories = array_keys($avatar_list); + + foreach ($categories as $cat) + { + if (!empty($avatar_list[$cat])) + { + $template->assign_block_vars('av_local_cats', array( + 'NAME' => $cat, + 'SELECTED' => ($cat == $category), + )); + } + } + + if (!empty($avatar_list[$category])) + { + foreach ($avatar_list[$category] as $img => $data) + { + $template->assign_block_vars('av_local_imgs', array( + 'AVATAR_IMAGE' => $path . '/' . $data['file'], + 'AVATAR_NAME' => $data['name'], + 'AVATAR_FILE' => $data['filename'], + )); + } + } + + return true; + } } diff --git a/phpBB/includes/avatar/driver/remote.php b/phpBB/includes/avatar/driver/remote.php index dbd567124d..c60102e787 100644 --- a/phpBB/includes/avatar/driver/remote.php +++ b/phpBB/includes/avatar/driver/remote.php @@ -47,4 +47,19 @@ class phpbb_avatar_driver_remote extends phpbb_avatar_driver ); } } + + /** + * @TODO + **/ + public function handle_form($template, &$error = array(), $submitted = false) + { + if ($submitted) { + $error[] = 'TODO'; + return ''; + } + else + { + return true; + } + } } diff --git a/phpBB/includes/avatar/driver/upload.php b/phpBB/includes/avatar/driver/upload.php index da12d52d40..fbfd5dcc89 100644 --- a/phpBB/includes/avatar/driver/upload.php +++ b/phpBB/includes/avatar/driver/upload.php @@ -47,4 +47,31 @@ class phpbb_avatar_driver_upload extends phpbb_avatar_driver ); } } + + /** + * @TODO + **/ + public function handle_form($template, &$error = array(), $submitted = false) + { + if ($submitted) { + $error[] = 'TODO'; + return ''; + } + else + { + $can_upload = (file_exists($this->phpbb_root_path . $this->config['avatar_path']) && phpbb_is_writable($this->phpbb_root_path . $this->config['avatar_path']) && (@ini_get('file_uploads') || strtolower(@ini_get('file_uploads')) == 'on')) ? true : false; + if ($can_upload) + { + $template->assign_vars(array( + 'S_UPLOAD_AVATAR_URL' => ($this->config['allow_avatar_remote_upload']) ? true : false, + )); + + return true; + } + else + { + return false; + } + } + } } diff --git a/phpBB/includes/avatar/manager.php b/phpBB/includes/avatar/manager.php index 04a4d8f425..11b7e75017 100644 --- a/phpBB/includes/avatar/manager.php +++ b/phpBB/includes/avatar/manager.php @@ -26,6 +26,9 @@ class phpbb_avatar_manager private $cache; private static $valid_drivers = false; + /** + * @TODO + **/ public function __construct($phpbb_root_path, $php_ext = '.php', phpbb_config $config, phpbb_cache_driver_interface $cache = null) { $this->phpbb_root_path = $phpbb_root_path; @@ -34,6 +37,9 @@ class phpbb_avatar_manager $this->cache = $cache; } + /** + * @TODO + **/ public function get_singleton($avatar_type) { if (self::$valid_drivers === false) @@ -57,6 +63,9 @@ class phpbb_avatar_manager } } + /** + * @TODO + **/ private function load_valid_drivers() { require_once($this->phpbb_root_path . 'includes/avatar/driver.' . $this->php_ext); @@ -88,4 +97,16 @@ class phpbb_avatar_manager } } } + + /** + * @TODO + **/ + public function get_valid_drivers() { + if (self::$valid_drivers === false) + { + $this->load_valid_drivers(); + } + + return array_keys(self::$valid_drivers); + } } diff --git a/phpBB/includes/ucp/ucp_profile.php b/phpBB/includes/ucp/ucp_profile.php index f61e692f32..0a2440d77d 100644 --- a/phpBB/includes/ucp/ucp_profile.php +++ b/phpBB/includes/ucp/ucp_profile.php @@ -28,7 +28,7 @@ class ucp_profile function main($id, $mode) { - global $config, $db, $user, $auth, $template, $phpbb_root_path, $phpEx; + global $cache, $config, $db, $user, $auth, $template, $phpbb_root_path, $phpEx; global $request; $user->add_lang('posting'); @@ -544,55 +544,89 @@ class ucp_profile break; case 'avatar': - include($phpbb_root_path . 'includes/functions_display.' . $phpEx); - + $display_gallery = request_var('display_gallery', '0'); $avatar_select = basename(request_var('avatar_select', '')); $category = basename(request_var('category', '')); - - $can_upload = (file_exists($phpbb_root_path . $config['avatar_path']) && phpbb_is_writable($phpbb_root_path . $config['avatar_path']) && $auth->acl_get('u_chgavatar') && (@ini_get('file_uploads') || strtolower(@ini_get('file_uploads')) == 'on')) ? true : false; - + add_form_key('ucp_avatar'); - if ($submit) + $avatars_enabled = false; + + if ($config['allow_avatar'] && $auth->acl_get('u_chgavatar')) { - if (check_form_key('ucp_avatar')) - { - if (avatar_process_user($error, false, $can_upload)) - { - meta_refresh(3, $this->u_action); - $message = $user->lang['PROFILE_UPDATED'] . '

' . sprintf($user->lang['RETURN_UCP'], '', ''); - trigger_error($message); + $avatar_manager = new phpbb_avatar_manager($phpbb_root_path, $phpEx, $config, $cache->getDriver()); + $avatar_drivers = $avatar_manager->get_valid_drivers(); + sort($avatar_drivers); + + foreach ($avatar_drivers as $driver) { + if ($config["allow_avatar_$driver"]) { + $avatars_enabled = true; + $template->set_filenames(array( + 'avatar' => "ucp_avatar_options_$driver.html", + )); + + $avatar = $avatar_manager->get_singleton($driver); + if (isset($_POST["submit_av_$driver"])) + { + if (check_form_key('ucp_avatar')) + { + $result = $avatar->handle_form($template, $error, true); + + if (empty($error)) + { + // Success! Lets save the result in the database + $sql_ary = array( + 'user_avatar_type' => $driver, + 'user_avatar' => (string) $result, + ); + + $sql = 'UPDATE ' . USERS_TABLE . ' + SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' + WHERE user_id = ' . $user->data['user_id']; + + $db->sql_query($sql); + + meta_refresh(3, $this->u_action); + $message = $user->lang['PROFILE_UPDATED'] . '

' . sprintf($user->lang['RETURN_UCP'], '', ''); + trigger_error($message); + } + } + else + { + $error[] = 'FORM_INVALID'; + } + } + + if ($avatar->handle_form($template, $error)) { + $driver_u = strtoupper($driver); + + $template->assign_block_vars('avatar_drivers', array( + 'L_TITLE' => $user->lang('AVATAR_DRIVER_' . $driver_u . '_TITLE'), // @TODO add lang values + 'L_EXPLAIN' => $user->lang('AVATAR_DRIVER_' . $driver_u . '_EXPLAIN'), + + 'DRIVER' => $driver, + 'OUTPUT' => $template->assign_display('avatar'), + )); + } } } - else - { - $error[] = 'FORM_INVALID'; - } - // Replace "error" strings with their real, localised form - $error = array_map(array($user, 'lang'), $error); } + + // Replace "error" strings with their real, localised form + $error = array_map(array($user, 'lang'), $error); - if (!$config['allow_avatar'] && $user->data['user_avatar_type']) - { - $error[] = $user->lang['AVATAR_NOT_ALLOWED']; - } - else if ((($user->data['user_avatar_type'] == AVATAR_UPLOAD) && !$config['allow_avatar_upload']) || - (($user->data['user_avatar_type'] == AVATAR_REMOTE) && !$config['allow_avatar_remote']) || - (($user->data['user_avatar_type'] == AVATAR_GALLERY) && !$config['allow_avatar_local'])) - { - $error[] = $user->lang['AVATAR_TYPE_NOT_ALLOWED']; - } + $avatar = get_user_avatar($user->data, 'USER_AVATAR', true); $template->assign_vars(array( 'ERROR' => (sizeof($error)) ? implode('
', $error) : '', - 'AVATAR' => get_user_avatar($user->data, 'USER_AVATAR', true), + 'AVATAR' => $avatar, 'AVATAR_SIZE' => $config['avatar_filesize'], 'U_GALLERY' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=profile&mode=avatar&display_gallery=1'), - 'S_FORM_ENCTYPE' => ($can_upload && ($config['allow_avatar_upload'] || $config['allow_avatar_remote_upload'])) ? ' enctype="multipart/form-data"' : '', + 'S_FORM_ENCTYPE' => ' enctype="multipart/form-data"', 'L_AVATAR_EXPLAIN' => phpbb_avatar_explanation_string(), )); @@ -603,16 +637,11 @@ class ucp_profile } else if ($config['allow_avatar']) { - $avatars_enabled = (($can_upload && ($config['allow_avatar_upload'] || $config['allow_avatar_remote_upload'])) || ($auth->acl_get('u_chgavatar') && ($config['allow_avatar_local'] || $config['allow_avatar_remote']))) ? true : false; - $template->assign_vars(array( - 'AVATAR_WIDTH' => request_var('width', $user->data['user_avatar_width']), - 'AVATAR_HEIGHT' => request_var('height', $user->data['user_avatar_height']), + 'AVATAR_WIDTH' => request_var('width', empty($avatar) ? 0 : $user->data['user_avatar_width']), + 'AVATAR_HEIGHT' => request_var('height', empty($avatar) ? 0 : $user->data['user_avatar_height']), 'S_AVATARS_ENABLED' => $avatars_enabled, - 'S_UPLOAD_AVATAR_FILE' => ($can_upload && $config['allow_avatar_upload']) ? true : false, - 'S_UPLOAD_AVATAR_URL' => ($can_upload && $config['allow_avatar_remote_upload']) ? true : false, - 'S_LINK_AVATAR' => ($auth->acl_get('u_chgavatar') && $config['allow_avatar_remote']) ? true : false, 'S_DISPLAY_GALLERY' => ($auth->acl_get('u_chgavatar') && $config['allow_avatar_local']) ? true : false) ); } diff --git a/phpBB/styles/prosilver/template/ucp_avatar_options.html b/phpBB/styles/prosilver/template/ucp_avatar_options.html index 7012c42f3b..680267bb10 100644 --- a/phpBB/styles/prosilver/template/ucp_avatar_options.html +++ b/phpBB/styles/prosilver/template/ucp_avatar_options.html @@ -7,31 +7,12 @@

{ERROR}

-
-

{L_AVATAR_EXPLAIN}
-
{AVATAR}
-
-
- -
-
-
-
- - - -
-

{L_UPLOAD_AVATAR_URL_EXPLAIN}
-
-
- - - -
-

{L_LINK_REMOTE_AVATAR_EXPLAIN}
-
+

{L_AVATAR_EXPLAIN}
+
{AVATAR}
+
+

{L_LINK_REMOTE_SIZE_EXPLAIN}
@@ -39,32 +20,26 @@
+ +
+ + +

{avatar_drivers.L_TITLE}

+

{avatar_drivers.L_EXPLAIN}

+ +
+ {avatar_drivers.OUTPUT} +
+
+   + +
+ + +
+
- - - - -
-
- -

{L_AVATAR_GALLERY}

- -
- - - -
- - - - -
diff --git a/phpBB/styles/prosilver/template/ucp_avatar_options_local.html b/phpBB/styles/prosilver/template/ucp_avatar_options_local.html new file mode 100644 index 0000000000..2644397e0d --- /dev/null +++ b/phpBB/styles/prosilver/template/ucp_avatar_options_local.html @@ -0,0 +1,14 @@ + + + + diff --git a/phpBB/styles/prosilver/template/ucp_avatar_options_remote.html b/phpBB/styles/prosilver/template/ucp_avatar_options_remote.html new file mode 100644 index 0000000000..70869086a9 --- /dev/null +++ b/phpBB/styles/prosilver/template/ucp_avatar_options_remote.html @@ -0,0 +1,4 @@ +
+

{L_LINK_REMOTE_AVATAR_EXPLAIN}
+
+
diff --git a/phpBB/styles/prosilver/template/ucp_avatar_options_upload.html b/phpBB/styles/prosilver/template/ucp_avatar_options_upload.html new file mode 100644 index 0000000000..9caab72444 --- /dev/null +++ b/phpBB/styles/prosilver/template/ucp_avatar_options_upload.html @@ -0,0 +1,11 @@ +
+
+
+
+ + +
+

{L_UPLOAD_AVATAR_URL_EXPLAIN}
+
+
+ diff --git a/phpBB/styles/prosilver/template/ucp_profile_avatar.html b/phpBB/styles/prosilver/template/ucp_profile_avatar.html index a25c43a588..8157d8c15b 100644 --- a/phpBB/styles/prosilver/template/ucp_profile_avatar.html +++ b/phpBB/styles/prosilver/template/ucp_profile_avatar.html @@ -6,14 +6,8 @@ -
- {S_HIDDEN_FIELDS} -   -   -   - - {S_FORM_TOKEN} -
+{S_HIDDEN_FIELDS} +{S_FORM_TOKEN} From f102d9a631d6de464abefe2089ff1e6e13ed044d Mon Sep 17 00:00:00 2001 From: Cullen Walsh Date: Mon, 18 Apr 2011 10:44:29 -0700 Subject: [PATCH 0006/2494] [feature/avatars] Various cosmetic changes Various small changes based on feedback from nn- * Renaming $php_ext to $phpEx * Fixing copyright years * Explain $ignore_config * Explain Regex * Copypasta package error * rename get_singleton PHPBB3-10018 --- phpBB/includes/avatar/driver.php | 32 ++++++++---- phpBB/includes/avatar/driver/local.php | 65 ++++++++++++++----------- phpBB/includes/avatar/driver/remote.php | 12 ++--- phpBB/includes/avatar/driver/upload.php | 14 ++---- phpBB/includes/avatar/manager.php | 21 ++++---- phpBB/includes/functions_display.php | 2 +- phpBB/includes/ucp/ucp_profile.php | 2 +- 7 files changed, 80 insertions(+), 68 deletions(-) diff --git a/phpBB/includes/avatar/driver.php b/phpBB/includes/avatar/driver.php index 016f9e94a8..60ec18670e 100644 --- a/phpBB/includes/avatar/driver.php +++ b/phpBB/includes/avatar/driver.php @@ -2,7 +2,7 @@ /** * * @package avatar -* @copyright (c) 2005, 2009 phpBB Group +* @copyright (c) 2011 phpBB Group * @license http://opensource.org/licenses/gpl-license.php GNU Public License * */ @@ -37,7 +37,13 @@ abstract class phpbb_avatar_driver * Current $phpEx * @type string */ - protected $php_ext; + protected $phpEx; + + /** + * A cache driver + * @type phpbb_cache_driver_interface + */ + protected $cache; /** * This flag should be set to true if the avatar requires a nonstandard image @@ -47,22 +53,27 @@ abstract class phpbb_avatar_driver public $custom_html = false; /** - * Construct an avatar object + * Construct an driver object * - * @param $user_row User data to base the avatar url/html on + * @param $config The phpBB configuration + * @param $phpbb_root_path The path to the phpBB root + * @param $phpEx The php file extension + * @param $cache A cache driver */ - public function __construct(phpbb_config $config, $phpbb_root_path, $php_ext) + public function __construct(phpbb_config $config, $phpbb_root_path, $phpEx, phpbb_cache_driver_interface $cache = null) { $this->config = $config; $this->phpbb_root_path = $phpbb_root_path; - $this->php_ext = $php_ext; + $this->phpEx = $phpEx; + $this->cache = $cache; } /** * Get the avatar url and dimensions * - * @param $ignore_config Whether $user or global avatar visibility settings - * should be ignored + * @param $ignore_config Whether this function should respect the users/board + * configuration option, or should just render the avatar anyways. + * Useful for the ACP. * @return array Avatar data */ public function get_data($user_row, $ignore_config = false) @@ -78,8 +89,9 @@ abstract class phpbb_avatar_driver * Returns custom html for displaying this avatar. * Only called if $custom_html is true. * - * @param $ignore_config Whether $user or global avatar visibility settings - * should be ignored + * @param $ignore_config Whether this function should respect the users/board + * configuration option, or should just render the avatar anyways. + * Useful for the ACP. * @return string HTML */ public function get_custom_html($user_row, $ignore_config = false) diff --git a/phpBB/includes/avatar/driver/local.php b/phpBB/includes/avatar/driver/local.php index 0a3ae51a48..65340c92ce 100644 --- a/phpBB/includes/avatar/driver/local.php +++ b/phpBB/includes/avatar/driver/local.php @@ -2,7 +2,7 @@ /** * * @package avatar -* @copyright (c) 2005, 2009 phpBB Group +* @copyright (c) 2011 phpBB Group * @license http://opensource.org/licenses/gpl-license.php GNU Public License * */ @@ -22,11 +22,7 @@ if (!defined('IN_PHPBB')) class phpbb_avatar_driver_local extends phpbb_avatar_driver { /** - * Get the avatar url and dimensions - * - * @param $ignore_config Whether $user or global avatar visibility settings - * should be ignored - * @return array Avatar data + * @inheritdoc */ public function get_data($user_row, $ignore_config = false) { @@ -49,8 +45,8 @@ class phpbb_avatar_driver_local extends phpbb_avatar_driver } /** - * @TODO - **/ + * @inheritdoc + */ public function handle_form($template, &$error = array(), $submitted = false) { if ($submitted) { @@ -58,39 +54,50 @@ class phpbb_avatar_driver_local extends phpbb_avatar_driver return ''; } - $avatar_list = array(); - $path = $this->phpbb_root_path . $this->config['avatar_gallery_path']; + $avatar_list = ($this->cache == null) ? false : $this->cache->get('av_local_list'); - $dh = @opendir($path); - - if (!$dh) + if (!$avatar_list) { - return $avatar_list; - } + $avatar_list = array(); + $path = $this->phpbb_root_path . $this->config['avatar_gallery_path']; - while (($cat = readdir($dh)) !== false) { - if ($cat[0] != '.' && preg_match('#^[^&"\'<>]+$#i', $cat) && is_dir("$path/$cat")) + $dh = @opendir($path); + + if (!$dh) { - if ($ch = @opendir("$path/$cat")) + return $avatar_list; + } + + while (($cat = readdir($dh)) !== false) { + if ($cat[0] != '.' && preg_match('#^[^&"\'<>]+$#i', $cat) && is_dir("$path/$cat")) { - while (($image = readdir($ch)) !== false) + if ($ch = @opendir("$path/$cat")) { - if (preg_match('#^[^&\'"<>]+\.(?:gif|png|jpe?g)$#i', $image)) + while (($image = readdir($ch)) !== false) { - $avatar_list[$cat][] = array( - 'file' => rawurlencode($cat) . '/' . rawurlencode($image), - 'filename' => rawurlencode($image), - 'name' => ucfirst(str_replace('_', ' ', preg_replace('#^(.*)\..*$#', '\1', $image))), - ); + // Match all images in the gallery folder + if (preg_match('#^[^&\'"<>]+\.(?:gif|png|jpe?g)$#i', $image)) + { + $avatar_list[$cat][] = array( + 'file' => rawurlencode($cat) . '/' . rawurlencode($image), + 'filename' => rawurlencode($image), + 'name' => ucfirst(str_replace('_', ' ', preg_replace('#^(.*)\..*$#', '\1', $image))), + ); + } } + @closedir($ch); } - @closedir($ch); } } - } - @closedir($dh); + @closedir($dh); - @ksort($avatar_list); + @ksort($avatar_list); + + if ($this->cache != null) + { + $this->cache->put('av_local_list', $avatar_list); + } + } $category = request_var('av_local_cat', ''); $categories = array_keys($avatar_list); diff --git a/phpBB/includes/avatar/driver/remote.php b/phpBB/includes/avatar/driver/remote.php index c60102e787..bfc1be263f 100644 --- a/phpBB/includes/avatar/driver/remote.php +++ b/phpBB/includes/avatar/driver/remote.php @@ -2,7 +2,7 @@ /** * * @package avatar -* @copyright (c) 2005, 2009 phpBB Group +* @copyright (c) 2011 phpBB Group * @license http://opensource.org/licenses/gpl-license.php GNU Public License * */ @@ -22,11 +22,7 @@ if (!defined('IN_PHPBB')) class phpbb_avatar_driver_remote extends phpbb_avatar_driver { /** - * Get the avatar url and dimensions - * - * @param $ignore_config Whether $user or global avatar visibility settings - * should be ignored - * @return array Avatar data + * @inheritdoc */ public function get_data($user_row, $ignore_config = false) { @@ -49,8 +45,8 @@ class phpbb_avatar_driver_remote extends phpbb_avatar_driver } /** - * @TODO - **/ + * @inheritdoc + */ public function handle_form($template, &$error = array(), $submitted = false) { if ($submitted) { diff --git a/phpBB/includes/avatar/driver/upload.php b/phpBB/includes/avatar/driver/upload.php index fbfd5dcc89..9705a888b6 100644 --- a/phpBB/includes/avatar/driver/upload.php +++ b/phpBB/includes/avatar/driver/upload.php @@ -2,7 +2,7 @@ /** * * @package avatar -* @copyright (c) 2005, 2009 phpBB Group +* @copyright (c) 2011 phpBB Group * @license http://opensource.org/licenses/gpl-license.php GNU Public License * */ @@ -22,18 +22,14 @@ if (!defined('IN_PHPBB')) class phpbb_avatar_driver_upload extends phpbb_avatar_driver { /** - * Get the avatar url and dimensions - * - * @param $ignore_config Whether $user or global avatar visibility settings - * should be ignored - * @return array Avatar data + * @inheritdoc */ public function get_data($user_row, $ignore_config = false) { if ($ignore_config || $this->config['allow_avatar_upload']) { return array( - 'src' => $this->phpbb_root_path . 'download/file.' . $this->php_ext . '?avatar=' . $user_row['user_avatar'], + 'src' => $this->phpbb_root_path . 'download/file.' . $this->phpEx . '?avatar=' . $user_row['user_avatar'], 'width' => $user_row['user_avatar_width'], 'height' => $user_row['user_avatar_height'], ); @@ -49,8 +45,8 @@ class phpbb_avatar_driver_upload extends phpbb_avatar_driver } /** - * @TODO - **/ + * @inheritdoc + */ public function handle_form($template, &$error = array(), $submitted = false) { if ($submitted) { diff --git a/phpBB/includes/avatar/manager.php b/phpBB/includes/avatar/manager.php index 11b7e75017..6471c4cc9c 100644 --- a/phpBB/includes/avatar/manager.php +++ b/phpBB/includes/avatar/manager.php @@ -2,7 +2,7 @@ /** * * @package avatar -* @copyright (c) 2010 phpBB Group +* @copyright (c) 2011 phpBB Group * @license http://opensource.org/licenses/gpl-license.php GNU Public License * */ @@ -16,12 +16,12 @@ if (!defined('IN_PHPBB')) } /** -* @package acm +* @package avatar */ class phpbb_avatar_manager { private $phpbb_root_path; - private $php_ext; + private $phpEx; private $config; private $cache; private static $valid_drivers = false; @@ -29,10 +29,10 @@ class phpbb_avatar_manager /** * @TODO **/ - public function __construct($phpbb_root_path, $php_ext = '.php', phpbb_config $config, phpbb_cache_driver_interface $cache = null) + public function __construct($phpbb_root_path, $phpEx, phpbb_config $config, phpbb_cache_driver_interface $cache = null) { $this->phpbb_root_path = $phpbb_root_path; - $this->php_ext = $php_ext; + $this->phpEx = $phpEx; $this->config = $config; $this->cache = $cache; } @@ -40,7 +40,7 @@ class phpbb_avatar_manager /** * @TODO **/ - public function get_singleton($avatar_type) + public function get_driver($avatar_type, $new = false) { if (self::$valid_drivers === false) { @@ -49,10 +49,10 @@ class phpbb_avatar_manager if (isset(self::$valid_drivers[$avatar_type])) { - if (!is_object(self::$valid_drivers[$avatar_type])) + if ($new || !is_object(self::$valid_drivers[$avatar_type])) { $class_name = 'phpbb_avatar_driver_' . $avatar_type; - self::$valid_drivers[$avatar_type] = new $class_name($this->config, $this->phpbb_root_path, $this->php_ext); + self::$valid_drivers[$avatar_type] = new $class_name($this->config, $this->phpbb_root_path, $this->phpEx, $this->cache); } return self::$valid_drivers[$avatar_type]; @@ -68,7 +68,7 @@ class phpbb_avatar_manager **/ private function load_valid_drivers() { - require_once($this->phpbb_root_path . 'includes/avatar/driver.' . $this->php_ext); + require_once($this->phpbb_root_path . 'includes/avatar/driver.' . $this->phpEx); if ($this->cache) { @@ -83,7 +83,8 @@ class phpbb_avatar_manager foreach ($iterator as $file) { - if (preg_match("/^(.*)\.{$this->php_ext}$/", $file, $match)) + // Match all files that appear to be php files + if (preg_match("/^(.*)\.{$this->phpEx}$/", $file, $match)) { self::$valid_drivers[] = $match[1]; } diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php index 3aeee5f704..23900dfd88 100644 --- a/phpBB/includes/functions_display.php +++ b/phpBB/includes/functions_display.php @@ -1341,7 +1341,7 @@ function get_user_avatar($user_row, $alt = 'USER_AVATAR', $ignore_config = false $avatar_manager = new phpbb_avatar_manager($phpbb_root_path, $phpEx, $config, $cache->get_driver()); } - $avatar = $avatar_manager->get_singleton($user_row['user_avatar_type']); + $avatar = $avatar_manager->get_driver($user_row['user_avatar_type']); if ($avatar) { diff --git a/phpBB/includes/ucp/ucp_profile.php b/phpBB/includes/ucp/ucp_profile.php index 0a2440d77d..a93430644c 100644 --- a/phpBB/includes/ucp/ucp_profile.php +++ b/phpBB/includes/ucp/ucp_profile.php @@ -567,7 +567,7 @@ class ucp_profile 'avatar' => "ucp_avatar_options_$driver.html", )); - $avatar = $avatar_manager->get_singleton($driver); + $avatar = $avatar_manager->get_driver($driver); if (isset($_POST["submit_av_$driver"])) { if (check_form_key('ucp_avatar')) From 00d4b9d431d6772889291f2f4c857a144bce93fb Mon Sep 17 00:00:00 2001 From: Cullen Walsh Date: Mon, 18 Apr 2011 22:54:35 -0700 Subject: [PATCH 0007/2494] [feature/avatars] Implement UCP remote/local avatars Implementing selection logic for gallery and remote avatars. Modified some of the driver interfaces to make things work nicer also. Upload functionality will be in the next commit. PHPBB3-10018 --- phpBB/includes/avatar/driver.php | 2 +- phpBB/includes/avatar/driver/local.php | 31 ++++-- phpBB/includes/avatar/driver/remote.php | 105 +++++++++++++++++- phpBB/includes/avatar/driver/upload.php | 3 +- phpBB/includes/ucp/ucp_profile.php | 58 ++++------ .../template/ucp_avatar_options.html | 9 -- .../template/ucp_avatar_options_local.html | 2 +- .../template/ucp_avatar_options_remote.html | 11 +- .../template/ucp_avatar_options_upload.html | 8 +- 9 files changed, 165 insertions(+), 64 deletions(-) diff --git a/phpBB/includes/avatar/driver.php b/phpBB/includes/avatar/driver.php index 60ec18670e..a2ff5d804d 100644 --- a/phpBB/includes/avatar/driver.php +++ b/phpBB/includes/avatar/driver.php @@ -102,7 +102,7 @@ abstract class phpbb_avatar_driver /** * @TODO **/ - public function handle_form($template, &$error = array(), $submitted = false) + public function handle_form($template, $user_row, &$error, $submitted = false) { return false; } diff --git a/phpBB/includes/avatar/driver/local.php b/phpBB/includes/avatar/driver/local.php index 65340c92ce..c00f65a81d 100644 --- a/phpBB/includes/avatar/driver/local.php +++ b/phpBB/includes/avatar/driver/local.php @@ -47,13 +47,8 @@ class phpbb_avatar_driver_local extends phpbb_avatar_driver /** * @inheritdoc */ - public function handle_form($template, &$error = array(), $submitted = false) + public function handle_form($template, $user_row, &$error, $submitted = false) { - if ($submitted) { - $error[] = 'TODO'; - return ''; - } - $avatar_list = ($this->cache == null) ? false : $this->cache->get('av_local_list'); if (!$avatar_list) @@ -78,10 +73,13 @@ class phpbb_avatar_driver_local extends phpbb_avatar_driver // Match all images in the gallery folder if (preg_match('#^[^&\'"<>]+\.(?:gif|png|jpe?g)$#i', $image)) { - $avatar_list[$cat][] = array( + $dims = getimagesize($this->phpbb_root_path . $this->config['avatar_gallery_path'] . '/' . $cat . '/' . $image); + $avatar_list[$cat][$image] = array( 'file' => rawurlencode($cat) . '/' . rawurlencode($image), 'filename' => rawurlencode($image), 'name' => ucfirst(str_replace('_', ' ', preg_replace('#^(.*)\..*$#', '\1', $image))), + 'width' => $dims[0], + 'height' => $dims[1], ); } } @@ -98,8 +96,25 @@ class phpbb_avatar_driver_local extends phpbb_avatar_driver $this->cache->put('av_local_list', $avatar_list); } } - + $category = request_var('av_local_cat', ''); + + if ($submitted) { + $file = request_var('av_local_file', ''); + if (!isset($avatar_list[$category][urldecode($file)])) + { + $error[] = 'AVATAR_URL_NOT_FOUND'; + return false; + } + + return array( + 'user_avatar' => $category . '/' . $file, + 'user_avatar_width' => $avatar_list[$category][urldecode($file)]['width'], + 'user_avatar_height' => $avatar_list[$category][urldecode($file)]['height'], + ); + } + + $categories = array_keys($avatar_list); foreach ($categories as $cat) diff --git a/phpBB/includes/avatar/driver/remote.php b/phpBB/includes/avatar/driver/remote.php index bfc1be263f..ebaf3cf5c4 100644 --- a/phpBB/includes/avatar/driver/remote.php +++ b/phpBB/includes/avatar/driver/remote.php @@ -47,14 +47,111 @@ class phpbb_avatar_driver_remote extends phpbb_avatar_driver /** * @inheritdoc */ - public function handle_form($template, &$error = array(), $submitted = false) + public function handle_form($template, $user_row, &$error, $submitted = false) { - if ($submitted) { - $error[] = 'TODO'; - return ''; + if ($submitted) + { + $url = request_var('av_remote_url', ''); + $width = request_var('av_remote_width', 0); + $height = request_var('av_remote_height', 0); + + if (!preg_match('#^(http|https|ftp)://#i', $url)) + { + $url = 'http://' . $url; + } + + $error = array_merge($error, validate_data(array( + 'url' => $url, + ), array( + 'url' => array('string', true, 5, 255), + ))); + + if (!empty($error)) + { + return false; + } + + // Check if this url looks alright + // This isn't perfect, but it's what phpBB 3.0 did, and might as well make sure everything is compatible + if (!preg_match('#^(http|https|ftp)://(?:(.*?\.)*?[a-z0-9\-]+?\.[a-z]{2,4}|(?:\d{1,3}\.){3,5}\d{1,3}):?([0-9]*?).*?\.(gif|jpg|jpeg|png)$#i', $url)) + { + $error[] = 'AVATAR_URL_INVALID'; + return false; + } + + // Make sure getimagesize works... + if (($image_data = getimagesize($url)) === false && ($width <= 0 || $height <= 0)) + { + $error[] = 'UNABLE_GET_IMAGE_SIZE'; + return false; + } + + if (!empty($image_data) && ($image_data[0] < 2 || $image_data[1] < 2)) + { + $error[] = 'AVATAR_NO_SIZE'; + return false; + } + + $width = ($width && $height) ? $width : $image_data[0]; + $height = ($width && $height) ? $height : $image_data[1]; + + if ($width < 2 || $height < 2) + { + $error[] = 'AVATAR_NO_SIZE'; + return false; + } + + include_once($this->phpbb_root_path . 'includes/functions_upload.' . $this->phpEx); + $types = fileupload::image_types(); + $extension = strtolower(filespec::get_extension($url)); + + if (!empty($image_data) && (!isset($types[$image_data[2]]) || !in_array($extension, $types[$image_data[2]]))) + { + if (!isset($types[$image_data[2]])) + { + $error[] = 'UNABLE_GET_IMAGE_SIZE'; + } + else + { + $error[] = array('IMAGE_FILETYPE_MISMATCH', $types[$image_data[2]][0], $extension); + } + + return false; + } + + if ($this->config['avatar_max_width'] || $this->config['avatar_max_height']) + { + if ($width > $this->config['avatar_max_width'] || $height > $this->config['avatar_max_height']) + { + $error[] = array('AVATAR_WRONG_SIZE', $this->config['avatar_min_width'], $this->config['avatar_min_height'], $this->config['avatar_max_width'], $this->config['avatar_max_height'], $width, $height); + return false; + } + } + + if ($this->config['avatar_min_width'] || $this->config['avatar_min_height']) + { + if ($width < $this->config['avatar_min_width'] || $height < $this->config['avatar_min_height']) + { + $error[] = array('AVATAR_WRONG_SIZE', $this->config['avatar_min_width'], $this->config['avatar_min_height'], $this->config['avatar_max_width'], $this->config['avatar_max_height'], $width, $height); + return false; + } + } + + $result = array( + 'user_avatar' => $url, + 'user_avatar_width' => $width, + 'user_avatar_height' => $height, + ); + + return $result; } else { + $template->assign_vars(array( + 'AV_REMOTE_WIDTH' => (($user_row['user_avatar_type'] == AVATAR_REMOTE || $user_row['user_avatar_type'] == 'remote') && $user_row['user_avatar_width']) ? $user_row['user_avatar_width'] : request_var('av_local_width', 0), + 'AV_REMOTE_HEIGHT' => (($user_row['user_avatar_type'] == AVATAR_REMOTE || $user_row['user_avatar_type'] == 'remote') && $user_row['user_avatar_height']) ? $user_row['user_avatar_height'] : request_var('av_local_width', 0), + 'AV_REMOTE_URL' => (($user_row['user_avatar_type'] == AVATAR_REMOTE || $user_row['user_avatar_type'] == 'remote') && $user_row['user_avatar']) ? $user_row['user_avatar'] : '', + )); return true; } } diff --git a/phpBB/includes/avatar/driver/upload.php b/phpBB/includes/avatar/driver/upload.php index 9705a888b6..84168722ec 100644 --- a/phpBB/includes/avatar/driver/upload.php +++ b/phpBB/includes/avatar/driver/upload.php @@ -47,7 +47,7 @@ class phpbb_avatar_driver_upload extends phpbb_avatar_driver /** * @inheritdoc */ - public function handle_form($template, &$error = array(), $submitted = false) + public function handle_form($template, $user_row, &$error, $submitted = false) { if ($submitted) { $error[] = 'TODO'; @@ -60,6 +60,7 @@ class phpbb_avatar_driver_upload extends phpbb_avatar_driver { $template->assign_vars(array( 'S_UPLOAD_AVATAR_URL' => ($this->config['allow_avatar_remote_upload']) ? true : false, + 'AV_UPLOAD_SIZE' => $this->config['avatar_filesize'], )); return true; diff --git a/phpBB/includes/ucp/ucp_profile.php b/phpBB/includes/ucp/ucp_profile.php index a93430644c..5d7dbe12d8 100644 --- a/phpBB/includes/ucp/ucp_profile.php +++ b/phpBB/includes/ucp/ucp_profile.php @@ -544,12 +544,8 @@ class ucp_profile break; case 'avatar': - include($phpbb_root_path . 'includes/functions_display.' . $phpEx); - - $display_gallery = request_var('display_gallery', '0'); - $avatar_select = basename(request_var('avatar_select', '')); - $category = basename(request_var('category', '')); - + include_once($phpbb_root_path . 'includes/functions_display.' . $phpEx); + add_form_key('ucp_avatar'); $avatars_enabled = false; @@ -572,18 +568,15 @@ class ucp_profile { if (check_form_key('ucp_avatar')) { - $result = $avatar->handle_form($template, $error, true); + $result = $avatar->handle_form($template, $user->data, $error, true); if (empty($error)) { // Success! Lets save the result in the database - $sql_ary = array( - 'user_avatar_type' => $driver, - 'user_avatar' => (string) $result, - ); + $result['user_avatar_type'] = $driver; $sql = 'UPDATE ' . USERS_TABLE . ' - SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' + SET ' . $db->sql_build_array('UPDATE', $result) . ' WHERE user_id = ' . $user->data['user_id']; $db->sql_query($sql); @@ -599,7 +592,7 @@ class ucp_profile } } - if ($avatar->handle_form($template, $error)) { + if ($avatar->handle_form($template, $user->data, $error)) { $driver_u = strtoupper($driver); $template->assign_block_vars('avatar_drivers', array( @@ -613,39 +606,36 @@ class ucp_profile } } } - - // Replace "error" strings with their real, localised form - $error = array_map(array($user, 'lang'), $error); + // Replace "error" strings with their real, localised form + $err = $error; + $error = array(); + foreach ($err as $e) + { + if (is_array($e)) + { + $key = array_shift($e); + $error[] = vsprintf($user->lang($key), $e); + } + else + { + $error[] = $user->lang((string) $e); + } + } + $avatar = get_user_avatar($user->data, 'USER_AVATAR', true); $template->assign_vars(array( 'ERROR' => (sizeof($error)) ? implode('
', $error) : '', 'AVATAR' => $avatar, - 'AVATAR_SIZE' => $config['avatar_filesize'], - - 'U_GALLERY' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=profile&mode=avatar&display_gallery=1'), 'S_FORM_ENCTYPE' => ' enctype="multipart/form-data"', 'L_AVATAR_EXPLAIN' => phpbb_avatar_explanation_string(), + + 'S_AVATARS_ENABLED' => ($config['allow_avatar'] && $avatars_enabled), )); - if ($config['allow_avatar'] && $display_gallery && $auth->acl_get('u_chgavatar') && $config['allow_avatar_local']) - { - avatar_gallery($category, $avatar_select, 4); - } - else if ($config['allow_avatar']) - { - $template->assign_vars(array( - 'AVATAR_WIDTH' => request_var('width', empty($avatar) ? 0 : $user->data['user_avatar_width']), - 'AVATAR_HEIGHT' => request_var('height', empty($avatar) ? 0 : $user->data['user_avatar_height']), - - 'S_AVATARS_ENABLED' => $avatars_enabled, - 'S_DISPLAY_GALLERY' => ($auth->acl_get('u_chgavatar') && $config['allow_avatar_local']) ? true : false) - ); - } - break; } diff --git a/phpBB/styles/prosilver/template/ucp_avatar_options.html b/phpBB/styles/prosilver/template/ucp_avatar_options.html index 680267bb10..e30fcc74aa 100644 --- a/phpBB/styles/prosilver/template/ucp_avatar_options.html +++ b/phpBB/styles/prosilver/template/ucp_avatar_options.html @@ -12,15 +12,6 @@
{AVATAR}
- -
-

{L_LINK_REMOTE_SIZE_EXPLAIN}
-
- ×  - -
-
- diff --git a/phpBB/styles/prosilver/template/ucp_avatar_options_local.html b/phpBB/styles/prosilver/template/ucp_avatar_options_local.html index 2644397e0d..0dd83db017 100644 --- a/phpBB/styles/prosilver/template/ucp_avatar_options_local.html +++ b/phpBB/styles/prosilver/template/ucp_avatar_options_local.html @@ -9,6 +9,6 @@ diff --git a/phpBB/styles/prosilver/template/ucp_avatar_options_remote.html b/phpBB/styles/prosilver/template/ucp_avatar_options_remote.html index 70869086a9..4e62e96d9d 100644 --- a/phpBB/styles/prosilver/template/ucp_avatar_options_remote.html +++ b/phpBB/styles/prosilver/template/ucp_avatar_options_remote.html @@ -1,4 +1,11 @@
-

{L_LINK_REMOTE_AVATAR_EXPLAIN}
-
+

{L_LINK_REMOTE_AVATAR_EXPLAIN}
+
+
+
+

{L_LINK_REMOTE_SIZE_EXPLAIN}
+
+ ×  + +
diff --git a/phpBB/styles/prosilver/template/ucp_avatar_options_upload.html b/phpBB/styles/prosilver/template/ucp_avatar_options_upload.html index 9caab72444..9c8dd9af01 100644 --- a/phpBB/styles/prosilver/template/ucp_avatar_options_upload.html +++ b/phpBB/styles/prosilver/template/ucp_avatar_options_upload.html @@ -1,11 +1,11 @@
-
-
+
+
-

{L_UPLOAD_AVATAR_URL_EXPLAIN}
-
+

{L_UPLOAD_AVATAR_URL_EXPLAIN}
+
From f02f6216867db63f6ad2659b0b702b81b07a875c Mon Sep 17 00:00:00 2001 From: Cullen Walsh Date: Mon, 18 Apr 2011 23:34:56 -0700 Subject: [PATCH 0008/2494] [feature/avatars] Fixing remote avatars size checks Remote avatars size checks were broken. It assumed getimagesize() was available and used the wrong template values. PHPBB3-10018 --- phpBB/includes/avatar/driver/local.php | 9 +++++- phpBB/includes/avatar/driver/remote.php | 29 ++++++++++--------- .../template/ucp_avatar_options_remote.html | 4 +-- 3 files changed, 26 insertions(+), 16 deletions(-) diff --git a/phpBB/includes/avatar/driver/local.php b/phpBB/includes/avatar/driver/local.php index c00f65a81d..4c15b5de2e 100644 --- a/phpBB/includes/avatar/driver/local.php +++ b/phpBB/includes/avatar/driver/local.php @@ -73,7 +73,14 @@ class phpbb_avatar_driver_local extends phpbb_avatar_driver // Match all images in the gallery folder if (preg_match('#^[^&\'"<>]+\.(?:gif|png|jpe?g)$#i', $image)) { - $dims = getimagesize($this->phpbb_root_path . $this->config['avatar_gallery_path'] . '/' . $cat . '/' . $image); + if (function_exists('getimagesize')) + { + $dims = getimagesize($this->phpbb_root_path . $this->config['avatar_gallery_path'] . '/' . $cat . '/' . $image); + } + else + { + $dims = array(0, 0); + } $avatar_list[$cat][$image] = array( 'file' => rawurlencode($cat) . '/' . rawurlencode($image), 'filename' => rawurlencode($image), diff --git a/phpBB/includes/avatar/driver/remote.php b/phpBB/includes/avatar/driver/remote.php index ebaf3cf5c4..48f86cac3f 100644 --- a/phpBB/includes/avatar/driver/remote.php +++ b/phpBB/includes/avatar/driver/remote.php @@ -80,22 +80,25 @@ class phpbb_avatar_driver_remote extends phpbb_avatar_driver } // Make sure getimagesize works... - if (($image_data = getimagesize($url)) === false && ($width <= 0 || $height <= 0)) + if (function_exists('getimagesize')) { - $error[] = 'UNABLE_GET_IMAGE_SIZE'; - return false; + if (($width <= 0 || $height <= 0) && (($image_data = @getimagesize($url)) === false)) + { + $error[] = 'UNABLE_GET_IMAGE_SIZE'; + return false; + } + + if (!empty($image_data) && ($image_data[0] <= 0 || $image_data[1] <= 0)) + { + $error[] = 'AVATAR_NO_SIZE'; + return false; + } + + $width = ($width && $height) ? $width : $image_data[0]; + $height = ($width && $height) ? $height : $image_data[1]; } - if (!empty($image_data) && ($image_data[0] < 2 || $image_data[1] < 2)) - { - $error[] = 'AVATAR_NO_SIZE'; - return false; - } - - $width = ($width && $height) ? $width : $image_data[0]; - $height = ($width && $height) ? $height : $image_data[1]; - - if ($width < 2 || $height < 2) + if ($width <= 0 || $height <= 0) { $error[] = 'AVATAR_NO_SIZE'; return false; diff --git a/phpBB/styles/prosilver/template/ucp_avatar_options_remote.html b/phpBB/styles/prosilver/template/ucp_avatar_options_remote.html index 4e62e96d9d..02704c5be8 100644 --- a/phpBB/styles/prosilver/template/ucp_avatar_options_remote.html +++ b/phpBB/styles/prosilver/template/ucp_avatar_options_remote.html @@ -5,7 +5,7 @@

{L_LINK_REMOTE_SIZE_EXPLAIN}
- ×  - + ×  +
From 019b9bc0735bb74d46f4e87fe006328970211dad Mon Sep 17 00:00:00 2001 From: Cullen Walsh Date: Tue, 19 Apr 2011 11:19:47 -0700 Subject: [PATCH 0009/2494] [feature/avatars] Implement avatar uploads for ucp As above, implement avatar uploads from local and remote sources in the UCP. PHPBB3-10018 --- phpBB/includes/avatar/driver/local.php | 50 +++++++++-------- phpBB/includes/avatar/driver/upload.php | 71 ++++++++++++++++++++----- phpBB/includes/ucp/ucp_profile.php | 2 +- 3 files changed, 82 insertions(+), 41 deletions(-) diff --git a/phpBB/includes/avatar/driver/local.php b/phpBB/includes/avatar/driver/local.php index 4c15b5de2e..f9b7662e93 100644 --- a/phpBB/includes/avatar/driver/local.php +++ b/phpBB/includes/avatar/driver/local.php @@ -58,43 +58,41 @@ class phpbb_avatar_driver_local extends phpbb_avatar_driver $dh = @opendir($path); - if (!$dh) + if ($dh) { - return $avatar_list; - } - - while (($cat = readdir($dh)) !== false) { - if ($cat[0] != '.' && preg_match('#^[^&"\'<>]+$#i', $cat) && is_dir("$path/$cat")) - { - if ($ch = @opendir("$path/$cat")) + while (($cat = readdir($dh)) !== false) { + if ($cat[0] != '.' && preg_match('#^[^&"\'<>]+$#i', $cat) && is_dir("$path/$cat")) { - while (($image = readdir($ch)) !== false) + if ($ch = @opendir("$path/$cat")) { - // Match all images in the gallery folder - if (preg_match('#^[^&\'"<>]+\.(?:gif|png|jpe?g)$#i', $image)) + while (($image = readdir($ch)) !== false) { - if (function_exists('getimagesize')) + // Match all images in the gallery folder + if (preg_match('#^[^&\'"<>]+\.(?:gif|png|jpe?g)$#i', $image)) { - $dims = getimagesize($this->phpbb_root_path . $this->config['avatar_gallery_path'] . '/' . $cat . '/' . $image); + if (function_exists('getimagesize')) + { + $dims = getimagesize($this->phpbb_root_path . $this->config['avatar_gallery_path'] . '/' . $cat . '/' . $image); + } + else + { + $dims = array(0, 0); + } + $avatar_list[$cat][$image] = array( + 'file' => rawurlencode($cat) . '/' . rawurlencode($image), + 'filename' => rawurlencode($image), + 'name' => ucfirst(str_replace('_', ' ', preg_replace('#^(.*)\..*$#', '\1', $image))), + 'width' => $dims[0], + 'height' => $dims[1], + ); } - else - { - $dims = array(0, 0); - } - $avatar_list[$cat][$image] = array( - 'file' => rawurlencode($cat) . '/' . rawurlencode($image), - 'filename' => rawurlencode($image), - 'name' => ucfirst(str_replace('_', ' ', preg_replace('#^(.*)\..*$#', '\1', $image))), - 'width' => $dims[0], - 'height' => $dims[1], - ); } + @closedir($ch); } - @closedir($ch); } } + @closedir($dh); } - @closedir($dh); @ksort($avatar_list); diff --git a/phpBB/includes/avatar/driver/upload.php b/phpBB/includes/avatar/driver/upload.php index 84168722ec..cbc46e0e49 100644 --- a/phpBB/includes/avatar/driver/upload.php +++ b/phpBB/includes/avatar/driver/upload.php @@ -49,26 +49,69 @@ class phpbb_avatar_driver_upload extends phpbb_avatar_driver */ public function handle_form($template, $user_row, &$error, $submitted = false) { - if ($submitted) { - $error[] = 'TODO'; - return ''; - } - else - { - $can_upload = (file_exists($this->phpbb_root_path . $this->config['avatar_path']) && phpbb_is_writable($this->phpbb_root_path . $this->config['avatar_path']) && (@ini_get('file_uploads') || strtolower(@ini_get('file_uploads')) == 'on')) ? true : false; - if ($can_upload) - { - $template->assign_vars(array( - 'S_UPLOAD_AVATAR_URL' => ($this->config['allow_avatar_remote_upload']) ? true : false, - 'AV_UPLOAD_SIZE' => $this->config['avatar_filesize'], - )); + $can_upload = (file_exists($this->phpbb_root_path . $this->config['avatar_path']) && phpbb_is_writable($this->phpbb_root_path . $this->config['avatar_path']) && (@ini_get('file_uploads') || strtolower(@ini_get('file_uploads')) == 'on')) ? true : false; - return true; + if ($can_upload == false) + { + return false; + } + + if ($submitted) + { + include_once($this->phpbb_root_path . 'includes/functions_upload.' . $this->phpEx); + + $upload = new fileupload('AVATAR_', array('jpg', 'jpeg', 'gif', 'png'), $this->config['avatar_filesize'], $this->config['avatar_min_width'], $this->config['avatar_min_height'], $this->config['avatar_max_width'], $this->config['avatar_max_height'], (isset($this->config['mime_triggers']) ? explode('|', $this->config['mime_triggers']) : false)); + + $url = request_var('av_upload_url', ''); + + if (!empty($_FILES['av_upload_file']['name'])) + { + $file = $upload->form_upload('av_upload_file'); } else { + $file = $upload->remote_upload($url); + } + + $prefix = $this->config['avatar_salt'] . '_'; + $file->clean_filename('avatar', $prefix, $user_row['user_id']); + + $destination = $this->config['avatar_path']; + + // Adjust destination path (no trailing slash) + if (substr($destination, -1, 1) == '/' || substr($destination, -1, 1) == '\\') + { + $destination = substr($destination, 0, -1); + } + + $destination = str_replace(array('../', '..\\', './', '.\\'), '', $destination); + if ($destination && ($destination[0] == '/' || $destination[0] == "\\")) + { + $destination = ''; + } + + // Move file and overwrite any existing image + $file->move_file($destination, true); + + if (sizeof($file->error)) + { + $file->remove(); + $error = array_merge($error, $file->error); return false; } + + return array( + 'user_avatar' => $user_row['user_id'] . '_' . time() . '.' . $file->get('extension'), + 'user_avatar_width' => $file->get('width'), + 'user_avatar_height' => $file->get('height'), + ); } + + $template->assign_vars(array( + 'S_UPLOAD_AVATAR_URL' => ($this->config['allow_avatar_remote_upload']) ? true : false, + 'AV_UPLOAD_SIZE' => $this->config['avatar_filesize'], + )); + + return true; } } diff --git a/phpBB/includes/ucp/ucp_profile.php b/phpBB/includes/ucp/ucp_profile.php index 5d7dbe12d8..a815ec7987 100644 --- a/phpBB/includes/ucp/ucp_profile.php +++ b/phpBB/includes/ucp/ucp_profile.php @@ -570,7 +570,7 @@ class ucp_profile { $result = $avatar->handle_form($template, $user->data, $error, true); - if (empty($error)) + if ($result && empty($error)) { // Success! Lets save the result in the database $result['user_avatar_type'] = $driver; From 611a1d647a3a63013df472b469bf1f3e6e7bd657 Mon Sep 17 00:00:00 2001 From: Cullen Walsh Date: Wed, 20 Apr 2011 09:46:36 -0700 Subject: [PATCH 0010/2494] [feature/avatars] Refactor avatar's handle_form Since it was performing two distinct operations, refactor handle_form to separate functions that prepare and process forms. PHPBB3-10018 --- phpBB/includes/avatar/driver.php | 10 +- phpBB/includes/avatar/driver/local.php | 105 ++++++++------ phpBB/includes/avatar/driver/remote.php | 178 ++++++++++++------------ phpBB/includes/avatar/driver/upload.php | 124 +++++++++-------- phpBB/includes/ucp/ucp_profile.php | 4 +- 5 files changed, 229 insertions(+), 192 deletions(-) diff --git a/phpBB/includes/avatar/driver.php b/phpBB/includes/avatar/driver.php index a2ff5d804d..5d3b734f7b 100644 --- a/phpBB/includes/avatar/driver.php +++ b/phpBB/includes/avatar/driver.php @@ -102,7 +102,15 @@ abstract class phpbb_avatar_driver /** * @TODO **/ - public function handle_form($template, $user_row, &$error, $submitted = false) + public function prepare_form($template, $user_row, &$error) + { + return false; + } + + /** + * @TODO + **/ + public function process_form($template, $user_row, &$error) { return false; } diff --git a/phpBB/includes/avatar/driver/local.php b/phpBB/includes/avatar/driver/local.php index f9b7662e93..47ae143ec9 100644 --- a/phpBB/includes/avatar/driver/local.php +++ b/phpBB/includes/avatar/driver/local.php @@ -47,7 +47,65 @@ class phpbb_avatar_driver_local extends phpbb_avatar_driver /** * @inheritdoc */ - public function handle_form($template, $user_row, &$error, $submitted = false) + public function prepare_form($template, $user_row, &$error) + { + $avatar_list = $this->get_avatar_list(); + $category = request_var('av_local_cat', ''); + + $categories = array_keys($avatar_list); + + foreach ($categories as $cat) + { + if (!empty($avatar_list[$cat])) + { + $template->assign_block_vars('av_local_cats', array( + 'NAME' => $cat, + 'SELECTED' => ($cat == $category), + )); + } + } + + if (!empty($avatar_list[$category])) + { + foreach ($avatar_list[$category] as $img => $data) + { + $template->assign_block_vars('av_local_imgs', array( + 'AVATAR_IMAGE' => $path . '/' . $data['file'], + 'AVATAR_NAME' => $data['name'], + 'AVATAR_FILE' => $data['filename'], + )); + } + } + + return true; + } + + /** + * @inheritdoc + */ + public function process_form($template, $user_row, &$error) + { + $avatar_list = $this->get_avatar_list(); + $category = request_var('av_local_cat', ''); + + $file = request_var('av_local_file', ''); + if (!isset($avatar_list[$category][urldecode($file)])) + { + $error[] = 'AVATAR_URL_NOT_FOUND'; + return false; + } + + return array( + 'user_avatar' => $category . '/' . $file, + 'user_avatar_width' => $avatar_list[$category][urldecode($file)]['width'], + 'user_avatar_height' => $avatar_list[$category][urldecode($file)]['height'], + ); + } + + /** + * @TODO + */ + private function get_avatar_list() { $avatar_list = ($this->cache == null) ? false : $this->cache->get('av_local_list'); @@ -101,50 +159,7 @@ class phpbb_avatar_driver_local extends phpbb_avatar_driver $this->cache->put('av_local_list', $avatar_list); } } - - $category = request_var('av_local_cat', ''); - - if ($submitted) { - $file = request_var('av_local_file', ''); - if (!isset($avatar_list[$category][urldecode($file)])) - { - $error[] = 'AVATAR_URL_NOT_FOUND'; - return false; - } - return array( - 'user_avatar' => $category . '/' . $file, - 'user_avatar_width' => $avatar_list[$category][urldecode($file)]['width'], - 'user_avatar_height' => $avatar_list[$category][urldecode($file)]['height'], - ); - } - - - $categories = array_keys($avatar_list); - - foreach ($categories as $cat) - { - if (!empty($avatar_list[$cat])) - { - $template->assign_block_vars('av_local_cats', array( - 'NAME' => $cat, - 'SELECTED' => ($cat == $category), - )); - } - } - - if (!empty($avatar_list[$category])) - { - foreach ($avatar_list[$category] as $img => $data) - { - $template->assign_block_vars('av_local_imgs', array( - 'AVATAR_IMAGE' => $path . '/' . $data['file'], - 'AVATAR_NAME' => $data['name'], - 'AVATAR_FILE' => $data['filename'], - )); - } - } - - return true; + return $avatar_list; } } diff --git a/phpBB/includes/avatar/driver/remote.php b/phpBB/includes/avatar/driver/remote.php index 48f86cac3f..32f93c7928 100644 --- a/phpBB/includes/avatar/driver/remote.php +++ b/phpBB/includes/avatar/driver/remote.php @@ -47,115 +47,115 @@ class phpbb_avatar_driver_remote extends phpbb_avatar_driver /** * @inheritdoc */ - public function handle_form($template, $user_row, &$error, $submitted = false) + public function prepare_form($template, $user_row, &$error) { - if ($submitted) - { - $url = request_var('av_remote_url', ''); - $width = request_var('av_remote_width', 0); - $height = request_var('av_remote_height', 0); + $template->assign_vars(array( + 'AV_REMOTE_WIDTH' => (($user_row['user_avatar_type'] == AVATAR_REMOTE || $user_row['user_avatar_type'] == 'remote') && $user_row['user_avatar_width']) ? $user_row['user_avatar_width'] : request_var('av_local_width', 0), + 'AV_REMOTE_HEIGHT' => (($user_row['user_avatar_type'] == AVATAR_REMOTE || $user_row['user_avatar_type'] == 'remote') && $user_row['user_avatar_height']) ? $user_row['user_avatar_height'] : request_var('av_local_width', 0), + 'AV_REMOTE_URL' => (($user_row['user_avatar_type'] == AVATAR_REMOTE || $user_row['user_avatar_type'] == 'remote') && $user_row['user_avatar']) ? $user_row['user_avatar'] : '', + )); + + return true; + } + + /** + * @inheritdoc + */ + public function process_form($template, $user_row, &$error) + { + $url = request_var('av_remote_url', ''); + $width = request_var('av_remote_width', 0); + $height = request_var('av_remote_height', 0); - if (!preg_match('#^(http|https|ftp)://#i', $url)) - { - $url = 'http://' . $url; - } + if (!preg_match('#^(http|https|ftp)://#i', $url)) + { + $url = 'http://' . $url; + } - $error = array_merge($error, validate_data(array( - 'url' => $url, - ), array( - 'url' => array('string', true, 5, 255), - ))); + $error = array_merge($error, validate_data(array( + 'url' => $url, + ), array( + 'url' => array('string', true, 5, 255), + ))); - if (!empty($error)) + if (!empty($error)) + { + return false; + } + + // Check if this url looks alright + // This isn't perfect, but it's what phpBB 3.0 did, and might as well make sure everything is compatible + if (!preg_match('#^(http|https|ftp)://(?:(.*?\.)*?[a-z0-9\-]+?\.[a-z]{2,4}|(?:\d{1,3}\.){3,5}\d{1,3}):?([0-9]*?).*?\.(gif|jpg|jpeg|png)$#i', $url)) + { + $error[] = 'AVATAR_URL_INVALID'; + return false; + } + + // Make sure getimagesize works... + if (function_exists('getimagesize')) + { + if (($width <= 0 || $height <= 0) && (($image_data = @getimagesize($url)) === false)) { + $error[] = 'UNABLE_GET_IMAGE_SIZE'; return false; } - // Check if this url looks alright - // This isn't perfect, but it's what phpBB 3.0 did, and might as well make sure everything is compatible - if (!preg_match('#^(http|https|ftp)://(?:(.*?\.)*?[a-z0-9\-]+?\.[a-z]{2,4}|(?:\d{1,3}\.){3,5}\d{1,3}):?([0-9]*?).*?\.(gif|jpg|jpeg|png)$#i', $url)) - { - $error[] = 'AVATAR_URL_INVALID'; - return false; - } - - // Make sure getimagesize works... - if (function_exists('getimagesize')) - { - if (($width <= 0 || $height <= 0) && (($image_data = @getimagesize($url)) === false)) - { - $error[] = 'UNABLE_GET_IMAGE_SIZE'; - return false; - } - - if (!empty($image_data) && ($image_data[0] <= 0 || $image_data[1] <= 0)) - { - $error[] = 'AVATAR_NO_SIZE'; - return false; - } - - $width = ($width && $height) ? $width : $image_data[0]; - $height = ($width && $height) ? $height : $image_data[1]; - } - - if ($width <= 0 || $height <= 0) + if (!empty($image_data) && ($image_data[0] <= 0 || $image_data[1] <= 0)) { $error[] = 'AVATAR_NO_SIZE'; return false; } - include_once($this->phpbb_root_path . 'includes/functions_upload.' . $this->phpEx); - $types = fileupload::image_types(); - $extension = strtolower(filespec::get_extension($url)); + $width = ($width && $height) ? $width : $image_data[0]; + $height = ($width && $height) ? $height : $image_data[1]; + } - if (!empty($image_data) && (!isset($types[$image_data[2]]) || !in_array($extension, $types[$image_data[2]]))) + if ($width <= 0 || $height <= 0) + { + $error[] = 'AVATAR_NO_SIZE'; + return false; + } + + include_once($this->phpbb_root_path . 'includes/functions_upload.' . $this->phpEx); + $types = fileupload::image_types(); + $extension = strtolower(filespec::get_extension($url)); + + if (!empty($image_data) && (!isset($types[$image_data[2]]) || !in_array($extension, $types[$image_data[2]]))) + { + if (!isset($types[$image_data[2]])) { - if (!isset($types[$image_data[2]])) - { - $error[] = 'UNABLE_GET_IMAGE_SIZE'; - } - else - { - $error[] = array('IMAGE_FILETYPE_MISMATCH', $types[$image_data[2]][0], $extension); - } + $error[] = 'UNABLE_GET_IMAGE_SIZE'; + } + else + { + $error[] = array('IMAGE_FILETYPE_MISMATCH', $types[$image_data[2]][0], $extension); + } + return false; + } + + if ($this->config['avatar_max_width'] || $this->config['avatar_max_height']) + { + if ($width > $this->config['avatar_max_width'] || $height > $this->config['avatar_max_height']) + { + $error[] = array('AVATAR_WRONG_SIZE', $this->config['avatar_min_width'], $this->config['avatar_min_height'], $this->config['avatar_max_width'], $this->config['avatar_max_height'], $width, $height); return false; } - - if ($this->config['avatar_max_width'] || $this->config['avatar_max_height']) - { - if ($width > $this->config['avatar_max_width'] || $height > $this->config['avatar_max_height']) - { - $error[] = array('AVATAR_WRONG_SIZE', $this->config['avatar_min_width'], $this->config['avatar_min_height'], $this->config['avatar_max_width'], $this->config['avatar_max_height'], $width, $height); - return false; - } - } - - if ($this->config['avatar_min_width'] || $this->config['avatar_min_height']) - { - if ($width < $this->config['avatar_min_width'] || $height < $this->config['avatar_min_height']) - { - $error[] = array('AVATAR_WRONG_SIZE', $this->config['avatar_min_width'], $this->config['avatar_min_height'], $this->config['avatar_max_width'], $this->config['avatar_max_height'], $width, $height); - return false; - } - } - - $result = array( - 'user_avatar' => $url, - 'user_avatar_width' => $width, - 'user_avatar_height' => $height, - ); - - return $result; } - else + + if ($this->config['avatar_min_width'] || $this->config['avatar_min_height']) { - $template->assign_vars(array( - 'AV_REMOTE_WIDTH' => (($user_row['user_avatar_type'] == AVATAR_REMOTE || $user_row['user_avatar_type'] == 'remote') && $user_row['user_avatar_width']) ? $user_row['user_avatar_width'] : request_var('av_local_width', 0), - 'AV_REMOTE_HEIGHT' => (($user_row['user_avatar_type'] == AVATAR_REMOTE || $user_row['user_avatar_type'] == 'remote') && $user_row['user_avatar_height']) ? $user_row['user_avatar_height'] : request_var('av_local_width', 0), - 'AV_REMOTE_URL' => (($user_row['user_avatar_type'] == AVATAR_REMOTE || $user_row['user_avatar_type'] == 'remote') && $user_row['user_avatar']) ? $user_row['user_avatar'] : '', - )); - return true; + if ($width < $this->config['avatar_min_width'] || $height < $this->config['avatar_min_height']) + { + $error[] = array('AVATAR_WRONG_SIZE', $this->config['avatar_min_width'], $this->config['avatar_min_height'], $this->config['avatar_max_width'], $this->config['avatar_max_height'], $width, $height); + return false; + } } + + return array( + 'user_avatar' => $url, + 'user_avatar_width' => $width, + 'user_avatar_height' => $height, + ); } } diff --git a/phpBB/includes/avatar/driver/upload.php b/phpBB/includes/avatar/driver/upload.php index cbc46e0e49..dd1dbfa5a0 100644 --- a/phpBB/includes/avatar/driver/upload.php +++ b/phpBB/includes/avatar/driver/upload.php @@ -47,66 +47,13 @@ class phpbb_avatar_driver_upload extends phpbb_avatar_driver /** * @inheritdoc */ - public function handle_form($template, $user_row, &$error, $submitted = false) + public function prepare_form($template, $user_row, &$error) { - $can_upload = (file_exists($this->phpbb_root_path . $this->config['avatar_path']) && phpbb_is_writable($this->phpbb_root_path . $this->config['avatar_path']) && (@ini_get('file_uploads') || strtolower(@ini_get('file_uploads')) == 'on')) ? true : false; - - if ($can_upload == false) + if (!$this->can_upload()) { return false; } - if ($submitted) - { - include_once($this->phpbb_root_path . 'includes/functions_upload.' . $this->phpEx); - - $upload = new fileupload('AVATAR_', array('jpg', 'jpeg', 'gif', 'png'), $this->config['avatar_filesize'], $this->config['avatar_min_width'], $this->config['avatar_min_height'], $this->config['avatar_max_width'], $this->config['avatar_max_height'], (isset($this->config['mime_triggers']) ? explode('|', $this->config['mime_triggers']) : false)); - - $url = request_var('av_upload_url', ''); - - if (!empty($_FILES['av_upload_file']['name'])) - { - $file = $upload->form_upload('av_upload_file'); - } - else - { - $file = $upload->remote_upload($url); - } - - $prefix = $this->config['avatar_salt'] . '_'; - $file->clean_filename('avatar', $prefix, $user_row['user_id']); - - $destination = $this->config['avatar_path']; - - // Adjust destination path (no trailing slash) - if (substr($destination, -1, 1) == '/' || substr($destination, -1, 1) == '\\') - { - $destination = substr($destination, 0, -1); - } - - $destination = str_replace(array('../', '..\\', './', '.\\'), '', $destination); - if ($destination && ($destination[0] == '/' || $destination[0] == "\\")) - { - $destination = ''; - } - - // Move file and overwrite any existing image - $file->move_file($destination, true); - - if (sizeof($file->error)) - { - $file->remove(); - $error = array_merge($error, $file->error); - return false; - } - - return array( - 'user_avatar' => $user_row['user_id'] . '_' . time() . '.' . $file->get('extension'), - 'user_avatar_width' => $file->get('width'), - 'user_avatar_height' => $file->get('height'), - ); - } - $template->assign_vars(array( 'S_UPLOAD_AVATAR_URL' => ($this->config['allow_avatar_remote_upload']) ? true : false, 'AV_UPLOAD_SIZE' => $this->config['avatar_filesize'], @@ -114,4 +61,71 @@ class phpbb_avatar_driver_upload extends phpbb_avatar_driver return true; } + + /** + * @inheritdoc + */ + public function process_form($template, $user_row, &$error) + { + if (!$this->can_upload()) + { + return false; + } + + include_once($this->phpbb_root_path . 'includes/functions_upload.' . $this->phpEx); + + $upload = new fileupload('AVATAR_', array('jpg', 'jpeg', 'gif', 'png'), $this->config['avatar_filesize'], $this->config['avatar_min_width'], $this->config['avatar_min_height'], $this->config['avatar_max_width'], $this->config['avatar_max_height'], (isset($this->config['mime_triggers']) ? explode('|', $this->config['mime_triggers']) : false)); + + $url = request_var('av_upload_url', ''); + + if (!empty($_FILES['av_upload_file']['name'])) + { + $file = $upload->form_upload('av_upload_file'); + } + else + { + $file = $upload->remote_upload($url); + } + + $prefix = $this->config['avatar_salt'] . '_'; + $file->clean_filename('avatar', $prefix, $user_row['user_id']); + + $destination = $this->config['avatar_path']; + + // Adjust destination path (no trailing slash) + if (substr($destination, -1, 1) == '/' || substr($destination, -1, 1) == '\\') + { + $destination = substr($destination, 0, -1); + } + + $destination = str_replace(array('../', '..\\', './', '.\\'), '', $destination); + if ($destination && ($destination[0] == '/' || $destination[0] == "\\")) + { + $destination = ''; + } + + // Move file and overwrite any existing image + $file->move_file($destination, true); + + if (sizeof($file->error)) + { + $file->remove(); + $error = array_merge($error, $file->error); + return false; + } + + return array( + 'user_avatar' => $user_row['user_id'] . '_' . time() . '.' . $file->get('extension'), + 'user_avatar_width' => $file->get('width'), + 'user_avatar_height' => $file->get('height'), + ); + } + + /** + * @TODO + */ + private function can_upload() + { + return (file_exists($this->phpbb_root_path . $this->config['avatar_path']) && phpbb_is_writable($this->phpbb_root_path . $this->config['avatar_path']) && (@ini_get('file_uploads') || strtolower(@ini_get('file_uploads')) == 'on')); + } } diff --git a/phpBB/includes/ucp/ucp_profile.php b/phpBB/includes/ucp/ucp_profile.php index a815ec7987..a712547bd1 100644 --- a/phpBB/includes/ucp/ucp_profile.php +++ b/phpBB/includes/ucp/ucp_profile.php @@ -568,7 +568,7 @@ class ucp_profile { if (check_form_key('ucp_avatar')) { - $result = $avatar->handle_form($template, $user->data, $error, true); + $result = $avatar->process_form($template, $user->data, $error); if ($result && empty($error)) { @@ -592,7 +592,7 @@ class ucp_profile } } - if ($avatar->handle_form($template, $user->data, $error)) { + if ($avatar->prepare_form($template, $user->data, $error)) { $driver_u = strtoupper($driver); $template->assign_block_vars('avatar_drivers', array( From 84099e5bc1f452e1a4643fd78658929875ab1eee Mon Sep 17 00:00:00 2001 From: Cullen Walsh Date: Wed, 20 Apr 2011 23:14:38 -0700 Subject: [PATCH 0011/2494] [feature/avatars] Support proper avatar deletion, stub ACP Fixing avatar deletion in the UCP and ACP, and stubbing the ACP configuration page. I'll admit I kind of got caught carried away, so this really should be a couple separate commits. PHPBB3-10018 --- phpBB/adm/style/acp_avatar_options_local.html | 14 +++ .../adm/style/acp_avatar_options_remote.html | 11 +++ .../adm/style/acp_avatar_options_upload.html | 11 +++ phpBB/adm/style/acp_users_avatar.html | 87 ++++--------------- phpBB/includes/acp/acp_users.php | 9 +- phpBB/includes/avatar/driver.php | 8 ++ phpBB/includes/avatar/driver/upload.php | 16 ++++ phpBB/includes/avatar/manager.php | 14 +++ phpBB/includes/functions_user.php | 1 + phpBB/includes/ucp/ucp_profile.php | 33 +++++++ .../template/ucp_avatar_options.html | 7 +- 11 files changed, 130 insertions(+), 81 deletions(-) create mode 100644 phpBB/adm/style/acp_avatar_options_local.html create mode 100644 phpBB/adm/style/acp_avatar_options_remote.html create mode 100644 phpBB/adm/style/acp_avatar_options_upload.html diff --git a/phpBB/adm/style/acp_avatar_options_local.html b/phpBB/adm/style/acp_avatar_options_local.html new file mode 100644 index 0000000000..0dd83db017 --- /dev/null +++ b/phpBB/adm/style/acp_avatar_options_local.html @@ -0,0 +1,14 @@ + + + + diff --git a/phpBB/adm/style/acp_avatar_options_remote.html b/phpBB/adm/style/acp_avatar_options_remote.html new file mode 100644 index 0000000000..02704c5be8 --- /dev/null +++ b/phpBB/adm/style/acp_avatar_options_remote.html @@ -0,0 +1,11 @@ +
+

{L_LINK_REMOTE_AVATAR_EXPLAIN}
+
+
+
+

{L_LINK_REMOTE_SIZE_EXPLAIN}
+
+ ×  + +
+
diff --git a/phpBB/adm/style/acp_avatar_options_upload.html b/phpBB/adm/style/acp_avatar_options_upload.html new file mode 100644 index 0000000000..9c8dd9af01 --- /dev/null +++ b/phpBB/adm/style/acp_avatar_options_upload.html @@ -0,0 +1,11 @@ +
+
+
+
+ + +
+

{L_UPLOAD_AVATAR_URL_EXPLAIN}
+
+
+ diff --git a/phpBB/adm/style/acp_users_avatar.html b/phpBB/adm/style/acp_users_avatar.html index 35d8374237..3d6754830b 100644 --- a/phpBB/adm/style/acp_users_avatar.html +++ b/phpBB/adm/style/acp_users_avatar.html @@ -1,78 +1,23 @@ -
enctype="multipart/form-data"> +
{L_ACP_USER_AVATAR} -
-

{L_AVATAR_EXPLAIN}
-
{AVATAR_IMAGE}
-
-
- - -
-
-
-
- - -
-

{L_UPLOAD_AVATAR_URL_EXPLAIN}
-
-
- - -
-

{L_LINK_REMOTE_AVATAR_EXPLAIN}
-
-
-
-

{L_LINK_REMOTE_SIZE_EXPLAIN}
-
{L_PIXEL} × {L_PIXEL}
-
- - -
-
-
-
- - -
- +

{ERROR}

+
+

{L_AVATAR_EXPLAIN}
+
{AVATAR}
+
+
+ +
- {L_AVATAR_GALLERY} -
-
-
 
-
-
- - - - - - - - - - - - - -
{avatar_row.avatar_column.AVATAR_NAME}
-
+ {avatar_drivers.L_TITLE} +

{avatar_drivers.L_EXPLAIN}

+ {avatar_drivers.OUTPUT}
- -
- +
+   +
- - -
- -
- - {S_FORM_TOKEN} -
- +
diff --git a/phpBB/includes/acp/acp_users.php b/phpBB/includes/acp/acp_users.php index 390e421a51..5dc1829e8b 100644 --- a/phpBB/includes/acp/acp_users.php +++ b/phpBB/includes/acp/acp_users.php @@ -452,10 +452,10 @@ class acp_users { trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); } - + $sql_ary = array( 'user_avatar' => '', - 'user_avatar_type' => 0, + 'user_avatar_type' => '', 'user_avatar_width' => 0, 'user_avatar_height' => 0, ); @@ -466,9 +466,10 @@ class acp_users $db->sql_query($sql); // Delete old avatar if present - if ($user_row['user_avatar'] && $user_row['user_avatar_type'] != AVATAR_GALLERY) + $avatar_manager = new phpbb_avatar_manager($phpbb_root_path, $phpEx, $config, $cache->getDriver()); + if ($driver = $avatar_manager->get_driver($user_row['user_avatar_type'])) { - avatar_delete('user', $user_row); + $driver->delete($user_row); } add_log('admin', 'LOG_USER_DEL_AVATAR', $user_row['username']); diff --git a/phpBB/includes/avatar/driver.php b/phpBB/includes/avatar/driver.php index 5d3b734f7b..5322f73c60 100644 --- a/phpBB/includes/avatar/driver.php +++ b/phpBB/includes/avatar/driver.php @@ -114,4 +114,12 @@ abstract class phpbb_avatar_driver { return false; } + + /** + * @TODO + **/ + public function delete($user_row) + { + return true; + } } diff --git a/phpBB/includes/avatar/driver/upload.php b/phpBB/includes/avatar/driver/upload.php index dd1dbfa5a0..5b487745b1 100644 --- a/phpBB/includes/avatar/driver/upload.php +++ b/phpBB/includes/avatar/driver/upload.php @@ -121,6 +121,22 @@ class phpbb_avatar_driver_upload extends phpbb_avatar_driver ); } + /** + * @inheritdoc + */ + public function delete($user_row) + { + $ext = substr(strrchr($user_row['user_avatar'], '.'), 1); + $filename = $this->phpbb_root_path . $this->config['avatar_path'] . '/' . $this->config['avatar_salt'] . '_' . $user_row['user_id'] . '.' . $ext; + + if (file_exists($filename)) + { + @unlink($filename); + } + + return true; + } + /** * @TODO */ diff --git a/phpBB/includes/avatar/manager.php b/phpBB/includes/avatar/manager.php index 6471c4cc9c..7137243898 100644 --- a/phpBB/includes/avatar/manager.php +++ b/phpBB/includes/avatar/manager.php @@ -47,6 +47,20 @@ class phpbb_avatar_manager $this->load_valid_drivers(); } + // Legacy stuff... + switch ($avatar_type) + { + case AVATAR_LOCAL: + $avatar_type = 'local'; + break; + case AVATAR_UPLOAD: + $avatar_type = 'upload'; + break; + case AVATAR_REMOTE: + $avatar_type = 'remote'; + break; + } + if (isset(self::$valid_drivers[$avatar_type])) { if ($new || !is_object(self::$valid_drivers[$avatar_type])) diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index 509e1a953c..9035cac7be 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -1968,6 +1968,7 @@ function avatar_delete($mode, $row, $clean_db = false) avatar_remove_db($row[$mode . '_avatar']); } $filename = get_avatar_filename($row[$mode . '_avatar']); + if (file_exists($phpbb_root_path . $config['avatar_path'] . '/' . $filename)) { @unlink($phpbb_root_path . $config['avatar_path'] . '/' . $filename); diff --git a/phpBB/includes/ucp/ucp_profile.php b/phpBB/includes/ucp/ucp_profile.php index a712547bd1..222d9e0af4 100644 --- a/phpBB/includes/ucp/ucp_profile.php +++ b/phpBB/includes/ucp/ucp_profile.php @@ -553,6 +553,39 @@ class ucp_profile if ($config['allow_avatar'] && $auth->acl_get('u_chgavatar')) { $avatar_manager = new phpbb_avatar_manager($phpbb_root_path, $phpEx, $config, $cache->getDriver()); + + if (isset($_POST['av_delete'])) + { + if (check_form_key('ucp_avatar')) + { + $result = array( + 'user_avatar' => '', + 'user_avatar_type' => '', + 'user_avatar_width' => 0, + 'user_avatar_height' => 0, + ); + + if ($driver = $avatar_manager->get_driver($user->data['user_avatar_type'])) + { + $driver->delete($user->data); + } + + $sql = 'UPDATE ' . USERS_TABLE . ' + SET ' . $db->sql_build_array('UPDATE', $result) . ' + WHERE user_id = ' . $user->data['user_id']; + + $db->sql_query($sql); + + meta_refresh(3, $this->u_action); + $message = $user->lang['PROFILE_UPDATED'] . '

' . sprintf($user->lang['RETURN_UCP'], '', ''); + trigger_error($message); + } + else + { + $error[] = 'FORM_INVALID'; + } + } + $avatar_drivers = $avatar_manager->get_valid_drivers(); sort($avatar_drivers); diff --git a/phpBB/styles/prosilver/template/ucp_avatar_options.html b/phpBB/styles/prosilver/template/ucp_avatar_options.html index e30fcc74aa..f05e96410d 100644 --- a/phpBB/styles/prosilver/template/ucp_avatar_options.html +++ b/phpBB/styles/prosilver/template/ucp_avatar_options.html @@ -10,7 +10,7 @@

{L_AVATAR_EXPLAIN}
{AVATAR}
-
+
@@ -27,10 +27,5 @@ -
- - -
- From 6d0f2e478800e1e9696701eeff00ac69c1e57dee Mon Sep 17 00:00:00 2001 From: Cullen Walsh Date: Wed, 15 Jun 2011 12:38:17 -0700 Subject: [PATCH 0012/2494] [feature/avatars] Fixing typos in avatar manager and local avatars See above PHPBB3-10018 --- phpBB/includes/avatar/driver/local.php | 2 +- phpBB/includes/avatar/manager.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/avatar/driver/local.php b/phpBB/includes/avatar/driver/local.php index 47ae143ec9..216ad2ce46 100644 --- a/phpBB/includes/avatar/driver/local.php +++ b/phpBB/includes/avatar/driver/local.php @@ -70,7 +70,7 @@ class phpbb_avatar_driver_local extends phpbb_avatar_driver foreach ($avatar_list[$category] as $img => $data) { $template->assign_block_vars('av_local_imgs', array( - 'AVATAR_IMAGE' => $path . '/' . $data['file'], + 'AVATAR_IMAGE' => $this->phpbb_root_path . $this->config['avatar_gallery_path'] . '/' . $data['file'], 'AVATAR_NAME' => $data['name'], 'AVATAR_FILE' => $data['filename'], )); diff --git a/phpBB/includes/avatar/manager.php b/phpBB/includes/avatar/manager.php index 7137243898..001fcf2f14 100644 --- a/phpBB/includes/avatar/manager.php +++ b/phpBB/includes/avatar/manager.php @@ -50,7 +50,7 @@ class phpbb_avatar_manager // Legacy stuff... switch ($avatar_type) { - case AVATAR_LOCAL: + case AVATAR_GALLERY: $avatar_type = 'local'; break; case AVATAR_UPLOAD: From 22c864cb3a945b52fe9b91765d247abfe00b50bc Mon Sep 17 00:00:00 2001 From: Cullen Walsh Date: Wed, 15 Jun 2011 12:58:02 -0700 Subject: [PATCH 0013/2494] [feature/avatars] Dynamically list the avatar types in UCP and ACP List the avatar types more nicely, adding UCP modify user support PHPBB3-10018 --- phpBB/adm/style/acp_users_avatar.html | 6 +- phpBB/includes/acp/acp_users.php | 136 ++++++++++++++++++-------- phpBB/includes/ucp/ucp_profile.php | 9 +- 3 files changed, 103 insertions(+), 48 deletions(-) diff --git a/phpBB/adm/style/acp_users_avatar.html b/phpBB/adm/style/acp_users_avatar.html index 3d6754830b..c0ec9e5f8c 100644 --- a/phpBB/adm/style/acp_users_avatar.html +++ b/phpBB/adm/style/acp_users_avatar.html @@ -5,8 +5,8 @@

{ERROR}


{L_AVATAR_EXPLAIN}
-
{AVATAR}
-
+
{AVATAR}
+
@@ -16,8 +16,8 @@ {avatar_drivers.OUTPUT}
-  
+ {S_FORM_TOKEN} diff --git a/phpBB/includes/acp/acp_users.php b/phpBB/includes/acp/acp_users.php index 5dc1829e8b..9c8a1c683e 100644 --- a/phpBB/includes/acp/acp_users.php +++ b/phpBB/includes/acp/acp_users.php @@ -1683,65 +1683,117 @@ class acp_users case 'avatar': include($phpbb_root_path . 'includes/functions_display.' . $phpEx); - include($phpbb_root_path . 'includes/functions_user.' . $phpEx); - $can_upload = (file_exists($phpbb_root_path . $config['avatar_path']) && phpbb_is_writable($phpbb_root_path . $config['avatar_path']) && $file_uploads) ? true : false; - - if ($submit) + $avatars_enabled = false; + if ($config['allow_avatar']) { + $avatar_manager = new phpbb_avatar_manager($phpbb_root_path, $phpEx, $config, $cache->getDriver()); - if (!check_form_key($form_name)) + if (isset($_POST['av_delete'])) { + if (!check_form_key($form_name)) + { trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); + } + + $result = array( + 'user_avatar' => '', + 'user_avatar_type' => '', + 'user_avatar_height' => 0, + 'user_avatar_width' => 0, + ); + + if ($driver = $avatar_manager->get_driver($user_row['user_avatar_type'])) + { + $driver->delete($user_row); + } + + $sql = 'UPDATE ' . USERS_TABLE . ' + SET ' . $db->sql_build_array('UPDATE', $result) . ' + WHERE user_id = ' . $user_id; + + $db->sql_query($sql); + trigger_error($user->lang['USER_AVATAR_UPDATED'] . adm_back_link($this->u_action . '&u=' . $user_id)); } - if (avatar_process_user($error, $user_row, $can_upload)) + $avatar_drivers = $avatar_manager->get_valid_drivers(); + sort($avatar_drivers); + + foreach ($avatar_drivers as $driver) { - trigger_error($user->lang['USER_AVATAR_UPDATED'] . adm_back_link($this->u_action . '&u=' . $user_row['user_id'])); + if ($config["allow_avatar_$driver"]) + { + $avatars_enabled = true; + $template->set_filenames(array( + 'avatar' => "acp_avatar_options_$driver.html", + )); + + $avatar = $avatar_manager->get_driver($driver); + if (isset($_POST["submit_av_$driver"])) + { + if (!check_form_key($form_name)) + { + trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); + } + + $result = $avatar->process_form($template, $user_row, $error); + + if ($result && empty($error)) + { + // Success! Lets save the result in the database + $result['user_avatar_type'] = $driver; + $sql = 'UPDATE ' . USERS_TABLE . ' + SET ' . $db->sql_build_array('UPDATE', $result) . ' + WHERE user_id = ' . $user_id; + + $db->sql_query($sql); + trigger_error($user->lang['USER_AVATAR_UPDATED'] . adm_back_link($this->u_action . '&u=' . $user_id)); + } + } + + if ($avatar->prepare_form($template, $user_row, $error)) + { + $driver_u = strtoupper($driver); + $template->assign_block_vars('avatar_drivers', array( + 'L_TITLE' => $user->lang('AVATAR_DRIVER_' . $driver_u . '_TITLE'), // @TODO add lang values + 'L_EXPLAIN' => $user->lang('AVATAR_DRIVER_' . $driver_u . '_EXPLAIN'), + 'DRIVER' => $driver, + 'OUTPUT' => $template->assign_display('avatar'), + )); + } + } } - - // Replace "error" strings with their real, localised form - $error = array_map(array($user, 'lang'), $error); } - if (!$config['allow_avatar'] && $user_row['user_avatar_type']) + // Replace "error" strings with their real, localised form + $err = $error; + $error = array(); + foreach ($err as $e) { - $error[] = $user->lang['USER_AVATAR_NOT_ALLOWED']; - } - else if ((($user_row['user_avatar_type'] == AVATAR_UPLOAD) && !$config['allow_avatar_upload']) || - (($user_row['user_avatar_type'] == AVATAR_REMOTE) && !$config['allow_avatar_remote']) || - (($user_row['user_avatar_type'] == AVATAR_GALLERY) && !$config['allow_avatar_local'])) - { - $error[] = $user->lang['USER_AVATAR_TYPE_NOT_ALLOWED']; - } - - // Generate users avatar - $avatar_img = ($user_row['user_avatar']) ? get_user_avatar($user_row, 'USER_AVATAR', true) : ''; - - $display_gallery = (isset($_POST['display_gallery'])) ? true : false; - $avatar_select = basename(request_var('avatar_select', '')); - $category = basename(request_var('category', '')); - - if ($config['allow_avatar_local'] && $display_gallery) - { - avatar_gallery($category, $avatar_select, 4); + if (is_array($e)) + { + $key = array_shift($e); + $error[] = vsprintf($user->lang($key), $e); + } + else + { + $error[] = $user->lang((string) $e); + } } + + $avatar = get_user_avatar($user_row, 'USER_AVATAR', true); $template->assign_vars(array( - 'S_AVATAR' => true, - 'S_CAN_UPLOAD' => $can_upload, - 'S_UPLOAD_FILE' => ($config['allow_avatar'] && $can_upload && $config['allow_avatar_upload']) ? true : false, - 'S_REMOTE_UPLOAD' => ($config['allow_avatar'] && $can_upload && $config['allow_avatar_remote_upload']) ? true : false, - 'S_ALLOW_REMOTE' => ($config['allow_avatar'] && $config['allow_avatar_remote']) ? true : false, - 'S_DISPLAY_GALLERY' => ($config['allow_avatar'] && $config['allow_avatar_local'] && !$display_gallery) ? true : false, - 'S_IN_GALLERY' => ($config['allow_avatar'] && $config['allow_avatar_local'] && $display_gallery) ? true : false, + 'S_AVATAR' => true, + 'ERROR' => (sizeof($error)) ? implode('
', $error) : '', + 'AVATAR' => (empty($avatar) ? '' : $avatar), + 'AV_SHOW_DELETE' => !empty($avatar), - 'AVATAR_IMAGE' => $avatar_img, - 'AVATAR_MAX_FILESIZE' => $config['avatar_filesize'], - 'USER_AVATAR_WIDTH' => $user_row['user_avatar_width'], - 'USER_AVATAR_HEIGHT' => $user_row['user_avatar_height'], + 'S_FORM_ENCTYPE' => ' enctype="multipart/form-data"', - 'L_AVATAR_EXPLAIN' => phpbb_avatar_explanation_string(), + 'L_AVATAR_EXPLAIN' => sprintf($user->lang['AVATAR_EXPLAIN'], $config['avatar_max_width'], $config['avatar_max_height'], $config['avatar_filesize'] / 1024), + + 'S_AVATARS_ENABLED' => ($config['allow_avatar'] && $avatars_enabled), )); break; diff --git a/phpBB/includes/ucp/ucp_profile.php b/phpBB/includes/ucp/ucp_profile.php index 222d9e0af4..bcafd3d636 100644 --- a/phpBB/includes/ucp/ucp_profile.php +++ b/phpBB/includes/ucp/ucp_profile.php @@ -589,8 +589,10 @@ class ucp_profile $avatar_drivers = $avatar_manager->get_valid_drivers(); sort($avatar_drivers); - foreach ($avatar_drivers as $driver) { - if ($config["allow_avatar_$driver"]) { + foreach ($avatar_drivers as $driver) + { + if ($config["allow_avatar_$driver"]) + { $avatars_enabled = true; $template->set_filenames(array( 'avatar' => "ucp_avatar_options_$driver.html", @@ -625,7 +627,8 @@ class ucp_profile } } - if ($avatar->prepare_form($template, $user->data, $error)) { + if ($avatar->prepare_form($template, $user->data, $error)) + { $driver_u = strtoupper($driver); $template->assign_block_vars('avatar_drivers', array( From 6deadc3acf302e9fd15adfd6bff5f0fe525240c7 Mon Sep 17 00:00:00 2001 From: Cullen Walsh Date: Sat, 18 Jun 2011 21:12:29 -0700 Subject: [PATCH 0014/2494] [feature/avatars] Rework UCP to be simpler/more consistent Redesigning the UCP avatar page to use javascript to make use less confusing. This design is also more easily transfered to the ACP for group avatars, which will give better consistency in the long run. PHPBB3-10018 --- phpBB/includes/avatar/driver/remote.php | 2 + phpBB/includes/ucp/ucp_profile.php | 69 +++++++++++++------ .../template/ucp_avatar_options.html | 49 +++++++++++-- 3 files changed, 94 insertions(+), 26 deletions(-) diff --git a/phpBB/includes/avatar/driver/remote.php b/phpBB/includes/avatar/driver/remote.php index 32f93c7928..c28eed93da 100644 --- a/phpBB/includes/avatar/driver/remote.php +++ b/phpBB/includes/avatar/driver/remote.php @@ -72,6 +72,8 @@ class phpbb_avatar_driver_remote extends phpbb_avatar_driver $url = 'http://' . $url; } + require_once($this->phpbb_root_path . 'includes/functions_user.' . $this->phpEx); + $error = array_merge($error, validate_data(array( 'url' => $url, ), array( diff --git a/phpBB/includes/ucp/ucp_profile.php b/phpBB/includes/ucp/ucp_profile.php index bcafd3d636..d5f3ec4b81 100644 --- a/phpBB/includes/ucp/ucp_profile.php +++ b/phpBB/includes/ucp/ucp_profile.php @@ -554,31 +554,60 @@ class ucp_profile { $avatar_manager = new phpbb_avatar_manager($phpbb_root_path, $phpEx, $config, $cache->getDriver()); - if (isset($_POST['av_delete'])) + $avatar_drivers = $avatar_manager->get_valid_drivers(); + sort($avatar_drivers); + + if ($submit) { if (check_form_key('ucp_avatar')) { - $result = array( - 'user_avatar' => '', - 'user_avatar_type' => '', - 'user_avatar_width' => 0, - 'user_avatar_height' => 0, - ); - - if ($driver = $avatar_manager->get_driver($user->data['user_avatar_type'])) + $driver = request_var('avatar_driver', ''); + if (in_array($driver, $avatar_drivers) && $config["allow_avatar_$driver"]) { - $driver->delete($user->data); + $avatar = $avatar_manager->get_driver($driver); + $result = $avatar->process_form($template, $user->data, $error); + + if ($result && empty($error)) + { + // Success! Lets save the result in the database + $result['user_avatar_type'] = $driver; + + $sql = 'UPDATE ' . USERS_TABLE . ' + SET ' . $db->sql_build_array('UPDATE', $result) . ' + WHERE user_id = ' . $user->data['user_id']; + + $db->sql_query($sql); + + meta_refresh(3, $this->u_action); + $message = $user->lang['PROFILE_UPDATED'] . '

' . sprintf($user->lang['RETURN_UCP'], '', ''); + trigger_error($message); + } } - - $sql = 'UPDATE ' . USERS_TABLE . ' - SET ' . $db->sql_build_array('UPDATE', $result) . ' - WHERE user_id = ' . $user->data['user_id']; + else + { + // They are removing their avatar or are trying to play games with us + if ($avatar = $avatar_manager->get_driver($user->data['user_avatar_type'])) + { + $avatar->delete($user->data); + } - $db->sql_query($sql); + $result = array( + 'user_avatar' => '', + 'user_avatar_type' => '', + 'user_avatar_width' => 0, + 'user_avatar_height' => 0, + ); - meta_refresh(3, $this->u_action); - $message = $user->lang['PROFILE_UPDATED'] . '

' . sprintf($user->lang['RETURN_UCP'], '', ''); - trigger_error($message); + $sql = 'UPDATE ' . USERS_TABLE . ' + SET ' . $db->sql_build_array('UPDATE', $result) . ' + WHERE user_id = ' . $user->data['user_id']; + + $db->sql_query($sql); + + meta_refresh(3, $this->u_action); + $message = $user->lang['PROFILE_UPDATED'] . '

' . sprintf($user->lang['RETURN_UCP'], '', ''); + trigger_error($message); + } } else { @@ -586,9 +615,6 @@ class ucp_profile } } - $avatar_drivers = $avatar_manager->get_valid_drivers(); - sort($avatar_drivers); - foreach ($avatar_drivers as $driver) { if ($config["allow_avatar_$driver"]) @@ -636,6 +662,7 @@ class ucp_profile 'L_EXPLAIN' => $user->lang('AVATAR_DRIVER_' . $driver_u . '_EXPLAIN'), 'DRIVER' => $driver, + 'SELECTED' => ($driver == $user->data['user_avatar_type']), 'OUTPUT' => $template->assign_display('avatar'), )); } diff --git a/phpBB/styles/prosilver/template/ucp_avatar_options.html b/phpBB/styles/prosilver/template/ucp_avatar_options.html index f05e96410d..eb78e9f77c 100644 --- a/phpBB/styles/prosilver/template/ucp_avatar_options.html +++ b/phpBB/styles/prosilver/template/ucp_avatar_options.html @@ -10,22 +10,61 @@

{L_AVATAR_EXPLAIN}
{AVATAR}
-
- +

{L_AVATAR_SELECT_NEW}

+
+
+
+
+
+
-

{avatar_drivers.L_TITLE}

+
+

{avatar_drivers.L_EXPLAIN}

{avatar_drivers.OUTPUT}
+
+ +
  - +
- + + + From d0bb14ded1960de47eb07d955a483d74fd9e0af2 Mon Sep 17 00:00:00 2001 From: Cullen Walsh Date: Sat, 18 Jun 2011 22:05:54 -0700 Subject: [PATCH 0015/2494] [feature/avatars] Update ACP manage users, fix gallery focus issue Updated ACP to match UCP with dropdown. Correctly determe which avatar to focus on by checking if the form was submitted and avatar_driver is set. PHPBB3-10018 --- phpBB/adm/style/acp_users_avatar.html | 56 ++++++++++++++---- phpBB/includes/acp/acp_users.php | 84 ++++++++++++++------------- phpBB/includes/avatar/driver.php | 2 +- phpBB/includes/ucp/ucp_profile.php | 31 +--------- 4 files changed, 92 insertions(+), 81 deletions(-) diff --git a/phpBB/adm/style/acp_users_avatar.html b/phpBB/adm/style/acp_users_avatar.html index c0ec9e5f8c..6316ff4a22 100644 --- a/phpBB/adm/style/acp_users_avatar.html +++ b/phpBB/adm/style/acp_users_avatar.html @@ -6,18 +6,52 @@

{L_AVATAR_EXPLAIN}
{AVATAR}
-
- -
- {avatar_drivers.L_TITLE} -

{avatar_drivers.L_EXPLAIN}

- {avatar_drivers.OUTPUT} -
-
- -
- +
+ {L_AVATAR_SELECT_NEW} +
+
+
+
+
+ +
+

{avatar_drivers.L_EXPLAIN}

+ {avatar_drivers.OUTPUT} +
+ +
+
+ + +
+ +
{S_FORM_TOKEN} diff --git a/phpBB/includes/acp/acp_users.php b/phpBB/includes/acp/acp_users.php index 9c8a1c683e..bcce458e20 100644 --- a/phpBB/includes/acp/acp_users.php +++ b/phpBB/includes/acp/acp_users.php @@ -1689,53 +1689,17 @@ class acp_users { $avatar_manager = new phpbb_avatar_manager($phpbb_root_path, $phpEx, $config, $cache->getDriver()); - if (isset($_POST['av_delete'])) - { - if (!check_form_key($form_name)) - { - trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); - } - - $result = array( - 'user_avatar' => '', - 'user_avatar_type' => '', - 'user_avatar_height' => 0, - 'user_avatar_width' => 0, - ); - - if ($driver = $avatar_manager->get_driver($user_row['user_avatar_type'])) - { - $driver->delete($user_row); - } - - $sql = 'UPDATE ' . USERS_TABLE . ' - SET ' . $db->sql_build_array('UPDATE', $result) . ' - WHERE user_id = ' . $user_id; - - $db->sql_query($sql); - trigger_error($user->lang['USER_AVATAR_UPDATED'] . adm_back_link($this->u_action . '&u=' . $user_id)); - } - $avatar_drivers = $avatar_manager->get_valid_drivers(); sort($avatar_drivers); - foreach ($avatar_drivers as $driver) + if ($submit) { - if ($config["allow_avatar_$driver"]) + if (check_form_key($form_name)) { - $avatars_enabled = true; - $template->set_filenames(array( - 'avatar' => "acp_avatar_options_$driver.html", - )); - - $avatar = $avatar_manager->get_driver($driver); - if (isset($_POST["submit_av_$driver"])) + $driver = request_var('avatar_driver', ''); + if (in_array($driver, $avatar_drivers) && $config["allow_avatar_$driver"]) { - if (!check_form_key($form_name)) - { - trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); - } - + $avatar = $avatar_manager->get_driver($driver); $result = $avatar->process_form($template, $user_row, $error); if ($result && empty($error)) @@ -1750,6 +1714,42 @@ class acp_users trigger_error($user->lang['USER_AVATAR_UPDATED'] . adm_back_link($this->u_action . '&u=' . $user_id)); } } + else + { + // Removing the avatar + $result = array( + 'user_avatar' => '', + 'user_avatar_type' => '', + 'user_avatar_width' => 0, + 'user_avatar_height' => 0, + ); + + $sql = 'UPDATE ' . USERS_TABLE . ' + SET ' . $db->sql_build_array('UPDATE', $result) . ' + WHERE user_id = ' . $user_id; + + $db->sql_query($sql); + trigger_error($user->lang['USER_AVATAR_UPDATED'] . adm_back_link($this->u_action . '&u=' . $user_id)); + } + } + else + { + trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); + } + } + + $focused_driver = request_var('avatar_driver', $user_row['user_avatar_type']); + + foreach ($avatar_drivers as $driver) + { + if ($config["allow_avatar_$driver"]) + { + $avatars_enabled = true; + $template->set_filenames(array( + 'avatar' => "acp_avatar_options_$driver.html", + )); + + $avatar = $avatar_manager->get_driver($driver); if ($avatar->prepare_form($template, $user_row, $error)) { @@ -1757,7 +1757,9 @@ class acp_users $template->assign_block_vars('avatar_drivers', array( 'L_TITLE' => $user->lang('AVATAR_DRIVER_' . $driver_u . '_TITLE'), // @TODO add lang values 'L_EXPLAIN' => $user->lang('AVATAR_DRIVER_' . $driver_u . '_EXPLAIN'), + 'DRIVER' => $driver, + 'SELECTED' => ($driver == $focused_driver), 'OUTPUT' => $template->assign_display('avatar'), )); } diff --git a/phpBB/includes/avatar/driver.php b/phpBB/includes/avatar/driver.php index 5322f73c60..1ed5b1a5f7 100644 --- a/phpBB/includes/avatar/driver.php +++ b/phpBB/includes/avatar/driver.php @@ -102,7 +102,7 @@ abstract class phpbb_avatar_driver /** * @TODO **/ - public function prepare_form($template, $user_row, &$error) + public function prepare_form($template, $user_row, &$error, &$override_focus) { return false; } diff --git a/phpBB/includes/ucp/ucp_profile.php b/phpBB/includes/ucp/ucp_profile.php index d5f3ec4b81..186c023798 100644 --- a/phpBB/includes/ucp/ucp_profile.php +++ b/phpBB/includes/ucp/ucp_profile.php @@ -615,6 +615,8 @@ class ucp_profile } } + $focused_driver = request_var('avatar_driver', $user->data['user_avatar_type']); + foreach ($avatar_drivers as $driver) { if ($config["allow_avatar_$driver"]) @@ -625,33 +627,6 @@ class ucp_profile )); $avatar = $avatar_manager->get_driver($driver); - if (isset($_POST["submit_av_$driver"])) - { - if (check_form_key('ucp_avatar')) - { - $result = $avatar->process_form($template, $user->data, $error); - - if ($result && empty($error)) - { - // Success! Lets save the result in the database - $result['user_avatar_type'] = $driver; - - $sql = 'UPDATE ' . USERS_TABLE . ' - SET ' . $db->sql_build_array('UPDATE', $result) . ' - WHERE user_id = ' . $user->data['user_id']; - - $db->sql_query($sql); - - meta_refresh(3, $this->u_action); - $message = $user->lang['PROFILE_UPDATED'] . '

' . sprintf($user->lang['RETURN_UCP'], '', ''); - trigger_error($message); - } - } - else - { - $error[] = 'FORM_INVALID'; - } - } if ($avatar->prepare_form($template, $user->data, $error)) { @@ -662,7 +637,7 @@ class ucp_profile 'L_EXPLAIN' => $user->lang('AVATAR_DRIVER_' . $driver_u . '_EXPLAIN'), 'DRIVER' => $driver, - 'SELECTED' => ($driver == $user->data['user_avatar_type']), + 'SELECTED' => ($driver == $focused_driver), 'OUTPUT' => $template->assign_display('avatar'), )); } From a06380c69a154659f4f9985238008640670669e0 Mon Sep 17 00:00:00 2001 From: Cullen Walsh Date: Sat, 18 Jun 2011 22:50:52 -0700 Subject: [PATCH 0016/2494] [feature/avatars] Make avatars generic Adding a cleaning function for data coming from the users/groups tables so drivers only deal with clean data (ideally). Refactored get_user_avatar() and get_group_avatar() to use an underlying get_avatar() function. PHPBB3-10018 --- phpBB/includes/avatar/driver.php | 69 +++++++++++++++++++++---- phpBB/includes/avatar/driver/local.php | 18 +++---- phpBB/includes/avatar/driver/remote.php | 24 ++++----- phpBB/includes/avatar/driver/upload.php | 26 +++++----- phpBB/includes/functions_display.php | 66 ++++++++++++----------- phpBB/includes/ucp/ucp_profile.php | 16 ++++-- 6 files changed, 141 insertions(+), 78 deletions(-) diff --git a/phpBB/includes/avatar/driver.php b/phpBB/includes/avatar/driver.php index 1ed5b1a5f7..d158c419bd 100644 --- a/phpBB/includes/avatar/driver.php +++ b/phpBB/includes/avatar/driver.php @@ -44,6 +44,12 @@ abstract class phpbb_avatar_driver * @type phpbb_cache_driver_interface */ protected $cache; + + /** + * @TODO + */ + const FROM_USER = 0; + const FROM_GROUP = 1; /** * This flag should be set to true if the avatar requires a nonstandard image @@ -71,12 +77,12 @@ abstract class phpbb_avatar_driver /** * Get the avatar url and dimensions * - * @param $ignore_config Whether this function should respect the users/board - * configuration option, or should just render the avatar anyways. - * Useful for the ACP. + * @param $ignore_config Whether this function should respect the users prefs + * and board configuration configuration option, or should just render + * the avatar anyways. Useful for the ACP. * @return array Avatar data */ - public function get_data($user_row, $ignore_config = false) + public function get_data($row, $ignore_config = false) { return array( 'src' => '', @@ -89,12 +95,12 @@ abstract class phpbb_avatar_driver * Returns custom html for displaying this avatar. * Only called if $custom_html is true. * - * @param $ignore_config Whether this function should respect the users/board - * configuration option, or should just render the avatar anyways. - * Useful for the ACP. + * @param $ignore_config Whether this function should respect the users prefs + * and board configuration configuration option, or should just render + * the avatar anyways. Useful for the ACP. * @return string HTML */ - public function get_custom_html($user_row, $ignore_config = false) + public function get_custom_html($row, $ignore_config = false) { return ''; } @@ -102,7 +108,7 @@ abstract class phpbb_avatar_driver /** * @TODO **/ - public function prepare_form($template, $user_row, &$error, &$override_focus) + public function prepare_form($template, $row, &$error, &$override_focus) { return false; } @@ -110,7 +116,7 @@ abstract class phpbb_avatar_driver /** * @TODO **/ - public function process_form($template, $user_row, &$error) + public function process_form($template, $row, &$error) { return false; } @@ -118,8 +124,49 @@ abstract class phpbb_avatar_driver /** * @TODO **/ - public function delete($user_row) + public function delete($row) { return true; } + + /** + * @TODO + **/ + public static function clean_row($row, $src = phpbb_avatar_driver::FROM_USER) + { + $return = array(); + $prefix = false; + + if ($src == phpbb_avatar_driver::FROM_USER) + { + $prefix = 'user_'; + } + else if ($src == phpbb_avatar_driver::FROM_GROUP) + { + $prefix = 'group_'; + } + + if ($prefix) + { + $len = strlen($prefix); + foreach ($row as $key => $val) + { + $sub = substr($key, 0, $len); + if ($sub == $prefix) + { + $return[substr($key, $len)] = $val; + } + else + { + $return[$key] = $val; + } + } + } + else + { + $return = $row; + } + + return $return; + } } diff --git a/phpBB/includes/avatar/driver/local.php b/phpBB/includes/avatar/driver/local.php index 216ad2ce46..edd62696f0 100644 --- a/phpBB/includes/avatar/driver/local.php +++ b/phpBB/includes/avatar/driver/local.php @@ -24,14 +24,14 @@ class phpbb_avatar_driver_local extends phpbb_avatar_driver /** * @inheritdoc */ - public function get_data($user_row, $ignore_config = false) + public function get_data($row, $ignore_config = false) { if ($ignore_config || $this->config['allow_avatar_local']) { return array( - 'src' => $this->phpbb_root_path . $this->config['avatar_gallery_path'] . '/' . $user_row['user_avatar'], - 'width' => $user_row['user_avatar_width'], - 'height' => $user_row['user_avatar_height'], + 'src' => $this->phpbb_root_path . $this->config['avatar_gallery_path'] . '/' . $row['avatar'], + 'width' => $row['avatar_width'], + 'height' => $row['avatar_height'], ); } else @@ -47,7 +47,7 @@ class phpbb_avatar_driver_local extends phpbb_avatar_driver /** * @inheritdoc */ - public function prepare_form($template, $user_row, &$error) + public function prepare_form($template, $row, &$error) { $avatar_list = $this->get_avatar_list(); $category = request_var('av_local_cat', ''); @@ -83,7 +83,7 @@ class phpbb_avatar_driver_local extends phpbb_avatar_driver /** * @inheritdoc */ - public function process_form($template, $user_row, &$error) + public function process_form($template, $row, &$error) { $avatar_list = $this->get_avatar_list(); $category = request_var('av_local_cat', ''); @@ -96,9 +96,9 @@ class phpbb_avatar_driver_local extends phpbb_avatar_driver } return array( - 'user_avatar' => $category . '/' . $file, - 'user_avatar_width' => $avatar_list[$category][urldecode($file)]['width'], - 'user_avatar_height' => $avatar_list[$category][urldecode($file)]['height'], + 'avatar' => $category . '/' . $file, + 'avatar_width' => $avatar_list[$category][urldecode($file)]['width'], + 'avatar_height' => $avatar_list[$category][urldecode($file)]['height'], ); } diff --git a/phpBB/includes/avatar/driver/remote.php b/phpBB/includes/avatar/driver/remote.php index c28eed93da..cad9850c3f 100644 --- a/phpBB/includes/avatar/driver/remote.php +++ b/phpBB/includes/avatar/driver/remote.php @@ -24,14 +24,14 @@ class phpbb_avatar_driver_remote extends phpbb_avatar_driver /** * @inheritdoc */ - public function get_data($user_row, $ignore_config = false) + public function get_data($row, $ignore_config = false) { if ($ignore_config || $this->config['allow_avatar_remote']) { return array( - 'src' => $user_row['user_avatar'], - 'width' => $user_row['user_avatar_width'], - 'height' => $user_row['user_avatar_height'], + 'src' => $row['avatar'], + 'width' => $row['avatar_width'], + 'height' => $row['avatar_height'], ); } else @@ -47,12 +47,12 @@ class phpbb_avatar_driver_remote extends phpbb_avatar_driver /** * @inheritdoc */ - public function prepare_form($template, $user_row, &$error) + public function prepare_form($template, $row, &$error) { $template->assign_vars(array( - 'AV_REMOTE_WIDTH' => (($user_row['user_avatar_type'] == AVATAR_REMOTE || $user_row['user_avatar_type'] == 'remote') && $user_row['user_avatar_width']) ? $user_row['user_avatar_width'] : request_var('av_local_width', 0), - 'AV_REMOTE_HEIGHT' => (($user_row['user_avatar_type'] == AVATAR_REMOTE || $user_row['user_avatar_type'] == 'remote') && $user_row['user_avatar_height']) ? $user_row['user_avatar_height'] : request_var('av_local_width', 0), - 'AV_REMOTE_URL' => (($user_row['user_avatar_type'] == AVATAR_REMOTE || $user_row['user_avatar_type'] == 'remote') && $user_row['user_avatar']) ? $user_row['user_avatar'] : '', + 'AV_REMOTE_WIDTH' => (($row['avatar_type'] == AVATAR_REMOTE || $row['avatar_type'] == 'remote') && $row['avatar_width']) ? $row['avatar_width'] : request_var('av_local_width', 0), + 'AV_REMOTE_HEIGHT' => (($row['avatar_type'] == AVATAR_REMOTE || $row['avatar_type'] == 'remote') && $row['avatar_height']) ? $row['avatar_height'] : request_var('av_local_width', 0), + 'AV_REMOTE_URL' => (($row['avatar_type'] == AVATAR_REMOTE || $row['avatar_type'] == 'remote') && $row['avatar']) ? $row['avatar'] : '', )); return true; @@ -61,7 +61,7 @@ class phpbb_avatar_driver_remote extends phpbb_avatar_driver /** * @inheritdoc */ - public function process_form($template, $user_row, &$error) + public function process_form($template, $row, &$error) { $url = request_var('av_remote_url', ''); $width = request_var('av_remote_width', 0); @@ -155,9 +155,9 @@ class phpbb_avatar_driver_remote extends phpbb_avatar_driver } return array( - 'user_avatar' => $url, - 'user_avatar_width' => $width, - 'user_avatar_height' => $height, + 'avatar' => $url, + 'avatar_width' => $width, + 'avatar_height' => $height, ); } } diff --git a/phpBB/includes/avatar/driver/upload.php b/phpBB/includes/avatar/driver/upload.php index 5b487745b1..23521ef435 100644 --- a/phpBB/includes/avatar/driver/upload.php +++ b/phpBB/includes/avatar/driver/upload.php @@ -24,14 +24,14 @@ class phpbb_avatar_driver_upload extends phpbb_avatar_driver /** * @inheritdoc */ - public function get_data($user_row, $ignore_config = false) + public function get_data($row, $ignore_config = false) { if ($ignore_config || $this->config['allow_avatar_upload']) { return array( - 'src' => $this->phpbb_root_path . 'download/file.' . $this->phpEx . '?avatar=' . $user_row['user_avatar'], - 'width' => $user_row['user_avatar_width'], - 'height' => $user_row['user_avatar_height'], + 'src' => $this->phpbb_root_path . 'download/file.' . $this->phpEx . '?avatar=' . $row['avatar'], + 'width' => $row['avatar_width'], + 'height' => $row['avatar_height'], ); } else @@ -47,7 +47,7 @@ class phpbb_avatar_driver_upload extends phpbb_avatar_driver /** * @inheritdoc */ - public function prepare_form($template, $user_row, &$error) + public function prepare_form($template, $row, &$error) { if (!$this->can_upload()) { @@ -65,7 +65,7 @@ class phpbb_avatar_driver_upload extends phpbb_avatar_driver /** * @inheritdoc */ - public function process_form($template, $user_row, &$error) + public function process_form($template, $row, &$error) { if (!$this->can_upload()) { @@ -88,7 +88,7 @@ class phpbb_avatar_driver_upload extends phpbb_avatar_driver } $prefix = $this->config['avatar_salt'] . '_'; - $file->clean_filename('avatar', $prefix, $user_row['user_id']); + $file->clean_filename('avatar', $prefix, $row['id']); $destination = $this->config['avatar_path']; @@ -115,19 +115,19 @@ class phpbb_avatar_driver_upload extends phpbb_avatar_driver } return array( - 'user_avatar' => $user_row['user_id'] . '_' . time() . '.' . $file->get('extension'), - 'user_avatar_width' => $file->get('width'), - 'user_avatar_height' => $file->get('height'), + 'avatar' => $row['id'] . '_' . time() . '.' . $file->get('extension'), + 'avatar_width' => $file->get('width'), + 'avatar_height' => $file->get('height'), ); } /** * @inheritdoc */ - public function delete($user_row) + public function delete($row) { - $ext = substr(strrchr($user_row['user_avatar'], '.'), 1); - $filename = $this->phpbb_root_path . $this->config['avatar_path'] . '/' . $this->config['avatar_salt'] . '_' . $user_row['user_id'] . '.' . $ext; + $ext = substr(strrchr($row['avatar'], '.'), 1); + $filename = $this->phpbb_root_path . $this->config['avatar_path'] . '/' . $this->config['avatar_salt'] . '_' . $row['id'] . '.' . $ext; if (file_exists($filename)) { diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php index 23900dfd88..b82f004505 100644 --- a/phpBB/includes/functions_display.php +++ b/phpBB/includes/functions_display.php @@ -1279,6 +1279,36 @@ function get_user_rank($user_rank, $user_posts, &$rank_title, &$rank_img, &$rank * @return string Avatar html */ function get_user_avatar($user_row, $alt = 'USER_AVATAR', $ignore_config = false) +{ + $row = phpbb_avatar_driver::clean_row($user_row, phpbb_avatar_driver::FROM_USER); + return get_avatar($row, $alt, $ignore_config); +} + +/** +* Get group avatar +* +* @param array $group_row Row from the groups table +* @param string $alt Optional language string for alt tag within image, can be a language key or text +* @param bool $ignore_config Ignores the config-setting, to be still able to view the avatar in the UCP +* +* @return string Avatar html +*/ +function get_group_avatar($user_row, $alt = 'GROUP_AVATAR', $ignore_config = false) +{ + $row = phpbb_avatar_driver::clean_row($user_row, phpbb_avatar_driver::FROM_GROUP); + return get_avatar($row, $alt, $ignore_config); +} + +/** +* Get avatar +* +* @param array $row Row cleaned by phpbb_avatar_driver::clean_row +* @param string $alt Optional language string for alt tag within image, can be a language key or text +* @param bool $ignore_config Ignores the config-setting, to be still able to view the avatar in the UCP +* +* @return string Avatar html +*/ +function get_avatar($row, $alt, $ignore_config = false) { global $user, $config, $cache, $phpbb_root_path, $phpEx; @@ -1290,12 +1320,12 @@ function get_user_avatar($user_row, $alt = 'USER_AVATAR', $ignore_config = false } $avatar_data = array( - 'src' => $user_row['user_avatar'], - 'width' => $user_row['user_avatar_width'], - 'height' => $user_row['user_avatar_height'], + 'src' => $row['avatar'], + 'width' => $row['avatar_width'], + 'height' => $row['avatar_height'], ); - switch ($user_row['user_avatar_type']) + switch ($row['avatar_type']) { case AVATAR_UPLOAD: // Compatibility with old avatars @@ -1341,16 +1371,16 @@ function get_user_avatar($user_row, $alt = 'USER_AVATAR', $ignore_config = false $avatar_manager = new phpbb_avatar_manager($phpbb_root_path, $phpEx, $config, $cache->get_driver()); } - $avatar = $avatar_manager->get_driver($user_row['user_avatar_type']); + $avatar = $avatar_manager->get_driver($row['avatar_type']); if ($avatar) { if ($avatar->custom_html) { - return $avatar->get_html($user_row, $ignore_config); + return $avatar->get_html($row, $ignore_config); } - $avatar_data = $avatar->get_data($user_row, $ignore_config); + $avatar_data = $avatar->get_data($row, $ignore_config); } else { @@ -1372,25 +1402,3 @@ function get_user_avatar($user_row, $alt = 'USER_AVATAR', $ignore_config = false return $html; } - -/** -* Get group avatar -* -* @param array $group_row Row from the groups table -* @param string $alt Optional language string for alt tag within image, can be a language key or text -* @param bool $ignore_config Ignores the config-setting, to be still able to view the avatar in the UCP -* -* @return string Avatar html -*/ -function get_group_avatar($group_row, $alt = 'GROUP_AVATAR', $ignore_config = false) -{ - // Kind of abusing this functionality... - $avatar_row = array( - 'user_avatar' => $group_row['group_avatar'], - 'user_avatar_type' => $group_row['group_avatar_type'], - 'user_avatar_width' => $group_row['group_avatar_width'], - 'user_avatar_height' => $group_row['group_avatar_height'], - ); - - return get_user_avatar($group_row, $alt, $ignore_config); -} diff --git a/phpBB/includes/ucp/ucp_profile.php b/phpBB/includes/ucp/ucp_profile.php index 186c023798..1c469fa290 100644 --- a/phpBB/includes/ucp/ucp_profile.php +++ b/phpBB/includes/ucp/ucp_profile.php @@ -556,6 +556,9 @@ class ucp_profile $avatar_drivers = $avatar_manager->get_valid_drivers(); sort($avatar_drivers); + + // This is normalised data, without the user_ prefix + $avatar_data = phpbb_avatar_driver::clean_row($user->data, phpbb_avatar_driver::FROM_USER); if ($submit) { @@ -565,12 +568,17 @@ class ucp_profile if (in_array($driver, $avatar_drivers) && $config["allow_avatar_$driver"]) { $avatar = $avatar_manager->get_driver($driver); - $result = $avatar->process_form($template, $user->data, $error); + $result = $avatar->process_form($template, $avatar_data, $error); if ($result && empty($error)) { // Success! Lets save the result in the database - $result['user_avatar_type'] = $driver; + $result = array( + 'user_avatar_type' => $driver, + 'user_avatar' => $result['avatar'], + 'user_avatar_width' => $result['avatar_width'], + 'user_avatar_height' => $result['avatar_height'], + ); $sql = 'UPDATE ' . USERS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $result) . ' @@ -588,7 +596,7 @@ class ucp_profile // They are removing their avatar or are trying to play games with us if ($avatar = $avatar_manager->get_driver($user->data['user_avatar_type'])) { - $avatar->delete($user->data); + $avatar->delete($avatar_data); } $result = array( @@ -628,7 +636,7 @@ class ucp_profile $avatar = $avatar_manager->get_driver($driver); - if ($avatar->prepare_form($template, $user->data, $error)) + if ($avatar->prepare_form($template, $avatar_data, $error)) { $driver_u = strtoupper($driver); From 8416bf3dc9539df19530e3bef85352d40ac795f2 Mon Sep 17 00:00:00 2001 From: Cullen Walsh Date: Sat, 18 Jun 2011 23:49:04 -0700 Subject: [PATCH 0017/2494] [feature/avatars] Made ACP avatar gallery in Manage Users prettier Added row/column information so avatars can be displayed nicely in the ACP PHPBB3-10018 --- phpBB/adm/style/acp_avatar_options_local.html | 39 ++++++++++++------- phpBB/includes/acp/acp_users.php | 14 +++++-- phpBB/includes/avatar/driver/local.php | 32 ++++++++++++--- .../template/ucp_avatar_options_local.html | 10 +++-- 4 files changed, 68 insertions(+), 27 deletions(-) diff --git a/phpBB/adm/style/acp_avatar_options_local.html b/phpBB/adm/style/acp_avatar_options_local.html index 0dd83db017..0a50a4eed4 100644 --- a/phpBB/adm/style/acp_avatar_options_local.html +++ b/phpBB/adm/style/acp_avatar_options_local.html @@ -1,14 +1,25 @@ - - - - +
+
+
 
+
+
+ + + + + + + + + + + + + +
{av_local_row.av_local_col.AVATAR_NAME}
+
diff --git a/phpBB/includes/acp/acp_users.php b/phpBB/includes/acp/acp_users.php index bcce458e20..9b5c52e28e 100644 --- a/phpBB/includes/acp/acp_users.php +++ b/phpBB/includes/acp/acp_users.php @@ -1692,6 +1692,9 @@ class acp_users $avatar_drivers = $avatar_manager->get_valid_drivers(); sort($avatar_drivers); + // This is normalised data, without the user_ prefix + $avatar_data = phpbb_avatar_driver::clean_row($user_row, phpbb_avatar_driver::FROM_USER); + if ($submit) { if (check_form_key($form_name)) @@ -1700,12 +1703,17 @@ class acp_users if (in_array($driver, $avatar_drivers) && $config["allow_avatar_$driver"]) { $avatar = $avatar_manager->get_driver($driver); - $result = $avatar->process_form($template, $user_row, $error); + $result = $avatar->process_form($template, $avatar_data, $error); if ($result && empty($error)) { // Success! Lets save the result in the database - $result['user_avatar_type'] = $driver; + $result = array( + 'user_avatar_type' => $driver, + 'user_avatar' => $result['avatar'], + 'user_avatar_width' => $result['avatar_width'], + 'user_avatar_height' => $result['avatar_height'], + ); $sql = 'UPDATE ' . USERS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $result) . ' WHERE user_id = ' . $user_id; @@ -1751,7 +1759,7 @@ class acp_users $avatar = $avatar_manager->get_driver($driver); - if ($avatar->prepare_form($template, $user_row, $error)) + if ($avatar->prepare_form($template, $avatar_data, $error)) { $driver_u = strtoupper($driver); $template->assign_block_vars('avatar_drivers', array( diff --git a/phpBB/includes/avatar/driver/local.php b/phpBB/includes/avatar/driver/local.php index edd62696f0..85eda96018 100644 --- a/phpBB/includes/avatar/driver/local.php +++ b/phpBB/includes/avatar/driver/local.php @@ -51,7 +51,7 @@ class phpbb_avatar_driver_local extends phpbb_avatar_driver { $avatar_list = $this->get_avatar_list(); $category = request_var('av_local_cat', ''); - + $categories = array_keys($avatar_list); foreach ($categories as $cat) @@ -67,13 +67,33 @@ class phpbb_avatar_driver_local extends phpbb_avatar_driver if (!empty($avatar_list[$category])) { - foreach ($avatar_list[$category] as $img => $data) + $table_cols = isset($row['av_gallery_cols']) ? $row['av_gallery_cols'] : 4; + $row_count = $col_count = $av_pos = 0; + $av_count = sizeof($avatar_list[$category]); + + reset($avatar_list[$category]); + + while ($av_pos < $av_count) { - $template->assign_block_vars('av_local_imgs', array( - 'AVATAR_IMAGE' => $this->phpbb_root_path . $this->config['avatar_gallery_path'] . '/' . $data['file'], - 'AVATAR_NAME' => $data['name'], - 'AVATAR_FILE' => $data['filename'], + $img = current($avatar_list[$category]); + next($avatar_list[$category]); + + if ($col_count == 0) + { + ++$row_count; + $template->assign_block_vars('av_local_row', array( + )); + } + + $template->assign_block_vars('av_local_row.av_local_col', array( + 'AVATAR_IMAGE' => $this->phpbb_root_path . $this->config['avatar_gallery_path'] . '/' . $img['file'], + 'AVATAR_NAME' => $img['name'], + 'AVATAR_FILE' => $img['filename'], )); + + $col_count = ($col_count + 1) % $table_cols; + + ++$av_pos; } } diff --git a/phpBB/styles/prosilver/template/ucp_avatar_options_local.html b/phpBB/styles/prosilver/template/ucp_avatar_options_local.html index 0dd83db017..9f726e2ff9 100644 --- a/phpBB/styles/prosilver/template/ucp_avatar_options_local.html +++ b/phpBB/styles/prosilver/template/ucp_avatar_options_local.html @@ -7,8 +7,10 @@ From 48e61b1b45655b38660740abb0de9704234af849 Mon Sep 17 00:00:00 2001 From: Cullen Walsh Date: Mon, 4 Jul 2011 16:58:35 -0700 Subject: [PATCH 0018/2494] [feature/avatars] Support editing of group avatars in ACP Edited templates for group avatars so they can be properly modified in ACP PHPBB3-10018 --- phpBB/adm/style/acp_avatar_options_local.html | 2 + phpBB/adm/style/acp_groups.html | 94 ++++----- phpBB/includes/acp/acp_groups.php | 184 +++++++++--------- phpBB/includes/acp/acp_users.php | 1 - phpBB/includes/avatar/driver/local.php | 4 + 5 files changed, 137 insertions(+), 148 deletions(-) diff --git a/phpBB/adm/style/acp_avatar_options_local.html b/phpBB/adm/style/acp_avatar_options_local.html index 0a50a4eed4..d762fa9008 100644 --- a/phpBB/adm/style/acp_avatar_options_local.html +++ b/phpBB/adm/style/acp_avatar_options_local.html @@ -8,6 +8,7 @@  
+ @@ -22,4 +23,5 @@
+
diff --git a/phpBB/adm/style/acp_groups.html b/phpBB/adm/style/acp_groups.html index 158751623a..1c78c0c344 100644 --- a/phpBB/adm/style/acp_groups.html +++ b/phpBB/adm/style/acp_groups.html @@ -104,66 +104,46 @@ {L_GROUP_AVATAR}

{L_AVATAR_EXPLAIN}
-
{AVATAR_IMAGE}
-
+
{AVATAR}
- - -
-
-
-
-
-

{L_UPLOAD_AVATAR_URL_EXPLAIN}
-
-
- -
-

{L_LINK_REMOTE_AVATAR_EXPLAIN}
-
-
-
-

{L_LINK_REMOTE_SIZE_EXPLAIN}
-
{L_PIXEL} × {L_PIXEL}
-
- -
-
-
-
- - - +
+
+
+
+
+ +
+

{avatar_drivers.L_EXPLAIN}

+ {avatar_drivers.OUTPUT} +
+ +
+
diff --git a/phpBB/includes/acp/acp_groups.php b/phpBB/includes/acp/acp_groups.php index 9ad157f78a..16ae8670ce 100644 --- a/phpBB/includes/acp/acp_groups.php +++ b/phpBB/includes/acp/acp_groups.php @@ -54,7 +54,6 @@ class acp_groups // Clear some vars - $can_upload = (file_exists($phpbb_root_path . $config['avatar_path']) && phpbb_is_writable($phpbb_root_path . $config['avatar_path']) && $file_uploads) ? true : false; $group_row = array(); // Grab basic data for group, if group_id is set and exists @@ -281,8 +280,24 @@ class acp_groups $error = array(); $user->add_lang('ucp'); - $avatar_select = basename(request_var('avatar_select', '')); - $category = basename(request_var('category', '')); + // Setup avatar data for later + $avatars_enabled = false; + $avatar_manager = null; + $avatar_drivers = null; + $avatar_data = null; + $avatar_error = array(); + + if ($config['allow_avatar']) + { + $avatar_manager = new phpbb_avatar_manager($phpbb_root_path, $phpEx, $config, $cache->getDriver()); + + $avatar_drivers = $avatar_manager->get_valid_drivers(); + sort($avatar_drivers); + + // This is normalised data, without the group_ prefix + $avatar_data = phpbb_avatar_driver::clean_row($group_row, phpbb_avatar_driver::FROM_GROUP); + } + // Did we submit? if ($update) @@ -300,12 +315,6 @@ class acp_groups $allow_desc_urls = request_var('desc_parse_urls', false); $allow_desc_smilies = request_var('desc_parse_smilies', false); - $data['uploadurl'] = request_var('uploadurl', ''); - $data['remotelink'] = request_var('remotelink', ''); - $data['width'] = request_var('width', ''); - $data['height'] = request_var('height', ''); - $delete = request_var('delete', ''); - $submit_ary = array( 'colour' => request_var('group_colour', ''), 'rank' => request_var('group_rank', 0), @@ -322,81 +331,38 @@ class acp_groups { $submit_ary['founder_manage'] = isset($_REQUEST['group_founder_manage']) ? 1 : 0; } - - if (!empty($_FILES['uploadfile']['tmp_name']) || $data['uploadurl'] || $data['remotelink']) - { - // Avatar stuff - $var_ary = array( - 'uploadurl' => array('string', true, 5, 255), - 'remotelink' => array('string', true, 5, 255), - 'width' => array('string', true, 1, 3), - 'height' => array('string', true, 1, 3), - ); - - if (!($error = validate_data($data, $var_ary))) + + if ($config['allow_avatar']) { + // Handle avatar + $driver = request_var('avatar_driver', ''); + if (in_array($driver, $avatar_drivers) && $config["allow_avatar_$driver"]) { - $data['user_id'] = "g$group_id"; + $avatar = $avatar_manager->get_driver($driver); + $result = $avatar->process_form($template, $avatar_data, $avatar_error); - if ((!empty($_FILES['uploadfile']['tmp_name']) || $data['uploadurl']) && $can_upload) + if ($result && empty($avatar_error)) { - list($submit_ary['avatar_type'], $submit_ary['avatar'], $submit_ary['avatar_width'], $submit_ary['avatar_height']) = avatar_upload($data, $error); - } - else if ($data['remotelink']) - { - list($submit_ary['avatar_type'], $submit_ary['avatar'], $submit_ary['avatar_width'], $submit_ary['avatar_height']) = avatar_remote($data, $error); + // Success! Lets save the result + + /* + $result = array( + 'avatar' => ..., + 'avatar_width' => ..., + 'avatar_height' => ..., + ); + */ + + $submit_ary = array_merge($submit_ary, $result); + $submit_ary['avatar_type'] = $driver; } } - } - else if ($avatar_select && $config['allow_avatar_local']) - { - // check avatar gallery - if (is_dir($phpbb_root_path . $config['avatar_gallery_path'] . '/' . $category)) + else { - $submit_ary['avatar_type'] = AVATAR_GALLERY; - - list($submit_ary['avatar_width'], $submit_ary['avatar_height']) = getimagesize($phpbb_root_path . $config['avatar_gallery_path'] . '/' . $category . '/' . $avatar_select); - $submit_ary['avatar'] = $category . '/' . $avatar_select; - } - } - else if ($delete) - { - $submit_ary['avatar'] = ''; - $submit_ary['avatar_type'] = $submit_ary['avatar_width'] = $submit_ary['avatar_height'] = 0; - } - else if ($data['width'] && $data['height']) - { - // Only update the dimensions? - if ($config['avatar_max_width'] || $config['avatar_max_height']) - { - if ($data['width'] > $config['avatar_max_width'] || $data['height'] > $config['avatar_max_height']) - { - $error[] = phpbb_avatar_error_wrong_size($data['width'], $data['height']); - } - } - - if (!sizeof($error)) - { - if ($config['avatar_min_width'] || $config['avatar_min_height']) - { - if ($data['width'] < $config['avatar_min_width'] || $data['height'] < $config['avatar_min_height']) - { - $error[] = phpbb_avatar_error_wrong_size($data['width'], $data['height']); - } - } - } - - if (!sizeof($error)) - { - $submit_ary['avatar_width'] = $data['width']; - $submit_ary['avatar_height'] = $data['height']; - } - } - - if ((isset($submit_ary['avatar']) && $submit_ary['avatar'] && (!isset($group_row['group_avatar']))) || $delete) - { - if (isset($group_row['group_avatar']) && $group_row['group_avatar']) - { - avatar_delete('group', $group_row, true); + // Removing the avatar + $submit_ary['avatar_type'] = ''; + $submit_ary['avatar'] = ''; + $submit_ary['avatar_width'] = 0; + $submit_ary['avatar_height'] = 0; } } @@ -423,7 +389,7 @@ class acp_groups 'rank' => 'int', 'colour' => 'string', 'avatar' => 'string', - 'avatar_type' => 'int', + 'avatar_type' => 'string', 'avatar_width' => 'int', 'avatar_height' => 'int', 'receive_pm' => 'int', @@ -553,13 +519,54 @@ class acp_groups $type_closed = ($group_type == GROUP_CLOSED) ? ' checked="checked"' : ''; $type_hidden = ($group_type == GROUP_HIDDEN) ? ' checked="checked"' : ''; - $avatar_img = (!empty($group_row['group_avatar'])) ? get_group_avatar($group_row) : ''; - - $display_gallery = (isset($_POST['display_gallery'])) ? true : false; - - if ($config['allow_avatar_local'] && $display_gallery) + // Load up stuff for avatars + if ($config['allow_avatar']) { - avatar_gallery($category, $avatar_select, 4); + $avatars_enabled = false; + $focused_driver = request_var('avatar_driver', $avatar_data['avatar_type']); + + foreach ($avatar_drivers as $driver) + { + if ($config["allow_avatar_$driver"]) + { + $avatars_enabled = true; + $template->set_filenames(array( + 'avatar' => "acp_avatar_options_$driver.html", + )); + + $avatar = $avatar_manager->get_driver($driver); + + if ($avatar->prepare_form($template, $avatar_data, $avatar_error)) + { + $driver_u = strtoupper($driver); + $template->assign_block_vars('avatar_drivers', array( + 'L_TITLE' => $user->lang('AVATAR_DRIVER_' . $driver_u . '_TITLE'), // @TODO add lang values + 'L_EXPLAIN' => $user->lang('AVATAR_DRIVER_' . $driver_u . '_EXPLAIN'), + + 'DRIVER' => $driver, + 'SELECTED' => ($driver == $focused_driver), + 'OUTPUT' => $template->assign_display('avatar'), + )); + } + } + } + } + + $avatar = get_group_avatar($group_row, 'GROUP_AVATAR', true); + + // Merge any avatars errors into the primary error array + // Drivers use lang constants, so we need to map to the actual strings + foreach ($avatar_error as $e) + { + if (is_array($e)) + { + $key = array_shift($e); + $error[] = vsprintf($user->lang($key), $e); + } + else + { + $error[] = $user->lang((string) $e); + } } $back_link = request_var('back_link', ''); @@ -580,12 +587,10 @@ class acp_groups 'S_ADD_GROUP' => ($action == 'add') ? true : false, 'S_GROUP_PERM' => ($action == 'add' && $auth->acl_get('a_authgroups') && $auth->acl_gets('a_aauth', 'a_fauth', 'a_mauth', 'a_uauth')) ? true : false, 'S_INCLUDE_SWATCH' => true, - 'S_CAN_UPLOAD' => $can_upload, 'S_ERROR' => (sizeof($error)) ? true : false, 'S_SPECIAL_GROUP' => ($group_type == GROUP_SPECIAL) ? true : false, - 'S_DISPLAY_GALLERY' => ($config['allow_avatar_local'] && !$display_gallery) ? true : false, - 'S_IN_GALLERY' => ($config['allow_avatar_local'] && $display_gallery) ? true : false, 'S_USER_FOUNDER' => ($user->data['user_type'] == USER_FOUNDER) ? true : false, + 'S_AVATARS_ENABLED' => ($config['allow_avatar'] && $avatars_enabled), 'ERROR_MSG' => (sizeof($error)) ? implode('
', $error) : '', 'GROUP_NAME' => ($group_type == GROUP_SPECIAL) ? $user->lang['G_' . $group_name] : $group_name, @@ -606,8 +611,7 @@ class acp_groups 'S_RANK_OPTIONS' => $rank_options, 'S_GROUP_OPTIONS' => group_select_options(false, false, (($user->data['user_type'] == USER_FOUNDER) ? false : 0)), - 'AVATAR' => $avatar_img, - 'AVATAR_IMAGE' => $avatar_img, + 'AVATAR' => (empty($avatar) ? '' : $avatar), 'AVATAR_MAX_FILESIZE' => $config['avatar_filesize'], 'AVATAR_WIDTH' => (isset($group_row['group_avatar_width'])) ? $group_row['group_avatar_width'] : '', 'AVATAR_HEIGHT' => (isset($group_row['group_avatar_height'])) ? $group_row['group_avatar_height'] : '', diff --git a/phpBB/includes/acp/acp_users.php b/phpBB/includes/acp/acp_users.php index 9b5c52e28e..ad8e7532c0 100644 --- a/phpBB/includes/acp/acp_users.php +++ b/phpBB/includes/acp/acp_users.php @@ -1797,7 +1797,6 @@ class acp_users 'S_AVATAR' => true, 'ERROR' => (sizeof($error)) ? implode('
', $error) : '', 'AVATAR' => (empty($avatar) ? '' : $avatar), - 'AV_SHOW_DELETE' => !empty($avatar), 'S_FORM_ENCTYPE' => ' enctype="multipart/form-data"', diff --git a/phpBB/includes/avatar/driver/local.php b/phpBB/includes/avatar/driver/local.php index 85eda96018..f87854315d 100644 --- a/phpBB/includes/avatar/driver/local.php +++ b/phpBB/includes/avatar/driver/local.php @@ -67,6 +67,10 @@ class phpbb_avatar_driver_local extends phpbb_avatar_driver if (!empty($avatar_list[$category])) { + $template->assign_vars(array( + 'AV_LOCAL_SHOW' => true, + )); + $table_cols = isset($row['av_gallery_cols']) ? $row['av_gallery_cols'] : 4; $row_count = $col_count = $av_pos = 0; $av_count = sizeof($avatar_list[$category]); From 3963b39634225a68687cf1b817a47ae1eeb6ac79 Mon Sep 17 00:00:00 2001 From: Cullen Walsh Date: Mon, 4 Jul 2011 17:19:18 -0700 Subject: [PATCH 0019/2494] [feature/avatars] Making schema changes for db tables These schema changes make manual column chaning uncessesary. PHPBB3-10018 --- phpBB/install/database_update.php | 4 ++++ phpBB/install/schemas/firebird_schema.sql | 4 ++-- phpBB/install/schemas/mssql_schema.sql | 4 ++-- phpBB/install/schemas/mysql_40_schema.sql | 4 ++-- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 843e8c2f23..ba6d5d34e2 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -1092,6 +1092,10 @@ function database_update_info() 'change_columns' => array( GROUPS_TABLE => array( 'group_legend' => array('UINT', 0), + 'group_avatar_type' => array('VCHAR:32', 0), + ), + USERS_TABLE => array( + 'user_avatar_type' => array('VCHAR:32', 0), ), ), 'drop_columns' => array( diff --git a/phpBB/install/schemas/firebird_schema.sql b/phpBB/install/schemas/firebird_schema.sql index daeba45864..8b5bc90afa 100644 --- a/phpBB/install/schemas/firebird_schema.sql +++ b/phpBB/install/schemas/firebird_schema.sql @@ -445,7 +445,7 @@ CREATE TABLE phpbb_groups ( group_desc_uid VARCHAR(8) CHARACTER SET NONE DEFAULT '' NOT NULL, group_display INTEGER DEFAULT 0 NOT NULL, group_avatar VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL, - group_avatar_type INTEGER DEFAULT 0 NOT NULL, + group_avatar_type VARCHAR(32) CHARACTER SET NONE DEFAULT '' NOT NULL, group_avatar_width INTEGER DEFAULT 0 NOT NULL, group_avatar_height INTEGER DEFAULT 0 NOT NULL, group_rank INTEGER DEFAULT 0 NOT NULL, @@ -1317,7 +1317,7 @@ CREATE TABLE phpbb_users ( user_allow_massemail INTEGER DEFAULT 1 NOT NULL, user_options INTEGER DEFAULT 230271 NOT NULL, user_avatar VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL, - user_avatar_type INTEGER DEFAULT 0 NOT NULL, + user_avatar_type VARCHAR(32) CHARACTER SET NONE DEFAULT '' NOT NULL, user_avatar_width INTEGER DEFAULT 0 NOT NULL, user_avatar_height INTEGER DEFAULT 0 NOT NULL, user_sig BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL, diff --git a/phpBB/install/schemas/mssql_schema.sql b/phpBB/install/schemas/mssql_schema.sql index 736917fdcb..65ef420877 100644 --- a/phpBB/install/schemas/mssql_schema.sql +++ b/phpBB/install/schemas/mssql_schema.sql @@ -553,7 +553,7 @@ CREATE TABLE [phpbb_groups] ( [group_desc_uid] [varchar] (8) DEFAULT ('') NOT NULL , [group_display] [int] DEFAULT (0) NOT NULL , [group_avatar] [varchar] (255) DEFAULT ('') NOT NULL , - [group_avatar_type] [int] DEFAULT (0) NOT NULL , + [group_avatar_type] [varchar] (32) DEFAULT ('') NOT NULL , [group_avatar_width] [int] DEFAULT (0) NOT NULL , [group_avatar_height] [int] DEFAULT (0) NOT NULL , [group_rank] [int] DEFAULT (0) NOT NULL , @@ -1603,7 +1603,7 @@ CREATE TABLE [phpbb_users] ( [user_allow_massemail] [int] DEFAULT (1) NOT NULL , [user_options] [int] DEFAULT (230271) NOT NULL , [user_avatar] [varchar] (255) DEFAULT ('') NOT NULL , - [user_avatar_type] [int] DEFAULT (0) NOT NULL , + [user_avatar_type] [varchar] (32) DEFAULT ('') NOT NULL , [user_avatar_width] [int] DEFAULT (0) NOT NULL , [user_avatar_height] [int] DEFAULT (0) NOT NULL , [user_sig] [text] DEFAULT ('') NOT NULL , diff --git a/phpBB/install/schemas/mysql_40_schema.sql b/phpBB/install/schemas/mysql_40_schema.sql index 97c378621b..a41a55494c 100644 --- a/phpBB/install/schemas/mysql_40_schema.sql +++ b/phpBB/install/schemas/mysql_40_schema.sql @@ -317,7 +317,7 @@ CREATE TABLE phpbb_groups ( group_desc_uid varbinary(8) DEFAULT '' NOT NULL, group_display tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, group_avatar varbinary(255) DEFAULT '' NOT NULL, - group_avatar_type tinyint(2) DEFAULT '0' NOT NULL, + group_avatar_type varbinary(32) DEFAULT '' NOT NULL, group_avatar_width smallint(4) UNSIGNED DEFAULT '0' NOT NULL, group_avatar_height smallint(4) UNSIGNED DEFAULT '0' NOT NULL, group_rank mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, @@ -941,7 +941,7 @@ CREATE TABLE phpbb_users ( user_allow_massemail tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, user_options int(11) UNSIGNED DEFAULT '230271' NOT NULL, user_avatar varbinary(255) DEFAULT '' NOT NULL, - user_avatar_type tinyint(2) DEFAULT '0' NOT NULL, + user_avatar_type varbinary(32) DEFAULT '' NOT NULL, user_avatar_width smallint(4) UNSIGNED DEFAULT '0' NOT NULL, user_avatar_height smallint(4) UNSIGNED DEFAULT '0' NOT NULL, user_sig mediumblob NOT NULL, From c7976279e1c85f921156ed499dee1e587587c693 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 7 Apr 2012 18:59:24 +0200 Subject: [PATCH 0020/2494] [feature/avatars] Fix avatar driver filename for autoloading PHPBB3-10018 --- phpBB/includes/avatar/{ => driver}/driver.php | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename phpBB/includes/avatar/{ => driver}/driver.php (100%) diff --git a/phpBB/includes/avatar/driver.php b/phpBB/includes/avatar/driver/driver.php similarity index 100% rename from phpBB/includes/avatar/driver.php rename to phpBB/includes/avatar/driver/driver.php From 3b0e0dba3279a78cab2336d32ee8ff63a7077c5c Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 7 Apr 2012 19:08:54 +0200 Subject: [PATCH 0021/2494] [feature/avatars] Remove unneeded require (class is now autoloaded) PHPBB3-10018 --- phpBB/includes/avatar/manager.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/phpBB/includes/avatar/manager.php b/phpBB/includes/avatar/manager.php index 001fcf2f14..a81b0d1e51 100644 --- a/phpBB/includes/avatar/manager.php +++ b/phpBB/includes/avatar/manager.php @@ -82,8 +82,6 @@ class phpbb_avatar_manager **/ private function load_valid_drivers() { - require_once($this->phpbb_root_path . 'includes/avatar/driver.' . $this->phpEx); - if ($this->cache) { self::$valid_drivers = $this->cache->get('avatar_drivers'); From e861bb0e04c08b03366ec7c58473b630acc91181 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 7 Apr 2012 19:19:13 +0200 Subject: [PATCH 0022/2494] [feature/avatars] Use request object in avatar drivers PHPBB3-10018 --- phpBB/includes/acp/acp_groups.php | 2 +- phpBB/includes/acp/acp_users.php | 5 +++-- phpBB/includes/avatar/driver/driver.php | 12 ++++++++++-- phpBB/includes/avatar/driver/local.php | 8 ++++---- phpBB/includes/avatar/driver/remote.php | 12 ++++++------ phpBB/includes/avatar/driver/upload.php | 2 +- phpBB/includes/avatar/manager.php | 6 ++++-- phpBB/includes/functions_display.php | 3 ++- phpBB/includes/ucp/ucp_profile.php | 4 ++-- 9 files changed, 33 insertions(+), 21 deletions(-) diff --git a/phpBB/includes/acp/acp_groups.php b/phpBB/includes/acp/acp_groups.php index 16ae8670ce..0a22c216c7 100644 --- a/phpBB/includes/acp/acp_groups.php +++ b/phpBB/includes/acp/acp_groups.php @@ -289,7 +289,7 @@ class acp_groups if ($config['allow_avatar']) { - $avatar_manager = new phpbb_avatar_manager($phpbb_root_path, $phpEx, $config, $cache->getDriver()); + $avatar_manager = new phpbb_avatar_manager($phpbb_root_path, $phpEx, $config, $request, $cache->getDriver()); $avatar_drivers = $avatar_manager->get_valid_drivers(); sort($avatar_drivers); diff --git a/phpBB/includes/acp/acp_users.php b/phpBB/includes/acp/acp_users.php index c0da9b8ce0..12da482dbe 100644 --- a/phpBB/includes/acp/acp_users.php +++ b/phpBB/includes/acp/acp_users.php @@ -32,6 +32,7 @@ class acp_users { global $config, $db, $user, $auth, $template, $cache; global $phpbb_root_path, $phpbb_admin_path, $phpEx, $table_prefix, $file_uploads; + global $request; $user->add_lang(array('posting', 'ucp', 'acp/users')); $this->tpl_name = 'acp_users'; @@ -466,7 +467,7 @@ class acp_users $db->sql_query($sql); // Delete old avatar if present - $avatar_manager = new phpbb_avatar_manager($phpbb_root_path, $phpEx, $config, $cache->getDriver()); + $avatar_manager = new phpbb_avatar_manager($phpbb_root_path, $phpEx, $config, $request, $cache->getDriver()); if ($driver = $avatar_manager->get_driver($user_row['user_avatar_type'])) { $driver->delete($user_row); @@ -1687,7 +1688,7 @@ class acp_users $avatars_enabled = false; if ($config['allow_avatar']) { - $avatar_manager = new phpbb_avatar_manager($phpbb_root_path, $phpEx, $config, $cache->getDriver()); + $avatar_manager = new phpbb_avatar_manager($phpbb_root_path, $phpEx, $config, $request, $cache->getDriver()); $avatar_drivers = $avatar_manager->get_valid_drivers(); sort($avatar_drivers); diff --git a/phpBB/includes/avatar/driver/driver.php b/phpBB/includes/avatar/driver/driver.php index d158c419bd..8fb80693fb 100644 --- a/phpBB/includes/avatar/driver/driver.php +++ b/phpBB/includes/avatar/driver/driver.php @@ -26,7 +26,13 @@ abstract class phpbb_avatar_driver * @type phpbb_config */ protected $config; - + + /** + * Current board configuration + * @type phpbb_config + */ + protected $request; + /** * Current $phpbb_root_path * @type string @@ -62,13 +68,15 @@ abstract class phpbb_avatar_driver * Construct an driver object * * @param $config The phpBB configuration + * @param $request The request object * @param $phpbb_root_path The path to the phpBB root * @param $phpEx The php file extension * @param $cache A cache driver */ - public function __construct(phpbb_config $config, $phpbb_root_path, $phpEx, phpbb_cache_driver_interface $cache = null) + public function __construct(phpbb_config $config, phpbb_request $request, $phpbb_root_path, $phpEx, phpbb_cache_driver_interface $cache = null) { $this->config = $config; + $this->request = $request; $this->phpbb_root_path = $phpbb_root_path; $this->phpEx = $phpEx; $this->cache = $cache; diff --git a/phpBB/includes/avatar/driver/local.php b/phpBB/includes/avatar/driver/local.php index f87854315d..27e451c099 100644 --- a/phpBB/includes/avatar/driver/local.php +++ b/phpBB/includes/avatar/driver/local.php @@ -50,7 +50,7 @@ class phpbb_avatar_driver_local extends phpbb_avatar_driver public function prepare_form($template, $row, &$error) { $avatar_list = $this->get_avatar_list(); - $category = request_var('av_local_cat', ''); + $category = $this->request->variable('av_local_cat', ''); $categories = array_keys($avatar_list); @@ -110,9 +110,9 @@ class phpbb_avatar_driver_local extends phpbb_avatar_driver public function process_form($template, $row, &$error) { $avatar_list = $this->get_avatar_list(); - $category = request_var('av_local_cat', ''); - - $file = request_var('av_local_file', ''); + $category = $this->request->variable('av_local_cat', ''); + + $file = $this->request->variable('av_local_file', ''); if (!isset($avatar_list[$category][urldecode($file)])) { $error[] = 'AVATAR_URL_NOT_FOUND'; diff --git a/phpBB/includes/avatar/driver/remote.php b/phpBB/includes/avatar/driver/remote.php index cad9850c3f..cd0a756428 100644 --- a/phpBB/includes/avatar/driver/remote.php +++ b/phpBB/includes/avatar/driver/remote.php @@ -50,8 +50,8 @@ class phpbb_avatar_driver_remote extends phpbb_avatar_driver public function prepare_form($template, $row, &$error) { $template->assign_vars(array( - 'AV_REMOTE_WIDTH' => (($row['avatar_type'] == AVATAR_REMOTE || $row['avatar_type'] == 'remote') && $row['avatar_width']) ? $row['avatar_width'] : request_var('av_local_width', 0), - 'AV_REMOTE_HEIGHT' => (($row['avatar_type'] == AVATAR_REMOTE || $row['avatar_type'] == 'remote') && $row['avatar_height']) ? $row['avatar_height'] : request_var('av_local_width', 0), + 'AV_REMOTE_WIDTH' => (($row['avatar_type'] == AVATAR_REMOTE || $row['avatar_type'] == 'remote') && $row['avatar_width']) ? $row['avatar_width'] : $this->request->variable('av_local_width', 0), + 'AV_REMOTE_HEIGHT' => (($row['avatar_type'] == AVATAR_REMOTE || $row['avatar_type'] == 'remote') && $row['avatar_height']) ? $row['avatar_height'] : $this->request->variable('av_local_width', 0), 'AV_REMOTE_URL' => (($row['avatar_type'] == AVATAR_REMOTE || $row['avatar_type'] == 'remote') && $row['avatar']) ? $row['avatar'] : '', )); @@ -63,10 +63,10 @@ class phpbb_avatar_driver_remote extends phpbb_avatar_driver */ public function process_form($template, $row, &$error) { - $url = request_var('av_remote_url', ''); - $width = request_var('av_remote_width', 0); - $height = request_var('av_remote_height', 0); - + $url = $this->request->variable('av_remote_url', ''); + $width = $this->request->variable('av_remote_width', 0); + $height = $this->request->variable('av_remote_height', 0); + if (!preg_match('#^(http|https|ftp)://#i', $url)) { $url = 'http://' . $url; diff --git a/phpBB/includes/avatar/driver/upload.php b/phpBB/includes/avatar/driver/upload.php index 23521ef435..c7d2b870c1 100644 --- a/phpBB/includes/avatar/driver/upload.php +++ b/phpBB/includes/avatar/driver/upload.php @@ -76,7 +76,7 @@ class phpbb_avatar_driver_upload extends phpbb_avatar_driver $upload = new fileupload('AVATAR_', array('jpg', 'jpeg', 'gif', 'png'), $this->config['avatar_filesize'], $this->config['avatar_min_width'], $this->config['avatar_min_height'], $this->config['avatar_max_width'], $this->config['avatar_max_height'], (isset($this->config['mime_triggers']) ? explode('|', $this->config['mime_triggers']) : false)); - $url = request_var('av_upload_url', ''); + $url = $this->request->variable('av_upload_url', ''); if (!empty($_FILES['av_upload_file']['name'])) { diff --git a/phpBB/includes/avatar/manager.php b/phpBB/includes/avatar/manager.php index a81b0d1e51..f9a262b92f 100644 --- a/phpBB/includes/avatar/manager.php +++ b/phpBB/includes/avatar/manager.php @@ -23,17 +23,19 @@ class phpbb_avatar_manager private $phpbb_root_path; private $phpEx; private $config; + private $request; private $cache; private static $valid_drivers = false; /** * @TODO **/ - public function __construct($phpbb_root_path, $phpEx, phpbb_config $config, phpbb_cache_driver_interface $cache = null) + public function __construct($phpbb_root_path, $phpEx, phpbb_config $config, phpbb_request $request, phpbb_cache_driver_interface $cache = null) { $this->phpbb_root_path = $phpbb_root_path; $this->phpEx = $phpEx; $this->config = $config; + $this->request = $request; $this->cache = $cache; } @@ -66,7 +68,7 @@ class phpbb_avatar_manager if ($new || !is_object(self::$valid_drivers[$avatar_type])) { $class_name = 'phpbb_avatar_driver_' . $avatar_type; - self::$valid_drivers[$avatar_type] = new $class_name($this->config, $this->phpbb_root_path, $this->phpEx, $this->cache); + self::$valid_drivers[$avatar_type] = new $class_name($this->config, $this->request, $this->phpbb_root_path, $this->phpEx, $this->cache); } return self::$valid_drivers[$avatar_type]; diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php index 1c1663f2cc..c59805dacd 100644 --- a/phpBB/includes/functions_display.php +++ b/phpBB/includes/functions_display.php @@ -1312,6 +1312,7 @@ function get_group_avatar($user_row, $alt = 'GROUP_AVATAR', $ignore_config = fal function get_avatar($row, $alt, $ignore_config = false) { global $user, $config, $cache, $phpbb_root_path, $phpEx; + global $request; static $avatar_manager = null; @@ -1369,7 +1370,7 @@ function get_avatar($row, $alt, $ignore_config = false) default: if (empty($avatar_manager)) { - $avatar_manager = new phpbb_avatar_manager($phpbb_root_path, $phpEx, $config, $cache->get_driver()); + $avatar_manager = new phpbb_avatar_manager($phpbb_root_path, $phpEx, $config, $request, $cache->get_driver()); } $avatar = $avatar_manager->get_driver($row['avatar_type']); diff --git a/phpBB/includes/ucp/ucp_profile.php b/phpBB/includes/ucp/ucp_profile.php index 1c469fa290..ffc6ebf556 100644 --- a/phpBB/includes/ucp/ucp_profile.php +++ b/phpBB/includes/ucp/ucp_profile.php @@ -552,8 +552,8 @@ class ucp_profile if ($config['allow_avatar'] && $auth->acl_get('u_chgavatar')) { - $avatar_manager = new phpbb_avatar_manager($phpbb_root_path, $phpEx, $config, $cache->getDriver()); - + $avatar_manager = new phpbb_avatar_manager($phpbb_root_path, $phpEx, $config, $request, $cache->getDriver()); + $avatar_drivers = $avatar_manager->get_valid_drivers(); sort($avatar_drivers); From 0898d114574e88eb5eda819b8921a27739be74ca Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 7 Apr 2012 20:27:11 +0200 Subject: [PATCH 0023/2494] [feature/avatars] Fix CS PHPBB3-10018 --- phpBB/includes/avatar/manager.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/phpBB/includes/avatar/manager.php b/phpBB/includes/avatar/manager.php index f9a262b92f..41429f3a06 100644 --- a/phpBB/includes/avatar/manager.php +++ b/phpBB/includes/avatar/manager.php @@ -116,7 +116,8 @@ class phpbb_avatar_manager /** * @TODO **/ - public function get_valid_drivers() { + public function get_valid_drivers() + { if (self::$valid_drivers === false) { $this->load_valid_drivers(); From e8a9c0ae6d92822699de9a2d7fc1aae9377ade8a Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sun, 8 Apr 2012 16:11:06 +0200 Subject: [PATCH 0024/2494] [feature/avatars] Fix avatar_type in create_schema_files PHPBB3-10018 --- phpBB/develop/create_schema_files.php | 4 ++-- phpBB/install/schemas/mssql_schema.sql | 2 +- phpBB/install/schemas/mysql_41_schema.sql | 4 ++-- phpBB/install/schemas/oracle_schema.sql | 4 ++-- phpBB/install/schemas/postgres_schema.sql | 4 ++-- phpBB/install/schemas/sqlite_schema.sql | 4 ++-- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/phpBB/develop/create_schema_files.php b/phpBB/develop/create_schema_files.php index 4088657743..6418bb57f0 100644 --- a/phpBB/develop/create_schema_files.php +++ b/phpBB/develop/create_schema_files.php @@ -1168,7 +1168,7 @@ function get_schema_struct() 'group_desc_uid' => array('VCHAR:8', ''), 'group_display' => array('BOOL', 0), 'group_avatar' => array('VCHAR', ''), - 'group_avatar_type' => array('TINT:2', 0), + 'group_avatar_type' => array('VCHAR:32', ''), 'group_avatar_width' => array('USINT', 0), 'group_avatar_height' => array('USINT', 0), 'group_rank' => array('UINT', 0), @@ -1821,7 +1821,7 @@ function get_schema_struct() 'user_allow_massemail' => array('BOOL', 1), 'user_options' => array('UINT:11', 230271), 'user_avatar' => array('VCHAR', ''), - 'user_avatar_type' => array('TINT:2', 0), + 'user_avatar_type' => array('VCHAR:32', ''), 'user_avatar_width' => array('USINT', 0), 'user_avatar_height' => array('USINT', 0), 'user_sig' => array('MTEXT_UNI', ''), diff --git a/phpBB/install/schemas/mssql_schema.sql b/phpBB/install/schemas/mssql_schema.sql index 2cf60e9f02..516b030f5a 100644 --- a/phpBB/install/schemas/mssql_schema.sql +++ b/phpBB/install/schemas/mssql_schema.sql @@ -1109,7 +1109,7 @@ CREATE TABLE [phpbb_reports] ( [report_closed] [int] DEFAULT (0) NOT NULL , [report_time] [int] DEFAULT (0) NOT NULL , [report_text] [text] DEFAULT ('') NOT NULL , - [reported_post_text] [text] DEFAULT ('') NOT NULL + [reported_post_text] [text] DEFAULT ('') NOT NULL ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY] GO diff --git a/phpBB/install/schemas/mysql_41_schema.sql b/phpBB/install/schemas/mysql_41_schema.sql index 3fd8d4f1d1..11286e2526 100644 --- a/phpBB/install/schemas/mysql_41_schema.sql +++ b/phpBB/install/schemas/mysql_41_schema.sql @@ -317,7 +317,7 @@ CREATE TABLE phpbb_groups ( group_desc_uid varchar(8) DEFAULT '' NOT NULL, group_display tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, group_avatar varchar(255) DEFAULT '' NOT NULL, - group_avatar_type tinyint(2) DEFAULT '0' NOT NULL, + group_avatar_type varchar(32) DEFAULT '' NOT NULL, group_avatar_width smallint(4) UNSIGNED DEFAULT '0' NOT NULL, group_avatar_height smallint(4) UNSIGNED DEFAULT '0' NOT NULL, group_rank mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, @@ -917,7 +917,7 @@ CREATE TABLE phpbb_users ( user_allow_massemail tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, user_options int(11) UNSIGNED DEFAULT '230271' NOT NULL, user_avatar varchar(255) DEFAULT '' NOT NULL, - user_avatar_type tinyint(2) DEFAULT '0' NOT NULL, + user_avatar_type varchar(32) DEFAULT '' NOT NULL, user_avatar_width smallint(4) UNSIGNED DEFAULT '0' NOT NULL, user_avatar_height smallint(4) UNSIGNED DEFAULT '0' NOT NULL, user_sig mediumtext NOT NULL, diff --git a/phpBB/install/schemas/oracle_schema.sql b/phpBB/install/schemas/oracle_schema.sql index 8a0f3e56b1..3bc6a853ca 100644 --- a/phpBB/install/schemas/oracle_schema.sql +++ b/phpBB/install/schemas/oracle_schema.sql @@ -610,7 +610,7 @@ CREATE TABLE phpbb_groups ( group_desc_uid varchar2(8) DEFAULT '' , group_display number(1) DEFAULT '0' NOT NULL, group_avatar varchar2(255) DEFAULT '' , - group_avatar_type number(2) DEFAULT '0' NOT NULL, + group_avatar_type varchar2(32) DEFAULT '' , group_avatar_width number(4) DEFAULT '0' NOT NULL, group_avatar_height number(4) DEFAULT '0' NOT NULL, group_rank number(8) DEFAULT '0' NOT NULL, @@ -1665,7 +1665,7 @@ CREATE TABLE phpbb_users ( user_allow_massemail number(1) DEFAULT '1' NOT NULL, user_options number(11) DEFAULT '230271' NOT NULL, user_avatar varchar2(255) DEFAULT '' , - user_avatar_type number(2) DEFAULT '0' NOT NULL, + user_avatar_type varchar2(32) DEFAULT '' , user_avatar_width number(4) DEFAULT '0' NOT NULL, user_avatar_height number(4) DEFAULT '0' NOT NULL, user_sig clob DEFAULT '' , diff --git a/phpBB/install/schemas/postgres_schema.sql b/phpBB/install/schemas/postgres_schema.sql index c624024362..f139dc0ced 100644 --- a/phpBB/install/schemas/postgres_schema.sql +++ b/phpBB/install/schemas/postgres_schema.sql @@ -463,7 +463,7 @@ CREATE TABLE phpbb_groups ( group_desc_uid varchar(8) DEFAULT '' NOT NULL, group_display INT2 DEFAULT '0' NOT NULL CHECK (group_display >= 0), group_avatar varchar(255) DEFAULT '' NOT NULL, - group_avatar_type INT2 DEFAULT '0' NOT NULL, + group_avatar_type varchar(32) DEFAULT '' NOT NULL, group_avatar_width INT2 DEFAULT '0' NOT NULL CHECK (group_avatar_width >= 0), group_avatar_height INT2 DEFAULT '0' NOT NULL CHECK (group_avatar_height >= 0), group_rank INT4 DEFAULT '0' NOT NULL CHECK (group_rank >= 0), @@ -1167,7 +1167,7 @@ CREATE TABLE phpbb_users ( user_allow_massemail INT2 DEFAULT '1' NOT NULL CHECK (user_allow_massemail >= 0), user_options INT4 DEFAULT '230271' NOT NULL CHECK (user_options >= 0), user_avatar varchar(255) DEFAULT '' NOT NULL, - user_avatar_type INT2 DEFAULT '0' NOT NULL, + user_avatar_type varchar(32) DEFAULT '' NOT NULL, user_avatar_width INT2 DEFAULT '0' NOT NULL CHECK (user_avatar_width >= 0), user_avatar_height INT2 DEFAULT '0' NOT NULL CHECK (user_avatar_height >= 0), user_sig TEXT DEFAULT '' NOT NULL, diff --git a/phpBB/install/schemas/sqlite_schema.sql b/phpBB/install/schemas/sqlite_schema.sql index bd002c93ed..417464110b 100644 --- a/phpBB/install/schemas/sqlite_schema.sql +++ b/phpBB/install/schemas/sqlite_schema.sql @@ -309,7 +309,7 @@ CREATE TABLE phpbb_groups ( group_desc_uid varchar(8) NOT NULL DEFAULT '', group_display INTEGER UNSIGNED NOT NULL DEFAULT '0', group_avatar varchar(255) NOT NULL DEFAULT '', - group_avatar_type tinyint(2) NOT NULL DEFAULT '0', + group_avatar_type varchar(32) NOT NULL DEFAULT '', group_avatar_width INTEGER UNSIGNED NOT NULL DEFAULT '0', group_avatar_height INTEGER UNSIGNED NOT NULL DEFAULT '0', group_rank INTEGER UNSIGNED NOT NULL DEFAULT '0', @@ -891,7 +891,7 @@ CREATE TABLE phpbb_users ( user_allow_massemail INTEGER UNSIGNED NOT NULL DEFAULT '1', user_options INTEGER UNSIGNED NOT NULL DEFAULT '230271', user_avatar varchar(255) NOT NULL DEFAULT '', - user_avatar_type tinyint(2) NOT NULL DEFAULT '0', + user_avatar_type varchar(32) NOT NULL DEFAULT '', user_avatar_width INTEGER UNSIGNED NOT NULL DEFAULT '0', user_avatar_height INTEGER UNSIGNED NOT NULL DEFAULT '0', user_sig mediumtext(16777215) NOT NULL DEFAULT '', From eea2ec50521e274b928d23f710108f37797cb22c Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sun, 8 Apr 2012 16:27:09 +0200 Subject: [PATCH 0025/2494] [feature/avatars] Introduce global phpbb_avatar_manager PHPBB3-10018 --- phpBB/common.php | 2 ++ phpBB/download/file.php | 2 ++ phpBB/includes/acp/acp_groups.php | 10 ++++------ phpBB/includes/acp/acp_users.php | 12 +++++------- phpBB/includes/functions_display.php | 10 ++-------- phpBB/includes/ucp/ucp_profile.php | 13 ++++++------- 6 files changed, 21 insertions(+), 28 deletions(-) diff --git a/phpBB/common.php b/phpBB/common.php index b3b8d7e4f7..c59c231d28 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -130,6 +130,8 @@ $style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $phpbb_style_ $phpbb_subscriber_loader = new phpbb_event_extension_subscriber_loader($phpbb_dispatcher, $phpbb_extension_manager); $phpbb_subscriber_loader->load(); +$phpbb_avatar_manager = new phpbb_avatar_manager($phpbb_root_path, $phpEx, $config, $request, $cache->get_driver()); + // Add own hook handler require($phpbb_root_path . 'includes/hooks/index.' . $phpEx); $phpbb_hook = new phpbb_hook(array('exit_handler', 'phpbb_user_session_handler', 'append_sid', array('template', 'display'))); diff --git a/phpBB/download/file.php b/phpBB/download/file.php index c01b0789de..55364b3fd0 100644 --- a/phpBB/download/file.php +++ b/phpBB/download/file.php @@ -82,6 +82,8 @@ if (isset($_GET['avatar'])) $phpbb_subscriber_loader = new phpbb_event_extension_subscriber_loader($phpbb_dispatcher, $phpbb_extension_manager); $phpbb_subscriber_loader->load(); + $phpbb_avatar_manager = new phpbb_avatar_manager($phpbb_root_path, $phpEx, $config, $request, $cache->get_driver()); + $filename = request_var('avatar', ''); $avatar_group = false; $exit = false; diff --git a/phpBB/includes/acp/acp_groups.php b/phpBB/includes/acp/acp_groups.php index 0a22c216c7..34c233604a 100644 --- a/phpBB/includes/acp/acp_groups.php +++ b/phpBB/includes/acp/acp_groups.php @@ -26,6 +26,7 @@ class acp_groups { global $config, $db, $user, $auth, $template, $cache; global $phpbb_root_path, $phpbb_admin_path, $phpEx, $table_prefix, $file_uploads; + global $phpbb_avatar_manager; $user->add_lang('acp/groups'); $this->tpl_name = 'acp_groups'; @@ -282,16 +283,13 @@ class acp_groups // Setup avatar data for later $avatars_enabled = false; - $avatar_manager = null; $avatar_drivers = null; $avatar_data = null; $avatar_error = array(); if ($config['allow_avatar']) { - $avatar_manager = new phpbb_avatar_manager($phpbb_root_path, $phpEx, $config, $request, $cache->getDriver()); - - $avatar_drivers = $avatar_manager->get_valid_drivers(); + $avatar_drivers = $phpbb_avatar_manager->get_valid_drivers(); sort($avatar_drivers); // This is normalised data, without the group_ prefix @@ -337,7 +335,7 @@ class acp_groups $driver = request_var('avatar_driver', ''); if (in_array($driver, $avatar_drivers) && $config["allow_avatar_$driver"]) { - $avatar = $avatar_manager->get_driver($driver); + $avatar = $phpbb_avatar_manager->get_driver($driver); $result = $avatar->process_form($template, $avatar_data, $avatar_error); if ($result && empty($avatar_error)) @@ -534,7 +532,7 @@ class acp_groups 'avatar' => "acp_avatar_options_$driver.html", )); - $avatar = $avatar_manager->get_driver($driver); + $avatar = $phpbb_avatar_manager->get_driver($driver); if ($avatar->prepare_form($template, $avatar_data, $avatar_error)) { diff --git a/phpBB/includes/acp/acp_users.php b/phpBB/includes/acp/acp_users.php index 12da482dbe..fac84ba40a 100644 --- a/phpBB/includes/acp/acp_users.php +++ b/phpBB/includes/acp/acp_users.php @@ -33,6 +33,7 @@ class acp_users global $config, $db, $user, $auth, $template, $cache; global $phpbb_root_path, $phpbb_admin_path, $phpEx, $table_prefix, $file_uploads; global $request; + global $phpbb_avatar_manager; $user->add_lang(array('posting', 'ucp', 'acp/users')); $this->tpl_name = 'acp_users'; @@ -467,8 +468,7 @@ class acp_users $db->sql_query($sql); // Delete old avatar if present - $avatar_manager = new phpbb_avatar_manager($phpbb_root_path, $phpEx, $config, $request, $cache->getDriver()); - if ($driver = $avatar_manager->get_driver($user_row['user_avatar_type'])) + if ($driver = $phpbb_avatar_manager->get_driver($user_row['user_avatar_type'])) { $driver->delete($user_row); } @@ -1688,9 +1688,7 @@ class acp_users $avatars_enabled = false; if ($config['allow_avatar']) { - $avatar_manager = new phpbb_avatar_manager($phpbb_root_path, $phpEx, $config, $request, $cache->getDriver()); - - $avatar_drivers = $avatar_manager->get_valid_drivers(); + $avatar_drivers = $phpbb_avatar_manager->get_valid_drivers(); sort($avatar_drivers); // This is normalised data, without the user_ prefix @@ -1703,7 +1701,7 @@ class acp_users $driver = request_var('avatar_driver', ''); if (in_array($driver, $avatar_drivers) && $config["allow_avatar_$driver"]) { - $avatar = $avatar_manager->get_driver($driver); + $avatar = $phpbb_avatar_manager->get_driver($driver); $result = $avatar->process_form($template, $avatar_data, $error); if ($result && empty($error)) @@ -1758,7 +1756,7 @@ class acp_users 'avatar' => "acp_avatar_options_$driver.html", )); - $avatar = $avatar_manager->get_driver($driver); + $avatar = $phpbb_avatar_manager->get_driver($driver); if ($avatar->prepare_form($template, $avatar_data, $error)) { diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php index c59805dacd..e1dd67aeaf 100644 --- a/phpBB/includes/functions_display.php +++ b/phpBB/includes/functions_display.php @@ -1313,8 +1313,7 @@ function get_avatar($row, $alt, $ignore_config = false) { global $user, $config, $cache, $phpbb_root_path, $phpEx; global $request; - - static $avatar_manager = null; + global $phpbb_avatar_manager; if (!$config['allow_avatar'] && !$ignore_config) { @@ -1368,12 +1367,7 @@ function get_avatar($row, $alt, $ignore_config = false) break; default: - if (empty($avatar_manager)) - { - $avatar_manager = new phpbb_avatar_manager($phpbb_root_path, $phpEx, $config, $request, $cache->get_driver()); - } - - $avatar = $avatar_manager->get_driver($row['avatar_type']); + $avatar = $phpbb_avatar_manager->get_driver($row['avatar_type']); if ($avatar) { diff --git a/phpBB/includes/ucp/ucp_profile.php b/phpBB/includes/ucp/ucp_profile.php index ffc6ebf556..58e5254d4b 100644 --- a/phpBB/includes/ucp/ucp_profile.php +++ b/phpBB/includes/ucp/ucp_profile.php @@ -30,6 +30,7 @@ class ucp_profile { global $cache, $config, $db, $user, $auth, $template, $phpbb_root_path, $phpEx; global $request; + global $phpbb_avatar_manager; $user->add_lang('posting'); @@ -552,11 +553,9 @@ class ucp_profile if ($config['allow_avatar'] && $auth->acl_get('u_chgavatar')) { - $avatar_manager = new phpbb_avatar_manager($phpbb_root_path, $phpEx, $config, $request, $cache->getDriver()); - - $avatar_drivers = $avatar_manager->get_valid_drivers(); + $avatar_drivers = $phpbb_avatar_manager->get_valid_drivers(); sort($avatar_drivers); - + // This is normalised data, without the user_ prefix $avatar_data = phpbb_avatar_driver::clean_row($user->data, phpbb_avatar_driver::FROM_USER); @@ -567,7 +566,7 @@ class ucp_profile $driver = request_var('avatar_driver', ''); if (in_array($driver, $avatar_drivers) && $config["allow_avatar_$driver"]) { - $avatar = $avatar_manager->get_driver($driver); + $avatar = $phpbb_avatar_manager->get_driver($driver); $result = $avatar->process_form($template, $avatar_data, $error); if ($result && empty($error)) @@ -594,7 +593,7 @@ class ucp_profile else { // They are removing their avatar or are trying to play games with us - if ($avatar = $avatar_manager->get_driver($user->data['user_avatar_type'])) + if ($avatar = $phpbb_avatar_manager->get_driver($user->data['user_avatar_type'])) { $avatar->delete($avatar_data); } @@ -634,7 +633,7 @@ class ucp_profile 'avatar' => "ucp_avatar_options_$driver.html", )); - $avatar = $avatar_manager->get_driver($driver); + $avatar = $phpbb_avatar_manager->get_driver($driver); if ($avatar->prepare_form($template, $avatar_data, $error)) { From 81fb4268cd141259fe5b3bc9ad51adf2e29e0772 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sun, 8 Apr 2012 16:40:19 +0200 Subject: [PATCH 0026/2494] [feature/avatars] Introduce an avatar driver interface PHPBB3-10018 --- phpBB/includes/acp/acp_groups.php | 2 +- phpBB/includes/acp/acp_users.php | 2 +- phpBB/includes/avatar/driver/driver.php | 39 ++++-------- phpBB/includes/avatar/driver/interface.php | 71 ++++++++++++++++++++++ phpBB/includes/functions_display.php | 4 +- phpBB/includes/ucp/ucp_profile.php | 2 +- 6 files changed, 87 insertions(+), 33 deletions(-) create mode 100644 phpBB/includes/avatar/driver/interface.php diff --git a/phpBB/includes/acp/acp_groups.php b/phpBB/includes/acp/acp_groups.php index 34c233604a..5a45b3b572 100644 --- a/phpBB/includes/acp/acp_groups.php +++ b/phpBB/includes/acp/acp_groups.php @@ -293,7 +293,7 @@ class acp_groups sort($avatar_drivers); // This is normalised data, without the group_ prefix - $avatar_data = phpbb_avatar_driver::clean_row($group_row, phpbb_avatar_driver::FROM_GROUP); + $avatar_data = phpbb_avatar_driver::clean_row($group_row, phpbb_avatar_driver_interface::FROM_GROUP); } diff --git a/phpBB/includes/acp/acp_users.php b/phpBB/includes/acp/acp_users.php index fac84ba40a..9c12116062 100644 --- a/phpBB/includes/acp/acp_users.php +++ b/phpBB/includes/acp/acp_users.php @@ -1692,7 +1692,7 @@ class acp_users sort($avatar_drivers); // This is normalised data, without the user_ prefix - $avatar_data = phpbb_avatar_driver::clean_row($user_row, phpbb_avatar_driver::FROM_USER); + $avatar_data = phpbb_avatar_driver::clean_row($user_row, phpbb_avatar_driver_interface::FROM_USER); if ($submit) { diff --git a/phpBB/includes/avatar/driver/driver.php b/phpBB/includes/avatar/driver/driver.php index 8fb80693fb..277130e819 100644 --- a/phpBB/includes/avatar/driver/driver.php +++ b/phpBB/includes/avatar/driver/driver.php @@ -19,7 +19,7 @@ if (!defined('IN_PHPBB')) * Base class for avatar drivers * @package avatars */ -abstract class phpbb_avatar_driver +abstract class phpbb_avatar_driver implements phpbb_avatar_driver_interface { /** * Current board configuration @@ -51,12 +51,6 @@ abstract class phpbb_avatar_driver */ protected $cache; - /** - * @TODO - */ - const FROM_USER = 0; - const FROM_GROUP = 1; - /** * This flag should be set to true if the avatar requires a nonstandard image * tag, and will generate the html itself. @@ -83,12 +77,7 @@ abstract class phpbb_avatar_driver } /** - * Get the avatar url and dimensions - * - * @param $ignore_config Whether this function should respect the users prefs - * and board configuration configuration option, or should just render - * the avatar anyways. Useful for the ACP. - * @return array Avatar data + * @inheritdoc */ public function get_data($row, $ignore_config = false) { @@ -100,13 +89,7 @@ abstract class phpbb_avatar_driver } /** - * Returns custom html for displaying this avatar. - * Only called if $custom_html is true. - * - * @param $ignore_config Whether this function should respect the users prefs - * and board configuration configuration option, or should just render - * the avatar anyways. Useful for the ACP. - * @return string HTML + * @inheritdoc */ public function get_custom_html($row, $ignore_config = false) { @@ -114,7 +97,7 @@ abstract class phpbb_avatar_driver } /** - * @TODO + * @inheritdoc **/ public function prepare_form($template, $row, &$error, &$override_focus) { @@ -122,7 +105,7 @@ abstract class phpbb_avatar_driver } /** - * @TODO + * @inheritdoc **/ public function process_form($template, $row, &$error) { @@ -130,7 +113,7 @@ abstract class phpbb_avatar_driver } /** - * @TODO + * @inheritdoc **/ public function delete($row) { @@ -138,18 +121,18 @@ abstract class phpbb_avatar_driver } /** - * @TODO + * @inheritdoc **/ - public static function clean_row($row, $src = phpbb_avatar_driver::FROM_USER) + public static function clean_row($row, $src = phpbb_avatar_driver_interface::FROM_USER) { $return = array(); $prefix = false; - - if ($src == phpbb_avatar_driver::FROM_USER) + + if ($src == phpbb_avatar_driver_interface::FROM_USER) { $prefix = 'user_'; } - else if ($src == phpbb_avatar_driver::FROM_GROUP) + else if ($src == phpbb_avatar_driver_interface::FROM_GROUP) { $prefix = 'group_'; } diff --git a/phpBB/includes/avatar/driver/interface.php b/phpBB/includes/avatar/driver/interface.php new file mode 100644 index 0000000000..dcec5811bb --- /dev/null +++ b/phpBB/includes/avatar/driver/interface.php @@ -0,0 +1,71 @@ + '', 'width' => 0, 'height' => 0] + */ + public function get_data($row, $ignore_config = false); + + /** + * Returns custom html for displaying this avatar. + * Only called if $custom_html is true. + * + * @param $ignore_config Whether this function should respect the users prefs + * and board configuration configuration option, or should just render + * the avatar anyways. Useful for the ACP. + * @return string HTML + */ + public function get_custom_html($row, $ignore_config = false); + + /** + * @TODO + **/ + public function prepare_form($template, $row, &$error, &$override_focus); + + /** + * @TODO + **/ + public function process_form($template, $row, &$error); + + /** + * @TODO + **/ + public function delete($row); + + /** + * @TODO + **/ + public static function clean_row($row, $src = phpbb_avatar_driver_interface::FROM_USER); +} diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php index e1dd67aeaf..82638b7f2b 100644 --- a/phpBB/includes/functions_display.php +++ b/phpBB/includes/functions_display.php @@ -1281,7 +1281,7 @@ function get_user_rank($user_rank, $user_posts, &$rank_title, &$rank_img, &$rank */ function get_user_avatar($user_row, $alt = 'USER_AVATAR', $ignore_config = false) { - $row = phpbb_avatar_driver::clean_row($user_row, phpbb_avatar_driver::FROM_USER); + $row = phpbb_avatar_driver::clean_row($user_row, phpbb_avatar_driver_interface::FROM_USER); return get_avatar($row, $alt, $ignore_config); } @@ -1296,7 +1296,7 @@ function get_user_avatar($user_row, $alt = 'USER_AVATAR', $ignore_config = false */ function get_group_avatar($user_row, $alt = 'GROUP_AVATAR', $ignore_config = false) { - $row = phpbb_avatar_driver::clean_row($user_row, phpbb_avatar_driver::FROM_GROUP); + $row = phpbb_avatar_driver::clean_row($user_row, phpbb_avatar_driver_interface::FROM_GROUP); return get_avatar($row, $alt, $ignore_config); } diff --git a/phpBB/includes/ucp/ucp_profile.php b/phpBB/includes/ucp/ucp_profile.php index 58e5254d4b..9d22fd4dba 100644 --- a/phpBB/includes/ucp/ucp_profile.php +++ b/phpBB/includes/ucp/ucp_profile.php @@ -557,7 +557,7 @@ class ucp_profile sort($avatar_drivers); // This is normalised data, without the user_ prefix - $avatar_data = phpbb_avatar_driver::clean_row($user->data, phpbb_avatar_driver::FROM_USER); + $avatar_data = phpbb_avatar_driver::clean_row($user->data, phpbb_avatar_driver_interface::FROM_USER); if ($submit) { From 3b71e81cfba726043063b05cb793e18186143252 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sun, 8 Apr 2012 21:29:52 +0200 Subject: [PATCH 0027/2494] [feature/avatars] Simplify clean_row, move it to avatar manager PHPBB3-10018 --- phpBB/includes/acp/acp_groups.php | 2 +- phpBB/includes/acp/acp_users.php | 2 +- phpBB/includes/avatar/driver/driver.php | 41 ---------------------- phpBB/includes/avatar/driver/interface.php | 11 ------ phpBB/includes/avatar/manager.php | 19 ++++++++++ phpBB/includes/functions_display.php | 4 +-- phpBB/includes/ucp/ucp_profile.php | 2 +- 7 files changed, 24 insertions(+), 57 deletions(-) diff --git a/phpBB/includes/acp/acp_groups.php b/phpBB/includes/acp/acp_groups.php index 5a45b3b572..d4a3e40d93 100644 --- a/phpBB/includes/acp/acp_groups.php +++ b/phpBB/includes/acp/acp_groups.php @@ -293,7 +293,7 @@ class acp_groups sort($avatar_drivers); // This is normalised data, without the group_ prefix - $avatar_data = phpbb_avatar_driver::clean_row($group_row, phpbb_avatar_driver_interface::FROM_GROUP); + $avatar_data = phpbb_avatar_manager::clean_row($group_row); } diff --git a/phpBB/includes/acp/acp_users.php b/phpBB/includes/acp/acp_users.php index 9c12116062..cd50b02ca1 100644 --- a/phpBB/includes/acp/acp_users.php +++ b/phpBB/includes/acp/acp_users.php @@ -1692,7 +1692,7 @@ class acp_users sort($avatar_drivers); // This is normalised data, without the user_ prefix - $avatar_data = phpbb_avatar_driver::clean_row($user_row, phpbb_avatar_driver_interface::FROM_USER); + $avatar_data = phpbb_avatar_manager::clean_row($user_row); if ($submit) { diff --git a/phpBB/includes/avatar/driver/driver.php b/phpBB/includes/avatar/driver/driver.php index 277130e819..7028df4b64 100644 --- a/phpBB/includes/avatar/driver/driver.php +++ b/phpBB/includes/avatar/driver/driver.php @@ -119,45 +119,4 @@ abstract class phpbb_avatar_driver implements phpbb_avatar_driver_interface { return true; } - - /** - * @inheritdoc - **/ - public static function clean_row($row, $src = phpbb_avatar_driver_interface::FROM_USER) - { - $return = array(); - $prefix = false; - - if ($src == phpbb_avatar_driver_interface::FROM_USER) - { - $prefix = 'user_'; - } - else if ($src == phpbb_avatar_driver_interface::FROM_GROUP) - { - $prefix = 'group_'; - } - - if ($prefix) - { - $len = strlen($prefix); - foreach ($row as $key => $val) - { - $sub = substr($key, 0, $len); - if ($sub == $prefix) - { - $return[substr($key, $len)] = $val; - } - else - { - $return[$key] = $val; - } - } - } - else - { - $return = $row; - } - - return $return; - } } diff --git a/phpBB/includes/avatar/driver/interface.php b/phpBB/includes/avatar/driver/interface.php index dcec5811bb..8c8a067d13 100644 --- a/phpBB/includes/avatar/driver/interface.php +++ b/phpBB/includes/avatar/driver/interface.php @@ -21,12 +21,6 @@ if (!defined('IN_PHPBB')) */ interface phpbb_avatar_driver_interface { - /** - * @TODO - */ - const FROM_USER = 0; - const FROM_GROUP = 1; - /** * Get the avatar url and dimensions * @@ -63,9 +57,4 @@ interface phpbb_avatar_driver_interface * @TODO **/ public function delete($row); - - /** - * @TODO - **/ - public static function clean_row($row, $src = phpbb_avatar_driver_interface::FROM_USER); } diff --git a/phpBB/includes/avatar/manager.php b/phpBB/includes/avatar/manager.php index 41429f3a06..054bb0cee9 100644 --- a/phpBB/includes/avatar/manager.php +++ b/phpBB/includes/avatar/manager.php @@ -125,4 +125,23 @@ class phpbb_avatar_manager return array_keys(self::$valid_drivers); } + + /** + * Strip out user_ and group_ prefixes from keys + **/ + public static function clean_row($row) + { + $keys = array_keys($row); + $values = array_values($row); + + $keys = array_map( + function ($key) + { + return preg_replace('(user_|group_)', '', $key); + }, + $row + ); + + return array_combine($keys, $values); + } } diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php index 82638b7f2b..619c30ada5 100644 --- a/phpBB/includes/functions_display.php +++ b/phpBB/includes/functions_display.php @@ -1281,7 +1281,7 @@ function get_user_rank($user_rank, $user_posts, &$rank_title, &$rank_img, &$rank */ function get_user_avatar($user_row, $alt = 'USER_AVATAR', $ignore_config = false) { - $row = phpbb_avatar_driver::clean_row($user_row, phpbb_avatar_driver_interface::FROM_USER); + $row = phpbb_avatar_manager::clean_row($user_row); return get_avatar($row, $alt, $ignore_config); } @@ -1296,7 +1296,7 @@ function get_user_avatar($user_row, $alt = 'USER_AVATAR', $ignore_config = false */ function get_group_avatar($user_row, $alt = 'GROUP_AVATAR', $ignore_config = false) { - $row = phpbb_avatar_driver::clean_row($user_row, phpbb_avatar_driver_interface::FROM_GROUP); + $row = phpbb_avatar_manager::clean_row($user_row); return get_avatar($row, $alt, $ignore_config); } diff --git a/phpBB/includes/ucp/ucp_profile.php b/phpBB/includes/ucp/ucp_profile.php index 9d22fd4dba..44dc57cfd7 100644 --- a/phpBB/includes/ucp/ucp_profile.php +++ b/phpBB/includes/ucp/ucp_profile.php @@ -557,7 +557,7 @@ class ucp_profile sort($avatar_drivers); // This is normalised data, without the user_ prefix - $avatar_data = phpbb_avatar_driver::clean_row($user->data, phpbb_avatar_driver_interface::FROM_USER); + $avatar_data = phpbb_avatar_manager::clean_row($user->data); if ($submit) { From a1132fc5c7e990d73cbc8ac7abf4502a1bbe7216 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sun, 8 Apr 2012 21:45:51 +0200 Subject: [PATCH 0028/2494] [feature/avatars] Update avatars in database_update PHPBB3-10018 --- phpBB/includes/functions_display.php | 72 ++++++---------------------- phpBB/install/database_update.php | 24 +++++++++- 2 files changed, 36 insertions(+), 60 deletions(-) diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php index 619c30ada5..291d92387f 100644 --- a/phpBB/includes/functions_display.php +++ b/phpBB/includes/functions_display.php @@ -1325,72 +1325,28 @@ function get_avatar($row, $alt, $ignore_config = false) 'width' => $row['avatar_width'], 'height' => $row['avatar_height'], ); - - switch ($row['avatar_type']) + + $avatar = $phpbb_avatar_manager->get_driver($row['avatar_type']); + + if ($avatar) { - case AVATAR_UPLOAD: - // Compatibility with old avatars - if (!$config['allow_avatar_upload'] && !$ignore_config) - { - $avatar_data['src'] = ''; - } - else - { - $avatar_data['src'] = $phpbb_root_path . "download/file.$phpEx?avatar=" . $avatar_data['src']; - $avatar_data['src'] = str_replace(' ', '%20', $avatar_data['src']); - } - break; + if ($avatar->custom_html) + { + return $avatar->get_html($row, $ignore_config); + } - case AVATAR_GALLERY: - // Compatibility with old avatars - if (!$config['allow_avatar_local'] && !$ignore_config) - { - $avatar_data['src'] = ''; - } - else - { - $avatar_data['src'] = $phpbb_root_path . $config['avatar_gallery_path'] . '/' . $avatar_data['src']; - $avatar_data['src'] = str_replace(' ', '%20', $avatar_data['src']); - } - break; - - case AVATAR_REMOTE: - // Compatibility with old avatars - if (!$config['allow_avatar_remote'] && !$ignore_config) - { - $avatar_data['src'] = ''; - } - else - { - $avatar_data['src'] = str_replace(' ', '%20', $avatar_data['src']); - } - break; - - default: - $avatar = $phpbb_avatar_manager->get_driver($row['avatar_type']); - - if ($avatar) - { - if ($avatar->custom_html) - { - return $avatar->get_html($row, $ignore_config); - } - - $avatar_data = $avatar->get_data($row, $ignore_config); - } - else - { - $avatar_data['src'] = ''; - } - - break; + $avatar_data = $avatar->get_data($row, $ignore_config); + } + else + { + $avatar_data['src'] = ''; } $html = ''; if (!empty($avatar_data['src'])) { - $html = ''; diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index e85fe1810d..75f1ada749 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -2391,13 +2391,33 @@ function change_database_data(&$no_updates, $version) { set_config('teampage_memberships', '1'); } - + // Clear styles table and add prosilver entry _sql('DELETE FROM ' . STYLES_TABLE, $errored, $error_ary); $sql = 'INSERT INTO ' . STYLES_TABLE . " (style_name, style_copyright, style_active, style_path, bbcode_bitfield, style_parent_id, style_parent_tree) VALUES ('prosilver', '© phpBB Group', 1, 'prosilver', 'kNg=', 0, '')"; _sql($sql, $errored, $error_ary); - + + // Update avatars to modular types + $avatar_type_map = array( + AVATAR_UPLOAD => 'upload', + AVATAR_GALLERY => 'local', + AVATAR_REMOTE => 'remote', + ); + + foreach ($avatar_type_map as $old => $new) + { + $sql = 'UPDATE ' . USERS_TABLE . " + SET user_avatar_type = '" . $db->sql_escape($new) . "' + WHERE user_avatar_type = '" . $db->sql_escape($old) . "'"; + _sql($sql, $errored, $error_ary); + + $sql = 'UPDATE ' . GROUPS_TABLE . " + SET group_avatar_type = '" . $db->sql_escape($new) . "' + WHERE group_avatar_type = '" . $db->sql_escape($old) . "'"; + _sql($sql, $errored, $error_ary); + } + $no_updates = false; break; From b2b812f1714fc924a7c9e595ccb8fbb35f20f203 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sun, 8 Apr 2012 22:13:10 +0200 Subject: [PATCH 0029/2494] [feature/avatars] Do not assign in an if statement PHPBB3-10018 --- phpBB/includes/acp/acp_users.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/phpBB/includes/acp/acp_users.php b/phpBB/includes/acp/acp_users.php index cd50b02ca1..33a173b74d 100644 --- a/phpBB/includes/acp/acp_users.php +++ b/phpBB/includes/acp/acp_users.php @@ -468,7 +468,8 @@ class acp_users $db->sql_query($sql); // Delete old avatar if present - if ($driver = $phpbb_avatar_manager->get_driver($user_row['user_avatar_type'])) + $driver = $phpbb_avatar_manager->get_driver($user_row['user_avatar_type']); + if ($driver) { $driver->delete($user_row); } From f273ab16ae68d15832832e2b2c98a3b99c966c97 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sun, 8 Apr 2012 22:28:40 +0200 Subject: [PATCH 0030/2494] [feature/avatars] Fix clean_row regex, thanks to chris PHPBB3-10018 --- phpBB/includes/avatar/manager.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/avatar/manager.php b/phpBB/includes/avatar/manager.php index 054bb0cee9..f4e5a6d7f8 100644 --- a/phpBB/includes/avatar/manager.php +++ b/phpBB/includes/avatar/manager.php @@ -137,7 +137,7 @@ class phpbb_avatar_manager $keys = array_map( function ($key) { - return preg_replace('(user_|group_)', '', $key); + return preg_replace('#^(?:user_|group_)#', '', $key); }, $row ); From 421fc8d94db1b6a89518cbcc3f3141625eefff25 Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Tue, 10 Apr 2012 11:25:06 +0100 Subject: [PATCH 0031/2494] [ticket/10776] Fixed errors in docs/README.html. PHPBB3-10776 --- phpBB/docs/README.html | 77 +++++++++++++++++++++--------------------- 1 file changed, 38 insertions(+), 39 deletions(-) diff --git a/phpBB/docs/README.html b/phpBB/docs/README.html index aa60d7dd25..d54b9d920f 100644 --- a/phpBB/docs/README.html +++ b/phpBB/docs/README.html @@ -41,7 +41,7 @@ -

Thank you for downloading phpBB3. This README will guide through the basics of installation and operation of phpBB3. Please ensure you read this and the accompanying documentation fully before proceeding with the installation.

+

Thank you for downloading phpBB3. This README will guide you through the basics of installation and operation of phpBB3. Please ensure you read this and the accompanying documentation fully before proceeding with the installation.

Readme

@@ -62,12 +62,12 @@
  • Getting help with phpBB3
    1. Documentation
    2. -
    3. Community Forums
    4. +
    5. Community forums
    6. Internet Relay Chat
  • Status of this version
  • -
  • Reporting Bugs +
  • Reporting bugs
    1. Security related bugs
    @@ -91,11 +91,11 @@
    -

    Installation, update and conversion instructions can be found in the INSTALL document contained in this distribution. If you are intending to convert from a previous phpBB 2.0.x installation we highly recommend you backup any existing data before proceeding!

    +

    Installation, update and conversion instructions can be found in the INSTALL document in this directory. If you are intending on converting from a phpBB 2.0.x installation we highly recommend that you backup any existing data before proceeding!

    Users of phpBB3 Beta versions cannot directly update.

    -

    Please note that we won't support the following installation types:

    +

    Please note that we don't support the following installation types:

    • Updates from phpBB3 Beta versions to phpBB3 RC1 and higher
    • Conversions from phpBB 2.0.x to phpBB3 Beta versions
    • @@ -107,7 +107,7 @@
      • Updates from phpBB3 RC1 to the latest version
      • Conversions from phpBB 2.0.x to the latest version
      • -
      • New installations of phpBB3 - always only the latest released version
      • +
      • New installations of phpBB3 - only the latest released version
    @@ -134,33 +134,33 @@

    http://www.phpbb.com/downloads/

    -

    This is the official location for all supported language sets. If you download a package from a 3rd party site you do so with the understanding that we cannot offer support. So please, do not ask for help in these cases!

    +

    This is the official location for all supported language sets. If you download a package from a 3rd party site you do so with the understanding that we cannot offer support. Please do not ask for support if you download a language pack from a 3rd party site.

    -

    Installation of these packages is straightforward, simply download the required language pack and unarchive it into the languages/ folder. Please ensure you retain the directory structure when doing this! Once uploaded go to the Admin->System->Language Packs and install the now appeared new language pack. To install the style imageset you should download the imageset for your language and unarchive the file/s into the relevant imageset directory (styles/prosilver/imageset or styles/subsilver2/imageset), again you must retain the directory structure. Once installed the imageset will become immediately available.

    +

    Installation of these packages is straightforward; simply download the required language pack and unarchive it into the languages/ folder. Please ensure you retain the directory structure when doing this! Once uploaded go to the Admin->System->Language Packs and install the new language pack, which will have been automatically detected. To install the style imageset you should download the imageset for your language and unarchive the file/s into the relevant imageset directory (styles/prosilver/imageset or styles/subsilver2/imageset). Again, you must retain the directory structure. Once installed the imageset will immediately become available.

    If your language is not available please visit our forums where you will find a topic listing translations currently available or in preparation. This topic also gives you information should you wish to volunteer to translate a language not currently listed.

    2.ii. Styles

    -

    Although phpBB Group are rather proud of the included styles we realise that it may not be to everyones tastes. Therefore phpBB3 allows styles to be switched with relative ease. Firstly you need to locate and download a style you like. We maintain such a site at

    +

    Although phpBB Group are rather proud of the included styles we realise that it may not be to everyones tastes. Therefore phpBB3 allows other styles to be used with relative ease. First, you need to locate and download a style you like. We maintain such a site at

    http://www.phpbb.com/styles/

    -

    Please note that 3rd party styles downloaded for versions of phpBB2 will not work in phpBB3.

    +

    Please note that styles for phpBB2 will not work with phpBB3.

    -

    Once you have downloaded a style the usual next step is to unarchive (or upload the unarchived contents of) the package into your styles/ directory. You then need to visit Administration -> Styles, you should see the new style available, click install and it will become available for all your users.

    +

    Once you have downloaded a style, the next step is to unarchive (or upload the unarchived contents of) the package into your styles/ directory. You then need to visit Administration -> Styles. You should see the new style, click install and it will become available for all your users.

    -

    Please note that if you create your own style or modify existing ones, please remember to enable the "Recompile stale style components" setting within the Admin->General->Load Settings screen. This setting allows the cache to detect changes made to the style and automatically refresh it. If this setting is disabled, you will not see your changes taking effect.

    +

    Please note that if you create your own style or modify existing ones, you should enable the "Recompile stale style components" setting within the Admin->General->Load Settings screen. This setting allows the cache to detect changes made to the style and automatically refresh it. If this setting is disabled, you will not see your changes taking effect without manually refreshing the style components.

    2.iii. Modifications

    -

    Although not officially supported by phpBB Group, phpBB has a thriving modification scene. These third party modifications to the standard phpBB extend its capabilities still further and can be found at:

    +

    Although the modifications themselves are not officially supported by phpBB Group, phpBB has a thriving modification scene. These add features to phpBB, and can be found at:

    http://www.phpbb.com/mods/

    -

    Please remember that any bugs or other issues that occur after you have added any modification should NOT be reported to the bug tracker (see below). First remove the modification and see if the problem is resolved.

    +

    Please remember that any bugs or other issues that may occur as a result of installing a modification should NOT be reported to the bug tracker (see below). First remove the modification, and then see if that has fixed the problem.

    -

    Also remember that any modifications which modify the database in any way may render upgrading your forum to future versions more difficult unless we state otherwise. With all this said many users have and continue to utilise many of the mods already available with great success.

    +

    Also remember that any modifications which modify the database in any way may make upgrading your forum to future versions more difficult. However, many users have and continue to utilise many of the mods already available with great success.

    @@ -178,27 +178,27 @@
    -

    phpBB3 can seem a little daunting to new users in places, particularly with regard the permission system. The first thing you should do is check the FAQ which covers a few basic getting started questions. If you need additional help there are several places you should look.

    +

    phpBB3 can sometimes seem a little daunting to new users, particularly with regards to the permission system. The first thing you should do is check the FAQ, which covers a few basic getting started questions. If you need additional help there are several places you can find it.

    3.i. phpBB3 Documentation

    -

    A comprehensive documentation is now available online and can be accessed from the following location:

    +

    Comprehensive documentation is now available on the phpBB website:

    http://www.phpbb.com/support/documentation/3.0/

    -

    This covers everything from installation through setting permissions and managing users.

    +

    This covers everything from installation to setting permissions and managing users.

    3.ii. Community Forums

    -

    phpBB Group maintains a thriving community where a number of people have generously decided to donate their time to help support users. This site can be found at:

    +

    phpBB Group maintains a thriving community where a number of people generously donate their time to help support users. This site can be found at:

    -

    http://www.phpbb.com/

    +

    http://www.phpbb.com/community/

    -

    If you do seek help via our forums please be sure to do a Search before posting. This may well save both you and us time and allow the developer, moderator and support groups to spend more time responding to people with unknown issues and problems. Please also remember that phpBB is an entirely volunteer effort, no one receives any compensation for the time they give, this includes moderators as well as developers. So please be respectful and mindful when awaiting responses.

    +

    If you do seek help via our forums please be sure to do a search before posting to make sure; if someone has experienced the issue before, then you may find that your question has already been answered. Please remember that phpBB is entirely staffed by volunteers, no one receives any compensation for the time they give, including moderators as well as developers; please be respectful and mindful when awaiting responses and receiving support.

    3.iii Internet Relay Chat

    -

    Another place you may find help is our IRC channel. This operates on the Freenode IRC network, irc.freenode.net and the channel is #phpbb and can be accessed by any good IRC client such as mIRC, XChat, etc. Again, please do not abuse this service and be respectful of other users.

    +

    Another place you can find help is our IRC channel, which you can find on the Freenode IRC network, irc.freenode.net in #phpbb. It can be accessed by any IRC client such as mIRC, XChat, etc. Again, please do not abuse this service and be respectful of other users.

    @@ -216,13 +216,13 @@
    -

    This is the third stable release of phpBB. The 3.0.x line is essentially feature frozen, with only point releases seeing fixes for bugs and security issues, though feature alterations and minor feature additions may be done if deemed absolutely required. Our next major release will be phpBB 3.2 and the planning phase has begun (the unstable development version is 3.1). Please do not post questions asking when 3.2 will be available, no release date has been set.

    +

    This is the third stable release of phpBB. The 3.0.x line is essentially feature frozen, with releases only containing fixes for bugs and security issues, though feature alterations and minor feature additions may be done if deemed absolutely required. Our next major release will be phpBB 3.1, which is currently under development. Please do not post questions asking when any future releases will be released; they will be released when they are finished.

    -

    For those interested in the development of phpBB should keep an eye on the community forums to see how things are progressing:

    +

    Those interested in the development of phpBB should keep an eye on the forums on the development site, Area51, to see how things are progressing and to help out if you wish:

    http://area51.phpbb.com/phpBB/

    -

    Please note that this forum should NOT be used to obtain support for or ask questions about phpBB 2.0.x or phpBB 3.0.x, the main community forums are the place for this. Any such posts will be locked and go unanswered.

    +

    Please note that these forums should NOT be used to obtain support, as the main community forums are the place for this. Any such posts will be locked and go unanswered.

    @@ -240,20 +240,19 @@
    -

    The phpBB Group uses a bug tracking system to store, list and manage all reported bugs, it can be found at the location listed below. Please DO NOT post bug reports to our forums, they will be locked. In addition please DO NOT use the bug tracker for support requests. Posting such a request will only see you directed to the support forums (while taking time away from working on real bugs).

    +

    The phpBB Group uses a bug tracking system to manage all reported bugs, which can be found at the location listed below. Please DO NOT post bug reports to our forums, they will be locked. In addition please DO NOT use the bug tracker for support requests. Posting such a request will only see you directed to the support forums (while taking time away from working on real bugs).

    http://tracker.phpbb.com/

    While we very much appreciate receiving bug reports (the more reports the more stable phpBB will be) we ask you carry out a few steps before adding new entries:

      -
    • Firstly determine if your bug is reproduceable, how to determine this depends on the bug in question. Only if the bug is reproduceable it is likely to be a problem with phpBB3 (or in some way connected). If something cannot be reproduced it may turn out to have been your hosting provider working on something, a user doing something silly, etc. Bug reports for non-reproduceable events can slow down our attempts to fix real, reproduceable issues

    • -
    • Next please read or search through the existing bug reports to see if your bug (or one very similar to it) is already listed. If it is please add to that existing bug rather than creating a new duplicate entry (all this does is slow us down).

    • -
    • Check the forums (use search!) to see if people have discussed anything that sounds similar to what you are seeing. However, as noted above please DO NOT post your particular bug to the forum unless it's non-reproduceable or you are sure it's related to something you have done rather phpBB3

    • -
    • If no existing bug exists then please feel free to add it
    • +
    • First determine if your bug is reproducible. How to determine this depends on the bug in question. If the bug is reproduceable it is likely to be a problem with phpBB3 (or in some way connected). If it cannot, then it is most likely not a bug in phpBB.

    • +
    • Next please read or search through the existing bug reports to see whether we already know about the bug you found. If there is already a ticket, then please add to that existing bug rather than creating a new duplicate entry (all this does is slow us down).

    • +
    • If no existing bug exists then please add it
    -

    If you do post a new bug (i.e. one that isn't already listed in the bug tracker) firstly make sure you have logged in (your username and password are the same as for the community forums) then please include the following details:

    +

    If you do post a new bug, make sure you are logged in (your username and password are the same as for the community forums) then please include the following details in your bug report:

    • Your server type/version, e.g. Apache 1.3.28, IIS 4, Sambar, etc.
    • @@ -263,9 +262,9 @@

      The relevant database type/version is listed within the administration control panel

      -

      Please also be as detailed as you can in your report, if possible list the steps required to duplicate the problem. If you have a patch that fixes the issue, please attach it to the ticket or submit a pull request on GitHub.

      +

      Please be as detailed as you can in your report, and if possible, list the steps required to duplicate the problem. If you have a patch that fixes the issue, please attach it to the ticket or submit a pull request to our repository on GitHub.

      -

      Once a bug has been submitted you will be emailed any follow up comments added to it. Please if you are requested to supply additional information, do so! It is frustrating for us to receive bug reports, ask for additional information but get nothing. In these cases we have a policy of closing the bug, which may leave a very real problem in place. Obviously we would rather not have this situation arise.

      +

      Once a bug has been submitted you will be emailed any follow up comments added to it. If you are requested to supply additional information, please do so! It is frustrating for us to receive bug reports, ask for additional information but get nothing. If we cannot replicate the bug we may close the ticket, which could leave the bug in phpBB. Obviously we would rather not have this situation arise.

      5.i. Security related bugs

      @@ -289,11 +288,11 @@
      -

      This list is not complete but does represent those bugs which may effect users on a wider scale. Other bugs listed in the tracker have typically been shown to be limited to certain setups or methods of installation, updating and/or conversions.

      +

      This list is by no means complete but does represent those bugs which may effect users on a wider scale. Other bugs listed in the tracker have typically been shown to be limited to certain setups or methods of installation, updating and/or conversions.

        -
      • Conversions may fail to complete on large boards under some hosts
      • -
      • Updates may fail to complete on large update sets under some hosts
      • +
      • Conversions may fail to complete on large boards under some hosts.
      • +
      • Updates may fail to complete on large update sets under some hosts.
      • Smilies placed directly after bbcode tags will not get parsed. Smilies always need to be separated by spaces.
      @@ -313,9 +312,9 @@
      -

      phpBB is no longer supported on PHP3 due to several compatibility issues and we recommend that you upgrade to the latest stable release of PHP5 to run phpBB. The minimum version required is PHP 4.3.3.

      +

      phpBB is no longer supported on PHP3 due to several compatibility issues and we recommend that you upgrade to the latest stable release of PHP5 to run phpBB. The minimum version required is PHP 4.3.3. The minimum version that will be required for phpBB 3.1 is PHP 5.3.2.

      -

      Please remember that running any application on a developmental version of PHP can lead to strange/unexpected results which may appear to be bugs in the application (which may not be true). Therefore we recommend you upgrade to the newest stable version of PHP before running phpBB3. If you are running a developmental version of PHP please check any bugs you find on a system running a stable release before submitting.

      +

      Please remember that running any application on a development (unstable, e.g. a beta release) version of PHP can lead to strange/unexpected results which may appear to be bugs in the application. Therefore, we recommend you upgrade to the newest stable version of PHP before running phpBB3. If you are running a development version of PHP please check any bugs you find on a system running a stable release before submitting.

      This board has been developed and tested under Linux and Windows (amongst others) running Apache using MySQL 3.23, 4.x, 5.x, MSSQL Server 2000, PostgreSQL 7.x, Oracle 8, SQLite and Firebird. Versions of PHP used range from 4.3.3 to 6.0.0-dev without problem.

      @@ -339,7 +338,7 @@
      -

      This application is opensource software released under the GNU General Public License v2. Please see source code and the docs directory for more details. This package and its contents are Copyright (c) phpBB Group, All Rights Reserved.

      +

      This application is open source software released under the GNU General Public License v2. Please see source code and the docs directory for more details. This package and its contents are Copyright © phpBB Group, All Rights Reserved.

      From 8a2063090c382445835e64fb95ad3aebd777e146 Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Thu, 12 Apr 2012 20:53:27 +0100 Subject: [PATCH 0032/2494] [ticket/10776] Fixed a couple language changes in docs/README.html. PHPBB3-10776 --- phpBB/docs/README.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/phpBB/docs/README.html b/phpBB/docs/README.html index d54b9d920f..0b5709a7c7 100644 --- a/phpBB/docs/README.html +++ b/phpBB/docs/README.html @@ -136,7 +136,7 @@

      This is the official location for all supported language sets. If you download a package from a 3rd party site you do so with the understanding that we cannot offer support. Please do not ask for support if you download a language pack from a 3rd party site.

      -

      Installation of these packages is straightforward; simply download the required language pack and unarchive it into the languages/ folder. Please ensure you retain the directory structure when doing this! Once uploaded go to the Admin->System->Language Packs and install the new language pack, which will have been automatically detected. To install the style imageset you should download the imageset for your language and unarchive the file/s into the relevant imageset directory (styles/prosilver/imageset or styles/subsilver2/imageset). Again, you must retain the directory structure. Once installed the imageset will immediately become available.

      +

      Installation of these packages is straightforward; simply download the required language pack and extract it into the languages/ folder. Please ensure you retain the directory structure when doing this! Once uploaded go to the Admin->System->Language Packs and install the new language pack, which will have been automatically detected. To install the style imageset you should download the imageset for your language and extract the file/s into the relevant imageset directory (styles/prosilver/imageset or styles/subsilver2/imageset). Again, you must retain the directory structure. Once installed the imageset will immediately become available.

      If your language is not available please visit our forums where you will find a topic listing translations currently available or in preparation. This topic also gives you information should you wish to volunteer to translate a language not currently listed.

      @@ -148,7 +148,7 @@

      Please note that styles for phpBB2 will not work with phpBB3.

      -

      Once you have downloaded a style, the next step is to unarchive (or upload the unarchived contents of) the package into your styles/ directory. You then need to visit Administration -> Styles. You should see the new style, click install and it will become available for all your users.

      +

      Once you have downloaded a style, the next step is to extract (or upload the extracted contents of) the package into your styles/ directory. You then need to visit Administration -> Styles. You should see the new style, click install and it will become available for all your users.

      Please note that if you create your own style or modify existing ones, you should enable the "Recompile stale style components" setting within the Admin->General->Load Settings screen. This setting allows the cache to detect changes made to the style and automatically refresh it. If this setting is disabled, you will not see your changes taking effect without manually refreshing the style components.

      @@ -194,7 +194,7 @@

      http://www.phpbb.com/community/

      -

      If you do seek help via our forums please be sure to do a search before posting to make sure; if someone has experienced the issue before, then you may find that your question has already been answered. Please remember that phpBB is entirely staffed by volunteers, no one receives any compensation for the time they give, including moderators as well as developers; please be respectful and mindful when awaiting responses and receiving support.

      +

      If you do seek help via our forums please be sure to do a search before posting; if someone has experienced the issue before, then you may find that your question has already been answered. Please remember that phpBB is entirely staffed by volunteers, no one receives any compensation for the time they give, including moderators as well as developers; please be respectful and mindful when awaiting responses and receiving support.

      3.iii Internet Relay Chat

      From a9cf558af7fc08539e15ceca1e889e087c815c8d Mon Sep 17 00:00:00 2001 From: Sajaki Date: Sat, 28 Apr 2012 10:43:43 +0200 Subject: [PATCH 0033/2494] [ticket/10854] sql server drop default constraint when dropping column drops default columns with T-SQL before attempting drop column to avoids sql exception. This is a huge annoyance in UMIL scripts running under sql server. --- phpBB/includes/db/db_tools.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/phpBB/includes/db/db_tools.php b/phpBB/includes/db/db_tools.php index c6dd23e6bd..f63ff18cbe 100644 --- a/phpBB/includes/db/db_tools.php +++ b/phpBB/includes/db/db_tools.php @@ -1819,6 +1819,22 @@ class phpbb_db_tools case 'mssql': case 'mssqlnative': + // remove default cosntraints first + // http://msdn.microsoft.com/en-us/library/aa175912%28v=sql.80%29.aspx + $statements[] = "DECLARE @drop_default_name VARCHAR(100), @cmd VARCHAR(1000) + SET @drop_default_name = + (SELECT so.name FROM sysobjects so + JOIN sysconstraints sc ON so.id = sc.constid + WHERE object_name(so.parent_obj) = '{$table_name}' + AND so.xtype = 'D' + AND sc.colid = (SELECT colid FROM syscolumns + WHERE id = object_id('{$table_name}') + AND name = '{$column_name}')) + IF @drop_default_name <> '' + BEGIN + SET @cmd = 'ALTER TABLE [{$table_name}] DROP CONSTRAINT [' + @drop_default_name + ']' + EXEC(@cmd) + END"; $statements[] = 'ALTER TABLE [' . $table_name . '] DROP COLUMN [' . $column_name . ']'; break; From d5a788ae5b615c1b6b642c631884a4d936be2a4c Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Thu, 21 Jun 2012 19:16:05 +0100 Subject: [PATCH 0034/2494] [ticket/10949] Converted AJAX coding standards to new guidelines. Basically, moved parentheses to same line and changed variable names to camel case. PHPBB3-10949 --- phpBB/assets/javascript/core.js | 195 ++++++++++-------------- phpBB/styles/prosilver/template/ajax.js | 22 +-- 2 files changed, 86 insertions(+), 131 deletions(-) diff --git a/phpBB/assets/javascript/core.js b/phpBB/assets/javascript/core.js index 958b6c9ff6..53b85e677a 100644 --- a/phpBB/assets/javascript/core.js +++ b/phpBB/assets/javascript/core.js @@ -1,5 +1,5 @@ var phpbb = {}; -phpbb.alert_time = 100; +phpbb.alertTime = 100; (function($) { // Avoid conflicts with other libraries @@ -12,35 +12,31 @@ var keymap = { }; var dark = $('#darkenwrapper'); -var loading_alert = $('#loadingalert'); +var loadingAlert = $('#loadingalert'); /** - * Display a loading screen. + * Display a loading screen * - * @returns object Returns loading_alert. + * @returns object Returns loadingAlert. */ -phpbb.loading_alert = function() { - if (dark.is(':visible')) - { - loading_alert.fadeIn(phpbb.alert_time); - } - else - { - loading_alert.show(); - dark.fadeIn(phpbb.alert_time, function() { +phpbb.loadingAlert = function() { + if (dark.is(':visible')) { + loadingAlert.fadeIn(phpbb.alertTime); + } else { + loadingAlert.show(); + dark.fadeIn(phpbb.alertTime, function() { // Wait five seconds and display an error if nothing has been returned by then. setTimeout(function() { - if (loading_alert.is(':visible')) - { + if (loadingAlert.is(':visible')) { phpbb.alert($('#phpbb_alert').attr('data-l-err'), $('#phpbb_alert').attr('data-l-timeout-processing-req')); } }, 5000); }); } - return loading_alert; -} + return loadingAlert; +}; /** * Display a simple alert similar to JSs native alert(). @@ -67,7 +63,7 @@ phpbb.alert = function(title, msg, fadedark) { div.find('.alert_close').unbind('click'); fade = (typeof fadedark !== 'undefined' && !fadedark) ? div : dark; - fade.fadeOut(phpbb.alert_time, function() { + fade.fadeOut(phpbb.alertTime, function() { div.hide(); }); @@ -90,27 +86,22 @@ phpbb.alert = function(title, msg, fadedark) { e.preventDefault(); }); - if (loading_alert.is(':visible')) - { - loading_alert.fadeOut(phpbb.alert_time, function() { + if (loadingAlert.is(':visible')) { + loadingAlert.fadeOut(phpbb.alertTime, function() { dark.append(div); - div.fadeIn(phpbb.alert_time); + div.fadeIn(phpbb.alertTime); }); - } - else if (dark.is(':visible')) - { + } else if (dark.is(':visible')) { dark.append(div); - div.fadeIn(phpbb.alert_time); - } - else - { + div.fadeIn(phpbb.alertTime); + } else { dark.append(div); div.show(); - dark.fadeIn(phpbb.alert_time); + dark.fadeIn(phpbb.alertTime); } return div; -} +}; /** * Display a simple yes / no box to the user. @@ -136,7 +127,7 @@ phpbb.confirm = function(msg, callback, fadedark) { var click_handler = function(e) { var res = this.className === 'button1'; var fade = (typeof fadedark !== 'undefined' && !fadedark && res) ? div : dark; - fade.fadeOut(phpbb.alert_time, function() { + fade.fadeOut(phpbb.alertTime, function() { div.hide(); }); div.find('input[type="button"]').unbind('click', click_handler); @@ -151,7 +142,7 @@ phpbb.confirm = function(msg, callback, fadedark) { dark.one('click', function(e) { div.find('.alert_close').unbind('click'); - dark.fadeOut(phpbb.alert_time, function() { + dark.fadeOut(phpbb.alertTime, function() { div.hide(); }); callback(false); @@ -174,7 +165,7 @@ phpbb.confirm = function(msg, callback, fadedark) { div.find('.alert_close').one('click', function(e) { var fade = (typeof fadedark !== 'undefined' && fadedark) ? div : dark; - fade.fadeOut(phpbb.alert_time, function() { + fade.fadeOut(phpbb.alertTime, function() { div.hide(); }); callback(false); @@ -182,27 +173,22 @@ phpbb.confirm = function(msg, callback, fadedark) { e.preventDefault(); }); - if (loading_alert.is(':visible')) - { - loading_alert.fadeOut(phpbb.alert_time, function() { + if (loadingAlert.is(':visible')) { + loadingAlert.fadeOut(phpbb.alertTime, function() { dark.append(div); - div.fadeIn(phpbb.alert_time); + div.fadeIn(phpbb.alertTime); }); - } - else if (dark.is(':visible')) - { + } else if (dark.is(':visible')) { dark.append(div); - div.fadeIn(phpbb.alert_time); - } - else - { + div.fadeIn(phpbb.alertTime); + } else { dark.append(div); div.show(); - dark.fadeIn(phpbb.alert_time); + dark.fadeIn(phpbb.alertTime); } return div; -} +}; /** * Turn a querystring into an array. @@ -214,13 +200,12 @@ phpbb.parse_querystring = function(string) { var params = {}, i, split; string = string.split('&'); - for (i = 0; i < string.length; i++) - { + for (i = 0; i < string.length; i++) { split = string[i].split('='); params[split[0]] = decodeURIComponent(split[1]); } return params; -} +}; /** @@ -246,14 +231,13 @@ phpbb.ajaxify = function(options) { refresh = options.refresh, callback = options.callback, overlay = (typeof options.overlay !== 'undefined') ? options.overlay : true, - is_form = elements.is('form'), - event_name = is_form ? 'submit' : 'click'; + isForm = elements.is('form'), + eventName = isForm ? 'submit' : 'click'; - elements.bind(event_name, function(event) { + elements.bind(eventName, function(event) { var action, method, data, submit, that = this, $this = $(this); - if ($this.find('input[type="submit"][data-clicked]').attr('data-ajax') === 'false') - { + if ($this.find('input[type="submit"][data-clicked]').attr('data-ajax') === 'false') { return; } @@ -267,84 +251,69 @@ phpbb.ajaxify = function(options) { * * @param object res The object sent back by the server. */ - function return_handler(res) - { + function returnHandler(res) { var alert; // Is a confirmation required? - if (typeof res.S_CONFIRM_ACTION === 'undefined') - { + if (typeof res.S_CONFIRM_ACTION === 'undefined') { // If a confirmation is not required, display an alert and call the // callbacks. - if (typeof res.MESSAGE_TITLE !== 'undefined') - { + if (typeof res.MESSAGE_TITLE !== 'undefined') { alert = phpbb.alert(res.MESSAGE_TITLE, res.MESSAGE_TEXT); - } - else - { - dark.fadeOut(phpbb.alert_time); + } else { + dark.fadeOut(phpbb.alertTime); } - if (typeof phpbb.ajax_callbacks[callback] === 'function') - { - phpbb.ajax_callbacks[callback].call(that, res); + if (typeof phpbb.ajaxCallbacks[callback] === 'function') { + phpbb.ajaxCallbacks[callback].call(that, res); } // If the server says to refresh the page, check whether the page should // be refreshed and refresh page after specified time if required. - if (res.REFRESH_DATA) - { - if (typeof refresh === 'function') - { + if (res.REFRESH_DATA) { + if (typeof refresh === 'function') { refresh = refresh(res.REFRESH_DATA.url); - } - else if (typeof refresh !== 'boolean') - { + } else if (typeof refresh !== 'boolean') { refresh = false; } setTimeout(function() { - if (refresh) - { + if (refresh) { window.location = res.REFRESH_DATA.url; } // Hide the alert even if we refresh the page, in case the user // presses the back button. - dark.fadeOut(phpbb.alert_time, function() { + dark.fadeOut(phpbb.alertTime, function() { alert.hide(); }); }, res.REFRESH_DATA.time * 1000); // Server specifies time in seconds } - } - else - { + } else { // If confirmation is required, display a diologue to the user. phpbb.confirm(res.MESSAGE_TEXT, function(del) { - if (del) - { - phpbb.loading_alert(); + if (del) { + phpbb.loadingAlert(); data = $('
      ' + res.S_HIDDEN_FIELDS + '
      ').serialize(); $.ajax({ url: res.S_CONFIRM_ACTION, type: 'POST', data: data + '&confirm=' + res.YES_VALUE, - success: return_handler, - error: error_handler + success: returnHandler, + error: errorHandler }); } }, false); } } - function error_handler() - { + function errorHandler() { var alert; alert = phpbb.alert(dark.attr('data-ajax-error-title'), dark.attr('data-ajax-error-text')); setTimeout(function () { - dark.fadeOut(phpbb.alert_time, function() { + dark.fadeOut(phpbb.alertTime, function() { alert.hide(); }); }, 5000); @@ -352,25 +321,21 @@ phpbb.ajaxify = function(options) { // If the element is a form, POST must be used and some extra data must // be taken from the form. - var run_filter = (typeof options.filter === 'function'); + var runFilter = (typeof options.filter === 'function'); - if (is_form) - { + if (isForm) { action = $this.attr('action').replace('&', '&'); data = $this.serializeArray(); method = $this.attr('method') || 'GET'; - if ($this.find('input[type="submit"][data-clicked]')) - { + if ($this.find('input[type="submit"][data-clicked]')) { submit = $this.find('input[type="submit"][data-clicked]'); data.push({ name: submit.attr('name'), value: submit.val() }); } - } - else - { + } else { action = this.href; data = null; method = 'GET'; @@ -378,28 +343,26 @@ phpbb.ajaxify = function(options) { // If filter function returns false, cancel the AJAX functionality, // and return true (meaning that the HTTP request will be sent normally). - if (run_filter && !options.filter.call(this, data)) - { + if (runFilter && !options.filter.call(this, data)) { return; } - if (overlay) - { - phpbb.loading_alert(); + if (overlay) { + phpbb.loadingAlert(); } $.ajax({ url: action, type: method, data: data, - success: return_handler, - error: error_handler + success: returnHandler, + error: errorHandler }); event.preventDefault(); }); - if (is_form) { + if (isForm) { elements.find('input:submit').click(function () { var $this = $(this); @@ -409,9 +372,9 @@ phpbb.ajaxify = function(options) { } return this; -} +}; -phpbb.ajax_callbacks = {}; +phpbb.ajaxCallbacks = {}; /** * Adds an AJAX callback to be used by phpbb.ajaxify. @@ -421,14 +384,12 @@ phpbb.ajax_callbacks = {}; * @param string id The name of the callback. * @param function callback The callback to be called. */ -phpbb.add_ajax_callback = function(id, callback) -{ - if (typeof callback === 'function') - { - phpbb.ajax_callbacks[id] = callback; +phpbb.add_ajax_callback = function(id, callback) { + if (typeof callback === 'function') { + phpbb.ajaxCallbacks[id] = callback; } return this; -} +}; /** @@ -438,11 +399,11 @@ phpbb.add_ajax_callback = function(id, callback) */ phpbb.add_ajax_callback('alt_text', function(data) { var el = $(this), - alt_text; + altText; - alt_text = el.attr('data-alt-text'); - el.attr('title', alt_text); - el.text(alt_text); + altText = el.attr('data-alt-text'); + el.attr('title', altText); + el.text(altText); }); diff --git a/phpBB/styles/prosilver/template/ajax.js b/phpBB/styles/prosilver/template/ajax.js index 54f34e4204..83335b23af 100644 --- a/phpBB/styles/prosilver/template/ajax.js +++ b/phpBB/styles/prosilver/template/ajax.js @@ -5,14 +5,12 @@ // This callback finds the post from the delete link, and removes it. phpbb.add_ajax_callback('post_delete', function() { var el = $(this), - post_id; + postId; - if (el.attr('data-refresh') === undefined) - { - post_id = el[0].href.split('&p=')[1]; - var post = el.parents('#p' + post_id).css('pointer-events', 'none'); - if (post.hasClass('bg1') || post.hasClass('bg2')) - { + if (el.attr('data-refresh') === undefined) { + postId = el[0].href.split('&p=')[1]; + var post = el.parents('#p' + postId).css('pointer-events', 'none'); + if (post.hasClass('bg1') || post.hasClass('bg2')) { var posts1 = post.nextAll('.bg1'); post.nextAll('.bg2').removeClass('bg2').addClass('bg1'); posts1.removeClass('bg1').addClass('bg2'); @@ -54,8 +52,7 @@ $('[data-ajax]').each(function() { ajax = $this.attr('data-ajax'), fn; - if (ajax !== 'false') - { + if (ajax !== 'false') { fn = (ajax !== 'true') ? ajax : null; phpbb.ajaxify({ selector: this, @@ -89,12 +86,9 @@ phpbb.ajaxify({ filter: function (data) { var action = $('#quick-mod-select').val(); - if (action === 'make_normal') - { + if (action === 'make_normal') { return $(this).find('select option[value="make_global"]').length > 0; - } - else if (action === 'lock' || action === 'unlock') - { + } else if (action === 'lock' || action === 'unlock') { return true; } From 6d994380d76accba5485b0a04d3028f1c153ebd8 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Wed, 27 Jun 2012 14:48:51 +0200 Subject: [PATCH 0035/2494] [feature/avatars] Fix error in avatar_manager::clean_row PHPBB3-10018 --- phpBB/includes/avatar/manager.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/avatar/manager.php b/phpBB/includes/avatar/manager.php index f4e5a6d7f8..839216b61e 100644 --- a/phpBB/includes/avatar/manager.php +++ b/phpBB/includes/avatar/manager.php @@ -139,7 +139,7 @@ class phpbb_avatar_manager { return preg_replace('#^(?:user_|group_)#', '', $key); }, - $row + $keys ); return array_combine($keys, $values); From d10486699273b896fffe86f05f66a6d542843f5b Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Wed, 27 Jun 2012 16:59:06 +0200 Subject: [PATCH 0036/2494] [feature/avatars] Remove unneeded argument for driver prepare_form() PHPBB3-10018 --- phpBB/includes/avatar/driver/driver.php | 6 +++--- phpBB/includes/avatar/driver/interface.php | 2 +- phpBB/includes/avatar/driver/local.php | 4 ++-- phpBB/includes/avatar/driver/upload.php | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/phpBB/includes/avatar/driver/driver.php b/phpBB/includes/avatar/driver/driver.php index 7028df4b64..4ac6762140 100644 --- a/phpBB/includes/avatar/driver/driver.php +++ b/phpBB/includes/avatar/driver/driver.php @@ -38,13 +38,13 @@ abstract class phpbb_avatar_driver implements phpbb_avatar_driver_interface * @type string */ protected $phpbb_root_path; - + /** * Current $phpEx * @type string */ protected $phpEx; - + /** * A cache driver * @type phpbb_cache_driver_interface @@ -99,7 +99,7 @@ abstract class phpbb_avatar_driver implements phpbb_avatar_driver_interface /** * @inheritdoc **/ - public function prepare_form($template, $row, &$error, &$override_focus) + public function prepare_form($template, $row, &$error) { return false; } diff --git a/phpBB/includes/avatar/driver/interface.php b/phpBB/includes/avatar/driver/interface.php index 8c8a067d13..d3b764e275 100644 --- a/phpBB/includes/avatar/driver/interface.php +++ b/phpBB/includes/avatar/driver/interface.php @@ -46,7 +46,7 @@ interface phpbb_avatar_driver_interface /** * @TODO **/ - public function prepare_form($template, $row, &$error, &$override_focus); + public function prepare_form($template, $row, &$error); /** * @TODO diff --git a/phpBB/includes/avatar/driver/local.php b/phpBB/includes/avatar/driver/local.php index 27e451c099..a0ef912eae 100644 --- a/phpBB/includes/avatar/driver/local.php +++ b/phpBB/includes/avatar/driver/local.php @@ -43,7 +43,7 @@ class phpbb_avatar_driver_local extends phpbb_avatar_driver ); } } - + /** * @inheritdoc */ @@ -103,7 +103,7 @@ class phpbb_avatar_driver_local extends phpbb_avatar_driver return true; } - + /** * @inheritdoc */ diff --git a/phpBB/includes/avatar/driver/upload.php b/phpBB/includes/avatar/driver/upload.php index c7d2b870c1..d9504c04a0 100644 --- a/phpBB/includes/avatar/driver/upload.php +++ b/phpBB/includes/avatar/driver/upload.php @@ -58,7 +58,7 @@ class phpbb_avatar_driver_upload extends phpbb_avatar_driver 'S_UPLOAD_AVATAR_URL' => ($this->config['allow_avatar_remote_upload']) ? true : false, 'AV_UPLOAD_SIZE' => $this->config['avatar_filesize'], )); - + return true; } From f40e6963c61548d746c59b78cb60c0f7459c7696 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Wed, 27 Jun 2012 17:11:20 +0200 Subject: [PATCH 0037/2494] [feature/avatars] Remove empty script tag PHPBB3-10018 --- phpBB/styles/prosilver/template/ucp_avatar_options.html | 3 --- 1 file changed, 3 deletions(-) diff --git a/phpBB/styles/prosilver/template/ucp_avatar_options.html b/phpBB/styles/prosilver/template/ucp_avatar_options.html index e8114da3ea..a246b00ddd 100644 --- a/phpBB/styles/prosilver/template/ucp_avatar_options.html +++ b/phpBB/styles/prosilver/template/ucp_avatar_options.html @@ -1,4 +1,3 @@ -
      @@ -66,5 +65,3 @@
      - From 21df013210d1de2cffae568c0620a7ccd6d8f426 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Wed, 27 Jun 2012 18:23:26 +0200 Subject: [PATCH 0038/2494] [feature/avatars] Move avatars JavaScript code to external JS file PHPBB3-10018 --- phpBB/adm/style/acp_groups.html | 23 ++---------------- phpBB/adm/style/acp_users_avatar.html | 23 ++---------------- phpBB/adm/style/avatars.js | 17 +++++++++++++ phpBB/styles/prosilver/template/avatars.js | 17 +++++++++++++ .../template/ucp_avatar_options.html | 24 ++----------------- 5 files changed, 40 insertions(+), 64 deletions(-) create mode 100644 phpBB/adm/style/avatars.js create mode 100644 phpBB/styles/prosilver/template/avatars.js diff --git a/phpBB/adm/style/acp_groups.html b/phpBB/adm/style/acp_groups.html index 42cb434ad3..167642e5cb 100644 --- a/phpBB/adm/style/acp_groups.html +++ b/phpBB/adm/style/acp_groups.html @@ -123,27 +123,6 @@
      -
  • @@ -154,6 +133,8 @@
    + + « {L_BACK} diff --git a/phpBB/adm/style/acp_users_avatar.html b/phpBB/adm/style/acp_users_avatar.html index 6316ff4a22..9649fa923e 100644 --- a/phpBB/adm/style/acp_users_avatar.html +++ b/phpBB/adm/style/acp_users_avatar.html @@ -28,30 +28,11 @@ -
    {S_FORM_TOKEN} + + diff --git a/phpBB/adm/style/avatars.js b/phpBB/adm/style/avatars.js new file mode 100644 index 0000000000..baa2623ac9 --- /dev/null +++ b/phpBB/adm/style/avatars.js @@ -0,0 +1,17 @@ +function avatar_simplify() { + var node = document.getElementById('av_options'); + for (var i = 0; i < node.children.length; i++) { + child = node.children[i]; + child.style.display = 'none'; + } + + var selected = document.getElementById('avatar_driver').value; + var id = 'av_option_' + selected; + node = document.getElementById(id); + if (node != null) { + node.style.display = 'block'; + } +} + +avatar_simplify(); +document.getElementById('avatar_driver').onchange = avatar_simplify; diff --git a/phpBB/styles/prosilver/template/avatars.js b/phpBB/styles/prosilver/template/avatars.js new file mode 100644 index 0000000000..baa2623ac9 --- /dev/null +++ b/phpBB/styles/prosilver/template/avatars.js @@ -0,0 +1,17 @@ +function avatar_simplify() { + var node = document.getElementById('av_options'); + for (var i = 0; i < node.children.length; i++) { + child = node.children[i]; + child.style.display = 'none'; + } + + var selected = document.getElementById('avatar_driver').value; + var id = 'av_option_' + selected; + node = document.getElementById(id); + if (node != null) { + node.style.display = 'block'; + } +} + +avatar_simplify(); +document.getElementById('avatar_driver').onchange = avatar_simplify; diff --git a/phpBB/styles/prosilver/template/ucp_avatar_options.html b/phpBB/styles/prosilver/template/ucp_avatar_options.html index a246b00ddd..2438deefd5 100644 --- a/phpBB/styles/prosilver/template/ucp_avatar_options.html +++ b/phpBB/styles/prosilver/template/ucp_avatar_options.html @@ -41,27 +41,7 @@ - - + + From b060667ac102109c0c8f198925bb81b489a30f34 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Wed, 27 Jun 2012 18:26:44 +0200 Subject: [PATCH 0039/2494] [feature/avatars] Rewrite avatars event handler to use jQuery PHPBB3-10018 --- phpBB/adm/style/avatars.js | 16 ++++------------ phpBB/styles/prosilver/template/avatars.js | 16 ++++------------ 2 files changed, 8 insertions(+), 24 deletions(-) diff --git a/phpBB/adm/style/avatars.js b/phpBB/adm/style/avatars.js index baa2623ac9..252081ee08 100644 --- a/phpBB/adm/style/avatars.js +++ b/phpBB/adm/style/avatars.js @@ -1,17 +1,9 @@ function avatar_simplify() { - var node = document.getElementById('av_options'); - for (var i = 0; i < node.children.length; i++) { - child = node.children[i]; - child.style.display = 'none'; - } + $('#av_options').hide(); - var selected = document.getElementById('avatar_driver').value; - var id = 'av_option_' + selected; - node = document.getElementById(id); - if (node != null) { - node.style.display = 'block'; - } + var selected = $('#avatar_driver').val(); + $('#av_option_' + selected).show(); } avatar_simplify(); -document.getElementById('avatar_driver').onchange = avatar_simplify; +$('#avatar_driver').on('change', avatar_simplify); diff --git a/phpBB/styles/prosilver/template/avatars.js b/phpBB/styles/prosilver/template/avatars.js index baa2623ac9..252081ee08 100644 --- a/phpBB/styles/prosilver/template/avatars.js +++ b/phpBB/styles/prosilver/template/avatars.js @@ -1,17 +1,9 @@ function avatar_simplify() { - var node = document.getElementById('av_options'); - for (var i = 0; i < node.children.length; i++) { - child = node.children[i]; - child.style.display = 'none'; - } + $('#av_options').hide(); - var selected = document.getElementById('avatar_driver').value; - var id = 'av_option_' + selected; - node = document.getElementById(id); - if (node != null) { - node.style.display = 'block'; - } + var selected = $('#avatar_driver').val(); + $('#av_option_' + selected).show(); } avatar_simplify(); -document.getElementById('avatar_driver').onchange = avatar_simplify; +$('#avatar_driver').on('change', avatar_simplify); From 2f3581fe3ef928d91f12c442ab5e4890c6620f58 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Wed, 27 Jun 2012 18:37:23 +0200 Subject: [PATCH 0040/2494] [feature/avatars] Add self-invoking closure around avatars.js PHPBB3-10018 --- phpBB/adm/style/avatars.js | 6 ++++++ phpBB/styles/prosilver/template/avatars.js | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/phpBB/adm/style/avatars.js b/phpBB/adm/style/avatars.js index 252081ee08..cb19aa9b7a 100644 --- a/phpBB/adm/style/avatars.js +++ b/phpBB/adm/style/avatars.js @@ -1,3 +1,7 @@ +(function($) { // Avoid conflicts with other libraries + +"use strict"; + function avatar_simplify() { $('#av_options').hide(); @@ -7,3 +11,5 @@ function avatar_simplify() { avatar_simplify(); $('#avatar_driver').on('change', avatar_simplify); + +})(jQuery); // Avoid conflicts with other libraries diff --git a/phpBB/styles/prosilver/template/avatars.js b/phpBB/styles/prosilver/template/avatars.js index 252081ee08..cb19aa9b7a 100644 --- a/phpBB/styles/prosilver/template/avatars.js +++ b/phpBB/styles/prosilver/template/avatars.js @@ -1,3 +1,7 @@ +(function($) { // Avoid conflicts with other libraries + +"use strict"; + function avatar_simplify() { $('#av_options').hide(); @@ -7,3 +11,5 @@ function avatar_simplify() { avatar_simplify(); $('#avatar_driver').on('change', avatar_simplify); + +})(jQuery); // Avoid conflicts with other libraries From 13f4bfabbeab77698f06c3431931b73ebedc587c Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Wed, 27 Jun 2012 21:00:00 +0200 Subject: [PATCH 0041/2494] [feature/avatars] Fixup avatars.js rewrite PHPBB3-10018 --- phpBB/adm/style/avatars.js | 4 ++-- phpBB/styles/prosilver/template/avatars.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/phpBB/adm/style/avatars.js b/phpBB/adm/style/avatars.js index cb19aa9b7a..2068bdbbc4 100644 --- a/phpBB/adm/style/avatars.js +++ b/phpBB/adm/style/avatars.js @@ -3,13 +3,13 @@ "use strict"; function avatar_simplify() { - $('#av_options').hide(); + $('#av_options > div').hide(); var selected = $('#avatar_driver').val(); $('#av_option_' + selected).show(); } avatar_simplify(); -$('#avatar_driver').on('change', avatar_simplify); +$('#avatar_driver').bind('change', avatar_simplify); })(jQuery); // Avoid conflicts with other libraries diff --git a/phpBB/styles/prosilver/template/avatars.js b/phpBB/styles/prosilver/template/avatars.js index cb19aa9b7a..2068bdbbc4 100644 --- a/phpBB/styles/prosilver/template/avatars.js +++ b/phpBB/styles/prosilver/template/avatars.js @@ -3,13 +3,13 @@ "use strict"; function avatar_simplify() { - $('#av_options').hide(); + $('#av_options > div').hide(); var selected = $('#avatar_driver').val(); $('#av_option_' + selected).show(); } avatar_simplify(); -$('#avatar_driver').on('change', avatar_simplify); +$('#avatar_driver').bind('change', avatar_simplify); })(jQuery); // Avoid conflicts with other libraries From df16bd1c49e6e970b147f15e752825dd3186fb87 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Wed, 27 Jun 2012 21:02:07 +0200 Subject: [PATCH 0042/2494] [feature/avatars] Rewrite drivers to use full class name * Use full driver class name as avatar_type value * Move avatar drivers to core namespace * Make avatars installable through extensions PHPBB3-10018 --- phpBB/common.php | 2 +- phpBB/download/file.php | 2 +- .../avatar/driver/{ => core}/local.php | 2 +- .../avatar/driver/{ => core}/remote.php | 2 +- .../avatar/driver/{ => core}/upload.php | 2 +- phpBB/includes/avatar/driver/driver.php | 21 +++++++ phpBB/includes/avatar/driver/interface.php | 10 ++++ phpBB/includes/avatar/manager.php | 55 +++++++++---------- phpBB/includes/ucp/ucp_profile.php | 10 ++-- 9 files changed, 68 insertions(+), 38 deletions(-) rename phpBB/includes/avatar/driver/{ => core}/local.php (98%) rename phpBB/includes/avatar/driver/{ => core}/remote.php (98%) rename phpBB/includes/avatar/driver/{ => core}/upload.php (98%) diff --git a/phpBB/common.php b/phpBB/common.php index 11b84ee858..52666685ac 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -130,7 +130,7 @@ $phpbb_style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $phpbb_ $phpbb_subscriber_loader = new phpbb_event_extension_subscriber_loader($phpbb_dispatcher, $phpbb_extension_manager); $phpbb_subscriber_loader->load(); -$phpbb_avatar_manager = new phpbb_avatar_manager($phpbb_root_path, $phpEx, $config, $request, $cache->get_driver()); +$phpbb_avatar_manager = new phpbb_avatar_manager($phpbb_root_path, $phpEx, $config, $request, $phpbb_extension_manager, $cache->get_driver()); // Add own hook handler require($phpbb_root_path . 'includes/hooks/index.' . $phpEx); diff --git a/phpBB/download/file.php b/phpBB/download/file.php index 55364b3fd0..34999ab24c 100644 --- a/phpBB/download/file.php +++ b/phpBB/download/file.php @@ -82,7 +82,7 @@ if (isset($_GET['avatar'])) $phpbb_subscriber_loader = new phpbb_event_extension_subscriber_loader($phpbb_dispatcher, $phpbb_extension_manager); $phpbb_subscriber_loader->load(); - $phpbb_avatar_manager = new phpbb_avatar_manager($phpbb_root_path, $phpEx, $config, $request, $cache->get_driver()); + $phpbb_avatar_manager = new phpbb_avatar_manager($phpbb_root_path, $phpEx, $config, $request, $phpbb_extension_manager, $cache->get_driver()); $filename = request_var('avatar', ''); $avatar_group = false; diff --git a/phpBB/includes/avatar/driver/local.php b/phpBB/includes/avatar/driver/core/local.php similarity index 98% rename from phpBB/includes/avatar/driver/local.php rename to phpBB/includes/avatar/driver/core/local.php index a0ef912eae..ca82b9c175 100644 --- a/phpBB/includes/avatar/driver/local.php +++ b/phpBB/includes/avatar/driver/core/local.php @@ -19,7 +19,7 @@ if (!defined('IN_PHPBB')) * Handles avatars selected from the board gallery * @package avatars */ -class phpbb_avatar_driver_local extends phpbb_avatar_driver +class phpbb_avatar_driver_core_local extends phpbb_avatar_driver { /** * @inheritdoc diff --git a/phpBB/includes/avatar/driver/remote.php b/phpBB/includes/avatar/driver/core/remote.php similarity index 98% rename from phpBB/includes/avatar/driver/remote.php rename to phpBB/includes/avatar/driver/core/remote.php index cd0a756428..9f5a58e75a 100644 --- a/phpBB/includes/avatar/driver/remote.php +++ b/phpBB/includes/avatar/driver/core/remote.php @@ -19,7 +19,7 @@ if (!defined('IN_PHPBB')) * Handles avatars hosted remotely * @package avatars */ -class phpbb_avatar_driver_remote extends phpbb_avatar_driver +class phpbb_avatar_driver_core_remote extends phpbb_avatar_driver { /** * @inheritdoc diff --git a/phpBB/includes/avatar/driver/upload.php b/phpBB/includes/avatar/driver/core/upload.php similarity index 98% rename from phpBB/includes/avatar/driver/upload.php rename to phpBB/includes/avatar/driver/core/upload.php index d9504c04a0..d0ce856dbe 100644 --- a/phpBB/includes/avatar/driver/upload.php +++ b/phpBB/includes/avatar/driver/core/upload.php @@ -19,7 +19,7 @@ if (!defined('IN_PHPBB')) * Handles avatars uploaded to the board * @package avatars */ -class phpbb_avatar_driver_upload extends phpbb_avatar_driver +class phpbb_avatar_driver_core_upload extends phpbb_avatar_driver { /** * @inheritdoc diff --git a/phpBB/includes/avatar/driver/driver.php b/phpBB/includes/avatar/driver/driver.php index 4ac6762140..5cebd1533d 100644 --- a/phpBB/includes/avatar/driver/driver.php +++ b/phpBB/includes/avatar/driver/driver.php @@ -119,4 +119,25 @@ abstract class phpbb_avatar_driver implements phpbb_avatar_driver_interface { return true; } + + /** + * @inheritdoc + **/ + public function is_enabled() + { + $driver = preg_replace('#^phpbb_avatar_driver_core_#', '', get_class($this)); + + return $this->config["allow_avatar_$driver"]; + } + + /** + * @inheritdoc + **/ + public function get_template_name() + { + $driver = preg_replace('#^phpbb_avatar_driver_core_#', '', get_class($this)); + $template = "ucp_avatar_options_$driver.html"; + + return $template; + } } diff --git a/phpBB/includes/avatar/driver/interface.php b/phpBB/includes/avatar/driver/interface.php index d3b764e275..4f1c1f73cf 100644 --- a/phpBB/includes/avatar/driver/interface.php +++ b/phpBB/includes/avatar/driver/interface.php @@ -57,4 +57,14 @@ interface phpbb_avatar_driver_interface * @TODO **/ public function delete($row); + + /** + * @TODO + **/ + public function is_enabled(); + + /** + * @TODO + **/ + public function get_template_name(); } diff --git a/phpBB/includes/avatar/manager.php b/phpBB/includes/avatar/manager.php index 839216b61e..c2c3dbbbca 100644 --- a/phpBB/includes/avatar/manager.php +++ b/phpBB/includes/avatar/manager.php @@ -24,25 +24,27 @@ class phpbb_avatar_manager private $phpEx; private $config; private $request; + private $extension_manager; private $cache; private static $valid_drivers = false; /** * @TODO **/ - public function __construct($phpbb_root_path, $phpEx, phpbb_config $config, phpbb_request $request, phpbb_cache_driver_interface $cache = null) + public function __construct($phpbb_root_path, $phpEx, phpbb_config $config, phpbb_request $request, phpbb_extension_manager $extension_manager, phpbb_cache_driver_interface $cache = null) { $this->phpbb_root_path = $phpbb_root_path; $this->phpEx = $phpEx; $this->config = $config; $this->request = $request; + $this->extension_manager = $extension_manager; $this->cache = $cache; } /** * @TODO **/ - public function get_driver($avatar_type, $new = false) + public function get_driver($avatar_type) { if (self::$valid_drivers === false) { @@ -53,30 +55,33 @@ class phpbb_avatar_manager switch ($avatar_type) { case AVATAR_GALLERY: - $avatar_type = 'local'; + $avatar_type = 'phpbb_avatar_driver_local'; break; case AVATAR_UPLOAD: - $avatar_type = 'upload'; + $avatar_type = 'phpbb_avatar_driver_upload'; break; case AVATAR_REMOTE: - $avatar_type = 'remote'; + $avatar_type = 'phpbb_avatar_driver_remote'; break; } - if (isset(self::$valid_drivers[$avatar_type])) - { - if ($new || !is_object(self::$valid_drivers[$avatar_type])) - { - $class_name = 'phpbb_avatar_driver_' . $avatar_type; - self::$valid_drivers[$avatar_type] = new $class_name($this->config, $this->request, $this->phpbb_root_path, $this->phpEx, $this->cache); - } - - return self::$valid_drivers[$avatar_type]; - } - else + if (false === array_search($avatar_type, self::$valid_drivers)) { return null; } + + $r = new ReflectionClass($avatar_type); + + if ($r->isSubClassOf('phpbb_avatar_driver')) { + $driver = new $avatar_type($this->config, $this->request, $this->phpbb_root_path, $this->phpEx, $this->cache); + } else if ($r->implementsInterface('phpbb_avatar_driver')) { + $driver = new $avatar_type(); + } else { + $message = "Invalid avatar driver class name '%s' provided. It must implement phpbb_avatar_driver_interface."; + trigger_error(sprintf($message, $avatar_type)); + } + + return $driver; } /** @@ -93,18 +98,12 @@ class phpbb_avatar_manager { self::$valid_drivers = array(); - $iterator = new DirectoryIterator($this->phpbb_root_path . 'includes/avatar/driver'); + $finder = $this->extension_manager->get_finder(); - foreach ($iterator as $file) - { - // Match all files that appear to be php files - if (preg_match("/^(.*)\.{$this->phpEx}$/", $file, $match)) - { - self::$valid_drivers[] = $match[1]; - } - } - - self::$valid_drivers = array_flip(self::$valid_drivers); + self::$valid_drivers = $finder + ->extension_directory('/avatar/driver/') + ->core_path('includes/avatar/driver/core/') + ->get_classes(); if ($this->cache) { @@ -123,7 +122,7 @@ class phpbb_avatar_manager $this->load_valid_drivers(); } - return array_keys(self::$valid_drivers); + return self::$valid_drivers; } /** diff --git a/phpBB/includes/ucp/ucp_profile.php b/phpBB/includes/ucp/ucp_profile.php index 6b2133796d..f406e9dc5b 100644 --- a/phpBB/includes/ucp/ucp_profile.php +++ b/phpBB/includes/ucp/ucp_profile.php @@ -623,18 +623,18 @@ class ucp_profile } $focused_driver = request_var('avatar_driver', $user->data['user_avatar_type']); - + foreach ($avatar_drivers as $driver) { - if ($config["allow_avatar_$driver"]) + $avatar = $phpbb_avatar_manager->get_driver($driver); + + if ($avatar->is_enabled()) { $avatars_enabled = true; $template->set_filenames(array( - 'avatar' => "ucp_avatar_options_$driver.html", + 'avatar' => $avatar->get_template_name(), )); - $avatar = $phpbb_avatar_manager->get_driver($driver); - if ($avatar->prepare_form($template, $avatar_data, $error)) { $driver_u = strtoupper($driver); From 90a957ad26f52e26c3979464c5ac15b1fd0fcc28 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 21 Jul 2012 17:43:43 +0200 Subject: [PATCH 0043/2494] [ticket/11015] Make DBAL classes autoloadable PHPBB3-11015 This allows us to just create the object without having to include the driver first. However, it also means that users must specify the full class name in config.php --- phpBB/common.php | 3 +- phpBB/download/file.php | 3 +- phpBB/includes/config/db.php | 2 +- phpBB/includes/db/dbal.php | 1049 ----------------- phpBB/includes/db/driver/driver.php | 1044 ++++++++++++++++ phpBB/includes/db/{ => driver}/firebird.php | 4 +- phpBB/includes/db/{ => driver}/mssql.php | 6 +- phpBB/includes/db/{ => driver}/mssql_odbc.php | 4 +- .../includes/db/{ => driver}/mssqlnative.php | 4 +- phpBB/includes/db/{ => driver}/mysql.php | 4 +- phpBB/includes/db/{ => driver}/mysqli.php | 4 +- phpBB/includes/db/{ => driver}/oracle.php | 4 +- phpBB/includes/db/{ => driver}/postgres.php | 9 +- phpBB/includes/db/{ => driver}/sqlite.php | 4 +- phpBB/includes/extension/manager.php | 4 +- phpBB/includes/functions_install.php | 59 +- phpBB/install/database_update.php | 7 +- phpBB/install/install_convert.php | 24 +- phpBB/install/install_install.php | 12 +- phpBB/install/install_update.php | 3 +- tests/RUNNING_TESTS.txt | 2 +- tests/session/testable_factory.php | 2 +- .../phpbb_database_test_case.php | 7 +- ...phpbb_database_test_connection_manager.php | 44 +- .../phpbb_functional_test_case.php | 8 +- .../phpbb_test_case_helpers.php | 2 +- 26 files changed, 1129 insertions(+), 1189 deletions(-) delete mode 100644 phpBB/includes/db/dbal.php create mode 100644 phpBB/includes/db/driver/driver.php rename phpBB/includes/db/{ => driver}/firebird.php (99%) rename phpBB/includes/db/{ => driver}/mssql.php (99%) rename phpBB/includes/db/{ => driver}/mssql_odbc.php (98%) rename phpBB/includes/db/{ => driver}/mssqlnative.php (99%) rename phpBB/includes/db/{ => driver}/mysql.php (99%) rename phpBB/includes/db/{ => driver}/mysqli.php (99%) rename phpBB/includes/db/{ => driver}/oracle.php (99%) rename phpBB/includes/db/{ => driver}/postgres.php (98%) rename phpBB/includes/db/{ => driver}/sqlite.php (98%) diff --git a/phpBB/common.php b/phpBB/common.php index 81fe275008..9862fcf4c3 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -79,7 +79,6 @@ require($phpbb_root_path . 'includes/functions.' . $phpEx); require($phpbb_root_path . 'includes/functions_content.' . $phpEx); require($phpbb_root_path . 'includes/constants.' . $phpEx); -require($phpbb_root_path . 'includes/db/' . $dbms . '.' . $phpEx); require($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx); // Set PHP error handler to ours @@ -102,7 +101,7 @@ $phpbb_dispatcher = new phpbb_event_dispatcher(); $request = new phpbb_request(); $user = new phpbb_user(); $auth = new phpbb_auth(); -$db = new $sql_db(); +$db = new $dbms(); // make sure request_var uses this request instance request_var('', 0, false, false, $request); // "dependency injection" for a function diff --git a/phpBB/download/file.php b/phpBB/download/file.php index c01b0789de..72c2d3ba3f 100644 --- a/phpBB/download/file.php +++ b/phpBB/download/file.php @@ -39,7 +39,6 @@ if (isset($_GET['avatar'])) } require($phpbb_root_path . 'includes/class_loader.' . $phpEx); - require($phpbb_root_path . 'includes/db/' . $dbms . '.' . $phpEx); require($phpbb_root_path . 'includes/constants.' . $phpEx); require($phpbb_root_path . 'includes/functions.' . $phpEx); require($phpbb_root_path . 'includes/functions_download' . '.' . $phpEx); @@ -58,7 +57,7 @@ if (isset($_GET['avatar'])) $phpbb_dispatcher = new phpbb_event_dispatcher(); $request = new phpbb_request(); - $db = new $sql_db(); + $db = new $dbms(); // Connect to DB if (!@$db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, false)) diff --git a/phpBB/includes/config/db.php b/phpBB/includes/config/db.php index 993a764a7f..4293498d97 100644 --- a/phpBB/includes/config/db.php +++ b/phpBB/includes/config/db.php @@ -46,7 +46,7 @@ class phpbb_config_db extends phpbb_config * @param phpbb_cache_driver_interface $cache Cache instance * @param string $table Configuration table name */ - public function __construct(dbal $db, phpbb_cache_driver_interface $cache, $table) + public function __construct(phpbb_db_driver $db, phpbb_cache_driver_interface $cache, $table) { $this->db = $db; $this->cache = $cache; diff --git a/phpBB/includes/db/dbal.php b/phpBB/includes/db/dbal.php deleted file mode 100644 index 159703d3be..0000000000 --- a/phpBB/includes/db/dbal.php +++ /dev/null @@ -1,1049 +0,0 @@ -num_queries = array( - 'cached' => 0, - 'normal' => 0, - 'total' => 0, - ); - - // Fill default sql layer based on the class being called. - // This can be changed by the specified layer itself later if needed. - $this->sql_layer = substr(get_class($this), 5); - - // Do not change this please! This variable is used to easy the use of it - and is hardcoded. - $this->any_char = chr(0) . '%'; - $this->one_char = chr(0) . '_'; - } - - /** - * return on error or display error message - */ - function sql_return_on_error($fail = false) - { - $this->sql_error_triggered = false; - $this->sql_error_sql = ''; - - $this->return_on_error = $fail; - } - - /** - * Return number of sql queries and cached sql queries used - */ - function sql_num_queries($cached = false) - { - return ($cached) ? $this->num_queries['cached'] : $this->num_queries['normal']; - } - - /** - * Add to query count - */ - function sql_add_num_queries($cached = false) - { - $this->num_queries['cached'] += ($cached !== false) ? 1 : 0; - $this->num_queries['normal'] += ($cached !== false) ? 0 : 1; - $this->num_queries['total'] += 1; - } - - /** - * DBAL garbage collection, close sql connection - */ - function sql_close() - { - if (!$this->db_connect_id) - { - return false; - } - - if ($this->transaction) - { - do - { - $this->sql_transaction('commit'); - } - while ($this->transaction); - } - - foreach ($this->open_queries as $query_id) - { - $this->sql_freeresult($query_id); - } - - // Connection closed correctly. Set db_connect_id to false to prevent errors - if ($result = $this->_sql_close()) - { - $this->db_connect_id = false; - } - - return $result; - } - - /** - * Build LIMIT query - * Doing some validation here. - */ - function sql_query_limit($query, $total, $offset = 0, $cache_ttl = 0) - { - if (empty($query)) - { - return false; - } - - // Never use a negative total or offset - $total = ($total < 0) ? 0 : $total; - $offset = ($offset < 0) ? 0 : $offset; - - return $this->_sql_query_limit($query, $total, $offset, $cache_ttl); - } - - /** - * Fetch all rows - */ - function sql_fetchrowset($query_id = false) - { - if ($query_id === false) - { - $query_id = $this->query_result; - } - - if ($query_id !== false) - { - $result = array(); - while ($row = $this->sql_fetchrow($query_id)) - { - $result[] = $row; - } - - return $result; - } - - return false; - } - - /** - * Seek to given row number - * rownum is zero-based - */ - function sql_rowseek($rownum, &$query_id) - { - global $cache; - - if ($query_id === false) - { - $query_id = $this->query_result; - } - - if (isset($cache->sql_rowset[$query_id])) - { - return $cache->sql_rowseek($rownum, $query_id); - } - - if ($query_id === false) - { - return false; - } - - $this->sql_freeresult($query_id); - $query_id = $this->sql_query($this->last_query_text); - - if ($query_id === false) - { - return false; - } - - // We do not fetch the row for rownum == 0 because then the next resultset would be the second row - for ($i = 0; $i < $rownum; $i++) - { - if (!$this->sql_fetchrow($query_id)) - { - return false; - } - } - - return true; - } - - /** - * Fetch field - * if rownum is false, the current row is used, else it is pointing to the row (zero-based) - */ - function sql_fetchfield($field, $rownum = false, $query_id = false) - { - global $cache; - - if ($query_id === false) - { - $query_id = $this->query_result; - } - - if ($query_id !== false) - { - if ($rownum !== false) - { - $this->sql_rowseek($rownum, $query_id); - } - - if (!is_object($query_id) && isset($cache->sql_rowset[$query_id])) - { - return $cache->sql_fetchfield($query_id, $field); - } - - $row = $this->sql_fetchrow($query_id); - return (isset($row[$field])) ? $row[$field] : false; - } - - return false; - } - - /** - * Correctly adjust LIKE expression for special characters - * Some DBMS are handling them in a different way - * - * @param string $expression The expression to use. Every wildcard is escaped, except $this->any_char and $this->one_char - * @return string LIKE expression including the keyword! - */ - function sql_like_expression($expression) - { - $expression = utf8_str_replace(array('_', '%'), array("\_", "\%"), $expression); - $expression = utf8_str_replace(array(chr(0) . "\_", chr(0) . "\%"), array('_', '%'), $expression); - - return $this->_sql_like_expression('LIKE \'' . $this->sql_escape($expression) . '\''); - } - - /** - * Build a case expression - * - * Note: The two statements action_true and action_false must have the same data type (int, vchar, ...) in the database! - * - * @param string $condition The condition which must be true, to use action_true rather then action_else - * @param string $action_true SQL expression that is used, if the condition is true - * @param string $action_else SQL expression that is used, if the condition is false, optional - * @return string CASE expression including the condition and statements - */ - public function sql_case($condition, $action_true, $action_false = false) - { - $sql_case = 'CASE WHEN ' . $condition; - $sql_case .= ' THEN ' . $action_true; - $sql_case .= ($action_false !== false) ? ' ELSE ' . $action_false : ''; - $sql_case .= ' END'; - return $sql_case; - } - - /** - * Build a concatenated expression - * - * @param string $expr1 Base SQL expression where we append the second one - * @param string $expr2 SQL expression that is appended to the first expression - * @return string Concatenated string - */ - public function sql_concatenate($expr1, $expr2) - { - return $expr1 . ' || ' . $expr2; - } - - /** - * Returns whether results of a query need to be buffered to run a transaction while iterating over them. - * - * @return bool Whether buffering is required. - */ - function sql_buffer_nested_transactions() - { - return false; - } - - /** - * SQL Transaction - * @access private - */ - function sql_transaction($status = 'begin') - { - switch ($status) - { - case 'begin': - // If we are within a transaction we will not open another one, but enclose the current one to not loose data (prevening auto commit) - if ($this->transaction) - { - $this->transactions++; - return true; - } - - $result = $this->_sql_transaction('begin'); - - if (!$result) - { - $this->sql_error(); - } - - $this->transaction = true; - break; - - case 'commit': - // If there was a previously opened transaction we do not commit yet... but count back the number of inner transactions - if ($this->transaction && $this->transactions) - { - $this->transactions--; - return true; - } - - // Check if there is a transaction (no transaction can happen if there was an error, with a combined rollback and error returning enabled) - // This implies we have transaction always set for autocommit db's - if (!$this->transaction) - { - return false; - } - - $result = $this->_sql_transaction('commit'); - - if (!$result) - { - $this->sql_error(); - } - - $this->transaction = false; - $this->transactions = 0; - break; - - case 'rollback': - $result = $this->_sql_transaction('rollback'); - $this->transaction = false; - $this->transactions = 0; - break; - - default: - $result = $this->_sql_transaction($status); - break; - } - - return $result; - } - - /** - * Build sql statement from array for insert/update/select statements - * - * Idea for this from Ikonboard - * Possible query values: INSERT, INSERT_SELECT, UPDATE, SELECT - * - */ - function sql_build_array($query, $assoc_ary = false) - { - if (!is_array($assoc_ary)) - { - return false; - } - - $fields = $values = array(); - - if ($query == 'INSERT' || $query == 'INSERT_SELECT') - { - foreach ($assoc_ary as $key => $var) - { - $fields[] = $key; - - if (is_array($var) && is_string($var[0])) - { - // This is used for INSERT_SELECT(s) - $values[] = $var[0]; - } - else - { - $values[] = $this->_sql_validate_value($var); - } - } - - $query = ($query == 'INSERT') ? ' (' . implode(', ', $fields) . ') VALUES (' . implode(', ', $values) . ')' : ' (' . implode(', ', $fields) . ') SELECT ' . implode(', ', $values) . ' '; - } - else if ($query == 'MULTI_INSERT') - { - trigger_error('The MULTI_INSERT query value is no longer supported. Please use sql_multi_insert() instead.', E_USER_ERROR); - } - else if ($query == 'UPDATE' || $query == 'SELECT') - { - $values = array(); - foreach ($assoc_ary as $key => $var) - { - $values[] = "$key = " . $this->_sql_validate_value($var); - } - $query = implode(($query == 'UPDATE') ? ', ' : ' AND ', $values); - } - - return $query; - } - - /** - * Build IN or NOT IN sql comparison string, uses <> or = on single element - * arrays to improve comparison speed - * - * @access public - * @param string $field name of the sql column that shall be compared - * @param array $array array of values that are allowed (IN) or not allowed (NOT IN) - * @param bool $negate true for NOT IN (), false for IN () (default) - * @param bool $allow_empty_set If true, allow $array to be empty, this function will return 1=1 or 1=0 then. Default to false. - */ - function sql_in_set($field, $array, $negate = false, $allow_empty_set = false) - { - if (!sizeof($array)) - { - if (!$allow_empty_set) - { - // Print the backtrace to help identifying the location of the problematic code - $this->sql_error('No values specified for SQL IN comparison'); - } - else - { - // NOT IN () actually means everything so use a tautology - if ($negate) - { - return '1=1'; - } - // IN () actually means nothing so use a contradiction - else - { - return '1=0'; - } - } - } - - if (!is_array($array)) - { - $array = array($array); - } - - if (sizeof($array) == 1) - { - @reset($array); - $var = current($array); - - return $field . ($negate ? ' <> ' : ' = ') . $this->_sql_validate_value($var); - } - else - { - return $field . ($negate ? ' NOT IN ' : ' IN ') . '(' . implode(', ', array_map(array($this, '_sql_validate_value'), $array)) . ')'; - } - } - - /** - * Run binary AND operator on DB column. - * Results in sql statement: "{$column_name} & (1 << {$bit}) {$compare}" - * - * @param string $column_name The column name to use - * @param int $bit The value to use for the AND operator, will be converted to (1 << $bit). Is used by options, using the number schema... 0, 1, 2...29 - * @param string $compare Any custom SQL code after the check (for example "= 0") - */ - function sql_bit_and($column_name, $bit, $compare = '') - { - if (method_exists($this, '_sql_bit_and')) - { - return $this->_sql_bit_and($column_name, $bit, $compare); - } - - return $column_name . ' & ' . (1 << $bit) . (($compare) ? ' ' . $compare : ''); - } - - /** - * Run binary OR operator on DB column. - * Results in sql statement: "{$column_name} | (1 << {$bit}) {$compare}" - * - * @param string $column_name The column name to use - * @param int $bit The value to use for the OR operator, will be converted to (1 << $bit). Is used by options, using the number schema... 0, 1, 2...29 - * @param string $compare Any custom SQL code after the check (for example "= 0") - */ - function sql_bit_or($column_name, $bit, $compare = '') - { - if (method_exists($this, '_sql_bit_or')) - { - return $this->_sql_bit_or($column_name, $bit, $compare); - } - - return $column_name . ' | ' . (1 << $bit) . (($compare) ? ' ' . $compare : ''); - } - - /** - * Returns SQL string to cast a string expression to an int. - * - * @param string $expression An expression evaluating to string - * @return string Expression returning an int - */ - function cast_expr_to_bigint($expression) - { - return $expression; - } - - /** - * Returns SQL string to cast an integer expression to a string. - * - * @param string $expression An expression evaluating to int - * @return string Expression returning a string - */ - function cast_expr_to_string($expression) - { - return $expression; - } - - /** - * Run LOWER() on DB column of type text (i.e. neither varchar nor char). - * - * @param string $column_name The column name to use - * - * @return string A SQL statement like "LOWER($column_name)" - */ - function sql_lower_text($column_name) - { - return "LOWER($column_name)"; - } - - /** - * Run more than one insert statement. - * - * @param string $table table name to run the statements on - * @param array &$sql_ary multi-dimensional array holding the statement data. - * - * @return bool false if no statements were executed. - * @access public - */ - function sql_multi_insert($table, &$sql_ary) - { - if (!sizeof($sql_ary)) - { - return false; - } - - if ($this->multi_insert) - { - $ary = array(); - foreach ($sql_ary as $id => $_sql_ary) - { - // If by accident the sql array is only one-dimensional we build a normal insert statement - if (!is_array($_sql_ary)) - { - return $this->sql_query('INSERT INTO ' . $table . ' ' . $this->sql_build_array('INSERT', $sql_ary)); - } - - $values = array(); - foreach ($_sql_ary as $key => $var) - { - $values[] = $this->_sql_validate_value($var); - } - $ary[] = '(' . implode(', ', $values) . ')'; - } - - return $this->sql_query('INSERT INTO ' . $table . ' ' . ' (' . implode(', ', array_keys($sql_ary[0])) . ') VALUES ' . implode(', ', $ary)); - } - else - { - foreach ($sql_ary as $ary) - { - if (!is_array($ary)) - { - return false; - } - - $result = $this->sql_query('INSERT INTO ' . $table . ' ' . $this->sql_build_array('INSERT', $ary)); - - if (!$result) - { - return false; - } - } - } - - return true; - } - - /** - * Function for validating values - * @access private - */ - function _sql_validate_value($var) - { - if (is_null($var)) - { - return 'NULL'; - } - else if (is_string($var)) - { - return "'" . $this->sql_escape($var) . "'"; - } - else - { - return (is_bool($var)) ? intval($var) : $var; - } - } - - /** - * Build sql statement from array for select and select distinct statements - * - * Possible query values: SELECT, SELECT_DISTINCT - */ - function sql_build_query($query, $array) - { - $sql = ''; - switch ($query) - { - case 'SELECT': - case 'SELECT_DISTINCT'; - - $sql = str_replace('_', ' ', $query) . ' ' . $array['SELECT'] . ' FROM '; - - // Build table array. We also build an alias array for later checks. - $table_array = $aliases = array(); - $used_multi_alias = false; - - foreach ($array['FROM'] as $table_name => $alias) - { - if (is_array($alias)) - { - $used_multi_alias = true; - - foreach ($alias as $multi_alias) - { - $table_array[] = $table_name . ' ' . $multi_alias; - $aliases[] = $multi_alias; - } - } - else - { - $table_array[] = $table_name . ' ' . $alias; - $aliases[] = $alias; - } - } - - // We run the following code to determine if we need to re-order the table array. ;) - // The reason for this is that for multi-aliased tables (two equal tables) in the FROM statement the last table need to match the first comparison. - // DBMS who rely on this: Oracle, PostgreSQL and MSSQL. For all other DBMS it makes absolutely no difference in which order the table is. - if (!empty($array['LEFT_JOIN']) && sizeof($array['FROM']) > 1 && $used_multi_alias !== false) - { - // Take first LEFT JOIN - $join = current($array['LEFT_JOIN']); - - // Determine the table used there (even if there are more than one used, we only want to have one - preg_match('/(' . implode('|', $aliases) . ')\.[^\s]+/U', str_replace(array('(', ')', 'AND', 'OR', ' '), '', $join['ON']), $matches); - - // If there is a first join match, we need to make sure the table order is correct - if (!empty($matches[1])) - { - $first_join_match = trim($matches[1]); - $table_array = $last = array(); - - foreach ($array['FROM'] as $table_name => $alias) - { - if (is_array($alias)) - { - foreach ($alias as $multi_alias) - { - ($multi_alias === $first_join_match) ? $last[] = $table_name . ' ' . $multi_alias : $table_array[] = $table_name . ' ' . $multi_alias; - } - } - else - { - ($alias === $first_join_match) ? $last[] = $table_name . ' ' . $alias : $table_array[] = $table_name . ' ' . $alias; - } - } - - $table_array = array_merge($table_array, $last); - } - } - - $sql .= $this->_sql_custom_build('FROM', implode(' CROSS JOIN ', $table_array)); - - if (!empty($array['LEFT_JOIN'])) - { - foreach ($array['LEFT_JOIN'] as $join) - { - $sql .= ' LEFT JOIN ' . key($join['FROM']) . ' ' . current($join['FROM']) . ' ON (' . $join['ON'] . ')'; - } - } - - if (!empty($array['WHERE'])) - { - $sql .= ' WHERE ' . $this->_sql_custom_build('WHERE', $array['WHERE']); - } - - if (!empty($array['GROUP_BY'])) - { - $sql .= ' GROUP BY ' . $array['GROUP_BY']; - } - - if (!empty($array['ORDER_BY'])) - { - $sql .= ' ORDER BY ' . $array['ORDER_BY']; - } - - break; - } - - return $sql; - } - - /** - * display sql error page - */ - function sql_error($sql = '') - { - global $auth, $user, $config; - - // Set var to retrieve errored status - $this->sql_error_triggered = true; - $this->sql_error_sql = $sql; - - $this->sql_error_returned = $this->_sql_error(); - - if (!$this->return_on_error) - { - $message = 'SQL ERROR [ ' . $this->sql_layer . ' ]

    ' . $this->sql_error_returned['message'] . ' [' . $this->sql_error_returned['code'] . ']'; - - // Show complete SQL error and path to administrators only - // Additionally show complete error on installation or if extended debug mode is enabled - // The DEBUG_EXTRA constant is for development only! - if ((isset($auth) && $auth->acl_get('a_')) || defined('IN_INSTALL') || defined('DEBUG_EXTRA')) - { - $message .= ($sql) ? '

    SQL

    ' . htmlspecialchars($sql) : ''; - } - else - { - // If error occurs in initiating the session we need to use a pre-defined language string - // This could happen if the connection could not be established for example (then we are not able to grab the default language) - if (!isset($user->lang['SQL_ERROR_OCCURRED'])) - { - $message .= '

    An sql error occurred while fetching this page. Please contact an administrator if this problem persists.'; - } - else - { - if (!empty($config['board_contact'])) - { - $message .= '

    ' . sprintf($user->lang['SQL_ERROR_OCCURRED'], '', ''); - } - else - { - $message .= '

    ' . sprintf($user->lang['SQL_ERROR_OCCURRED'], '', ''); - } - } - } - - if ($this->transaction) - { - $this->sql_transaction('rollback'); - } - - if (strlen($message) > 1024) - { - // We need to define $msg_long_text here to circumvent text stripping. - global $msg_long_text; - $msg_long_text = $message; - - trigger_error(false, E_USER_ERROR); - } - - trigger_error($message, E_USER_ERROR); - } - - if ($this->transaction) - { - $this->sql_transaction('rollback'); - } - - return $this->sql_error_returned; - } - - /** - * Explain queries - */ - function sql_report($mode, $query = '') - { - global $cache, $starttime, $phpbb_root_path, $user; - global $request; - - if (is_object($request) && !$request->variable('explain', false)) - { - return false; - } - - if (!$query && $this->query_hold != '') - { - $query = $this->query_hold; - } - - switch ($mode) - { - case 'display': - if (!empty($cache)) - { - $cache->unload(); - } - $this->sql_close(); - - $mtime = explode(' ', microtime()); - $totaltime = $mtime[0] + $mtime[1] - $starttime; - - echo ' - - - - SQL Report - - - -
    - -
    -
    -
    - -
    -

    SQL Report

    -
    -

    Page generated in ' . round($totaltime, 4) . " seconds with {$this->num_queries['normal']} queries" . (($this->num_queries['cached']) ? " + {$this->num_queries['cached']} " . (($this->num_queries['cached'] == 1) ? 'query' : 'queries') . ' returning data from cache' : '') . '

    - -

    Time spent on ' . $this->sql_layer . ' queries: ' . round($this->sql_time, 5) . 's | Time spent on PHP: ' . round($totaltime - $this->sql_time, 5) . 's

    - -

    - ' . $this->sql_report . ' -
    - -
    -
    -
    - -
    - - '; - - exit_handler(); - - break; - - case 'stop': - $endtime = explode(' ', microtime()); - $endtime = $endtime[0] + $endtime[1]; - - $this->sql_report .= ' - - - - - - - - - - - - -
    Query #' . $this->num_queries['total'] . '
    - - ' . $this->html_hold . ' - -

    - '; - - if ($this->query_result) - { - if (preg_match('/^(UPDATE|DELETE|REPLACE)/', $query)) - { - $this->sql_report .= 'Affected rows: ' . $this->sql_affectedrows($this->query_result) . ' | '; - } - $this->sql_report .= 'Before: ' . sprintf('%.5f', $this->curtime - $starttime) . 's | After: ' . sprintf('%.5f', $endtime - $starttime) . 's | Elapsed: ' . sprintf('%.5f', $endtime - $this->curtime) . 's'; - } - else - { - $error = $this->sql_error(); - $this->sql_report .= 'FAILED - ' . $this->sql_layer . ' Error ' . $error['code'] . ': ' . htmlspecialchars($error['message']); - } - - $this->sql_report .= '



    '; - - $this->sql_time += $endtime - $this->curtime; - break; - - case 'start': - $this->query_hold = $query; - $this->html_hold = ''; - - $this->_sql_report($mode, $query); - - $this->curtime = explode(' ', microtime()); - $this->curtime = $this->curtime[0] + $this->curtime[1]; - - break; - - case 'add_select_row': - - $html_table = func_get_arg(2); - $row = func_get_arg(3); - - if (!$html_table && sizeof($row)) - { - $html_table = true; - $this->html_hold .= ''; - - foreach (array_keys($row) as $val) - { - $this->html_hold .= ''; - } - $this->html_hold .= ''; - } - $this->html_hold .= ''; - - $class = 'row1'; - foreach (array_values($row) as $val) - { - $class = ($class == 'row1') ? 'row2' : 'row1'; - $this->html_hold .= ''; - } - $this->html_hold .= ''; - - return $html_table; - - break; - - case 'fromcache': - - $this->_sql_report($mode, $query); - - break; - - case 'record_fromcache': - - $endtime = func_get_arg(2); - $splittime = func_get_arg(3); - - $time_cache = $endtime - $this->curtime; - $time_db = $splittime - $endtime; - $color = ($time_db > $time_cache) ? 'green' : 'red'; - - $this->sql_report .= '
    ' . (($val) ? ucwords(str_replace('_', ' ', $val)) : ' ') . '
    ' . (($val) ? $val : ' ') . '
    '; - $this->sql_report .= '
    Query results obtained from the cache
    '; - $this->sql_report .= '

    '; - $this->sql_report .= 'Before: ' . sprintf('%.5f', $this->curtime - $starttime) . 's | After: ' . sprintf('%.5f', $endtime - $starttime) . 's | Elapsed [cache]: ' . sprintf('%.5f', ($time_cache)) . 's | Elapsed [db]: ' . sprintf('%.5f', $time_db) . 's



    '; - - // Pad the start time to not interfere with page timing - $starttime += $time_db; - - break; - - default: - - $this->_sql_report($mode, $query); - - break; - } - - return true; - } - - /** - * Gets the estimated number of rows in a specified table. - * - * @param string $table_name Table name - * - * @return string Number of rows in $table_name. - * Prefixed with ~ if estimated (otherwise exact). - * - * @access public - */ - function get_estimated_row_count($table_name) - { - return $this->get_row_count($table_name); - } - - /** - * Gets the exact number of rows in a specified table. - * - * @param string $table_name Table name - * - * @return string Exact number of rows in $table_name. - * - * @access public - */ - function get_row_count($table_name) - { - $sql = 'SELECT COUNT(*) AS rows_total - FROM ' . $this->sql_escape($table_name); - $result = $this->sql_query($sql); - $rows_total = $this->sql_fetchfield('rows_total'); - $this->sql_freeresult($result); - - return $rows_total; - } -} - -/** -* This variable holds the class name to use later -*/ -$sql_db = (!empty($dbms)) ? 'dbal_' . basename($dbms) : 'dbal'; diff --git a/phpBB/includes/db/driver/driver.php b/phpBB/includes/db/driver/driver.php new file mode 100644 index 0000000000..39211a5af4 --- /dev/null +++ b/phpBB/includes/db/driver/driver.php @@ -0,0 +1,1044 @@ +num_queries = array( + 'cached' => 0, + 'normal' => 0, + 'total' => 0, + ); + + // Fill default sql layer based on the class being called. + // This can be changed by the specified layer itself later if needed. + $this->sql_layer = substr(get_class($this), 5); + + // Do not change this please! This variable is used to easy the use of it - and is hardcoded. + $this->any_char = chr(0) . '%'; + $this->one_char = chr(0) . '_'; + } + + /** + * return on error or display error message + */ + function sql_return_on_error($fail = false) + { + $this->sql_error_triggered = false; + $this->sql_error_sql = ''; + + $this->return_on_error = $fail; + } + + /** + * Return number of sql queries and cached sql queries used + */ + function sql_num_queries($cached = false) + { + return ($cached) ? $this->num_queries['cached'] : $this->num_queries['normal']; + } + + /** + * Add to query count + */ + function sql_add_num_queries($cached = false) + { + $this->num_queries['cached'] += ($cached !== false) ? 1 : 0; + $this->num_queries['normal'] += ($cached !== false) ? 0 : 1; + $this->num_queries['total'] += 1; + } + + /** + * DBAL garbage collection, close sql connection + */ + function sql_close() + { + if (!$this->db_connect_id) + { + return false; + } + + if ($this->transaction) + { + do + { + $this->sql_transaction('commit'); + } + while ($this->transaction); + } + + foreach ($this->open_queries as $query_id) + { + $this->sql_freeresult($query_id); + } + + // Connection closed correctly. Set db_connect_id to false to prevent errors + if ($result = $this->_sql_close()) + { + $this->db_connect_id = false; + } + + return $result; + } + + /** + * Build LIMIT query + * Doing some validation here. + */ + function sql_query_limit($query, $total, $offset = 0, $cache_ttl = 0) + { + if (empty($query)) + { + return false; + } + + // Never use a negative total or offset + $total = ($total < 0) ? 0 : $total; + $offset = ($offset < 0) ? 0 : $offset; + + return $this->_sql_query_limit($query, $total, $offset, $cache_ttl); + } + + /** + * Fetch all rows + */ + function sql_fetchrowset($query_id = false) + { + if ($query_id === false) + { + $query_id = $this->query_result; + } + + if ($query_id !== false) + { + $result = array(); + while ($row = $this->sql_fetchrow($query_id)) + { + $result[] = $row; + } + + return $result; + } + + return false; + } + + /** + * Seek to given row number + * rownum is zero-based + */ + function sql_rowseek($rownum, &$query_id) + { + global $cache; + + if ($query_id === false) + { + $query_id = $this->query_result; + } + + if (isset($cache->sql_rowset[$query_id])) + { + return $cache->sql_rowseek($rownum, $query_id); + } + + if ($query_id === false) + { + return false; + } + + $this->sql_freeresult($query_id); + $query_id = $this->sql_query($this->last_query_text); + + if ($query_id === false) + { + return false; + } + + // We do not fetch the row for rownum == 0 because then the next resultset would be the second row + for ($i = 0; $i < $rownum; $i++) + { + if (!$this->sql_fetchrow($query_id)) + { + return false; + } + } + + return true; + } + + /** + * Fetch field + * if rownum is false, the current row is used, else it is pointing to the row (zero-based) + */ + function sql_fetchfield($field, $rownum = false, $query_id = false) + { + global $cache; + + if ($query_id === false) + { + $query_id = $this->query_result; + } + + if ($query_id !== false) + { + if ($rownum !== false) + { + $this->sql_rowseek($rownum, $query_id); + } + + if (!is_object($query_id) && isset($cache->sql_rowset[$query_id])) + { + return $cache->sql_fetchfield($query_id, $field); + } + + $row = $this->sql_fetchrow($query_id); + return (isset($row[$field])) ? $row[$field] : false; + } + + return false; + } + + /** + * Correctly adjust LIKE expression for special characters + * Some DBMS are handling them in a different way + * + * @param string $expression The expression to use. Every wildcard is escaped, except $this->any_char and $this->one_char + * @return string LIKE expression including the keyword! + */ + function sql_like_expression($expression) + { + $expression = utf8_str_replace(array('_', '%'), array("\_", "\%"), $expression); + $expression = utf8_str_replace(array(chr(0) . "\_", chr(0) . "\%"), array('_', '%'), $expression); + + return $this->_sql_like_expression('LIKE \'' . $this->sql_escape($expression) . '\''); + } + + /** + * Build a case expression + * + * Note: The two statements action_true and action_false must have the same data type (int, vchar, ...) in the database! + * + * @param string $condition The condition which must be true, to use action_true rather then action_else + * @param string $action_true SQL expression that is used, if the condition is true + * @param string $action_else SQL expression that is used, if the condition is false, optional + * @return string CASE expression including the condition and statements + */ + public function sql_case($condition, $action_true, $action_false = false) + { + $sql_case = 'CASE WHEN ' . $condition; + $sql_case .= ' THEN ' . $action_true; + $sql_case .= ($action_false !== false) ? ' ELSE ' . $action_false : ''; + $sql_case .= ' END'; + return $sql_case; + } + + /** + * Build a concatenated expression + * + * @param string $expr1 Base SQL expression where we append the second one + * @param string $expr2 SQL expression that is appended to the first expression + * @return string Concatenated string + */ + public function sql_concatenate($expr1, $expr2) + { + return $expr1 . ' || ' . $expr2; + } + + /** + * Returns whether results of a query need to be buffered to run a transaction while iterating over them. + * + * @return bool Whether buffering is required. + */ + function sql_buffer_nested_transactions() + { + return false; + } + + /** + * SQL Transaction + * @access private + */ + function sql_transaction($status = 'begin') + { + switch ($status) + { + case 'begin': + // If we are within a transaction we will not open another one, but enclose the current one to not loose data (prevening auto commit) + if ($this->transaction) + { + $this->transactions++; + return true; + } + + $result = $this->_sql_transaction('begin'); + + if (!$result) + { + $this->sql_error(); + } + + $this->transaction = true; + break; + + case 'commit': + // If there was a previously opened transaction we do not commit yet... but count back the number of inner transactions + if ($this->transaction && $this->transactions) + { + $this->transactions--; + return true; + } + + // Check if there is a transaction (no transaction can happen if there was an error, with a combined rollback and error returning enabled) + // This implies we have transaction always set for autocommit db's + if (!$this->transaction) + { + return false; + } + + $result = $this->_sql_transaction('commit'); + + if (!$result) + { + $this->sql_error(); + } + + $this->transaction = false; + $this->transactions = 0; + break; + + case 'rollback': + $result = $this->_sql_transaction('rollback'); + $this->transaction = false; + $this->transactions = 0; + break; + + default: + $result = $this->_sql_transaction($status); + break; + } + + return $result; + } + + /** + * Build sql statement from array for insert/update/select statements + * + * Idea for this from Ikonboard + * Possible query values: INSERT, INSERT_SELECT, UPDATE, SELECT + * + */ + function sql_build_array($query, $assoc_ary = false) + { + if (!is_array($assoc_ary)) + { + return false; + } + + $fields = $values = array(); + + if ($query == 'INSERT' || $query == 'INSERT_SELECT') + { + foreach ($assoc_ary as $key => $var) + { + $fields[] = $key; + + if (is_array($var) && is_string($var[0])) + { + // This is used for INSERT_SELECT(s) + $values[] = $var[0]; + } + else + { + $values[] = $this->_sql_validate_value($var); + } + } + + $query = ($query == 'INSERT') ? ' (' . implode(', ', $fields) . ') VALUES (' . implode(', ', $values) . ')' : ' (' . implode(', ', $fields) . ') SELECT ' . implode(', ', $values) . ' '; + } + else if ($query == 'MULTI_INSERT') + { + trigger_error('The MULTI_INSERT query value is no longer supported. Please use sql_multi_insert() instead.', E_USER_ERROR); + } + else if ($query == 'UPDATE' || $query == 'SELECT') + { + $values = array(); + foreach ($assoc_ary as $key => $var) + { + $values[] = "$key = " . $this->_sql_validate_value($var); + } + $query = implode(($query == 'UPDATE') ? ', ' : ' AND ', $values); + } + + return $query; + } + + /** + * Build IN or NOT IN sql comparison string, uses <> or = on single element + * arrays to improve comparison speed + * + * @access public + * @param string $field name of the sql column that shall be compared + * @param array $array array of values that are allowed (IN) or not allowed (NOT IN) + * @param bool $negate true for NOT IN (), false for IN () (default) + * @param bool $allow_empty_set If true, allow $array to be empty, this function will return 1=1 or 1=0 then. Default to false. + */ + function sql_in_set($field, $array, $negate = false, $allow_empty_set = false) + { + if (!sizeof($array)) + { + if (!$allow_empty_set) + { + // Print the backtrace to help identifying the location of the problematic code + $this->sql_error('No values specified for SQL IN comparison'); + } + else + { + // NOT IN () actually means everything so use a tautology + if ($negate) + { + return '1=1'; + } + // IN () actually means nothing so use a contradiction + else + { + return '1=0'; + } + } + } + + if (!is_array($array)) + { + $array = array($array); + } + + if (sizeof($array) == 1) + { + @reset($array); + $var = current($array); + + return $field . ($negate ? ' <> ' : ' = ') . $this->_sql_validate_value($var); + } + else + { + return $field . ($negate ? ' NOT IN ' : ' IN ') . '(' . implode(', ', array_map(array($this, '_sql_validate_value'), $array)) . ')'; + } + } + + /** + * Run binary AND operator on DB column. + * Results in sql statement: "{$column_name} & (1 << {$bit}) {$compare}" + * + * @param string $column_name The column name to use + * @param int $bit The value to use for the AND operator, will be converted to (1 << $bit). Is used by options, using the number schema... 0, 1, 2...29 + * @param string $compare Any custom SQL code after the check (for example "= 0") + */ + function sql_bit_and($column_name, $bit, $compare = '') + { + if (method_exists($this, '_sql_bit_and')) + { + return $this->_sql_bit_and($column_name, $bit, $compare); + } + + return $column_name . ' & ' . (1 << $bit) . (($compare) ? ' ' . $compare : ''); + } + + /** + * Run binary OR operator on DB column. + * Results in sql statement: "{$column_name} | (1 << {$bit}) {$compare}" + * + * @param string $column_name The column name to use + * @param int $bit The value to use for the OR operator, will be converted to (1 << $bit). Is used by options, using the number schema... 0, 1, 2...29 + * @param string $compare Any custom SQL code after the check (for example "= 0") + */ + function sql_bit_or($column_name, $bit, $compare = '') + { + if (method_exists($this, '_sql_bit_or')) + { + return $this->_sql_bit_or($column_name, $bit, $compare); + } + + return $column_name . ' | ' . (1 << $bit) . (($compare) ? ' ' . $compare : ''); + } + + /** + * Returns SQL string to cast a string expression to an int. + * + * @param string $expression An expression evaluating to string + * @return string Expression returning an int + */ + function cast_expr_to_bigint($expression) + { + return $expression; + } + + /** + * Returns SQL string to cast an integer expression to a string. + * + * @param string $expression An expression evaluating to int + * @return string Expression returning a string + */ + function cast_expr_to_string($expression) + { + return $expression; + } + + /** + * Run LOWER() on DB column of type text (i.e. neither varchar nor char). + * + * @param string $column_name The column name to use + * + * @return string A SQL statement like "LOWER($column_name)" + */ + function sql_lower_text($column_name) + { + return "LOWER($column_name)"; + } + + /** + * Run more than one insert statement. + * + * @param string $table table name to run the statements on + * @param array &$sql_ary multi-dimensional array holding the statement data. + * + * @return bool false if no statements were executed. + * @access public + */ + function sql_multi_insert($table, &$sql_ary) + { + if (!sizeof($sql_ary)) + { + return false; + } + + if ($this->multi_insert) + { + $ary = array(); + foreach ($sql_ary as $id => $_sql_ary) + { + // If by accident the sql array is only one-dimensional we build a normal insert statement + if (!is_array($_sql_ary)) + { + return $this->sql_query('INSERT INTO ' . $table . ' ' . $this->sql_build_array('INSERT', $sql_ary)); + } + + $values = array(); + foreach ($_sql_ary as $key => $var) + { + $values[] = $this->_sql_validate_value($var); + } + $ary[] = '(' . implode(', ', $values) . ')'; + } + + return $this->sql_query('INSERT INTO ' . $table . ' ' . ' (' . implode(', ', array_keys($sql_ary[0])) . ') VALUES ' . implode(', ', $ary)); + } + else + { + foreach ($sql_ary as $ary) + { + if (!is_array($ary)) + { + return false; + } + + $result = $this->sql_query('INSERT INTO ' . $table . ' ' . $this->sql_build_array('INSERT', $ary)); + + if (!$result) + { + return false; + } + } + } + + return true; + } + + /** + * Function for validating values + * @access private + */ + function _sql_validate_value($var) + { + if (is_null($var)) + { + return 'NULL'; + } + else if (is_string($var)) + { + return "'" . $this->sql_escape($var) . "'"; + } + else + { + return (is_bool($var)) ? intval($var) : $var; + } + } + + /** + * Build sql statement from array for select and select distinct statements + * + * Possible query values: SELECT, SELECT_DISTINCT + */ + function sql_build_query($query, $array) + { + $sql = ''; + switch ($query) + { + case 'SELECT': + case 'SELECT_DISTINCT'; + + $sql = str_replace('_', ' ', $query) . ' ' . $array['SELECT'] . ' FROM '; + + // Build table array. We also build an alias array for later checks. + $table_array = $aliases = array(); + $used_multi_alias = false; + + foreach ($array['FROM'] as $table_name => $alias) + { + if (is_array($alias)) + { + $used_multi_alias = true; + + foreach ($alias as $multi_alias) + { + $table_array[] = $table_name . ' ' . $multi_alias; + $aliases[] = $multi_alias; + } + } + else + { + $table_array[] = $table_name . ' ' . $alias; + $aliases[] = $alias; + } + } + + // We run the following code to determine if we need to re-order the table array. ;) + // The reason for this is that for multi-aliased tables (two equal tables) in the FROM statement the last table need to match the first comparison. + // DBMS who rely on this: Oracle, PostgreSQL and MSSQL. For all other DBMS it makes absolutely no difference in which order the table is. + if (!empty($array['LEFT_JOIN']) && sizeof($array['FROM']) > 1 && $used_multi_alias !== false) + { + // Take first LEFT JOIN + $join = current($array['LEFT_JOIN']); + + // Determine the table used there (even if there are more than one used, we only want to have one + preg_match('/(' . implode('|', $aliases) . ')\.[^\s]+/U', str_replace(array('(', ')', 'AND', 'OR', ' '), '', $join['ON']), $matches); + + // If there is a first join match, we need to make sure the table order is correct + if (!empty($matches[1])) + { + $first_join_match = trim($matches[1]); + $table_array = $last = array(); + + foreach ($array['FROM'] as $table_name => $alias) + { + if (is_array($alias)) + { + foreach ($alias as $multi_alias) + { + ($multi_alias === $first_join_match) ? $last[] = $table_name . ' ' . $multi_alias : $table_array[] = $table_name . ' ' . $multi_alias; + } + } + else + { + ($alias === $first_join_match) ? $last[] = $table_name . ' ' . $alias : $table_array[] = $table_name . ' ' . $alias; + } + } + + $table_array = array_merge($table_array, $last); + } + } + + $sql .= $this->_sql_custom_build('FROM', implode(' CROSS JOIN ', $table_array)); + + if (!empty($array['LEFT_JOIN'])) + { + foreach ($array['LEFT_JOIN'] as $join) + { + $sql .= ' LEFT JOIN ' . key($join['FROM']) . ' ' . current($join['FROM']) . ' ON (' . $join['ON'] . ')'; + } + } + + if (!empty($array['WHERE'])) + { + $sql .= ' WHERE ' . $this->_sql_custom_build('WHERE', $array['WHERE']); + } + + if (!empty($array['GROUP_BY'])) + { + $sql .= ' GROUP BY ' . $array['GROUP_BY']; + } + + if (!empty($array['ORDER_BY'])) + { + $sql .= ' ORDER BY ' . $array['ORDER_BY']; + } + + break; + } + + return $sql; + } + + /** + * display sql error page + */ + function sql_error($sql = '') + { + global $auth, $user, $config; + + // Set var to retrieve errored status + $this->sql_error_triggered = true; + $this->sql_error_sql = $sql; + + $this->sql_error_returned = $this->_sql_error(); + + if (!$this->return_on_error) + { + $message = 'SQL ERROR [ ' . $this->sql_layer . ' ]

    ' . $this->sql_error_returned['message'] . ' [' . $this->sql_error_returned['code'] . ']'; + + // Show complete SQL error and path to administrators only + // Additionally show complete error on installation or if extended debug mode is enabled + // The DEBUG_EXTRA constant is for development only! + if ((isset($auth) && $auth->acl_get('a_')) || defined('IN_INSTALL') || defined('DEBUG_EXTRA')) + { + $message .= ($sql) ? '

    SQL

    ' . htmlspecialchars($sql) : ''; + } + else + { + // If error occurs in initiating the session we need to use a pre-defined language string + // This could happen if the connection could not be established for example (then we are not able to grab the default language) + if (!isset($user->lang['SQL_ERROR_OCCURRED'])) + { + $message .= '

    An sql error occurred while fetching this page. Please contact an administrator if this problem persists.'; + } + else + { + if (!empty($config['board_contact'])) + { + $message .= '

    ' . sprintf($user->lang['SQL_ERROR_OCCURRED'], '', ''); + } + else + { + $message .= '

    ' . sprintf($user->lang['SQL_ERROR_OCCURRED'], '', ''); + } + } + } + + if ($this->transaction) + { + $this->sql_transaction('rollback'); + } + + if (strlen($message) > 1024) + { + // We need to define $msg_long_text here to circumvent text stripping. + global $msg_long_text; + $msg_long_text = $message; + + trigger_error(false, E_USER_ERROR); + } + + trigger_error($message, E_USER_ERROR); + } + + if ($this->transaction) + { + $this->sql_transaction('rollback'); + } + + return $this->sql_error_returned; + } + + /** + * Explain queries + */ + function sql_report($mode, $query = '') + { + global $cache, $starttime, $phpbb_root_path, $user; + global $request; + + if (is_object($request) && !$request->variable('explain', false)) + { + return false; + } + + if (!$query && $this->query_hold != '') + { + $query = $this->query_hold; + } + + switch ($mode) + { + case 'display': + if (!empty($cache)) + { + $cache->unload(); + } + $this->sql_close(); + + $mtime = explode(' ', microtime()); + $totaltime = $mtime[0] + $mtime[1] - $starttime; + + echo ' + + + + SQL Report + + + +
    + +
    +
    +
    + +
    +

    SQL Report

    +
    +

    Page generated in ' . round($totaltime, 4) . " seconds with {$this->num_queries['normal']} queries" . (($this->num_queries['cached']) ? " + {$this->num_queries['cached']} " . (($this->num_queries['cached'] == 1) ? 'query' : 'queries') . ' returning data from cache' : '') . '

    + +

    Time spent on ' . $this->sql_layer . ' queries: ' . round($this->sql_time, 5) . 's | Time spent on PHP: ' . round($totaltime - $this->sql_time, 5) . 's

    + +

    + ' . $this->sql_report . ' +
    + +
    +
    +
    + +
    + + '; + + exit_handler(); + + break; + + case 'stop': + $endtime = explode(' ', microtime()); + $endtime = $endtime[0] + $endtime[1]; + + $this->sql_report .= ' + + + + + + + + + + + + +
    Query #' . $this->num_queries['total'] . '
    + + ' . $this->html_hold . ' + +

    + '; + + if ($this->query_result) + { + if (preg_match('/^(UPDATE|DELETE|REPLACE)/', $query)) + { + $this->sql_report .= 'Affected rows: ' . $this->sql_affectedrows($this->query_result) . ' | '; + } + $this->sql_report .= 'Before: ' . sprintf('%.5f', $this->curtime - $starttime) . 's | After: ' . sprintf('%.5f', $endtime - $starttime) . 's | Elapsed: ' . sprintf('%.5f', $endtime - $this->curtime) . 's'; + } + else + { + $error = $this->sql_error(); + $this->sql_report .= 'FAILED - ' . $this->sql_layer . ' Error ' . $error['code'] . ': ' . htmlspecialchars($error['message']); + } + + $this->sql_report .= '



    '; + + $this->sql_time += $endtime - $this->curtime; + break; + + case 'start': + $this->query_hold = $query; + $this->html_hold = ''; + + $this->_sql_report($mode, $query); + + $this->curtime = explode(' ', microtime()); + $this->curtime = $this->curtime[0] + $this->curtime[1]; + + break; + + case 'add_select_row': + + $html_table = func_get_arg(2); + $row = func_get_arg(3); + + if (!$html_table && sizeof($row)) + { + $html_table = true; + $this->html_hold .= ''; + + foreach (array_keys($row) as $val) + { + $this->html_hold .= ''; + } + $this->html_hold .= ''; + } + $this->html_hold .= ''; + + $class = 'row1'; + foreach (array_values($row) as $val) + { + $class = ($class == 'row1') ? 'row2' : 'row1'; + $this->html_hold .= ''; + } + $this->html_hold .= ''; + + return $html_table; + + break; + + case 'fromcache': + + $this->_sql_report($mode, $query); + + break; + + case 'record_fromcache': + + $endtime = func_get_arg(2); + $splittime = func_get_arg(3); + + $time_cache = $endtime - $this->curtime; + $time_db = $splittime - $endtime; + $color = ($time_db > $time_cache) ? 'green' : 'red'; + + $this->sql_report .= '
    ' . (($val) ? ucwords(str_replace('_', ' ', $val)) : ' ') . '
    ' . (($val) ? $val : ' ') . '
    '; + $this->sql_report .= '
    Query results obtained from the cache
    '; + $this->sql_report .= '

    '; + $this->sql_report .= 'Before: ' . sprintf('%.5f', $this->curtime - $starttime) . 's | After: ' . sprintf('%.5f', $endtime - $starttime) . 's | Elapsed [cache]: ' . sprintf('%.5f', ($time_cache)) . 's | Elapsed [db]: ' . sprintf('%.5f', $time_db) . 's



    '; + + // Pad the start time to not interfere with page timing + $starttime += $time_db; + + break; + + default: + + $this->_sql_report($mode, $query); + + break; + } + + return true; + } + + /** + * Gets the estimated number of rows in a specified table. + * + * @param string $table_name Table name + * + * @return string Number of rows in $table_name. + * Prefixed with ~ if estimated (otherwise exact). + * + * @access public + */ + function get_estimated_row_count($table_name) + { + return $this->get_row_count($table_name); + } + + /** + * Gets the exact number of rows in a specified table. + * + * @param string $table_name Table name + * + * @return string Exact number of rows in $table_name. + * + * @access public + */ + function get_row_count($table_name) + { + $sql = 'SELECT COUNT(*) AS rows_total + FROM ' . $this->sql_escape($table_name); + $result = $this->sql_query($sql); + $rows_total = $this->sql_fetchfield('rows_total'); + $this->sql_freeresult($result); + + return $rows_total; + } +} diff --git a/phpBB/includes/db/firebird.php b/phpBB/includes/db/driver/firebird.php similarity index 99% rename from phpBB/includes/db/firebird.php rename to phpBB/includes/db/driver/firebird.php index 7709e8fdf5..c793e0a51f 100644 --- a/phpBB/includes/db/firebird.php +++ b/phpBB/includes/db/driver/firebird.php @@ -15,14 +15,12 @@ if (!defined('IN_PHPBB')) exit; } -include_once($phpbb_root_path . 'includes/db/dbal.' . $phpEx); - /** * Firebird/Interbase Database Abstraction Layer * Minimum Requirement is Firebird 2.1 * @package dbal */ -class dbal_firebird extends dbal +class phpbb_db_driver_firebird extends phpbb_db_driver { var $last_query_text = ''; var $service_handle = false; diff --git a/phpBB/includes/db/mssql.php b/phpBB/includes/db/driver/mssql.php similarity index 99% rename from phpBB/includes/db/mssql.php rename to phpBB/includes/db/driver/mssql.php index fb044b492f..e68738f918 100644 --- a/phpBB/includes/db/mssql.php +++ b/phpBB/includes/db/driver/mssql.php @@ -15,14 +15,12 @@ if (!defined('IN_PHPBB')) exit; } -include_once($phpbb_root_path . 'includes/db/dbal.' . $phpEx); - /** * MSSQL Database Abstraction Layer * Minimum Requirement is MSSQL 2000+ * @package dbal */ -class dbal_mssql extends dbal +class phpbb_db_driver_mssql extends phpbb_db_driver { /** * Connect to server @@ -374,7 +372,7 @@ class dbal_mssql extends dbal FROM master.dbo.sysmessages WHERE error = ' . $error['code']; $result_id = @mssql_query($sql); - + if ($result_id) { $row = @mssql_fetch_assoc($result_id); diff --git a/phpBB/includes/db/mssql_odbc.php b/phpBB/includes/db/driver/mssql_odbc.php similarity index 98% rename from phpBB/includes/db/mssql_odbc.php rename to phpBB/includes/db/driver/mssql_odbc.php index 64fa9634d1..7b35ce3d11 100644 --- a/phpBB/includes/db/mssql_odbc.php +++ b/phpBB/includes/db/driver/mssql_odbc.php @@ -15,8 +15,6 @@ if (!defined('IN_PHPBB')) exit; } -include_once($phpbb_root_path . 'includes/db/dbal.' . $phpEx); - /** * Unified ODBC functions * Unified ODBC functions support any database having ODBC driver, for example Adabas D, IBM DB2, iODBC, Solid, Sybase SQL Anywhere... @@ -28,7 +26,7 @@ include_once($phpbb_root_path . 'includes/db/dbal.' . $phpEx); * * @package dbal */ -class dbal_mssql_odbc extends dbal +class phpbb_db_driver_mssql_odbc extends phpbb_db_driver { var $last_query_text = ''; diff --git a/phpBB/includes/db/mssqlnative.php b/phpBB/includes/db/driver/mssqlnative.php similarity index 99% rename from phpBB/includes/db/mssqlnative.php rename to phpBB/includes/db/driver/mssqlnative.php index 1f37d54ecb..99b9d7975a 100644 --- a/phpBB/includes/db/mssqlnative.php +++ b/phpBB/includes/db/driver/mssqlnative.php @@ -19,8 +19,6 @@ if (!defined('IN_PHPBB')) exit; } -include_once($phpbb_root_path . 'includes/db/dbal.' . $phpEx); - /** * Prior to version 1.1 the SQL Server Native PHP driver didn't support sqlsrv_num_rows, or cursor based seeking so we recall all rows into an array * and maintain our own cursor index into that array. @@ -193,7 +191,7 @@ class result_mssqlnative /** * @package dbal */ -class dbal_mssqlnative extends dbal +class phpbb_db_driver_mssqlnative extends phpbb_db_driver { var $m_insert_id = NULL; var $last_query_text = ''; diff --git a/phpBB/includes/db/mysql.php b/phpBB/includes/db/driver/mysql.php similarity index 99% rename from phpBB/includes/db/mysql.php rename to phpBB/includes/db/driver/mysql.php index 8d1f805870..987691341a 100644 --- a/phpBB/includes/db/mysql.php +++ b/phpBB/includes/db/driver/mysql.php @@ -15,8 +15,6 @@ if (!defined('IN_PHPBB')) exit; } -include_once($phpbb_root_path . 'includes/db/dbal.' . $phpEx); - /** * MySQL4 Database Abstraction Layer * Compatible with: @@ -26,7 +24,7 @@ include_once($phpbb_root_path . 'includes/db/dbal.' . $phpEx); * MySQL 5.0+ * @package dbal */ -class dbal_mysql extends dbal +class phpbb_db_driver_mysql extends phpbb_db_driver { var $multi_insert = true; diff --git a/phpBB/includes/db/mysqli.php b/phpBB/includes/db/driver/mysqli.php similarity index 99% rename from phpBB/includes/db/mysqli.php rename to phpBB/includes/db/driver/mysqli.php index e07cd35e24..c473c7fe99 100644 --- a/phpBB/includes/db/mysqli.php +++ b/phpBB/includes/db/driver/mysqli.php @@ -15,15 +15,13 @@ if (!defined('IN_PHPBB')) exit; } -include_once($phpbb_root_path . 'includes/db/dbal.' . $phpEx); - /** * MySQLi Database Abstraction Layer * mysqli-extension has to be compiled with: * MySQL 4.1+ or MySQL 5.0+ * @package dbal */ -class dbal_mysqli extends dbal +class phpbb_db_driver_mysqli extends phpbb_db_driver { var $multi_insert = true; diff --git a/phpBB/includes/db/oracle.php b/phpBB/includes/db/driver/oracle.php similarity index 99% rename from phpBB/includes/db/oracle.php rename to phpBB/includes/db/driver/oracle.php index 2e801532f0..25803e57bd 100644 --- a/phpBB/includes/db/oracle.php +++ b/phpBB/includes/db/driver/oracle.php @@ -15,13 +15,11 @@ if (!defined('IN_PHPBB')) exit; } -include_once($phpbb_root_path . 'includes/db/dbal.' . $phpEx); - /** * Oracle Database Abstraction Layer * @package dbal */ -class dbal_oracle extends dbal +class phpbb_db_driver_oracle extends phpbb_db_driver { var $last_query_text = ''; diff --git a/phpBB/includes/db/postgres.php b/phpBB/includes/db/driver/postgres.php similarity index 98% rename from phpBB/includes/db/postgres.php rename to phpBB/includes/db/driver/postgres.php index bf22cffafa..3f54936d23 100644 --- a/phpBB/includes/db/postgres.php +++ b/phpBB/includes/db/driver/postgres.php @@ -15,19 +15,12 @@ if (!defined('IN_PHPBB')) exit; } -include_once($phpbb_root_path . 'includes/db/dbal.' . $phpEx); - -if (!class_exists('phpbb_error_collector')) -{ - include($phpbb_root_path . 'includes/error_collector.' . $phpEx); -} - /** * PostgreSQL Database Abstraction Layer * Minimum Requirement is Version 7.3+ * @package dbal */ -class dbal_postgres extends dbal +class phpbb_db_driver_postgres extends phpbb_db_driver { var $last_query_text = ''; var $connect_error = ''; diff --git a/phpBB/includes/db/sqlite.php b/phpBB/includes/db/driver/sqlite.php similarity index 98% rename from phpBB/includes/db/sqlite.php rename to phpBB/includes/db/driver/sqlite.php index 86bfa75a13..363f26da2b 100644 --- a/phpBB/includes/db/sqlite.php +++ b/phpBB/includes/db/driver/sqlite.php @@ -15,14 +15,12 @@ if (!defined('IN_PHPBB')) exit; } -include_once($phpbb_root_path . 'includes/db/dbal.' . $phpEx); - /** * Sqlite Database Abstraction Layer * Minimum Requirement: 2.8.2+ * @package dbal */ -class dbal_sqlite extends dbal +class phpbb_db_driver_sqlite extends phpbb_db_driver { /** * Connect to server diff --git a/phpBB/includes/extension/manager.php b/phpBB/includes/extension/manager.php index 537c19aff8..c3d1f58893 100644 --- a/phpBB/includes/extension/manager.php +++ b/phpBB/includes/extension/manager.php @@ -39,7 +39,7 @@ class phpbb_extension_manager * @param phpbb_cache_driver_interface $cache A cache instance or null * @param string $cache_name The name of the cache variable, defaults to _ext */ - public function __construct(dbal $db, $extension_table, $phpbb_root_path, $phpEx = '.php', phpbb_cache_driver_interface $cache = null, $cache_name = '_ext') + public function __construct(phpbb_db_driver $db, $extension_table, $phpbb_root_path, $phpEx = '.php', phpbb_cache_driver_interface $cache = null, $cache_name = '_ext') { $this->phpbb_root_path = $phpbb_root_path; $this->db = $db; @@ -432,7 +432,7 @@ class phpbb_extension_manager } return $disabled; } - + /** * Check to see if a given extension is available on the filesystem * diff --git a/phpBB/includes/functions_install.php b/phpBB/includes/functions_install.php index 46541acd44..413d8481b0 100644 --- a/phpBB/includes/functions_install.php +++ b/phpBB/includes/functions_install.php @@ -49,7 +49,7 @@ function get_available_dbms($dbms = false, $return_unavailable = false, $only_20 'SCHEMA' => 'firebird', 'MODULE' => 'interbase', 'DELIM' => ';;', - 'DRIVER' => 'firebird', + 'DRIVER' => 'phpbb_db_driver_firebird', 'AVAILABLE' => true, '2.0.x' => false, ), @@ -58,7 +58,7 @@ function get_available_dbms($dbms = false, $return_unavailable = false, $only_20 'SCHEMA' => 'mysql_41', 'MODULE' => 'mysqli', 'DELIM' => ';', - 'DRIVER' => 'mysqli', + 'DRIVER' => 'phpbb_db_driver_mysqli', 'AVAILABLE' => true, '2.0.x' => true, ), @@ -67,7 +67,7 @@ function get_available_dbms($dbms = false, $return_unavailable = false, $only_20 'SCHEMA' => 'mysql', 'MODULE' => 'mysql', 'DELIM' => ';', - 'DRIVER' => 'mysql', + 'DRIVER' => 'phpbb_db_driver_mysql', 'AVAILABLE' => true, '2.0.x' => true, ), @@ -76,7 +76,7 @@ function get_available_dbms($dbms = false, $return_unavailable = false, $only_20 'SCHEMA' => 'mssql', 'MODULE' => 'mssql', 'DELIM' => 'GO', - 'DRIVER' => 'mssql', + 'DRIVER' => 'phpbb_db_driver_mssql', 'AVAILABLE' => true, '2.0.x' => true, ), @@ -85,7 +85,7 @@ function get_available_dbms($dbms = false, $return_unavailable = false, $only_20 'SCHEMA' => 'mssql', 'MODULE' => 'odbc', 'DELIM' => 'GO', - 'DRIVER' => 'mssql_odbc', + 'DRIVER' => 'phpbb_db_driver_mssql_odbc', 'AVAILABLE' => true, '2.0.x' => true, ), @@ -94,7 +94,7 @@ function get_available_dbms($dbms = false, $return_unavailable = false, $only_20 'SCHEMA' => 'mssql', 'MODULE' => 'sqlsrv', 'DELIM' => 'GO', - 'DRIVER' => 'mssqlnative', + 'DRIVER' => 'phpbb_db_driver_mssqlnative', 'AVAILABLE' => true, '2.0.x' => false, ), @@ -103,7 +103,7 @@ function get_available_dbms($dbms = false, $return_unavailable = false, $only_20 'SCHEMA' => 'oracle', 'MODULE' => 'oci8', 'DELIM' => '/', - 'DRIVER' => 'oracle', + 'DRIVER' => 'phpbb_db_driver_oracle', 'AVAILABLE' => true, '2.0.x' => false, ), @@ -112,7 +112,7 @@ function get_available_dbms($dbms = false, $return_unavailable = false, $only_20 'SCHEMA' => 'postgres', 'MODULE' => 'pgsql', 'DELIM' => ';', - 'DRIVER' => 'postgres', + 'DRIVER' => 'phpbb_db_driver_postgres', 'AVAILABLE' => true, '2.0.x' => true, ), @@ -121,7 +121,7 @@ function get_available_dbms($dbms = false, $return_unavailable = false, $only_20 'SCHEMA' => 'sqlite', 'MODULE' => 'sqlite', 'DELIM' => ';', - 'DRIVER' => 'sqlite', + 'DRIVER' => 'phpbb_db_driver_sqlite', 'AVAILABLE' => true, '2.0.x' => false, ), @@ -229,26 +229,19 @@ function connect_check_db($error_connect, &$error, $dbms_details, $table_prefix, $dbms = $dbms_details['DRIVER']; - if ($load_dbal) - { - // Include the DB layer - include($phpbb_root_path . 'includes/db/' . $dbms . '.' . $phpEx); - } - // Instantiate it and set return on error true - $sql_db = 'dbal_' . $dbms; - $db = new $sql_db(); + $db = new $dbms(); $db->sql_return_on_error(true); // Check that we actually have a database name before going any further..... - if ($dbms_details['DRIVER'] != 'sqlite' && $dbms_details['DRIVER'] != 'oracle' && $dbname === '') + if ($dbms_details['DRIVER'] != 'phpbb_db_driver_sqlite' && $dbms_details['DRIVER'] != 'phpbb_db_driver_oracle' && $dbname === '') { $error[] = $lang['INST_ERR_DB_NO_NAME']; return false; } // Make sure we don't have a daft user who thinks having the SQLite database in the forum directory is a good idea - if ($dbms_details['DRIVER'] == 'sqlite' && stripos(phpbb_realpath($dbhost), phpbb_realpath('../')) === 0) + if ($dbms_details['DRIVER'] == 'phpbb_db_driver_sqlite' && stripos(phpbb_realpath($dbhost), phpbb_realpath('../')) === 0) { $error[] = $lang['INST_ERR_DB_FORUM_PATH']; return false; @@ -257,8 +250,8 @@ function connect_check_db($error_connect, &$error, $dbms_details, $table_prefix, // Check the prefix length to ensure that index names are not too long and does not contain invalid characters switch ($dbms_details['DRIVER']) { - case 'mysql': - case 'mysqli': + case 'phpbb_db_driver_mysql': + case 'phpbb_db_driver_mysqli': if (strspn($table_prefix, '-./\\') !== 0) { $error[] = $lang['INST_ERR_PREFIX_INVALID']; @@ -267,22 +260,22 @@ function connect_check_db($error_connect, &$error, $dbms_details, $table_prefix, // no break; - case 'postgres': + case 'phpbb_db_driver_postgres': $prefix_length = 36; break; - case 'mssql': - case 'mssql_odbc': - case 'mssqlnative': + case 'phpbb_db_driver_mssql': + case 'phpbb_db_driver_mssql_odbc': + case 'phpbb_db_driver_mssqlnative': $prefix_length = 90; break; - case 'sqlite': + case 'phpbb_db_driver_sqlite': $prefix_length = 200; break; - case 'firebird': - case 'oracle': + case 'phpbb_db_driver_firebird': + case 'phpbb_db_driver_oracle': $prefix_length = 6; break; } @@ -320,21 +313,21 @@ function connect_check_db($error_connect, &$error, $dbms_details, $table_prefix, // Make sure that the user has selected a sensible DBAL for the DBMS actually installed switch ($dbms_details['DRIVER']) { - case 'mysqli': + case 'phpbb_db_driver_mysqli': if (version_compare(mysqli_get_server_info($db->db_connect_id), '4.1.3', '<')) { $error[] = $lang['INST_ERR_DB_NO_MYSQLI']; } break; - case 'sqlite': + case 'phpbb_db_driver_sqlite': if (version_compare(sqlite_libversion(), '2.8.2', '<')) { $error[] = $lang['INST_ERR_DB_NO_SQLITE']; } break; - case 'firebird': + case 'phpbb_db_driver_firebird': // check the version of FB, use some hackery if we can't get access to the server info if ($db->service_handle !== false && function_exists('ibase_server_info')) { @@ -415,7 +408,7 @@ function connect_check_db($error_connect, &$error, $dbms_details, $table_prefix, } break; - case 'oracle': + case 'phpbb_db_driver_oracle': if ($unicode_check) { $sql = "SELECT * @@ -437,7 +430,7 @@ function connect_check_db($error_connect, &$error, $dbms_details, $table_prefix, } break; - case 'postgres': + case 'phpbb_db_driver_postgres': if ($unicode_check) { $sql = "SHOW server_encoding;"; diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 6e99fd56a0..63a949762b 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -91,7 +91,6 @@ phpbb_require_updated('includes/functions_content.' . $phpEx, true); require($phpbb_root_path . 'includes/functions_admin.' . $phpEx); require($phpbb_root_path . 'includes/constants.' . $phpEx); -require($phpbb_root_path . 'includes/db/' . $dbms . '.' . $phpEx); require($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx); phpbb_require_updated('includes/db/db_tools.' . $phpEx); @@ -121,7 +120,7 @@ $phpbb_class_loader->set_cache($cache->get_driver()); $phpbb_dispatcher = new phpbb_event_dispatcher(); $request = new phpbb_request(); $user = new phpbb_user(); -$db = new $sql_db(); +$db = new $dbms(); // make sure request_var uses this request instance request_var('', 0, false, false, $request); // "dependency injection" for a function @@ -2601,10 +2600,10 @@ function change_database_data(&$no_updates, $version) // Create config value for displaying last subject on forum list if (!isset($config['display_last_subject'])) - { + { $config->set('display_last_subject', '1'); } - + $no_updates = false; if (!isset($config['assets_version'])) diff --git a/phpBB/install/install_convert.php b/phpBB/install/install_convert.php index db974f9903..8f648066ba 100644 --- a/phpBB/install/install_convert.php +++ b/phpBB/install/install_convert.php @@ -121,10 +121,9 @@ class install_convert extends module require($phpbb_root_path . 'config.' . $phpEx); require($phpbb_root_path . 'includes/constants.' . $phpEx); - require($phpbb_root_path . 'includes/db/' . $dbms . '.' . $phpEx); require($phpbb_root_path . 'includes/functions_convert.' . $phpEx); - $db = new $sql_db(); + $db = new $dbms(); $db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, true); unset($dbpasswd); @@ -209,10 +208,8 @@ class install_convert extends module require($phpbb_root_path . 'config.' . $phpEx); require($phpbb_root_path . 'includes/constants.' . $phpEx); - require($phpbb_root_path . 'includes/db/' . $dbms . '.' . $phpEx); - require($phpbb_root_path . 'includes/functions_convert.' . $phpEx); - $db = new $sql_db(); + $db = new $dbms(); $db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, true); unset($dbpasswd); @@ -332,10 +329,9 @@ class install_convert extends module require($phpbb_root_path . 'config.' . $phpEx); require($phpbb_root_path . 'includes/constants.' . $phpEx); - require($phpbb_root_path . 'includes/db/' . $dbms . '.' . $phpEx); require($phpbb_root_path . 'includes/functions_convert.' . $phpEx); - $db = new $sql_db(); + $db = new $dbms(); $db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, true); unset($dbpasswd); @@ -425,8 +421,7 @@ class install_convert extends module if ($src_dbms != $dbms || $src_dbhost != $dbhost || $src_dbport != $dbport || $src_dbname != $dbname || $src_dbuser != $dbuser) { - $sql_db = 'dbal_' . $src_dbms; - $src_db = new $sql_db(); + $src_db = new $src_dbms(); $src_db->sql_connect($src_dbhost, $src_dbuser, htmlspecialchars_decode($src_dbpasswd), $src_dbname, $src_dbport, false, true); $same_db = false; } @@ -575,10 +570,9 @@ class install_convert extends module require($phpbb_root_path . 'config.' . $phpEx); require($phpbb_root_path . 'includes/constants.' . $phpEx); - require($phpbb_root_path . 'includes/db/' . $dbms . '.' . $phpEx); require($phpbb_root_path . 'includes/functions_convert.' . $phpEx); - $db = new $sql_db(); + $db = new $dbms(); $db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, true); unset($dbpasswd); @@ -639,12 +633,8 @@ class install_convert extends module $src_db = $same_db = null; if ($convert->src_dbms != $dbms || $convert->src_dbhost != $dbhost || $convert->src_dbport != $dbport || $convert->src_dbname != $dbname || $convert->src_dbuser != $dbuser) { - if ($convert->src_dbms != $dbms) - { - require($phpbb_root_path . 'includes/db/' . $convert->src_dbms . '.' . $phpEx); - } - $sql_db = 'dbal_' . $convert->src_dbms; - $src_db = new $sql_db(); + $dbms = $convert->src_dbms; + $src_db = new $dbms(); $src_db->sql_connect($convert->src_dbhost, $convert->src_dbuser, htmlspecialchars_decode($convert->src_dbpasswd), $convert->src_dbname, $convert->src_dbport, false, true); $same_db = false; } diff --git a/phpBB/install/install_install.php b/phpBB/install/install_install.php index 40dee7b3d7..520163ef9d 100644 --- a/phpBB/install/install_install.php +++ b/phpBB/install/install_install.php @@ -250,7 +250,7 @@ class install_install extends module 'S_EXPLAIN' => true, 'S_LEGEND' => false, )); - + // Check for php json support if (@extension_loaded('json')) { @@ -1144,11 +1144,8 @@ class install_install extends module $dbms = $available_dbms[$data['dbms']]['DRIVER']; - // Load the appropriate database class if not already loaded - include($phpbb_root_path . 'includes/db/' . $dbms . '.' . $phpEx); - // Instantiate the database - $db = new $sql_db(); + $db = new $dbms(); $db->sql_connect($data['dbhost'], $data['dbuser'], htmlspecialchars_decode($data['dbpasswd']), $data['dbname'], $data['dbport'], false, false); // NOTE: trigger_error does not work here. @@ -1444,11 +1441,8 @@ class install_install extends module $dbms = $available_dbms[$data['dbms']]['DRIVER']; - // Load the appropriate database class if not already loaded - include($phpbb_root_path . 'includes/db/' . $dbms . '.' . $phpEx); - // Instantiate the database - $db = new $sql_db(); + $db = new $dbms(); $db->sql_connect($data['dbhost'], $data['dbuser'], htmlspecialchars_decode($data['dbpasswd']), $data['dbname'], $data['dbport'], false, false); // NOTE: trigger_error does not work here. diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php index c2feaa086a..fb76420033 100644 --- a/phpBB/install/install_update.php +++ b/phpBB/install/install_update.php @@ -83,7 +83,6 @@ class install_update extends module // Init DB require($phpbb_root_path . 'config.' . $phpEx); - require($phpbb_root_path . 'includes/db/' . $dbms . '.' . $phpEx); require($phpbb_root_path . 'includes/constants.' . $phpEx); // Special options for conflicts/modified files @@ -92,7 +91,7 @@ class install_update extends module define('MERGE_NEW_FILE', 3); define('MERGE_MOD_FILE', 4); - $db = new $sql_db(); + $db = new $dbms(); // Connect to DB $db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, false); diff --git a/tests/RUNNING_TESTS.txt b/tests/RUNNING_TESTS.txt index 7c2a7c3fce..0342179a6e 100644 --- a/tests/RUNNING_TESTS.txt +++ b/tests/RUNNING_TESTS.txt @@ -30,7 +30,7 @@ example for mysqli can be found below. More information on configuration options can be found on the wiki (see below). get_database_config(); // Firebird requires table and column names to be uppercase - if ($db_config['dbms'] == 'firebird') + if ($db_config['dbms'] == 'phpbb_db_driver_firebird') { $xml_data = file_get_contents($path); $xml_data = preg_replace_callback('/(?:())/', 'phpbb_database_test_case::to_upper', $xml_data); @@ -100,9 +100,8 @@ abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_Test $config = $this->get_database_config(); - require_once dirname(__FILE__) . '/../../phpBB/includes/db/' . $config['dbms'] . '.php'; - $dbal = 'dbal_' . $config['dbms']; - $db = new $dbal(); + $dbms = $config['dbms']; + $db = new $dbms(); $db->sql_connect($config['dbhost'], $config['dbuser'], $config['dbpasswd'], $config['dbname'], $config['dbport']); return $db; diff --git a/tests/test_framework/phpbb_database_test_connection_manager.php b/tests/test_framework/phpbb_database_test_connection_manager.php index 25e0972f42..db772496a0 100644 --- a/tests/test_framework/phpbb_database_test_connection_manager.php +++ b/tests/test_framework/phpbb_database_test_connection_manager.php @@ -108,7 +108,7 @@ class phpbb_database_test_connection_manager // These require different connection strings on the phpBB side than they do in PDO // so you must provide a DSN string for ODBC separately - if (!empty($this->config['custom_dsn']) && ($this->config['dbms'] == 'mssql' || $this->config['dbms'] == 'firebird')) + if (!empty($this->config['custom_dsn']) && ($this->config['dbms'] == 'phpbb_db_driver_mssql' || $this->config['dbms'] == 'phpbb_db_driver_firebird')) { $dsn = 'odbc:' . $this->config['custom_dsn']; } @@ -117,12 +117,12 @@ class phpbb_database_test_connection_manager { switch ($this->config['dbms']) { - case 'mssql': - case 'mssql_odbc': + case 'phpbb_db_driver_mssql': + case 'phpbb_db_driver_mssql_odbc': $this->pdo = new phpbb_database_connection_odbc_pdo_wrapper('mssql', 0, $dsn, $this->config['dbuser'], $this->config['dbpasswd']); break; - case 'firebird': + case 'phpbb_db_driver_firebird': if (!empty($this->config['custom_dsn'])) { $this->pdo = new phpbb_database_connection_odbc_pdo_wrapper('firebird', 0, $dsn, $this->config['dbuser'], $this->config['dbpasswd']); @@ -165,14 +165,14 @@ class phpbb_database_test_connection_manager { switch ($this->config['dbms']) { - case 'sqlite': + case 'phpbb_db_driver_sqlite': if (file_exists($this->config['dbhost'])) { unlink($this->config['dbhost']); } break; - case 'firebird': + case 'phpbb_db_driver_firebird': $this->connect(); // Drop all of the tables foreach ($this->get_tables() as $table) @@ -182,7 +182,7 @@ class phpbb_database_test_connection_manager $this->purge_extras(); break; - case 'oracle': + case 'phpbb_db_driver_oracle': $this->connect(); // Drop all of the tables foreach ($this->get_tables() as $table) @@ -232,39 +232,39 @@ class phpbb_database_test_connection_manager switch ($this->config['dbms']) { - case 'mysql': - case 'mysql4': - case 'mysqli': + case 'phpbb_db_driver_mysql': + case 'phpbb_db_driver_mysql4': + case 'phpbb_db_driver_mysqli': $sql = 'SHOW TABLES'; break; - case 'sqlite': + case 'phpbb_db_driver_sqlite': $sql = 'SELECT name FROM sqlite_master WHERE type = "table"'; break; - case 'mssql': - case 'mssql_odbc': - case 'mssqlnative': + case 'phpbb_db_driver_mssql': + case 'phpbb_db_driver_mssql_odbc': + case 'phpbb_db_driver_mssqlnative': $sql = "SELECT name FROM sysobjects WHERE type='U'"; break; - case 'postgres': + case 'phpbb_db_driver_postgres': $sql = 'SELECT relname FROM pg_stat_user_tables'; break; - case 'firebird': + case 'phpbb_db_driver_firebird': $sql = 'SELECT rdb$relation_name FROM rdb$relations WHERE rdb$view_source is null AND rdb$system_flag = 0'; break; - case 'oracle': + case 'phpbb_db_driver_oracle': $sql = 'SELECT table_name FROM USER_TABLES'; break; @@ -299,8 +299,8 @@ class phpbb_database_test_connection_manager protected function load_schema_from_file($directory) { $schema = $this->dbms['SCHEMA']; - - if ($this->config['dbms'] == 'mysql') + + if ($this->config['dbms'] == 'phpbb_db_driver_mysql') { $sth = $this->pdo->query('SELECT VERSION() AS version'); $row = $sth->fetch(PDO::FETCH_ASSOC); @@ -319,7 +319,7 @@ class phpbb_database_test_connection_manager $queries = file_get_contents($filename); $sql = phpbb_remove_comments($queries); - + $sql = split_sql_file($sql, $this->dbms['DELIM']); foreach ($sql as $query) @@ -403,7 +403,7 @@ class phpbb_database_test_connection_manager switch ($this->config['dbms']) { - case 'firebird': + case 'phpbb_db_driver_firebird': $sql = 'SELECT RDB$GENERATOR_NAME FROM RDB$GENERATORS WHERE RDB$SYSTEM_FLAG = 0'; @@ -415,7 +415,7 @@ class phpbb_database_test_connection_manager } break; - case 'oracle': + case 'phpbb_db_driver_oracle': $sql = 'SELECT sequence_name FROM USER_SEQUENCES'; $result = $this->pdo->query($sql); diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index c042d75811..ce0042d538 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -87,12 +87,8 @@ class phpbb_functional_test_case extends phpbb_test_case // so we don't reopen an open connection if (!($this->db instanceof dbal)) { - if (!class_exists('dbal_' . self::$config['dbms'])) - { - include($phpbb_root_path . 'includes/db/' . self::$config['dbms'] . ".$phpEx"); - } - $sql_db = 'dbal_' . self::$config['dbms']; - $this->db = new $sql_db(); + $dbms = self::$config['dbms']; + $this->db = new $dbms(); $this->db->sql_connect(self::$config['dbhost'], self::$config['dbuser'], self::$config['dbpasswd'], self::$config['dbname'], self::$config['dbport']); } return $this->db; diff --git a/tests/test_framework/phpbb_test_case_helpers.php b/tests/test_framework/phpbb_test_case_helpers.php index 46feef550a..5667aa6ca2 100644 --- a/tests/test_framework/phpbb_test_case_helpers.php +++ b/tests/test_framework/phpbb_test_case_helpers.php @@ -54,7 +54,7 @@ class phpbb_test_case_helpers if (extension_loaded('sqlite') && version_compare(PHPUnit_Runner_Version::id(), '3.4.15', '>=')) { $config = array_merge($config, array( - 'dbms' => 'sqlite', + 'dbms' => 'phpbb_db_driver_sqlite', 'dbhost' => dirname(__FILE__) . '/../phpbb_unit_tests.sqlite2', // filename 'dbport' => '', 'dbname' => '', From 65bafb22810038fd51e22fd8168775afd86c2e74 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 21 Jul 2012 18:08:40 +0200 Subject: [PATCH 0044/2494] [ticket/11015] Add BC files for the drivers PHPBB3-11015 --- phpBB/includes/db/firebird.php | 19 +++++++++++++++++++ phpBB/includes/db/mssql.php | 19 +++++++++++++++++++ phpBB/includes/db/mssql_odbc.php | 19 +++++++++++++++++++ phpBB/includes/db/mssqlnative.php | 19 +++++++++++++++++++ phpBB/includes/db/mysql.php | 19 +++++++++++++++++++ phpBB/includes/db/mysqli.php | 19 +++++++++++++++++++ phpBB/includes/db/oracle.php | 19 +++++++++++++++++++ phpBB/includes/db/postgres.php | 19 +++++++++++++++++++ phpBB/includes/db/sqlite.php | 19 +++++++++++++++++++ 9 files changed, 171 insertions(+) create mode 100644 phpBB/includes/db/firebird.php create mode 100644 phpBB/includes/db/mssql.php create mode 100644 phpBB/includes/db/mssql_odbc.php create mode 100644 phpBB/includes/db/mssqlnative.php create mode 100644 phpBB/includes/db/mysql.php create mode 100644 phpBB/includes/db/mysqli.php create mode 100644 phpBB/includes/db/oracle.php create mode 100644 phpBB/includes/db/postgres.php create mode 100644 phpBB/includes/db/sqlite.php diff --git a/phpBB/includes/db/firebird.php b/phpBB/includes/db/firebird.php new file mode 100644 index 0000000000..33f4e2ea48 --- /dev/null +++ b/phpBB/includes/db/firebird.php @@ -0,0 +1,19 @@ + Date: Sat, 21 Jul 2012 18:24:24 +0200 Subject: [PATCH 0045/2494] [ticket/11015] Correctly set sql_layer in driver base class PHPBB3-11015 --- phpBB/includes/db/driver/driver.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/db/driver/driver.php b/phpBB/includes/db/driver/driver.php index 39211a5af4..9692ee71b9 100644 --- a/phpBB/includes/db/driver/driver.php +++ b/phpBB/includes/db/driver/driver.php @@ -82,7 +82,7 @@ class phpbb_db_driver // Fill default sql layer based on the class being called. // This can be changed by the specified layer itself later if needed. - $this->sql_layer = substr(get_class($this), 5); + $this->sql_layer = substr(get_class($this), strlen('phpbb_db_driver_')); // Do not change this please! This variable is used to easy the use of it - and is hardcoded. $this->any_char = chr(0) . '%'; From d6cca4e2c0719da35c75d3fff68f4a46255fe352 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 21 Jul 2012 19:35:39 +0200 Subject: [PATCH 0046/2494] [ticket/11015] Fix connection manager db driver selection PHPBB3-11015 --- .../phpbb_database_test_connection_manager.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/test_framework/phpbb_database_test_connection_manager.php b/tests/test_framework/phpbb_database_test_connection_manager.php index db772496a0..82da5fe4c3 100644 --- a/tests/test_framework/phpbb_database_test_connection_manager.php +++ b/tests/test_framework/phpbb_database_test_connection_manager.php @@ -334,47 +334,47 @@ class phpbb_database_test_connection_manager protected function get_dbms_data($dbms) { $available_dbms = array( - 'firebird' => array( + 'phpbb_db_driver_firebird' => array( 'SCHEMA' => 'firebird', 'DELIM' => ';;', 'PDO' => 'firebird', ), - 'mysqli' => array( + 'phpbb_db_driver_mysqli' => array( 'SCHEMA' => 'mysql_41', 'DELIM' => ';', 'PDO' => 'mysql', ), - 'mysql' => array( + 'phpbb_db_driver_mysql' => array( 'SCHEMA' => 'mysql', 'DELIM' => ';', 'PDO' => 'mysql', ), - 'mssql' => array( + 'phpbb_db_driver_mssql' => array( 'SCHEMA' => 'mssql', 'DELIM' => 'GO', 'PDO' => 'odbc', ), - 'mssql_odbc'=> array( + 'phpbb_db_driver_mssql_odbc'=> array( 'SCHEMA' => 'mssql', 'DELIM' => 'GO', 'PDO' => 'odbc', ), - 'mssqlnative' => array( + 'phpbb_db_driver_mssqlnative' => array( 'SCHEMA' => 'mssql', 'DELIM' => 'GO', 'PDO' => 'sqlsrv', ), - 'oracle' => array( + 'phpbb_db_driver_oracle' => array( 'SCHEMA' => 'oracle', 'DELIM' => '/', 'PDO' => 'oci', ), - 'postgres' => array( + 'phpbb_db_driver_postgres' => array( 'SCHEMA' => 'postgres', 'DELIM' => ';', 'PDO' => 'pgsql', ), - 'sqlite' => array( + 'phpbb_db_driver_sqlite' => array( 'SCHEMA' => 'sqlite', 'DELIM' => ';', 'PDO' => 'sqlite2', From c34ca32795f29c944c840f8282c025e4b322c891 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 21 Jul 2012 19:35:45 +0200 Subject: [PATCH 0047/2494] [ticket/11015] Fix db connection type hint in lock_db PHPBB3-11015 --- phpBB/includes/lock/db.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/lock/db.php b/phpBB/includes/lock/db.php index fa559d6887..40690144b1 100644 --- a/phpBB/includes/lock/db.php +++ b/phpBB/includes/lock/db.php @@ -61,7 +61,7 @@ class phpbb_lock_db * @param array $config The phpBB configuration * @param dbal $db A database connection */ - public function __construct($config_name, phpbb_config $config, dbal $db) + public function __construct($config_name, phpbb_config $config, phpbb_db_driver $db) { $this->config_name = $config_name; $this->config = $config; From 0971d3f975ebaa8c2874115bd82b308b244783f2 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 21 Jul 2012 19:57:00 +0200 Subject: [PATCH 0048/2494] [ticket/11015] Fix configuration for travis PHPBB3-11015 --- travis/phpunit-mysql-travis.xml | 2 +- travis/phpunit-postgres-travis.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/travis/phpunit-mysql-travis.xml b/travis/phpunit-mysql-travis.xml index e54b2bb77b..6eeffeff15 100644 --- a/travis/phpunit-mysql-travis.xml +++ b/travis/phpunit-mysql-travis.xml @@ -27,7 +27,7 @@ - + diff --git a/travis/phpunit-postgres-travis.xml b/travis/phpunit-postgres-travis.xml index 55ba996548..3a09c4a826 100644 --- a/travis/phpunit-postgres-travis.xml +++ b/travis/phpunit-postgres-travis.xml @@ -29,7 +29,7 @@ - + From cf651ef81d611865a06d93c9db7c4dfcd680405c Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 17 Mar 2012 23:50:28 +0100 Subject: [PATCH 0049/2494] [ticket/10714] Implement a class to add logs to the database. PHPBB3-10714 --- phpBB/includes/log/interface.php | 55 ++++++++++ phpBB/includes/log/log.php | 177 +++++++++++++++++++++++++++++++ 2 files changed, 232 insertions(+) create mode 100644 phpBB/includes/log/interface.php create mode 100644 phpBB/includes/log/log.php diff --git a/phpBB/includes/log/interface.php b/phpBB/includes/log/interface.php new file mode 100644 index 0000000000..897b8a8211 --- /dev/null +++ b/phpBB/includes/log/interface.php @@ -0,0 +1,55 @@ +log_table = $log_table; + $this->enable(); + } + + /** + * This function returns the state of the log-system. + * + * @return bool True if log is enabled + */ + public function is_enabled() + { + return $this->enabled; + } + + /** + * This function allows disable the log-system. When add_log is called, the log will not be added to the database. + */ + public function disable() + { + $this->enabled = false; + } + + /** + * This function allows re-enable the log-system. + */ + public function enable() + { + $this->enabled = true; + } + + /** + * Adds a log to the database + * + * @param string $mode The mode defines which log_type is used and in which log the entry is displayed. + * @param int $user_id User ID of the user + * @param string $log_ip IP address of the user + * @param string $log_operation Name of the operation + * @param int $log_time Timestamp when the log was added. + * @param array $additional_data More arguments can be added, depending on the log_type + * + * @return int|bool Returns the log_id, if the entry was added to the database, false otherwise. + */ + public function add($mode, $user_id, $log_ip, $log_operation, $log_time = false, $additional_data = array()) + { + if (!$this->is_enabled()) + { + return false; + } + + global $db; + /** + * @todo: enable when events are merged + * + global $db, $phpbb_dispatcher; + */ + + if ($log_time == false) + { + $log_time = time(); + } + + $sql_ary = array( + 'user_id' => $user_id, + 'log_ip' => $log_ip, + 'log_time' => $log_time, + 'log_operation' => $log_operation, + ); + + switch ($mode) + { + case 'admin': + $sql_ary += array( + 'log_type' => LOG_ADMIN, + 'log_data' => (!sizeof($additional_data)) ? '' : serialize($additional_data), + ); + break; + + case 'mod': + $sql_ary += array( + 'log_type' => LOG_MOD, + 'forum_id' => intval(array_shift($additional_data)), + 'topic_id' => intval(array_shift($additional_data)), + 'log_data' => (!sizeof($additional_data)) ? '' : serialize($additional_data), + ); + break; + + case 'user': + $sql_ary += array( + 'log_type' => LOG_USERS, + 'reportee_id' => intval(array_shift($additional_data)), + 'log_data' => (!sizeof($additional_data)) ? '' : serialize($additional_data), + ); + break; + + case 'critical': + $sql_ary += array( + 'log_type' => LOG_CRITICAL, + 'log_data' => (!sizeof($additional_data)) ? '' : serialize($additional_data), + ); + break; + + default: + /** + * @todo: enable when events are merged + * + if ($phpbb_dispatcher != null) + { + $vars = array('mode', 'user_id', 'log_ip', 'log_time', 'additional_data', 'sql_ary'); + $event = new phpbb_event_data(compact($vars)); + $phpbb_dispatcher->dispatch('core.add_log_case', $event); + extract($event->get_data_filtered($vars)); + } + */ + + // We didn't find a log_type, so we don't save it in the database. + if (!isset($sql_ary['log_type'])) + { + return false; + } + } + + /** + * @todo: enable when events are merged + * + if ($phpbb_dispatcher != null) + { + $vars = array('mode', 'user_id', 'log_ip', 'log_time', 'additional_data', 'sql_ary'); + $event = new phpbb_event_data(compact($vars)); + $phpbb_dispatcher->dispatch('core.add_log', $event); + extract($event->get_data_filtered($vars)); + } + */ + + $db->sql_query('INSERT INTO ' . $this->log_table . ' ' . $db->sql_build_array('INSERT', $sql_ary)); + + return $db->sql_nextid(); + } +} From 3fbac076ceb4773aa3c985d24eeaf306aa0b6a42 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 17 Mar 2012 23:52:01 +0100 Subject: [PATCH 0050/2494] [ticket/10714] Use new phpbb_log class in add_log function PHPBB3-10714 --- phpBB/includes/functions.php | 93 ++++++++++++++++++++---------------- 1 file changed, 51 insertions(+), 42 deletions(-) diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index ecec1e5e4a..9a1485f37a 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -3357,65 +3357,74 @@ function parse_cfg_file($filename, $lines = false) */ function add_log() { - global $db, $user; + // This is all just an ugly hack to add "Dependency Injection" to a function + // the only real code is the function call which maps this function to a method. + static $static_log = null; - // In phpBB 3.1.x i want to have logging in a class to be able to control it - // For now, we need a quite hakish approach to circumvent logging for some actions - // @todo implement cleanly - if (!empty($GLOBALS['skip_add_log'])) + $args = func_get_args(); + $log = (isset($args[0])) ? $args[0] : false; + + if ($log instanceof phpbb_log_interface) + { + $static_log = $log; + return true; + } + else if ($log === false) { return false; } - $args = func_get_args(); + $tmp_log = $static_log; - $mode = array_shift($args); - $reportee_id = ($mode == 'user') ? intval(array_shift($args)) : ''; - $forum_id = ($mode == 'mod') ? intval(array_shift($args)) : ''; - $topic_id = ($mode == 'mod') ? intval(array_shift($args)) : ''; - $action = array_shift($args); - $data = (!sizeof($args)) ? '' : serialize($args); + // no log class set, create a temporary one ourselves to keep backwards compatability + if ($tmp_log === null) + { + $tmp_log = new phpbb_log(LOG_TABLE); + } - $sql_ary = array( - 'user_id' => (empty($user->data)) ? ANONYMOUS : $user->data['user_id'], - 'log_ip' => $user->ip, - 'log_time' => time(), - 'log_operation' => $action, - 'log_data' => $data, - ); + $mode = array_shift($args); + // This looks kind of dirty, but add_log has some additional data before the log_operation + $additional_data = array(); switch ($mode) { case 'admin': - $sql_ary['log_type'] = LOG_ADMIN; - break; - - case 'mod': - $sql_ary += array( - 'log_type' => LOG_MOD, - 'forum_id' => $forum_id, - 'topic_id' => $topic_id - ); - break; - - case 'user': - $sql_ary += array( - 'log_type' => LOG_USERS, - 'reportee_id' => $reportee_id - ); - break; - case 'critical': - $sql_ary['log_type'] = LOG_CRITICAL; break; - + case 'mod': + // forum_id + $additional_data[] = array_shift($args); + // topic_id + $additional_data[] = array_shift($args); + break; + case 'user': + // reportee_id + $additional_data[] = array_shift($args); + break; default: - return false; + /** + * @todo: enable when events are merged + * + global $phpbb_dispatcher; + + if ($phpbb_dispatcher != null) + { + $vars = array('mode', 'args', 'additional_data'); + $event = new phpbb_event_data(compact($vars)); + $phpbb_dispatcher->dispatch('core.function_add_log', $event); + extract($event->get_data_filtered($vars)); + } + */ } + $log_operation = array_shift($args); + $additional_data = array_merge($additional_data, $args); - $db->sql_query('INSERT INTO ' . LOG_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary)); + global $user; - return $db->sql_nextid(); + $user_id = (empty($user->data)) ? ANONYMOUS : $user->data['user_id']; + $user_ip = (empty($user->ip)) ? '' : $user->ip; + + return $tmp_log->add($mode, $user_id, $user_ip, $log_operation, time(), $additional_data); } /** From 34ce2561a0242c9066702e5fa9c92d0a6c77c2d2 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 17 Mar 2012 23:52:47 +0100 Subject: [PATCH 0051/2494] [ticket/10714] Remove the dirty global hack to disable the log. PHPBB3-10714 --- phpBB/includes/functions_user.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index 9e33a5122e..4074eaa2f2 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -299,8 +299,10 @@ function user_add($user_row, $cp_data = false) if ($add_group_id) { - // Because these actions only fill the log unneccessarily we skip the add_log() entry with a little hack. :/ - $GLOBALS['skip_add_log'] = true; + global $phpbb_log; + + // Because these actions only fill the log unneccessarily we skip the add_log() entry. + $phpbb_log->disable(); // Add user to "newly registered users" group and set to default group if admin specified so. if ($config['new_member_group_default']) @@ -313,7 +315,7 @@ function user_add($user_row, $cp_data = false) group_user_add($add_group_id, $user_id); } - unset($GLOBALS['skip_add_log']); + $phpbb_log->enable(); } } From 87eec7cfb66f6072344680743b04bf0186e8ca17 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sun, 18 Mar 2012 00:07:09 +0100 Subject: [PATCH 0052/2494] [ticket/10714] Create a phpbb_log object and inject it into add_log PHPBB3-10714 --- phpBB/common.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/phpBB/common.php b/phpBB/common.php index c7c5859c25..bbcf8b894f 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -139,6 +139,10 @@ foreach ($cache->obtain_hooks() as $hook) @include($phpbb_root_path . 'includes/hooks/' . $hook . '.' . $phpEx); } +// make sure add_log uses this log instance +$phpbb_log = new phpbb_log(LOG_TABLE); +add_log($phpbb_log); // "dependency injection" for a function + if (!$config['use_system_cron']) { $cron = new phpbb_cron_manager(new phpbb_cron_task_provider($phpbb_extension_manager), $cache->get_driver()); From 7e80e4004e92ddcf3ad147d05d43bb411010e9e0 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sun, 18 Mar 2012 12:07:41 +0100 Subject: [PATCH 0053/2494] [ticket/10714] Add unit tests for add_log function PHPBB3-10714 --- tests/log/fixtures/empty_log.xml | 15 +++ tests/log/function_add_log_test.php | 151 ++++++++++++++++++++++++++++ 2 files changed, 166 insertions(+) create mode 100644 tests/log/fixtures/empty_log.xml create mode 100644 tests/log/function_add_log_test.php diff --git a/tests/log/fixtures/empty_log.xml b/tests/log/fixtures/empty_log.xml new file mode 100644 index 0000000000..261b6a622a --- /dev/null +++ b/tests/log/fixtures/empty_log.xml @@ -0,0 +1,15 @@ + + +
    + log_id + log_type + user_id + forum_id + topic_id + reportee_id + log_ip + log_time + log_operation + log_data +
    + diff --git a/tests/log/function_add_log_test.php b/tests/log/function_add_log_test.php new file mode 100644 index 0000000000..05fae0f916 --- /dev/null +++ b/tests/log/function_add_log_test.php @@ -0,0 +1,151 @@ +createXMLDataSet(dirname(__FILE__) . '/fixtures/empty_log.xml'); + } + + public static function test_add_log_function_critical_data() + { + return array( + array( + array( + array( + 'user_id' => 2, + 'log_type' => LOG_CRITICAL, + 'log_operation' => 'LOG_NO_ADDITIONAL', + 'log_data' => '', + 'reportee_id' => 0, + 'forum_id' => 0, + 'topic_id' => 0, + ), + ), + 2, 'critical', 'LOG_NO_ADDITIONAL', + ), + array( + array( + array( + 'user_id' => 2, + 'log_type' => LOG_CRITICAL, + 'log_operation' => 'LOG_ONE_ADDITIONAL', + 'log_data' => 'a:1:{i:0;s:9:"argument1";}', + 'reportee_id' => 0, + 'forum_id' => 0, + 'topic_id' => 0, + ), + ), + 2, 'critical', 'LOG_ONE_ADDITIONAL', 'argument1', + ), + array( + array( + array( + 'user_id' => ANONYMOUS, + 'log_type' => LOG_ADMIN, + 'log_operation' => 'LOG_TWO_ADDITIONAL', + 'log_data' => 'a:2:{i:0;s:9:"argument1";i:1;s:9:"argument2";}', + 'reportee_id' => 0, + 'forum_id' => 0, + 'topic_id' => 0, + ), + ), + false, 'admin', 'LOG_TWO_ADDITIONAL', 'argument1', 'argument2', + ), + array( + array( + array( + 'user_id' => ANONYMOUS, + 'log_type' => LOG_USERS, + 'log_operation' => 'LOG_USERS_ADDITIONAL', + 'log_data' => 'a:1:{i:0;s:9:"argument2";}', + 'reportee_id' => 2, + 'forum_id' => 0, + 'topic_id' => 0, + ), + ), + false, 'user', 2, 'LOG_USERS_ADDITIONAL', 'argument2', + ), + array( + array( + array( + 'user_id' => ANONYMOUS, + 'log_type' => LOG_MOD, + 'log_operation' => 'LOG_MOD_TOPIC_AND_FORUM', + 'log_data' => '', + 'reportee_id' => 0, + 'forum_id' => 12, + 'topic_id' => 34, + ), + ), + false, 'mod', 12, 34, 'LOG_MOD_TOPIC_AND_FORUM', + ), + array( + array( + array( + 'user_id' => ANONYMOUS, + 'log_type' => LOG_MOD, + 'log_operation' => 'LOG_MOD_ADDITIONAL', + 'log_data' => 'a:1:{i:0;s:9:"argument3";}', + 'reportee_id' => 0, + 'forum_id' => 56, + 'topic_id' => 78, + ), + ), + false, 'mod', 56, 78, 'LOG_MOD_ADDITIONAL', 'argument3', + ), + array( + array( + ), + false, 'mode_does_not_exist', 'LOG_MOD_ADDITIONAL', 'argument1', + ), + ); + } + + /** + * @dataProvider test_add_log_function_critical_data + */ + public function test_add_log_function_critical($expected, $user_id, $mode, $required1, $additional1 = null, $additional2 = null, $additional3 = null) + { + global $db, $user; + + $db = $this->new_dbal(); + + $user->ip = 'user_ip'; + if ($user_id) + { + $user->data['user_id'] = $user_id; + } + + if ($additional3 != null) + { + add_log($mode, $required1, $additional1, $additional2, $additional3); + } + else if ($additional2 != null) + { + add_log($mode, $required1, $additional1, $additional2); + } + else if ($additional1 != null) + { + add_log($mode, $required1, $additional1); + } + else + { + add_log($mode, $required1); + } + + $result = $db->sql_query('SELECT user_id, log_type, log_operation, log_data, reportee_id, forum_id, topic_id + FROM ' . LOG_TABLE); + + $this->assertEquals($expected, $db->sql_fetchrowset($result)); + } +} From 72d875ebdee08f8c6af7c016b15d3e89442ed0e1 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sun, 18 Mar 2012 12:23:32 +0100 Subject: [PATCH 0054/2494] [ticket/10714] Add unit tests for log class PHPBB3-10714 --- tests/log/add_test.php | 56 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 tests/log/add_test.php diff --git a/tests/log/add_test.php b/tests/log/add_test.php new file mode 100644 index 0000000000..a2b763f2b7 --- /dev/null +++ b/tests/log/add_test.php @@ -0,0 +1,56 @@ +createXMLDataSet(dirname(__FILE__) . '/fixtures/empty_log.xml'); + } + + public function test_log_enabled() + { + $log = new phpbb_log(LOG_TABLE); + $this->assertTrue($log->is_enabled()); + + $log->disable(); + $this->assertFalse($log->is_enabled()); + + $log->enable(); + $this->assertTrue($log->is_enabled()); + } + + public function test_log_add() + { + global $db; + + $db = $this->new_dbal(); + + $mode = 'critical'; + $user_id = ANONYMOUS; + $log_ip = 'user_ip'; + $log_time = time(); + $log_operation = 'LOG_OPERATION'; + $additional_data = array(); + + // Add an entry successful + $log = new phpbb_log(LOG_TABLE); + $this->assertEquals(1, $log->add($mode, $user_id, $log_ip, $log_operation, $log_time)); + + // Disable logging + $log->disable(); + $this->assertFalse($log->add($mode, $user_id, $log_ip, $log_operation, $log_time)); + $log->enable(); + + // Invalid mode specified + $this->assertFalse($log->add('mode_does_not_exist', $user_id, $log_ip, $log_operation, $log_time)); + } +} From 31e18f31a6139cddb32520aa6ed020dc8f80f70a Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sun, 18 Mar 2012 13:40:56 +0100 Subject: [PATCH 0055/2494] [ticket/10714] Serialize the log_data in the testinsteadof hardcoding it PHPBB3-10714 --- tests/log/function_add_log_test.php | 107 +++++++++++++++------------- 1 file changed, 57 insertions(+), 50 deletions(-) diff --git a/tests/log/function_add_log_test.php b/tests/log/function_add_log_test.php index 05fae0f916..407aeb9ad1 100644 --- a/tests/log/function_add_log_test.php +++ b/tests/log/function_add_log_test.php @@ -21,85 +21,82 @@ class phpbb_log_function_add_log_test extends phpbb_database_test_case return array( array( array( - array( - 'user_id' => 2, - 'log_type' => LOG_CRITICAL, - 'log_operation' => 'LOG_NO_ADDITIONAL', - 'log_data' => '', - 'reportee_id' => 0, - 'forum_id' => 0, - 'topic_id' => 0, - ), + 'user_id' => 2, + 'log_type' => LOG_CRITICAL, + 'log_operation' => 'LOG_NO_ADDITIONAL', + 'log_data' => '', + 'reportee_id' => 0, + 'forum_id' => 0, + 'topic_id' => 0, ), 2, 'critical', 'LOG_NO_ADDITIONAL', ), array( array( - array( - 'user_id' => 2, - 'log_type' => LOG_CRITICAL, - 'log_operation' => 'LOG_ONE_ADDITIONAL', - 'log_data' => 'a:1:{i:0;s:9:"argument1";}', - 'reportee_id' => 0, - 'forum_id' => 0, - 'topic_id' => 0, + 'user_id' => 2, + 'log_type' => LOG_CRITICAL, + 'log_operation' => 'LOG_ONE_ADDITIONAL', + 'log_data' => array( + 'argument1', ), + 'reportee_id' => 0, + 'forum_id' => 0, + 'topic_id' => 0, ), 2, 'critical', 'LOG_ONE_ADDITIONAL', 'argument1', ), array( array( - array( - 'user_id' => ANONYMOUS, - 'log_type' => LOG_ADMIN, - 'log_operation' => 'LOG_TWO_ADDITIONAL', - 'log_data' => 'a:2:{i:0;s:9:"argument1";i:1;s:9:"argument2";}', - 'reportee_id' => 0, - 'forum_id' => 0, - 'topic_id' => 0, + 'user_id' => ANONYMOUS, + 'log_type' => LOG_ADMIN, + 'log_operation' => 'LOG_TWO_ADDITIONAL', + 'log_data' => array( + 'argument1', + 'argument2', ), + 'reportee_id' => 0, + 'forum_id' => 0, + 'topic_id' => 0, ), false, 'admin', 'LOG_TWO_ADDITIONAL', 'argument1', 'argument2', ), array( array( - array( - 'user_id' => ANONYMOUS, - 'log_type' => LOG_USERS, - 'log_operation' => 'LOG_USERS_ADDITIONAL', - 'log_data' => 'a:1:{i:0;s:9:"argument2";}', - 'reportee_id' => 2, - 'forum_id' => 0, - 'topic_id' => 0, + 'user_id' => ANONYMOUS, + 'log_type' => LOG_USERS, + 'log_operation' => 'LOG_USERS_ADDITIONAL', + 'log_data' => array( + 'argument2', ), + 'reportee_id' => 2, + 'forum_id' => 0, + 'topic_id' => 0, ), false, 'user', 2, 'LOG_USERS_ADDITIONAL', 'argument2', ), array( array( - array( - 'user_id' => ANONYMOUS, - 'log_type' => LOG_MOD, - 'log_operation' => 'LOG_MOD_TOPIC_AND_FORUM', - 'log_data' => '', - 'reportee_id' => 0, - 'forum_id' => 12, - 'topic_id' => 34, - ), + 'user_id' => ANONYMOUS, + 'log_type' => LOG_MOD, + 'log_operation' => 'LOG_MOD_TOPIC_AND_FORUM', + 'log_data' => '', + 'reportee_id' => 0, + 'forum_id' => 12, + 'topic_id' => 34, ), false, 'mod', 12, 34, 'LOG_MOD_TOPIC_AND_FORUM', ), array( array( - array( - 'user_id' => ANONYMOUS, - 'log_type' => LOG_MOD, - 'log_operation' => 'LOG_MOD_ADDITIONAL', - 'log_data' => 'a:1:{i:0;s:9:"argument3";}', - 'reportee_id' => 0, - 'forum_id' => 56, - 'topic_id' => 78, + 'user_id' => ANONYMOUS, + 'log_type' => LOG_MOD, + 'log_operation' => 'LOG_MOD_ADDITIONAL', + 'log_data' => array( + 'argument3', ), + 'reportee_id' => 0, + 'forum_id' => 56, + 'topic_id' => 78, ), false, 'mod', 56, 78, 'LOG_MOD_ADDITIONAL', 'argument3', ), @@ -118,6 +115,16 @@ class phpbb_log_function_add_log_test extends phpbb_database_test_case { global $db, $user; + if ($expected) + { + // Serialize the log data if we have some + if (is_array($expected['log_data'])) + { + $expected['log_data'] = serialize($expected['log_data']); + } + $expected = array($expected); + } + $db = $this->new_dbal(); $user->ip = 'user_ip'; From 1539ad7ebe1493e4c486181f65976c93dbb95c29 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sun, 18 Mar 2012 13:42:08 +0100 Subject: [PATCH 0056/2494] [ticket/10714] Add @return null to doc blocks PHPBB3-10714 --- phpBB/includes/log/interface.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/phpBB/includes/log/interface.php b/phpBB/includes/log/interface.php index 897b8a8211..7eda4b9710 100644 --- a/phpBB/includes/log/interface.php +++ b/phpBB/includes/log/interface.php @@ -31,11 +31,15 @@ interface phpbb_log_interface /** * This function allows disable the log-system. When add_log is called, the log will not be added to the database. + * + * @return null */ public function disable(); /** * This function allows re-enable the log-system. + * + * @return null */ public function enable(); From cff15ec307d76b004b6a825fb51b5dd3c8da58f2 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sun, 18 Mar 2012 13:47:24 +0100 Subject: [PATCH 0057/2494] [ticket/10714] Use keys for the log data instead of requiring a special order PHPBB3-10714 --- phpBB/includes/functions.php | 9 +++------ phpBB/includes/log/log.php | 13 ++++++++++--- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 9a1485f37a..3e3d796ba2 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -3392,14 +3392,11 @@ function add_log() case 'critical': break; case 'mod': - // forum_id - $additional_data[] = array_shift($args); - // topic_id - $additional_data[] = array_shift($args); + $additional_data['forum_id'] = array_shift($args); + $additional_data['topic_id'] = array_shift($args); break; case 'user': - // reportee_id - $additional_data[] = array_shift($args); + $additional_data['reportee_id'] = array_shift($args); break; default: /** diff --git a/phpBB/includes/log/log.php b/phpBB/includes/log/log.php index 89dc22593e..2523b97dbe 100644 --- a/phpBB/includes/log/log.php +++ b/phpBB/includes/log/log.php @@ -115,18 +115,25 @@ class phpbb_log implements phpbb_log_interface break; case 'mod': + $forum_id = (int) $additional_data['forum_id']; + unset($additional_data['forum_id']); + $topic_id = (int) $additional_data['topic_id']; + unset($additional_data['topic_id']); $sql_ary += array( 'log_type' => LOG_MOD, - 'forum_id' => intval(array_shift($additional_data)), - 'topic_id' => intval(array_shift($additional_data)), + 'forum_id' => $forum_id, + 'topic_id' => $topic_id, 'log_data' => (!sizeof($additional_data)) ? '' : serialize($additional_data), ); break; case 'user': + $reportee_id = (int) $additional_data['reportee_id']; + unset($additional_data['reportee_id']); + $sql_ary += array( 'log_type' => LOG_USERS, - 'reportee_id' => intval(array_shift($additional_data)), + 'reportee_id' => $reportee_id, 'log_data' => (!sizeof($additional_data)) ? '' : serialize($additional_data), ); break; From b9b08cf765d7feb2865477bb82ab58e8cfb0c156 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sun, 18 Mar 2012 13:54:33 +0100 Subject: [PATCH 0058/2494] [ticket/10714] Add return null to phpbb_log and add param to constructor PHPBB3-10714 --- phpBB/includes/log/log.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/phpBB/includes/log/log.php b/phpBB/includes/log/log.php index 2523b97dbe..67336d232a 100644 --- a/phpBB/includes/log/log.php +++ b/phpBB/includes/log/log.php @@ -34,6 +34,8 @@ class phpbb_log implements phpbb_log_interface /** * Constructor + * + * @param string $log_table The table we use to store our logs */ public function __construct($log_table) { @@ -53,6 +55,8 @@ class phpbb_log implements phpbb_log_interface /** * This function allows disable the log-system. When add_log is called, the log will not be added to the database. + * + * @return null */ public function disable() { @@ -61,6 +65,8 @@ class phpbb_log implements phpbb_log_interface /** * This function allows re-enable the log-system. + * + * @return null */ public function enable() { From 61cbabb120dfca6d924fbb08645f6dfbbcc5c1ec Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sun, 18 Mar 2012 13:59:32 +0100 Subject: [PATCH 0059/2494] [ticket/10714] Add missing log_operation to events in phpbb_log PHPBB3-10714 --- phpBB/includes/log/log.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/log/log.php b/phpBB/includes/log/log.php index 67336d232a..db774e48d5 100644 --- a/phpBB/includes/log/log.php +++ b/phpBB/includes/log/log.php @@ -157,7 +157,7 @@ class phpbb_log implements phpbb_log_interface * if ($phpbb_dispatcher != null) { - $vars = array('mode', 'user_id', 'log_ip', 'log_time', 'additional_data', 'sql_ary'); + $vars = array('mode', 'user_id', 'log_ip', 'log_operation', 'log_time', 'additional_data', 'sql_ary'); $event = new phpbb_event_data(compact($vars)); $phpbb_dispatcher->dispatch('core.add_log_case', $event); extract($event->get_data_filtered($vars)); @@ -176,7 +176,7 @@ class phpbb_log implements phpbb_log_interface * if ($phpbb_dispatcher != null) { - $vars = array('mode', 'user_id', 'log_ip', 'log_time', 'additional_data', 'sql_ary'); + $vars = array('mode', 'user_id', 'log_ip', 'log_operation', 'log_time', 'additional_data', 'sql_ary'); $event = new phpbb_event_data(compact($vars)); $phpbb_dispatcher->dispatch('core.add_log', $event); extract($event->get_data_filtered($vars)); From a0b35f8e4e94d1301421670cf35406b974510ed0 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sun, 18 Mar 2012 21:56:15 +0100 Subject: [PATCH 0060/2494] [ticket/10714] Use {@inheritDoc} instead of repeating the doc-block PHPBB3-10714 --- phpBB/includes/log/log.php | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/phpBB/includes/log/log.php b/phpBB/includes/log/log.php index db774e48d5..aa60c453e4 100644 --- a/phpBB/includes/log/log.php +++ b/phpBB/includes/log/log.php @@ -76,14 +76,7 @@ class phpbb_log implements phpbb_log_interface /** * Adds a log to the database * - * @param string $mode The mode defines which log_type is used and in which log the entry is displayed. - * @param int $user_id User ID of the user - * @param string $log_ip IP address of the user - * @param string $log_operation Name of the operation - * @param int $log_time Timestamp when the log was added. - * @param array $additional_data More arguments can be added, depending on the log_type - * - * @return int|bool Returns the log_id, if the entry was added to the database, false otherwise. + * {@inheritDoc} */ public function add($mode, $user_id, $log_ip, $log_operation, $log_time = false, $additional_data = array()) { From ea652f0ec9e7046f329e692fc355e64836f9bf9d Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 21 Mar 2012 13:33:25 +0100 Subject: [PATCH 0061/2494] [ticket/10714] Rename add_log_function test PHPBB3-10714 --- tests/log/function_add_log_test.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/log/function_add_log_test.php b/tests/log/function_add_log_test.php index 407aeb9ad1..1f54f66d2d 100644 --- a/tests/log/function_add_log_test.php +++ b/tests/log/function_add_log_test.php @@ -16,7 +16,7 @@ class phpbb_log_function_add_log_test extends phpbb_database_test_case return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/empty_log.xml'); } - public static function test_add_log_function_critical_data() + public static function test_add_log_function_data() { return array( array( @@ -109,9 +109,9 @@ class phpbb_log_function_add_log_test extends phpbb_database_test_case } /** - * @dataProvider test_add_log_function_critical_data + * @dataProvider test_add_log_function_data */ - public function test_add_log_function_critical($expected, $user_id, $mode, $required1, $additional1 = null, $additional2 = null, $additional3 = null) + public function test_add_log_function($expected, $user_id, $mode, $required1, $additional1 = null, $additional2 = null, $additional3 = null) { global $db, $user; From 920cb1a0de10febca3c78ef13286a49838656ab2 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 21 Mar 2012 13:38:02 +0100 Subject: [PATCH 0062/2494] [ticket/10714] Add unit tests for view_log function PHPBB3-10714 --- tests/log/fixtures/full_log.xml | 166 +++++++++++++ tests/log/function_view_log_test.php | 341 +++++++++++++++++++++++++++ 2 files changed, 507 insertions(+) create mode 100644 tests/log/fixtures/full_log.xml create mode 100644 tests/log/function_view_log_test.php diff --git a/tests/log/fixtures/full_log.xml b/tests/log/fixtures/full_log.xml new file mode 100644 index 0000000000..2ce2643d26 --- /dev/null +++ b/tests/log/fixtures/full_log.xml @@ -0,0 +1,166 @@ + + + + log_id + log_type + user_id + forum_id + topic_id + reportee_id + log_ip + log_time + log_operation + log_data + + 1 + 0 + 1 + 0 + 0 + 0 + 127.0.0.1 + 1 + LOG_INSTALL_INSTALLED + a:1:{i:0;s:9:"3.1.0-dev";} + + + 2 + 0 + 1 + 0 + 0 + 0 + 127.0.0.1 + 1 + LOG_KEY_NOT_EXISTS + a:1:{i:0;s:15:"additional_data";} + + + 3 + 2 + 1 + 0 + 0 + 0 + 127.0.0.1 + 1 + LOG_CRITICAL + a:1:{i:0;s:13:"critical data";} + + + 4 + 1 + 1 + 12 + 34 + 0 + 127.0.0.1 + 1 + LOG_MOD + + + + 5 + 1 + 1 + 12 + 45 + 0 + 127.0.0.1 + 1 + LOG_MOD + + + + 6 + 1 + 1 + 23 + 56 + 0 + 127.0.0.1 + 1 + LOG_MOD + + + + 7 + 1 + 1 + 12 + 45 + 0 + 127.0.0.1 + 1 + LOG_MOD2 + + + + 8 + 3 + 1 + 0 + 0 + 2 + 127.0.0.1 + 1 + LOG_USER + a:1:{i:0;s:5:"admin";} + + + 9 + 3 + 1 + 0 + 0 + 1 + 127.0.0.1 + 1 + LOG_USER + a:1:{i:0;s:5:"guest";} + +
    + + user_id + username + username_clean + user_permissions + user_sig + user_occ + user_interests + + 1 + Anonymous + Anonymous + + + + + + + 2 + admin + admin + + + + + +
    + + topic_id + forum_id + + 34 + 12 + + + 45 + 12 + + + 56 + 23 + +
    +
    diff --git a/tests/log/function_view_log_test.php b/tests/log/function_view_log_test.php new file mode 100644 index 0000000000..7c44413330 --- /dev/null +++ b/tests/log/function_view_log_test.php @@ -0,0 +1,341 @@ +createXMLDataSet(dirname(__FILE__) . '/fixtures/full_log.xml'); + } + + public static function test_view_log_function_data() + { + global $phpEx; + + $expected_data_sets = array( + 1 => array( + 'id' => 1, + + 'reportee_id' => 0, + 'reportee_username' => '', + 'reportee_username_full'=> '', + + 'user_id' => 1, + 'username' => 'Anonymous', + 'username_full' => 'Anonymous', + + 'ip' => '127.0.0.1', + 'time' => 1, + 'forum_id' => 0, + 'topic_id' => 0, + + 'viewforum' => '', + 'action' => 'installed: 3.1.0-dev', + ), + 2 => array( + 'id' => 2, + + 'reportee_id' => 0, + 'reportee_username' => '', + 'reportee_username_full'=> '', + + 'user_id' => 1, + 'username' => 'Anonymous', + 'username_full' => 'Anonymous', + + 'ip' => '127.0.0.1', + 'time' => 1, + 'forum_id' => 0, + 'topic_id' => 0, + + 'viewforum' => '', + 'action' => '{LOG KEY NOT EXISTS}
    additional_data', + ), + 3 => array( + 'id' => 3, + + 'reportee_id' => 0, + 'reportee_username' => '', + 'reportee_username_full'=> '', + + 'user_id' => 1, + 'username' => 'Anonymous', + 'username_full' => 'Anonymous', + + 'ip' => '127.0.0.1', + 'time' => 1, + 'forum_id' => 0, + 'topic_id' => 0, + + 'viewforum' => '', + 'action' => '{LOG CRITICAL}
    critical data', + ), + 4 => array( + 'id' => 4, + + 'reportee_id' => 0, + 'reportee_username' => '', + 'reportee_username_full'=> '', + + 'user_id' => 1, + 'username' => 'Anonymous', + 'username_full' => 'Anonymous', + + 'ip' => '127.0.0.1', + 'time' => 1, + 'forum_id' => 12, + 'topic_id' => 34, + + 'viewforum' => '', + 'action' => '{LOG MOD}', + 'viewtopic' => '', + 'viewlogs' => '', + ), + 5 => array( + 'id' => 5, + + 'reportee_id' => 0, + 'reportee_username' => '', + 'reportee_username_full'=> '', + + 'user_id' => 1, + 'username' => 'Anonymous', + 'username_full' => 'Anonymous', + + 'ip' => '127.0.0.1', + 'time' => 1, + 'forum_id' => 12, + 'topic_id' => 45, + + 'viewforum' => '', + 'action' => '{LOG MOD}', + 'viewtopic' => '', + 'viewlogs' => '', + ), + 6 => array( + 'id' => 6, + + 'reportee_id' => 0, + 'reportee_username' => '', + 'reportee_username_full'=> '', + + 'user_id' => 1, + 'username' => 'Anonymous', + 'username_full' => 'Anonymous', + + 'ip' => '127.0.0.1', + 'time' => 1, + 'forum_id' => 23, + 'topic_id' => 56, + + 'viewforum' => append_sid("phpBB/viewforum.$phpEx", 'f=23'), + 'action' => '{LOG MOD}', + 'viewtopic' => append_sid("phpBB/viewtopic.$phpEx", 'f=23&t=56'), + 'viewlogs' => append_sid("phpBB/mcp.$phpEx", 'i=logs&mode=topic_logs&t=56'), + ), + 7 => array( + 'id' => 7, + + 'reportee_id' => 0, + 'reportee_username' => '', + 'reportee_username_full'=> '', + + 'user_id' => 1, + 'username' => 'Anonymous', + 'username_full' => 'Anonymous', + + 'ip' => '127.0.0.1', + 'time' => 1, + 'forum_id' => 12, + 'topic_id' => 45, + + 'viewforum' => '', + 'action' => '{LOG MOD2}', + 'viewtopic' => '', + 'viewlogs' => '', + ), + 8 => array( + 'id' => 8, + + 'reportee_id' => 2, + 'reportee_username' => 'admin', + 'reportee_username_full'=> 'admin', + + 'user_id' => 1, + 'username' => 'Anonymous', + 'username_full' => 'Anonymous', + + 'ip' => '127.0.0.1', + 'time' => 1, + 'forum_id' => 0, + 'topic_id' => 0, + + 'viewforum' => '', + 'action' => '{LOG USER}
    admin', + ), + 9 => array( + 'id' => 9, + + 'reportee_id' => 1, + 'reportee_username' => 'Anonymous', + 'reportee_username_full'=> 'Anonymous', + + 'user_id' => 1, + 'username' => 'Anonymous', + 'username_full' => 'Anonymous', + + 'ip' => '127.0.0.1', + 'time' => 1, + 'forum_id' => 0, + 'topic_id' => 0, + + 'viewforum' => '', + 'action' => '{LOG USER}
    guest', + ), + ); + + $test_cases = array( + array( + 'expected' => array(1, 2), + 'expected_returned' => 0, + false, + 'admin', + ), + array( + 'expected' => array(1), + 'expected_returned' => 0, + false, + 'admin', 1, + ), + array( + 'expected' => array(2), + 'expected_returned' => 1, + false, + 'admin', 1, 1, + ), + array( + 'expected' => array(2), + 'expected_returned' => 1, + 0, + 'admin', 1, 1, + ), + array( + 'expected' => array(2), + 'expected_returned' => 1, + 0, + 'admin', 1, 5, + ), + array( + 'expected' => array(3), + 'expected_returned' => 0, + false, + 'critical', + ), + array( + 'expected' => array(), + 'expected_returned' => null, + false, + 'mode_does_not_exist', + ), + array( + 'expected' => array(4, 5, 7), + 'expected_returned' => 0, + 0, + 'mod', 5, 0, 12, + ), + array( + 'expected' => array(5, 7), + 'expected_returned' => 0, + 0, + 'mod', 5, 0, 12, 45, + ), + array( + 'expected' => array(6), + 'expected_returned' => 0, + 0, + 'mod', 5, 0, 23, + ), + array( + 'expected' => array(8), + 'expected_returned' => 0, + 0, + 'user', 5, 0, 0, 0, 2, + ), + array( + 'expected' => array(8, 9), + 'expected_returned' => 0, + 0, + 'users', + ), + ); + + foreach ($test_cases as $case => $case_data) + { + foreach ($case_data['expected'] as $data_set => $expected) + { + $test_cases[$case]['expected'][$data_set] = $expected_data_sets[$expected]; + } + } + + return $test_cases; + } + + /** + * @dataProvider test_view_log_function_data + */ + public function test_view_log_function($expected, $expected_returned, $log_count, $mode, $limit = 5, $offset = 0, $forum_id = 0, $topic_id = 0, $user_id = 0, $limit_days = 0, $sort_by = 'l.log_id ASC', $keywords = '') + { + global $cache, $db, $user, $auth; + + $db = $this->new_dbal(); + $cache = new phpbb_mock_cache; + + // Create auth mock + $auth = $this->getMock('auth'); + $acl_get_map = array( + array('f_read', 23, true), + array('m_', 23, true), + ); + $acl_gets_map = array( + array('a_', 'm_', 23, true), + ); + + $auth->expects($this->any()) + ->method('acl_get') + ->with($this->stringContains('_'), + $this->anything()) + ->will($this->returnValueMap($acl_get_map)); + $auth->expects($this->any()) + ->method('acl_gets') + ->with($this->stringContains('_'), + $this->anything()) + ->will($this->returnValueMap($acl_gets_map)); + + $user = new phpbb_mock_user; + $user->optionset('viewcensors', false); + // Test sprintf() of the data into the action + $user->lang = array( + 'LOG_INSTALL_INSTALLED' => 'installed: %s', + ); + + $log = array(); + $this->assertEquals($expected_returned, view_log($mode, $log, $log_count, $limit, $offset, $forum_id, $topic_id, $user_id, $limit_days, $sort_by, $keywords)); + + $this->assertEquals($expected, $log); + } +} From 91384d8395166ec21995103410e35f7ba28ac830 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 24 Mar 2012 15:05:02 +0100 Subject: [PATCH 0063/2494] [ticket/10714] Add casts to integer values. PHPBB3-10714 --- phpBB/includes/functions_admin.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index 5e2ee8c8f6..e05ed3cdde 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -2603,6 +2603,7 @@ function view_log($mode, &$log, &$log_count, $limit = 0, $offset = 0, $forum_id $log = array(); while ($row = $db->sql_fetchrow($result)) { + $row['forum_id'] = (int) $row['forum_id']; if ($row['topic_id']) { $topic_id_list[] = $row['topic_id']; @@ -2614,20 +2615,20 @@ function view_log($mode, &$log, &$log_count, $limit = 0, $offset = 0, $forum_id } $log[$i] = array( - 'id' => $row['log_id'], + 'id' => (int) $row['log_id'], - 'reportee_id' => $row['reportee_id'], + 'reportee_id' => (int) $row['reportee_id'], 'reportee_username' => '', 'reportee_username_full'=> '', - 'user_id' => $row['user_id'], + 'user_id' => (int) $row['user_id'], 'username' => $row['username'], 'username_full' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour'], false, $profile_url), 'ip' => $row['log_ip'], - 'time' => $row['log_time'], - 'forum_id' => $row['forum_id'], - 'topic_id' => $row['topic_id'], + 'time' => (int) $row['log_time'], + 'forum_id' => (int) $row['forum_id'], + 'topic_id' => (int) $row['topic_id'], 'viewforum' => ($row['forum_id'] && $auth->acl_get('f_read', $row['forum_id'])) ? append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $row['forum_id']) : false, 'action' => (isset($user->lang[$row['log_operation']])) ? $user->lang[$row['log_operation']] : '{' . ucfirst(str_replace('_', ' ', $row['log_operation'])) . '}', @@ -2689,6 +2690,7 @@ function view_log($mode, &$log, &$log_count, $limit = 0, $offset = 0, $forum_id while ($row = $db->sql_fetchrow($result)) { + $row['forum_id'] = (int) $row['forum_id']; if ($auth->acl_get('f_read', $row['forum_id'])) { $is_auth[$row['topic_id']] = $row['forum_id']; From f5063a6eda49d2a35b2aed486f86cde76e0f04a8 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 24 Mar 2012 15:06:13 +0100 Subject: [PATCH 0064/2494] [ticket/10714] Add incorrect offset calculation in view_log function PHPBB3-10714 --- phpBB/includes/functions_admin.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index e05ed3cdde..fd1f5568ab 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -2584,9 +2584,13 @@ function view_log($mode, &$log, &$log_count, $limit = 0, $offset = 0, $forum_id return 0; } - if ($offset >= $log_count) + if ($log_count) { - $offset = ($offset - $limit < 0) ? 0 : $offset - $limit; + // Return the user to the last page that is valid + while ($offset >= $log_count) + { + $offset = ($offset - $limit < 0) ? 0 : $offset - $limit; + } } $sql = "SELECT l.*, u.username, u.username_clean, u.user_colour From 9248b9b25fdc3c05cc9fb1e99f607817f8ec7bcb Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 24 Mar 2012 15:06:32 +0100 Subject: [PATCH 0065/2494] [ticket/10714] Add doc block for view_log function PHPBB3-10714 --- phpBB/includes/functions_admin.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index fd1f5568ab..49c34f7fff 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -2470,7 +2470,21 @@ function cache_moderators() /** * View log -* If $log_count is set to false, we will skip counting all entries in the database. +* +* @param string $mode The mode defines which log_type is used and in which log the entry is displayed. +* @param array &$log The result array with the logs +* @param mixed &$log_count If $log_count is set to false, we will skip counting all entries in the database. +* Otherwise an integer with the number of total matching entries is returned. +* @param int $limit Limit the number of entries that are returned +* @param int $offset Offset when fetching the log entries, f.e. on paginations +* @param mixed $forum_id Restrict the log entries to the given forum_id (can also be an array of forum_ids) +* @param int $topic_id Restrict the log entries to the given topic_id +* @param int $user_id Restrict the log entries to the given user_id +* @param int $log_time Only get log entries newer than the given timestamp +* @param string $sort_by SQL order option, e.g. 'l.log_time DESC' +* @param string $keywords Will only return log entries that have the keywords in log_operation or log_data +* +* @return int Returns the offset of the last valid page, if the specified offset was invalid (too high) */ function view_log($mode, &$log, &$log_count, $limit = 0, $offset = 0, $forum_id = 0, $topic_id = 0, $user_id = 0, $limit_days = 0, $sort_by = 'l.log_time DESC', $keywords = '') { From 55b94af82ecb7e73535bfbed6c278f1d992efecb Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 24 Mar 2012 16:27:52 +0100 Subject: [PATCH 0066/2494] [ticket/10714] Implement get_logs() based on view_log() I moved some stuff into its own function to make the code a bit clearer. PHPBB3-10714 --- phpBB/includes/log/interface.php | 64 +++++ phpBB/includes/log/log.php | 406 +++++++++++++++++++++++++++++++ 2 files changed, 470 insertions(+) diff --git a/phpBB/includes/log/interface.php b/phpBB/includes/log/interface.php index 7eda4b9710..fde718b71a 100644 --- a/phpBB/includes/log/interface.php +++ b/phpBB/includes/log/interface.php @@ -56,4 +56,68 @@ interface phpbb_log_interface * @return int|bool Returns the log_id, if the entry was added to the database, false otherwise. */ public function add($mode, $user_id, $log_ip, $log_operation, $log_time, $additional_data); + + /** + * Grab the logs from the database + * + * @param string $mode The mode defines which log_type is used and in which log the entry is displayed. + * @param bool $count_logs Shall we count all matching log entries? + * @param int $limit Limit the number of entries that are returned + * @param int $offset Offset when fetching the log entries, f.e. on paginations + * @param mixed $forum_id Restrict the log entries to the given forum_id (can also be an array of forum_ids) + * @param int $topic_id Restrict the log entries to the given topic_id + * @param int $user_id Restrict the log entries to the given user_id + * @param int $log_time Only get log entries newer than the given timestamp + * @param string $sort_by SQL order option, e.g. 'l.log_time DESC' + * @param string $keywords Will only return log entries that have the keywords in log_operation or log_data + * + * @return array The result array with the logs + */ + public function get_logs($mode, $count_logs = true, $limit = 0, $offset = 0, $forum_id = 0, $topic_id = 0, $user_id = 0, $log_time = 0, $sort_by = 'l.log_time DESC', $keywords = ''); + + /** + * Generates a sql condition out of the specified keywords + * + * @param string $keywords The keywords the user specified to search for + * + * @return string Returns the SQL condition searching for the keywords + */ + static public function generate_sql_keyword($keywords); + + /** + * Determinate whether the user is allowed to read and/or moderate the forum of the topic + * + * @param array $topic_ids Array with the topic ids + * + * @return array Returns an array with two keys 'm_' and 'read_f' which are also an array of topic_id => forum_id sets when the permissions are given. Sample: + * array( + * 'permission' => array( + * topic_id => forum_id + * ), + * ), + */ + static public function get_topic_auth($topic_ids); + + /** + * Get the data for all reportee form the database + * + * @param array $reportee_ids Array with the user ids of the reportees + * + * @return array Returns an array with the reportee data + */ + static public function get_reportee_data($reportee_ids); + + /** + * Get total log count + * + * @return int Returns the number of matching logs from the last call to get_logs() + */ + public function get_log_count(); + + /** + * Get offset of the last valid page + * + * @return int Returns the offset of the last valid page from the last call to get_logs() + */ + public function get_valid_offset(); } diff --git a/phpBB/includes/log/log.php b/phpBB/includes/log/log.php index aa60c453e4..14f8bfd534 100644 --- a/phpBB/includes/log/log.php +++ b/phpBB/includes/log/log.php @@ -27,6 +27,16 @@ class phpbb_log implements phpbb_log_interface */ private $enabled; + /** + * Keeps the total log count of the last call to get_logs() + */ + private $logs_total; + + /** + * Keeps the offset of the last valid page of the last call to get_logs() + */ + private $logs_offset; + /** * The table we use to store our logs. */ @@ -180,4 +190,400 @@ class phpbb_log implements phpbb_log_interface return $db->sql_nextid(); } + + /** + * Grab the logs from the database + * + * {@inheritDoc} + */ + public function get_logs($mode, $count_logs = true, $limit = 0, $offset = 0, $forum_id = 0, $topic_id = 0, $user_id = 0, $log_time = 0, $sort_by = 'l.log_time DESC', $keywords = '') + { + global $db, $user, $auth, $phpEx, $phpbb_root_path, $phpbb_admin_path; + + $this->logs_total = 0; + $this->logs_offset = $offset; + + $topic_id_list = $reportee_id_list = array(); + + $profile_url = (defined('IN_ADMIN')) ? append_sid("{$phpbb_admin_path}index.$phpEx", 'i=users&mode=overview') : append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=viewprofile'); + + switch ($mode) + { + case 'admin': + $log_type = LOG_ADMIN; + $sql_additional = ''; + break; + + case 'mod': + $log_type = LOG_MOD; + $sql_additional = ''; + + if ($topic_id) + { + $sql_additional = 'AND l.topic_id = ' . (int) $topic_id; + } + else if (is_array($forum_id)) + { + $sql_additional = 'AND ' . $db->sql_in_set('l.forum_id', array_map('intval', $forum_id)); + } + else if ($forum_id) + { + $sql_additional = 'AND l.forum_id = ' . (int) $forum_id; + } + break; + + case 'user': + $log_type = LOG_USERS; + $sql_additional = 'AND l.reportee_id = ' . (int) $user_id; + break; + + case 'users': + $log_type = LOG_USERS; + $sql_additional = ''; + break; + + case 'critical': + $log_type = LOG_CRITICAL; + $sql_additional = ''; + break; + + default: + $log_type = null; + $sql_additional = ''; + /** + * @todo: enable when events are merged + * + if ($phpbb_dispatcher != null) + { + $vars = array('mode', 'count_logs', 'limit', 'offset', 'forum_id', 'topic_id', 'user_id', 'log_time', 'sort_by', 'keywords', 'profile_url', 'log_type', 'sql_additional'); + $event = new phpbb_event_data(compact($vars)); + $phpbb_dispatcher->dispatch('core.get_logs_switch_mode', $event); + extract($event->get_data_filtered($vars)); + } + */ + + if (!isset($log_type)) + { + $this->logs_offset = 0; + return array(); + } + } + + /** + * @todo: enable when events are merged + * + if ($phpbb_dispatcher != null) + { + $vars = array('mode', 'count_logs', 'limit', 'offset', 'forum_id', 'topic_id', 'user_id', 'log_time', 'sort_by', 'keywords', 'profile_url', 'log_type', 'sql_additional'); + $event = new phpbb_event_data(compact($vars)); + $phpbb_dispatcher->dispatch('core.get_logs_after_get_type', $event); + extract($event->get_data_filtered($vars)); + } + */ + + $sql_keywords = ''; + if (!empty($keywords)) + { + // Get the SQL condition for our keywords + $sql_keywords = self::generate_sql_keyword($keywords); + } + + if ($count_logs) + { + $sql = 'SELECT COUNT(l.log_id) AS total_entries + FROM ' . LOG_TABLE . ' l, ' . USERS_TABLE . " u + WHERE l.log_type = $log_type + AND l.user_id = u.user_id + AND l.log_time >= $log_time + $sql_keywords + $sql_additional"; + $result = $db->sql_query($sql); + $this->logs_total = (int) $db->sql_fetchfield('total_entries'); + $db->sql_freeresult($result); + + if ($this->logs_total == 0) + { + // Save the queries, because there are no logs to display + $this->logs_offset = 0; + return array(); + } + + // Return the user to the last page that is valid + while ($this->logs_offset >= $this->logs_total) + { + $this->logs_offset = ($this->logs_offset - $limit < 0) ? 0 : $this->logs_offset - $limit; + } + } + + $sql = "SELECT l.*, u.username, u.username_clean, u.user_colour + FROM " . LOG_TABLE . " l, " . USERS_TABLE . " u + WHERE l.log_type = $log_type + AND u.user_id = l.user_id + " . (($log_time) ? "AND l.log_time >= $log_time" : '') . " + $sql_keywords + $sql_additional + ORDER BY $sort_by"; + $result = $db->sql_query_limit($sql, $limit, $this->logs_offset); + + $i = 0; + $log = array(); + while ($row = $db->sql_fetchrow($result)) + { + $row['forum_id'] = (int) $row['forum_id']; + if ($row['topic_id']) + { + $topic_id_list[] = (int) $row['topic_id']; + } + + if ($row['reportee_id']) + { + $reportee_id_list[] = (int) $row['reportee_id']; + } + + $log_entry_data = array( + 'id' => (int) $row['log_id'], + + 'reportee_id' => (int) $row['reportee_id'], + 'reportee_username' => '', + 'reportee_username_full'=> '', + + 'user_id' => (int) $row['user_id'], + 'username' => $row['username'], + 'username_full' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour'], false, $profile_url), + + 'ip' => $row['log_ip'], + 'time' => (int) $row['log_time'], + 'forum_id' => (int) $row['forum_id'], + 'topic_id' => (int) $row['topic_id'], + + 'viewforum' => ($row['forum_id'] && $auth->acl_get('f_read', $row['forum_id'])) ? append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $row['forum_id']) : false, + 'action' => (isset($user->lang[$row['log_operation']])) ? $user->lang[$row['log_operation']] : '{' . ucfirst(str_replace('_', ' ', $row['log_operation'])) . '}', + ); + + /** + * @todo: enable when events are merged + * + if ($phpbb_dispatcher != null) + { + $vars = array('log_entry_data', 'row'); + $event = new phpbb_event_data(compact($vars)); + $phpbb_dispatcher->dispatch('core.get_logs_entry_data', $event); + extract($event->get_data_filtered($vars)); + } + */ + + $log[$i] = $log_entry_data; + + if (!empty($row['log_data'])) + { + $log_data_ary = @unserialize($row['log_data']); + $log_data_ary = ($log_data_ary === false) ? array() : $log_data_ary; + + if (isset($user->lang[$row['log_operation']])) + { + // Check if there are more occurrences of % than arguments, if there are we fill out the arguments array + // It doesn't matter if we add more arguments than placeholders + if ((substr_count($log[$i]['action'], '%') - sizeof($log_data_ary)) > 0) + { + $log_data_ary = array_merge($log_data_ary, array_fill(0, substr_count($log[$i]['action'], '%') - sizeof($log_data_ary), '')); + } + + $log[$i]['action'] = vsprintf($log[$i]['action'], $log_data_ary); + + // If within the admin panel we do not censor text out + if (defined('IN_ADMIN')) + { + $log[$i]['action'] = bbcode_nl2br($log[$i]['action']); + } + else + { + $log[$i]['action'] = bbcode_nl2br(censor_text($log[$i]['action'])); + } + } + else if (!empty($log_data_ary)) + { + $log[$i]['action'] .= '
    ' . implode('', $log_data_ary); + } + + /* Apply make_clickable... has to be seen if it is for good. :/ + // Seems to be not for the moment, reconsider later... + $log[$i]['action'] = make_clickable($log[$i]['action']); + */ + } + + $i++; + } + $db->sql_freeresult($result); + + /** + * @todo: enable when events are merged + * + if ($phpbb_dispatcher != null) + { + $vars = array('log', 'topic_id_list', 'reportee_id_list'); + $event = new phpbb_event_data(compact($vars)); + $phpbb_dispatcher->dispatch('core.get_logs_additional_data', $event); + extract($event->get_data_filtered($vars)); + } + */ + + if (sizeof($topic_id_list)) + { + $topic_auth = self::get_topic_auth($topic_id_list); + + foreach ($log as $key => $row) + { + $log[$key]['viewtopic'] = (isset($topic_auth['f_read'][$row['topic_id']])) ? append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $topic_auth['f_read'][$row['topic_id']] . '&t=' . $row['topic_id']) : false; + $log[$key]['viewlogs'] = (isset($topic_auth['m_'][$row['topic_id']])) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=logs&mode=topic_logs&t=' . $row['topic_id'], true, $user->session_id) : false; + } + } + + if (sizeof($reportee_id_list)) + { + $reportee_data_list = self::get_reportee_data($reportee_id_list); + + foreach ($log as $key => $row) + { + if (!isset($reportee_data_list[$row['reportee_id']])) + { + continue; + } + + $log[$key]['reportee_username'] = $reportee_data_list[$row['reportee_id']]['username']; + $log[$key]['reportee_username_full'] = get_username_string('full', $row['reportee_id'], $reportee_data_list[$row['reportee_id']]['username'], $reportee_data_list[$row['reportee_id']]['user_colour'], false, $profile_url); + } + } + + return $log; + } + + /** + * Generates a sql condition out of the specified keywords + * + * {@inheritDoc} + */ + static public function generate_sql_keyword($keywords) + { + global $db, $user; + + // Use no preg_quote for $keywords because this would lead to sole backslashes being added + // We also use an OR connection here for spaces and the | string. Currently, regex is not supported for searching (but may come later). + $keywords = preg_split('#[\s|]+#u', utf8_strtolower($keywords), 0, PREG_SPLIT_NO_EMPTY); + $sql_keywords = ''; + + if (!empty($keywords)) + { + $keywords_pattern = array(); + + // Build pattern and keywords... + for ($i = 0, $num_keywords = sizeof($keywords); $i < $num_keywords; $i++) + { + $keywords_pattern[] = preg_quote($keywords[$i], '#'); + $keywords[$i] = $db->sql_like_expression($db->any_char . $keywords[$i] . $db->any_char); + } + + $keywords_pattern = '#' . implode('|', $keywords_pattern) . '#ui'; + + $operations = array(); + foreach ($user->lang as $key => $value) + { + if (substr($key, 0, 4) == 'LOG_' && preg_match($keywords_pattern, $value)) + { + $operations[] = $key; + } + } + + $sql_keywords = 'AND ('; + if (!empty($operations)) + { + $sql_keywords .= $db->sql_in_set('l.log_operation', $operations) . ' OR '; + } + $sql_keywords .= 'LOWER(l.log_data) ' . implode(' OR LOWER(l.log_data) ', $keywords) . ')'; + } + + return $sql_keywords; + } + + /** + * Determinate whether the user is allowed to read and/or moderate the forum of the topic + * + * {@inheritDoc} + */ + static public function get_topic_auth($topic_ids) + { + global $auth, $db; + + $forum_auth = array('f_read' => array(), 'm_' => array()); + $topic_ids = array_unique($topic_ids); + + $sql = 'SELECT topic_id, forum_id + FROM ' . TOPICS_TABLE . ' + WHERE ' . $db->sql_in_set('topic_id', array_map('intval', $topic_ids)); + $result = $db->sql_query($sql); + + while ($row = $db->sql_fetchrow($result)) + { + $row['topic_id'] = (int) $row['topic_id']; + $row['forum_id'] = (int) $row['forum_id']; + + if ($auth->acl_get('f_read', $row['forum_id'])) + { + $forum_auth['f_read'][$row['topic_id']] = $row['forum_id']; + } + + if ($auth->acl_gets('a_', 'm_', $row['forum_id'])) + { + $forum_auth['m_'][$row['topic_id']] = $row['forum_id']; + } + } + $db->sql_freeresult($result); + + return $forum_auth; + } + + /** + * Get the data for all reportee form the database + * + * {@inheritDoc} + */ + static public function get_reportee_data($reportee_ids) + { + global $db; + + $reportee_ids = array_unique($reportee_ids); + $reportee_data_list = array(); + + $sql = 'SELECT user_id, username, user_colour + FROM ' . USERS_TABLE . ' + WHERE ' . $db->sql_in_set('user_id', $reportee_ids); + $result = $db->sql_query($sql); + + while ($row = $db->sql_fetchrow($result)) + { + $reportee_data_list[$row['user_id']] = $row; + } + $db->sql_freeresult($result); + + return $reportee_data_list; + } + + /** + * Get total log count + * + * @return int Returns the number of matching logs from the last call to get_logs() + */ + public function get_log_count() + { + return ($this->logs_total) ? $this->logs_total : 0; + } + + /** + * Get offset of the last valid log page + * + * @return int Returns the offset of the last valid page from the last call to get_logs() + */ + public function get_valid_offset() + { + return ($this->logs_offset) ? $this->logs_offset : 0; + } } From 97290647fae683ecce842541a682e3403b7717ee Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 24 Mar 2012 16:39:03 +0100 Subject: [PATCH 0067/2494] [ticket/10714] Use phpbb_log class in view_log() PHPBB3-10714 --- phpBB/includes/functions_admin.php | 277 ++--------------------------- phpBB/includes/log/log.php | 105 +++++++---- 2 files changed, 87 insertions(+), 295 deletions(-) diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index 49c34f7fff..e7aed85e15 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -2488,275 +2488,34 @@ function cache_moderators() */ function view_log($mode, &$log, &$log_count, $limit = 0, $offset = 0, $forum_id = 0, $topic_id = 0, $user_id = 0, $limit_days = 0, $sort_by = 'l.log_time DESC', $keywords = '') { - global $db, $user, $auth, $phpEx, $phpbb_root_path, $phpbb_admin_path; + // This is all just an ugly hack to add "Dependency Injection" to a function + // the only real code is the function call which maps this function to a method. + static $static_log = null; - $topic_id_list = $reportee_id_list = $is_auth = $is_mod = array(); - - $profile_url = (defined('IN_ADMIN')) ? append_sid("{$phpbb_admin_path}index.$phpEx", 'i=users&mode=overview') : append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=viewprofile'); - - switch ($mode) + if ($mode instanceof phpbb_log_interface) { - case 'admin': - $log_type = LOG_ADMIN; - $sql_forum = ''; - break; - - case 'mod': - $log_type = LOG_MOD; - $sql_forum = ''; - - if ($topic_id) - { - $sql_forum = 'AND l.topic_id = ' . (int) $topic_id; - } - else if (is_array($forum_id)) - { - $sql_forum = 'AND ' . $db->sql_in_set('l.forum_id', array_map('intval', $forum_id)); - } - else if ($forum_id) - { - $sql_forum = 'AND l.forum_id = ' . (int) $forum_id; - } - break; - - case 'user': - $log_type = LOG_USERS; - $sql_forum = 'AND l.reportee_id = ' . (int) $user_id; - break; - - case 'users': - $log_type = LOG_USERS; - $sql_forum = ''; - break; - - case 'critical': - $log_type = LOG_CRITICAL; - $sql_forum = ''; - break; - - default: - return; + $static_log = $mode; + return true; + } + else if ($mode === false) + { + return false; } - // Use no preg_quote for $keywords because this would lead to sole backslashes being added - // We also use an OR connection here for spaces and the | string. Currently, regex is not supported for searching (but may come later). - $keywords = preg_split('#[\s|]+#u', utf8_strtolower($keywords), 0, PREG_SPLIT_NO_EMPTY); - $sql_keywords = ''; + $tmp_log = $static_log; - if (!empty($keywords)) + // no log class set, create a temporary one ourselves to keep backwards compatability + if ($tmp_log === null) { - $keywords_pattern = array(); - - // Build pattern and keywords... - for ($i = 0, $num_keywords = sizeof($keywords); $i < $num_keywords; $i++) - { - $keywords_pattern[] = preg_quote($keywords[$i], '#'); - $keywords[$i] = $db->sql_like_expression($db->any_char . $keywords[$i] . $db->any_char); - } - - $keywords_pattern = '#' . implode('|', $keywords_pattern) . '#ui'; - - $operations = array(); - foreach ($user->lang as $key => $value) - { - if (substr($key, 0, 4) == 'LOG_' && preg_match($keywords_pattern, $value)) - { - $operations[] = $key; - } - } - - $sql_keywords = 'AND ('; - if (!empty($operations)) - { - $sql_keywords .= $db->sql_in_set('l.log_operation', $operations) . ' OR '; - } - $sql_lower = $db->sql_lower_text('l.log_data'); - $sql_keywords .= "$sql_lower " . implode(" OR $sql_lower ", $keywords) . ')'; + $tmp_log = new phpbb_log(LOG_TABLE); } - if ($log_count !== false) - { - $sql = 'SELECT COUNT(l.log_id) AS total_entries - FROM ' . LOG_TABLE . ' l, ' . USERS_TABLE . " u - WHERE l.log_type = $log_type - AND l.user_id = u.user_id - AND l.log_time >= $limit_days - $sql_keywords - $sql_forum"; - $result = $db->sql_query($sql); - $log_count = (int) $db->sql_fetchfield('total_entries'); - $db->sql_freeresult($result); - } + $count_logs = ($log_count !== false); - // $log_count may be false here if false was passed in for it, - // because in this case we did not run the COUNT() query above. - // If we ran the COUNT() query and it returned zero rows, return; - // otherwise query for logs below. - if ($log_count === 0) - { - // Save the queries, because there are no logs to display - return 0; - } + $log = $tmp_log->get_logs($mode, $count_logs, $limit, $offset, $forum_id, $topic_id, $user_id, $limit_days, $sort_by, $keywords); + $log_count = $tmp_log->get_log_count(); - if ($log_count) - { - // Return the user to the last page that is valid - while ($offset >= $log_count) - { - $offset = ($offset - $limit < 0) ? 0 : $offset - $limit; - } - } - - $sql = "SELECT l.*, u.username, u.username_clean, u.user_colour - FROM " . LOG_TABLE . " l, " . USERS_TABLE . " u - WHERE l.log_type = $log_type - AND u.user_id = l.user_id - " . (($limit_days) ? "AND l.log_time >= $limit_days" : '') . " - $sql_keywords - $sql_forum - ORDER BY $sort_by"; - $result = $db->sql_query_limit($sql, $limit, $offset); - - $i = 0; - $log = array(); - while ($row = $db->sql_fetchrow($result)) - { - $row['forum_id'] = (int) $row['forum_id']; - if ($row['topic_id']) - { - $topic_id_list[] = $row['topic_id']; - } - - if ($row['reportee_id']) - { - $reportee_id_list[] = $row['reportee_id']; - } - - $log[$i] = array( - 'id' => (int) $row['log_id'], - - 'reportee_id' => (int) $row['reportee_id'], - 'reportee_username' => '', - 'reportee_username_full'=> '', - - 'user_id' => (int) $row['user_id'], - 'username' => $row['username'], - 'username_full' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour'], false, $profile_url), - - 'ip' => $row['log_ip'], - 'time' => (int) $row['log_time'], - 'forum_id' => (int) $row['forum_id'], - 'topic_id' => (int) $row['topic_id'], - - 'viewforum' => ($row['forum_id'] && $auth->acl_get('f_read', $row['forum_id'])) ? append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $row['forum_id']) : false, - 'action' => (isset($user->lang[$row['log_operation']])) ? $user->lang[$row['log_operation']] : '{' . ucfirst(str_replace('_', ' ', $row['log_operation'])) . '}', - ); - - if (!empty($row['log_data'])) - { - $log_data_ary = @unserialize($row['log_data']); - $log_data_ary = ($log_data_ary === false) ? array() : $log_data_ary; - - if (isset($user->lang[$row['log_operation']])) - { - // Check if there are more occurrences of % than arguments, if there are we fill out the arguments array - // It doesn't matter if we add more arguments than placeholders - if ((substr_count($log[$i]['action'], '%') - sizeof($log_data_ary)) > 0) - { - $log_data_ary = array_merge($log_data_ary, array_fill(0, substr_count($log[$i]['action'], '%') - sizeof($log_data_ary), '')); - } - - $log[$i]['action'] = vsprintf($log[$i]['action'], $log_data_ary); - - // If within the admin panel we do not censor text out - if (defined('IN_ADMIN')) - { - $log[$i]['action'] = bbcode_nl2br($log[$i]['action']); - } - else - { - $log[$i]['action'] = bbcode_nl2br(censor_text($log[$i]['action'])); - } - } - else if (!empty($log_data_ary)) - { - $log[$i]['action'] .= '
    ' . implode('', $log_data_ary); - } - - /* Apply make_clickable... has to be seen if it is for good. :/ - // Seems to be not for the moment, reconsider later... - $log[$i]['action'] = make_clickable($log[$i]['action']); - */ - } - - $i++; - } - $db->sql_freeresult($result); - - if (sizeof($topic_id_list)) - { - $topic_id_list = array_unique($topic_id_list); - - // This query is not really needed if move_topics() updates the forum_id field, - // although it's also used to determine if the topic still exists in the database - $sql = 'SELECT topic_id, forum_id - FROM ' . TOPICS_TABLE . ' - WHERE ' . $db->sql_in_set('topic_id', array_map('intval', $topic_id_list)); - $result = $db->sql_query($sql); - - $default_forum_id = 0; - - while ($row = $db->sql_fetchrow($result)) - { - $row['forum_id'] = (int) $row['forum_id']; - if ($auth->acl_get('f_read', $row['forum_id'])) - { - $is_auth[$row['topic_id']] = $row['forum_id']; - } - - if ($auth->acl_gets('a_', 'm_', $row['forum_id'])) - { - $is_mod[$row['topic_id']] = $row['forum_id']; - } - } - $db->sql_freeresult($result); - - foreach ($log as $key => $row) - { - $log[$key]['viewtopic'] = (isset($is_auth[$row['topic_id']])) ? append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $is_auth[$row['topic_id']] . '&t=' . $row['topic_id']) : false; - $log[$key]['viewlogs'] = (isset($is_mod[$row['topic_id']])) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=logs&mode=topic_logs&t=' . $row['topic_id'], true, $user->session_id) : false; - } - } - - if (sizeof($reportee_id_list)) - { - $reportee_id_list = array_unique($reportee_id_list); - $reportee_names_list = array(); - - $sql = 'SELECT user_id, username, user_colour - FROM ' . USERS_TABLE . ' - WHERE ' . $db->sql_in_set('user_id', $reportee_id_list); - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $reportee_names_list[$row['user_id']] = $row; - } - $db->sql_freeresult($result); - - foreach ($log as $key => $row) - { - if (!isset($reportee_names_list[$row['reportee_id']])) - { - continue; - } - - $log[$key]['reportee_username'] = $reportee_names_list[$row['reportee_id']]['username']; - $log[$key]['reportee_username_full'] = get_username_string('full', $row['reportee_id'], $reportee_names_list[$row['reportee_id']]['username'], $reportee_names_list[$row['reportee_id']]['user_colour'], false, $profile_url); - } - } - - return $offset; + return $tmp_log->get_valid_offset(); } /** diff --git a/phpBB/includes/log/log.php b/phpBB/includes/log/log.php index 14f8bfd534..5d81dd8495 100644 --- a/phpBB/includes/log/log.php +++ b/phpBB/includes/log/log.php @@ -25,7 +25,7 @@ class phpbb_log implements phpbb_log_interface /** * Keeps the status of the log-system. Is the log enabled or disabled? */ - private $enabled; + private $disabled_logs; /** * Keeps the total log count of the last call to get_logs() @@ -56,31 +56,70 @@ class phpbb_log implements phpbb_log_interface /** * This function returns the state of the log-system. * - * @return bool True if log is enabled + * @param string $type The log type we want to check. Empty to get global log status. + * + * @return bool True if log for the type is enabled */ - public function is_enabled() + public function is_enabled($type = '') { - return $this->enabled; + if ($type == '' || $type == 'all') + { + return !isset($this->disabled_logs['all']); + } + return !isset($this->disabled_logs[$type]) && !isset($this->disabled_logs['all']); } /** * This function allows disable the log-system. When add_log is called, the log will not be added to the database. * + * @param mixed $type The log type we want to enable. Empty to disable all logs. + * Can also be an array of types + * * @return null */ - public function disable() + public function disable($type = '') { - $this->enabled = false; + if (is_array($type)) + { + foreach ($type as $disable_type) + { + $this->disable($disable_type); + } + return; + } + + if ($type == '' || $type == 'all') + { + $this->disabled_logs['all'] = true; + return; + } + $this->disabled_logs[$type] = true; } /** * This function allows re-enable the log-system. * + * @param mixed $type The log type we want to enable. Empty to enable all logs. + * * @return null */ - public function enable() + public function enable($type = '') { - $this->enabled = true; + if (is_array($type)) + { + foreach ($type as $enable_type) + { + $this->enable($enable_type); + } + return; + } + + if ($type == '' || $type == 'all') + { + $this->disabled_logs = array(); + return; + } + unset($this->disabled_logs[$type]); } /** @@ -90,7 +129,7 @@ class phpbb_log implements phpbb_log_interface */ public function add($mode, $user_id, $log_ip, $log_operation, $log_time = false, $additional_data = array()) { - if (!$this->is_enabled()) + if (!$this->is_enabled($mode)) { return false; } @@ -119,7 +158,7 @@ class phpbb_log implements phpbb_log_interface case 'admin': $sql_ary += array( 'log_type' => LOG_ADMIN, - 'log_data' => (!sizeof($additional_data)) ? '' : serialize($additional_data), + 'log_data' => (!empty($additional_data)) ? serialize($additional_data) : '', ); break; @@ -132,7 +171,7 @@ class phpbb_log implements phpbb_log_interface 'log_type' => LOG_MOD, 'forum_id' => $forum_id, 'topic_id' => $topic_id, - 'log_data' => (!sizeof($additional_data)) ? '' : serialize($additional_data), + 'log_data' => (!empty($additional_data)) ? serialize($additional_data) : '', ); break; @@ -143,14 +182,14 @@ class phpbb_log implements phpbb_log_interface $sql_ary += array( 'log_type' => LOG_USERS, 'reportee_id' => $reportee_id, - 'log_data' => (!sizeof($additional_data)) ? '' : serialize($additional_data), + 'log_data' => (!empty($additional_data)) ? serialize($additional_data) : '', ); break; case 'critical': $sql_ary += array( 'log_type' => LOG_CRITICAL, - 'log_data' => (!sizeof($additional_data)) ? '' : serialize($additional_data), + 'log_data' => (!empty($additional_data)) ? serialize($additional_data) : '', ); break; @@ -161,9 +200,7 @@ class phpbb_log implements phpbb_log_interface if ($phpbb_dispatcher != null) { $vars = array('mode', 'user_id', 'log_ip', 'log_operation', 'log_time', 'additional_data', 'sql_ary'); - $event = new phpbb_event_data(compact($vars)); - $phpbb_dispatcher->dispatch('core.add_log_case', $event); - extract($event->get_data_filtered($vars)); + extract($phpbb_dispatcher->trigger_event('core.add_log_case', $vars, $vars)); } */ @@ -180,9 +217,7 @@ class phpbb_log implements phpbb_log_interface if ($phpbb_dispatcher != null) { $vars = array('mode', 'user_id', 'log_ip', 'log_operation', 'log_time', 'additional_data', 'sql_ary'); - $event = new phpbb_event_data(compact($vars)); - $phpbb_dispatcher->dispatch('core.add_log', $event); - extract($event->get_data_filtered($vars)); + extract($phpbb_dispatcher->trigger_event('core.add_log', $vars, $vars)); } */ @@ -199,6 +234,11 @@ class phpbb_log implements phpbb_log_interface public function get_logs($mode, $count_logs = true, $limit = 0, $offset = 0, $forum_id = 0, $topic_id = 0, $user_id = 0, $log_time = 0, $sort_by = 'l.log_time DESC', $keywords = '') { global $db, $user, $auth, $phpEx, $phpbb_root_path, $phpbb_admin_path; + /** + * @todo: enable when events are merged + * + global $db, $user, $auth, $phpEx, $phpbb_root_path, $phpbb_admin_path, $phpbb_dispatcher; + */ $this->logs_total = 0; $this->logs_offset = $offset; @@ -256,9 +296,7 @@ class phpbb_log implements phpbb_log_interface if ($phpbb_dispatcher != null) { $vars = array('mode', 'count_logs', 'limit', 'offset', 'forum_id', 'topic_id', 'user_id', 'log_time', 'sort_by', 'keywords', 'profile_url', 'log_type', 'sql_additional'); - $event = new phpbb_event_data(compact($vars)); - $phpbb_dispatcher->dispatch('core.get_logs_switch_mode', $event); - extract($event->get_data_filtered($vars)); + extract($phpbb_dispatcher->trigger_event('core.get_logs_switch_mode', $vars, $vars)); } */ @@ -275,9 +313,7 @@ class phpbb_log implements phpbb_log_interface if ($phpbb_dispatcher != null) { $vars = array('mode', 'count_logs', 'limit', 'offset', 'forum_id', 'topic_id', 'user_id', 'log_time', 'sort_by', 'keywords', 'profile_url', 'log_type', 'sql_additional'); - $event = new phpbb_event_data(compact($vars)); - $phpbb_dispatcher->dispatch('core.get_logs_after_get_type', $event); - extract($event->get_data_filtered($vars)); + extract($phpbb_dispatcher->trigger_event('core.get_logs_after_get_type', $vars, $vars)); } */ @@ -311,12 +347,12 @@ class phpbb_log implements phpbb_log_interface // Return the user to the last page that is valid while ($this->logs_offset >= $this->logs_total) { - $this->logs_offset = ($this->logs_offset - $limit < 0) ? 0 : $this->logs_offset - $limit; + $this->logs_offset = max(0, $this->logs_offset - $limit); } } - $sql = "SELECT l.*, u.username, u.username_clean, u.user_colour - FROM " . LOG_TABLE . " l, " . USERS_TABLE . " u + $sql = 'SELECT l.*, u.username, u.username_clean, u.user_colour + FROM ' . LOG_TABLE . ' l, ' . USERS_TABLE . " u WHERE l.log_type = $log_type AND u.user_id = l.user_id " . (($log_time) ? "AND l.log_time >= $log_time" : '') . " @@ -366,9 +402,7 @@ class phpbb_log implements phpbb_log_interface if ($phpbb_dispatcher != null) { $vars = array('log_entry_data', 'row'); - $event = new phpbb_event_data(compact($vars)); - $phpbb_dispatcher->dispatch('core.get_logs_entry_data', $event); - extract($event->get_data_filtered($vars)); + extract($phpbb_dispatcher->trigger_event('core.get_logs_entry_data', $vars, $vars)); } */ @@ -377,7 +411,7 @@ class phpbb_log implements phpbb_log_interface if (!empty($row['log_data'])) { $log_data_ary = @unserialize($row['log_data']); - $log_data_ary = ($log_data_ary === false) ? array() : $log_data_ary; + $log_data_ary = ($log_data_ary !== false) ? $log_data_ary : array(); if (isset($user->lang[$row['log_operation']])) { @@ -421,9 +455,7 @@ class phpbb_log implements phpbb_log_interface if ($phpbb_dispatcher != null) { $vars = array('log', 'topic_id_list', 'reportee_id_list'); - $event = new phpbb_event_data(compact($vars)); - $phpbb_dispatcher->dispatch('core.get_logs_additional_data', $event); - extract($event->get_data_filtered($vars)); + extract($phpbb_dispatcher->trigger_event('core.get_logs_additional_data', $vars, $vars)); } */ @@ -498,7 +530,8 @@ class phpbb_log implements phpbb_log_interface { $sql_keywords .= $db->sql_in_set('l.log_operation', $operations) . ' OR '; } - $sql_keywords .= 'LOWER(l.log_data) ' . implode(' OR LOWER(l.log_data) ', $keywords) . ')'; + $sql_lower = $db->sql_lower_text('l.log_data'); + $sql_keywords .= " $sql_lower " . implode(" OR $sql_lower ", $keywords) . ')'; } return $sql_keywords; From 325827c40f778ef7efd3c195706cb0b1fb28805b Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 24 Mar 2012 16:43:26 +0100 Subject: [PATCH 0068/2494] [ticket/10714] Inject the global $phpbb_log into view_log() PHPBB3-10714 --- phpBB/common.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/phpBB/common.php b/phpBB/common.php index bbcf8b894f..799c1162b1 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -76,6 +76,7 @@ if (!empty($load_extensions) && function_exists('dl')) require($phpbb_root_path . 'includes/class_loader.' . $phpEx); require($phpbb_root_path . 'includes/functions.' . $phpEx); +require($phpbb_root_path . 'includes/functions_admin.' . $phpEx); require($phpbb_root_path . 'includes/functions_content.' . $phpEx); require($phpbb_root_path . 'includes/constants.' . $phpEx); @@ -142,6 +143,10 @@ foreach ($cache->obtain_hooks() as $hook) // make sure add_log uses this log instance $phpbb_log = new phpbb_log(LOG_TABLE); add_log($phpbb_log); // "dependency injection" for a function +// Parameter 2 and 3 are passed by reference, so we need to create a variable for it. +$tmp_var = ''; +view_log($phpbb_log, $tmp_var, $tmp_var); // "dependency injection" for a function +unset($tmp_var); if (!$config['use_system_cron']) { From 1e00c697b766d1a8695c8e058334efe1dd3dbb7e Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 24 Mar 2012 17:02:56 +0100 Subject: [PATCH 0069/2494] [ticket/10714] Add docblock for the test cases PHPBB3-10714 --- tests/log/function_add_log_test.php | 29 ++++++++++++++++ tests/log/function_view_log_test.php | 50 ++++++++++++++-------------- 2 files changed, 54 insertions(+), 25 deletions(-) diff --git a/tests/log/function_add_log_test.php b/tests/log/function_add_log_test.php index 1f54f66d2d..e7b3c4335f 100644 --- a/tests/log/function_add_log_test.php +++ b/tests/log/function_add_log_test.php @@ -19,6 +19,35 @@ class phpbb_log_function_add_log_test extends phpbb_database_test_case public static function test_add_log_function_data() { return array( + /** + * Case documentation + array( + // Row that is in the database afterwards + array( + 'user_id' => ANONYMOUS, + 'log_type' => LOG_MOD, + 'log_operation' => 'LOG_MOD_ADDITIONAL', + // log_data will be serialized + 'log_data' => array( + 'argument3', + ), + 'reportee_id' => 0, + 'forum_id' => 56, + 'topic_id' => 78, + ), + // user_id Can also be false, than ANONYMOUS is used + false, + // log_mode Used to determinate the log_type + 'mod', + // Followed by some additional arguments + // forum_id, topic_id and reportee_id are specified before log_operation + // The rest is specified afterwards. + 56, + 78, + 'LOG_MOD_ADDITIONAL', // log_operation + 'argument3', + ), + */ array( array( 'user_id' => 2, diff --git a/tests/log/function_view_log_test.php b/tests/log/function_view_log_test.php index 7c44413330..78bc2843a8 100644 --- a/tests/log/function_view_log_test.php +++ b/tests/log/function_view_log_test.php @@ -210,77 +210,77 @@ class phpbb_log_function_view_log_test extends phpbb_database_test_case ); $test_cases = array( + /** + * Case documentation + array( + // Array of datasets that should be in $log after running the function + 'expected' => array(5, 7), + // Offset that will be returned form the function + 'expected_returned' => 0, + // view_log parameters (see includes/functions_admin.php for docblock) + // $log is ommited! + 'mod', 5, 0, 12, 45, + ), + */ array( 'expected' => array(1, 2), 'expected_returned' => 0, - false, - 'admin', + 'admin', false, ), array( 'expected' => array(1), 'expected_returned' => 0, - false, - 'admin', 1, + 'admin', false, 1, ), array( 'expected' => array(2), 'expected_returned' => 1, - false, - 'admin', 1, 1, + 'admin', false, 1, 1, ), array( 'expected' => array(2), 'expected_returned' => 1, - 0, - 'admin', 1, 1, + 'admin', 0, 1, 1, ), array( 'expected' => array(2), 'expected_returned' => 1, - 0, - 'admin', 1, 5, + 'admin', 0, 1, 5, ), array( 'expected' => array(3), 'expected_returned' => 0, - false, - 'critical', + 'critical', false, ), array( 'expected' => array(), 'expected_returned' => null, - false, - 'mode_does_not_exist', + 'mode_does_not_exist', false, ), array( 'expected' => array(4, 5, 7), 'expected_returned' => 0, - 0, - 'mod', 5, 0, 12, + 'mod', 0, 5, 0, 12, ), array( 'expected' => array(5, 7), 'expected_returned' => 0, - 0, - 'mod', 5, 0, 12, 45, + 'mod', 0, 5, 0, 12, 45, ), array( 'expected' => array(6), 'expected_returned' => 0, - 0, - 'mod', 5, 0, 23, + 'mod', 0, 5, 0, 23, ), array( 'expected' => array(8), 'expected_returned' => 0, - 0, - 'user', 5, 0, 0, 0, 2, + 'user', 0, 5, 0, 0, 0, 2, ), array( 'expected' => array(8, 9), 'expected_returned' => 0, - 0, - 'users', + 'users', 0, ), ); @@ -298,7 +298,7 @@ class phpbb_log_function_view_log_test extends phpbb_database_test_case /** * @dataProvider test_view_log_function_data */ - public function test_view_log_function($expected, $expected_returned, $log_count, $mode, $limit = 5, $offset = 0, $forum_id = 0, $topic_id = 0, $user_id = 0, $limit_days = 0, $sort_by = 'l.log_id ASC', $keywords = '') + public function test_view_log_function($expected, $expected_returned, $mode, $log_count, $limit = 5, $offset = 0, $forum_id = 0, $topic_id = 0, $user_id = 0, $limit_days = 0, $sort_by = 'l.log_id ASC', $keywords = '') { global $cache, $db, $user, $auth; From 2c7f498c1b43cfb96f868e9b0f9b80ad5ec626a8 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 24 Mar 2012 17:13:17 +0100 Subject: [PATCH 0070/2494] [ticket/10714] Change $phpbb_dispatcher calls to the new layout PHPBB3-10714 --- phpBB/includes/functions.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 3e3d796ba2..c5a1543277 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -3407,9 +3407,7 @@ function add_log() if ($phpbb_dispatcher != null) { $vars = array('mode', 'args', 'additional_data'); - $event = new phpbb_event_data(compact($vars)); - $phpbb_dispatcher->dispatch('core.function_add_log', $event); - extract($event->get_data_filtered($vars)); + extract($phpbb_dispatcher->trigger_event('core.function_add_log', $vars, $vars)); } */ } From 3170845a5011ea76af7f4f8359acafb43ad7e19e Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 28 Mar 2012 15:48:45 +0200 Subject: [PATCH 0071/2494] [ticket/10714] Refactor disable mechanism to only disable certain types Only disable admin log when adding multiple users, so critical errors are still logged. PHPBB3-10714 --- phpBB/includes/functions_user.php | 4 ++-- phpBB/includes/log/interface.php | 16 ++++++++++++---- tests/log/add_test.php | 28 +++++++++++++++++++++++----- 3 files changed, 37 insertions(+), 11 deletions(-) diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index 4074eaa2f2..d1f1544fcd 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -302,7 +302,7 @@ function user_add($user_row, $cp_data = false) global $phpbb_log; // Because these actions only fill the log unneccessarily we skip the add_log() entry. - $phpbb_log->disable(); + $phpbb_log->disable('admin'); // Add user to "newly registered users" group and set to default group if admin specified so. if ($config['new_member_group_default']) @@ -315,7 +315,7 @@ function user_add($user_row, $cp_data = false) group_user_add($add_group_id, $user_id); } - $phpbb_log->enable(); + $phpbb_log->enable('admin'); } } diff --git a/phpBB/includes/log/interface.php b/phpBB/includes/log/interface.php index fde718b71a..feeab585bf 100644 --- a/phpBB/includes/log/interface.php +++ b/phpBB/includes/log/interface.php @@ -25,23 +25,31 @@ interface phpbb_log_interface /** * This function returns the state of the log-system. * - * @return bool True if log is enabled + * @param string $type The log type we want to check. Empty to get global log status. + * + * @return bool True if log for the type is enabled */ - public function is_enabled(); + public function is_enabled($type = ''); /** * This function allows disable the log-system. When add_log is called, the log will not be added to the database. * + * @param mixed $type The log type we want to disable. Empty to disable all logs. + * Can also be an array of types + * * @return null */ - public function disable(); + public function disable($type = ''); /** * This function allows re-enable the log-system. * + * @param mixed $type The log type we want to enable. Empty to enable all logs. + * Can also be an array of types + * * @return null */ - public function enable(); + public function enable($type = ''); /** * Adds a log to the database diff --git a/tests/log/add_test.php b/tests/log/add_test.php index a2b763f2b7..faf5953836 100644 --- a/tests/log/add_test.php +++ b/tests/log/add_test.php @@ -19,13 +19,21 @@ class phpbb_log_add_test extends phpbb_database_test_case public function test_log_enabled() { $log = new phpbb_log(LOG_TABLE); - $this->assertTrue($log->is_enabled()); + $this->assertTrue($log->is_enabled(), 'Initialise failed'); $log->disable(); - $this->assertFalse($log->is_enabled()); + $this->assertFalse($log->is_enabled(), 'Disable all failed'); $log->enable(); - $this->assertTrue($log->is_enabled()); + $this->assertTrue($log->is_enabled(), 'Enable all failed'); + + $log->disable('admin'); + $this->assertFalse($log->is_enabled('admin'), 'Disable admin failed'); + $this->assertTrue($log->is_enabled('user'), 'User should be enabled, is disabled'); + $this->assertTrue($log->is_enabled(), 'Disable admin disabled all'); + + $log->enable('admin'); + $this->assertTrue($log->is_enabled('admin'), 'Enable admin failed'); } public function test_log_add() @@ -45,9 +53,19 @@ class phpbb_log_add_test extends phpbb_database_test_case $log = new phpbb_log(LOG_TABLE); $this->assertEquals(1, $log->add($mode, $user_id, $log_ip, $log_operation, $log_time)); - // Disable logging + // Disable logging for all types $log->disable(); - $this->assertFalse($log->add($mode, $user_id, $log_ip, $log_operation, $log_time)); + $this->assertFalse($log->add($mode, $user_id, $log_ip, $log_operation, $log_time), 'Disable for all types failed'); + $log->enable(); + + // Disable logging for same type + $log->disable('critical'); + $this->assertFalse($log->add($mode, $user_id, $log_ip, $log_operation, $log_time), 'Disable for same type failed'); + $log->enable(); + + // Disable logging for different type + $log->disable('admin'); + $this->assertEquals(2, $log->add($mode, $user_id, $log_ip, $log_operation, $log_time), 'Disable for different types failed'); $log->enable(); // Invalid mode specified From 0fcbb40a0e1affcfa07a6d51ce273b73b3a95359 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 21 Aug 2012 12:40:55 +0200 Subject: [PATCH 0072/2494] [ticket/10714] Enable core.add_log event and remove superseded add_log_case PHPBB3-10714 --- phpBB/includes/log/log.php | 46 ++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 24 deletions(-) diff --git a/phpBB/includes/log/log.php b/phpBB/includes/log/log.php index 5d81dd8495..752ed21955 100644 --- a/phpBB/includes/log/log.php +++ b/phpBB/includes/log/log.php @@ -134,12 +134,7 @@ class phpbb_log implements phpbb_log_interface return false; } - global $db; - /** - * @todo: enable when events are merged - * global $db, $phpbb_dispatcher; - */ if ($log_time == false) { @@ -192,34 +187,37 @@ class phpbb_log implements phpbb_log_interface 'log_data' => (!empty($additional_data)) ? serialize($additional_data) : '', ); break; - - default: - /** - * @todo: enable when events are merged - * - if ($phpbb_dispatcher != null) - { - $vars = array('mode', 'user_id', 'log_ip', 'log_operation', 'log_time', 'additional_data', 'sql_ary'); - extract($phpbb_dispatcher->trigger_event('core.add_log_case', $vars, $vars)); - } - */ - - // We didn't find a log_type, so we don't save it in the database. - if (!isset($sql_ary['log_type'])) - { - return false; - } } /** - * @todo: enable when events are merged + * Allow to modify log data before we add them to the database * + * NOTE: if sql_ary does not contain a log_type value, the entry will + * not be stored in the database. So ensure to set it, if needed. + * + * @event core.add_log + * @var string mode Mode of the entry we log + * @var int user_id ID of the user who triggered the log + * @var string log_ip IP of the user who triggered the log + * @var string log_operation Language key of the log operation + * @var int log_time Timestamp, when the log was added + * @var array additional_data Array with additional log data + * @var array sql_ary Array with log data we insert into the + * database. If sql_ary[log_type] is not set, + * we won't add the entry to the database. + * @since 3.1-A1 + */ if ($phpbb_dispatcher != null) { $vars = array('mode', 'user_id', 'log_ip', 'log_operation', 'log_time', 'additional_data', 'sql_ary'); extract($phpbb_dispatcher->trigger_event('core.add_log', $vars, $vars)); } - */ + + // We didn't find a log_type, so we don't save it in the database. + if (!isset($sql_ary['log_type'])) + { + return false; + } $db->sql_query('INSERT INTO ' . $this->log_table . ' ' . $db->sql_build_array('INSERT', $sql_ary)); From bd6dfee23e0d3f11ff028d4376e73c9c1e770f2a Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 21 Aug 2012 13:06:43 +0200 Subject: [PATCH 0073/2494] [ticket/10714] Add event core.get_logs_modify_type core.get_logs_switch_mode is superseded by this one and therefor removed PHPBB3-10714 --- phpBB/includes/log/log.php | 53 +++++++++++++++++++++----------------- 1 file changed, 30 insertions(+), 23 deletions(-) diff --git a/phpBB/includes/log/log.php b/phpBB/includes/log/log.php index 752ed21955..97d0aac623 100644 --- a/phpBB/includes/log/log.php +++ b/phpBB/includes/log/log.php @@ -231,12 +231,7 @@ class phpbb_log implements phpbb_log_interface */ public function get_logs($mode, $count_logs = true, $limit = 0, $offset = 0, $forum_id = 0, $topic_id = 0, $user_id = 0, $log_time = 0, $sort_by = 'l.log_time DESC', $keywords = '') { - global $db, $user, $auth, $phpEx, $phpbb_root_path, $phpbb_admin_path; - /** - * @todo: enable when events are merged - * global $db, $user, $auth, $phpEx, $phpbb_root_path, $phpbb_admin_path, $phpbb_dispatcher; - */ $this->logs_total = 0; $this->logs_offset = $offset; @@ -288,32 +283,44 @@ class phpbb_log implements phpbb_log_interface default: $log_type = null; $sql_additional = ''; - /** - * @todo: enable when events are merged - * - if ($phpbb_dispatcher != null) - { - $vars = array('mode', 'count_logs', 'limit', 'offset', 'forum_id', 'topic_id', 'user_id', 'log_time', 'sort_by', 'keywords', 'profile_url', 'log_type', 'sql_additional'); - extract($phpbb_dispatcher->trigger_event('core.get_logs_switch_mode', $vars, $vars)); - } - */ - - if (!isset($log_type)) - { - $this->logs_offset = 0; - return array(); - } } /** - * @todo: enable when events are merged + * Overwrite log type and limitations before we count and get the logs * + * NOTE: if log_type is not set, no entries will be returned. + * + * @event core.get_logs_modify_type + * @var string mode Mode of the entries we display + * @var bool count_logs Do we count all matching entries? + * @var int limit Limit the number of entries + * @var int offset Offset when fetching the entries + * @var mixed forum_id Limit entries to the forum_id, + * can also be an array of forum_ids + * @var int topic_id Limit entries to the topic_id + * @var int user_id Limit entries to the user_id + * @var int log_time Limit maximum age of log entries + * @var string sort_by SQL order option + * @var string keywords Will only return entries that have the + * keywords in log_operation or log_data + * @var string profile_url URL to the users profile + * @var int log_type Limit logs to a certain type. If log_type + * is not set, no entries will be returned. + * @var string sql_additional Additional conditions for the entries, + * e.g.: 'AND l.forum_id = 1' + * @since 3.1-A1 + */ if ($phpbb_dispatcher != null) { $vars = array('mode', 'count_logs', 'limit', 'offset', 'forum_id', 'topic_id', 'user_id', 'log_time', 'sort_by', 'keywords', 'profile_url', 'log_type', 'sql_additional'); - extract($phpbb_dispatcher->trigger_event('core.get_logs_after_get_type', $vars, $vars)); + extract($phpbb_dispatcher->trigger_event('core.get_logs_modify_type', $vars)); + } + + if (!isset($log_type)) + { + $this->logs_offset = 0; + return array(); } - */ $sql_keywords = ''; if (!empty($keywords)) From 0bb4af90a4d9a1fedb254a1b6e9702726cfcf091 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 21 Aug 2012 13:07:11 +0200 Subject: [PATCH 0074/2494] [ticket/10714] Fix core.add_log event PHPBB3-10714 --- phpBB/includes/log/log.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/log/log.php b/phpBB/includes/log/log.php index 97d0aac623..92730aa7da 100644 --- a/phpBB/includes/log/log.php +++ b/phpBB/includes/log/log.php @@ -210,7 +210,7 @@ class phpbb_log implements phpbb_log_interface if ($phpbb_dispatcher != null) { $vars = array('mode', 'user_id', 'log_ip', 'log_operation', 'log_time', 'additional_data', 'sql_ary'); - extract($phpbb_dispatcher->trigger_event('core.add_log', $vars, $vars)); + extract($phpbb_dispatcher->trigger_event('core.add_log', $vars)); } // We didn't find a log_type, so we don't save it in the database. From cf095dd393a6540d092c6308bc03aab824376562 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 21 Aug 2012 13:12:50 +0200 Subject: [PATCH 0075/2494] [ticket/10714] Enable event core.get_logs_modify_entry_data PHPBB3-10714 --- phpBB/includes/log/log.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/phpBB/includes/log/log.php b/phpBB/includes/log/log.php index 92730aa7da..c95b334cad 100644 --- a/phpBB/includes/log/log.php +++ b/phpBB/includes/log/log.php @@ -402,14 +402,18 @@ class phpbb_log implements phpbb_log_interface ); /** - * @todo: enable when events are merged + * Modify the entry's data before it is returned * + * @event core.get_logs_modify_entry_data + * @var array row Entry data from the database + * @var array log_entry_data Entry's data which is returned + * @since 3.1-A1 + */ if ($phpbb_dispatcher != null) { - $vars = array('log_entry_data', 'row'); - extract($phpbb_dispatcher->trigger_event('core.get_logs_entry_data', $vars, $vars)); + $vars = array('row', 'log_entry_data'); + extract($phpbb_dispatcher->trigger_event('core.get_logs_modify_entry_data', $vars)); } - */ $log[$i] = $log_entry_data; From 701052481542cad1ab46fb5e48cf5bbd139030b8 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 21 Aug 2012 13:19:13 +0200 Subject: [PATCH 0076/2494] [ticket/10714] Enable event core.get_logs_get_additional_data PHPBB3-10714 --- phpBB/includes/log/log.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/phpBB/includes/log/log.php b/phpBB/includes/log/log.php index c95b334cad..ef74f6aaf4 100644 --- a/phpBB/includes/log/log.php +++ b/phpBB/includes/log/log.php @@ -459,14 +459,21 @@ class phpbb_log implements phpbb_log_interface $db->sql_freeresult($result); /** - * @todo: enable when events are merged + * Get some additional data after we got all log entries * + * @event core.get_logs_get_additional_data + * @var array log Array with all our log entries + * @var array topic_id_list Array of topic ids, for which we + * get the permission data + * @var array reportee_id_list Array of additional user IDs we + * get the username strings for + * @since 3.1-A1 + */ if ($phpbb_dispatcher != null) { $vars = array('log', 'topic_id_list', 'reportee_id_list'); - extract($phpbb_dispatcher->trigger_event('core.get_logs_additional_data', $vars, $vars)); + extract($phpbb_dispatcher->trigger_event('core.get_logs_get_additional_data', $vars)); } - */ if (sizeof($topic_id_list)) { From 151346c6e053e925b5cfcf2845eca532509bbc80 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 21 Aug 2012 13:25:26 +0200 Subject: [PATCH 0077/2494] [ticket/10714] Remove event core.function_add_log, add_log should be used instead PHPBB3-10714 --- phpBB/includes/functions.php | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index c5a1543277..b5d0c4d62f 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -3398,18 +3398,6 @@ function add_log() case 'user': $additional_data['reportee_id'] = array_shift($args); break; - default: - /** - * @todo: enable when events are merged - * - global $phpbb_dispatcher; - - if ($phpbb_dispatcher != null) - { - $vars = array('mode', 'args', 'additional_data'); - extract($phpbb_dispatcher->trigger_event('core.function_add_log', $vars, $vars)); - } - */ } $log_operation = array_shift($args); $additional_data = array_merge($additional_data, $args); From 2afbec5ac425b8913c2d3e3193b195190b7185db Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 21 Aug 2012 15:50:46 +0200 Subject: [PATCH 0078/2494] [ticket/10714] Always try to trigger events on phpbb_dispatcher We may add the if () later again, if we decide to do that. PHPBB3-10714 --- phpBB/includes/log/log.php | 28 ++++++++-------------------- 1 file changed, 8 insertions(+), 20 deletions(-) diff --git a/phpBB/includes/log/log.php b/phpBB/includes/log/log.php index ef74f6aaf4..780881ae13 100644 --- a/phpBB/includes/log/log.php +++ b/phpBB/includes/log/log.php @@ -207,11 +207,8 @@ class phpbb_log implements phpbb_log_interface * we won't add the entry to the database. * @since 3.1-A1 */ - if ($phpbb_dispatcher != null) - { - $vars = array('mode', 'user_id', 'log_ip', 'log_operation', 'log_time', 'additional_data', 'sql_ary'); - extract($phpbb_dispatcher->trigger_event('core.add_log', $vars)); - } + $vars = array('mode', 'user_id', 'log_ip', 'log_operation', 'log_time', 'additional_data', 'sql_ary'); + extract($phpbb_dispatcher->trigger_event('core.add_log', $vars)); // We didn't find a log_type, so we don't save it in the database. if (!isset($sql_ary['log_type'])) @@ -310,11 +307,8 @@ class phpbb_log implements phpbb_log_interface * e.g.: 'AND l.forum_id = 1' * @since 3.1-A1 */ - if ($phpbb_dispatcher != null) - { - $vars = array('mode', 'count_logs', 'limit', 'offset', 'forum_id', 'topic_id', 'user_id', 'log_time', 'sort_by', 'keywords', 'profile_url', 'log_type', 'sql_additional'); - extract($phpbb_dispatcher->trigger_event('core.get_logs_modify_type', $vars)); - } + $vars = array('mode', 'count_logs', 'limit', 'offset', 'forum_id', 'topic_id', 'user_id', 'log_time', 'sort_by', 'keywords', 'profile_url', 'log_type', 'sql_additional'); + extract($phpbb_dispatcher->trigger_event('core.get_logs_modify_type', $vars)); if (!isset($log_type)) { @@ -409,11 +403,8 @@ class phpbb_log implements phpbb_log_interface * @var array log_entry_data Entry's data which is returned * @since 3.1-A1 */ - if ($phpbb_dispatcher != null) - { - $vars = array('row', 'log_entry_data'); - extract($phpbb_dispatcher->trigger_event('core.get_logs_modify_entry_data', $vars)); - } + $vars = array('row', 'log_entry_data'); + extract($phpbb_dispatcher->trigger_event('core.get_logs_modify_entry_data', $vars)); $log[$i] = $log_entry_data; @@ -469,11 +460,8 @@ class phpbb_log implements phpbb_log_interface * get the username strings for * @since 3.1-A1 */ - if ($phpbb_dispatcher != null) - { - $vars = array('log', 'topic_id_list', 'reportee_id_list'); - extract($phpbb_dispatcher->trigger_event('core.get_logs_get_additional_data', $vars)); - } + $vars = array('log', 'topic_id_list', 'reportee_id_list'); + extract($phpbb_dispatcher->trigger_event('core.get_logs_get_additional_data', $vars)); if (sizeof($topic_id_list)) { From d828ef93f29eda5fe31a6f8291dd1e5b3cdfd97c Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 21 Aug 2012 16:00:01 +0200 Subject: [PATCH 0079/2494] [ticket/10714] Fix unit test because of events and moved files PHPBB3-10714 --- tests/log/add_test.php | 3 ++- tests/log/function_add_log_test.php | 3 ++- tests/log/function_view_log_test.php | 8 ++++---- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/tests/log/add_test.php b/tests/log/add_test.php index faf5953836..fceb48ed01 100644 --- a/tests/log/add_test.php +++ b/tests/log/add_test.php @@ -38,9 +38,10 @@ class phpbb_log_add_test extends phpbb_database_test_case public function test_log_add() { - global $db; + global $db, $phpbb_dispatcher; $db = $this->new_dbal(); + $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); $mode = 'critical'; $user_id = ANONYMOUS; diff --git a/tests/log/function_add_log_test.php b/tests/log/function_add_log_test.php index e7b3c4335f..77c4578baa 100644 --- a/tests/log/function_add_log_test.php +++ b/tests/log/function_add_log_test.php @@ -142,7 +142,7 @@ class phpbb_log_function_add_log_test extends phpbb_database_test_case */ public function test_add_log_function($expected, $user_id, $mode, $required1, $additional1 = null, $additional2 = null, $additional3 = null) { - global $db, $user; + global $db, $user, $phpbb_dispatcher; if ($expected) { @@ -155,6 +155,7 @@ class phpbb_log_function_add_log_test extends phpbb_database_test_case } $db = $this->new_dbal(); + $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); $user->ip = 'user_ip'; if ($user_id) diff --git a/tests/log/function_view_log_test.php b/tests/log/function_view_log_test.php index 78bc2843a8..790597e9c8 100644 --- a/tests/log/function_view_log_test.php +++ b/tests/log/function_view_log_test.php @@ -7,13 +7,12 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/auth.php'; require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; require_once dirname(__FILE__) . '/../../phpBB/includes/functions_admin.php'; require_once dirname(__FILE__) . '/../../phpBB/includes/functions_content.php'; require_once dirname(__FILE__) . '/../../phpBB/includes/utf/utf_tools.php'; require_once dirname(__FILE__) . '/../../phpBB/includes/session.php'; -require_once dirname(__FILE__) . '/../mock_user.php'; +require_once dirname(__FILE__) . '/../mock/user.php'; require_once dirname(__FILE__) . '/../mock/cache.php'; class phpbb_log_function_view_log_test extends phpbb_database_test_case @@ -300,13 +299,14 @@ class phpbb_log_function_view_log_test extends phpbb_database_test_case */ public function test_view_log_function($expected, $expected_returned, $mode, $log_count, $limit = 5, $offset = 0, $forum_id = 0, $topic_id = 0, $user_id = 0, $limit_days = 0, $sort_by = 'l.log_id ASC', $keywords = '') { - global $cache, $db, $user, $auth; + global $cache, $db, $user, $auth, $phpbb_dispatcher; $db = $this->new_dbal(); $cache = new phpbb_mock_cache; + $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); // Create auth mock - $auth = $this->getMock('auth'); + $auth = $this->getMock('phpbb_auth'); $acl_get_map = array( array('f_read', 23, true), array('m_', 23, true), From d289bc13acc0ab0329cac25742ae22560a80c607 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 21 Aug 2012 16:49:08 +0200 Subject: [PATCH 0080/2494] [ticket/10714] Remove dependency injection and use global instead This avoids loading functions_admin.php globally and was suggested by naderman PHPBB3-10714 --- phpBB/common.php | 11 ++--------- phpBB/includes/functions.php | 19 +++++-------------- phpBB/includes/functions_admin.php | 26 ++++++-------------------- 3 files changed, 13 insertions(+), 43 deletions(-) diff --git a/phpBB/common.php b/phpBB/common.php index 799c1162b1..2d2b31df83 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -76,7 +76,6 @@ if (!empty($load_extensions) && function_exists('dl')) require($phpbb_root_path . 'includes/class_loader.' . $phpEx); require($phpbb_root_path . 'includes/functions.' . $phpEx); -require($phpbb_root_path . 'includes/functions_admin.' . $phpEx); require($phpbb_root_path . 'includes/functions_content.' . $phpEx); require($phpbb_root_path . 'includes/constants.' . $phpEx); @@ -119,6 +118,8 @@ $config = new phpbb_config_db($db, $cache->get_driver(), CONFIG_TABLE); set_config(null, null, null, $config); set_config_count(null, null, null, $config); +$phpbb_log = new phpbb_log(LOG_TABLE); + // load extensions $phpbb_extension_manager = new phpbb_extension_manager($db, EXT_TABLE, $phpbb_root_path, ".$phpEx", $cache->get_driver()); @@ -140,14 +141,6 @@ foreach ($cache->obtain_hooks() as $hook) @include($phpbb_root_path . 'includes/hooks/' . $hook . '.' . $phpEx); } -// make sure add_log uses this log instance -$phpbb_log = new phpbb_log(LOG_TABLE); -add_log($phpbb_log); // "dependency injection" for a function -// Parameter 2 and 3 are passed by reference, so we need to create a variable for it. -$tmp_var = ''; -view_log($phpbb_log, $tmp_var, $tmp_var); // "dependency injection" for a function -unset($tmp_var); - if (!$config['use_system_cron']) { $cron = new phpbb_cron_manager(new phpbb_cron_task_provider($phpbb_extension_manager), $cache->get_driver()); diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index b5d0c4d62f..e202273204 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -3357,29 +3357,20 @@ function parse_cfg_file($filename, $lines = false) */ function add_log() { - // This is all just an ugly hack to add "Dependency Injection" to a function - // the only real code is the function call which maps this function to a method. - static $static_log = null; + global $phpbb_log; $args = func_get_args(); $log = (isset($args[0])) ? $args[0] : false; - if ($log instanceof phpbb_log_interface) - { - $static_log = $log; - return true; - } - else if ($log === false) + if ($log === false) { return false; } - $tmp_log = $static_log; - // no log class set, create a temporary one ourselves to keep backwards compatability - if ($tmp_log === null) + if ($phpbb_log === null) { - $tmp_log = new phpbb_log(LOG_TABLE); + $phpbb_log = new phpbb_log(LOG_TABLE); } $mode = array_shift($args); @@ -3407,7 +3398,7 @@ function add_log() $user_id = (empty($user->data)) ? ANONYMOUS : $user->data['user_id']; $user_ip = (empty($user->ip)) ? '' : $user->ip; - return $tmp_log->add($mode, $user_id, $user_ip, $log_operation, time(), $additional_data); + return $phpbb_log->add($mode, $user_id, $user_ip, $log_operation, time(), $additional_data); } /** diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index e7aed85e15..2a87feed51 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -2488,34 +2488,20 @@ function cache_moderators() */ function view_log($mode, &$log, &$log_count, $limit = 0, $offset = 0, $forum_id = 0, $topic_id = 0, $user_id = 0, $limit_days = 0, $sort_by = 'l.log_time DESC', $keywords = '') { - // This is all just an ugly hack to add "Dependency Injection" to a function - // the only real code is the function call which maps this function to a method. - static $static_log = null; - - if ($mode instanceof phpbb_log_interface) - { - $static_log = $mode; - return true; - } - else if ($mode === false) - { - return false; - } - - $tmp_log = $static_log; + global $phpbb_log; // no log class set, create a temporary one ourselves to keep backwards compatability - if ($tmp_log === null) + if ($phpbb_log === null) { - $tmp_log = new phpbb_log(LOG_TABLE); + $phpbb_log = new phpbb_log(LOG_TABLE); } $count_logs = ($log_count !== false); - $log = $tmp_log->get_logs($mode, $count_logs, $limit, $offset, $forum_id, $topic_id, $user_id, $limit_days, $sort_by, $keywords); - $log_count = $tmp_log->get_log_count(); + $log = $phpbb_log->get_logs($mode, $count_logs, $limit, $offset, $forum_id, $topic_id, $user_id, $limit_days, $sort_by, $keywords); + $log_count = $phpbb_log->get_log_count(); - return $tmp_log->get_valid_offset(); + return $phpbb_log->get_valid_offset(); } /** From b8c55291ed7ed86565be2bc651bf20eb1a9ed4dd Mon Sep 17 00:00:00 2001 From: Josh Woody Date: Thu, 17 Jun 2010 23:58:18 -0500 Subject: [PATCH 0081/2494] [feature/soft-delete] Lay the groundwork for a soft-delete feature So far, I've added no new functionality. The biggest change here is adjusting the DB column names to "visibility" rather than "approved". Some things here are pretty likely to change, for example the name and location of the topic_visibility class. Happy birthday phpBB :) PHPBB3-9657 --- phpBB/common.php | 3 + phpBB/develop/create_schema_files.php | 10 +- phpBB/develop/mysql_upgrader.php | 10 +- phpBB/docs/README.html | 4 - phpBB/feed.php | 28 +- phpBB/includes/acp/acp_forums.php | 8 +- phpBB/includes/acp/acp_main.php | 6 +- phpBB/includes/acp/acp_users.php | 4 +- phpBB/includes/constants.php | 4 + phpBB/includes/functions_admin.php | 77 +- phpBB/includes/functions_convert.php | 6 +- phpBB/includes/functions_posting.php | 64 +- phpBB/includes/mcp/mcp_forum.php | 10 +- phpBB/includes/mcp/mcp_front.php | 4 +- phpBB/includes/mcp/mcp_main.php | 12 +- phpBB/includes/mcp/mcp_post.php | 4 +- phpBB/includes/mcp/mcp_queue.php | 12 +- phpBB/includes/mcp/mcp_reports.php | 2 +- phpBB/includes/mcp/mcp_topic.php | 22 +- phpBB/includes/search/fulltext_mysql.php | 14 +- phpBB/includes/search/fulltext_native.php | 15 +- phpBB/install/install_convert.php | 2 +- phpBB/install/schemas/firebird_schema.sql | 2732 ++++++++-------- phpBB/install/schemas/mssql_schema.sql | 3312 ++++++++++--------- phpBB/install/schemas/mysql_40_schema.sql | 1954 ++++++----- phpBB/install/schemas/mysql_41_schema.sql | 1954 ++++++----- phpBB/install/schemas/oracle_schema.sql | 3572 ++++++++++----------- phpBB/install/schemas/postgres_schema.sql | 2476 +++++++------- phpBB/install/schemas/schema_data.sql | 2 + phpBB/install/schemas/sqlite_schema.sql | 1898 ++++++----- phpBB/mcp.php | 10 +- phpBB/memberlist.php | 2 +- phpBB/posting.php | 18 +- phpBB/search.php | 19 +- phpBB/viewforum.php | 11 +- phpBB/viewtopic.php | 32 +- 36 files changed, 9164 insertions(+), 9149 deletions(-) diff --git a/phpBB/common.php b/phpBB/common.php index c7c5859c25..6e226aea9f 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -82,6 +82,9 @@ require($phpbb_root_path . 'includes/constants.' . $phpEx); require($phpbb_root_path . 'includes/db/' . $dbms . '.' . $phpEx); require($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx); + +include($phpbb_root_path . 'includes/class_visibility.'.$phpEx); + // Set PHP error handler to ours set_error_handler(defined('PHPBB_MSG_HANDLER') ? PHPBB_MSG_HANDLER : 'msg_handler'); diff --git a/phpBB/develop/create_schema_files.php b/phpBB/develop/create_schema_files.php index 6eb4a80199..6ef73266ba 100644 --- a/phpBB/develop/create_schema_files.php +++ b/phpBB/develop/create_schema_files.php @@ -1331,7 +1331,7 @@ function get_schema_struct() 'icon_id' => array('UINT', 0), 'poster_ip' => array('VCHAR:40', ''), 'post_time' => array('TIMESTAMP', 0), - 'post_approved' => array('BOOL', 1), + 'post_visibility' => array('TINT:3', 0), 'post_reported' => array('BOOL', 0), 'enable_bbcode' => array('BOOL', 1), 'enable_smilies' => array('BOOL', 1), @@ -1357,7 +1357,7 @@ function get_schema_struct() 'topic_id' => array('INDEX', 'topic_id'), 'poster_ip' => array('INDEX', 'poster_ip'), 'poster_id' => array('INDEX', 'poster_id'), - 'post_approved' => array('INDEX', 'post_approved'), + 'post_visibility' => array('INDEX', 'post_visibility'), 'post_username' => array('INDEX', 'post_username'), 'tid_post_time' => array('INDEX', array('topic_id', 'post_time')), ), @@ -1673,7 +1673,7 @@ function get_schema_struct() 'forum_id' => array('UINT', 0), 'icon_id' => array('UINT', 0), 'topic_attachment' => array('BOOL', 0), - 'topic_approved' => array('BOOL', 1), + 'topic_visibility' => array('TINT:3', 0), 'topic_reported' => array('BOOL', 0), 'topic_title' => array('STEXT_UNI', '', 'true_sort'), 'topic_poster' => array('UINT', 0), @@ -1709,8 +1709,8 @@ function get_schema_struct() 'forum_id' => array('INDEX', 'forum_id'), 'forum_id_type' => array('INDEX', array('forum_id', 'topic_type')), 'last_post_time' => array('INDEX', 'topic_last_post_time'), - 'topic_approved' => array('INDEX', 'topic_approved'), - 'forum_appr_last' => array('INDEX', array('forum_id', 'topic_approved', 'topic_last_post_id')), + 'topic_visibility' => array('INDEX', 'topic_visibility'), + 'forum_appr_last' => array('INDEX', array('forum_id', 'topic_visibility', 'topic_last_post_id')), 'fid_time_moved' => array('INDEX', array('forum_id', 'topic_last_post_time', 'topic_moved_id')), ), ); diff --git a/phpBB/develop/mysql_upgrader.php b/phpBB/develop/mysql_upgrader.php index 7f82ebfeab..3d3891c7b9 100644 --- a/phpBB/develop/mysql_upgrader.php +++ b/phpBB/develop/mysql_upgrader.php @@ -768,7 +768,7 @@ function get_schema_struct() 'icon_id' => array('UINT', 0), 'poster_ip' => array('VCHAR:40', ''), 'post_time' => array('TIMESTAMP', 0), - 'post_approved' => array('BOOL', 1), + 'post_visibility' => array('TINT:3', 0), 'post_reported' => array('BOOL', 0), 'enable_bbcode' => array('BOOL', 1), 'enable_smilies' => array('BOOL', 1), @@ -794,7 +794,7 @@ function get_schema_struct() 'topic_id' => array('INDEX', 'topic_id'), 'poster_ip' => array('INDEX', 'poster_ip'), 'poster_id' => array('INDEX', 'poster_id'), - 'post_approved' => array('INDEX', 'post_approved'), + 'post_visibility' => array('INDEX', 'post_visibility'), 'post_username' => array('INDEX', 'post_username'), 'tid_post_time' => array('INDEX', array('topic_id', 'post_time')), ), @@ -1107,7 +1107,7 @@ function get_schema_struct() 'forum_id' => array('UINT', 0), 'icon_id' => array('UINT', 0), 'topic_attachment' => array('BOOL', 0), - 'topic_approved' => array('BOOL', 1), + 'topic_visibility' => array('TINT:3', 0), 'topic_reported' => array('BOOL', 0), 'topic_title' => array('STEXT_UNI', '', 'true_sort'), 'topic_poster' => array('UINT', 0), @@ -1143,8 +1143,8 @@ function get_schema_struct() 'forum_id' => array('INDEX', 'forum_id'), 'forum_id_type' => array('INDEX', array('forum_id', 'topic_type')), 'last_post_time' => array('INDEX', 'topic_last_post_time'), - 'topic_approved' => array('INDEX', 'topic_approved'), - 'forum_appr_last' => array('INDEX', array('forum_id', 'topic_approved', 'topic_last_post_id')), + 'topic_visibility' => array('INDEX', 'topic_visibility'), + 'forum_appr_last' => array('INDEX', array('forum_id', 'topic_visibility', 'topic_last_post_id')), 'fid_time_moved' => array('INDEX', array('forum_id', 'topic_last_post_time', 'topic_moved_id')), ), ); diff --git a/phpBB/docs/README.html b/phpBB/docs/README.html index 8f9e960275..9bd6f13bf4 100644 --- a/phpBB/docs/README.html +++ b/phpBB/docs/README.html @@ -324,11 +324,7 @@

    Please remember that running any application on a developmental version of PHP can lead to strange/unexpected results which may appear to be bugs in the application (which may not be true). Therefore we recommend you upgrade to the newest stable version of PHP before running phpBB3. If you are running a developmental version of PHP please check any bugs you find on a system running a stable release before submitting.

    -<<<<<<< HEAD

    This board has been developed and tested under Linux and Windows (amongst others) running Apache using MySQL 3.23, 4.x, 5.x, MSSQL Server 2000, PostgreSQL 8.x, Oracle 8, SQLite and Firebird. Versions of PHP used range from 5.3.x to 5.4.x without problem.

    -======= -

    This board has been developed and tested under Linux and Windows (amongst others) running Apache using MySQL 3.23, 4.x, 5.x, MSSQL Server 2000, PostgreSQL 7.x, Oracle 8, SQLite 2 and Firebird. Versions of PHP used range from 4.3.3 to 5.4.x without problem.

    ->>>>>>> develop-olympus

    7.i. Notice on PHP security issues

    diff --git a/phpBB/feed.php b/phpBB/feed.php index 9b7ef3a575..a806cdd608 100644 --- a/phpBB/feed.php +++ b/phpBB/feed.php @@ -681,7 +681,7 @@ class phpbb_feed_post_base extends phpbb_feed_base { $item_row['statistics'] = $user->lang['POSTED'] . ' ' . $user->lang['POST_BY_AUTHOR'] . ' ' . $this->user_viewprofile($row) . ' ' . $this->separator_stats . ' ' . $user->format_date($row[$this->get('published')]) - . (($this->is_moderator_approve_forum($row['forum_id']) && !$row['post_approved']) ? ' ' . $this->separator_stats . ' ' . $user->lang['POST_UNAPPROVED'] : ''); + . (($this->is_moderator_approve_forum($row['forum_id']) && $row['post_visibility'] !== ITEM_APPROVED) ? ' ' . $this->separator_stats . ' ' . $user->lang['POST_UNAPPROVED'] : ''); } } } @@ -760,8 +760,7 @@ class phpbb_feed_overall extends phpbb_feed_post_base FROM ' . TOPICS_TABLE . ' WHERE ' . $db->sql_in_set('forum_id', $forum_ids) . ' AND topic_moved_id = 0 - AND (topic_approved = 1 - ' . $sql_m_approve . ') + AND ' . topic_visibility::get_visibility_sql_global('topic') . ' ORDER BY topic_last_post_time DESC'; $result = $db->sql_query_limit($sql, $this->num_items); @@ -783,7 +782,7 @@ class phpbb_feed_overall extends phpbb_feed_post_base // Get the actual data $this->sql = array( 'SELECT' => 'f.forum_id, f.forum_name, ' . - 'p.post_id, p.topic_id, p.post_time, p.post_edit_time, p.post_approved, p.post_subject, p.post_text, p.bbcode_bitfield, p.bbcode_uid, p.enable_bbcode, p.enable_smilies, p.enable_magic_url, ' . + 'p.post_id, p.topic_id, p.post_time, p.post_edit_time, p.post_visibility, p.post_subject, p.post_text, p.bbcode_bitfield, p.bbcode_uid, p.enable_bbcode, p.enable_smilies, p.enable_magic_url, ' . 'u.username, u.user_id', 'FROM' => array( USERS_TABLE => 'u', @@ -796,8 +795,7 @@ class phpbb_feed_overall extends phpbb_feed_post_base ), ), 'WHERE' => $db->sql_in_set('p.topic_id', $topic_ids) . ' - AND (p.post_approved = 1 - ' . str_replace('forum_id', 'p.forum_id', $sql_m_approve) . ') + AND ' . topic_visibility::get_visibility_sql('post', array(), 'p.') . ' AND p.post_time >= ' . $min_post_time . ' AND u.user_id = p.poster_id', 'ORDER_BY' => 'p.post_time DESC', @@ -894,7 +892,7 @@ class phpbb_feed_forum extends phpbb_feed_post_base FROM ' . TOPICS_TABLE . ' WHERE forum_id = ' . $this->forum_id . ' AND topic_moved_id = 0 - ' . ((!$m_approve) ? 'AND topic_approved = 1' : '') . ' + AND ' . topic_visibility::get_visibility_sql('topic', $this->forum_id) . ' ORDER BY topic_last_post_time DESC'; $result = $db->sql_query_limit($sql, $this->num_items); @@ -914,14 +912,14 @@ class phpbb_feed_forum extends phpbb_feed_post_base } $this->sql = array( - 'SELECT' => 'p.post_id, p.topic_id, p.post_time, p.post_edit_time, p.post_approved, p.post_subject, p.post_text, p.bbcode_bitfield, p.bbcode_uid, p.enable_bbcode, p.enable_smilies, p.enable_magic_url, ' . + 'SELECT' => 'p.post_id, p.topic_id, p.post_time, p.post_edit_time, p.post_visibility, p.post_subject, p.post_text, p.bbcode_bitfield, p.bbcode_uid, p.enable_bbcode, p.enable_smilies, p.enable_magic_url, ' . 'u.username, u.user_id', 'FROM' => array( POSTS_TABLE => 'p', USERS_TABLE => 'u', ), 'WHERE' => $db->sql_in_set('p.topic_id', $topic_ids) . ' - ' . ((!$m_approve) ? 'AND p.post_approved = 1' : '') . ' + AND ' . topic_visibility::get_visibility_sql('post', $this->forum_id, 'p.') . ' AND p.post_time >= ' . $min_post_time . ' AND p.poster_id = u.user_id', 'ORDER_BY' => 'p.post_time DESC', @@ -967,7 +965,7 @@ class phpbb_feed_topic extends phpbb_feed_post_base { global $auth, $db, $user; - $sql = 'SELECT f.forum_options, f.forum_password, t.topic_id, t.forum_id, t.topic_approved, t.topic_title, t.topic_time, t.topic_views, t.topic_replies, t.topic_type + $sql = 'SELECT f.forum_options, f.forum_password, t.topic_id, t.forum_id, t.topic_visibility, t.topic_title, t.topic_time, t.topic_views, t.topic_replies, t.topic_type FROM ' . TOPICS_TABLE . ' t LEFT JOIN ' . FORUMS_TABLE . ' f ON (f.forum_id = t.forum_id) @@ -1020,14 +1018,14 @@ class phpbb_feed_topic extends phpbb_feed_post_base global $auth, $db; $this->sql = array( - 'SELECT' => 'p.post_id, p.post_time, p.post_edit_time, p.post_approved, p.post_subject, p.post_text, p.bbcode_bitfield, p.bbcode_uid, p.enable_bbcode, p.enable_smilies, p.enable_magic_url, ' . + 'SELECT' => 'p.post_id, p.post_time, p.post_edit_time, p.post_visibility, p.post_subject, p.post_text, p.bbcode_bitfield, p.bbcode_uid, p.enable_bbcode, p.enable_smilies, p.enable_magic_url, ' . 'u.username, u.user_id', 'FROM' => array( POSTS_TABLE => 'p', USERS_TABLE => 'u', ), 'WHERE' => 'p.topic_id = ' . $this->topic_id . ' - ' . ($this->forum_id && !$auth->acl_get('m_approve', $this->forum_id) ? 'AND p.post_approved = 1' : '') . ' + AND ' . topic_visibility::get_visibility_sql('post', $this->forum_id, 'p.') . ' AND p.poster_id = u.user_id', 'ORDER_BY' => 'p.post_time DESC', ); @@ -1163,7 +1161,7 @@ class phpbb_feed_news extends phpbb_feed_topic_base FROM ' . TOPICS_TABLE . ' WHERE ' . $db->sql_in_set('forum_id', $in_fid_ary) . ' AND topic_moved_id = 0 - AND topic_approved = 1 + AND topic_visibility = ' . ITEM_APPROVED . ' ORDER BY topic_time DESC'; $result = $db->sql_query_limit($sql, $this->num_items); @@ -1233,7 +1231,7 @@ class phpbb_feed_topics extends phpbb_feed_topic_base FROM ' . TOPICS_TABLE . ' WHERE ' . $db->sql_in_set('forum_id', $in_fid_ary) . ' AND topic_moved_id = 0 - AND topic_approved = 1 + AND topic_visibility = ' . ITEM_APPROVED .' ORDER BY topic_time DESC'; $result = $db->sql_query_limit($sql, $this->num_items); @@ -1325,7 +1323,7 @@ class phpbb_feed_topics_active extends phpbb_feed_topic_base FROM ' . TOPICS_TABLE . ' WHERE ' . $db->sql_in_set('forum_id', $in_fid_ary) . ' AND topic_moved_id = 0 - AND topic_approved = 1 + AND topic_visibility = ' . ITEM_APPROVED . ' ' . $last_post_time_sql . ' ORDER BY topic_last_post_time DESC'; $result = $db->sql_query_limit($sql, $this->num_items); diff --git a/phpBB/includes/acp/acp_forums.php b/phpBB/includes/acp/acp_forums.php index c6dbf5eb9c..622d84d15e 100644 --- a/phpBB/includes/acp/acp_forums.php +++ b/phpBB/includes/acp/acp_forums.php @@ -314,7 +314,7 @@ class acp_forums $end = $start + $batch_size; // Sync all topics in batch mode... - sync('topic_approved', 'range', 'topic_id BETWEEN ' . $start . ' AND ' . $end, true, false); + sync('topic_visibility', 'range', 'topic_id BETWEEN ' . $start . ' AND ' . $end, true, false); sync('topic', 'range', 'topic_id BETWEEN ' . $start . ' AND ' . $end, true, true); if ($end < $row2['max_topic_id']) @@ -1793,7 +1793,7 @@ class acp_forums FROM ' . POSTS_TABLE . ' WHERE forum_id = ' . $forum_id . ' AND post_postcount = 1 - AND post_approved = 1'; + AND post_visibility = ' . ITEM_APPROVED; $result = $db->sql_query($sql); $post_counts = array(); @@ -1931,7 +1931,7 @@ class acp_forums // Make sure the overall post/topic count is correct... $sql = 'SELECT COUNT(post_id) AS stat FROM ' . POSTS_TABLE . ' - WHERE post_approved = 1'; + WHERE post_visibility = ' . ITEM_APPROVED; $result = $db->sql_query($sql); $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); @@ -1940,7 +1940,7 @@ class acp_forums $sql = 'SELECT COUNT(topic_id) AS stat FROM ' . TOPICS_TABLE . ' - WHERE topic_approved = 1'; + WHERE topic_visibility = ' . ITEM_APPROVED; $result = $db->sql_query($sql); $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); diff --git a/phpBB/includes/acp/acp_main.php b/phpBB/includes/acp/acp_main.php index eb613535bf..0584bb510e 100644 --- a/phpBB/includes/acp/acp_main.php +++ b/phpBB/includes/acp/acp_main.php @@ -144,14 +144,14 @@ class acp_main $sql = 'SELECT COUNT(post_id) AS stat FROM ' . POSTS_TABLE . ' - WHERE post_approved = 1'; + WHERE post_visibility = ' . ITEM_APPROVED; $result = $db->sql_query($sql); set_config('num_posts', (int) $db->sql_fetchfield('stat'), true); $db->sql_freeresult($result); $sql = 'SELECT COUNT(topic_id) AS stat FROM ' . TOPICS_TABLE . ' - WHERE topic_approved = 1'; + WHERE topic_visibility = ' . ITEM_APPROVED; $result = $db->sql_query($sql); set_config('num_topics', (int) $db->sql_fetchfield('stat'), true); $db->sql_freeresult($result); @@ -232,7 +232,7 @@ class acp_main $sql = 'SELECT COUNT(post_id) AS num_posts, poster_id FROM ' . POSTS_TABLE . ' WHERE post_id BETWEEN ' . ($start + 1) . ' AND ' . ($start + $step) . ' - AND post_postcount = 1 AND post_approved = 1 + AND post_postcount = 1 AND post_visibility = ' . ITEM_APPROVED . ' GROUP BY poster_id'; $result = $db->sql_query($sql); diff --git a/phpBB/includes/acp/acp_users.php b/phpBB/includes/acp/acp_users.php index b54257b04a..304027df45 100644 --- a/phpBB/includes/acp/acp_users.php +++ b/phpBB/includes/acp/acp_users.php @@ -676,7 +676,7 @@ class acp_users 'topic_time' => time(), 'forum_id' => $new_forum_id, 'icon_id' => 0, - 'topic_approved' => 1, + 'topic_visibility' => ITEM_APPROVED, 'topic_title' => $post_ary['title'], 'topic_first_poster_name' => $user_row['username'], 'topic_type' => POST_NORMAL, @@ -1033,7 +1033,7 @@ class acp_users $sql = 'SELECT COUNT(post_id) as posts_in_queue FROM ' . POSTS_TABLE . ' WHERE poster_id = ' . $user_id . ' - AND post_approved = 0'; + AND post_visibility = ' . ITEM_UNAPPROVED; $result = $db->sql_query($sql); $user_row['posts_in_queue'] = (int) $db->sql_fetchfield('posts_in_queue'); $db->sql_freeresult($result); diff --git a/phpBB/includes/constants.php b/phpBB/includes/constants.php index 68af41ab20..62c06dc1d0 100644 --- a/phpBB/includes/constants.php +++ b/phpBB/includes/constants.php @@ -87,6 +87,10 @@ define('ITEM_UNLOCKED', 0); define('ITEM_LOCKED', 1); define('ITEM_MOVED', 2); +define('ITEM_UNAPPROVED', 0); // => has not yet been approved +define('ITEM_APPROVED', 1); // => has been approved, and has not been soft deleted +define('ITEM_DELETED', 2); // => has been soft deleted + // Forum Flags define('FORUM_FLAG_LINK_TRACK', 1); define('FORUM_FLAG_PRUNE_POLL', 2); diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index 5e2ee8c8f6..328c8e9778 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -644,7 +644,7 @@ function delete_topics($where_type, $where_ids, $auto_sync = true, $post_count_s 'posts' => ($call_delete_posts) ? delete_posts($where_type, $where_ids, false, true, $post_count_sync, false) : 0, ); - $sql = 'SELECT topic_id, forum_id, topic_approved, topic_moved_id + $sql = 'SELECT topic_id, forum_id, topic_visibility, topic_moved_id FROM ' . TOPICS_TABLE . ' WHERE ' . $where_clause; $result = $db->sql_query($sql); @@ -654,7 +654,7 @@ function delete_topics($where_type, $where_ids, $auto_sync = true, $post_count_s $forum_ids[] = $row['forum_id']; $topic_ids[] = $row['topic_id']; - if ($row['topic_approved'] && !$row['topic_moved_id']) + if ($row['topic_visibility'] == ITEM_APPROVED && !$row['topic_moved_id']) { $approved_topics++; } @@ -767,7 +767,7 @@ function delete_posts($where_type, $where_ids, $auto_sync = true, $posted_sync = $approved_posts = 0; $post_ids = $topic_ids = $forum_ids = $post_counts = $remove_topics = array(); - $sql = 'SELECT post_id, poster_id, post_approved, post_postcount, topic_id, forum_id + $sql = 'SELECT post_id, poster_id, post_visibility, post_postcount, topic_id, forum_id FROM ' . POSTS_TABLE . ' WHERE ' . $where_clause; $result = $db->sql_query($sql); @@ -779,12 +779,12 @@ function delete_posts($where_type, $where_ids, $auto_sync = true, $posted_sync = $topic_ids[] = (int) $row['topic_id']; $forum_ids[] = (int) $row['forum_id']; - if ($row['post_postcount'] && $post_count_sync && $row['post_approved']) + if ($row['post_postcount'] && $post_count_sync && $row['post_visibility'] == ITEM_APPROVED) { $post_counts[$row['poster_id']] = (!empty($post_counts[$row['poster_id']])) ? $post_counts[$row['poster_id']] + 1 : 1; } - if ($row['post_approved']) + if ($row['post_visibility'] == ITEM_APPROVED) { $approved_posts++; } @@ -1274,7 +1274,7 @@ function phpbb_unlink($filename, $mode = 'file', $entry_removed = false) * - forum Resync complete forum * - topic Resync topics * - topic_moved Removes topic shadows that would be in the same forum as the topic they link to -* - topic_approved Resyncs the topic_approved flag according to the status of the first post +* - topic_visibility Resyncs the topic_visibility flag according to the status of the first post * - post_reported Resyncs the post_reported flag, relying on actual reports * - topic_reported Resyncs the topic_reported flag, relying on post_reported flags * - post_attachement Same as post_reported, but with attachment flags @@ -1294,7 +1294,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, $where_ids = ($where_ids) ? array((int) $where_ids) : array(); } - if ($mode == 'forum' || $mode == 'topic' || $mode == 'topic_approved' || $mode == 'topic_reported' || $mode == 'post_reported') + if ($mode == 'forum' || $mode == 'topic' || $mode == 'topic_visibility' || $mode == 'topic_reported' || $mode == 'post_reported') { if (!$where_type) { @@ -1380,7 +1380,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, $db->sql_transaction('commit'); break; - case 'topic_approved': + case 'topic_visibility': $db->sql_transaction('begin'); switch ($db->sql_layer) @@ -1388,22 +1388,22 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, case 'mysql4': case 'mysqli': $sql = 'UPDATE ' . TOPICS_TABLE . ' t, ' . POSTS_TABLE . " p - SET t.topic_approved = p.post_approved + SET t.topic_visibility = p.post_visibility $where_sql_and t.topic_first_post_id = p.post_id"; $db->sql_query($sql); break; default: - $sql = 'SELECT t.topic_id, p.post_approved + $sql = 'SELECT t.topic_id, p.post_visibility FROM ' . TOPICS_TABLE . ' t, ' . POSTS_TABLE . " p $where_sql_and p.post_id = t.topic_first_post_id - AND p.post_approved <> t.topic_approved"; + AND p.post_visibility <> t.topic_visibility"; $result = $db->sql_query($sql); $topic_ids = array(); while ($row = $db->sql_fetchrow($result)) { - $topic_ids[] = $row['topic_id']; + $topic_ids[$row['topic_id']] = $row['post_visibility']; } $db->sql_freeresult($result); @@ -1412,10 +1412,13 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, return; } - $sql = 'UPDATE ' . TOPICS_TABLE . ' - SET topic_approved = 1 - topic_approved - WHERE ' . $db->sql_in_set('topic_id', $topic_ids); - $db->sql_query($sql); + foreach ($topic_ids as $topic_id => $visibility) + { + $sql = 'UPDATE ' . TOPICS_TABLE . ' + SET topic_visibility = ' . $visibility . ' + WHERE topic_id' . $topic_id; + $db->sql_query($sql); + } break; } @@ -1680,10 +1683,10 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, // 2: Get topic counts for each forum (optional) if ($sync_extra) { - $sql = 'SELECT forum_id, topic_approved, COUNT(topic_id) AS forum_topics + $sql = 'SELECT forum_id, topic_visibility, COUNT(topic_id) AS forum_topics FROM ' . TOPICS_TABLE . ' WHERE ' . $db->sql_in_set('forum_id', $forum_ids) . ' - GROUP BY forum_id, topic_approved'; + GROUP BY forum_id, topic_visibility'; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) @@ -1691,7 +1694,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, $forum_id = (int) $row['forum_id']; $forum_data[$forum_id]['topics_real'] += $row['forum_topics']; - if ($row['topic_approved']) + if ($row['topic_visibility'] == ITEM_APPROVED) { $forum_data[$forum_id]['topics'] = $row['forum_topics']; } @@ -1707,7 +1710,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, $sql = 'SELECT SUM(t.topic_replies + 1) AS forum_posts FROM ' . TOPICS_TABLE . ' t WHERE ' . $db->sql_in_set('t.forum_id', $forum_ids) . ' - AND t.topic_approved = 1 + AND t.topic_visibility = ' . ITEM_APPROVED . ' AND t.topic_status <> ' . ITEM_MOVED; } else @@ -1715,7 +1718,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, $sql = 'SELECT t.forum_id, SUM(t.topic_replies + 1) AS forum_posts FROM ' . TOPICS_TABLE . ' t WHERE ' . $db->sql_in_set('t.forum_id', $forum_ids) . ' - AND t.topic_approved = 1 + AND t.topic_visibility = ' . ITEM_APPROVED . ' AND t.topic_status <> ' . ITEM_MOVED . ' GROUP BY t.forum_id'; } @@ -1737,14 +1740,14 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, $sql = 'SELECT MAX(t.topic_last_post_id) as last_post_id FROM ' . TOPICS_TABLE . ' t WHERE ' . $db->sql_in_set('t.forum_id', $forum_ids) . ' - AND t.topic_approved = 1'; + AND t.topic_visibility = ' . ITEM_APPROVED; } else { $sql = 'SELECT t.forum_id, MAX(t.topic_last_post_id) as last_post_id FROM ' . TOPICS_TABLE . ' t WHERE ' . $db->sql_in_set('t.forum_id', $forum_ids) . ' - AND t.topic_approved = 1 + AND t.topic_visibility = ' . ITEM_APPROVED . ' GROUP BY t.forum_id'; } @@ -1846,7 +1849,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, $db->sql_transaction('begin'); - $sql = 'SELECT t.topic_id, t.forum_id, t.topic_moved_id, t.topic_approved, ' . (($sync_extra) ? 't.topic_attachment, t.topic_reported, ' : '') . 't.topic_poster, t.topic_time, t.topic_replies, t.topic_replies_real, t.topic_first_post_id, t.topic_first_poster_name, t.topic_first_poster_colour, t.topic_last_post_id, t.topic_last_post_subject, t.topic_last_poster_id, t.topic_last_poster_name, t.topic_last_poster_colour, t.topic_last_post_time + $sql = 'SELECT t.topic_id, t.forum_id, t.topic_moved_id, t.topic_visibility, ' . (($sync_extra) ? 't.topic_attachment, t.topic_reported, ' : '') . 't.topic_poster, t.topic_time, t.topic_replies, t.topic_replies_real, t.topic_first_post_id, t.topic_first_poster_name, t.topic_first_poster_colour, t.topic_last_post_id, t.topic_last_post_subject, t.topic_last_poster_id, t.topic_last_poster_name, t.topic_last_poster_colour, t.topic_last_post_time FROM ' . TOPICS_TABLE . " t $where_sql"; $result = $db->sql_query($sql); @@ -1880,10 +1883,10 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, // Use "t" as table alias because of the $where_sql clause // NOTE: 't.post_approved' in the GROUP BY is causing a major slowdown. - $sql = 'SELECT t.topic_id, t.post_approved, COUNT(t.post_id) AS total_posts, MIN(t.post_id) AS first_post_id, MAX(t.post_id) AS last_post_id + $sql = 'SELECT t.topic_id, t.post_visibility, COUNT(t.post_id) AS total_posts, MIN(t.post_id) AS first_post_id, MAX(t.post_id) AS last_post_id FROM ' . POSTS_TABLE . " t $where_sql - GROUP BY t.topic_id, t.post_approved"; + GROUP BY t.topic_id, t.post_visibility"; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) @@ -1907,7 +1910,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, $topic_data[$topic_id]['replies_real'] += $row['total_posts']; $topic_data[$topic_id]['first_post_id'] = (!$topic_data[$topic_id]['first_post_id']) ? $row['first_post_id'] : min($topic_data[$topic_id]['first_post_id'], $row['first_post_id']); - if ($row['post_approved'] || !$topic_data[$topic_id]['last_post_id']) + if ($row['post_visibility'] || !$topic_data[$topic_id]['last_post_id']) { $topic_data[$topic_id]['replies'] = $row['total_posts'] - 1; $topic_data[$topic_id]['last_post_id'] = $row['last_post_id']; @@ -1952,7 +1955,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, unset($delete_topics, $delete_topic_ids); } - $sql = 'SELECT p.post_id, p.topic_id, p.post_approved, p.poster_id, p.post_subject, p.post_username, p.post_time, u.username, u.user_colour + $sql = 'SELECT p.post_id, p.topic_id, p.post_visibility, p.poster_id, p.post_subject, p.post_username, p.post_time, u.username, u.user_colour FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . ' u WHERE ' . $db->sql_in_set('p.post_id', $post_ids) . ' AND u.user_id = p.poster_id'; @@ -1965,9 +1968,9 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, if ($row['post_id'] == $topic_data[$topic_id]['first_post_id']) { - if ($topic_data[$topic_id]['topic_approved'] != $row['post_approved']) + if ($topic_data[$topic_id]['topic_visibility'] != $row['post_visibility']) { - $approved_unapproved_ids[] = $topic_id; + $approved_unapproved_ids[$topic_id] = $row['post_visibility']; } $topic_data[$topic_id]['time'] = $row['post_time']; $topic_data[$topic_id]['poster'] = $row['poster_id']; @@ -2029,7 +2032,7 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, $sync_shadow_topics = array(); if (sizeof($post_ids)) { - $sql = 'SELECT p.post_id, p.topic_id, p.post_approved, p.poster_id, p.post_subject, p.post_username, p.post_time, u.username, u.user_colour + $sql = 'SELECT p.post_id, p.topic_id, p.post_visibility, p.poster_id, p.post_subject, p.post_username, p.post_time, u.username, u.user_colour FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . ' u WHERE ' . $db->sql_in_set('p.post_id', $post_ids) . ' AND u.user_id = p.poster_id'; @@ -2099,10 +2102,14 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false, // approved becomes unapproved, and vice-versa if (sizeof($approved_unapproved_ids)) { - $sql = 'UPDATE ' . TOPICS_TABLE . ' - SET topic_approved = 1 - topic_approved - WHERE ' . $db->sql_in_set('topic_id', $approved_unapproved_ids); - $db->sql_query($sql); + foreach ($approved_unapproved_ids as $update_topic_id => $status) + { + // @TODO: Consider grouping by $status and only running 3 queries + $sql = 'UPDATE ' . TOPICS_TABLE . ' + SET topic_visibility = ' . $status . ' + WHERE topic_id = ' . $update_topic_id; + $db->sql_query($sql); + } } unset($approved_unapproved_ids); diff --git a/phpBB/includes/functions_convert.php b/phpBB/includes/functions_convert.php index ac791e0d9b..a34a193f60 100644 --- a/phpBB/includes/functions_convert.php +++ b/phpBB/includes/functions_convert.php @@ -1768,7 +1768,7 @@ function sync_post_count($offset, $limit) $sql = 'SELECT COUNT(post_id) AS num_posts, poster_id FROM ' . POSTS_TABLE . ' WHERE post_postcount = 1 - AND post_approved = 1 + AND post_visibility = ' . ITEM_APPROVED . ' GROUP BY poster_id ORDER BY poster_id'; $result = $db->sql_query_limit($sql, $limit, $offset); @@ -1941,7 +1941,7 @@ function update_dynamic_config() $sql = 'SELECT COUNT(post_id) AS stat FROM ' . POSTS_TABLE . ' - WHERE post_approved = 1'; + WHERE post_visibility = ' . ITEM_APPROVED; $result = $db->sql_query($sql); $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); @@ -1950,7 +1950,7 @@ function update_dynamic_config() $sql = 'SELECT COUNT(topic_id) AS stat FROM ' . TOPICS_TABLE . ' - WHERE topic_approved = 1'; + WHERE topic_visibility = ' . ITEM_APPROVED; $result = $db->sql_query($sql); $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index c50395a5df..2f51200b48 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -176,7 +176,7 @@ function update_post_information($type, $ids, $return_update_sql = false) if ($type != 'topic') { $topic_join = ', ' . TOPICS_TABLE . ' t'; - $topic_condition = 'AND t.topic_id = p.topic_id AND t.topic_approved = 1'; + $topic_condition = 'AND t.topic_id = p.topic_id AND t.topic_visibility = ' . ITEM_APPROVED; } else { @@ -190,7 +190,7 @@ function update_post_information($type, $ids, $return_update_sql = false) FROM ' . POSTS_TABLE . " p $topic_join WHERE " . $db->sql_in_set('p.' . $type . '_id', $ids) . " $topic_condition - AND p.post_approved = 1"; + AND p.post_visibility = " . ITEM_APPROVED; } else { @@ -198,7 +198,7 @@ function update_post_information($type, $ids, $return_update_sql = false) FROM ' . POSTS_TABLE . " p $topic_join WHERE " . $db->sql_in_set('p.' . $type . '_id', $ids) . " $topic_condition - AND p.post_approved = 1 + AND p.post_visibility = " . ITEM_APPROVED . " GROUP BY p.{$type}_id"; } $result = $db->sql_query($sql); @@ -993,7 +993,7 @@ function topic_review($topic_id, $forum_id, $mode = 'topic_review', $cur_post_id $sql = 'SELECT p.post_id FROM ' . POSTS_TABLE . ' p' . " WHERE p.topic_id = $topic_id - " . ((!$auth->acl_get('m_approve', $forum_id)) ? 'AND p.post_approved = 1' : '') . ' + AND " . topic_visibility::get_visibility_sql('post', $forum_id, 'p.') . ' ' . (($mode == 'post_review') ? " AND p.post_id > $cur_post_id" : '') . ' ' . (($mode == 'post_review_edit') ? " AND p.post_id = $cur_post_id" : '') . ' ORDER BY p.post_time '; @@ -1489,7 +1489,7 @@ function delete_post($forum_id, $topic_id, $post_id, &$data) delete_topics('topic_id', array($topic_id), false); $sql_data[FORUMS_TABLE] .= 'forum_topics_real = forum_topics_real - 1'; - $sql_data[FORUMS_TABLE] .= ($data['topic_approved']) ? ', forum_posts = forum_posts - 1, forum_topics = forum_topics - 1' : ''; + $sql_data[FORUMS_TABLE] .= ($data['topic_visibility'] == ITEM_APPROVED) ? ', forum_posts = forum_posts - 1, forum_topics = forum_topics - 1' : ''; $update_sql = update_post_information('forum', $forum_id, true); if (sizeof($update_sql)) @@ -1509,18 +1509,18 @@ function delete_post($forum_id, $topic_id, $post_id, &$data) $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); - $sql_data[FORUMS_TABLE] = ($data['post_approved']) ? 'forum_posts = forum_posts - 1' : ''; + $sql_data[FORUMS_TABLE] = ($data['post_visibility'] == ITEM_APPROVED) ? 'forum_posts = forum_posts - 1' : ''; $sql_data[TOPICS_TABLE] = 'topic_poster = ' . intval($row['poster_id']) . ', topic_first_post_id = ' . intval($row['post_id']) . ", topic_first_poster_colour = '" . $db->sql_escape($row['user_colour']) . "', topic_first_poster_name = '" . (($row['poster_id'] == ANONYMOUS) ? $db->sql_escape($row['post_username']) : $db->sql_escape($row['username'])) . "', topic_time = " . (int) $row['post_time']; // Decrementing topic_replies here is fine because this case only happens if there is more than one post within the topic - basically removing one "reply" - $sql_data[TOPICS_TABLE] .= ', topic_replies_real = topic_replies_real - 1' . (($data['post_approved']) ? ', topic_replies = topic_replies - 1' : ''); + $sql_data[TOPICS_TABLE] .= ', topic_replies_real = topic_replies_real - 1' . (($data['post_visibility'] == ITEM_APPROVED) ? ', topic_replies = topic_replies - 1' : ''); $next_post_id = (int) $row['post_id']; break; case 'delete_last_post': - $sql_data[FORUMS_TABLE] = ($data['post_approved']) ? 'forum_posts = forum_posts - 1' : ''; + $sql_data[FORUMS_TABLE] = ($data['post_visibility'] == ITEM_APPROVED) ? 'forum_posts = forum_posts - 1' : ''; $update_sql = update_post_information('forum', $forum_id, true); if (sizeof($update_sql)) @@ -1529,7 +1529,7 @@ function delete_post($forum_id, $topic_id, $post_id, &$data) $sql_data[FORUMS_TABLE] .= implode(', ', $update_sql[$forum_id]); } - $sql_data[TOPICS_TABLE] = 'topic_bumped = 0, topic_bumper = 0, topic_replies_real = topic_replies_real - 1' . (($data['post_approved']) ? ', topic_replies = topic_replies - 1' : ''); + $sql_data[TOPICS_TABLE] = 'topic_bumped = 0, topic_bumper = 0, topic_replies_real = topic_replies_real - 1' . (($data['post_visibility'] == ITEM_APPROVED) ? ', topic_replies = topic_replies - 1' : ''); $update_sql = update_post_information('topic', $topic_id, true); if (sizeof($update_sql)) @@ -1541,8 +1541,8 @@ function delete_post($forum_id, $topic_id, $post_id, &$data) { $sql = 'SELECT MAX(post_id) as last_post_id FROM ' . POSTS_TABLE . " - WHERE topic_id = $topic_id " . - ((!$auth->acl_get('m_approve', $forum_id)) ? 'AND post_approved = 1' : ''); + WHERE topic_id = $topic_id + AND " . topic_visibility::get_visibility_sql('post', $forum_id); $result = $db->sql_query($sql); $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); @@ -1554,17 +1554,17 @@ function delete_post($forum_id, $topic_id, $post_id, &$data) case 'delete': $sql = 'SELECT post_id FROM ' . POSTS_TABLE . " - WHERE topic_id = $topic_id " . - ((!$auth->acl_get('m_approve', $forum_id)) ? 'AND post_approved = 1' : '') . ' + WHERE topic_id = $topic_id + AND " . topic_visibility::get_visibility_sql('post', $forum_id) . ' AND post_time > ' . $data['post_time'] . ' ORDER BY post_time ASC'; $result = $db->sql_query_limit($sql, 1); $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); - $sql_data[FORUMS_TABLE] = ($data['post_approved']) ? 'forum_posts = forum_posts - 1' : ''; + $sql_data[FORUMS_TABLE] = ($data['post_visibility'] == ITEM_APPROVED) ? 'forum_posts = forum_posts - 1' : ''; - $sql_data[TOPICS_TABLE] = 'topic_replies_real = topic_replies_real - 1' . (($data['post_approved']) ? ', topic_replies = topic_replies - 1' : ''); + $sql_data[TOPICS_TABLE] = 'topic_replies_real = topic_replies_real - 1' . (($data['post_visibility'] == ITEM_APPROVED) ? ', topic_replies = topic_replies - 1' : ''); $next_post_id = (int) $row['post_id']; break; } @@ -1674,9 +1674,9 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u $poster_id = ($mode == 'edit') ? $data['poster_id'] : (int) $user->data['user_id']; // Retrieve some additional information if not present - if ($mode == 'edit' && (!isset($data['post_approved']) || !isset($data['topic_approved']) || $data['post_approved'] === false || $data['topic_approved'] === false)) + if ($mode == 'edit' && (!isset($data['post_visibility']) || !isset($data['topic_visibility']) || $data['post_visibility'] === false || $data['topic_visibility'] === false)) { - $sql = 'SELECT p.post_approved, t.topic_type, t.topic_replies, t.topic_replies_real, t.topic_approved + $sql = 'SELECT p.post_visibility, t.topic_type, t.topic_replies, t.topic_replies_real, t.topic_visibility FROM ' . TOPICS_TABLE . ' t, ' . POSTS_TABLE . ' p WHERE t.topic_id = p.topic_id AND p.post_id = ' . $data['post_id']; @@ -1684,8 +1684,8 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u $topic_row = $db->sql_fetchrow($result); $db->sql_freeresult($result); - $data['topic_approved'] = $topic_row['topic_approved']; - $data['post_approved'] = $topic_row['post_approved']; + $data['topic_visibility'] = $topic_row['topic_visibility']; + $data['post_visibility'] = $topic_row['post_visibility']; } // This variable indicates if the user is able to post or put into the queue - it is used later for all code decisions regarding approval @@ -1719,7 +1719,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u 'icon_id' => $data['icon_id'], 'poster_ip' => $user->ip, 'post_time' => $current_time, - 'post_approved' => $post_approval, + 'post_visibility' => $post_approval, 'enable_bbcode' => $data['enable_bbcode'], 'enable_smilies' => $data['enable_smilies'], 'enable_magic_url' => $data['enable_urls'], @@ -1785,7 +1785,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u 'forum_id' => $data['forum_id'], 'poster_id' => $data['poster_id'], 'icon_id' => $data['icon_id'], - 'post_approved' => (!$post_approval) ? 0 : $data['post_approved'], + 'post_visibility' => (!$post_approval) ? 0 : $data['post_visibility'], 'enable_bbcode' => $data['enable_bbcode'], 'enable_smilies' => $data['enable_smilies'], 'enable_magic_url' => $data['enable_urls'], @@ -1807,7 +1807,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u break; } - $post_approved = $sql_data[POSTS_TABLE]['sql']['post_approved']; + $post_approved = $sql_data[POSTS_TABLE]['sql']['post_visibility']; $topic_row = array(); // And the topic ladies and gentlemen @@ -1820,7 +1820,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u 'topic_last_view_time' => $current_time, 'forum_id' => $data['forum_id'], 'icon_id' => $data['icon_id'], - 'topic_approved' => $post_approval, + 'topic_visibility' => $post_approval, 'topic_title' => $subject, 'topic_first_poster_name' => (!$user->data['is_registered'] && $username) ? $username : (($user->data['user_id'] != ANONYMOUS) ? $user->data['username'] : ''), 'topic_first_poster_colour' => $user->data['user_colour'], @@ -1897,7 +1897,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u $sql_data[TOPICS_TABLE]['sql'] = array( 'forum_id' => $data['forum_id'], 'icon_id' => $data['icon_id'], - 'topic_approved' => (!$post_approval) ? 0 : $data['topic_approved'], + 'topic_visibility' => (!$post_approval) ? 0 : $data['topic_visibility'], 'topic_title' => $subject, 'topic_first_poster_name' => $username, 'topic_type' => $topic_type, @@ -1913,12 +1913,12 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u ); // Correctly set back the topic replies and forum posts... only if the topic was approved before and now gets disapproved - if (!$post_approval && $data['topic_approved']) + if (!$post_approval && $data['topic_visibility'] == ITEM_APPROVED) { // Do we need to grab some topic informations? if (!sizeof($topic_row)) { - $sql = 'SELECT topic_type, topic_replies, topic_replies_real, topic_approved + $sql = 'SELECT topic_type, topic_replies, topic_replies_real, topic_visibility FROM ' . TOPICS_TABLE . ' WHERE topic_id = ' . $data['topic_id']; $result = $db->sql_query($sql); @@ -1949,7 +1949,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u case 'edit_last_post': // Correctly set back the topic replies and forum posts... but only if the post was approved before. - if (!$post_approval && $data['post_approved']) + if (!$post_approval && $data['post_visibility'] == ITEM_APPROVED) { $sql_data[TOPICS_TABLE]['stat'][] = 'topic_replies = topic_replies - 1, topic_last_view_time = ' . $current_time; $sql_data[FORUMS_TABLE]['stat'][] = 'forum_posts = forum_posts - 1'; @@ -2173,7 +2173,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u // we need to update the last forum information // only applicable if the topic is approved - if ($post_approved || !$data['post_approved']) + if ($post_approved || $data['post_visibility'] != ITEM_APPROVED) { // the last post makes us update the forum table. This can happen if... // We make a new topic @@ -2219,13 +2219,13 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u $sql_data[FORUMS_TABLE]['stat'][] = "forum_last_poster_name = '" . $db->sql_escape($username) . "'"; } } - else if ($data['post_approved'] !== $post_approved) + else if ($data['post_visibility'] !== $post_approved) { // we need a fresh change of socks, everything has become invalidated $sql = 'SELECT MAX(topic_last_post_id) as last_post_id FROM ' . TOPICS_TABLE . ' WHERE forum_id = ' . (int) $data['forum_id'] . ' - AND topic_approved = 1'; + AND topic_visibility = ' . ITEM_APPROVED; $result = $db->sql_query($sql); $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); @@ -2290,13 +2290,13 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u } } } - else if (!$data['post_approved'] && ($post_mode == 'edit_last_post' || $post_mode == 'edit_topic' || ($post_mode == 'edit_first_post' && !$data['topic_replies']))) + else if (!$data['post_visibility'] == ITEM_APPROVED && ($post_mode == 'edit_last_post' || $post_mode == 'edit_topic' || ($post_mode == 'edit_first_post' && !$data['topic_replies']))) { // like having the rug pulled from under us $sql = 'SELECT MAX(post_id) as last_post_id FROM ' . POSTS_TABLE . ' WHERE topic_id = ' . (int) $data['topic_id'] . ' - AND post_approved = 1'; + AND post_visibility = ' . ITEM_APPROVED; $result = $db->sql_query($sql); $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); diff --git a/phpBB/includes/mcp/mcp_forum.php b/phpBB/includes/mcp/mcp_forum.php index 7b3bc82093..48b9c7c2d3 100644 --- a/phpBB/includes/mcp/mcp_forum.php +++ b/phpBB/includes/mcp/mcp_forum.php @@ -154,7 +154,7 @@ function mcp_forum_view($id, $mode, $action, $forum_info) $sql = 'SELECT t.topic_id FROM ' . TOPICS_TABLE . ' t WHERE t.forum_id = ' . $forum_id . ' - ' . (($auth->acl_get('m_approve', $forum_id)) ? '' : 'AND t.topic_approved = 1') . " + ' . topic_visibility::get_visibility_sql('topic', $forum_id, 't.') . " $limit_time_sql ORDER BY t.topic_type DESC, $sort_order_sql"; $result = $db->sql_query_limit($sql, $topics_per_page, $start); @@ -220,9 +220,10 @@ function mcp_forum_view($id, $mode, $action, $forum_info) $topic_title = censor_text($row['topic_title']); - $topic_unapproved = (!$row['topic_approved'] && $auth->acl_get('m_approve', $row['forum_id'])) ? true : false; - $posts_unapproved = ($row['topic_approved'] && $row['topic_replies'] < $row['topic_replies_real'] && $auth->acl_get('m_approve', $row['forum_id'])) ? true : false; + $topic_unapproved = ($row['topic_visibility'] == ITEM_UNAPPROVED && $auth->acl_get('m_approve', $row['forum_id'])) ? true : false; + $posts_unapproved = ($row['topic_visibility'] == ITEM_APPROVED && $row['topic_replies'] < $row['topic_replies_real'] && $auth->acl_get('m_approve', $row['forum_id'])) ? true : false; $u_mcp_queue = ($topic_unapproved || $posts_unapproved) ? $url . '&i=queue&mode=' . (($topic_unapproved) ? 'approve_details' : 'unapproved_posts') . '&t=' . $row['topic_id'] : ''; + $topic_deleted = ($row['topic_visibility'] == ITEM_DELETED) ? true : false; $topic_row = array( 'ATTACH_ICON_IMG' => ($auth->acl_get('u_download') && $auth->acl_get('f_download', $row['forum_id']) && $row['topic_attachment']) ? $user->img('icon_topic_attach', $user->lang['TOTAL_ATTACHMENTS']) : '', @@ -232,6 +233,7 @@ function mcp_forum_view($id, $mode, $action, $forum_info) 'TOPIC_ICON_IMG_WIDTH' => (!empty($icons[$row['icon_id']])) ? $icons[$row['icon_id']]['width'] : '', 'TOPIC_ICON_IMG_HEIGHT' => (!empty($icons[$row['icon_id']])) ? $icons[$row['icon_id']]['height'] : '', 'UNAPPROVED_IMG' => ($topic_unapproved || $posts_unapproved) ? $user->img('icon_topic_unapproved', ($topic_unapproved) ? 'TOPIC_UNAPPROVED' : 'POSTS_UNAPPROVED') : '', + 'DELETED_IMG' => ($topic_deleted) ? $user->img(/*TODO*/) : '', 'TOPIC_AUTHOR' => get_username_string('username', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']), 'TOPIC_AUTHOR_COLOUR' => get_username_string('colour', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']), @@ -254,7 +256,9 @@ function mcp_forum_view($id, $mode, $action, $forum_info) 'S_TOPIC_REPORTED' => (!empty($row['topic_reported']) && empty($row['topic_moved_id']) && $auth->acl_get('m_report', $row['forum_id'])) ? true : false, 'S_TOPIC_UNAPPROVED' => $topic_unapproved, 'S_POSTS_UNAPPROVED' => $posts_unapproved, + 'S_TOPIC_DELETED' => $topic_deleted, 'S_UNREAD_TOPIC' => $unread_topic, + ); if ($row['topic_status'] == ITEM_MOVED) diff --git a/phpBB/includes/mcp/mcp_front.php b/phpBB/includes/mcp/mcp_front.php index 13398e62bc..1b9521674d 100644 --- a/phpBB/includes/mcp/mcp_front.php +++ b/phpBB/includes/mcp/mcp_front.php @@ -39,7 +39,7 @@ function mcp_front_view($id, $mode, $action) $sql = 'SELECT COUNT(post_id) AS total FROM ' . POSTS_TABLE . ' WHERE ' . $db->sql_in_set('forum_id', $forum_list) . ' - AND post_approved = 0'; + AND post_visibility = ' . ITEM_UNAPPROVED; $result = $db->sql_query($sql); $total = (int) $db->sql_fetchfield('total'); $db->sql_freeresult($result); @@ -60,7 +60,7 @@ function mcp_front_view($id, $mode, $action) $sql = 'SELECT post_id FROM ' . POSTS_TABLE . ' WHERE ' . $db->sql_in_set('forum_id', $forum_list) . ' - AND post_approved = 0 + AND post_visibility = ' . ITEM_UNAPPROVED . ' ORDER BY post_time DESC'; $result = $db->sql_query_limit($sql, 5); diff --git a/phpBB/includes/mcp/mcp_main.php b/phpBB/includes/mcp/mcp_main.php index 95ca7c2e1b..db9872e04e 100644 --- a/phpBB/includes/mcp/mcp_main.php +++ b/phpBB/includes/mcp/mcp_main.php @@ -475,7 +475,7 @@ function mcp_move_topic($topic_ids) foreach ($topic_data as $topic_id => $topic_info) { - if ($topic_info['topic_approved']) + if ($topic_info['topic_visibility'] == ITEM_APPROVED) { $topics_authed_moved++; $topic_posts_added++; @@ -486,7 +486,7 @@ function mcp_move_topic($topic_ids) $topics_removed++; $topic_posts_removed += $topic_info['topic_replies']; - if ($topic_info['topic_approved']) + if ($topic_info['topic_visibility'] == ITEM_APPROVED) { $topics_authed_removed++; $topic_posts_removed++; @@ -528,13 +528,13 @@ function mcp_move_topic($topic_ids) add_log('mod', $to_forum_id, $topic_id, 'LOG_MOVE', $row['forum_name'], $forum_data['forum_name']); // Leave a redirection if required and only if the topic is visible to users - if ($leave_shadow && $row['topic_approved'] && $row['topic_type'] != POST_GLOBAL) + if ($leave_shadow && $row['topic_visibility'] == ITEM_APPROVED && $row['topic_type'] != POST_GLOBAL) { $shadow = array( 'forum_id' => (int) $row['forum_id'], 'icon_id' => (int) $row['icon_id'], 'topic_attachment' => (int) $row['topic_attachment'], - 'topic_approved' => 1, // a shadow topic is always approved + 'topic_visibliity' => ITEM_APPROVED, // a shadow topic is always approved 'topic_reported' => 0, // a shadow topic is never reported 'topic_title' => (string) $row['topic_title'], 'topic_poster' => (int) $row['topic_poster'], @@ -932,7 +932,7 @@ function mcp_fork_topic($topic_ids) 'forum_id' => (int) $to_forum_id, 'icon_id' => (int) $topic_row['icon_id'], 'topic_attachment' => (int) $topic_row['topic_attachment'], - 'topic_approved' => 1, + 'topic_visibility' => ITEM_APPROVED, 'topic_reported' => 0, 'topic_title' => (string) $topic_row['topic_title'], 'topic_poster' => (int) $topic_row['topic_poster'], @@ -1009,7 +1009,7 @@ function mcp_fork_topic($topic_ids) 'icon_id' => (int) $row['icon_id'], 'poster_ip' => (string) $row['poster_ip'], 'post_time' => (int) $row['post_time'], - 'post_approved' => 1, + 'post_visibility' => ITEM_APPROVED, 'post_reported' => 0, 'enable_bbcode' => (int) $row['enable_bbcode'], 'enable_smilies' => (int) $row['enable_smilies'], diff --git a/phpBB/includes/mcp/mcp_post.php b/phpBB/includes/mcp/mcp_post.php index 520c964228..90ce18de4e 100644 --- a/phpBB/includes/mcp/mcp_post.php +++ b/phpBB/includes/mcp/mcp_post.php @@ -185,7 +185,7 @@ function mcp_post_details($id, $mode, $action) 'S_CAN_DELETE_POST' => $auth->acl_get('m_delete', $post_info['forum_id']), 'S_POST_REPORTED' => ($post_info['post_reported']) ? true : false, - 'S_POST_UNAPPROVED' => (!$post_info['post_approved']) ? true : false, + 'S_POST_UNAPPROVED' => ($post_info['post_visibility'] == ITEM_UNAPPROVED) ? true : false, 'S_POST_LOCKED' => ($post_info['post_edit_locked']) ? true : false, 'S_USER_NOTES' => true, 'S_CLEAR_ALLOWED' => ($auth->acl_get('a_clearlogs')) ? true : false, @@ -415,7 +415,7 @@ function change_poster(&$post_info, $userdata) } // Adjust post counts... only if the post is approved (else, it was not added the users post count anyway) - if ($post_info['post_postcount'] && $post_info['post_approved']) + if ($post_info['post_postcount'] && $post_info['post_visibility'] == ITEM_APPROVED) { $sql = 'UPDATE ' . USERS_TABLE . ' SET user_posts = user_posts - 1 diff --git a/phpBB/includes/mcp/mcp_queue.php b/phpBB/includes/mcp/mcp_queue.php index b44685b8a3..833f924efc 100644 --- a/phpBB/includes/mcp/mcp_queue.php +++ b/phpBB/includes/mcp/mcp_queue.php @@ -183,7 +183,7 @@ class mcp_queue 'U_APPROVE_ACTION' => append_sid("{$phpbb_root_path}mcp.$phpEx", "i=queue&p=$post_id&f=$forum_id"), 'S_CAN_VIEWIP' => $auth->acl_get('m_info', $post_info['forum_id']), 'S_POST_REPORTED' => $post_info['post_reported'], - 'S_POST_UNAPPROVED' => !$post_info['post_approved'], + 'S_POST_UNAPPROVED' => ($post_info['post_visibility'] == ITEM_UNAPPROVED) , 'S_POST_LOCKED' => $post_info['post_edit_locked'], 'S_USER_NOTES' => true, @@ -309,7 +309,7 @@ class mcp_queue $sql = 'SELECT p.post_id FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t' . (($sort_order_sql[0] == 'u') ? ', ' . USERS_TABLE . ' u' : '') . ' WHERE ' . $db->sql_in_set('p.forum_id', $forum_list) . ' - AND p.post_approved = 0 + AND p.post_visibility = ' . ITEM_UNAPPROVED . ' ' . (($sort_order_sql[0] == 'u') ? 'AND u.user_id = p.poster_id' : '') . ' ' . (($topic_id) ? 'AND p.topic_id = ' . $topic_id : '') . " AND t.topic_id = p.topic_id @@ -361,7 +361,7 @@ class mcp_queue $sql = 'SELECT t.forum_id, t.topic_id, t.topic_title, t.topic_title AS post_subject, t.topic_time AS post_time, t.topic_poster AS poster_id, t.topic_first_post_id AS post_id, t.topic_attachment AS post_attachment, t.topic_first_poster_name AS username, t.topic_first_poster_colour AS user_colour FROM ' . TOPICS_TABLE . " t WHERE " . $db->sql_in_set('forum_id', $forum_list) . " - AND topic_approved = 0 + AND topic_visibility = " . ITEM_UNAPPROVED . " $limit_time_sql ORDER BY $sort_order_sql"; $result = $db->sql_query_limit($sql, $config['topics_per_page'], $start); @@ -484,7 +484,7 @@ function approve_post($post_id_list, $id, $mode) foreach ($post_info as $post_id => $post_data) { - if ($post_data['post_approved']) + if ($post_data['post_visibility'] == ITEM_APPROVED) { $post_approved_list[] = $post_id; continue; @@ -544,7 +544,7 @@ function approve_post($post_id_list, $id, $mode) if (sizeof($topic_approve_sql)) { $sql = 'UPDATE ' . TOPICS_TABLE . ' - SET topic_approved = 1 + SET topic_visibility = ' . ITEM_APPROVED . ' WHERE ' . $db->sql_in_set('topic_id', $topic_approve_sql); $db->sql_query($sql); } @@ -552,7 +552,7 @@ function approve_post($post_id_list, $id, $mode) if (sizeof($post_approve_sql)) { $sql = 'UPDATE ' . POSTS_TABLE . ' - SET post_approved = 1 + SET post_visibility = ' . ITEM_APPROVED . ' WHERE ' . $db->sql_in_set('post_id', $post_approve_sql); $db->sql_query($sql); } diff --git a/phpBB/includes/mcp/mcp_reports.php b/phpBB/includes/mcp/mcp_reports.php index 2890cd56e2..dc917a25e0 100644 --- a/phpBB/includes/mcp/mcp_reports.php +++ b/phpBB/includes/mcp/mcp_reports.php @@ -190,7 +190,7 @@ class mcp_reports 'S_CLOSE_ACTION' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=reports&mode=report_details&f=' . $post_info['forum_id'] . '&p=' . $post_id), 'S_CAN_VIEWIP' => $auth->acl_get('m_info', $post_info['forum_id']), 'S_POST_REPORTED' => $post_info['post_reported'], - 'S_POST_UNAPPROVED' => !$post_info['post_approved'], + 'S_POST_UNAPPROVED' => ($post_info['post_visibility'] == POST_UNAPPROVED), 'S_POST_LOCKED' => $post_info['post_edit_locked'], 'S_USER_NOTES' => true, diff --git a/phpBB/includes/mcp/mcp_topic.php b/phpBB/includes/mcp/mcp_topic.php index e39e553ab6..f6fd12f0c4 100644 --- a/phpBB/includes/mcp/mcp_topic.php +++ b/phpBB/includes/mcp/mcp_topic.php @@ -145,8 +145,8 @@ function mcp_topic_view($id, $mode, $action) $sql = 'SELECT u.username, u.username_clean, u.user_colour, p.* FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . ' u WHERE ' . (($action == 'reports') ? 'p.post_reported = 1 AND ' : '') . ' - p.topic_id = ' . $topic_id . ' ' . - ((!$auth->acl_get('m_approve', $topic_info['forum_id'])) ? ' AND p.post_approved = 1 ' : '') . ' + p.topic_id = ' . $topic_id . ' + AND ' . topic_visibility::get_visibility_sql('post', $topic_info['forum_id'], 'p.') . ' AND p.poster_id = u.user_id ' . $limit_time_sql . ' ORDER BY ' . $sort_order_sql; @@ -227,7 +227,7 @@ function mcp_topic_view($id, $mode, $action) parse_attachments($topic_info['forum_id'], $message, $attachments[$row['post_id']], $update_count); } - if (!$row['post_approved']) + if ($row['post_visibility'] == ITEM_UNAPPROVED) { $has_unapproved_posts = true; } @@ -249,7 +249,7 @@ function mcp_topic_view($id, $mode, $action) 'MINI_POST_IMG' => ($post_unread) ? $user->img('icon_post_target_unread', 'UNREAD_POST') : $user->img('icon_post_target', 'POST'), 'S_POST_REPORTED' => ($row['post_reported'] && $auth->acl_get('m_report', $topic_info['forum_id'])), - 'S_POST_UNAPPROVED' => (!$row['post_approved'] && $auth->acl_get('m_approve', $topic_info['forum_id'])), + 'S_POST_UNAPPROVED' => ($row['post_visibility'] != ITEM_APPROVED && $auth->acl_get('m_approve', $topic_info['forum_id'])), 'S_CHECKED' => (($submitted_id_list && !in_array(intval($row['post_id']), $submitted_id_list)) || in_array(intval($row['post_id']), $checked_ids)) ? true : false, 'S_HAS_ATTACHMENTS' => (!empty($attachments[$row['post_id']])) ? true : false, @@ -448,7 +448,7 @@ function split_topic($action, $topic_id, $to_forum_id, $subject) if ($sort_order_sql[0] == 'u') { - $sql = 'SELECT p.post_id, p.forum_id, p.post_approved + $sql = 'SELECT p.post_id, p.forum_id, p.post_visibility FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . " u WHERE p.topic_id = $topic_id AND p.poster_id = u.user_id @@ -457,7 +457,7 @@ function split_topic($action, $topic_id, $to_forum_id, $subject) } else { - $sql = 'SELECT p.post_id, p.forum_id, p.post_approved + $sql = 'SELECT p.post_id, p.forum_id, p.post_visibility FROM ' . POSTS_TABLE . " p WHERE p.topic_id = $topic_id $limit_time_sql @@ -470,7 +470,7 @@ function split_topic($action, $topic_id, $to_forum_id, $subject) while ($row = $db->sql_fetchrow($result)) { // If split from selected post (split_beyond), we split the unapproved items too. - if (!$row['post_approved'] && !$auth->acl_get('m_approve', $row['forum_id'])) + if ($row['post_visibility'] == ITEM_UNAPPROVED && !$auth->acl_get('m_approve', $row['forum_id'])) { // continue; } @@ -497,10 +497,10 @@ function split_topic($action, $topic_id, $to_forum_id, $subject) $icon_id = request_var('icon', 0); $sql_ary = array( - 'forum_id' => $to_forum_id, - 'topic_title' => $subject, - 'icon_id' => $icon_id, - 'topic_approved'=> 1 + 'forum_id' => $to_forum_id, + 'topic_title' => $subject, + 'icon_id' => $icon_id, + 'topic_visibility' => 1 ); $sql = 'INSERT INTO ' . TOPICS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary); diff --git a/phpBB/includes/search/fulltext_mysql.php b/phpBB/includes/search/fulltext_mysql.php index cf89ab1c24..73bf5c52f2 100644 --- a/phpBB/includes/search/fulltext_mysql.php +++ b/phpBB/includes/search/fulltext_mysql.php @@ -265,7 +265,7 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base * @param string $sort_dir is either a or d representing ASC and DESC * @param string $sort_days specifies the maximum amount of days a post may be old * @param array $ex_fid_ary specifies an array of forum ids which should not be searched - * @param array $m_approve_fid_ary specifies an array of forum ids in which the searcher is allowed to view unapproved posts + * @param array $m_approve_fid_sql specifies which types of posts a user may view, based on permissions * @param int $topic_id is set to 0 or a topic id, if it is not 0 then only posts in this topic should be searched * @param array $author_ary an array of author ids if the author should be ignored during the search the array is empty * @param string $author_name specifies the author match, when ANONYMOUS is also a search-match @@ -292,7 +292,7 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base $sort_key, $topic_id, implode(',', $ex_fid_ary), - implode(',', $m_approve_fid_ary), +// @TODO implode(',', $m_approve_fid_ary), implode(',', $author_ary) ))); @@ -354,7 +354,7 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base break; } - if (!sizeof($m_approve_fid_ary)) +/* if (!sizeof($m_approve_fid_ary)) { $m_approve_fid_sql = ' AND p.post_approved = 1'; } @@ -366,6 +366,7 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base { $m_approve_fid_sql = ' AND (p.post_approved = 1 OR ' . $this->db->sql_in_set('p.forum_id', $m_approve_fid_ary, true) . ')'; } +*/ $sql_select = (!$result_count) ? 'SQL_CALC_FOUND_ROWS ' : ''; $sql_select = ($type == 'posts') ? $sql_select . 'p.post_id' : 'DISTINCT ' . $sql_select . 't.topic_id'; @@ -445,7 +446,7 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base * @param string $sort_dir is either a or d representing ASC and DESC * @param string $sort_days specifies the maximum amount of days a post may be old * @param array $ex_fid_ary specifies an array of forum ids which should not be searched - * @param array $m_approve_fid_ary specifies an array of forum ids in which the searcher is allowed to view unapproved posts + * @param array $m_approve_fid_sql specifies which types of posts a user may view, based on permissions * @param int $topic_id is set to 0 or a topic id, if it is not 0 then only posts in this topic should be searched * @param array $author_ary an array of author ids * @param string $author_name specifies the author match, when ANONYMOUS is also a search-match @@ -473,7 +474,7 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base $sort_key, $topic_id, implode(',', $ex_fid_ary), - implode(',', $m_approve_fid_ary), +// @TODO implode(',', $m_approve_fid_ary), implode(',', $author_ary), $author_name, ))); @@ -523,7 +524,7 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base break; } - if (!sizeof($m_approve_fid_ary)) +/* if (!sizeof($m_approve_fid_ary)) { $m_approve_fid_sql = ' AND p.post_approved = 1'; } @@ -535,6 +536,7 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base { $m_approve_fid_sql = ' AND (p.post_approved = 1 OR ' . $this->db->sql_in_set('p.forum_id', $m_approve_fid_ary, true) . ')'; } +*/ // If the cache was completely empty count the results $calc_results = ($result_count) ? '' : 'SQL_CALC_FOUND_ROWS '; diff --git a/phpBB/includes/search/fulltext_native.php b/phpBB/includes/search/fulltext_native.php index 96b3f02ec6..c7e7a451e4 100644 --- a/phpBB/includes/search/fulltext_native.php +++ b/phpBB/includes/search/fulltext_native.php @@ -414,7 +414,7 @@ class phpbb_search_fulltext_native extends phpbb_search_base * @param string $sort_dir is either a or d representing ASC and DESC * @param string $sort_days specifies the maximum amount of days a post may be old * @param array $ex_fid_ary specifies an array of forum ids which should not be searched - * @param array $m_approve_fid_ary specifies an array of forum ids in which the searcher is allowed to view unapproved posts + * @param array $m_approve_fid_sql specifies which types of posts the user can view * @param int $topic_id is set to 0 or a topic id, if it is not 0 then only posts in this topic should be searched * @param array $author_ary an array of author ids if the author should be ignored during the search the array is empty * @param string $author_name specifies the author match, when ANONYMOUS is also a search-match @@ -451,7 +451,7 @@ class phpbb_search_fulltext_native extends phpbb_search_base $sort_key, $topic_id, implode(',', $ex_fid_ary), - implode(',', $m_approve_fid_ary), +// @TODO implode(',', $m_approve_fid_ary), implode(',', $author_ary), $author_name, ))); @@ -628,7 +628,7 @@ class phpbb_search_fulltext_native extends phpbb_search_base $sql_where[] = '(' . implode(' OR ', $is_null_joins) . ')'; } - if (!sizeof($m_approve_fid_ary)) +/* if (!sizeof($m_approve_fid_ary)) { $sql_where[] = 'p.post_approved = 1'; } @@ -636,6 +636,8 @@ class phpbb_search_fulltext_native extends phpbb_search_base { $sql_where[] = '(p.post_approved = 1 OR ' . $this->db->sql_in_set('p.forum_id', $m_approve_fid_ary, true) . ')'; } +*/ + $sql_where[] = $m_approve_fid_sql; if ($topic_id) { @@ -808,7 +810,7 @@ class phpbb_search_fulltext_native extends phpbb_search_base * @param string $sort_dir is either a or d representing ASC and DESC * @param string $sort_days specifies the maximum amount of days a post may be old * @param array $ex_fid_ary specifies an array of forum ids which should not be searched - * @param array $m_approve_fid_ary specifies an array of forum ids in which the searcher is allowed to view unapproved posts + * @param array $m_approve_fid_sql specifies which posts a user can view, based on permissions * @param int $topic_id is set to 0 or a topic id, if it is not 0 then only posts in this topic should be searched * @param array $author_ary an array of author ids * @param string $author_name specifies the author match, when ANONYMOUS is also a search-match @@ -836,7 +838,7 @@ class phpbb_search_fulltext_native extends phpbb_search_base $sort_key, $topic_id, implode(',', $ex_fid_ary), - implode(',', $m_approve_fid_ary), +// @TODO implode(',', $m_approve_fid_ary), implode(',', $author_ary), $author_name, ))); @@ -886,7 +888,7 @@ class phpbb_search_fulltext_native extends phpbb_search_base break; } - if (!sizeof($m_approve_fid_ary)) +/* if (!sizeof($m_approve_fid_ary)) { $m_approve_fid_sql = ' AND p.post_approved = 1'; } @@ -898,6 +900,7 @@ class phpbb_search_fulltext_native extends phpbb_search_base { $m_approve_fid_sql = ' AND (p.post_approved = 1 OR ' . $this->db->sql_in_set('p.forum_id', $m_approve_fid_ary, true) . ')'; } +*/ $select = ($type == 'posts') ? 'p.post_id' : 't.topic_id'; $is_mysql = false; diff --git a/phpBB/install/install_convert.php b/phpBB/install/install_convert.php index b8045cb98b..60606d74ab 100644 --- a/phpBB/install/install_convert.php +++ b/phpBB/install/install_convert.php @@ -1465,7 +1465,7 @@ class install_convert extends module $end = ($sync_batch + $batch_size - 1); // Sync all topics in batch mode... - sync('topic_approved', 'range', 'topic_id BETWEEN ' . $sync_batch . ' AND ' . $end, true, false); + sync('topic_visibility', 'range', 'topic_id BETWEEN ' . $sync_batch . ' AND ' . $end, true, false); sync('topic', 'range', 'topic_id BETWEEN ' . $sync_batch . ' AND ' . $end, true, true); $template->assign_block_vars('checks', array( diff --git a/phpBB/install/schemas/firebird_schema.sql b/phpBB/install/schemas/firebird_schema.sql index 588557b92a..d83fe4c2da 100644 --- a/phpBB/install/schemas/firebird_schema.sql +++ b/phpBB/install/schemas/firebird_schema.sql @@ -1,1367 +1,1365 @@ -# DO NOT EDIT THIS FILE, IT IS GENERATED -# -# To change the contents of this file, edit -# phpBB/develop/create_schema_files.php and -# run it. - -# Table: 'phpbb_attachments' -CREATE TABLE phpbb_attachments ( - attach_id INTEGER NOT NULL, - post_msg_id INTEGER DEFAULT 0 NOT NULL, - topic_id INTEGER DEFAULT 0 NOT NULL, - in_message INTEGER DEFAULT 0 NOT NULL, - poster_id INTEGER DEFAULT 0 NOT NULL, - is_orphan INTEGER DEFAULT 1 NOT NULL, - physical_filename VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL, - real_filename VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL, - download_count INTEGER DEFAULT 0 NOT NULL, - attach_comment BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL, - extension VARCHAR(100) CHARACTER SET NONE DEFAULT '' NOT NULL, - mimetype VARCHAR(100) CHARACTER SET NONE DEFAULT '' NOT NULL, - filesize INTEGER DEFAULT 0 NOT NULL, - filetime INTEGER DEFAULT 0 NOT NULL, - thumbnail INTEGER DEFAULT 0 NOT NULL -);; - -ALTER TABLE phpbb_attachments ADD PRIMARY KEY (attach_id);; - -CREATE INDEX phpbb_attachments_filetime ON phpbb_attachments(filetime);; -CREATE INDEX phpbb_attachments_post_msg_id ON phpbb_attachments(post_msg_id);; -CREATE INDEX phpbb_attachments_topic_id ON phpbb_attachments(topic_id);; -CREATE INDEX phpbb_attachments_poster_id ON phpbb_attachments(poster_id);; -CREATE INDEX phpbb_attachments_is_orphan ON phpbb_attachments(is_orphan);; - -CREATE GENERATOR phpbb_attachments_gen;; -SET GENERATOR phpbb_attachments_gen TO 0;; - -CREATE TRIGGER t_phpbb_attachments FOR phpbb_attachments -BEFORE INSERT -AS -BEGIN - NEW.attach_id = GEN_ID(phpbb_attachments_gen, 1); -END;; - - -# Table: 'phpbb_acl_groups' -CREATE TABLE phpbb_acl_groups ( - group_id INTEGER DEFAULT 0 NOT NULL, - forum_id INTEGER DEFAULT 0 NOT NULL, - auth_option_id INTEGER DEFAULT 0 NOT NULL, - auth_role_id INTEGER DEFAULT 0 NOT NULL, - auth_setting INTEGER DEFAULT 0 NOT NULL -);; - -CREATE INDEX phpbb_acl_groups_group_id ON phpbb_acl_groups(group_id);; -CREATE INDEX phpbb_acl_groups_auth_opt_id ON phpbb_acl_groups(auth_option_id);; -CREATE INDEX phpbb_acl_groups_auth_role_id ON phpbb_acl_groups(auth_role_id);; - -# Table: 'phpbb_acl_options' -CREATE TABLE phpbb_acl_options ( - auth_option_id INTEGER NOT NULL, - auth_option VARCHAR(50) CHARACTER SET NONE DEFAULT '' NOT NULL, - is_global INTEGER DEFAULT 0 NOT NULL, - is_local INTEGER DEFAULT 0 NOT NULL, - founder_only INTEGER DEFAULT 0 NOT NULL -);; - -ALTER TABLE phpbb_acl_options ADD PRIMARY KEY (auth_option_id);; - -CREATE UNIQUE INDEX phpbb_acl_options_auth_option ON phpbb_acl_options(auth_option);; - -CREATE GENERATOR phpbb_acl_options_gen;; -SET GENERATOR phpbb_acl_options_gen TO 0;; - -CREATE TRIGGER t_phpbb_acl_options FOR phpbb_acl_options -BEFORE INSERT -AS -BEGIN - NEW.auth_option_id = GEN_ID(phpbb_acl_options_gen, 1); -END;; - - -# Table: 'phpbb_acl_roles' -CREATE TABLE phpbb_acl_roles ( - role_id INTEGER NOT NULL, - role_name VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, - role_description BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL, - role_type VARCHAR(10) CHARACTER SET NONE DEFAULT '' NOT NULL, - role_order INTEGER DEFAULT 0 NOT NULL -);; - -ALTER TABLE phpbb_acl_roles ADD PRIMARY KEY (role_id);; - -CREATE INDEX phpbb_acl_roles_role_type ON phpbb_acl_roles(role_type);; -CREATE INDEX phpbb_acl_roles_role_order ON phpbb_acl_roles(role_order);; - -CREATE GENERATOR phpbb_acl_roles_gen;; -SET GENERATOR phpbb_acl_roles_gen TO 0;; - -CREATE TRIGGER t_phpbb_acl_roles FOR phpbb_acl_roles -BEFORE INSERT -AS -BEGIN - NEW.role_id = GEN_ID(phpbb_acl_roles_gen, 1); -END;; - - -# Table: 'phpbb_acl_roles_data' -CREATE TABLE phpbb_acl_roles_data ( - role_id INTEGER DEFAULT 0 NOT NULL, - auth_option_id INTEGER DEFAULT 0 NOT NULL, - auth_setting INTEGER DEFAULT 0 NOT NULL -);; - -ALTER TABLE phpbb_acl_roles_data ADD PRIMARY KEY (role_id, auth_option_id);; - -CREATE INDEX phpbb_acl_roles_data_ath_op_id ON phpbb_acl_roles_data(auth_option_id);; - -# Table: 'phpbb_acl_users' -CREATE TABLE phpbb_acl_users ( - user_id INTEGER DEFAULT 0 NOT NULL, - forum_id INTEGER DEFAULT 0 NOT NULL, - auth_option_id INTEGER DEFAULT 0 NOT NULL, - auth_role_id INTEGER DEFAULT 0 NOT NULL, - auth_setting INTEGER DEFAULT 0 NOT NULL -);; - -CREATE INDEX phpbb_acl_users_user_id ON phpbb_acl_users(user_id);; -CREATE INDEX phpbb_acl_users_auth_option_id ON phpbb_acl_users(auth_option_id);; -CREATE INDEX phpbb_acl_users_auth_role_id ON phpbb_acl_users(auth_role_id);; - -# Table: 'phpbb_banlist' -CREATE TABLE phpbb_banlist ( - ban_id INTEGER NOT NULL, - ban_userid INTEGER DEFAULT 0 NOT NULL, - ban_ip VARCHAR(40) CHARACTER SET NONE DEFAULT '' NOT NULL, - ban_email VARCHAR(100) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, - ban_start INTEGER DEFAULT 0 NOT NULL, - ban_end INTEGER DEFAULT 0 NOT NULL, - ban_exclude INTEGER DEFAULT 0 NOT NULL, - ban_reason VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, - ban_give_reason VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE -);; - -ALTER TABLE phpbb_banlist ADD PRIMARY KEY (ban_id);; - -CREATE INDEX phpbb_banlist_ban_end ON phpbb_banlist(ban_end);; -CREATE INDEX phpbb_banlist_ban_user ON phpbb_banlist(ban_userid, ban_exclude);; -CREATE INDEX phpbb_banlist_ban_email ON phpbb_banlist(ban_email, ban_exclude);; -CREATE INDEX phpbb_banlist_ban_ip ON phpbb_banlist(ban_ip, ban_exclude);; - -CREATE GENERATOR phpbb_banlist_gen;; -SET GENERATOR phpbb_banlist_gen TO 0;; - -CREATE TRIGGER t_phpbb_banlist FOR phpbb_banlist -BEFORE INSERT -AS -BEGIN - NEW.ban_id = GEN_ID(phpbb_banlist_gen, 1); -END;; - - -# Table: 'phpbb_bbcodes' -CREATE TABLE phpbb_bbcodes ( - bbcode_id INTEGER DEFAULT 0 NOT NULL, - bbcode_tag VARCHAR(16) CHARACTER SET NONE DEFAULT '' NOT NULL, - bbcode_helpline VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, - display_on_posting INTEGER DEFAULT 0 NOT NULL, - bbcode_match BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL, - bbcode_tpl BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL, - first_pass_match BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL, - first_pass_replace BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL, - second_pass_match BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL, - second_pass_replace BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL -);; - -ALTER TABLE phpbb_bbcodes ADD PRIMARY KEY (bbcode_id);; - -CREATE INDEX phpbb_bbcodes_display_on_post ON phpbb_bbcodes(display_on_posting);; - -# Table: 'phpbb_bookmarks' -CREATE TABLE phpbb_bookmarks ( - topic_id INTEGER DEFAULT 0 NOT NULL, - user_id INTEGER DEFAULT 0 NOT NULL -);; - -ALTER TABLE phpbb_bookmarks ADD PRIMARY KEY (topic_id, user_id);; - - -# Table: 'phpbb_bots' -CREATE TABLE phpbb_bots ( - bot_id INTEGER NOT NULL, - bot_active INTEGER DEFAULT 1 NOT NULL, - bot_name VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, - user_id INTEGER DEFAULT 0 NOT NULL, - bot_agent VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL, - bot_ip VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL -);; - -ALTER TABLE phpbb_bots ADD PRIMARY KEY (bot_id);; - -CREATE INDEX phpbb_bots_bot_active ON phpbb_bots(bot_active);; - -CREATE GENERATOR phpbb_bots_gen;; -SET GENERATOR phpbb_bots_gen TO 0;; - -CREATE TRIGGER t_phpbb_bots FOR phpbb_bots -BEFORE INSERT -AS -BEGIN - NEW.bot_id = GEN_ID(phpbb_bots_gen, 1); -END;; - - -# Table: 'phpbb_config' -CREATE TABLE phpbb_config ( - config_name VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL, - config_value VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, - is_dynamic INTEGER DEFAULT 0 NOT NULL -);; - -ALTER TABLE phpbb_config ADD PRIMARY KEY (config_name);; - -CREATE INDEX phpbb_config_is_dynamic ON phpbb_config(is_dynamic);; - -# Table: 'phpbb_confirm' -CREATE TABLE phpbb_confirm ( - confirm_id CHAR(32) CHARACTER SET NONE DEFAULT '' NOT NULL, - session_id CHAR(32) CHARACTER SET NONE DEFAULT '' NOT NULL, - confirm_type INTEGER DEFAULT 0 NOT NULL, - code VARCHAR(8) CHARACTER SET NONE DEFAULT '' NOT NULL, - seed INTEGER DEFAULT 0 NOT NULL, - attempts INTEGER DEFAULT 0 NOT NULL -);; - -ALTER TABLE phpbb_confirm ADD PRIMARY KEY (session_id, confirm_id);; - -CREATE INDEX phpbb_confirm_confirm_type ON phpbb_confirm(confirm_type);; - -# Table: 'phpbb_disallow' -CREATE TABLE phpbb_disallow ( - disallow_id INTEGER NOT NULL, - disallow_username VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE -);; - -ALTER TABLE phpbb_disallow ADD PRIMARY KEY (disallow_id);; - - -CREATE GENERATOR phpbb_disallow_gen;; -SET GENERATOR phpbb_disallow_gen TO 0;; - -CREATE TRIGGER t_phpbb_disallow FOR phpbb_disallow -BEFORE INSERT -AS -BEGIN - NEW.disallow_id = GEN_ID(phpbb_disallow_gen, 1); -END;; - - -# Table: 'phpbb_drafts' -CREATE TABLE phpbb_drafts ( - draft_id INTEGER NOT NULL, - user_id INTEGER DEFAULT 0 NOT NULL, - topic_id INTEGER DEFAULT 0 NOT NULL, - forum_id INTEGER DEFAULT 0 NOT NULL, - save_time INTEGER DEFAULT 0 NOT NULL, - draft_subject VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, - draft_message BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL -);; - -ALTER TABLE phpbb_drafts ADD PRIMARY KEY (draft_id);; - -CREATE INDEX phpbb_drafts_save_time ON phpbb_drafts(save_time);; - -CREATE GENERATOR phpbb_drafts_gen;; -SET GENERATOR phpbb_drafts_gen TO 0;; - -CREATE TRIGGER t_phpbb_drafts FOR phpbb_drafts -BEFORE INSERT -AS -BEGIN - NEW.draft_id = GEN_ID(phpbb_drafts_gen, 1); -END;; - - -# Table: 'phpbb_ext' -CREATE TABLE phpbb_ext ( - ext_name VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL, - ext_active INTEGER DEFAULT 0 NOT NULL, - ext_state BLOB SUB_TYPE TEXT CHARACTER SET NONE DEFAULT '' NOT NULL -);; - -CREATE UNIQUE INDEX phpbb_ext_ext_name ON phpbb_ext(ext_name);; - -# Table: 'phpbb_extensions' -CREATE TABLE phpbb_extensions ( - extension_id INTEGER NOT NULL, - group_id INTEGER DEFAULT 0 NOT NULL, - extension VARCHAR(100) CHARACTER SET NONE DEFAULT '' NOT NULL -);; - -ALTER TABLE phpbb_extensions ADD PRIMARY KEY (extension_id);; - - -CREATE GENERATOR phpbb_extensions_gen;; -SET GENERATOR phpbb_extensions_gen TO 0;; - -CREATE TRIGGER t_phpbb_extensions FOR phpbb_extensions -BEFORE INSERT -AS -BEGIN - NEW.extension_id = GEN_ID(phpbb_extensions_gen, 1); -END;; - - -# Table: 'phpbb_extension_groups' -CREATE TABLE phpbb_extension_groups ( - group_id INTEGER NOT NULL, - group_name VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, - cat_id INTEGER DEFAULT 0 NOT NULL, - allow_group INTEGER DEFAULT 0 NOT NULL, - download_mode INTEGER DEFAULT 1 NOT NULL, - upload_icon VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL, - max_filesize INTEGER DEFAULT 0 NOT NULL, - allowed_forums BLOB SUB_TYPE TEXT CHARACTER SET NONE DEFAULT '' NOT NULL, - allow_in_pm INTEGER DEFAULT 0 NOT NULL -);; - -ALTER TABLE phpbb_extension_groups ADD PRIMARY KEY (group_id);; - - -CREATE GENERATOR phpbb_extension_groups_gen;; -SET GENERATOR phpbb_extension_groups_gen TO 0;; - -CREATE TRIGGER t_phpbb_extension_groups FOR phpbb_extension_groups -BEFORE INSERT -AS -BEGIN - NEW.group_id = GEN_ID(phpbb_extension_groups_gen, 1); -END;; - - -# Table: 'phpbb_forums' -CREATE TABLE phpbb_forums ( - forum_id INTEGER NOT NULL, - parent_id INTEGER DEFAULT 0 NOT NULL, - left_id INTEGER DEFAULT 0 NOT NULL, - right_id INTEGER DEFAULT 0 NOT NULL, - forum_parents BLOB SUB_TYPE TEXT CHARACTER SET NONE DEFAULT '' NOT NULL, - forum_name VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, - forum_desc BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL, - forum_desc_bitfield VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL, - forum_desc_options INTEGER DEFAULT 7 NOT NULL, - forum_desc_uid VARCHAR(8) CHARACTER SET NONE DEFAULT '' NOT NULL, - forum_link VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, - forum_password VARCHAR(40) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, - forum_style INTEGER DEFAULT 0 NOT NULL, - forum_image VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL, - forum_rules BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL, - forum_rules_link VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, - forum_rules_bitfield VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL, - forum_rules_options INTEGER DEFAULT 7 NOT NULL, - forum_rules_uid VARCHAR(8) CHARACTER SET NONE DEFAULT '' NOT NULL, - forum_topics_per_page INTEGER DEFAULT 0 NOT NULL, - forum_type INTEGER DEFAULT 0 NOT NULL, - forum_status INTEGER DEFAULT 0 NOT NULL, - forum_posts INTEGER DEFAULT 0 NOT NULL, - forum_topics INTEGER DEFAULT 0 NOT NULL, - forum_topics_real INTEGER DEFAULT 0 NOT NULL, - forum_last_post_id INTEGER DEFAULT 0 NOT NULL, - forum_last_poster_id INTEGER DEFAULT 0 NOT NULL, - forum_last_post_subject VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, - forum_last_post_time INTEGER DEFAULT 0 NOT NULL, - forum_last_poster_name VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, - forum_last_poster_colour VARCHAR(6) CHARACTER SET NONE DEFAULT '' NOT NULL, - forum_flags INTEGER DEFAULT 32 NOT NULL, - forum_options INTEGER DEFAULT 0 NOT NULL, - display_subforum_list INTEGER DEFAULT 1 NOT NULL, - display_on_index INTEGER DEFAULT 1 NOT NULL, - enable_indexing INTEGER DEFAULT 1 NOT NULL, - enable_icons INTEGER DEFAULT 1 NOT NULL, - enable_prune INTEGER DEFAULT 0 NOT NULL, - prune_next INTEGER DEFAULT 0 NOT NULL, - prune_days INTEGER DEFAULT 0 NOT NULL, - prune_viewed INTEGER DEFAULT 0 NOT NULL, - prune_freq INTEGER DEFAULT 0 NOT NULL -);; - -ALTER TABLE phpbb_forums ADD PRIMARY KEY (forum_id);; - -CREATE INDEX phpbb_forums_left_right_id ON phpbb_forums(left_id, right_id);; -CREATE INDEX phpbb_forums_forum_lastpost_id ON phpbb_forums(forum_last_post_id);; - -CREATE GENERATOR phpbb_forums_gen;; -SET GENERATOR phpbb_forums_gen TO 0;; - -CREATE TRIGGER t_phpbb_forums FOR phpbb_forums -BEFORE INSERT -AS -BEGIN - NEW.forum_id = GEN_ID(phpbb_forums_gen, 1); -END;; - - -# Table: 'phpbb_forums_access' -CREATE TABLE phpbb_forums_access ( - forum_id INTEGER DEFAULT 0 NOT NULL, - user_id INTEGER DEFAULT 0 NOT NULL, - session_id CHAR(32) CHARACTER SET NONE DEFAULT '' NOT NULL -);; - -ALTER TABLE phpbb_forums_access ADD PRIMARY KEY (forum_id, user_id, session_id);; - - -# Table: 'phpbb_forums_track' -CREATE TABLE phpbb_forums_track ( - user_id INTEGER DEFAULT 0 NOT NULL, - forum_id INTEGER DEFAULT 0 NOT NULL, - mark_time INTEGER DEFAULT 0 NOT NULL -);; - -ALTER TABLE phpbb_forums_track ADD PRIMARY KEY (user_id, forum_id);; - - -# Table: 'phpbb_forums_watch' -CREATE TABLE phpbb_forums_watch ( - forum_id INTEGER DEFAULT 0 NOT NULL, - user_id INTEGER DEFAULT 0 NOT NULL, - notify_status INTEGER DEFAULT 0 NOT NULL -);; - -CREATE INDEX phpbb_forums_watch_forum_id ON phpbb_forums_watch(forum_id);; -CREATE INDEX phpbb_forums_watch_user_id ON phpbb_forums_watch(user_id);; -CREATE INDEX phpbb_forums_watch_notify_stat ON phpbb_forums_watch(notify_status);; - -# Table: 'phpbb_groups' -CREATE TABLE phpbb_groups ( - group_id INTEGER NOT NULL, - group_type INTEGER DEFAULT 1 NOT NULL, - group_founder_manage INTEGER DEFAULT 0 NOT NULL, - group_skip_auth INTEGER DEFAULT 0 NOT NULL, - group_name VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, - group_desc BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL, - group_desc_bitfield VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL, - group_desc_options INTEGER DEFAULT 7 NOT NULL, - group_desc_uid VARCHAR(8) CHARACTER SET NONE DEFAULT '' NOT NULL, - group_display INTEGER DEFAULT 0 NOT NULL, - group_avatar VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL, - group_avatar_type INTEGER DEFAULT 0 NOT NULL, - group_avatar_width INTEGER DEFAULT 0 NOT NULL, - group_avatar_height INTEGER DEFAULT 0 NOT NULL, - group_rank INTEGER DEFAULT 0 NOT NULL, - group_colour VARCHAR(6) CHARACTER SET NONE DEFAULT '' NOT NULL, - group_sig_chars INTEGER DEFAULT 0 NOT NULL, - group_receive_pm INTEGER DEFAULT 0 NOT NULL, - group_message_limit INTEGER DEFAULT 0 NOT NULL, - group_max_recipients INTEGER DEFAULT 0 NOT NULL, - group_legend INTEGER DEFAULT 0 NOT NULL, - group_teampage INTEGER DEFAULT 0 NOT NULL -);; - -ALTER TABLE phpbb_groups ADD PRIMARY KEY (group_id);; - -CREATE INDEX phpbb_groups_group_legend_name ON phpbb_groups(group_legend, group_name);; - -CREATE GENERATOR phpbb_groups_gen;; -SET GENERATOR phpbb_groups_gen TO 0;; - -CREATE TRIGGER t_phpbb_groups FOR phpbb_groups -BEFORE INSERT -AS -BEGIN - NEW.group_id = GEN_ID(phpbb_groups_gen, 1); -END;; - - -# Table: 'phpbb_icons' -CREATE TABLE phpbb_icons ( - icons_id INTEGER NOT NULL, - icons_url VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL, - icons_width INTEGER DEFAULT 0 NOT NULL, - icons_height INTEGER DEFAULT 0 NOT NULL, - icons_order INTEGER DEFAULT 0 NOT NULL, - display_on_posting INTEGER DEFAULT 1 NOT NULL -);; - -ALTER TABLE phpbb_icons ADD PRIMARY KEY (icons_id);; - -CREATE INDEX phpbb_icons_display_on_posting ON phpbb_icons(display_on_posting);; - -CREATE GENERATOR phpbb_icons_gen;; -SET GENERATOR phpbb_icons_gen TO 0;; - -CREATE TRIGGER t_phpbb_icons FOR phpbb_icons -BEFORE INSERT -AS -BEGIN - NEW.icons_id = GEN_ID(phpbb_icons_gen, 1); -END;; - - -# Table: 'phpbb_lang' -CREATE TABLE phpbb_lang ( - lang_id INTEGER NOT NULL, - lang_iso VARCHAR(30) CHARACTER SET NONE DEFAULT '' NOT NULL, - lang_dir VARCHAR(30) CHARACTER SET NONE DEFAULT '' NOT NULL, - lang_english_name VARCHAR(100) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, - lang_local_name VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, - lang_author VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE -);; - -ALTER TABLE phpbb_lang ADD PRIMARY KEY (lang_id);; - -CREATE INDEX phpbb_lang_lang_iso ON phpbb_lang(lang_iso);; - -CREATE GENERATOR phpbb_lang_gen;; -SET GENERATOR phpbb_lang_gen TO 0;; - -CREATE TRIGGER t_phpbb_lang FOR phpbb_lang -BEFORE INSERT -AS -BEGIN - NEW.lang_id = GEN_ID(phpbb_lang_gen, 1); -END;; - - -# Table: 'phpbb_log' -CREATE TABLE phpbb_log ( - log_id INTEGER NOT NULL, - log_type INTEGER DEFAULT 0 NOT NULL, - user_id INTEGER DEFAULT 0 NOT NULL, - forum_id INTEGER DEFAULT 0 NOT NULL, - topic_id INTEGER DEFAULT 0 NOT NULL, - reportee_id INTEGER DEFAULT 0 NOT NULL, - log_ip VARCHAR(40) CHARACTER SET NONE DEFAULT '' NOT NULL, - log_time INTEGER DEFAULT 0 NOT NULL, - log_operation BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL, - log_data BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL -);; - -ALTER TABLE phpbb_log ADD PRIMARY KEY (log_id);; - -CREATE INDEX phpbb_log_log_type ON phpbb_log(log_type);; -CREATE INDEX phpbb_log_log_time ON phpbb_log(log_time);; -CREATE INDEX phpbb_log_forum_id ON phpbb_log(forum_id);; -CREATE INDEX phpbb_log_topic_id ON phpbb_log(topic_id);; -CREATE INDEX phpbb_log_reportee_id ON phpbb_log(reportee_id);; -CREATE INDEX phpbb_log_user_id ON phpbb_log(user_id);; - -CREATE GENERATOR phpbb_log_gen;; -SET GENERATOR phpbb_log_gen TO 0;; - -CREATE TRIGGER t_phpbb_log FOR phpbb_log -BEFORE INSERT -AS -BEGIN - NEW.log_id = GEN_ID(phpbb_log_gen, 1); -END;; - - -# Table: 'phpbb_login_attempts' -CREATE TABLE phpbb_login_attempts ( - attempt_ip VARCHAR(40) CHARACTER SET NONE DEFAULT '' NOT NULL, - attempt_browser VARCHAR(150) CHARACTER SET NONE DEFAULT '' NOT NULL, - attempt_forwarded_for VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL, - attempt_time INTEGER DEFAULT 0 NOT NULL, - user_id INTEGER DEFAULT 0 NOT NULL, - username VARCHAR(255) CHARACTER SET UTF8 DEFAULT 0 NOT NULL COLLATE UNICODE, - username_clean VARCHAR(255) CHARACTER SET UTF8 DEFAULT 0 NOT NULL COLLATE UNICODE -);; - -CREATE INDEX phpbb_login_attempts_att_ip ON phpbb_login_attempts(attempt_ip, attempt_time);; -CREATE INDEX phpbb_login_attempts_att_for ON phpbb_login_attempts(attempt_forwarded_for, attempt_time);; -CREATE INDEX phpbb_login_attempts_att_time ON phpbb_login_attempts(attempt_time);; -CREATE INDEX phpbb_login_attempts_user_id ON phpbb_login_attempts(user_id);; - -# Table: 'phpbb_moderator_cache' -CREATE TABLE phpbb_moderator_cache ( - forum_id INTEGER DEFAULT 0 NOT NULL, - user_id INTEGER DEFAULT 0 NOT NULL, - username VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, - group_id INTEGER DEFAULT 0 NOT NULL, - group_name VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, - display_on_index INTEGER DEFAULT 1 NOT NULL -);; - -CREATE INDEX phpbb_moderator_cache_disp_idx ON phpbb_moderator_cache(display_on_index);; -CREATE INDEX phpbb_moderator_cache_forum_id ON phpbb_moderator_cache(forum_id);; - -# Table: 'phpbb_modules' -CREATE TABLE phpbb_modules ( - module_id INTEGER NOT NULL, - module_enabled INTEGER DEFAULT 1 NOT NULL, - module_display INTEGER DEFAULT 1 NOT NULL, - module_basename VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL, - module_class VARCHAR(10) CHARACTER SET NONE DEFAULT '' NOT NULL, - parent_id INTEGER DEFAULT 0 NOT NULL, - left_id INTEGER DEFAULT 0 NOT NULL, - right_id INTEGER DEFAULT 0 NOT NULL, - module_langname VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL, - module_mode VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL, - module_auth VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL -);; - -ALTER TABLE phpbb_modules ADD PRIMARY KEY (module_id);; - -CREATE INDEX phpbb_modules_left_right_id ON phpbb_modules(left_id, right_id);; -CREATE INDEX phpbb_modules_module_enabled ON phpbb_modules(module_enabled);; -CREATE INDEX phpbb_modules_class_left_id ON phpbb_modules(module_class, left_id);; - -CREATE GENERATOR phpbb_modules_gen;; -SET GENERATOR phpbb_modules_gen TO 0;; - -CREATE TRIGGER t_phpbb_modules FOR phpbb_modules -BEFORE INSERT -AS -BEGIN - NEW.module_id = GEN_ID(phpbb_modules_gen, 1); -END;; - - -# Table: 'phpbb_poll_options' -CREATE TABLE phpbb_poll_options ( - poll_option_id INTEGER DEFAULT 0 NOT NULL, - topic_id INTEGER DEFAULT 0 NOT NULL, - poll_option_text BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL, - poll_option_total INTEGER DEFAULT 0 NOT NULL -);; - -CREATE INDEX phpbb_poll_options_poll_opt_id ON phpbb_poll_options(poll_option_id);; -CREATE INDEX phpbb_poll_options_topic_id ON phpbb_poll_options(topic_id);; - -# Table: 'phpbb_poll_votes' -CREATE TABLE phpbb_poll_votes ( - topic_id INTEGER DEFAULT 0 NOT NULL, - poll_option_id INTEGER DEFAULT 0 NOT NULL, - vote_user_id INTEGER DEFAULT 0 NOT NULL, - vote_user_ip VARCHAR(40) CHARACTER SET NONE DEFAULT '' NOT NULL -);; - -CREATE INDEX phpbb_poll_votes_topic_id ON phpbb_poll_votes(topic_id);; -CREATE INDEX phpbb_poll_votes_vote_user_id ON phpbb_poll_votes(vote_user_id);; -CREATE INDEX phpbb_poll_votes_vote_user_ip ON phpbb_poll_votes(vote_user_ip);; - -# Table: 'phpbb_posts' -CREATE TABLE phpbb_posts ( - post_id INTEGER NOT NULL, - topic_id INTEGER DEFAULT 0 NOT NULL, - forum_id INTEGER DEFAULT 0 NOT NULL, - poster_id INTEGER DEFAULT 0 NOT NULL, - icon_id INTEGER DEFAULT 0 NOT NULL, - poster_ip VARCHAR(40) CHARACTER SET NONE DEFAULT '' NOT NULL, - post_time INTEGER DEFAULT 0 NOT NULL, - post_approved INTEGER DEFAULT 1 NOT NULL, - post_reported INTEGER DEFAULT 0 NOT NULL, - enable_bbcode INTEGER DEFAULT 1 NOT NULL, - enable_smilies INTEGER DEFAULT 1 NOT NULL, - enable_magic_url INTEGER DEFAULT 1 NOT NULL, - enable_sig INTEGER DEFAULT 1 NOT NULL, - post_username VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, - post_subject VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, - post_text BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL, - post_checksum VARCHAR(32) CHARACTER SET NONE DEFAULT '' NOT NULL, - post_attachment INTEGER DEFAULT 0 NOT NULL, - bbcode_bitfield VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL, - bbcode_uid VARCHAR(8) CHARACTER SET NONE DEFAULT '' NOT NULL, - post_postcount INTEGER DEFAULT 1 NOT NULL, - post_edit_time INTEGER DEFAULT 0 NOT NULL, - post_edit_reason VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, - post_edit_user INTEGER DEFAULT 0 NOT NULL, - post_edit_count INTEGER DEFAULT 0 NOT NULL, - post_edit_locked INTEGER DEFAULT 0 NOT NULL -);; - -ALTER TABLE phpbb_posts ADD PRIMARY KEY (post_id);; - -CREATE INDEX phpbb_posts_forum_id ON phpbb_posts(forum_id);; -CREATE INDEX phpbb_posts_topic_id ON phpbb_posts(topic_id);; -CREATE INDEX phpbb_posts_poster_ip ON phpbb_posts(poster_ip);; -CREATE INDEX phpbb_posts_poster_id ON phpbb_posts(poster_id);; -CREATE INDEX phpbb_posts_post_approved ON phpbb_posts(post_approved);; -CREATE INDEX phpbb_posts_post_username ON phpbb_posts(post_username);; -CREATE INDEX phpbb_posts_tid_post_time ON phpbb_posts(topic_id, post_time);; - -CREATE GENERATOR phpbb_posts_gen;; -SET GENERATOR phpbb_posts_gen TO 0;; - -CREATE TRIGGER t_phpbb_posts FOR phpbb_posts -BEFORE INSERT -AS -BEGIN - NEW.post_id = GEN_ID(phpbb_posts_gen, 1); -END;; - - -# Table: 'phpbb_privmsgs' -CREATE TABLE phpbb_privmsgs ( - msg_id INTEGER NOT NULL, - root_level INTEGER DEFAULT 0 NOT NULL, - author_id INTEGER DEFAULT 0 NOT NULL, - icon_id INTEGER DEFAULT 0 NOT NULL, - author_ip VARCHAR(40) CHARACTER SET NONE DEFAULT '' NOT NULL, - message_time INTEGER DEFAULT 0 NOT NULL, - enable_bbcode INTEGER DEFAULT 1 NOT NULL, - enable_smilies INTEGER DEFAULT 1 NOT NULL, - enable_magic_url INTEGER DEFAULT 1 NOT NULL, - enable_sig INTEGER DEFAULT 1 NOT NULL, - message_subject VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, - message_text BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL, - message_edit_reason VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, - message_edit_user INTEGER DEFAULT 0 NOT NULL, - message_attachment INTEGER DEFAULT 0 NOT NULL, - bbcode_bitfield VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL, - bbcode_uid VARCHAR(8) CHARACTER SET NONE DEFAULT '' NOT NULL, - message_edit_time INTEGER DEFAULT 0 NOT NULL, - message_edit_count INTEGER DEFAULT 0 NOT NULL, - to_address BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL, - bcc_address BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL, - message_reported INTEGER DEFAULT 0 NOT NULL -);; - -ALTER TABLE phpbb_privmsgs ADD PRIMARY KEY (msg_id);; - -CREATE INDEX phpbb_privmsgs_author_ip ON phpbb_privmsgs(author_ip);; -CREATE INDEX phpbb_privmsgs_message_time ON phpbb_privmsgs(message_time);; -CREATE INDEX phpbb_privmsgs_author_id ON phpbb_privmsgs(author_id);; -CREATE INDEX phpbb_privmsgs_root_level ON phpbb_privmsgs(root_level);; - -CREATE GENERATOR phpbb_privmsgs_gen;; -SET GENERATOR phpbb_privmsgs_gen TO 0;; - -CREATE TRIGGER t_phpbb_privmsgs FOR phpbb_privmsgs -BEFORE INSERT -AS -BEGIN - NEW.msg_id = GEN_ID(phpbb_privmsgs_gen, 1); -END;; - - -# Table: 'phpbb_privmsgs_folder' -CREATE TABLE phpbb_privmsgs_folder ( - folder_id INTEGER NOT NULL, - user_id INTEGER DEFAULT 0 NOT NULL, - folder_name VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, - pm_count INTEGER DEFAULT 0 NOT NULL -);; - -ALTER TABLE phpbb_privmsgs_folder ADD PRIMARY KEY (folder_id);; - -CREATE INDEX phpbb_privmsgs_folder_user_id ON phpbb_privmsgs_folder(user_id);; - -CREATE GENERATOR phpbb_privmsgs_folder_gen;; -SET GENERATOR phpbb_privmsgs_folder_gen TO 0;; - -CREATE TRIGGER t_phpbb_privmsgs_folder FOR phpbb_privmsgs_folder -BEFORE INSERT -AS -BEGIN - NEW.folder_id = GEN_ID(phpbb_privmsgs_folder_gen, 1); -END;; - - -# Table: 'phpbb_privmsgs_rules' -CREATE TABLE phpbb_privmsgs_rules ( - rule_id INTEGER NOT NULL, - user_id INTEGER DEFAULT 0 NOT NULL, - rule_check INTEGER DEFAULT 0 NOT NULL, - rule_connection INTEGER DEFAULT 0 NOT NULL, - rule_string VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, - rule_user_id INTEGER DEFAULT 0 NOT NULL, - rule_group_id INTEGER DEFAULT 0 NOT NULL, - rule_action INTEGER DEFAULT 0 NOT NULL, - rule_folder_id INTEGER DEFAULT 0 NOT NULL -);; - -ALTER TABLE phpbb_privmsgs_rules ADD PRIMARY KEY (rule_id);; - -CREATE INDEX phpbb_privmsgs_rules_user_id ON phpbb_privmsgs_rules(user_id);; - -CREATE GENERATOR phpbb_privmsgs_rules_gen;; -SET GENERATOR phpbb_privmsgs_rules_gen TO 0;; - -CREATE TRIGGER t_phpbb_privmsgs_rules FOR phpbb_privmsgs_rules -BEFORE INSERT -AS -BEGIN - NEW.rule_id = GEN_ID(phpbb_privmsgs_rules_gen, 1); -END;; - - -# Table: 'phpbb_privmsgs_to' -CREATE TABLE phpbb_privmsgs_to ( - msg_id INTEGER DEFAULT 0 NOT NULL, - user_id INTEGER DEFAULT 0 NOT NULL, - author_id INTEGER DEFAULT 0 NOT NULL, - pm_deleted INTEGER DEFAULT 0 NOT NULL, - pm_new INTEGER DEFAULT 1 NOT NULL, - pm_unread INTEGER DEFAULT 1 NOT NULL, - pm_replied INTEGER DEFAULT 0 NOT NULL, - pm_marked INTEGER DEFAULT 0 NOT NULL, - pm_forwarded INTEGER DEFAULT 0 NOT NULL, - folder_id INTEGER DEFAULT 0 NOT NULL -);; - -CREATE INDEX phpbb_privmsgs_to_msg_id ON phpbb_privmsgs_to(msg_id);; -CREATE INDEX phpbb_privmsgs_to_author_id ON phpbb_privmsgs_to(author_id);; -CREATE INDEX phpbb_privmsgs_to_usr_flder_id ON phpbb_privmsgs_to(user_id, folder_id);; - -# Table: 'phpbb_profile_fields' -CREATE TABLE phpbb_profile_fields ( - field_id INTEGER NOT NULL, - field_name VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, - field_type INTEGER DEFAULT 0 NOT NULL, - field_ident VARCHAR(20) CHARACTER SET NONE DEFAULT '' NOT NULL, - field_length VARCHAR(20) CHARACTER SET NONE DEFAULT '' NOT NULL, - field_minlen VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL, - field_maxlen VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL, - field_novalue VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, - field_default_value VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, - field_validation VARCHAR(20) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, - field_required INTEGER DEFAULT 0 NOT NULL, - field_show_novalue INTEGER DEFAULT 0 NOT NULL, - field_show_on_reg INTEGER DEFAULT 0 NOT NULL, - field_show_on_pm INTEGER DEFAULT 0 NOT NULL, - field_show_on_vt INTEGER DEFAULT 0 NOT NULL, - field_show_profile INTEGER DEFAULT 0 NOT NULL, - field_hide INTEGER DEFAULT 0 NOT NULL, - field_no_view INTEGER DEFAULT 0 NOT NULL, - field_active INTEGER DEFAULT 0 NOT NULL, - field_order INTEGER DEFAULT 0 NOT NULL -);; - -ALTER TABLE phpbb_profile_fields ADD PRIMARY KEY (field_id);; - -CREATE INDEX phpbb_profile_fields_fld_type ON phpbb_profile_fields(field_type);; -CREATE INDEX phpbb_profile_fields_fld_ordr ON phpbb_profile_fields(field_order);; - -CREATE GENERATOR phpbb_profile_fields_gen;; -SET GENERATOR phpbb_profile_fields_gen TO 0;; - -CREATE TRIGGER t_phpbb_profile_fields FOR phpbb_profile_fields -BEFORE INSERT -AS -BEGIN - NEW.field_id = GEN_ID(phpbb_profile_fields_gen, 1); -END;; - - -# Table: 'phpbb_profile_fields_data' -CREATE TABLE phpbb_profile_fields_data ( - user_id INTEGER DEFAULT 0 NOT NULL -);; - -ALTER TABLE phpbb_profile_fields_data ADD PRIMARY KEY (user_id);; - - -# Table: 'phpbb_profile_fields_lang' -CREATE TABLE phpbb_profile_fields_lang ( - field_id INTEGER DEFAULT 0 NOT NULL, - lang_id INTEGER DEFAULT 0 NOT NULL, - option_id INTEGER DEFAULT 0 NOT NULL, - field_type INTEGER DEFAULT 0 NOT NULL, - lang_value VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE -);; - -ALTER TABLE phpbb_profile_fields_lang ADD PRIMARY KEY (field_id, lang_id, option_id);; - - -# Table: 'phpbb_profile_lang' -CREATE TABLE phpbb_profile_lang ( - field_id INTEGER DEFAULT 0 NOT NULL, - lang_id INTEGER DEFAULT 0 NOT NULL, - lang_name VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, - lang_explain BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL, - lang_default_value VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE -);; - -ALTER TABLE phpbb_profile_lang ADD PRIMARY KEY (field_id, lang_id);; - - -# Table: 'phpbb_ranks' -CREATE TABLE phpbb_ranks ( - rank_id INTEGER NOT NULL, - rank_title VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, - rank_min INTEGER DEFAULT 0 NOT NULL, - rank_special INTEGER DEFAULT 0 NOT NULL, - rank_image VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL -);; - -ALTER TABLE phpbb_ranks ADD PRIMARY KEY (rank_id);; - - -CREATE GENERATOR phpbb_ranks_gen;; -SET GENERATOR phpbb_ranks_gen TO 0;; - -CREATE TRIGGER t_phpbb_ranks FOR phpbb_ranks -BEFORE INSERT -AS -BEGIN - NEW.rank_id = GEN_ID(phpbb_ranks_gen, 1); -END;; - - -# Table: 'phpbb_reports' -CREATE TABLE phpbb_reports ( - report_id INTEGER NOT NULL, - reason_id INTEGER DEFAULT 0 NOT NULL, - post_id INTEGER DEFAULT 0 NOT NULL, - pm_id INTEGER DEFAULT 0 NOT NULL, - user_id INTEGER DEFAULT 0 NOT NULL, - user_notify INTEGER DEFAULT 0 NOT NULL, - report_closed INTEGER DEFAULT 0 NOT NULL, - report_time INTEGER DEFAULT 0 NOT NULL, - report_text BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL, - reported_post_text BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL -);; - -ALTER TABLE phpbb_reports ADD PRIMARY KEY (report_id);; - -CREATE INDEX phpbb_reports_post_id ON phpbb_reports(post_id);; -CREATE INDEX phpbb_reports_pm_id ON phpbb_reports(pm_id);; - -CREATE GENERATOR phpbb_reports_gen;; -SET GENERATOR phpbb_reports_gen TO 0;; - -CREATE TRIGGER t_phpbb_reports FOR phpbb_reports -BEFORE INSERT -AS -BEGIN - NEW.report_id = GEN_ID(phpbb_reports_gen, 1); -END;; - - -# Table: 'phpbb_reports_reasons' -CREATE TABLE phpbb_reports_reasons ( - reason_id INTEGER NOT NULL, - reason_title VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, - reason_description BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL, - reason_order INTEGER DEFAULT 0 NOT NULL -);; - -ALTER TABLE phpbb_reports_reasons ADD PRIMARY KEY (reason_id);; - - -CREATE GENERATOR phpbb_reports_reasons_gen;; -SET GENERATOR phpbb_reports_reasons_gen TO 0;; - -CREATE TRIGGER t_phpbb_reports_reasons FOR phpbb_reports_reasons -BEFORE INSERT -AS -BEGIN - NEW.reason_id = GEN_ID(phpbb_reports_reasons_gen, 1); -END;; - - -# Table: 'phpbb_search_results' -CREATE TABLE phpbb_search_results ( - search_key VARCHAR(32) CHARACTER SET NONE DEFAULT '' NOT NULL, - search_time INTEGER DEFAULT 0 NOT NULL, - search_keywords BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL, - search_authors BLOB SUB_TYPE TEXT CHARACTER SET NONE DEFAULT '' NOT NULL -);; - -ALTER TABLE phpbb_search_results ADD PRIMARY KEY (search_key);; - - -# Table: 'phpbb_search_wordlist' -CREATE TABLE phpbb_search_wordlist ( - word_id INTEGER NOT NULL, - word_text VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, - word_common INTEGER DEFAULT 0 NOT NULL, - word_count INTEGER DEFAULT 0 NOT NULL -);; - -ALTER TABLE phpbb_search_wordlist ADD PRIMARY KEY (word_id);; - -CREATE UNIQUE INDEX phpbb_search_wordlist_wrd_txt ON phpbb_search_wordlist(word_text);; -CREATE INDEX phpbb_search_wordlist_wrd_cnt ON phpbb_search_wordlist(word_count);; - -CREATE GENERATOR phpbb_search_wordlist_gen;; -SET GENERATOR phpbb_search_wordlist_gen TO 0;; - -CREATE TRIGGER t_phpbb_search_wordlist FOR phpbb_search_wordlist -BEFORE INSERT -AS -BEGIN - NEW.word_id = GEN_ID(phpbb_search_wordlist_gen, 1); -END;; - - -# Table: 'phpbb_search_wordmatch' -CREATE TABLE phpbb_search_wordmatch ( - post_id INTEGER DEFAULT 0 NOT NULL, - word_id INTEGER DEFAULT 0 NOT NULL, - title_match INTEGER DEFAULT 0 NOT NULL -);; - -CREATE UNIQUE INDEX phpbb_search_wordmatch_unq_mtch ON phpbb_search_wordmatch(word_id, post_id, title_match);; -CREATE INDEX phpbb_search_wordmatch_word_id ON phpbb_search_wordmatch(word_id);; -CREATE INDEX phpbb_search_wordmatch_post_id ON phpbb_search_wordmatch(post_id);; - -# Table: 'phpbb_sessions' -CREATE TABLE phpbb_sessions ( - session_id CHAR(32) CHARACTER SET NONE DEFAULT '' NOT NULL, - session_user_id INTEGER DEFAULT 0 NOT NULL, - session_forum_id INTEGER DEFAULT 0 NOT NULL, - session_last_visit INTEGER DEFAULT 0 NOT NULL, - session_start INTEGER DEFAULT 0 NOT NULL, - session_time INTEGER DEFAULT 0 NOT NULL, - session_ip VARCHAR(40) CHARACTER SET NONE DEFAULT '' NOT NULL, - session_browser VARCHAR(150) CHARACTER SET NONE DEFAULT '' NOT NULL, - session_forwarded_for VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL, - session_page VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, - session_viewonline INTEGER DEFAULT 1 NOT NULL, - session_autologin INTEGER DEFAULT 0 NOT NULL, - session_admin INTEGER DEFAULT 0 NOT NULL -);; - -ALTER TABLE phpbb_sessions ADD PRIMARY KEY (session_id);; - -CREATE INDEX phpbb_sessions_session_time ON phpbb_sessions(session_time);; -CREATE INDEX phpbb_sessions_session_user_id ON phpbb_sessions(session_user_id);; -CREATE INDEX phpbb_sessions_session_fid ON phpbb_sessions(session_forum_id);; - -# Table: 'phpbb_sessions_keys' -CREATE TABLE phpbb_sessions_keys ( - key_id CHAR(32) CHARACTER SET NONE DEFAULT '' NOT NULL, - user_id INTEGER DEFAULT 0 NOT NULL, - last_ip VARCHAR(40) CHARACTER SET NONE DEFAULT '' NOT NULL, - last_login INTEGER DEFAULT 0 NOT NULL -);; - -ALTER TABLE phpbb_sessions_keys ADD PRIMARY KEY (key_id, user_id);; - -CREATE INDEX phpbb_sessions_keys_last_login ON phpbb_sessions_keys(last_login);; - -# Table: 'phpbb_sitelist' -CREATE TABLE phpbb_sitelist ( - site_id INTEGER NOT NULL, - site_ip VARCHAR(40) CHARACTER SET NONE DEFAULT '' NOT NULL, - site_hostname VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL, - ip_exclude INTEGER DEFAULT 0 NOT NULL -);; - -ALTER TABLE phpbb_sitelist ADD PRIMARY KEY (site_id);; - - -CREATE GENERATOR phpbb_sitelist_gen;; -SET GENERATOR phpbb_sitelist_gen TO 0;; - -CREATE TRIGGER t_phpbb_sitelist FOR phpbb_sitelist -BEFORE INSERT -AS -BEGIN - NEW.site_id = GEN_ID(phpbb_sitelist_gen, 1); -END;; - - -# Table: 'phpbb_smilies' -CREATE TABLE phpbb_smilies ( - smiley_id INTEGER NOT NULL, - code VARCHAR(50) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, - emotion VARCHAR(50) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, - smiley_url VARCHAR(50) CHARACTER SET NONE DEFAULT '' NOT NULL, - smiley_width INTEGER DEFAULT 0 NOT NULL, - smiley_height INTEGER DEFAULT 0 NOT NULL, - smiley_order INTEGER DEFAULT 0 NOT NULL, - display_on_posting INTEGER DEFAULT 1 NOT NULL -);; - -ALTER TABLE phpbb_smilies ADD PRIMARY KEY (smiley_id);; - -CREATE INDEX phpbb_smilies_display_on_post ON phpbb_smilies(display_on_posting);; - -CREATE GENERATOR phpbb_smilies_gen;; -SET GENERATOR phpbb_smilies_gen TO 0;; - -CREATE TRIGGER t_phpbb_smilies FOR phpbb_smilies -BEFORE INSERT -AS -BEGIN - NEW.smiley_id = GEN_ID(phpbb_smilies_gen, 1); -END;; - - -# Table: 'phpbb_styles' -CREATE TABLE phpbb_styles ( - style_id INTEGER NOT NULL, - style_name VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, - style_copyright VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, - style_active INTEGER DEFAULT 1 NOT NULL, - style_path VARCHAR(100) CHARACTER SET NONE DEFAULT '' NOT NULL, - bbcode_bitfield VARCHAR(255) CHARACTER SET NONE DEFAULT 'kNg=' NOT NULL, - style_parent_id INTEGER DEFAULT 0 NOT NULL, - style_parent_tree BLOB SUB_TYPE TEXT CHARACTER SET NONE DEFAULT '' NOT NULL -);; - -ALTER TABLE phpbb_styles ADD PRIMARY KEY (style_id);; - -CREATE UNIQUE INDEX phpbb_styles_style_name ON phpbb_styles(style_name);; - -CREATE GENERATOR phpbb_styles_gen;; -SET GENERATOR phpbb_styles_gen TO 0;; - -CREATE TRIGGER t_phpbb_styles FOR phpbb_styles -BEFORE INSERT -AS -BEGIN - NEW.style_id = GEN_ID(phpbb_styles_gen, 1); -END;; - - -# Table: 'phpbb_topics' -CREATE TABLE phpbb_topics ( - topic_id INTEGER NOT NULL, - forum_id INTEGER DEFAULT 0 NOT NULL, - icon_id INTEGER DEFAULT 0 NOT NULL, - topic_attachment INTEGER DEFAULT 0 NOT NULL, - topic_approved INTEGER DEFAULT 1 NOT NULL, - topic_reported INTEGER DEFAULT 0 NOT NULL, - topic_title VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, - topic_poster INTEGER DEFAULT 0 NOT NULL, - topic_time INTEGER DEFAULT 0 NOT NULL, - topic_time_limit INTEGER DEFAULT 0 NOT NULL, - topic_views INTEGER DEFAULT 0 NOT NULL, - topic_replies INTEGER DEFAULT 0 NOT NULL, - topic_replies_real INTEGER DEFAULT 0 NOT NULL, - topic_status INTEGER DEFAULT 0 NOT NULL, - topic_type INTEGER DEFAULT 0 NOT NULL, - topic_first_post_id INTEGER DEFAULT 0 NOT NULL, - topic_first_poster_name VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, - topic_first_poster_colour VARCHAR(6) CHARACTER SET NONE DEFAULT '' NOT NULL, - topic_last_post_id INTEGER DEFAULT 0 NOT NULL, - topic_last_poster_id INTEGER DEFAULT 0 NOT NULL, - topic_last_poster_name VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, - topic_last_poster_colour VARCHAR(6) CHARACTER SET NONE DEFAULT '' NOT NULL, - topic_last_post_subject VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, - topic_last_post_time INTEGER DEFAULT 0 NOT NULL, - topic_last_view_time INTEGER DEFAULT 0 NOT NULL, - topic_moved_id INTEGER DEFAULT 0 NOT NULL, - topic_bumped INTEGER DEFAULT 0 NOT NULL, - topic_bumper INTEGER DEFAULT 0 NOT NULL, - poll_title VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, - poll_start INTEGER DEFAULT 0 NOT NULL, - poll_length INTEGER DEFAULT 0 NOT NULL, - poll_max_options INTEGER DEFAULT 1 NOT NULL, - poll_last_vote INTEGER DEFAULT 0 NOT NULL, - poll_vote_change INTEGER DEFAULT 0 NOT NULL -);; - -ALTER TABLE phpbb_topics ADD PRIMARY KEY (topic_id);; - -CREATE INDEX phpbb_topics_forum_id ON phpbb_topics(forum_id);; -CREATE INDEX phpbb_topics_forum_id_type ON phpbb_topics(forum_id, topic_type);; -CREATE INDEX phpbb_topics_last_post_time ON phpbb_topics(topic_last_post_time);; -CREATE INDEX phpbb_topics_topic_approved ON phpbb_topics(topic_approved);; -CREATE INDEX phpbb_topics_forum_appr_last ON phpbb_topics(forum_id, topic_approved, topic_last_post_id);; -CREATE INDEX phpbb_topics_fid_time_moved ON phpbb_topics(forum_id, topic_last_post_time, topic_moved_id);; - -CREATE GENERATOR phpbb_topics_gen;; -SET GENERATOR phpbb_topics_gen TO 0;; - -CREATE TRIGGER t_phpbb_topics FOR phpbb_topics -BEFORE INSERT -AS -BEGIN - NEW.topic_id = GEN_ID(phpbb_topics_gen, 1); -END;; - - -# Table: 'phpbb_topics_track' -CREATE TABLE phpbb_topics_track ( - user_id INTEGER DEFAULT 0 NOT NULL, - topic_id INTEGER DEFAULT 0 NOT NULL, - forum_id INTEGER DEFAULT 0 NOT NULL, - mark_time INTEGER DEFAULT 0 NOT NULL -);; - -ALTER TABLE phpbb_topics_track ADD PRIMARY KEY (user_id, topic_id);; - -CREATE INDEX phpbb_topics_track_topic_id ON phpbb_topics_track(topic_id);; -CREATE INDEX phpbb_topics_track_forum_id ON phpbb_topics_track(forum_id);; - -# Table: 'phpbb_topics_posted' -CREATE TABLE phpbb_topics_posted ( - user_id INTEGER DEFAULT 0 NOT NULL, - topic_id INTEGER DEFAULT 0 NOT NULL, - topic_posted INTEGER DEFAULT 0 NOT NULL -);; - -ALTER TABLE phpbb_topics_posted ADD PRIMARY KEY (user_id, topic_id);; - - -# Table: 'phpbb_topics_watch' -CREATE TABLE phpbb_topics_watch ( - topic_id INTEGER DEFAULT 0 NOT NULL, - user_id INTEGER DEFAULT 0 NOT NULL, - notify_status INTEGER DEFAULT 0 NOT NULL -);; - -CREATE INDEX phpbb_topics_watch_topic_id ON phpbb_topics_watch(topic_id);; -CREATE INDEX phpbb_topics_watch_user_id ON phpbb_topics_watch(user_id);; -CREATE INDEX phpbb_topics_watch_notify_stat ON phpbb_topics_watch(notify_status);; - -# Table: 'phpbb_user_group' -CREATE TABLE phpbb_user_group ( - group_id INTEGER DEFAULT 0 NOT NULL, - user_id INTEGER DEFAULT 0 NOT NULL, - group_leader INTEGER DEFAULT 0 NOT NULL, - user_pending INTEGER DEFAULT 1 NOT NULL -);; - -CREATE INDEX phpbb_user_group_group_id ON phpbb_user_group(group_id);; -CREATE INDEX phpbb_user_group_user_id ON phpbb_user_group(user_id);; -CREATE INDEX phpbb_user_group_group_leader ON phpbb_user_group(group_leader);; - -# Table: 'phpbb_users' -CREATE TABLE phpbb_users ( - user_id INTEGER NOT NULL, - user_type INTEGER DEFAULT 0 NOT NULL, - group_id INTEGER DEFAULT 3 NOT NULL, - user_permissions BLOB SUB_TYPE TEXT CHARACTER SET NONE DEFAULT '' NOT NULL, - user_perm_from INTEGER DEFAULT 0 NOT NULL, - user_ip VARCHAR(40) CHARACTER SET NONE DEFAULT '' NOT NULL, - user_regdate INTEGER DEFAULT 0 NOT NULL, - username VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, - username_clean VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, - user_password VARCHAR(40) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, - user_passchg INTEGER DEFAULT 0 NOT NULL, - user_pass_convert INTEGER DEFAULT 0 NOT NULL, - user_email VARCHAR(100) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, - user_email_hash DOUBLE PRECISION DEFAULT 0 NOT NULL, - user_birthday VARCHAR(10) CHARACTER SET NONE DEFAULT '' NOT NULL, - user_lastvisit INTEGER DEFAULT 0 NOT NULL, - user_lastmark INTEGER DEFAULT 0 NOT NULL, - user_lastpost_time INTEGER DEFAULT 0 NOT NULL, - user_lastpage VARCHAR(200) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, - user_last_confirm_key VARCHAR(10) CHARACTER SET NONE DEFAULT '' NOT NULL, - user_last_search INTEGER DEFAULT 0 NOT NULL, - user_warnings INTEGER DEFAULT 0 NOT NULL, - user_last_warning INTEGER DEFAULT 0 NOT NULL, - user_login_attempts INTEGER DEFAULT 0 NOT NULL, - user_inactive_reason INTEGER DEFAULT 0 NOT NULL, - user_inactive_time INTEGER DEFAULT 0 NOT NULL, - user_posts INTEGER DEFAULT 0 NOT NULL, - user_lang VARCHAR(30) CHARACTER SET NONE DEFAULT '' NOT NULL, - user_timezone VARCHAR(100) CHARACTER SET NONE DEFAULT 'UTC' NOT NULL, - user_dateformat VARCHAR(30) CHARACTER SET UTF8 DEFAULT 'd M Y H:i' NOT NULL COLLATE UNICODE, - user_style INTEGER DEFAULT 0 NOT NULL, - user_rank INTEGER DEFAULT 0 NOT NULL, - user_colour VARCHAR(6) CHARACTER SET NONE DEFAULT '' NOT NULL, - user_new_privmsg INTEGER DEFAULT 0 NOT NULL, - user_unread_privmsg INTEGER DEFAULT 0 NOT NULL, - user_last_privmsg INTEGER DEFAULT 0 NOT NULL, - user_message_rules INTEGER DEFAULT 0 NOT NULL, - user_full_folder INTEGER DEFAULT -3 NOT NULL, - user_emailtime INTEGER DEFAULT 0 NOT NULL, - user_topic_show_days INTEGER DEFAULT 0 NOT NULL, - user_topic_sortby_type VARCHAR(1) CHARACTER SET NONE DEFAULT 't' NOT NULL, - user_topic_sortby_dir VARCHAR(1) CHARACTER SET NONE DEFAULT 'd' NOT NULL, - user_post_show_days INTEGER DEFAULT 0 NOT NULL, - user_post_sortby_type VARCHAR(1) CHARACTER SET NONE DEFAULT 't' NOT NULL, - user_post_sortby_dir VARCHAR(1) CHARACTER SET NONE DEFAULT 'a' NOT NULL, - user_notify INTEGER DEFAULT 0 NOT NULL, - user_notify_pm INTEGER DEFAULT 1 NOT NULL, - user_notify_type INTEGER DEFAULT 0 NOT NULL, - user_allow_pm INTEGER DEFAULT 1 NOT NULL, - user_allow_viewonline INTEGER DEFAULT 1 NOT NULL, - user_allow_viewemail INTEGER DEFAULT 1 NOT NULL, - user_allow_massemail INTEGER DEFAULT 1 NOT NULL, - user_options INTEGER DEFAULT 230271 NOT NULL, - user_avatar VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL, - user_avatar_type INTEGER DEFAULT 0 NOT NULL, - user_avatar_width INTEGER DEFAULT 0 NOT NULL, - user_avatar_height INTEGER DEFAULT 0 NOT NULL, - user_sig BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL, - user_sig_bbcode_uid VARCHAR(8) CHARACTER SET NONE DEFAULT '' NOT NULL, - user_sig_bbcode_bitfield VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL, - user_from VARCHAR(100) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, - user_icq VARCHAR(15) CHARACTER SET NONE DEFAULT '' NOT NULL, - user_aim VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, - user_yim VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, - user_msnm VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, - user_jabber VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, - user_website VARCHAR(200) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, - user_occ BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL, - user_interests BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL, - user_actkey VARCHAR(32) CHARACTER SET NONE DEFAULT '' NOT NULL, - user_newpasswd VARCHAR(40) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, - user_form_salt VARCHAR(32) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, - user_new INTEGER DEFAULT 1 NOT NULL, - user_reminded INTEGER DEFAULT 0 NOT NULL, - user_reminded_time INTEGER DEFAULT 0 NOT NULL -);; - -ALTER TABLE phpbb_users ADD PRIMARY KEY (user_id);; - -CREATE INDEX phpbb_users_user_birthday ON phpbb_users(user_birthday);; -CREATE INDEX phpbb_users_user_email_hash ON phpbb_users(user_email_hash);; -CREATE INDEX phpbb_users_user_type ON phpbb_users(user_type);; -CREATE UNIQUE INDEX phpbb_users_username_clean ON phpbb_users(username_clean);; - -CREATE GENERATOR phpbb_users_gen;; -SET GENERATOR phpbb_users_gen TO 0;; - -CREATE TRIGGER t_phpbb_users FOR phpbb_users -BEFORE INSERT -AS -BEGIN - NEW.user_id = GEN_ID(phpbb_users_gen, 1); -END;; - - -# Table: 'phpbb_warnings' -CREATE TABLE phpbb_warnings ( - warning_id INTEGER NOT NULL, - user_id INTEGER DEFAULT 0 NOT NULL, - post_id INTEGER DEFAULT 0 NOT NULL, - log_id INTEGER DEFAULT 0 NOT NULL, - warning_time INTEGER DEFAULT 0 NOT NULL -);; - -ALTER TABLE phpbb_warnings ADD PRIMARY KEY (warning_id);; - - -CREATE GENERATOR phpbb_warnings_gen;; -SET GENERATOR phpbb_warnings_gen TO 0;; - -CREATE TRIGGER t_phpbb_warnings FOR phpbb_warnings -BEFORE INSERT -AS -BEGIN - NEW.warning_id = GEN_ID(phpbb_warnings_gen, 1); -END;; - - -# Table: 'phpbb_words' -CREATE TABLE phpbb_words ( - word_id INTEGER NOT NULL, - word VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, - replacement VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE -);; - -ALTER TABLE phpbb_words ADD PRIMARY KEY (word_id);; - - -CREATE GENERATOR phpbb_words_gen;; -SET GENERATOR phpbb_words_gen TO 0;; - -CREATE TRIGGER t_phpbb_words FOR phpbb_words -BEFORE INSERT -AS -BEGIN - NEW.word_id = GEN_ID(phpbb_words_gen, 1); -END;; - - -# Table: 'phpbb_zebra' -CREATE TABLE phpbb_zebra ( - user_id INTEGER DEFAULT 0 NOT NULL, - zebra_id INTEGER DEFAULT 0 NOT NULL, - friend INTEGER DEFAULT 0 NOT NULL, - foe INTEGER DEFAULT 0 NOT NULL -);; - -ALTER TABLE phpbb_zebra ADD PRIMARY KEY (user_id, zebra_id);; - - +# DO NOT EDIT THIS FILE, IT IS GENERATED +# +# To change the contents of this file, edit +# phpBB/develop/create_schema_files.php and +# run it. + +# Table: 'phpbb_attachments' +CREATE TABLE phpbb_attachments ( + attach_id INTEGER NOT NULL, + post_msg_id INTEGER DEFAULT 0 NOT NULL, + topic_id INTEGER DEFAULT 0 NOT NULL, + in_message INTEGER DEFAULT 0 NOT NULL, + poster_id INTEGER DEFAULT 0 NOT NULL, + is_orphan INTEGER DEFAULT 1 NOT NULL, + physical_filename VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL, + real_filename VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL, + download_count INTEGER DEFAULT 0 NOT NULL, + attach_comment BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL, + extension VARCHAR(100) CHARACTER SET NONE DEFAULT '' NOT NULL, + mimetype VARCHAR(100) CHARACTER SET NONE DEFAULT '' NOT NULL, + filesize INTEGER DEFAULT 0 NOT NULL, + filetime INTEGER DEFAULT 0 NOT NULL, + thumbnail INTEGER DEFAULT 0 NOT NULL +);; + +ALTER TABLE phpbb_attachments ADD PRIMARY KEY (attach_id);; + +CREATE INDEX phpbb_attachments_filetime ON phpbb_attachments(filetime);; +CREATE INDEX phpbb_attachments_post_msg_id ON phpbb_attachments(post_msg_id);; +CREATE INDEX phpbb_attachments_topic_id ON phpbb_attachments(topic_id);; +CREATE INDEX phpbb_attachments_poster_id ON phpbb_attachments(poster_id);; +CREATE INDEX phpbb_attachments_is_orphan ON phpbb_attachments(is_orphan);; + +CREATE GENERATOR phpbb_attachments_gen;; +SET GENERATOR phpbb_attachments_gen TO 0;; + +CREATE TRIGGER t_phpbb_attachments FOR phpbb_attachments +BEFORE INSERT +AS +BEGIN + NEW.attach_id = GEN_ID(phpbb_attachments_gen, 1); +END;; + + +# Table: 'phpbb_acl_groups' +CREATE TABLE phpbb_acl_groups ( + group_id INTEGER DEFAULT 0 NOT NULL, + forum_id INTEGER DEFAULT 0 NOT NULL, + auth_option_id INTEGER DEFAULT 0 NOT NULL, + auth_role_id INTEGER DEFAULT 0 NOT NULL, + auth_setting INTEGER DEFAULT 0 NOT NULL +);; + +CREATE INDEX phpbb_acl_groups_group_id ON phpbb_acl_groups(group_id);; +CREATE INDEX phpbb_acl_groups_auth_opt_id ON phpbb_acl_groups(auth_option_id);; +CREATE INDEX phpbb_acl_groups_auth_role_id ON phpbb_acl_groups(auth_role_id);; + +# Table: 'phpbb_acl_options' +CREATE TABLE phpbb_acl_options ( + auth_option_id INTEGER NOT NULL, + auth_option VARCHAR(50) CHARACTER SET NONE DEFAULT '' NOT NULL, + is_global INTEGER DEFAULT 0 NOT NULL, + is_local INTEGER DEFAULT 0 NOT NULL, + founder_only INTEGER DEFAULT 0 NOT NULL +);; + +ALTER TABLE phpbb_acl_options ADD PRIMARY KEY (auth_option_id);; + +CREATE UNIQUE INDEX phpbb_acl_options_auth_option ON phpbb_acl_options(auth_option);; + +CREATE GENERATOR phpbb_acl_options_gen;; +SET GENERATOR phpbb_acl_options_gen TO 0;; + +CREATE TRIGGER t_phpbb_acl_options FOR phpbb_acl_options +BEFORE INSERT +AS +BEGIN + NEW.auth_option_id = GEN_ID(phpbb_acl_options_gen, 1); +END;; + + +# Table: 'phpbb_acl_roles' +CREATE TABLE phpbb_acl_roles ( + role_id INTEGER NOT NULL, + role_name VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, + role_description BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL, + role_type VARCHAR(10) CHARACTER SET NONE DEFAULT '' NOT NULL, + role_order INTEGER DEFAULT 0 NOT NULL +);; + +ALTER TABLE phpbb_acl_roles ADD PRIMARY KEY (role_id);; + +CREATE INDEX phpbb_acl_roles_role_type ON phpbb_acl_roles(role_type);; +CREATE INDEX phpbb_acl_roles_role_order ON phpbb_acl_roles(role_order);; + +CREATE GENERATOR phpbb_acl_roles_gen;; +SET GENERATOR phpbb_acl_roles_gen TO 0;; + +CREATE TRIGGER t_phpbb_acl_roles FOR phpbb_acl_roles +BEFORE INSERT +AS +BEGIN + NEW.role_id = GEN_ID(phpbb_acl_roles_gen, 1); +END;; + + +# Table: 'phpbb_acl_roles_data' +CREATE TABLE phpbb_acl_roles_data ( + role_id INTEGER DEFAULT 0 NOT NULL, + auth_option_id INTEGER DEFAULT 0 NOT NULL, + auth_setting INTEGER DEFAULT 0 NOT NULL +);; + +ALTER TABLE phpbb_acl_roles_data ADD PRIMARY KEY (role_id, auth_option_id);; + +CREATE INDEX phpbb_acl_roles_data_ath_op_id ON phpbb_acl_roles_data(auth_option_id);; + +# Table: 'phpbb_acl_users' +CREATE TABLE phpbb_acl_users ( + user_id INTEGER DEFAULT 0 NOT NULL, + forum_id INTEGER DEFAULT 0 NOT NULL, + auth_option_id INTEGER DEFAULT 0 NOT NULL, + auth_role_id INTEGER DEFAULT 0 NOT NULL, + auth_setting INTEGER DEFAULT 0 NOT NULL +);; + +CREATE INDEX phpbb_acl_users_user_id ON phpbb_acl_users(user_id);; +CREATE INDEX phpbb_acl_users_auth_option_id ON phpbb_acl_users(auth_option_id);; +CREATE INDEX phpbb_acl_users_auth_role_id ON phpbb_acl_users(auth_role_id);; + +# Table: 'phpbb_banlist' +CREATE TABLE phpbb_banlist ( + ban_id INTEGER NOT NULL, + ban_userid INTEGER DEFAULT 0 NOT NULL, + ban_ip VARCHAR(40) CHARACTER SET NONE DEFAULT '' NOT NULL, + ban_email VARCHAR(100) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, + ban_start INTEGER DEFAULT 0 NOT NULL, + ban_end INTEGER DEFAULT 0 NOT NULL, + ban_exclude INTEGER DEFAULT 0 NOT NULL, + ban_reason VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, + ban_give_reason VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE +);; + +ALTER TABLE phpbb_banlist ADD PRIMARY KEY (ban_id);; + +CREATE INDEX phpbb_banlist_ban_end ON phpbb_banlist(ban_end);; +CREATE INDEX phpbb_banlist_ban_user ON phpbb_banlist(ban_userid, ban_exclude);; +CREATE INDEX phpbb_banlist_ban_email ON phpbb_banlist(ban_email, ban_exclude);; +CREATE INDEX phpbb_banlist_ban_ip ON phpbb_banlist(ban_ip, ban_exclude);; + +CREATE GENERATOR phpbb_banlist_gen;; +SET GENERATOR phpbb_banlist_gen TO 0;; + +CREATE TRIGGER t_phpbb_banlist FOR phpbb_banlist +BEFORE INSERT +AS +BEGIN + NEW.ban_id = GEN_ID(phpbb_banlist_gen, 1); +END;; + + +# Table: 'phpbb_bbcodes' +CREATE TABLE phpbb_bbcodes ( + bbcode_id INTEGER DEFAULT 0 NOT NULL, + bbcode_tag VARCHAR(16) CHARACTER SET NONE DEFAULT '' NOT NULL, + bbcode_helpline VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, + display_on_posting INTEGER DEFAULT 0 NOT NULL, + bbcode_match BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL, + bbcode_tpl BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL, + first_pass_match BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL, + first_pass_replace BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL, + second_pass_match BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL, + second_pass_replace BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL +);; + +ALTER TABLE phpbb_bbcodes ADD PRIMARY KEY (bbcode_id);; + +CREATE INDEX phpbb_bbcodes_display_on_post ON phpbb_bbcodes(display_on_posting);; + +# Table: 'phpbb_bookmarks' +CREATE TABLE phpbb_bookmarks ( + topic_id INTEGER DEFAULT 0 NOT NULL, + user_id INTEGER DEFAULT 0 NOT NULL +);; + +ALTER TABLE phpbb_bookmarks ADD PRIMARY KEY (topic_id, user_id);; + + +# Table: 'phpbb_bots' +CREATE TABLE phpbb_bots ( + bot_id INTEGER NOT NULL, + bot_active INTEGER DEFAULT 1 NOT NULL, + bot_name VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, + user_id INTEGER DEFAULT 0 NOT NULL, + bot_agent VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL, + bot_ip VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL +);; + +ALTER TABLE phpbb_bots ADD PRIMARY KEY (bot_id);; + +CREATE INDEX phpbb_bots_bot_active ON phpbb_bots(bot_active);; + +CREATE GENERATOR phpbb_bots_gen;; +SET GENERATOR phpbb_bots_gen TO 0;; + +CREATE TRIGGER t_phpbb_bots FOR phpbb_bots +BEFORE INSERT +AS +BEGIN + NEW.bot_id = GEN_ID(phpbb_bots_gen, 1); +END;; + + +# Table: 'phpbb_config' +CREATE TABLE phpbb_config ( + config_name VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL, + config_value VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, + is_dynamic INTEGER DEFAULT 0 NOT NULL +);; + +ALTER TABLE phpbb_config ADD PRIMARY KEY (config_name);; + +CREATE INDEX phpbb_config_is_dynamic ON phpbb_config(is_dynamic);; + +# Table: 'phpbb_confirm' +CREATE TABLE phpbb_confirm ( + confirm_id CHAR(32) CHARACTER SET NONE DEFAULT '' NOT NULL, + session_id CHAR(32) CHARACTER SET NONE DEFAULT '' NOT NULL, + confirm_type INTEGER DEFAULT 0 NOT NULL, + code VARCHAR(8) CHARACTER SET NONE DEFAULT '' NOT NULL, + seed INTEGER DEFAULT 0 NOT NULL, + attempts INTEGER DEFAULT 0 NOT NULL +);; + +ALTER TABLE phpbb_confirm ADD PRIMARY KEY (session_id, confirm_id);; + +CREATE INDEX phpbb_confirm_confirm_type ON phpbb_confirm(confirm_type);; + +# Table: 'phpbb_disallow' +CREATE TABLE phpbb_disallow ( + disallow_id INTEGER NOT NULL, + disallow_username VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE +);; + +ALTER TABLE phpbb_disallow ADD PRIMARY KEY (disallow_id);; + + +CREATE GENERATOR phpbb_disallow_gen;; +SET GENERATOR phpbb_disallow_gen TO 0;; + +CREATE TRIGGER t_phpbb_disallow FOR phpbb_disallow +BEFORE INSERT +AS +BEGIN + NEW.disallow_id = GEN_ID(phpbb_disallow_gen, 1); +END;; + + +# Table: 'phpbb_drafts' +CREATE TABLE phpbb_drafts ( + draft_id INTEGER NOT NULL, + user_id INTEGER DEFAULT 0 NOT NULL, + topic_id INTEGER DEFAULT 0 NOT NULL, + forum_id INTEGER DEFAULT 0 NOT NULL, + save_time INTEGER DEFAULT 0 NOT NULL, + draft_subject VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, + draft_message BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL +);; + +ALTER TABLE phpbb_drafts ADD PRIMARY KEY (draft_id);; + +CREATE INDEX phpbb_drafts_save_time ON phpbb_drafts(save_time);; + +CREATE GENERATOR phpbb_drafts_gen;; +SET GENERATOR phpbb_drafts_gen TO 0;; + +CREATE TRIGGER t_phpbb_drafts FOR phpbb_drafts +BEFORE INSERT +AS +BEGIN + NEW.draft_id = GEN_ID(phpbb_drafts_gen, 1); +END;; + + +# Table: 'phpbb_ext' +CREATE TABLE phpbb_ext ( + ext_name VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL, + ext_active INTEGER DEFAULT 0 NOT NULL, + ext_state BLOB SUB_TYPE TEXT CHARACTER SET NONE DEFAULT '' NOT NULL +);; + +CREATE UNIQUE INDEX phpbb_ext_ext_name ON phpbb_ext(ext_name);; + +# Table: 'phpbb_extensions' +CREATE TABLE phpbb_extensions ( + extension_id INTEGER NOT NULL, + group_id INTEGER DEFAULT 0 NOT NULL, + extension VARCHAR(100) CHARACTER SET NONE DEFAULT '' NOT NULL +);; + +ALTER TABLE phpbb_extensions ADD PRIMARY KEY (extension_id);; + + +CREATE GENERATOR phpbb_extensions_gen;; +SET GENERATOR phpbb_extensions_gen TO 0;; + +CREATE TRIGGER t_phpbb_extensions FOR phpbb_extensions +BEFORE INSERT +AS +BEGIN + NEW.extension_id = GEN_ID(phpbb_extensions_gen, 1); +END;; + + +# Table: 'phpbb_extension_groups' +CREATE TABLE phpbb_extension_groups ( + group_id INTEGER NOT NULL, + group_name VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, + cat_id INTEGER DEFAULT 0 NOT NULL, + allow_group INTEGER DEFAULT 0 NOT NULL, + download_mode INTEGER DEFAULT 1 NOT NULL, + upload_icon VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL, + max_filesize INTEGER DEFAULT 0 NOT NULL, + allowed_forums BLOB SUB_TYPE TEXT CHARACTER SET NONE DEFAULT '' NOT NULL, + allow_in_pm INTEGER DEFAULT 0 NOT NULL +);; + +ALTER TABLE phpbb_extension_groups ADD PRIMARY KEY (group_id);; + + +CREATE GENERATOR phpbb_extension_groups_gen;; +SET GENERATOR phpbb_extension_groups_gen TO 0;; + +CREATE TRIGGER t_phpbb_extension_groups FOR phpbb_extension_groups +BEFORE INSERT +AS +BEGIN + NEW.group_id = GEN_ID(phpbb_extension_groups_gen, 1); +END;; + + +# Table: 'phpbb_forums' +CREATE TABLE phpbb_forums ( + forum_id INTEGER NOT NULL, + parent_id INTEGER DEFAULT 0 NOT NULL, + left_id INTEGER DEFAULT 0 NOT NULL, + right_id INTEGER DEFAULT 0 NOT NULL, + forum_parents BLOB SUB_TYPE TEXT CHARACTER SET NONE DEFAULT '' NOT NULL, + forum_name VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, + forum_desc BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL, + forum_desc_bitfield VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL, + forum_desc_options INTEGER DEFAULT 7 NOT NULL, + forum_desc_uid VARCHAR(8) CHARACTER SET NONE DEFAULT '' NOT NULL, + forum_link VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, + forum_password VARCHAR(40) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, + forum_style INTEGER DEFAULT 0 NOT NULL, + forum_image VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL, + forum_rules BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL, + forum_rules_link VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, + forum_rules_bitfield VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL, + forum_rules_options INTEGER DEFAULT 7 NOT NULL, + forum_rules_uid VARCHAR(8) CHARACTER SET NONE DEFAULT '' NOT NULL, + forum_topics_per_page INTEGER DEFAULT 0 NOT NULL, + forum_type INTEGER DEFAULT 0 NOT NULL, + forum_status INTEGER DEFAULT 0 NOT NULL, + forum_posts INTEGER DEFAULT 0 NOT NULL, + forum_topics INTEGER DEFAULT 0 NOT NULL, + forum_topics_real INTEGER DEFAULT 0 NOT NULL, + forum_last_post_id INTEGER DEFAULT 0 NOT NULL, + forum_last_poster_id INTEGER DEFAULT 0 NOT NULL, + forum_last_post_subject VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, + forum_last_post_time INTEGER DEFAULT 0 NOT NULL, + forum_last_poster_name VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, + forum_last_poster_colour VARCHAR(6) CHARACTER SET NONE DEFAULT '' NOT NULL, + forum_flags INTEGER DEFAULT 32 NOT NULL, + forum_options INTEGER DEFAULT 0 NOT NULL, + display_subforum_list INTEGER DEFAULT 1 NOT NULL, + display_on_index INTEGER DEFAULT 1 NOT NULL, + enable_indexing INTEGER DEFAULT 1 NOT NULL, + enable_icons INTEGER DEFAULT 1 NOT NULL, + enable_prune INTEGER DEFAULT 0 NOT NULL, + prune_next INTEGER DEFAULT 0 NOT NULL, + prune_days INTEGER DEFAULT 0 NOT NULL, + prune_viewed INTEGER DEFAULT 0 NOT NULL, + prune_freq INTEGER DEFAULT 0 NOT NULL +);; + +ALTER TABLE phpbb_forums ADD PRIMARY KEY (forum_id);; + +CREATE INDEX phpbb_forums_left_right_id ON phpbb_forums(left_id, right_id);; +CREATE INDEX phpbb_forums_forum_lastpost_id ON phpbb_forums(forum_last_post_id);; + +CREATE GENERATOR phpbb_forums_gen;; +SET GENERATOR phpbb_forums_gen TO 0;; + +CREATE TRIGGER t_phpbb_forums FOR phpbb_forums +BEFORE INSERT +AS +BEGIN + NEW.forum_id = GEN_ID(phpbb_forums_gen, 1); +END;; + + +# Table: 'phpbb_forums_access' +CREATE TABLE phpbb_forums_access ( + forum_id INTEGER DEFAULT 0 NOT NULL, + user_id INTEGER DEFAULT 0 NOT NULL, + session_id CHAR(32) CHARACTER SET NONE DEFAULT '' NOT NULL +);; + +ALTER TABLE phpbb_forums_access ADD PRIMARY KEY (forum_id, user_id, session_id);; + + +# Table: 'phpbb_forums_track' +CREATE TABLE phpbb_forums_track ( + user_id INTEGER DEFAULT 0 NOT NULL, + forum_id INTEGER DEFAULT 0 NOT NULL, + mark_time INTEGER DEFAULT 0 NOT NULL +);; + +ALTER TABLE phpbb_forums_track ADD PRIMARY KEY (user_id, forum_id);; + + +# Table: 'phpbb_forums_watch' +CREATE TABLE phpbb_forums_watch ( + forum_id INTEGER DEFAULT 0 NOT NULL, + user_id INTEGER DEFAULT 0 NOT NULL, + notify_status INTEGER DEFAULT 0 NOT NULL +);; + +CREATE INDEX phpbb_forums_watch_forum_id ON phpbb_forums_watch(forum_id);; +CREATE INDEX phpbb_forums_watch_user_id ON phpbb_forums_watch(user_id);; +CREATE INDEX phpbb_forums_watch_notify_stat ON phpbb_forums_watch(notify_status);; + +# Table: 'phpbb_groups' +CREATE TABLE phpbb_groups ( + group_id INTEGER NOT NULL, + group_type INTEGER DEFAULT 1 NOT NULL, + group_founder_manage INTEGER DEFAULT 0 NOT NULL, + group_skip_auth INTEGER DEFAULT 0 NOT NULL, + group_name VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, + group_desc BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL, + group_desc_bitfield VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL, + group_desc_options INTEGER DEFAULT 7 NOT NULL, + group_desc_uid VARCHAR(8) CHARACTER SET NONE DEFAULT '' NOT NULL, + group_display INTEGER DEFAULT 0 NOT NULL, + group_avatar VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL, + group_avatar_type INTEGER DEFAULT 0 NOT NULL, + group_avatar_width INTEGER DEFAULT 0 NOT NULL, + group_avatar_height INTEGER DEFAULT 0 NOT NULL, + group_rank INTEGER DEFAULT 0 NOT NULL, + group_colour VARCHAR(6) CHARACTER SET NONE DEFAULT '' NOT NULL, + group_sig_chars INTEGER DEFAULT 0 NOT NULL, + group_receive_pm INTEGER DEFAULT 0 NOT NULL, + group_message_limit INTEGER DEFAULT 0 NOT NULL, + group_max_recipients INTEGER DEFAULT 0 NOT NULL, + group_legend INTEGER DEFAULT 0 NOT NULL, + group_teampage INTEGER DEFAULT 0 NOT NULL +);; + +ALTER TABLE phpbb_groups ADD PRIMARY KEY (group_id);; + +CREATE INDEX phpbb_groups_group_legend_name ON phpbb_groups(group_legend, group_name);; + +CREATE GENERATOR phpbb_groups_gen;; +SET GENERATOR phpbb_groups_gen TO 0;; + +CREATE TRIGGER t_phpbb_groups FOR phpbb_groups +BEFORE INSERT +AS +BEGIN + NEW.group_id = GEN_ID(phpbb_groups_gen, 1); +END;; + + +# Table: 'phpbb_icons' +CREATE TABLE phpbb_icons ( + icons_id INTEGER NOT NULL, + icons_url VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL, + icons_width INTEGER DEFAULT 0 NOT NULL, + icons_height INTEGER DEFAULT 0 NOT NULL, + icons_order INTEGER DEFAULT 0 NOT NULL, + display_on_posting INTEGER DEFAULT 1 NOT NULL +);; + +ALTER TABLE phpbb_icons ADD PRIMARY KEY (icons_id);; + +CREATE INDEX phpbb_icons_display_on_posting ON phpbb_icons(display_on_posting);; + +CREATE GENERATOR phpbb_icons_gen;; +SET GENERATOR phpbb_icons_gen TO 0;; + +CREATE TRIGGER t_phpbb_icons FOR phpbb_icons +BEFORE INSERT +AS +BEGIN + NEW.icons_id = GEN_ID(phpbb_icons_gen, 1); +END;; + + +# Table: 'phpbb_lang' +CREATE TABLE phpbb_lang ( + lang_id INTEGER NOT NULL, + lang_iso VARCHAR(30) CHARACTER SET NONE DEFAULT '' NOT NULL, + lang_dir VARCHAR(30) CHARACTER SET NONE DEFAULT '' NOT NULL, + lang_english_name VARCHAR(100) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, + lang_local_name VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, + lang_author VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE +);; + +ALTER TABLE phpbb_lang ADD PRIMARY KEY (lang_id);; + +CREATE INDEX phpbb_lang_lang_iso ON phpbb_lang(lang_iso);; + +CREATE GENERATOR phpbb_lang_gen;; +SET GENERATOR phpbb_lang_gen TO 0;; + +CREATE TRIGGER t_phpbb_lang FOR phpbb_lang +BEFORE INSERT +AS +BEGIN + NEW.lang_id = GEN_ID(phpbb_lang_gen, 1); +END;; + + +# Table: 'phpbb_log' +CREATE TABLE phpbb_log ( + log_id INTEGER NOT NULL, + log_type INTEGER DEFAULT 0 NOT NULL, + user_id INTEGER DEFAULT 0 NOT NULL, + forum_id INTEGER DEFAULT 0 NOT NULL, + topic_id INTEGER DEFAULT 0 NOT NULL, + reportee_id INTEGER DEFAULT 0 NOT NULL, + log_ip VARCHAR(40) CHARACTER SET NONE DEFAULT '' NOT NULL, + log_time INTEGER DEFAULT 0 NOT NULL, + log_operation BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL, + log_data BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL +);; + +ALTER TABLE phpbb_log ADD PRIMARY KEY (log_id);; + +CREATE INDEX phpbb_log_log_type ON phpbb_log(log_type);; +CREATE INDEX phpbb_log_log_time ON phpbb_log(log_time);; +CREATE INDEX phpbb_log_forum_id ON phpbb_log(forum_id);; +CREATE INDEX phpbb_log_topic_id ON phpbb_log(topic_id);; +CREATE INDEX phpbb_log_reportee_id ON phpbb_log(reportee_id);; +CREATE INDEX phpbb_log_user_id ON phpbb_log(user_id);; + +CREATE GENERATOR phpbb_log_gen;; +SET GENERATOR phpbb_log_gen TO 0;; + +CREATE TRIGGER t_phpbb_log FOR phpbb_log +BEFORE INSERT +AS +BEGIN + NEW.log_id = GEN_ID(phpbb_log_gen, 1); +END;; + + +# Table: 'phpbb_login_attempts' +CREATE TABLE phpbb_login_attempts ( + attempt_ip VARCHAR(40) CHARACTER SET NONE DEFAULT '' NOT NULL, + attempt_browser VARCHAR(150) CHARACTER SET NONE DEFAULT '' NOT NULL, + attempt_forwarded_for VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL, + attempt_time INTEGER DEFAULT 0 NOT NULL, + user_id INTEGER DEFAULT 0 NOT NULL, + username VARCHAR(255) CHARACTER SET UTF8 DEFAULT 0 NOT NULL COLLATE UNICODE, + username_clean VARCHAR(255) CHARACTER SET UTF8 DEFAULT 0 NOT NULL COLLATE UNICODE +);; + +CREATE INDEX phpbb_login_attempts_att_ip ON phpbb_login_attempts(attempt_ip, attempt_time);; +CREATE INDEX phpbb_login_attempts_att_for ON phpbb_login_attempts(attempt_forwarded_for, attempt_time);; +CREATE INDEX phpbb_login_attempts_att_time ON phpbb_login_attempts(attempt_time);; +CREATE INDEX phpbb_login_attempts_user_id ON phpbb_login_attempts(user_id);; + +# Table: 'phpbb_moderator_cache' +CREATE TABLE phpbb_moderator_cache ( + forum_id INTEGER DEFAULT 0 NOT NULL, + user_id INTEGER DEFAULT 0 NOT NULL, + username VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, + group_id INTEGER DEFAULT 0 NOT NULL, + group_name VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, + display_on_index INTEGER DEFAULT 1 NOT NULL +);; + +CREATE INDEX phpbb_moderator_cache_disp_idx ON phpbb_moderator_cache(display_on_index);; +CREATE INDEX phpbb_moderator_cache_forum_id ON phpbb_moderator_cache(forum_id);; + +# Table: 'phpbb_modules' +CREATE TABLE phpbb_modules ( + module_id INTEGER NOT NULL, + module_enabled INTEGER DEFAULT 1 NOT NULL, + module_display INTEGER DEFAULT 1 NOT NULL, + module_basename VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL, + module_class VARCHAR(10) CHARACTER SET NONE DEFAULT '' NOT NULL, + parent_id INTEGER DEFAULT 0 NOT NULL, + left_id INTEGER DEFAULT 0 NOT NULL, + right_id INTEGER DEFAULT 0 NOT NULL, + module_langname VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL, + module_mode VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL, + module_auth VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL +);; + +ALTER TABLE phpbb_modules ADD PRIMARY KEY (module_id);; + +CREATE INDEX phpbb_modules_left_right_id ON phpbb_modules(left_id, right_id);; +CREATE INDEX phpbb_modules_module_enabled ON phpbb_modules(module_enabled);; +CREATE INDEX phpbb_modules_class_left_id ON phpbb_modules(module_class, left_id);; + +CREATE GENERATOR phpbb_modules_gen;; +SET GENERATOR phpbb_modules_gen TO 0;; + +CREATE TRIGGER t_phpbb_modules FOR phpbb_modules +BEFORE INSERT +AS +BEGIN + NEW.module_id = GEN_ID(phpbb_modules_gen, 1); +END;; + + +# Table: 'phpbb_poll_options' +CREATE TABLE phpbb_poll_options ( + poll_option_id INTEGER DEFAULT 0 NOT NULL, + topic_id INTEGER DEFAULT 0 NOT NULL, + poll_option_text BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL, + poll_option_total INTEGER DEFAULT 0 NOT NULL +);; + +CREATE INDEX phpbb_poll_options_poll_opt_id ON phpbb_poll_options(poll_option_id);; +CREATE INDEX phpbb_poll_options_topic_id ON phpbb_poll_options(topic_id);; + +# Table: 'phpbb_poll_votes' +CREATE TABLE phpbb_poll_votes ( + topic_id INTEGER DEFAULT 0 NOT NULL, + poll_option_id INTEGER DEFAULT 0 NOT NULL, + vote_user_id INTEGER DEFAULT 0 NOT NULL, + vote_user_ip VARCHAR(40) CHARACTER SET NONE DEFAULT '' NOT NULL +);; + +CREATE INDEX phpbb_poll_votes_topic_id ON phpbb_poll_votes(topic_id);; +CREATE INDEX phpbb_poll_votes_vote_user_id ON phpbb_poll_votes(vote_user_id);; +CREATE INDEX phpbb_poll_votes_vote_user_ip ON phpbb_poll_votes(vote_user_ip);; + +# Table: 'phpbb_posts' +CREATE TABLE phpbb_posts ( + post_id INTEGER NOT NULL, + topic_id INTEGER DEFAULT 0 NOT NULL, + forum_id INTEGER DEFAULT 0 NOT NULL, + poster_id INTEGER DEFAULT 0 NOT NULL, + icon_id INTEGER DEFAULT 0 NOT NULL, + poster_ip VARCHAR(40) CHARACTER SET NONE DEFAULT '' NOT NULL, + post_time INTEGER DEFAULT 0 NOT NULL, + post_approved INTEGER DEFAULT 1 NOT NULL, + post_reported INTEGER DEFAULT 0 NOT NULL, + enable_bbcode INTEGER DEFAULT 1 NOT NULL, + enable_smilies INTEGER DEFAULT 1 NOT NULL, + enable_magic_url INTEGER DEFAULT 1 NOT NULL, + enable_sig INTEGER DEFAULT 1 NOT NULL, + post_username VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, + post_subject VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, + post_text BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL, + post_checksum VARCHAR(32) CHARACTER SET NONE DEFAULT '' NOT NULL, + post_attachment INTEGER DEFAULT 0 NOT NULL, + bbcode_bitfield VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL, + bbcode_uid VARCHAR(8) CHARACTER SET NONE DEFAULT '' NOT NULL, + post_postcount INTEGER DEFAULT 1 NOT NULL, + post_edit_time INTEGER DEFAULT 0 NOT NULL, + post_edit_reason VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, + post_edit_user INTEGER DEFAULT 0 NOT NULL, + post_edit_count INTEGER DEFAULT 0 NOT NULL, + post_edit_locked INTEGER DEFAULT 0 NOT NULL +);; + +ALTER TABLE phpbb_posts ADD PRIMARY KEY (post_id);; + +CREATE INDEX phpbb_posts_forum_id ON phpbb_posts(forum_id);; +CREATE INDEX phpbb_posts_topic_id ON phpbb_posts(topic_id);; +CREATE INDEX phpbb_posts_poster_ip ON phpbb_posts(poster_ip);; +CREATE INDEX phpbb_posts_poster_id ON phpbb_posts(poster_id);; +CREATE INDEX phpbb_posts_post_approved ON phpbb_posts(post_approved);; +CREATE INDEX phpbb_posts_post_username ON phpbb_posts(post_username);; +CREATE INDEX phpbb_posts_tid_post_time ON phpbb_posts(topic_id, post_time);; + +CREATE GENERATOR phpbb_posts_gen;; +SET GENERATOR phpbb_posts_gen TO 0;; + +CREATE TRIGGER t_phpbb_posts FOR phpbb_posts +BEFORE INSERT +AS +BEGIN + NEW.post_id = GEN_ID(phpbb_posts_gen, 1); +END;; + + +# Table: 'phpbb_privmsgs' +CREATE TABLE phpbb_privmsgs ( + msg_id INTEGER NOT NULL, + root_level INTEGER DEFAULT 0 NOT NULL, + author_id INTEGER DEFAULT 0 NOT NULL, + icon_id INTEGER DEFAULT 0 NOT NULL, + author_ip VARCHAR(40) CHARACTER SET NONE DEFAULT '' NOT NULL, + message_time INTEGER DEFAULT 0 NOT NULL, + enable_bbcode INTEGER DEFAULT 1 NOT NULL, + enable_smilies INTEGER DEFAULT 1 NOT NULL, + enable_magic_url INTEGER DEFAULT 1 NOT NULL, + enable_sig INTEGER DEFAULT 1 NOT NULL, + message_subject VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, + message_text BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL, + message_edit_reason VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, + message_edit_user INTEGER DEFAULT 0 NOT NULL, + message_attachment INTEGER DEFAULT 0 NOT NULL, + bbcode_bitfield VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL, + bbcode_uid VARCHAR(8) CHARACTER SET NONE DEFAULT '' NOT NULL, + message_edit_time INTEGER DEFAULT 0 NOT NULL, + message_edit_count INTEGER DEFAULT 0 NOT NULL, + to_address BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL, + bcc_address BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL, + message_reported INTEGER DEFAULT 0 NOT NULL +);; + +ALTER TABLE phpbb_privmsgs ADD PRIMARY KEY (msg_id);; + +CREATE INDEX phpbb_privmsgs_author_ip ON phpbb_privmsgs(author_ip);; +CREATE INDEX phpbb_privmsgs_message_time ON phpbb_privmsgs(message_time);; +CREATE INDEX phpbb_privmsgs_author_id ON phpbb_privmsgs(author_id);; +CREATE INDEX phpbb_privmsgs_root_level ON phpbb_privmsgs(root_level);; + +CREATE GENERATOR phpbb_privmsgs_gen;; +SET GENERATOR phpbb_privmsgs_gen TO 0;; + +CREATE TRIGGER t_phpbb_privmsgs FOR phpbb_privmsgs +BEFORE INSERT +AS +BEGIN + NEW.msg_id = GEN_ID(phpbb_privmsgs_gen, 1); +END;; + + +# Table: 'phpbb_privmsgs_folder' +CREATE TABLE phpbb_privmsgs_folder ( + folder_id INTEGER NOT NULL, + user_id INTEGER DEFAULT 0 NOT NULL, + folder_name VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, + pm_count INTEGER DEFAULT 0 NOT NULL +);; + +ALTER TABLE phpbb_privmsgs_folder ADD PRIMARY KEY (folder_id);; + +CREATE INDEX phpbb_privmsgs_folder_user_id ON phpbb_privmsgs_folder(user_id);; + +CREATE GENERATOR phpbb_privmsgs_folder_gen;; +SET GENERATOR phpbb_privmsgs_folder_gen TO 0;; + +CREATE TRIGGER t_phpbb_privmsgs_folder FOR phpbb_privmsgs_folder +BEFORE INSERT +AS +BEGIN + NEW.folder_id = GEN_ID(phpbb_privmsgs_folder_gen, 1); +END;; + + +# Table: 'phpbb_privmsgs_rules' +CREATE TABLE phpbb_privmsgs_rules ( + rule_id INTEGER NOT NULL, + user_id INTEGER DEFAULT 0 NOT NULL, + rule_check INTEGER DEFAULT 0 NOT NULL, + rule_connection INTEGER DEFAULT 0 NOT NULL, + rule_string VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, + rule_user_id INTEGER DEFAULT 0 NOT NULL, + rule_group_id INTEGER DEFAULT 0 NOT NULL, + rule_action INTEGER DEFAULT 0 NOT NULL, + rule_folder_id INTEGER DEFAULT 0 NOT NULL +);; + +ALTER TABLE phpbb_privmsgs_rules ADD PRIMARY KEY (rule_id);; + +CREATE INDEX phpbb_privmsgs_rules_user_id ON phpbb_privmsgs_rules(user_id);; + +CREATE GENERATOR phpbb_privmsgs_rules_gen;; +SET GENERATOR phpbb_privmsgs_rules_gen TO 0;; + +CREATE TRIGGER t_phpbb_privmsgs_rules FOR phpbb_privmsgs_rules +BEFORE INSERT +AS +BEGIN + NEW.rule_id = GEN_ID(phpbb_privmsgs_rules_gen, 1); +END;; + + +# Table: 'phpbb_privmsgs_to' +CREATE TABLE phpbb_privmsgs_to ( + msg_id INTEGER DEFAULT 0 NOT NULL, + user_id INTEGER DEFAULT 0 NOT NULL, + author_id INTEGER DEFAULT 0 NOT NULL, + pm_deleted INTEGER DEFAULT 0 NOT NULL, + pm_new INTEGER DEFAULT 1 NOT NULL, + pm_unread INTEGER DEFAULT 1 NOT NULL, + pm_replied INTEGER DEFAULT 0 NOT NULL, + pm_marked INTEGER DEFAULT 0 NOT NULL, + pm_forwarded INTEGER DEFAULT 0 NOT NULL, + folder_id INTEGER DEFAULT 0 NOT NULL +);; + +CREATE INDEX phpbb_privmsgs_to_msg_id ON phpbb_privmsgs_to(msg_id);; +CREATE INDEX phpbb_privmsgs_to_author_id ON phpbb_privmsgs_to(author_id);; +CREATE INDEX phpbb_privmsgs_to_usr_flder_id ON phpbb_privmsgs_to(user_id, folder_id);; + +# Table: 'phpbb_profile_fields' +CREATE TABLE phpbb_profile_fields ( + field_id INTEGER NOT NULL, + field_name VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, + field_type INTEGER DEFAULT 0 NOT NULL, + field_ident VARCHAR(20) CHARACTER SET NONE DEFAULT '' NOT NULL, + field_length VARCHAR(20) CHARACTER SET NONE DEFAULT '' NOT NULL, + field_minlen VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL, + field_maxlen VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL, + field_novalue VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, + field_default_value VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, + field_validation VARCHAR(20) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, + field_required INTEGER DEFAULT 0 NOT NULL, + field_show_novalue INTEGER DEFAULT 0 NOT NULL, + field_show_on_reg INTEGER DEFAULT 0 NOT NULL, + field_show_on_pm INTEGER DEFAULT 0 NOT NULL, + field_show_on_vt INTEGER DEFAULT 0 NOT NULL, + field_show_profile INTEGER DEFAULT 0 NOT NULL, + field_hide INTEGER DEFAULT 0 NOT NULL, + field_no_view INTEGER DEFAULT 0 NOT NULL, + field_active INTEGER DEFAULT 0 NOT NULL, + field_order INTEGER DEFAULT 0 NOT NULL +);; + +ALTER TABLE phpbb_profile_fields ADD PRIMARY KEY (field_id);; + +CREATE INDEX phpbb_profile_fields_fld_type ON phpbb_profile_fields(field_type);; +CREATE INDEX phpbb_profile_fields_fld_ordr ON phpbb_profile_fields(field_order);; + +CREATE GENERATOR phpbb_profile_fields_gen;; +SET GENERATOR phpbb_profile_fields_gen TO 0;; + +CREATE TRIGGER t_phpbb_profile_fields FOR phpbb_profile_fields +BEFORE INSERT +AS +BEGIN + NEW.field_id = GEN_ID(phpbb_profile_fields_gen, 1); +END;; + + +# Table: 'phpbb_profile_fields_data' +CREATE TABLE phpbb_profile_fields_data ( + user_id INTEGER DEFAULT 0 NOT NULL +);; + +ALTER TABLE phpbb_profile_fields_data ADD PRIMARY KEY (user_id);; + + +# Table: 'phpbb_profile_fields_lang' +CREATE TABLE phpbb_profile_fields_lang ( + field_id INTEGER DEFAULT 0 NOT NULL, + lang_id INTEGER DEFAULT 0 NOT NULL, + option_id INTEGER DEFAULT 0 NOT NULL, + field_type INTEGER DEFAULT 0 NOT NULL, + lang_value VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE +);; + +ALTER TABLE phpbb_profile_fields_lang ADD PRIMARY KEY (field_id, lang_id, option_id);; + + +# Table: 'phpbb_profile_lang' +CREATE TABLE phpbb_profile_lang ( + field_id INTEGER DEFAULT 0 NOT NULL, + lang_id INTEGER DEFAULT 0 NOT NULL, + lang_name VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, + lang_explain BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL, + lang_default_value VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE +);; + +ALTER TABLE phpbb_profile_lang ADD PRIMARY KEY (field_id, lang_id);; + + +# Table: 'phpbb_ranks' +CREATE TABLE phpbb_ranks ( + rank_id INTEGER NOT NULL, + rank_title VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, + rank_min INTEGER DEFAULT 0 NOT NULL, + rank_special INTEGER DEFAULT 0 NOT NULL, + rank_image VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL +);; + +ALTER TABLE phpbb_ranks ADD PRIMARY KEY (rank_id);; + + +CREATE GENERATOR phpbb_ranks_gen;; +SET GENERATOR phpbb_ranks_gen TO 0;; + +CREATE TRIGGER t_phpbb_ranks FOR phpbb_ranks +BEFORE INSERT +AS +BEGIN + NEW.rank_id = GEN_ID(phpbb_ranks_gen, 1); +END;; + + +# Table: 'phpbb_reports' +CREATE TABLE phpbb_reports ( + report_id INTEGER NOT NULL, + reason_id INTEGER DEFAULT 0 NOT NULL, + post_id INTEGER DEFAULT 0 NOT NULL, + pm_id INTEGER DEFAULT 0 NOT NULL, + user_id INTEGER DEFAULT 0 NOT NULL, + user_notify INTEGER DEFAULT 0 NOT NULL, + report_closed INTEGER DEFAULT 0 NOT NULL, + report_time INTEGER DEFAULT 0 NOT NULL, + report_text BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL, + reported_post_text BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL +);; + +ALTER TABLE phpbb_reports ADD PRIMARY KEY (report_id);; + +CREATE INDEX phpbb_reports_post_id ON phpbb_reports(post_id);; +CREATE INDEX phpbb_reports_pm_id ON phpbb_reports(pm_id);; + +CREATE GENERATOR phpbb_reports_gen;; +SET GENERATOR phpbb_reports_gen TO 0;; + +CREATE TRIGGER t_phpbb_reports FOR phpbb_reports +BEFORE INSERT +AS +BEGIN + NEW.report_id = GEN_ID(phpbb_reports_gen, 1); +END;; + + +# Table: 'phpbb_reports_reasons' +CREATE TABLE phpbb_reports_reasons ( + reason_id INTEGER NOT NULL, + reason_title VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, + reason_description BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL, + reason_order INTEGER DEFAULT 0 NOT NULL +);; + +ALTER TABLE phpbb_reports_reasons ADD PRIMARY KEY (reason_id);; + + +CREATE GENERATOR phpbb_reports_reasons_gen;; +SET GENERATOR phpbb_reports_reasons_gen TO 0;; + +CREATE TRIGGER t_phpbb_reports_reasons FOR phpbb_reports_reasons +BEFORE INSERT +AS +BEGIN + NEW.reason_id = GEN_ID(phpbb_reports_reasons_gen, 1); +END;; + + +# Table: 'phpbb_search_results' +CREATE TABLE phpbb_search_results ( + search_key VARCHAR(32) CHARACTER SET NONE DEFAULT '' NOT NULL, + search_time INTEGER DEFAULT 0 NOT NULL, + search_keywords BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL, + search_authors BLOB SUB_TYPE TEXT CHARACTER SET NONE DEFAULT '' NOT NULL +);; + +ALTER TABLE phpbb_search_results ADD PRIMARY KEY (search_key);; + + +# Table: 'phpbb_search_wordlist' +CREATE TABLE phpbb_search_wordlist ( + word_id INTEGER NOT NULL, + word_text VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, + word_common INTEGER DEFAULT 0 NOT NULL, + word_count INTEGER DEFAULT 0 NOT NULL +);; + +ALTER TABLE phpbb_search_wordlist ADD PRIMARY KEY (word_id);; + +CREATE UNIQUE INDEX phpbb_search_wordlist_wrd_txt ON phpbb_search_wordlist(word_text);; +CREATE INDEX phpbb_search_wordlist_wrd_cnt ON phpbb_search_wordlist(word_count);; + +CREATE GENERATOR phpbb_search_wordlist_gen;; +SET GENERATOR phpbb_search_wordlist_gen TO 0;; + +CREATE TRIGGER t_phpbb_search_wordlist FOR phpbb_search_wordlist +BEFORE INSERT +AS +BEGIN + NEW.word_id = GEN_ID(phpbb_search_wordlist_gen, 1); +END;; + + +# Table: 'phpbb_search_wordmatch' +CREATE TABLE phpbb_search_wordmatch ( + post_id INTEGER DEFAULT 0 NOT NULL, + word_id INTEGER DEFAULT 0 NOT NULL, + title_match INTEGER DEFAULT 0 NOT NULL +);; + +CREATE UNIQUE INDEX phpbb_search_wordmatch_unq_mtch ON phpbb_search_wordmatch(word_id, post_id, title_match);; +CREATE INDEX phpbb_search_wordmatch_word_id ON phpbb_search_wordmatch(word_id);; +CREATE INDEX phpbb_search_wordmatch_post_id ON phpbb_search_wordmatch(post_id);; + +# Table: 'phpbb_sessions' +CREATE TABLE phpbb_sessions ( + session_id CHAR(32) CHARACTER SET NONE DEFAULT '' NOT NULL, + session_user_id INTEGER DEFAULT 0 NOT NULL, + session_forum_id INTEGER DEFAULT 0 NOT NULL, + session_last_visit INTEGER DEFAULT 0 NOT NULL, + session_start INTEGER DEFAULT 0 NOT NULL, + session_time INTEGER DEFAULT 0 NOT NULL, + session_ip VARCHAR(40) CHARACTER SET NONE DEFAULT '' NOT NULL, + session_browser VARCHAR(150) CHARACTER SET NONE DEFAULT '' NOT NULL, + session_forwarded_for VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL, + session_page VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, + session_viewonline INTEGER DEFAULT 1 NOT NULL, + session_autologin INTEGER DEFAULT 0 NOT NULL, + session_admin INTEGER DEFAULT 0 NOT NULL +);; + +ALTER TABLE phpbb_sessions ADD PRIMARY KEY (session_id);; + +CREATE INDEX phpbb_sessions_session_time ON phpbb_sessions(session_time);; +CREATE INDEX phpbb_sessions_session_user_id ON phpbb_sessions(session_user_id);; +CREATE INDEX phpbb_sessions_session_fid ON phpbb_sessions(session_forum_id);; + +# Table: 'phpbb_sessions_keys' +CREATE TABLE phpbb_sessions_keys ( + key_id CHAR(32) CHARACTER SET NONE DEFAULT '' NOT NULL, + user_id INTEGER DEFAULT 0 NOT NULL, + last_ip VARCHAR(40) CHARACTER SET NONE DEFAULT '' NOT NULL, + last_login INTEGER DEFAULT 0 NOT NULL +);; + +ALTER TABLE phpbb_sessions_keys ADD PRIMARY KEY (key_id, user_id);; + +CREATE INDEX phpbb_sessions_keys_last_login ON phpbb_sessions_keys(last_login);; + +# Table: 'phpbb_sitelist' +CREATE TABLE phpbb_sitelist ( + site_id INTEGER NOT NULL, + site_ip VARCHAR(40) CHARACTER SET NONE DEFAULT '' NOT NULL, + site_hostname VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL, + ip_exclude INTEGER DEFAULT 0 NOT NULL +);; + +ALTER TABLE phpbb_sitelist ADD PRIMARY KEY (site_id);; + + +CREATE GENERATOR phpbb_sitelist_gen;; +SET GENERATOR phpbb_sitelist_gen TO 0;; + +CREATE TRIGGER t_phpbb_sitelist FOR phpbb_sitelist +BEFORE INSERT +AS +BEGIN + NEW.site_id = GEN_ID(phpbb_sitelist_gen, 1); +END;; + + +# Table: 'phpbb_smilies' +CREATE TABLE phpbb_smilies ( + smiley_id INTEGER NOT NULL, + code VARCHAR(50) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, + emotion VARCHAR(50) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, + smiley_url VARCHAR(50) CHARACTER SET NONE DEFAULT '' NOT NULL, + smiley_width INTEGER DEFAULT 0 NOT NULL, + smiley_height INTEGER DEFAULT 0 NOT NULL, + smiley_order INTEGER DEFAULT 0 NOT NULL, + display_on_posting INTEGER DEFAULT 1 NOT NULL +);; + +ALTER TABLE phpbb_smilies ADD PRIMARY KEY (smiley_id);; + +CREATE INDEX phpbb_smilies_display_on_post ON phpbb_smilies(display_on_posting);; + +CREATE GENERATOR phpbb_smilies_gen;; +SET GENERATOR phpbb_smilies_gen TO 0;; + +CREATE TRIGGER t_phpbb_smilies FOR phpbb_smilies +BEFORE INSERT +AS +BEGIN + NEW.smiley_id = GEN_ID(phpbb_smilies_gen, 1); +END;; + + +# Table: 'phpbb_styles' +CREATE TABLE phpbb_styles ( + style_id INTEGER NOT NULL, + style_name VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, + style_copyright VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, + style_active INTEGER DEFAULT 1 NOT NULL, + style_path VARCHAR(100) CHARACTER SET NONE DEFAULT '' NOT NULL, + bbcode_bitfield VARCHAR(255) CHARACTER SET NONE DEFAULT 'kNg=' NOT NULL, + style_parent_id INTEGER DEFAULT 0 NOT NULL, + style_parent_tree BLOB SUB_TYPE TEXT CHARACTER SET NONE DEFAULT '' NOT NULL +);; + +ALTER TABLE phpbb_styles ADD PRIMARY KEY (style_id);; + +CREATE UNIQUE INDEX phpbb_styles_style_name ON phpbb_styles(style_name);; + +CREATE GENERATOR phpbb_styles_gen;; +SET GENERATOR phpbb_styles_gen TO 0;; + +CREATE TRIGGER t_phpbb_styles FOR phpbb_styles +BEFORE INSERT +AS +BEGIN + NEW.style_id = GEN_ID(phpbb_styles_gen, 1); +END;; + + +# Table: 'phpbb_topics' +CREATE TABLE phpbb_topics ( + topic_id INTEGER NOT NULL, + forum_id INTEGER DEFAULT 0 NOT NULL, + icon_id INTEGER DEFAULT 0 NOT NULL, + topic_attachment INTEGER DEFAULT 0 NOT NULL, + topic_approved INTEGER DEFAULT 1 NOT NULL, + topic_reported INTEGER DEFAULT 0 NOT NULL, + topic_title VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, + topic_poster INTEGER DEFAULT 0 NOT NULL, + topic_time INTEGER DEFAULT 0 NOT NULL, + topic_time_limit INTEGER DEFAULT 0 NOT NULL, + topic_views INTEGER DEFAULT 0 NOT NULL, + topic_replies INTEGER DEFAULT 0 NOT NULL, + topic_replies_real INTEGER DEFAULT 0 NOT NULL, + topic_status INTEGER DEFAULT 0 NOT NULL, + topic_type INTEGER DEFAULT 0 NOT NULL, + topic_first_post_id INTEGER DEFAULT 0 NOT NULL, + topic_first_poster_name VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, + topic_first_poster_colour VARCHAR(6) CHARACTER SET NONE DEFAULT '' NOT NULL, + topic_last_post_id INTEGER DEFAULT 0 NOT NULL, + topic_last_poster_id INTEGER DEFAULT 0 NOT NULL, + topic_last_poster_name VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, + topic_last_poster_colour VARCHAR(6) CHARACTER SET NONE DEFAULT '' NOT NULL, + topic_last_post_subject VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, + topic_last_post_time INTEGER DEFAULT 0 NOT NULL, + topic_last_view_time INTEGER DEFAULT 0 NOT NULL, + topic_moved_id INTEGER DEFAULT 0 NOT NULL, + topic_bumped INTEGER DEFAULT 0 NOT NULL, + topic_bumper INTEGER DEFAULT 0 NOT NULL, + poll_title VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, + poll_start INTEGER DEFAULT 0 NOT NULL, + poll_length INTEGER DEFAULT 0 NOT NULL, + poll_max_options INTEGER DEFAULT 1 NOT NULL, + poll_last_vote INTEGER DEFAULT 0 NOT NULL, + poll_vote_change INTEGER DEFAULT 0 NOT NULL +);; + +ALTER TABLE phpbb_topics ADD PRIMARY KEY (topic_id);; + +CREATE INDEX phpbb_topics_forum_id ON phpbb_topics(forum_id);; +CREATE INDEX phpbb_topics_forum_id_type ON phpbb_topics(forum_id, topic_type);; +CREATE INDEX phpbb_topics_last_post_time ON phpbb_topics(topic_last_post_time);; +CREATE INDEX phpbb_topics_topic_approved ON phpbb_topics(topic_approved);; +CREATE INDEX phpbb_topics_forum_appr_last ON phpbb_topics(forum_id, topic_approved, topic_last_post_id);; +CREATE INDEX phpbb_topics_fid_time_moved ON phpbb_topics(forum_id, topic_last_post_time, topic_moved_id);; + +CREATE GENERATOR phpbb_topics_gen;; +SET GENERATOR phpbb_topics_gen TO 0;; + +CREATE TRIGGER t_phpbb_topics FOR phpbb_topics +BEFORE INSERT +AS +BEGIN + NEW.topic_id = GEN_ID(phpbb_topics_gen, 1); +END;; + + +# Table: 'phpbb_topics_track' +CREATE TABLE phpbb_topics_track ( + user_id INTEGER DEFAULT 0 NOT NULL, + topic_id INTEGER DEFAULT 0 NOT NULL, + forum_id INTEGER DEFAULT 0 NOT NULL, + mark_time INTEGER DEFAULT 0 NOT NULL +);; + +ALTER TABLE phpbb_topics_track ADD PRIMARY KEY (user_id, topic_id);; + +CREATE INDEX phpbb_topics_track_topic_id ON phpbb_topics_track(topic_id);; +CREATE INDEX phpbb_topics_track_forum_id ON phpbb_topics_track(forum_id);; + +# Table: 'phpbb_topics_posted' +CREATE TABLE phpbb_topics_posted ( + user_id INTEGER DEFAULT 0 NOT NULL, + topic_id INTEGER DEFAULT 0 NOT NULL, + topic_posted INTEGER DEFAULT 0 NOT NULL +);; + +ALTER TABLE phpbb_topics_posted ADD PRIMARY KEY (user_id, topic_id);; + + +# Table: 'phpbb_topics_watch' +CREATE TABLE phpbb_topics_watch ( + topic_id INTEGER DEFAULT 0 NOT NULL, + user_id INTEGER DEFAULT 0 NOT NULL, + notify_status INTEGER DEFAULT 0 NOT NULL +);; + +CREATE INDEX phpbb_topics_watch_topic_id ON phpbb_topics_watch(topic_id);; +CREATE INDEX phpbb_topics_watch_user_id ON phpbb_topics_watch(user_id);; +CREATE INDEX phpbb_topics_watch_notify_stat ON phpbb_topics_watch(notify_status);; + +# Table: 'phpbb_user_group' +CREATE TABLE phpbb_user_group ( + group_id INTEGER DEFAULT 0 NOT NULL, + user_id INTEGER DEFAULT 0 NOT NULL, + group_leader INTEGER DEFAULT 0 NOT NULL, + user_pending INTEGER DEFAULT 1 NOT NULL +);; + +CREATE INDEX phpbb_user_group_group_id ON phpbb_user_group(group_id);; +CREATE INDEX phpbb_user_group_user_id ON phpbb_user_group(user_id);; +CREATE INDEX phpbb_user_group_group_leader ON phpbb_user_group(group_leader);; + +# Table: 'phpbb_users' +CREATE TABLE phpbb_users ( + user_id INTEGER NOT NULL, + user_type INTEGER DEFAULT 0 NOT NULL, + group_id INTEGER DEFAULT 3 NOT NULL, + user_permissions BLOB SUB_TYPE TEXT CHARACTER SET NONE DEFAULT '' NOT NULL, + user_perm_from INTEGER DEFAULT 0 NOT NULL, + user_ip VARCHAR(40) CHARACTER SET NONE DEFAULT '' NOT NULL, + user_regdate INTEGER DEFAULT 0 NOT NULL, + username VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, + username_clean VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, + user_password VARCHAR(40) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, + user_passchg INTEGER DEFAULT 0 NOT NULL, + user_pass_convert INTEGER DEFAULT 0 NOT NULL, + user_email VARCHAR(100) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, + user_email_hash DOUBLE PRECISION DEFAULT 0 NOT NULL, + user_birthday VARCHAR(10) CHARACTER SET NONE DEFAULT '' NOT NULL, + user_lastvisit INTEGER DEFAULT 0 NOT NULL, + user_lastmark INTEGER DEFAULT 0 NOT NULL, + user_lastpost_time INTEGER DEFAULT 0 NOT NULL, + user_lastpage VARCHAR(200) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, + user_last_confirm_key VARCHAR(10) CHARACTER SET NONE DEFAULT '' NOT NULL, + user_last_search INTEGER DEFAULT 0 NOT NULL, + user_warnings INTEGER DEFAULT 0 NOT NULL, + user_last_warning INTEGER DEFAULT 0 NOT NULL, + user_login_attempts INTEGER DEFAULT 0 NOT NULL, + user_inactive_reason INTEGER DEFAULT 0 NOT NULL, + user_inactive_time INTEGER DEFAULT 0 NOT NULL, + user_posts INTEGER DEFAULT 0 NOT NULL, + user_lang VARCHAR(30) CHARACTER SET NONE DEFAULT '' NOT NULL, + user_timezone VARCHAR(100) CHARACTER SET NONE DEFAULT 'UTC' NOT NULL, + user_dateformat VARCHAR(30) CHARACTER SET UTF8 DEFAULT 'd M Y H:i' NOT NULL COLLATE UNICODE, + user_style INTEGER DEFAULT 0 NOT NULL, + user_rank INTEGER DEFAULT 0 NOT NULL, + user_colour VARCHAR(6) CHARACTER SET NONE DEFAULT '' NOT NULL, + user_new_privmsg INTEGER DEFAULT 0 NOT NULL, + user_unread_privmsg INTEGER DEFAULT 0 NOT NULL, + user_last_privmsg INTEGER DEFAULT 0 NOT NULL, + user_message_rules INTEGER DEFAULT 0 NOT NULL, + user_full_folder INTEGER DEFAULT -3 NOT NULL, + user_emailtime INTEGER DEFAULT 0 NOT NULL, + user_topic_show_days INTEGER DEFAULT 0 NOT NULL, + user_topic_sortby_type VARCHAR(1) CHARACTER SET NONE DEFAULT 't' NOT NULL, + user_topic_sortby_dir VARCHAR(1) CHARACTER SET NONE DEFAULT 'd' NOT NULL, + user_post_show_days INTEGER DEFAULT 0 NOT NULL, + user_post_sortby_type VARCHAR(1) CHARACTER SET NONE DEFAULT 't' NOT NULL, + user_post_sortby_dir VARCHAR(1) CHARACTER SET NONE DEFAULT 'a' NOT NULL, + user_notify INTEGER DEFAULT 0 NOT NULL, + user_notify_pm INTEGER DEFAULT 1 NOT NULL, + user_notify_type INTEGER DEFAULT 0 NOT NULL, + user_allow_pm INTEGER DEFAULT 1 NOT NULL, + user_allow_viewonline INTEGER DEFAULT 1 NOT NULL, + user_allow_viewemail INTEGER DEFAULT 1 NOT NULL, + user_allow_massemail INTEGER DEFAULT 1 NOT NULL, + user_options INTEGER DEFAULT 230271 NOT NULL, + user_avatar VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL, + user_avatar_type INTEGER DEFAULT 0 NOT NULL, + user_avatar_width INTEGER DEFAULT 0 NOT NULL, + user_avatar_height INTEGER DEFAULT 0 NOT NULL, + user_sig BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL, + user_sig_bbcode_uid VARCHAR(8) CHARACTER SET NONE DEFAULT '' NOT NULL, + user_sig_bbcode_bitfield VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL, + user_from VARCHAR(100) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, + user_icq VARCHAR(15) CHARACTER SET NONE DEFAULT '' NOT NULL, + user_aim VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, + user_yim VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, + user_msnm VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, + user_jabber VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, + user_website VARCHAR(200) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, + user_occ BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL, + user_interests BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL, + user_actkey VARCHAR(32) CHARACTER SET NONE DEFAULT '' NOT NULL, + user_newpasswd VARCHAR(40) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, + user_form_salt VARCHAR(32) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, + user_new INTEGER DEFAULT 1 NOT NULL, + user_reminded INTEGER DEFAULT 0 NOT NULL, + user_reminded_time INTEGER DEFAULT 0 NOT NULL +);; + +ALTER TABLE phpbb_users ADD PRIMARY KEY (user_id);; + +CREATE INDEX phpbb_users_user_birthday ON phpbb_users(user_birthday);; +CREATE INDEX phpbb_users_user_email_hash ON phpbb_users(user_email_hash);; +CREATE INDEX phpbb_users_user_type ON phpbb_users(user_type);; +CREATE UNIQUE INDEX phpbb_users_username_clean ON phpbb_users(username_clean);; + +CREATE GENERATOR phpbb_users_gen;; +SET GENERATOR phpbb_users_gen TO 0;; + +CREATE TRIGGER t_phpbb_users FOR phpbb_users +BEFORE INSERT +AS +BEGIN + NEW.user_id = GEN_ID(phpbb_users_gen, 1); +END;; + + +# Table: 'phpbb_warnings' +CREATE TABLE phpbb_warnings ( + warning_id INTEGER NOT NULL, + user_id INTEGER DEFAULT 0 NOT NULL, + post_id INTEGER DEFAULT 0 NOT NULL, + log_id INTEGER DEFAULT 0 NOT NULL, + warning_time INTEGER DEFAULT 0 NOT NULL +);; + +ALTER TABLE phpbb_warnings ADD PRIMARY KEY (warning_id);; + + +CREATE GENERATOR phpbb_warnings_gen;; +SET GENERATOR phpbb_warnings_gen TO 0;; + +CREATE TRIGGER t_phpbb_warnings FOR phpbb_warnings +BEFORE INSERT +AS +BEGIN + NEW.warning_id = GEN_ID(phpbb_warnings_gen, 1); +END;; + + +# Table: 'phpbb_words' +CREATE TABLE phpbb_words ( + word_id INTEGER NOT NULL, + word VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE, + replacement VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE +);; + +ALTER TABLE phpbb_words ADD PRIMARY KEY (word_id);; + + +CREATE GENERATOR phpbb_words_gen;; +SET GENERATOR phpbb_words_gen TO 0;; + +CREATE TRIGGER t_phpbb_words FOR phpbb_words +BEFORE INSERT +AS +BEGIN + NEW.word_id = GEN_ID(phpbb_words_gen, 1); +END;; + + +# Table: 'phpbb_zebra' +CREATE TABLE phpbb_zebra ( + user_id INTEGER DEFAULT 0 NOT NULL, + zebra_id INTEGER DEFAULT 0 NOT NULL, + friend INTEGER DEFAULT 0 NOT NULL, + foe INTEGER DEFAULT 0 NOT NULL +);; + +ALTER TABLE phpbb_zebra ADD PRIMARY KEY (user_id, zebra_id);; diff --git a/phpBB/install/schemas/mssql_schema.sql b/phpBB/install/schemas/mssql_schema.sql index 9d0e81a66d..9c393b8361 100644 --- a/phpBB/install/schemas/mssql_schema.sql +++ b/phpBB/install/schemas/mssql_schema.sql @@ -1,1657 +1,1655 @@ -/* - * DO NOT EDIT THIS FILE, IT IS GENERATED - * - * To change the contents of this file, edit - * phpBB/develop/create_schema_files.php and - * run it. - */ - -/* - Table: 'phpbb_attachments' -*/ -CREATE TABLE [phpbb_attachments] ( - [attach_id] [int] IDENTITY (1, 1) NOT NULL , - [post_msg_id] [int] DEFAULT (0) NOT NULL , - [topic_id] [int] DEFAULT (0) NOT NULL , - [in_message] [int] DEFAULT (0) NOT NULL , - [poster_id] [int] DEFAULT (0) NOT NULL , - [is_orphan] [int] DEFAULT (1) NOT NULL , - [physical_filename] [varchar] (255) DEFAULT ('') NOT NULL , - [real_filename] [varchar] (255) DEFAULT ('') NOT NULL , - [download_count] [int] DEFAULT (0) NOT NULL , - [attach_comment] [varchar] (4000) DEFAULT ('') NOT NULL , - [extension] [varchar] (100) DEFAULT ('') NOT NULL , - [mimetype] [varchar] (100) DEFAULT ('') NOT NULL , - [filesize] [int] DEFAULT (0) NOT NULL , - [filetime] [int] DEFAULT (0) NOT NULL , - [thumbnail] [int] DEFAULT (0) NOT NULL -) ON [PRIMARY] -GO - -ALTER TABLE [phpbb_attachments] WITH NOCHECK ADD - CONSTRAINT [PK_phpbb_attachments] PRIMARY KEY CLUSTERED - ( - [attach_id] - ) ON [PRIMARY] -GO - -CREATE INDEX [filetime] ON [phpbb_attachments]([filetime]) ON [PRIMARY] -GO - -CREATE INDEX [post_msg_id] ON [phpbb_attachments]([post_msg_id]) ON [PRIMARY] -GO - -CREATE INDEX [topic_id] ON [phpbb_attachments]([topic_id]) ON [PRIMARY] -GO - -CREATE INDEX [poster_id] ON [phpbb_attachments]([poster_id]) ON [PRIMARY] -GO - -CREATE INDEX [is_orphan] ON [phpbb_attachments]([is_orphan]) ON [PRIMARY] -GO - - -/* - Table: 'phpbb_acl_groups' -*/ -CREATE TABLE [phpbb_acl_groups] ( - [group_id] [int] DEFAULT (0) NOT NULL , - [forum_id] [int] DEFAULT (0) NOT NULL , - [auth_option_id] [int] DEFAULT (0) NOT NULL , - [auth_role_id] [int] DEFAULT (0) NOT NULL , - [auth_setting] [int] DEFAULT (0) NOT NULL -) ON [PRIMARY] -GO - -CREATE INDEX [group_id] ON [phpbb_acl_groups]([group_id]) ON [PRIMARY] -GO - -CREATE INDEX [auth_opt_id] ON [phpbb_acl_groups]([auth_option_id]) ON [PRIMARY] -GO - -CREATE INDEX [auth_role_id] ON [phpbb_acl_groups]([auth_role_id]) ON [PRIMARY] -GO - - -/* - Table: 'phpbb_acl_options' -*/ -CREATE TABLE [phpbb_acl_options] ( - [auth_option_id] [int] IDENTITY (1, 1) NOT NULL , - [auth_option] [varchar] (50) DEFAULT ('') NOT NULL , - [is_global] [int] DEFAULT (0) NOT NULL , - [is_local] [int] DEFAULT (0) NOT NULL , - [founder_only] [int] DEFAULT (0) NOT NULL -) ON [PRIMARY] -GO - -ALTER TABLE [phpbb_acl_options] WITH NOCHECK ADD - CONSTRAINT [PK_phpbb_acl_options] PRIMARY KEY CLUSTERED - ( - [auth_option_id] - ) ON [PRIMARY] -GO - -CREATE UNIQUE INDEX [auth_option] ON [phpbb_acl_options]([auth_option]) ON [PRIMARY] -GO - - -/* - Table: 'phpbb_acl_roles' -*/ -CREATE TABLE [phpbb_acl_roles] ( - [role_id] [int] IDENTITY (1, 1) NOT NULL , - [role_name] [varchar] (255) DEFAULT ('') NOT NULL , - [role_description] [varchar] (4000) DEFAULT ('') NOT NULL , - [role_type] [varchar] (10) DEFAULT ('') NOT NULL , - [role_order] [int] DEFAULT (0) NOT NULL -) ON [PRIMARY] -GO - -ALTER TABLE [phpbb_acl_roles] WITH NOCHECK ADD - CONSTRAINT [PK_phpbb_acl_roles] PRIMARY KEY CLUSTERED - ( - [role_id] - ) ON [PRIMARY] -GO - -CREATE INDEX [role_type] ON [phpbb_acl_roles]([role_type]) ON [PRIMARY] -GO - -CREATE INDEX [role_order] ON [phpbb_acl_roles]([role_order]) ON [PRIMARY] -GO - - -/* - Table: 'phpbb_acl_roles_data' -*/ -CREATE TABLE [phpbb_acl_roles_data] ( - [role_id] [int] DEFAULT (0) NOT NULL , - [auth_option_id] [int] DEFAULT (0) NOT NULL , - [auth_setting] [int] DEFAULT (0) NOT NULL -) ON [PRIMARY] -GO - -ALTER TABLE [phpbb_acl_roles_data] WITH NOCHECK ADD - CONSTRAINT [PK_phpbb_acl_roles_data] PRIMARY KEY CLUSTERED - ( - [role_id], - [auth_option_id] - ) ON [PRIMARY] -GO - -CREATE INDEX [ath_op_id] ON [phpbb_acl_roles_data]([auth_option_id]) ON [PRIMARY] -GO - - -/* - Table: 'phpbb_acl_users' -*/ -CREATE TABLE [phpbb_acl_users] ( - [user_id] [int] DEFAULT (0) NOT NULL , - [forum_id] [int] DEFAULT (0) NOT NULL , - [auth_option_id] [int] DEFAULT (0) NOT NULL , - [auth_role_id] [int] DEFAULT (0) NOT NULL , - [auth_setting] [int] DEFAULT (0) NOT NULL -) ON [PRIMARY] -GO - -CREATE INDEX [user_id] ON [phpbb_acl_users]([user_id]) ON [PRIMARY] -GO - -CREATE INDEX [auth_option_id] ON [phpbb_acl_users]([auth_option_id]) ON [PRIMARY] -GO - -CREATE INDEX [auth_role_id] ON [phpbb_acl_users]([auth_role_id]) ON [PRIMARY] -GO - - -/* - Table: 'phpbb_banlist' -*/ -CREATE TABLE [phpbb_banlist] ( - [ban_id] [int] IDENTITY (1, 1) NOT NULL , - [ban_userid] [int] DEFAULT (0) NOT NULL , - [ban_ip] [varchar] (40) DEFAULT ('') NOT NULL , - [ban_email] [varchar] (100) DEFAULT ('') NOT NULL , - [ban_start] [int] DEFAULT (0) NOT NULL , - [ban_end] [int] DEFAULT (0) NOT NULL , - [ban_exclude] [int] DEFAULT (0) NOT NULL , - [ban_reason] [varchar] (255) DEFAULT ('') NOT NULL , - [ban_give_reason] [varchar] (255) DEFAULT ('') NOT NULL -) ON [PRIMARY] -GO - -ALTER TABLE [phpbb_banlist] WITH NOCHECK ADD - CONSTRAINT [PK_phpbb_banlist] PRIMARY KEY CLUSTERED - ( - [ban_id] - ) ON [PRIMARY] -GO - -CREATE INDEX [ban_end] ON [phpbb_banlist]([ban_end]) ON [PRIMARY] -GO - -CREATE INDEX [ban_user] ON [phpbb_banlist]([ban_userid], [ban_exclude]) ON [PRIMARY] -GO - -CREATE INDEX [ban_email] ON [phpbb_banlist]([ban_email], [ban_exclude]) ON [PRIMARY] -GO - -CREATE INDEX [ban_ip] ON [phpbb_banlist]([ban_ip], [ban_exclude]) ON [PRIMARY] -GO - - -/* - Table: 'phpbb_bbcodes' -*/ -CREATE TABLE [phpbb_bbcodes] ( - [bbcode_id] [int] DEFAULT (0) NOT NULL , - [bbcode_tag] [varchar] (16) DEFAULT ('') NOT NULL , - [bbcode_helpline] [varchar] (255) DEFAULT ('') NOT NULL , - [display_on_posting] [int] DEFAULT (0) NOT NULL , - [bbcode_match] [varchar] (4000) DEFAULT ('') NOT NULL , - [bbcode_tpl] [text] DEFAULT ('') NOT NULL , - [first_pass_match] [text] DEFAULT ('') NOT NULL , - [first_pass_replace] [text] DEFAULT ('') NOT NULL , - [second_pass_match] [text] DEFAULT ('') NOT NULL , - [second_pass_replace] [text] DEFAULT ('') NOT NULL -) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY] -GO - -ALTER TABLE [phpbb_bbcodes] WITH NOCHECK ADD - CONSTRAINT [PK_phpbb_bbcodes] PRIMARY KEY CLUSTERED - ( - [bbcode_id] - ) ON [PRIMARY] -GO - -CREATE INDEX [display_on_post] ON [phpbb_bbcodes]([display_on_posting]) ON [PRIMARY] -GO - - -/* - Table: 'phpbb_bookmarks' -*/ -CREATE TABLE [phpbb_bookmarks] ( - [topic_id] [int] DEFAULT (0) NOT NULL , - [user_id] [int] DEFAULT (0) NOT NULL -) ON [PRIMARY] -GO - -ALTER TABLE [phpbb_bookmarks] WITH NOCHECK ADD - CONSTRAINT [PK_phpbb_bookmarks] PRIMARY KEY CLUSTERED - ( - [topic_id], - [user_id] - ) ON [PRIMARY] -GO - - -/* - Table: 'phpbb_bots' -*/ -CREATE TABLE [phpbb_bots] ( - [bot_id] [int] IDENTITY (1, 1) NOT NULL , - [bot_active] [int] DEFAULT (1) NOT NULL , - [bot_name] [varchar] (255) DEFAULT ('') NOT NULL , - [user_id] [int] DEFAULT (0) NOT NULL , - [bot_agent] [varchar] (255) DEFAULT ('') NOT NULL , - [bot_ip] [varchar] (255) DEFAULT ('') NOT NULL -) ON [PRIMARY] -GO - -ALTER TABLE [phpbb_bots] WITH NOCHECK ADD - CONSTRAINT [PK_phpbb_bots] PRIMARY KEY CLUSTERED - ( - [bot_id] - ) ON [PRIMARY] -GO - -CREATE INDEX [bot_active] ON [phpbb_bots]([bot_active]) ON [PRIMARY] -GO - - -/* - Table: 'phpbb_config' -*/ -CREATE TABLE [phpbb_config] ( - [config_name] [varchar] (255) DEFAULT ('') NOT NULL , - [config_value] [varchar] (255) DEFAULT ('') NOT NULL , - [is_dynamic] [int] DEFAULT (0) NOT NULL -) ON [PRIMARY] -GO - -ALTER TABLE [phpbb_config] WITH NOCHECK ADD - CONSTRAINT [PK_phpbb_config] PRIMARY KEY CLUSTERED - ( - [config_name] - ) ON [PRIMARY] -GO - -CREATE INDEX [is_dynamic] ON [phpbb_config]([is_dynamic]) ON [PRIMARY] -GO - - -/* - Table: 'phpbb_confirm' -*/ -CREATE TABLE [phpbb_confirm] ( - [confirm_id] [char] (32) DEFAULT ('') NOT NULL , - [session_id] [char] (32) DEFAULT ('') NOT NULL , - [confirm_type] [int] DEFAULT (0) NOT NULL , - [code] [varchar] (8) DEFAULT ('') NOT NULL , - [seed] [int] DEFAULT (0) NOT NULL , - [attempts] [int] DEFAULT (0) NOT NULL -) ON [PRIMARY] -GO - -ALTER TABLE [phpbb_confirm] WITH NOCHECK ADD - CONSTRAINT [PK_phpbb_confirm] PRIMARY KEY CLUSTERED - ( - [session_id], - [confirm_id] - ) ON [PRIMARY] -GO - -CREATE INDEX [confirm_type] ON [phpbb_confirm]([confirm_type]) ON [PRIMARY] -GO - - -/* - Table: 'phpbb_disallow' -*/ -CREATE TABLE [phpbb_disallow] ( - [disallow_id] [int] IDENTITY (1, 1) NOT NULL , - [disallow_username] [varchar] (255) DEFAULT ('') NOT NULL -) ON [PRIMARY] -GO - -ALTER TABLE [phpbb_disallow] WITH NOCHECK ADD - CONSTRAINT [PK_phpbb_disallow] PRIMARY KEY CLUSTERED - ( - [disallow_id] - ) ON [PRIMARY] -GO - - -/* - Table: 'phpbb_drafts' -*/ -CREATE TABLE [phpbb_drafts] ( - [draft_id] [int] IDENTITY (1, 1) NOT NULL , - [user_id] [int] DEFAULT (0) NOT NULL , - [topic_id] [int] DEFAULT (0) NOT NULL , - [forum_id] [int] DEFAULT (0) NOT NULL , - [save_time] [int] DEFAULT (0) NOT NULL , - [draft_subject] [varchar] (255) DEFAULT ('') NOT NULL , - [draft_message] [text] DEFAULT ('') NOT NULL -) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY] -GO - -ALTER TABLE [phpbb_drafts] WITH NOCHECK ADD - CONSTRAINT [PK_phpbb_drafts] PRIMARY KEY CLUSTERED - ( - [draft_id] - ) ON [PRIMARY] -GO - -CREATE INDEX [save_time] ON [phpbb_drafts]([save_time]) ON [PRIMARY] -GO - - -/* - Table: 'phpbb_ext' -*/ -CREATE TABLE [phpbb_ext] ( - [ext_name] [varchar] (255) DEFAULT ('') NOT NULL , - [ext_active] [int] DEFAULT (0) NOT NULL , - [ext_state] [varchar] (8000) DEFAULT ('') NOT NULL -) ON [PRIMARY] -GO - -CREATE UNIQUE INDEX [ext_name] ON [phpbb_ext]([ext_name]) ON [PRIMARY] -GO - - -/* - Table: 'phpbb_extensions' -*/ -CREATE TABLE [phpbb_extensions] ( - [extension_id] [int] IDENTITY (1, 1) NOT NULL , - [group_id] [int] DEFAULT (0) NOT NULL , - [extension] [varchar] (100) DEFAULT ('') NOT NULL -) ON [PRIMARY] -GO - -ALTER TABLE [phpbb_extensions] WITH NOCHECK ADD - CONSTRAINT [PK_phpbb_extensions] PRIMARY KEY CLUSTERED - ( - [extension_id] - ) ON [PRIMARY] -GO - - -/* - Table: 'phpbb_extension_groups' -*/ -CREATE TABLE [phpbb_extension_groups] ( - [group_id] [int] IDENTITY (1, 1) NOT NULL , - [group_name] [varchar] (255) DEFAULT ('') NOT NULL , - [cat_id] [int] DEFAULT (0) NOT NULL , - [allow_group] [int] DEFAULT (0) NOT NULL , - [download_mode] [int] DEFAULT (1) NOT NULL , - [upload_icon] [varchar] (255) DEFAULT ('') NOT NULL , - [max_filesize] [int] DEFAULT (0) NOT NULL , - [allowed_forums] [varchar] (8000) DEFAULT ('') NOT NULL , - [allow_in_pm] [int] DEFAULT (0) NOT NULL -) ON [PRIMARY] -GO - -ALTER TABLE [phpbb_extension_groups] WITH NOCHECK ADD - CONSTRAINT [PK_phpbb_extension_groups] PRIMARY KEY CLUSTERED - ( - [group_id] - ) ON [PRIMARY] -GO - - -/* - Table: 'phpbb_forums' -*/ -CREATE TABLE [phpbb_forums] ( - [forum_id] [int] IDENTITY (1, 1) NOT NULL , - [parent_id] [int] DEFAULT (0) NOT NULL , - [left_id] [int] DEFAULT (0) NOT NULL , - [right_id] [int] DEFAULT (0) NOT NULL , - [forum_parents] [text] DEFAULT ('') NOT NULL , - [forum_name] [varchar] (255) DEFAULT ('') NOT NULL , - [forum_desc] [varchar] (4000) DEFAULT ('') NOT NULL , - [forum_desc_bitfield] [varchar] (255) DEFAULT ('') NOT NULL , - [forum_desc_options] [int] DEFAULT (7) NOT NULL , - [forum_desc_uid] [varchar] (8) DEFAULT ('') NOT NULL , - [forum_link] [varchar] (255) DEFAULT ('') NOT NULL , - [forum_password] [varchar] (40) DEFAULT ('') NOT NULL , - [forum_style] [int] DEFAULT (0) NOT NULL , - [forum_image] [varchar] (255) DEFAULT ('') NOT NULL , - [forum_rules] [varchar] (4000) DEFAULT ('') NOT NULL , - [forum_rules_link] [varchar] (255) DEFAULT ('') NOT NULL , - [forum_rules_bitfield] [varchar] (255) DEFAULT ('') NOT NULL , - [forum_rules_options] [int] DEFAULT (7) NOT NULL , - [forum_rules_uid] [varchar] (8) DEFAULT ('') NOT NULL , - [forum_topics_per_page] [int] DEFAULT (0) NOT NULL , - [forum_type] [int] DEFAULT (0) NOT NULL , - [forum_status] [int] DEFAULT (0) NOT NULL , - [forum_posts] [int] DEFAULT (0) NOT NULL , - [forum_topics] [int] DEFAULT (0) NOT NULL , - [forum_topics_real] [int] DEFAULT (0) NOT NULL , - [forum_last_post_id] [int] DEFAULT (0) NOT NULL , - [forum_last_poster_id] [int] DEFAULT (0) NOT NULL , - [forum_last_post_subject] [varchar] (255) DEFAULT ('') NOT NULL , - [forum_last_post_time] [int] DEFAULT (0) NOT NULL , - [forum_last_poster_name] [varchar] (255) DEFAULT ('') NOT NULL , - [forum_last_poster_colour] [varchar] (6) DEFAULT ('') NOT NULL , - [forum_flags] [int] DEFAULT (32) NOT NULL , - [forum_options] [int] DEFAULT (0) NOT NULL , - [display_subforum_list] [int] DEFAULT (1) NOT NULL , - [display_on_index] [int] DEFAULT (1) NOT NULL , - [enable_indexing] [int] DEFAULT (1) NOT NULL , - [enable_icons] [int] DEFAULT (1) NOT NULL , - [enable_prune] [int] DEFAULT (0) NOT NULL , - [prune_next] [int] DEFAULT (0) NOT NULL , - [prune_days] [int] DEFAULT (0) NOT NULL , - [prune_viewed] [int] DEFAULT (0) NOT NULL , - [prune_freq] [int] DEFAULT (0) NOT NULL -) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY] -GO - -ALTER TABLE [phpbb_forums] WITH NOCHECK ADD - CONSTRAINT [PK_phpbb_forums] PRIMARY KEY CLUSTERED - ( - [forum_id] - ) ON [PRIMARY] -GO - -CREATE INDEX [left_right_id] ON [phpbb_forums]([left_id], [right_id]) ON [PRIMARY] -GO - -CREATE INDEX [forum_lastpost_id] ON [phpbb_forums]([forum_last_post_id]) ON [PRIMARY] -GO - - -/* - Table: 'phpbb_forums_access' -*/ -CREATE TABLE [phpbb_forums_access] ( - [forum_id] [int] DEFAULT (0) NOT NULL , - [user_id] [int] DEFAULT (0) NOT NULL , - [session_id] [char] (32) DEFAULT ('') NOT NULL -) ON [PRIMARY] -GO - -ALTER TABLE [phpbb_forums_access] WITH NOCHECK ADD - CONSTRAINT [PK_phpbb_forums_access] PRIMARY KEY CLUSTERED - ( - [forum_id], - [user_id], - [session_id] - ) ON [PRIMARY] -GO - - -/* - Table: 'phpbb_forums_track' -*/ -CREATE TABLE [phpbb_forums_track] ( - [user_id] [int] DEFAULT (0) NOT NULL , - [forum_id] [int] DEFAULT (0) NOT NULL , - [mark_time] [int] DEFAULT (0) NOT NULL -) ON [PRIMARY] -GO - -ALTER TABLE [phpbb_forums_track] WITH NOCHECK ADD - CONSTRAINT [PK_phpbb_forums_track] PRIMARY KEY CLUSTERED - ( - [user_id], - [forum_id] - ) ON [PRIMARY] -GO - - -/* - Table: 'phpbb_forums_watch' -*/ -CREATE TABLE [phpbb_forums_watch] ( - [forum_id] [int] DEFAULT (0) NOT NULL , - [user_id] [int] DEFAULT (0) NOT NULL , - [notify_status] [int] DEFAULT (0) NOT NULL -) ON [PRIMARY] -GO - -CREATE INDEX [forum_id] ON [phpbb_forums_watch]([forum_id]) ON [PRIMARY] -GO - -CREATE INDEX [user_id] ON [phpbb_forums_watch]([user_id]) ON [PRIMARY] -GO - -CREATE INDEX [notify_stat] ON [phpbb_forums_watch]([notify_status]) ON [PRIMARY] -GO - - -/* - Table: 'phpbb_groups' -*/ -CREATE TABLE [phpbb_groups] ( - [group_id] [int] IDENTITY (1, 1) NOT NULL , - [group_type] [int] DEFAULT (1) NOT NULL , - [group_founder_manage] [int] DEFAULT (0) NOT NULL , - [group_skip_auth] [int] DEFAULT (0) NOT NULL , - [group_name] [varchar] (255) DEFAULT ('') NOT NULL , - [group_desc] [varchar] (4000) DEFAULT ('') NOT NULL , - [group_desc_bitfield] [varchar] (255) DEFAULT ('') NOT NULL , - [group_desc_options] [int] DEFAULT (7) NOT NULL , - [group_desc_uid] [varchar] (8) DEFAULT ('') NOT NULL , - [group_display] [int] DEFAULT (0) NOT NULL , - [group_avatar] [varchar] (255) DEFAULT ('') NOT NULL , - [group_avatar_type] [int] DEFAULT (0) NOT NULL , - [group_avatar_width] [int] DEFAULT (0) NOT NULL , - [group_avatar_height] [int] DEFAULT (0) NOT NULL , - [group_rank] [int] DEFAULT (0) NOT NULL , - [group_colour] [varchar] (6) DEFAULT ('') NOT NULL , - [group_sig_chars] [int] DEFAULT (0) NOT NULL , - [group_receive_pm] [int] DEFAULT (0) NOT NULL , - [group_message_limit] [int] DEFAULT (0) NOT NULL , - [group_max_recipients] [int] DEFAULT (0) NOT NULL , - [group_legend] [int] DEFAULT (0) NOT NULL , - [group_teampage] [int] DEFAULT (0) NOT NULL -) ON [PRIMARY] -GO - -ALTER TABLE [phpbb_groups] WITH NOCHECK ADD - CONSTRAINT [PK_phpbb_groups] PRIMARY KEY CLUSTERED - ( - [group_id] - ) ON [PRIMARY] -GO - -CREATE INDEX [group_legend_name] ON [phpbb_groups]([group_legend], [group_name]) ON [PRIMARY] -GO - - -/* - Table: 'phpbb_icons' -*/ -CREATE TABLE [phpbb_icons] ( - [icons_id] [int] IDENTITY (1, 1) NOT NULL , - [icons_url] [varchar] (255) DEFAULT ('') NOT NULL , - [icons_width] [int] DEFAULT (0) NOT NULL , - [icons_height] [int] DEFAULT (0) NOT NULL , - [icons_order] [int] DEFAULT (0) NOT NULL , - [display_on_posting] [int] DEFAULT (1) NOT NULL -) ON [PRIMARY] -GO - -ALTER TABLE [phpbb_icons] WITH NOCHECK ADD - CONSTRAINT [PK_phpbb_icons] PRIMARY KEY CLUSTERED - ( - [icons_id] - ) ON [PRIMARY] -GO - -CREATE INDEX [display_on_posting] ON [phpbb_icons]([display_on_posting]) ON [PRIMARY] -GO - - -/* - Table: 'phpbb_lang' -*/ -CREATE TABLE [phpbb_lang] ( - [lang_id] [int] IDENTITY (1, 1) NOT NULL , - [lang_iso] [varchar] (30) DEFAULT ('') NOT NULL , - [lang_dir] [varchar] (30) DEFAULT ('') NOT NULL , - [lang_english_name] [varchar] (100) DEFAULT ('') NOT NULL , - [lang_local_name] [varchar] (255) DEFAULT ('') NOT NULL , - [lang_author] [varchar] (255) DEFAULT ('') NOT NULL -) ON [PRIMARY] -GO - -ALTER TABLE [phpbb_lang] WITH NOCHECK ADD - CONSTRAINT [PK_phpbb_lang] PRIMARY KEY CLUSTERED - ( - [lang_id] - ) ON [PRIMARY] -GO - -CREATE INDEX [lang_iso] ON [phpbb_lang]([lang_iso]) ON [PRIMARY] -GO - - -/* - Table: 'phpbb_log' -*/ -CREATE TABLE [phpbb_log] ( - [log_id] [int] IDENTITY (1, 1) NOT NULL , - [log_type] [int] DEFAULT (0) NOT NULL , - [user_id] [int] DEFAULT (0) NOT NULL , - [forum_id] [int] DEFAULT (0) NOT NULL , - [topic_id] [int] DEFAULT (0) NOT NULL , - [reportee_id] [int] DEFAULT (0) NOT NULL , - [log_ip] [varchar] (40) DEFAULT ('') NOT NULL , - [log_time] [int] DEFAULT (0) NOT NULL , - [log_operation] [varchar] (4000) DEFAULT ('') NOT NULL , - [log_data] [text] DEFAULT ('') NOT NULL -) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY] -GO - -ALTER TABLE [phpbb_log] WITH NOCHECK ADD - CONSTRAINT [PK_phpbb_log] PRIMARY KEY CLUSTERED - ( - [log_id] - ) ON [PRIMARY] -GO - -CREATE INDEX [log_type] ON [phpbb_log]([log_type]) ON [PRIMARY] -GO - -CREATE INDEX [log_time] ON [phpbb_log]([log_time]) ON [PRIMARY] -GO - -CREATE INDEX [forum_id] ON [phpbb_log]([forum_id]) ON [PRIMARY] -GO - -CREATE INDEX [topic_id] ON [phpbb_log]([topic_id]) ON [PRIMARY] -GO - -CREATE INDEX [reportee_id] ON [phpbb_log]([reportee_id]) ON [PRIMARY] -GO - -CREATE INDEX [user_id] ON [phpbb_log]([user_id]) ON [PRIMARY] -GO - - -/* - Table: 'phpbb_login_attempts' -*/ -CREATE TABLE [phpbb_login_attempts] ( - [attempt_ip] [varchar] (40) DEFAULT ('') NOT NULL , - [attempt_browser] [varchar] (150) DEFAULT ('') NOT NULL , - [attempt_forwarded_for] [varchar] (255) DEFAULT ('') NOT NULL , - [attempt_time] [int] DEFAULT (0) NOT NULL , - [user_id] [int] DEFAULT (0) NOT NULL , - [username] [varchar] (255) DEFAULT (0) NOT NULL , - [username_clean] [varchar] (255) DEFAULT (0) NOT NULL -) ON [PRIMARY] -GO - -CREATE INDEX [att_ip] ON [phpbb_login_attempts]([attempt_ip], [attempt_time]) ON [PRIMARY] -GO - -CREATE INDEX [att_for] ON [phpbb_login_attempts]([attempt_forwarded_for], [attempt_time]) ON [PRIMARY] -GO - -CREATE INDEX [att_time] ON [phpbb_login_attempts]([attempt_time]) ON [PRIMARY] -GO - -CREATE INDEX [user_id] ON [phpbb_login_attempts]([user_id]) ON [PRIMARY] -GO - - -/* - Table: 'phpbb_moderator_cache' -*/ -CREATE TABLE [phpbb_moderator_cache] ( - [forum_id] [int] DEFAULT (0) NOT NULL , - [user_id] [int] DEFAULT (0) NOT NULL , - [username] [varchar] (255) DEFAULT ('') NOT NULL , - [group_id] [int] DEFAULT (0) NOT NULL , - [group_name] [varchar] (255) DEFAULT ('') NOT NULL , - [display_on_index] [int] DEFAULT (1) NOT NULL -) ON [PRIMARY] -GO - -CREATE INDEX [disp_idx] ON [phpbb_moderator_cache]([display_on_index]) ON [PRIMARY] -GO - -CREATE INDEX [forum_id] ON [phpbb_moderator_cache]([forum_id]) ON [PRIMARY] -GO - - -/* - Table: 'phpbb_modules' -*/ -CREATE TABLE [phpbb_modules] ( - [module_id] [int] IDENTITY (1, 1) NOT NULL , - [module_enabled] [int] DEFAULT (1) NOT NULL , - [module_display] [int] DEFAULT (1) NOT NULL , - [module_basename] [varchar] (255) DEFAULT ('') NOT NULL , - [module_class] [varchar] (10) DEFAULT ('') NOT NULL , - [parent_id] [int] DEFAULT (0) NOT NULL , - [left_id] [int] DEFAULT (0) NOT NULL , - [right_id] [int] DEFAULT (0) NOT NULL , - [module_langname] [varchar] (255) DEFAULT ('') NOT NULL , - [module_mode] [varchar] (255) DEFAULT ('') NOT NULL , - [module_auth] [varchar] (255) DEFAULT ('') NOT NULL -) ON [PRIMARY] -GO - -ALTER TABLE [phpbb_modules] WITH NOCHECK ADD - CONSTRAINT [PK_phpbb_modules] PRIMARY KEY CLUSTERED - ( - [module_id] - ) ON [PRIMARY] -GO - -CREATE INDEX [left_right_id] ON [phpbb_modules]([left_id], [right_id]) ON [PRIMARY] -GO - -CREATE INDEX [module_enabled] ON [phpbb_modules]([module_enabled]) ON [PRIMARY] -GO - -CREATE INDEX [class_left_id] ON [phpbb_modules]([module_class], [left_id]) ON [PRIMARY] -GO - - -/* - Table: 'phpbb_poll_options' -*/ -CREATE TABLE [phpbb_poll_options] ( - [poll_option_id] [int] DEFAULT (0) NOT NULL , - [topic_id] [int] DEFAULT (0) NOT NULL , - [poll_option_text] [varchar] (4000) DEFAULT ('') NOT NULL , - [poll_option_total] [int] DEFAULT (0) NOT NULL -) ON [PRIMARY] -GO - -CREATE INDEX [poll_opt_id] ON [phpbb_poll_options]([poll_option_id]) ON [PRIMARY] -GO - -CREATE INDEX [topic_id] ON [phpbb_poll_options]([topic_id]) ON [PRIMARY] -GO - - -/* - Table: 'phpbb_poll_votes' -*/ -CREATE TABLE [phpbb_poll_votes] ( - [topic_id] [int] DEFAULT (0) NOT NULL , - [poll_option_id] [int] DEFAULT (0) NOT NULL , - [vote_user_id] [int] DEFAULT (0) NOT NULL , - [vote_user_ip] [varchar] (40) DEFAULT ('') NOT NULL -) ON [PRIMARY] -GO - -CREATE INDEX [topic_id] ON [phpbb_poll_votes]([topic_id]) ON [PRIMARY] -GO - -CREATE INDEX [vote_user_id] ON [phpbb_poll_votes]([vote_user_id]) ON [PRIMARY] -GO - -CREATE INDEX [vote_user_ip] ON [phpbb_poll_votes]([vote_user_ip]) ON [PRIMARY] -GO - - -/* - Table: 'phpbb_posts' -*/ -CREATE TABLE [phpbb_posts] ( - [post_id] [int] IDENTITY (1, 1) NOT NULL , - [topic_id] [int] DEFAULT (0) NOT NULL , - [forum_id] [int] DEFAULT (0) NOT NULL , - [poster_id] [int] DEFAULT (0) NOT NULL , - [icon_id] [int] DEFAULT (0) NOT NULL , - [poster_ip] [varchar] (40) DEFAULT ('') NOT NULL , - [post_time] [int] DEFAULT (0) NOT NULL , - [post_approved] [int] DEFAULT (1) NOT NULL , - [post_reported] [int] DEFAULT (0) NOT NULL , - [enable_bbcode] [int] DEFAULT (1) NOT NULL , - [enable_smilies] [int] DEFAULT (1) NOT NULL , - [enable_magic_url] [int] DEFAULT (1) NOT NULL , - [enable_sig] [int] DEFAULT (1) NOT NULL , - [post_username] [varchar] (255) DEFAULT ('') NOT NULL , - [post_subject] [varchar] (255) DEFAULT ('') NOT NULL , - [post_text] [text] DEFAULT ('') NOT NULL , - [post_checksum] [varchar] (32) DEFAULT ('') NOT NULL , - [post_attachment] [int] DEFAULT (0) NOT NULL , - [bbcode_bitfield] [varchar] (255) DEFAULT ('') NOT NULL , - [bbcode_uid] [varchar] (8) DEFAULT ('') NOT NULL , - [post_postcount] [int] DEFAULT (1) NOT NULL , - [post_edit_time] [int] DEFAULT (0) NOT NULL , - [post_edit_reason] [varchar] (255) DEFAULT ('') NOT NULL , - [post_edit_user] [int] DEFAULT (0) NOT NULL , - [post_edit_count] [int] DEFAULT (0) NOT NULL , - [post_edit_locked] [int] DEFAULT (0) NOT NULL -) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY] -GO - -ALTER TABLE [phpbb_posts] WITH NOCHECK ADD - CONSTRAINT [PK_phpbb_posts] PRIMARY KEY CLUSTERED - ( - [post_id] - ) ON [PRIMARY] -GO - -CREATE INDEX [forum_id] ON [phpbb_posts]([forum_id]) ON [PRIMARY] -GO - -CREATE INDEX [topic_id] ON [phpbb_posts]([topic_id]) ON [PRIMARY] -GO - -CREATE INDEX [poster_ip] ON [phpbb_posts]([poster_ip]) ON [PRIMARY] -GO - -CREATE INDEX [poster_id] ON [phpbb_posts]([poster_id]) ON [PRIMARY] -GO - -CREATE INDEX [post_approved] ON [phpbb_posts]([post_approved]) ON [PRIMARY] -GO - -CREATE INDEX [post_username] ON [phpbb_posts]([post_username]) ON [PRIMARY] -GO - -CREATE INDEX [tid_post_time] ON [phpbb_posts]([topic_id], [post_time]) ON [PRIMARY] -GO - - -/* - Table: 'phpbb_privmsgs' -*/ -CREATE TABLE [phpbb_privmsgs] ( - [msg_id] [int] IDENTITY (1, 1) NOT NULL , - [root_level] [int] DEFAULT (0) NOT NULL , - [author_id] [int] DEFAULT (0) NOT NULL , - [icon_id] [int] DEFAULT (0) NOT NULL , - [author_ip] [varchar] (40) DEFAULT ('') NOT NULL , - [message_time] [int] DEFAULT (0) NOT NULL , - [enable_bbcode] [int] DEFAULT (1) NOT NULL , - [enable_smilies] [int] DEFAULT (1) NOT NULL , - [enable_magic_url] [int] DEFAULT (1) NOT NULL , - [enable_sig] [int] DEFAULT (1) NOT NULL , - [message_subject] [varchar] (255) DEFAULT ('') NOT NULL , - [message_text] [text] DEFAULT ('') NOT NULL , - [message_edit_reason] [varchar] (255) DEFAULT ('') NOT NULL , - [message_edit_user] [int] DEFAULT (0) NOT NULL , - [message_attachment] [int] DEFAULT (0) NOT NULL , - [bbcode_bitfield] [varchar] (255) DEFAULT ('') NOT NULL , - [bbcode_uid] [varchar] (8) DEFAULT ('') NOT NULL , - [message_edit_time] [int] DEFAULT (0) NOT NULL , - [message_edit_count] [int] DEFAULT (0) NOT NULL , - [to_address] [varchar] (4000) DEFAULT ('') NOT NULL , - [bcc_address] [varchar] (4000) DEFAULT ('') NOT NULL , - [message_reported] [int] DEFAULT (0) NOT NULL -) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY] -GO - -ALTER TABLE [phpbb_privmsgs] WITH NOCHECK ADD - CONSTRAINT [PK_phpbb_privmsgs] PRIMARY KEY CLUSTERED - ( - [msg_id] - ) ON [PRIMARY] -GO - -CREATE INDEX [author_ip] ON [phpbb_privmsgs]([author_ip]) ON [PRIMARY] -GO - -CREATE INDEX [message_time] ON [phpbb_privmsgs]([message_time]) ON [PRIMARY] -GO - -CREATE INDEX [author_id] ON [phpbb_privmsgs]([author_id]) ON [PRIMARY] -GO - -CREATE INDEX [root_level] ON [phpbb_privmsgs]([root_level]) ON [PRIMARY] -GO - - -/* - Table: 'phpbb_privmsgs_folder' -*/ -CREATE TABLE [phpbb_privmsgs_folder] ( - [folder_id] [int] IDENTITY (1, 1) NOT NULL , - [user_id] [int] DEFAULT (0) NOT NULL , - [folder_name] [varchar] (255) DEFAULT ('') NOT NULL , - [pm_count] [int] DEFAULT (0) NOT NULL -) ON [PRIMARY] -GO - -ALTER TABLE [phpbb_privmsgs_folder] WITH NOCHECK ADD - CONSTRAINT [PK_phpbb_privmsgs_folder] PRIMARY KEY CLUSTERED - ( - [folder_id] - ) ON [PRIMARY] -GO - -CREATE INDEX [user_id] ON [phpbb_privmsgs_folder]([user_id]) ON [PRIMARY] -GO - - -/* - Table: 'phpbb_privmsgs_rules' -*/ -CREATE TABLE [phpbb_privmsgs_rules] ( - [rule_id] [int] IDENTITY (1, 1) NOT NULL , - [user_id] [int] DEFAULT (0) NOT NULL , - [rule_check] [int] DEFAULT (0) NOT NULL , - [rule_connection] [int] DEFAULT (0) NOT NULL , - [rule_string] [varchar] (255) DEFAULT ('') NOT NULL , - [rule_user_id] [int] DEFAULT (0) NOT NULL , - [rule_group_id] [int] DEFAULT (0) NOT NULL , - [rule_action] [int] DEFAULT (0) NOT NULL , - [rule_folder_id] [int] DEFAULT (0) NOT NULL -) ON [PRIMARY] -GO - -ALTER TABLE [phpbb_privmsgs_rules] WITH NOCHECK ADD - CONSTRAINT [PK_phpbb_privmsgs_rules] PRIMARY KEY CLUSTERED - ( - [rule_id] - ) ON [PRIMARY] -GO - -CREATE INDEX [user_id] ON [phpbb_privmsgs_rules]([user_id]) ON [PRIMARY] -GO - - -/* - Table: 'phpbb_privmsgs_to' -*/ -CREATE TABLE [phpbb_privmsgs_to] ( - [msg_id] [int] DEFAULT (0) NOT NULL , - [user_id] [int] DEFAULT (0) NOT NULL , - [author_id] [int] DEFAULT (0) NOT NULL , - [pm_deleted] [int] DEFAULT (0) NOT NULL , - [pm_new] [int] DEFAULT (1) NOT NULL , - [pm_unread] [int] DEFAULT (1) NOT NULL , - [pm_replied] [int] DEFAULT (0) NOT NULL , - [pm_marked] [int] DEFAULT (0) NOT NULL , - [pm_forwarded] [int] DEFAULT (0) NOT NULL , - [folder_id] [int] DEFAULT (0) NOT NULL -) ON [PRIMARY] -GO - -CREATE INDEX [msg_id] ON [phpbb_privmsgs_to]([msg_id]) ON [PRIMARY] -GO - -CREATE INDEX [author_id] ON [phpbb_privmsgs_to]([author_id]) ON [PRIMARY] -GO - -CREATE INDEX [usr_flder_id] ON [phpbb_privmsgs_to]([user_id], [folder_id]) ON [PRIMARY] -GO - - -/* - Table: 'phpbb_profile_fields' -*/ -CREATE TABLE [phpbb_profile_fields] ( - [field_id] [int] IDENTITY (1, 1) NOT NULL , - [field_name] [varchar] (255) DEFAULT ('') NOT NULL , - [field_type] [int] DEFAULT (0) NOT NULL , - [field_ident] [varchar] (20) DEFAULT ('') NOT NULL , - [field_length] [varchar] (20) DEFAULT ('') NOT NULL , - [field_minlen] [varchar] (255) DEFAULT ('') NOT NULL , - [field_maxlen] [varchar] (255) DEFAULT ('') NOT NULL , - [field_novalue] [varchar] (255) DEFAULT ('') NOT NULL , - [field_default_value] [varchar] (255) DEFAULT ('') NOT NULL , - [field_validation] [varchar] (20) DEFAULT ('') NOT NULL , - [field_required] [int] DEFAULT (0) NOT NULL , - [field_show_novalue] [int] DEFAULT (0) NOT NULL , - [field_show_on_reg] [int] DEFAULT (0) NOT NULL , - [field_show_on_pm] [int] DEFAULT (0) NOT NULL , - [field_show_on_vt] [int] DEFAULT (0) NOT NULL , - [field_show_profile] [int] DEFAULT (0) NOT NULL , - [field_hide] [int] DEFAULT (0) NOT NULL , - [field_no_view] [int] DEFAULT (0) NOT NULL , - [field_active] [int] DEFAULT (0) NOT NULL , - [field_order] [int] DEFAULT (0) NOT NULL -) ON [PRIMARY] -GO - -ALTER TABLE [phpbb_profile_fields] WITH NOCHECK ADD - CONSTRAINT [PK_phpbb_profile_fields] PRIMARY KEY CLUSTERED - ( - [field_id] - ) ON [PRIMARY] -GO - -CREATE INDEX [fld_type] ON [phpbb_profile_fields]([field_type]) ON [PRIMARY] -GO - -CREATE INDEX [fld_ordr] ON [phpbb_profile_fields]([field_order]) ON [PRIMARY] -GO - - -/* - Table: 'phpbb_profile_fields_data' -*/ -CREATE TABLE [phpbb_profile_fields_data] ( - [user_id] [int] DEFAULT (0) NOT NULL -) ON [PRIMARY] -GO - -ALTER TABLE [phpbb_profile_fields_data] WITH NOCHECK ADD - CONSTRAINT [PK_phpbb_profile_fields_data] PRIMARY KEY CLUSTERED - ( - [user_id] - ) ON [PRIMARY] -GO - - -/* - Table: 'phpbb_profile_fields_lang' -*/ -CREATE TABLE [phpbb_profile_fields_lang] ( - [field_id] [int] DEFAULT (0) NOT NULL , - [lang_id] [int] DEFAULT (0) NOT NULL , - [option_id] [int] DEFAULT (0) NOT NULL , - [field_type] [int] DEFAULT (0) NOT NULL , - [lang_value] [varchar] (255) DEFAULT ('') NOT NULL -) ON [PRIMARY] -GO - -ALTER TABLE [phpbb_profile_fields_lang] WITH NOCHECK ADD - CONSTRAINT [PK_phpbb_profile_fields_lang] PRIMARY KEY CLUSTERED - ( - [field_id], - [lang_id], - [option_id] - ) ON [PRIMARY] -GO - - -/* - Table: 'phpbb_profile_lang' -*/ -CREATE TABLE [phpbb_profile_lang] ( - [field_id] [int] DEFAULT (0) NOT NULL , - [lang_id] [int] DEFAULT (0) NOT NULL , - [lang_name] [varchar] (255) DEFAULT ('') NOT NULL , - [lang_explain] [varchar] (4000) DEFAULT ('') NOT NULL , - [lang_default_value] [varchar] (255) DEFAULT ('') NOT NULL -) ON [PRIMARY] -GO - -ALTER TABLE [phpbb_profile_lang] WITH NOCHECK ADD - CONSTRAINT [PK_phpbb_profile_lang] PRIMARY KEY CLUSTERED - ( - [field_id], - [lang_id] - ) ON [PRIMARY] -GO - - -/* - Table: 'phpbb_ranks' -*/ -CREATE TABLE [phpbb_ranks] ( - [rank_id] [int] IDENTITY (1, 1) NOT NULL , - [rank_title] [varchar] (255) DEFAULT ('') NOT NULL , - [rank_min] [int] DEFAULT (0) NOT NULL , - [rank_special] [int] DEFAULT (0) NOT NULL , - [rank_image] [varchar] (255) DEFAULT ('') NOT NULL -) ON [PRIMARY] -GO - -ALTER TABLE [phpbb_ranks] WITH NOCHECK ADD - CONSTRAINT [PK_phpbb_ranks] PRIMARY KEY CLUSTERED - ( - [rank_id] - ) ON [PRIMARY] -GO - - -/* - Table: 'phpbb_reports' -*/ -CREATE TABLE [phpbb_reports] ( - [report_id] [int] IDENTITY (1, 1) NOT NULL , - [reason_id] [int] DEFAULT (0) NOT NULL , - [post_id] [int] DEFAULT (0) NOT NULL , - [pm_id] [int] DEFAULT (0) NOT NULL , - [user_id] [int] DEFAULT (0) NOT NULL , - [user_notify] [int] DEFAULT (0) NOT NULL , - [report_closed] [int] DEFAULT (0) NOT NULL , - [report_time] [int] DEFAULT (0) NOT NULL , - [report_text] [text] DEFAULT ('') NOT NULL , - [reported_post_text] [text] DEFAULT ('') NOT NULL -) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY] -GO - -ALTER TABLE [phpbb_reports] WITH NOCHECK ADD - CONSTRAINT [PK_phpbb_reports] PRIMARY KEY CLUSTERED - ( - [report_id] - ) ON [PRIMARY] -GO - -CREATE INDEX [post_id] ON [phpbb_reports]([post_id]) ON [PRIMARY] -GO - -CREATE INDEX [pm_id] ON [phpbb_reports]([pm_id]) ON [PRIMARY] -GO - - -/* - Table: 'phpbb_reports_reasons' -*/ -CREATE TABLE [phpbb_reports_reasons] ( - [reason_id] [int] IDENTITY (1, 1) NOT NULL , - [reason_title] [varchar] (255) DEFAULT ('') NOT NULL , - [reason_description] [text] DEFAULT ('') NOT NULL , - [reason_order] [int] DEFAULT (0) NOT NULL -) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY] -GO - -ALTER TABLE [phpbb_reports_reasons] WITH NOCHECK ADD - CONSTRAINT [PK_phpbb_reports_reasons] PRIMARY KEY CLUSTERED - ( - [reason_id] - ) ON [PRIMARY] -GO - - -/* - Table: 'phpbb_search_results' -*/ -CREATE TABLE [phpbb_search_results] ( - [search_key] [varchar] (32) DEFAULT ('') NOT NULL , - [search_time] [int] DEFAULT (0) NOT NULL , - [search_keywords] [text] DEFAULT ('') NOT NULL , - [search_authors] [text] DEFAULT ('') NOT NULL -) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY] -GO - -ALTER TABLE [phpbb_search_results] WITH NOCHECK ADD - CONSTRAINT [PK_phpbb_search_results] PRIMARY KEY CLUSTERED - ( - [search_key] - ) ON [PRIMARY] -GO - - -/* - Table: 'phpbb_search_wordlist' -*/ -CREATE TABLE [phpbb_search_wordlist] ( - [word_id] [int] IDENTITY (1, 1) NOT NULL , - [word_text] [varchar] (255) DEFAULT ('') NOT NULL , - [word_common] [int] DEFAULT (0) NOT NULL , - [word_count] [int] DEFAULT (0) NOT NULL -) ON [PRIMARY] -GO - -ALTER TABLE [phpbb_search_wordlist] WITH NOCHECK ADD - CONSTRAINT [PK_phpbb_search_wordlist] PRIMARY KEY CLUSTERED - ( - [word_id] - ) ON [PRIMARY] -GO - -CREATE UNIQUE INDEX [wrd_txt] ON [phpbb_search_wordlist]([word_text]) ON [PRIMARY] -GO - -CREATE INDEX [wrd_cnt] ON [phpbb_search_wordlist]([word_count]) ON [PRIMARY] -GO - - -/* - Table: 'phpbb_search_wordmatch' -*/ -CREATE TABLE [phpbb_search_wordmatch] ( - [post_id] [int] DEFAULT (0) NOT NULL , - [word_id] [int] DEFAULT (0) NOT NULL , - [title_match] [int] DEFAULT (0) NOT NULL -) ON [PRIMARY] -GO - -CREATE UNIQUE INDEX [unq_mtch] ON [phpbb_search_wordmatch]([word_id], [post_id], [title_match]) ON [PRIMARY] -GO - -CREATE INDEX [word_id] ON [phpbb_search_wordmatch]([word_id]) ON [PRIMARY] -GO - -CREATE INDEX [post_id] ON [phpbb_search_wordmatch]([post_id]) ON [PRIMARY] -GO - - -/* - Table: 'phpbb_sessions' -*/ -CREATE TABLE [phpbb_sessions] ( - [session_id] [char] (32) DEFAULT ('') NOT NULL , - [session_user_id] [int] DEFAULT (0) NOT NULL , - [session_forum_id] [int] DEFAULT (0) NOT NULL , - [session_last_visit] [int] DEFAULT (0) NOT NULL , - [session_start] [int] DEFAULT (0) NOT NULL , - [session_time] [int] DEFAULT (0) NOT NULL , - [session_ip] [varchar] (40) DEFAULT ('') NOT NULL , - [session_browser] [varchar] (150) DEFAULT ('') NOT NULL , - [session_forwarded_for] [varchar] (255) DEFAULT ('') NOT NULL , - [session_page] [varchar] (255) DEFAULT ('') NOT NULL , - [session_viewonline] [int] DEFAULT (1) NOT NULL , - [session_autologin] [int] DEFAULT (0) NOT NULL , - [session_admin] [int] DEFAULT (0) NOT NULL -) ON [PRIMARY] -GO - -ALTER TABLE [phpbb_sessions] WITH NOCHECK ADD - CONSTRAINT [PK_phpbb_sessions] PRIMARY KEY CLUSTERED - ( - [session_id] - ) ON [PRIMARY] -GO - -CREATE INDEX [session_time] ON [phpbb_sessions]([session_time]) ON [PRIMARY] -GO - -CREATE INDEX [session_user_id] ON [phpbb_sessions]([session_user_id]) ON [PRIMARY] -GO - -CREATE INDEX [session_fid] ON [phpbb_sessions]([session_forum_id]) ON [PRIMARY] -GO - - -/* - Table: 'phpbb_sessions_keys' -*/ -CREATE TABLE [phpbb_sessions_keys] ( - [key_id] [char] (32) DEFAULT ('') NOT NULL , - [user_id] [int] DEFAULT (0) NOT NULL , - [last_ip] [varchar] (40) DEFAULT ('') NOT NULL , - [last_login] [int] DEFAULT (0) NOT NULL -) ON [PRIMARY] -GO - -ALTER TABLE [phpbb_sessions_keys] WITH NOCHECK ADD - CONSTRAINT [PK_phpbb_sessions_keys] PRIMARY KEY CLUSTERED - ( - [key_id], - [user_id] - ) ON [PRIMARY] -GO - -CREATE INDEX [last_login] ON [phpbb_sessions_keys]([last_login]) ON [PRIMARY] -GO - - -/* - Table: 'phpbb_sitelist' -*/ -CREATE TABLE [phpbb_sitelist] ( - [site_id] [int] IDENTITY (1, 1) NOT NULL , - [site_ip] [varchar] (40) DEFAULT ('') NOT NULL , - [site_hostname] [varchar] (255) DEFAULT ('') NOT NULL , - [ip_exclude] [int] DEFAULT (0) NOT NULL -) ON [PRIMARY] -GO - -ALTER TABLE [phpbb_sitelist] WITH NOCHECK ADD - CONSTRAINT [PK_phpbb_sitelist] PRIMARY KEY CLUSTERED - ( - [site_id] - ) ON [PRIMARY] -GO - - -/* - Table: 'phpbb_smilies' -*/ -CREATE TABLE [phpbb_smilies] ( - [smiley_id] [int] IDENTITY (1, 1) NOT NULL , - [code] [varchar] (50) DEFAULT ('') NOT NULL , - [emotion] [varchar] (50) DEFAULT ('') NOT NULL , - [smiley_url] [varchar] (50) DEFAULT ('') NOT NULL , - [smiley_width] [int] DEFAULT (0) NOT NULL , - [smiley_height] [int] DEFAULT (0) NOT NULL , - [smiley_order] [int] DEFAULT (0) NOT NULL , - [display_on_posting] [int] DEFAULT (1) NOT NULL -) ON [PRIMARY] -GO - -ALTER TABLE [phpbb_smilies] WITH NOCHECK ADD - CONSTRAINT [PK_phpbb_smilies] PRIMARY KEY CLUSTERED - ( - [smiley_id] - ) ON [PRIMARY] -GO - -CREATE INDEX [display_on_post] ON [phpbb_smilies]([display_on_posting]) ON [PRIMARY] -GO - - -/* - Table: 'phpbb_styles' -*/ -CREATE TABLE [phpbb_styles] ( - [style_id] [int] IDENTITY (1, 1) NOT NULL , - [style_name] [varchar] (255) DEFAULT ('') NOT NULL , - [style_copyright] [varchar] (255) DEFAULT ('') NOT NULL , - [style_active] [int] DEFAULT (1) NOT NULL , - [style_path] [varchar] (100) DEFAULT ('') NOT NULL , - [bbcode_bitfield] [varchar] (255) DEFAULT ('kNg=') NOT NULL , - [style_parent_id] [int] DEFAULT (0) NOT NULL , - [style_parent_tree] [varchar] (8000) DEFAULT ('') NOT NULL -) ON [PRIMARY] -GO - -ALTER TABLE [phpbb_styles] WITH NOCHECK ADD - CONSTRAINT [PK_phpbb_styles] PRIMARY KEY CLUSTERED - ( - [style_id] - ) ON [PRIMARY] -GO - -CREATE UNIQUE INDEX [style_name] ON [phpbb_styles]([style_name]) ON [PRIMARY] -GO - - -/* - Table: 'phpbb_topics' -*/ -CREATE TABLE [phpbb_topics] ( - [topic_id] [int] IDENTITY (1, 1) NOT NULL , - [forum_id] [int] DEFAULT (0) NOT NULL , - [icon_id] [int] DEFAULT (0) NOT NULL , - [topic_attachment] [int] DEFAULT (0) NOT NULL , - [topic_approved] [int] DEFAULT (1) NOT NULL , - [topic_reported] [int] DEFAULT (0) NOT NULL , - [topic_title] [varchar] (255) DEFAULT ('') NOT NULL , - [topic_poster] [int] DEFAULT (0) NOT NULL , - [topic_time] [int] DEFAULT (0) NOT NULL , - [topic_time_limit] [int] DEFAULT (0) NOT NULL , - [topic_views] [int] DEFAULT (0) NOT NULL , - [topic_replies] [int] DEFAULT (0) NOT NULL , - [topic_replies_real] [int] DEFAULT (0) NOT NULL , - [topic_status] [int] DEFAULT (0) NOT NULL , - [topic_type] [int] DEFAULT (0) NOT NULL , - [topic_first_post_id] [int] DEFAULT (0) NOT NULL , - [topic_first_poster_name] [varchar] (255) DEFAULT ('') NOT NULL , - [topic_first_poster_colour] [varchar] (6) DEFAULT ('') NOT NULL , - [topic_last_post_id] [int] DEFAULT (0) NOT NULL , - [topic_last_poster_id] [int] DEFAULT (0) NOT NULL , - [topic_last_poster_name] [varchar] (255) DEFAULT ('') NOT NULL , - [topic_last_poster_colour] [varchar] (6) DEFAULT ('') NOT NULL , - [topic_last_post_subject] [varchar] (255) DEFAULT ('') NOT NULL , - [topic_last_post_time] [int] DEFAULT (0) NOT NULL , - [topic_last_view_time] [int] DEFAULT (0) NOT NULL , - [topic_moved_id] [int] DEFAULT (0) NOT NULL , - [topic_bumped] [int] DEFAULT (0) NOT NULL , - [topic_bumper] [int] DEFAULT (0) NOT NULL , - [poll_title] [varchar] (255) DEFAULT ('') NOT NULL , - [poll_start] [int] DEFAULT (0) NOT NULL , - [poll_length] [int] DEFAULT (0) NOT NULL , - [poll_max_options] [int] DEFAULT (1) NOT NULL , - [poll_last_vote] [int] DEFAULT (0) NOT NULL , - [poll_vote_change] [int] DEFAULT (0) NOT NULL -) ON [PRIMARY] -GO - -ALTER TABLE [phpbb_topics] WITH NOCHECK ADD - CONSTRAINT [PK_phpbb_topics] PRIMARY KEY CLUSTERED - ( - [topic_id] - ) ON [PRIMARY] -GO - -CREATE INDEX [forum_id] ON [phpbb_topics]([forum_id]) ON [PRIMARY] -GO - -CREATE INDEX [forum_id_type] ON [phpbb_topics]([forum_id], [topic_type]) ON [PRIMARY] -GO - -CREATE INDEX [last_post_time] ON [phpbb_topics]([topic_last_post_time]) ON [PRIMARY] -GO - -CREATE INDEX [topic_approved] ON [phpbb_topics]([topic_approved]) ON [PRIMARY] -GO - -CREATE INDEX [forum_appr_last] ON [phpbb_topics]([forum_id], [topic_approved], [topic_last_post_id]) ON [PRIMARY] -GO - -CREATE INDEX [fid_time_moved] ON [phpbb_topics]([forum_id], [topic_last_post_time], [topic_moved_id]) ON [PRIMARY] -GO - - -/* - Table: 'phpbb_topics_track' -*/ -CREATE TABLE [phpbb_topics_track] ( - [user_id] [int] DEFAULT (0) NOT NULL , - [topic_id] [int] DEFAULT (0) NOT NULL , - [forum_id] [int] DEFAULT (0) NOT NULL , - [mark_time] [int] DEFAULT (0) NOT NULL -) ON [PRIMARY] -GO - -ALTER TABLE [phpbb_topics_track] WITH NOCHECK ADD - CONSTRAINT [PK_phpbb_topics_track] PRIMARY KEY CLUSTERED - ( - [user_id], - [topic_id] - ) ON [PRIMARY] -GO - -CREATE INDEX [topic_id] ON [phpbb_topics_track]([topic_id]) ON [PRIMARY] -GO - -CREATE INDEX [forum_id] ON [phpbb_topics_track]([forum_id]) ON [PRIMARY] -GO - - -/* - Table: 'phpbb_topics_posted' -*/ -CREATE TABLE [phpbb_topics_posted] ( - [user_id] [int] DEFAULT (0) NOT NULL , - [topic_id] [int] DEFAULT (0) NOT NULL , - [topic_posted] [int] DEFAULT (0) NOT NULL -) ON [PRIMARY] -GO - -ALTER TABLE [phpbb_topics_posted] WITH NOCHECK ADD - CONSTRAINT [PK_phpbb_topics_posted] PRIMARY KEY CLUSTERED - ( - [user_id], - [topic_id] - ) ON [PRIMARY] -GO - - -/* - Table: 'phpbb_topics_watch' -*/ -CREATE TABLE [phpbb_topics_watch] ( - [topic_id] [int] DEFAULT (0) NOT NULL , - [user_id] [int] DEFAULT (0) NOT NULL , - [notify_status] [int] DEFAULT (0) NOT NULL -) ON [PRIMARY] -GO - -CREATE INDEX [topic_id] ON [phpbb_topics_watch]([topic_id]) ON [PRIMARY] -GO - -CREATE INDEX [user_id] ON [phpbb_topics_watch]([user_id]) ON [PRIMARY] -GO - -CREATE INDEX [notify_stat] ON [phpbb_topics_watch]([notify_status]) ON [PRIMARY] -GO - - -/* - Table: 'phpbb_user_group' -*/ -CREATE TABLE [phpbb_user_group] ( - [group_id] [int] DEFAULT (0) NOT NULL , - [user_id] [int] DEFAULT (0) NOT NULL , - [group_leader] [int] DEFAULT (0) NOT NULL , - [user_pending] [int] DEFAULT (1) NOT NULL -) ON [PRIMARY] -GO - -CREATE INDEX [group_id] ON [phpbb_user_group]([group_id]) ON [PRIMARY] -GO - -CREATE INDEX [user_id] ON [phpbb_user_group]([user_id]) ON [PRIMARY] -GO - -CREATE INDEX [group_leader] ON [phpbb_user_group]([group_leader]) ON [PRIMARY] -GO - - -/* - Table: 'phpbb_users' -*/ -CREATE TABLE [phpbb_users] ( - [user_id] [int] IDENTITY (1, 1) NOT NULL , - [user_type] [int] DEFAULT (0) NOT NULL , - [group_id] [int] DEFAULT (3) NOT NULL , - [user_permissions] [text] DEFAULT ('') NOT NULL , - [user_perm_from] [int] DEFAULT (0) NOT NULL , - [user_ip] [varchar] (40) DEFAULT ('') NOT NULL , - [user_regdate] [int] DEFAULT (0) NOT NULL , - [username] [varchar] (255) DEFAULT ('') NOT NULL , - [username_clean] [varchar] (255) DEFAULT ('') NOT NULL , - [user_password] [varchar] (40) DEFAULT ('') NOT NULL , - [user_passchg] [int] DEFAULT (0) NOT NULL , - [user_pass_convert] [int] DEFAULT (0) NOT NULL , - [user_email] [varchar] (100) DEFAULT ('') NOT NULL , - [user_email_hash] [float] DEFAULT (0) NOT NULL , - [user_birthday] [varchar] (10) DEFAULT ('') NOT NULL , - [user_lastvisit] [int] DEFAULT (0) NOT NULL , - [user_lastmark] [int] DEFAULT (0) NOT NULL , - [user_lastpost_time] [int] DEFAULT (0) NOT NULL , - [user_lastpage] [varchar] (200) DEFAULT ('') NOT NULL , - [user_last_confirm_key] [varchar] (10) DEFAULT ('') NOT NULL , - [user_last_search] [int] DEFAULT (0) NOT NULL , - [user_warnings] [int] DEFAULT (0) NOT NULL , - [user_last_warning] [int] DEFAULT (0) NOT NULL , - [user_login_attempts] [int] DEFAULT (0) NOT NULL , - [user_inactive_reason] [int] DEFAULT (0) NOT NULL , - [user_inactive_time] [int] DEFAULT (0) NOT NULL , - [user_posts] [int] DEFAULT (0) NOT NULL , - [user_lang] [varchar] (30) DEFAULT ('') NOT NULL , - [user_timezone] [varchar] (100) DEFAULT ('UTC') NOT NULL , - [user_dateformat] [varchar] (30) DEFAULT ('d M Y H:i') NOT NULL , - [user_style] [int] DEFAULT (0) NOT NULL , - [user_rank] [int] DEFAULT (0) NOT NULL , - [user_colour] [varchar] (6) DEFAULT ('') NOT NULL , - [user_new_privmsg] [int] DEFAULT (0) NOT NULL , - [user_unread_privmsg] [int] DEFAULT (0) NOT NULL , - [user_last_privmsg] [int] DEFAULT (0) NOT NULL , - [user_message_rules] [int] DEFAULT (0) NOT NULL , - [user_full_folder] [int] DEFAULT (-3) NOT NULL , - [user_emailtime] [int] DEFAULT (0) NOT NULL , - [user_topic_show_days] [int] DEFAULT (0) NOT NULL , - [user_topic_sortby_type] [varchar] (1) DEFAULT ('t') NOT NULL , - [user_topic_sortby_dir] [varchar] (1) DEFAULT ('d') NOT NULL , - [user_post_show_days] [int] DEFAULT (0) NOT NULL , - [user_post_sortby_type] [varchar] (1) DEFAULT ('t') NOT NULL , - [user_post_sortby_dir] [varchar] (1) DEFAULT ('a') NOT NULL , - [user_notify] [int] DEFAULT (0) NOT NULL , - [user_notify_pm] [int] DEFAULT (1) NOT NULL , - [user_notify_type] [int] DEFAULT (0) NOT NULL , - [user_allow_pm] [int] DEFAULT (1) NOT NULL , - [user_allow_viewonline] [int] DEFAULT (1) NOT NULL , - [user_allow_viewemail] [int] DEFAULT (1) NOT NULL , - [user_allow_massemail] [int] DEFAULT (1) NOT NULL , - [user_options] [int] DEFAULT (230271) NOT NULL , - [user_avatar] [varchar] (255) DEFAULT ('') NOT NULL , - [user_avatar_type] [int] DEFAULT (0) NOT NULL , - [user_avatar_width] [int] DEFAULT (0) NOT NULL , - [user_avatar_height] [int] DEFAULT (0) NOT NULL , - [user_sig] [text] DEFAULT ('') NOT NULL , - [user_sig_bbcode_uid] [varchar] (8) DEFAULT ('') NOT NULL , - [user_sig_bbcode_bitfield] [varchar] (255) DEFAULT ('') NOT NULL , - [user_from] [varchar] (100) DEFAULT ('') NOT NULL , - [user_icq] [varchar] (15) DEFAULT ('') NOT NULL , - [user_aim] [varchar] (255) DEFAULT ('') NOT NULL , - [user_yim] [varchar] (255) DEFAULT ('') NOT NULL , - [user_msnm] [varchar] (255) DEFAULT ('') NOT NULL , - [user_jabber] [varchar] (255) DEFAULT ('') NOT NULL , - [user_website] [varchar] (200) DEFAULT ('') NOT NULL , - [user_occ] [varchar] (4000) DEFAULT ('') NOT NULL , - [user_interests] [varchar] (4000) DEFAULT ('') NOT NULL , - [user_actkey] [varchar] (32) DEFAULT ('') NOT NULL , - [user_newpasswd] [varchar] (40) DEFAULT ('') NOT NULL , - [user_form_salt] [varchar] (32) DEFAULT ('') NOT NULL , - [user_new] [int] DEFAULT (1) NOT NULL , - [user_reminded] [int] DEFAULT (0) NOT NULL , - [user_reminded_time] [int] DEFAULT (0) NOT NULL -) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY] -GO - -ALTER TABLE [phpbb_users] WITH NOCHECK ADD - CONSTRAINT [PK_phpbb_users] PRIMARY KEY CLUSTERED - ( - [user_id] - ) ON [PRIMARY] -GO - -CREATE INDEX [user_birthday] ON [phpbb_users]([user_birthday]) ON [PRIMARY] -GO - -CREATE INDEX [user_email_hash] ON [phpbb_users]([user_email_hash]) ON [PRIMARY] -GO - -CREATE INDEX [user_type] ON [phpbb_users]([user_type]) ON [PRIMARY] -GO - -CREATE UNIQUE INDEX [username_clean] ON [phpbb_users]([username_clean]) ON [PRIMARY] -GO - - -/* - Table: 'phpbb_warnings' -*/ -CREATE TABLE [phpbb_warnings] ( - [warning_id] [int] IDENTITY (1, 1) NOT NULL , - [user_id] [int] DEFAULT (0) NOT NULL , - [post_id] [int] DEFAULT (0) NOT NULL , - [log_id] [int] DEFAULT (0) NOT NULL , - [warning_time] [int] DEFAULT (0) NOT NULL -) ON [PRIMARY] -GO - -ALTER TABLE [phpbb_warnings] WITH NOCHECK ADD - CONSTRAINT [PK_phpbb_warnings] PRIMARY KEY CLUSTERED - ( - [warning_id] - ) ON [PRIMARY] -GO - - -/* - Table: 'phpbb_words' -*/ -CREATE TABLE [phpbb_words] ( - [word_id] [int] IDENTITY (1, 1) NOT NULL , - [word] [varchar] (255) DEFAULT ('') NOT NULL , - [replacement] [varchar] (255) DEFAULT ('') NOT NULL -) ON [PRIMARY] -GO - -ALTER TABLE [phpbb_words] WITH NOCHECK ADD - CONSTRAINT [PK_phpbb_words] PRIMARY KEY CLUSTERED - ( - [word_id] - ) ON [PRIMARY] -GO - - -/* - Table: 'phpbb_zebra' -*/ -CREATE TABLE [phpbb_zebra] ( - [user_id] [int] DEFAULT (0) NOT NULL , - [zebra_id] [int] DEFAULT (0) NOT NULL , - [friend] [int] DEFAULT (0) NOT NULL , - [foe] [int] DEFAULT (0) NOT NULL -) ON [PRIMARY] -GO - -ALTER TABLE [phpbb_zebra] WITH NOCHECK ADD - CONSTRAINT [PK_phpbb_zebra] PRIMARY KEY CLUSTERED - ( - [user_id], - [zebra_id] - ) ON [PRIMARY] -GO - - +/* + * DO NOT EDIT THIS FILE, IT IS GENERATED + * + * To change the contents of this file, edit + * phpBB/develop/create_schema_files.php and + * run it. + */ + +/* + Table: 'phpbb_attachments' +*/ +CREATE TABLE [phpbb_attachments] ( + [attach_id] [int] IDENTITY (1, 1) NOT NULL , + [post_msg_id] [int] DEFAULT (0) NOT NULL , + [topic_id] [int] DEFAULT (0) NOT NULL , + [in_message] [int] DEFAULT (0) NOT NULL , + [poster_id] [int] DEFAULT (0) NOT NULL , + [is_orphan] [int] DEFAULT (1) NOT NULL , + [physical_filename] [varchar] (255) DEFAULT ('') NOT NULL , + [real_filename] [varchar] (255) DEFAULT ('') NOT NULL , + [download_count] [int] DEFAULT (0) NOT NULL , + [attach_comment] [varchar] (4000) DEFAULT ('') NOT NULL , + [extension] [varchar] (100) DEFAULT ('') NOT NULL , + [mimetype] [varchar] (100) DEFAULT ('') NOT NULL , + [filesize] [int] DEFAULT (0) NOT NULL , + [filetime] [int] DEFAULT (0) NOT NULL , + [thumbnail] [int] DEFAULT (0) NOT NULL +) ON [PRIMARY] +GO + +ALTER TABLE [phpbb_attachments] WITH NOCHECK ADD + CONSTRAINT [PK_phpbb_attachments] PRIMARY KEY CLUSTERED + ( + [attach_id] + ) ON [PRIMARY] +GO + +CREATE INDEX [filetime] ON [phpbb_attachments]([filetime]) ON [PRIMARY] +GO + +CREATE INDEX [post_msg_id] ON [phpbb_attachments]([post_msg_id]) ON [PRIMARY] +GO + +CREATE INDEX [topic_id] ON [phpbb_attachments]([topic_id]) ON [PRIMARY] +GO + +CREATE INDEX [poster_id] ON [phpbb_attachments]([poster_id]) ON [PRIMARY] +GO + +CREATE INDEX [is_orphan] ON [phpbb_attachments]([is_orphan]) ON [PRIMARY] +GO + + +/* + Table: 'phpbb_acl_groups' +*/ +CREATE TABLE [phpbb_acl_groups] ( + [group_id] [int] DEFAULT (0) NOT NULL , + [forum_id] [int] DEFAULT (0) NOT NULL , + [auth_option_id] [int] DEFAULT (0) NOT NULL , + [auth_role_id] [int] DEFAULT (0) NOT NULL , + [auth_setting] [int] DEFAULT (0) NOT NULL +) ON [PRIMARY] +GO + +CREATE INDEX [group_id] ON [phpbb_acl_groups]([group_id]) ON [PRIMARY] +GO + +CREATE INDEX [auth_opt_id] ON [phpbb_acl_groups]([auth_option_id]) ON [PRIMARY] +GO + +CREATE INDEX [auth_role_id] ON [phpbb_acl_groups]([auth_role_id]) ON [PRIMARY] +GO + + +/* + Table: 'phpbb_acl_options' +*/ +CREATE TABLE [phpbb_acl_options] ( + [auth_option_id] [int] IDENTITY (1, 1) NOT NULL , + [auth_option] [varchar] (50) DEFAULT ('') NOT NULL , + [is_global] [int] DEFAULT (0) NOT NULL , + [is_local] [int] DEFAULT (0) NOT NULL , + [founder_only] [int] DEFAULT (0) NOT NULL +) ON [PRIMARY] +GO + +ALTER TABLE [phpbb_acl_options] WITH NOCHECK ADD + CONSTRAINT [PK_phpbb_acl_options] PRIMARY KEY CLUSTERED + ( + [auth_option_id] + ) ON [PRIMARY] +GO + +CREATE UNIQUE INDEX [auth_option] ON [phpbb_acl_options]([auth_option]) ON [PRIMARY] +GO + + +/* + Table: 'phpbb_acl_roles' +*/ +CREATE TABLE [phpbb_acl_roles] ( + [role_id] [int] IDENTITY (1, 1) NOT NULL , + [role_name] [varchar] (255) DEFAULT ('') NOT NULL , + [role_description] [varchar] (4000) DEFAULT ('') NOT NULL , + [role_type] [varchar] (10) DEFAULT ('') NOT NULL , + [role_order] [int] DEFAULT (0) NOT NULL +) ON [PRIMARY] +GO + +ALTER TABLE [phpbb_acl_roles] WITH NOCHECK ADD + CONSTRAINT [PK_phpbb_acl_roles] PRIMARY KEY CLUSTERED + ( + [role_id] + ) ON [PRIMARY] +GO + +CREATE INDEX [role_type] ON [phpbb_acl_roles]([role_type]) ON [PRIMARY] +GO + +CREATE INDEX [role_order] ON [phpbb_acl_roles]([role_order]) ON [PRIMARY] +GO + + +/* + Table: 'phpbb_acl_roles_data' +*/ +CREATE TABLE [phpbb_acl_roles_data] ( + [role_id] [int] DEFAULT (0) NOT NULL , + [auth_option_id] [int] DEFAULT (0) NOT NULL , + [auth_setting] [int] DEFAULT (0) NOT NULL +) ON [PRIMARY] +GO + +ALTER TABLE [phpbb_acl_roles_data] WITH NOCHECK ADD + CONSTRAINT [PK_phpbb_acl_roles_data] PRIMARY KEY CLUSTERED + ( + [role_id], + [auth_option_id] + ) ON [PRIMARY] +GO + +CREATE INDEX [ath_op_id] ON [phpbb_acl_roles_data]([auth_option_id]) ON [PRIMARY] +GO + + +/* + Table: 'phpbb_acl_users' +*/ +CREATE TABLE [phpbb_acl_users] ( + [user_id] [int] DEFAULT (0) NOT NULL , + [forum_id] [int] DEFAULT (0) NOT NULL , + [auth_option_id] [int] DEFAULT (0) NOT NULL , + [auth_role_id] [int] DEFAULT (0) NOT NULL , + [auth_setting] [int] DEFAULT (0) NOT NULL +) ON [PRIMARY] +GO + +CREATE INDEX [user_id] ON [phpbb_acl_users]([user_id]) ON [PRIMARY] +GO + +CREATE INDEX [auth_option_id] ON [phpbb_acl_users]([auth_option_id]) ON [PRIMARY] +GO + +CREATE INDEX [auth_role_id] ON [phpbb_acl_users]([auth_role_id]) ON [PRIMARY] +GO + + +/* + Table: 'phpbb_banlist' +*/ +CREATE TABLE [phpbb_banlist] ( + [ban_id] [int] IDENTITY (1, 1) NOT NULL , + [ban_userid] [int] DEFAULT (0) NOT NULL , + [ban_ip] [varchar] (40) DEFAULT ('') NOT NULL , + [ban_email] [varchar] (100) DEFAULT ('') NOT NULL , + [ban_start] [int] DEFAULT (0) NOT NULL , + [ban_end] [int] DEFAULT (0) NOT NULL , + [ban_exclude] [int] DEFAULT (0) NOT NULL , + [ban_reason] [varchar] (255) DEFAULT ('') NOT NULL , + [ban_give_reason] [varchar] (255) DEFAULT ('') NOT NULL +) ON [PRIMARY] +GO + +ALTER TABLE [phpbb_banlist] WITH NOCHECK ADD + CONSTRAINT [PK_phpbb_banlist] PRIMARY KEY CLUSTERED + ( + [ban_id] + ) ON [PRIMARY] +GO + +CREATE INDEX [ban_end] ON [phpbb_banlist]([ban_end]) ON [PRIMARY] +GO + +CREATE INDEX [ban_user] ON [phpbb_banlist]([ban_userid], [ban_exclude]) ON [PRIMARY] +GO + +CREATE INDEX [ban_email] ON [phpbb_banlist]([ban_email], [ban_exclude]) ON [PRIMARY] +GO + +CREATE INDEX [ban_ip] ON [phpbb_banlist]([ban_ip], [ban_exclude]) ON [PRIMARY] +GO + + +/* + Table: 'phpbb_bbcodes' +*/ +CREATE TABLE [phpbb_bbcodes] ( + [bbcode_id] [int] DEFAULT (0) NOT NULL , + [bbcode_tag] [varchar] (16) DEFAULT ('') NOT NULL , + [bbcode_helpline] [varchar] (255) DEFAULT ('') NOT NULL , + [display_on_posting] [int] DEFAULT (0) NOT NULL , + [bbcode_match] [varchar] (4000) DEFAULT ('') NOT NULL , + [bbcode_tpl] [text] DEFAULT ('') NOT NULL , + [first_pass_match] [text] DEFAULT ('') NOT NULL , + [first_pass_replace] [text] DEFAULT ('') NOT NULL , + [second_pass_match] [text] DEFAULT ('') NOT NULL , + [second_pass_replace] [text] DEFAULT ('') NOT NULL +) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY] +GO + +ALTER TABLE [phpbb_bbcodes] WITH NOCHECK ADD + CONSTRAINT [PK_phpbb_bbcodes] PRIMARY KEY CLUSTERED + ( + [bbcode_id] + ) ON [PRIMARY] +GO + +CREATE INDEX [display_on_post] ON [phpbb_bbcodes]([display_on_posting]) ON [PRIMARY] +GO + + +/* + Table: 'phpbb_bookmarks' +*/ +CREATE TABLE [phpbb_bookmarks] ( + [topic_id] [int] DEFAULT (0) NOT NULL , + [user_id] [int] DEFAULT (0) NOT NULL +) ON [PRIMARY] +GO + +ALTER TABLE [phpbb_bookmarks] WITH NOCHECK ADD + CONSTRAINT [PK_phpbb_bookmarks] PRIMARY KEY CLUSTERED + ( + [topic_id], + [user_id] + ) ON [PRIMARY] +GO + + +/* + Table: 'phpbb_bots' +*/ +CREATE TABLE [phpbb_bots] ( + [bot_id] [int] IDENTITY (1, 1) NOT NULL , + [bot_active] [int] DEFAULT (1) NOT NULL , + [bot_name] [varchar] (255) DEFAULT ('') NOT NULL , + [user_id] [int] DEFAULT (0) NOT NULL , + [bot_agent] [varchar] (255) DEFAULT ('') NOT NULL , + [bot_ip] [varchar] (255) DEFAULT ('') NOT NULL +) ON [PRIMARY] +GO + +ALTER TABLE [phpbb_bots] WITH NOCHECK ADD + CONSTRAINT [PK_phpbb_bots] PRIMARY KEY CLUSTERED + ( + [bot_id] + ) ON [PRIMARY] +GO + +CREATE INDEX [bot_active] ON [phpbb_bots]([bot_active]) ON [PRIMARY] +GO + + +/* + Table: 'phpbb_config' +*/ +CREATE TABLE [phpbb_config] ( + [config_name] [varchar] (255) DEFAULT ('') NOT NULL , + [config_value] [varchar] (255) DEFAULT ('') NOT NULL , + [is_dynamic] [int] DEFAULT (0) NOT NULL +) ON [PRIMARY] +GO + +ALTER TABLE [phpbb_config] WITH NOCHECK ADD + CONSTRAINT [PK_phpbb_config] PRIMARY KEY CLUSTERED + ( + [config_name] + ) ON [PRIMARY] +GO + +CREATE INDEX [is_dynamic] ON [phpbb_config]([is_dynamic]) ON [PRIMARY] +GO + + +/* + Table: 'phpbb_confirm' +*/ +CREATE TABLE [phpbb_confirm] ( + [confirm_id] [char] (32) DEFAULT ('') NOT NULL , + [session_id] [char] (32) DEFAULT ('') NOT NULL , + [confirm_type] [int] DEFAULT (0) NOT NULL , + [code] [varchar] (8) DEFAULT ('') NOT NULL , + [seed] [int] DEFAULT (0) NOT NULL , + [attempts] [int] DEFAULT (0) NOT NULL +) ON [PRIMARY] +GO + +ALTER TABLE [phpbb_confirm] WITH NOCHECK ADD + CONSTRAINT [PK_phpbb_confirm] PRIMARY KEY CLUSTERED + ( + [session_id], + [confirm_id] + ) ON [PRIMARY] +GO + +CREATE INDEX [confirm_type] ON [phpbb_confirm]([confirm_type]) ON [PRIMARY] +GO + + +/* + Table: 'phpbb_disallow' +*/ +CREATE TABLE [phpbb_disallow] ( + [disallow_id] [int] IDENTITY (1, 1) NOT NULL , + [disallow_username] [varchar] (255) DEFAULT ('') NOT NULL +) ON [PRIMARY] +GO + +ALTER TABLE [phpbb_disallow] WITH NOCHECK ADD + CONSTRAINT [PK_phpbb_disallow] PRIMARY KEY CLUSTERED + ( + [disallow_id] + ) ON [PRIMARY] +GO + + +/* + Table: 'phpbb_drafts' +*/ +CREATE TABLE [phpbb_drafts] ( + [draft_id] [int] IDENTITY (1, 1) NOT NULL , + [user_id] [int] DEFAULT (0) NOT NULL , + [topic_id] [int] DEFAULT (0) NOT NULL , + [forum_id] [int] DEFAULT (0) NOT NULL , + [save_time] [int] DEFAULT (0) NOT NULL , + [draft_subject] [varchar] (255) DEFAULT ('') NOT NULL , + [draft_message] [text] DEFAULT ('') NOT NULL +) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY] +GO + +ALTER TABLE [phpbb_drafts] WITH NOCHECK ADD + CONSTRAINT [PK_phpbb_drafts] PRIMARY KEY CLUSTERED + ( + [draft_id] + ) ON [PRIMARY] +GO + +CREATE INDEX [save_time] ON [phpbb_drafts]([save_time]) ON [PRIMARY] +GO + + +/* + Table: 'phpbb_ext' +*/ +CREATE TABLE [phpbb_ext] ( + [ext_name] [varchar] (255) DEFAULT ('') NOT NULL , + [ext_active] [int] DEFAULT (0) NOT NULL , + [ext_state] [varchar] (8000) DEFAULT ('') NOT NULL +) ON [PRIMARY] +GO + +CREATE UNIQUE INDEX [ext_name] ON [phpbb_ext]([ext_name]) ON [PRIMARY] +GO + + +/* + Table: 'phpbb_extensions' +*/ +CREATE TABLE [phpbb_extensions] ( + [extension_id] [int] IDENTITY (1, 1) NOT NULL , + [group_id] [int] DEFAULT (0) NOT NULL , + [extension] [varchar] (100) DEFAULT ('') NOT NULL +) ON [PRIMARY] +GO + +ALTER TABLE [phpbb_extensions] WITH NOCHECK ADD + CONSTRAINT [PK_phpbb_extensions] PRIMARY KEY CLUSTERED + ( + [extension_id] + ) ON [PRIMARY] +GO + + +/* + Table: 'phpbb_extension_groups' +*/ +CREATE TABLE [phpbb_extension_groups] ( + [group_id] [int] IDENTITY (1, 1) NOT NULL , + [group_name] [varchar] (255) DEFAULT ('') NOT NULL , + [cat_id] [int] DEFAULT (0) NOT NULL , + [allow_group] [int] DEFAULT (0) NOT NULL , + [download_mode] [int] DEFAULT (1) NOT NULL , + [upload_icon] [varchar] (255) DEFAULT ('') NOT NULL , + [max_filesize] [int] DEFAULT (0) NOT NULL , + [allowed_forums] [varchar] (8000) DEFAULT ('') NOT NULL , + [allow_in_pm] [int] DEFAULT (0) NOT NULL +) ON [PRIMARY] +GO + +ALTER TABLE [phpbb_extension_groups] WITH NOCHECK ADD + CONSTRAINT [PK_phpbb_extension_groups] PRIMARY KEY CLUSTERED + ( + [group_id] + ) ON [PRIMARY] +GO + + +/* + Table: 'phpbb_forums' +*/ +CREATE TABLE [phpbb_forums] ( + [forum_id] [int] IDENTITY (1, 1) NOT NULL , + [parent_id] [int] DEFAULT (0) NOT NULL , + [left_id] [int] DEFAULT (0) NOT NULL , + [right_id] [int] DEFAULT (0) NOT NULL , + [forum_parents] [text] DEFAULT ('') NOT NULL , + [forum_name] [varchar] (255) DEFAULT ('') NOT NULL , + [forum_desc] [varchar] (4000) DEFAULT ('') NOT NULL , + [forum_desc_bitfield] [varchar] (255) DEFAULT ('') NOT NULL , + [forum_desc_options] [int] DEFAULT (7) NOT NULL , + [forum_desc_uid] [varchar] (8) DEFAULT ('') NOT NULL , + [forum_link] [varchar] (255) DEFAULT ('') NOT NULL , + [forum_password] [varchar] (40) DEFAULT ('') NOT NULL , + [forum_style] [int] DEFAULT (0) NOT NULL , + [forum_image] [varchar] (255) DEFAULT ('') NOT NULL , + [forum_rules] [varchar] (4000) DEFAULT ('') NOT NULL , + [forum_rules_link] [varchar] (255) DEFAULT ('') NOT NULL , + [forum_rules_bitfield] [varchar] (255) DEFAULT ('') NOT NULL , + [forum_rules_options] [int] DEFAULT (7) NOT NULL , + [forum_rules_uid] [varchar] (8) DEFAULT ('') NOT NULL , + [forum_topics_per_page] [int] DEFAULT (0) NOT NULL , + [forum_type] [int] DEFAULT (0) NOT NULL , + [forum_status] [int] DEFAULT (0) NOT NULL , + [forum_posts] [int] DEFAULT (0) NOT NULL , + [forum_topics] [int] DEFAULT (0) NOT NULL , + [forum_topics_real] [int] DEFAULT (0) NOT NULL , + [forum_last_post_id] [int] DEFAULT (0) NOT NULL , + [forum_last_poster_id] [int] DEFAULT (0) NOT NULL , + [forum_last_post_subject] [varchar] (255) DEFAULT ('') NOT NULL , + [forum_last_post_time] [int] DEFAULT (0) NOT NULL , + [forum_last_poster_name] [varchar] (255) DEFAULT ('') NOT NULL , + [forum_last_poster_colour] [varchar] (6) DEFAULT ('') NOT NULL , + [forum_flags] [int] DEFAULT (32) NOT NULL , + [forum_options] [int] DEFAULT (0) NOT NULL , + [display_subforum_list] [int] DEFAULT (1) NOT NULL , + [display_on_index] [int] DEFAULT (1) NOT NULL , + [enable_indexing] [int] DEFAULT (1) NOT NULL , + [enable_icons] [int] DEFAULT (1) NOT NULL , + [enable_prune] [int] DEFAULT (0) NOT NULL , + [prune_next] [int] DEFAULT (0) NOT NULL , + [prune_days] [int] DEFAULT (0) NOT NULL , + [prune_viewed] [int] DEFAULT (0) NOT NULL , + [prune_freq] [int] DEFAULT (0) NOT NULL +) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY] +GO + +ALTER TABLE [phpbb_forums] WITH NOCHECK ADD + CONSTRAINT [PK_phpbb_forums] PRIMARY KEY CLUSTERED + ( + [forum_id] + ) ON [PRIMARY] +GO + +CREATE INDEX [left_right_id] ON [phpbb_forums]([left_id], [right_id]) ON [PRIMARY] +GO + +CREATE INDEX [forum_lastpost_id] ON [phpbb_forums]([forum_last_post_id]) ON [PRIMARY] +GO + + +/* + Table: 'phpbb_forums_access' +*/ +CREATE TABLE [phpbb_forums_access] ( + [forum_id] [int] DEFAULT (0) NOT NULL , + [user_id] [int] DEFAULT (0) NOT NULL , + [session_id] [char] (32) DEFAULT ('') NOT NULL +) ON [PRIMARY] +GO + +ALTER TABLE [phpbb_forums_access] WITH NOCHECK ADD + CONSTRAINT [PK_phpbb_forums_access] PRIMARY KEY CLUSTERED + ( + [forum_id], + [user_id], + [session_id] + ) ON [PRIMARY] +GO + + +/* + Table: 'phpbb_forums_track' +*/ +CREATE TABLE [phpbb_forums_track] ( + [user_id] [int] DEFAULT (0) NOT NULL , + [forum_id] [int] DEFAULT (0) NOT NULL , + [mark_time] [int] DEFAULT (0) NOT NULL +) ON [PRIMARY] +GO + +ALTER TABLE [phpbb_forums_track] WITH NOCHECK ADD + CONSTRAINT [PK_phpbb_forums_track] PRIMARY KEY CLUSTERED + ( + [user_id], + [forum_id] + ) ON [PRIMARY] +GO + + +/* + Table: 'phpbb_forums_watch' +*/ +CREATE TABLE [phpbb_forums_watch] ( + [forum_id] [int] DEFAULT (0) NOT NULL , + [user_id] [int] DEFAULT (0) NOT NULL , + [notify_status] [int] DEFAULT (0) NOT NULL +) ON [PRIMARY] +GO + +CREATE INDEX [forum_id] ON [phpbb_forums_watch]([forum_id]) ON [PRIMARY] +GO + +CREATE INDEX [user_id] ON [phpbb_forums_watch]([user_id]) ON [PRIMARY] +GO + +CREATE INDEX [notify_stat] ON [phpbb_forums_watch]([notify_status]) ON [PRIMARY] +GO + + +/* + Table: 'phpbb_groups' +*/ +CREATE TABLE [phpbb_groups] ( + [group_id] [int] IDENTITY (1, 1) NOT NULL , + [group_type] [int] DEFAULT (1) NOT NULL , + [group_founder_manage] [int] DEFAULT (0) NOT NULL , + [group_skip_auth] [int] DEFAULT (0) NOT NULL , + [group_name] [varchar] (255) DEFAULT ('') NOT NULL , + [group_desc] [varchar] (4000) DEFAULT ('') NOT NULL , + [group_desc_bitfield] [varchar] (255) DEFAULT ('') NOT NULL , + [group_desc_options] [int] DEFAULT (7) NOT NULL , + [group_desc_uid] [varchar] (8) DEFAULT ('') NOT NULL , + [group_display] [int] DEFAULT (0) NOT NULL , + [group_avatar] [varchar] (255) DEFAULT ('') NOT NULL , + [group_avatar_type] [int] DEFAULT (0) NOT NULL , + [group_avatar_width] [int] DEFAULT (0) NOT NULL , + [group_avatar_height] [int] DEFAULT (0) NOT NULL , + [group_rank] [int] DEFAULT (0) NOT NULL , + [group_colour] [varchar] (6) DEFAULT ('') NOT NULL , + [group_sig_chars] [int] DEFAULT (0) NOT NULL , + [group_receive_pm] [int] DEFAULT (0) NOT NULL , + [group_message_limit] [int] DEFAULT (0) NOT NULL , + [group_max_recipients] [int] DEFAULT (0) NOT NULL , + [group_legend] [int] DEFAULT (0) NOT NULL , + [group_teampage] [int] DEFAULT (0) NOT NULL +) ON [PRIMARY] +GO + +ALTER TABLE [phpbb_groups] WITH NOCHECK ADD + CONSTRAINT [PK_phpbb_groups] PRIMARY KEY CLUSTERED + ( + [group_id] + ) ON [PRIMARY] +GO + +CREATE INDEX [group_legend_name] ON [phpbb_groups]([group_legend], [group_name]) ON [PRIMARY] +GO + + +/* + Table: 'phpbb_icons' +*/ +CREATE TABLE [phpbb_icons] ( + [icons_id] [int] IDENTITY (1, 1) NOT NULL , + [icons_url] [varchar] (255) DEFAULT ('') NOT NULL , + [icons_width] [int] DEFAULT (0) NOT NULL , + [icons_height] [int] DEFAULT (0) NOT NULL , + [icons_order] [int] DEFAULT (0) NOT NULL , + [display_on_posting] [int] DEFAULT (1) NOT NULL +) ON [PRIMARY] +GO + +ALTER TABLE [phpbb_icons] WITH NOCHECK ADD + CONSTRAINT [PK_phpbb_icons] PRIMARY KEY CLUSTERED + ( + [icons_id] + ) ON [PRIMARY] +GO + +CREATE INDEX [display_on_posting] ON [phpbb_icons]([display_on_posting]) ON [PRIMARY] +GO + + +/* + Table: 'phpbb_lang' +*/ +CREATE TABLE [phpbb_lang] ( + [lang_id] [int] IDENTITY (1, 1) NOT NULL , + [lang_iso] [varchar] (30) DEFAULT ('') NOT NULL , + [lang_dir] [varchar] (30) DEFAULT ('') NOT NULL , + [lang_english_name] [varchar] (100) DEFAULT ('') NOT NULL , + [lang_local_name] [varchar] (255) DEFAULT ('') NOT NULL , + [lang_author] [varchar] (255) DEFAULT ('') NOT NULL +) ON [PRIMARY] +GO + +ALTER TABLE [phpbb_lang] WITH NOCHECK ADD + CONSTRAINT [PK_phpbb_lang] PRIMARY KEY CLUSTERED + ( + [lang_id] + ) ON [PRIMARY] +GO + +CREATE INDEX [lang_iso] ON [phpbb_lang]([lang_iso]) ON [PRIMARY] +GO + + +/* + Table: 'phpbb_log' +*/ +CREATE TABLE [phpbb_log] ( + [log_id] [int] IDENTITY (1, 1) NOT NULL , + [log_type] [int] DEFAULT (0) NOT NULL , + [user_id] [int] DEFAULT (0) NOT NULL , + [forum_id] [int] DEFAULT (0) NOT NULL , + [topic_id] [int] DEFAULT (0) NOT NULL , + [reportee_id] [int] DEFAULT (0) NOT NULL , + [log_ip] [varchar] (40) DEFAULT ('') NOT NULL , + [log_time] [int] DEFAULT (0) NOT NULL , + [log_operation] [varchar] (4000) DEFAULT ('') NOT NULL , + [log_data] [text] DEFAULT ('') NOT NULL +) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY] +GO + +ALTER TABLE [phpbb_log] WITH NOCHECK ADD + CONSTRAINT [PK_phpbb_log] PRIMARY KEY CLUSTERED + ( + [log_id] + ) ON [PRIMARY] +GO + +CREATE INDEX [log_type] ON [phpbb_log]([log_type]) ON [PRIMARY] +GO + +CREATE INDEX [log_time] ON [phpbb_log]([log_time]) ON [PRIMARY] +GO + +CREATE INDEX [forum_id] ON [phpbb_log]([forum_id]) ON [PRIMARY] +GO + +CREATE INDEX [topic_id] ON [phpbb_log]([topic_id]) ON [PRIMARY] +GO + +CREATE INDEX [reportee_id] ON [phpbb_log]([reportee_id]) ON [PRIMARY] +GO + +CREATE INDEX [user_id] ON [phpbb_log]([user_id]) ON [PRIMARY] +GO + + +/* + Table: 'phpbb_login_attempts' +*/ +CREATE TABLE [phpbb_login_attempts] ( + [attempt_ip] [varchar] (40) DEFAULT ('') NOT NULL , + [attempt_browser] [varchar] (150) DEFAULT ('') NOT NULL , + [attempt_forwarded_for] [varchar] (255) DEFAULT ('') NOT NULL , + [attempt_time] [int] DEFAULT (0) NOT NULL , + [user_id] [int] DEFAULT (0) NOT NULL , + [username] [varchar] (255) DEFAULT (0) NOT NULL , + [username_clean] [varchar] (255) DEFAULT (0) NOT NULL +) ON [PRIMARY] +GO + +CREATE INDEX [att_ip] ON [phpbb_login_attempts]([attempt_ip], [attempt_time]) ON [PRIMARY] +GO + +CREATE INDEX [att_for] ON [phpbb_login_attempts]([attempt_forwarded_for], [attempt_time]) ON [PRIMARY] +GO + +CREATE INDEX [att_time] ON [phpbb_login_attempts]([attempt_time]) ON [PRIMARY] +GO + +CREATE INDEX [user_id] ON [phpbb_login_attempts]([user_id]) ON [PRIMARY] +GO + + +/* + Table: 'phpbb_moderator_cache' +*/ +CREATE TABLE [phpbb_moderator_cache] ( + [forum_id] [int] DEFAULT (0) NOT NULL , + [user_id] [int] DEFAULT (0) NOT NULL , + [username] [varchar] (255) DEFAULT ('') NOT NULL , + [group_id] [int] DEFAULT (0) NOT NULL , + [group_name] [varchar] (255) DEFAULT ('') NOT NULL , + [display_on_index] [int] DEFAULT (1) NOT NULL +) ON [PRIMARY] +GO + +CREATE INDEX [disp_idx] ON [phpbb_moderator_cache]([display_on_index]) ON [PRIMARY] +GO + +CREATE INDEX [forum_id] ON [phpbb_moderator_cache]([forum_id]) ON [PRIMARY] +GO + + +/* + Table: 'phpbb_modules' +*/ +CREATE TABLE [phpbb_modules] ( + [module_id] [int] IDENTITY (1, 1) NOT NULL , + [module_enabled] [int] DEFAULT (1) NOT NULL , + [module_display] [int] DEFAULT (1) NOT NULL , + [module_basename] [varchar] (255) DEFAULT ('') NOT NULL , + [module_class] [varchar] (10) DEFAULT ('') NOT NULL , + [parent_id] [int] DEFAULT (0) NOT NULL , + [left_id] [int] DEFAULT (0) NOT NULL , + [right_id] [int] DEFAULT (0) NOT NULL , + [module_langname] [varchar] (255) DEFAULT ('') NOT NULL , + [module_mode] [varchar] (255) DEFAULT ('') NOT NULL , + [module_auth] [varchar] (255) DEFAULT ('') NOT NULL +) ON [PRIMARY] +GO + +ALTER TABLE [phpbb_modules] WITH NOCHECK ADD + CONSTRAINT [PK_phpbb_modules] PRIMARY KEY CLUSTERED + ( + [module_id] + ) ON [PRIMARY] +GO + +CREATE INDEX [left_right_id] ON [phpbb_modules]([left_id], [right_id]) ON [PRIMARY] +GO + +CREATE INDEX [module_enabled] ON [phpbb_modules]([module_enabled]) ON [PRIMARY] +GO + +CREATE INDEX [class_left_id] ON [phpbb_modules]([module_class], [left_id]) ON [PRIMARY] +GO + + +/* + Table: 'phpbb_poll_options' +*/ +CREATE TABLE [phpbb_poll_options] ( + [poll_option_id] [int] DEFAULT (0) NOT NULL , + [topic_id] [int] DEFAULT (0) NOT NULL , + [poll_option_text] [varchar] (4000) DEFAULT ('') NOT NULL , + [poll_option_total] [int] DEFAULT (0) NOT NULL +) ON [PRIMARY] +GO + +CREATE INDEX [poll_opt_id] ON [phpbb_poll_options]([poll_option_id]) ON [PRIMARY] +GO + +CREATE INDEX [topic_id] ON [phpbb_poll_options]([topic_id]) ON [PRIMARY] +GO + + +/* + Table: 'phpbb_poll_votes' +*/ +CREATE TABLE [phpbb_poll_votes] ( + [topic_id] [int] DEFAULT (0) NOT NULL , + [poll_option_id] [int] DEFAULT (0) NOT NULL , + [vote_user_id] [int] DEFAULT (0) NOT NULL , + [vote_user_ip] [varchar] (40) DEFAULT ('') NOT NULL +) ON [PRIMARY] +GO + +CREATE INDEX [topic_id] ON [phpbb_poll_votes]([topic_id]) ON [PRIMARY] +GO + +CREATE INDEX [vote_user_id] ON [phpbb_poll_votes]([vote_user_id]) ON [PRIMARY] +GO + +CREATE INDEX [vote_user_ip] ON [phpbb_poll_votes]([vote_user_ip]) ON [PRIMARY] +GO + + +/* + Table: 'phpbb_posts' +*/ +CREATE TABLE [phpbb_posts] ( + [post_id] [int] IDENTITY (1, 1) NOT NULL , + [topic_id] [int] DEFAULT (0) NOT NULL , + [forum_id] [int] DEFAULT (0) NOT NULL , + [poster_id] [int] DEFAULT (0) NOT NULL , + [icon_id] [int] DEFAULT (0) NOT NULL , + [poster_ip] [varchar] (40) DEFAULT ('') NOT NULL , + [post_time] [int] DEFAULT (0) NOT NULL , + [post_approved] [int] DEFAULT (1) NOT NULL , + [post_reported] [int] DEFAULT (0) NOT NULL , + [enable_bbcode] [int] DEFAULT (1) NOT NULL , + [enable_smilies] [int] DEFAULT (1) NOT NULL , + [enable_magic_url] [int] DEFAULT (1) NOT NULL , + [enable_sig] [int] DEFAULT (1) NOT NULL , + [post_username] [varchar] (255) DEFAULT ('') NOT NULL , + [post_subject] [varchar] (255) DEFAULT ('') NOT NULL , + [post_text] [text] DEFAULT ('') NOT NULL , + [post_checksum] [varchar] (32) DEFAULT ('') NOT NULL , + [post_attachment] [int] DEFAULT (0) NOT NULL , + [bbcode_bitfield] [varchar] (255) DEFAULT ('') NOT NULL , + [bbcode_uid] [varchar] (8) DEFAULT ('') NOT NULL , + [post_postcount] [int] DEFAULT (1) NOT NULL , + [post_edit_time] [int] DEFAULT (0) NOT NULL , + [post_edit_reason] [varchar] (255) DEFAULT ('') NOT NULL , + [post_edit_user] [int] DEFAULT (0) NOT NULL , + [post_edit_count] [int] DEFAULT (0) NOT NULL , + [post_edit_locked] [int] DEFAULT (0) NOT NULL +) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY] +GO + +ALTER TABLE [phpbb_posts] WITH NOCHECK ADD + CONSTRAINT [PK_phpbb_posts] PRIMARY KEY CLUSTERED + ( + [post_id] + ) ON [PRIMARY] +GO + +CREATE INDEX [forum_id] ON [phpbb_posts]([forum_id]) ON [PRIMARY] +GO + +CREATE INDEX [topic_id] ON [phpbb_posts]([topic_id]) ON [PRIMARY] +GO + +CREATE INDEX [poster_ip] ON [phpbb_posts]([poster_ip]) ON [PRIMARY] +GO + +CREATE INDEX [poster_id] ON [phpbb_posts]([poster_id]) ON [PRIMARY] +GO + +CREATE INDEX [post_approved] ON [phpbb_posts]([post_approved]) ON [PRIMARY] +GO + +CREATE INDEX [post_username] ON [phpbb_posts]([post_username]) ON [PRIMARY] +GO + +CREATE INDEX [tid_post_time] ON [phpbb_posts]([topic_id], [post_time]) ON [PRIMARY] +GO + + +/* + Table: 'phpbb_privmsgs' +*/ +CREATE TABLE [phpbb_privmsgs] ( + [msg_id] [int] IDENTITY (1, 1) NOT NULL , + [root_level] [int] DEFAULT (0) NOT NULL , + [author_id] [int] DEFAULT (0) NOT NULL , + [icon_id] [int] DEFAULT (0) NOT NULL , + [author_ip] [varchar] (40) DEFAULT ('') NOT NULL , + [message_time] [int] DEFAULT (0) NOT NULL , + [enable_bbcode] [int] DEFAULT (1) NOT NULL , + [enable_smilies] [int] DEFAULT (1) NOT NULL , + [enable_magic_url] [int] DEFAULT (1) NOT NULL , + [enable_sig] [int] DEFAULT (1) NOT NULL , + [message_subject] [varchar] (255) DEFAULT ('') NOT NULL , + [message_text] [text] DEFAULT ('') NOT NULL , + [message_edit_reason] [varchar] (255) DEFAULT ('') NOT NULL , + [message_edit_user] [int] DEFAULT (0) NOT NULL , + [message_attachment] [int] DEFAULT (0) NOT NULL , + [bbcode_bitfield] [varchar] (255) DEFAULT ('') NOT NULL , + [bbcode_uid] [varchar] (8) DEFAULT ('') NOT NULL , + [message_edit_time] [int] DEFAULT (0) NOT NULL , + [message_edit_count] [int] DEFAULT (0) NOT NULL , + [to_address] [varchar] (4000) DEFAULT ('') NOT NULL , + [bcc_address] [varchar] (4000) DEFAULT ('') NOT NULL , + [message_reported] [int] DEFAULT (0) NOT NULL +) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY] +GO + +ALTER TABLE [phpbb_privmsgs] WITH NOCHECK ADD + CONSTRAINT [PK_phpbb_privmsgs] PRIMARY KEY CLUSTERED + ( + [msg_id] + ) ON [PRIMARY] +GO + +CREATE INDEX [author_ip] ON [phpbb_privmsgs]([author_ip]) ON [PRIMARY] +GO + +CREATE INDEX [message_time] ON [phpbb_privmsgs]([message_time]) ON [PRIMARY] +GO + +CREATE INDEX [author_id] ON [phpbb_privmsgs]([author_id]) ON [PRIMARY] +GO + +CREATE INDEX [root_level] ON [phpbb_privmsgs]([root_level]) ON [PRIMARY] +GO + + +/* + Table: 'phpbb_privmsgs_folder' +*/ +CREATE TABLE [phpbb_privmsgs_folder] ( + [folder_id] [int] IDENTITY (1, 1) NOT NULL , + [user_id] [int] DEFAULT (0) NOT NULL , + [folder_name] [varchar] (255) DEFAULT ('') NOT NULL , + [pm_count] [int] DEFAULT (0) NOT NULL +) ON [PRIMARY] +GO + +ALTER TABLE [phpbb_privmsgs_folder] WITH NOCHECK ADD + CONSTRAINT [PK_phpbb_privmsgs_folder] PRIMARY KEY CLUSTERED + ( + [folder_id] + ) ON [PRIMARY] +GO + +CREATE INDEX [user_id] ON [phpbb_privmsgs_folder]([user_id]) ON [PRIMARY] +GO + + +/* + Table: 'phpbb_privmsgs_rules' +*/ +CREATE TABLE [phpbb_privmsgs_rules] ( + [rule_id] [int] IDENTITY (1, 1) NOT NULL , + [user_id] [int] DEFAULT (0) NOT NULL , + [rule_check] [int] DEFAULT (0) NOT NULL , + [rule_connection] [int] DEFAULT (0) NOT NULL , + [rule_string] [varchar] (255) DEFAULT ('') NOT NULL , + [rule_user_id] [int] DEFAULT (0) NOT NULL , + [rule_group_id] [int] DEFAULT (0) NOT NULL , + [rule_action] [int] DEFAULT (0) NOT NULL , + [rule_folder_id] [int] DEFAULT (0) NOT NULL +) ON [PRIMARY] +GO + +ALTER TABLE [phpbb_privmsgs_rules] WITH NOCHECK ADD + CONSTRAINT [PK_phpbb_privmsgs_rules] PRIMARY KEY CLUSTERED + ( + [rule_id] + ) ON [PRIMARY] +GO + +CREATE INDEX [user_id] ON [phpbb_privmsgs_rules]([user_id]) ON [PRIMARY] +GO + + +/* + Table: 'phpbb_privmsgs_to' +*/ +CREATE TABLE [phpbb_privmsgs_to] ( + [msg_id] [int] DEFAULT (0) NOT NULL , + [user_id] [int] DEFAULT (0) NOT NULL , + [author_id] [int] DEFAULT (0) NOT NULL , + [pm_deleted] [int] DEFAULT (0) NOT NULL , + [pm_new] [int] DEFAULT (1) NOT NULL , + [pm_unread] [int] DEFAULT (1) NOT NULL , + [pm_replied] [int] DEFAULT (0) NOT NULL , + [pm_marked] [int] DEFAULT (0) NOT NULL , + [pm_forwarded] [int] DEFAULT (0) NOT NULL , + [folder_id] [int] DEFAULT (0) NOT NULL +) ON [PRIMARY] +GO + +CREATE INDEX [msg_id] ON [phpbb_privmsgs_to]([msg_id]) ON [PRIMARY] +GO + +CREATE INDEX [author_id] ON [phpbb_privmsgs_to]([author_id]) ON [PRIMARY] +GO + +CREATE INDEX [usr_flder_id] ON [phpbb_privmsgs_to]([user_id], [folder_id]) ON [PRIMARY] +GO + + +/* + Table: 'phpbb_profile_fields' +*/ +CREATE TABLE [phpbb_profile_fields] ( + [field_id] [int] IDENTITY (1, 1) NOT NULL , + [field_name] [varchar] (255) DEFAULT ('') NOT NULL , + [field_type] [int] DEFAULT (0) NOT NULL , + [field_ident] [varchar] (20) DEFAULT ('') NOT NULL , + [field_length] [varchar] (20) DEFAULT ('') NOT NULL , + [field_minlen] [varchar] (255) DEFAULT ('') NOT NULL , + [field_maxlen] [varchar] (255) DEFAULT ('') NOT NULL , + [field_novalue] [varchar] (255) DEFAULT ('') NOT NULL , + [field_default_value] [varchar] (255) DEFAULT ('') NOT NULL , + [field_validation] [varchar] (20) DEFAULT ('') NOT NULL , + [field_required] [int] DEFAULT (0) NOT NULL , + [field_show_novalue] [int] DEFAULT (0) NOT NULL , + [field_show_on_reg] [int] DEFAULT (0) NOT NULL , + [field_show_on_pm] [int] DEFAULT (0) NOT NULL , + [field_show_on_vt] [int] DEFAULT (0) NOT NULL , + [field_show_profile] [int] DEFAULT (0) NOT NULL , + [field_hide] [int] DEFAULT (0) NOT NULL , + [field_no_view] [int] DEFAULT (0) NOT NULL , + [field_active] [int] DEFAULT (0) NOT NULL , + [field_order] [int] DEFAULT (0) NOT NULL +) ON [PRIMARY] +GO + +ALTER TABLE [phpbb_profile_fields] WITH NOCHECK ADD + CONSTRAINT [PK_phpbb_profile_fields] PRIMARY KEY CLUSTERED + ( + [field_id] + ) ON [PRIMARY] +GO + +CREATE INDEX [fld_type] ON [phpbb_profile_fields]([field_type]) ON [PRIMARY] +GO + +CREATE INDEX [fld_ordr] ON [phpbb_profile_fields]([field_order]) ON [PRIMARY] +GO + + +/* + Table: 'phpbb_profile_fields_data' +*/ +CREATE TABLE [phpbb_profile_fields_data] ( + [user_id] [int] DEFAULT (0) NOT NULL +) ON [PRIMARY] +GO + +ALTER TABLE [phpbb_profile_fields_data] WITH NOCHECK ADD + CONSTRAINT [PK_phpbb_profile_fields_data] PRIMARY KEY CLUSTERED + ( + [user_id] + ) ON [PRIMARY] +GO + + +/* + Table: 'phpbb_profile_fields_lang' +*/ +CREATE TABLE [phpbb_profile_fields_lang] ( + [field_id] [int] DEFAULT (0) NOT NULL , + [lang_id] [int] DEFAULT (0) NOT NULL , + [option_id] [int] DEFAULT (0) NOT NULL , + [field_type] [int] DEFAULT (0) NOT NULL , + [lang_value] [varchar] (255) DEFAULT ('') NOT NULL +) ON [PRIMARY] +GO + +ALTER TABLE [phpbb_profile_fields_lang] WITH NOCHECK ADD + CONSTRAINT [PK_phpbb_profile_fields_lang] PRIMARY KEY CLUSTERED + ( + [field_id], + [lang_id], + [option_id] + ) ON [PRIMARY] +GO + + +/* + Table: 'phpbb_profile_lang' +*/ +CREATE TABLE [phpbb_profile_lang] ( + [field_id] [int] DEFAULT (0) NOT NULL , + [lang_id] [int] DEFAULT (0) NOT NULL , + [lang_name] [varchar] (255) DEFAULT ('') NOT NULL , + [lang_explain] [varchar] (4000) DEFAULT ('') NOT NULL , + [lang_default_value] [varchar] (255) DEFAULT ('') NOT NULL +) ON [PRIMARY] +GO + +ALTER TABLE [phpbb_profile_lang] WITH NOCHECK ADD + CONSTRAINT [PK_phpbb_profile_lang] PRIMARY KEY CLUSTERED + ( + [field_id], + [lang_id] + ) ON [PRIMARY] +GO + + +/* + Table: 'phpbb_ranks' +*/ +CREATE TABLE [phpbb_ranks] ( + [rank_id] [int] IDENTITY (1, 1) NOT NULL , + [rank_title] [varchar] (255) DEFAULT ('') NOT NULL , + [rank_min] [int] DEFAULT (0) NOT NULL , + [rank_special] [int] DEFAULT (0) NOT NULL , + [rank_image] [varchar] (255) DEFAULT ('') NOT NULL +) ON [PRIMARY] +GO + +ALTER TABLE [phpbb_ranks] WITH NOCHECK ADD + CONSTRAINT [PK_phpbb_ranks] PRIMARY KEY CLUSTERED + ( + [rank_id] + ) ON [PRIMARY] +GO + + +/* + Table: 'phpbb_reports' +*/ +CREATE TABLE [phpbb_reports] ( + [report_id] [int] IDENTITY (1, 1) NOT NULL , + [reason_id] [int] DEFAULT (0) NOT NULL , + [post_id] [int] DEFAULT (0) NOT NULL , + [pm_id] [int] DEFAULT (0) NOT NULL , + [user_id] [int] DEFAULT (0) NOT NULL , + [user_notify] [int] DEFAULT (0) NOT NULL , + [report_closed] [int] DEFAULT (0) NOT NULL , + [report_time] [int] DEFAULT (0) NOT NULL , + [report_text] [text] DEFAULT ('') NOT NULL , + [reported_post_text] [text] DEFAULT ('') NOT NULL +) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY] +GO + +ALTER TABLE [phpbb_reports] WITH NOCHECK ADD + CONSTRAINT [PK_phpbb_reports] PRIMARY KEY CLUSTERED + ( + [report_id] + ) ON [PRIMARY] +GO + +CREATE INDEX [post_id] ON [phpbb_reports]([post_id]) ON [PRIMARY] +GO + +CREATE INDEX [pm_id] ON [phpbb_reports]([pm_id]) ON [PRIMARY] +GO + + +/* + Table: 'phpbb_reports_reasons' +*/ +CREATE TABLE [phpbb_reports_reasons] ( + [reason_id] [int] IDENTITY (1, 1) NOT NULL , + [reason_title] [varchar] (255) DEFAULT ('') NOT NULL , + [reason_description] [text] DEFAULT ('') NOT NULL , + [reason_order] [int] DEFAULT (0) NOT NULL +) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY] +GO + +ALTER TABLE [phpbb_reports_reasons] WITH NOCHECK ADD + CONSTRAINT [PK_phpbb_reports_reasons] PRIMARY KEY CLUSTERED + ( + [reason_id] + ) ON [PRIMARY] +GO + + +/* + Table: 'phpbb_search_results' +*/ +CREATE TABLE [phpbb_search_results] ( + [search_key] [varchar] (32) DEFAULT ('') NOT NULL , + [search_time] [int] DEFAULT (0) NOT NULL , + [search_keywords] [text] DEFAULT ('') NOT NULL , + [search_authors] [text] DEFAULT ('') NOT NULL +) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY] +GO + +ALTER TABLE [phpbb_search_results] WITH NOCHECK ADD + CONSTRAINT [PK_phpbb_search_results] PRIMARY KEY CLUSTERED + ( + [search_key] + ) ON [PRIMARY] +GO + + +/* + Table: 'phpbb_search_wordlist' +*/ +CREATE TABLE [phpbb_search_wordlist] ( + [word_id] [int] IDENTITY (1, 1) NOT NULL , + [word_text] [varchar] (255) DEFAULT ('') NOT NULL , + [word_common] [int] DEFAULT (0) NOT NULL , + [word_count] [int] DEFAULT (0) NOT NULL +) ON [PRIMARY] +GO + +ALTER TABLE [phpbb_search_wordlist] WITH NOCHECK ADD + CONSTRAINT [PK_phpbb_search_wordlist] PRIMARY KEY CLUSTERED + ( + [word_id] + ) ON [PRIMARY] +GO + +CREATE UNIQUE INDEX [wrd_txt] ON [phpbb_search_wordlist]([word_text]) ON [PRIMARY] +GO + +CREATE INDEX [wrd_cnt] ON [phpbb_search_wordlist]([word_count]) ON [PRIMARY] +GO + + +/* + Table: 'phpbb_search_wordmatch' +*/ +CREATE TABLE [phpbb_search_wordmatch] ( + [post_id] [int] DEFAULT (0) NOT NULL , + [word_id] [int] DEFAULT (0) NOT NULL , + [title_match] [int] DEFAULT (0) NOT NULL +) ON [PRIMARY] +GO + +CREATE UNIQUE INDEX [unq_mtch] ON [phpbb_search_wordmatch]([word_id], [post_id], [title_match]) ON [PRIMARY] +GO + +CREATE INDEX [word_id] ON [phpbb_search_wordmatch]([word_id]) ON [PRIMARY] +GO + +CREATE INDEX [post_id] ON [phpbb_search_wordmatch]([post_id]) ON [PRIMARY] +GO + + +/* + Table: 'phpbb_sessions' +*/ +CREATE TABLE [phpbb_sessions] ( + [session_id] [char] (32) DEFAULT ('') NOT NULL , + [session_user_id] [int] DEFAULT (0) NOT NULL , + [session_forum_id] [int] DEFAULT (0) NOT NULL , + [session_last_visit] [int] DEFAULT (0) NOT NULL , + [session_start] [int] DEFAULT (0) NOT NULL , + [session_time] [int] DEFAULT (0) NOT NULL , + [session_ip] [varchar] (40) DEFAULT ('') NOT NULL , + [session_browser] [varchar] (150) DEFAULT ('') NOT NULL , + [session_forwarded_for] [varchar] (255) DEFAULT ('') NOT NULL , + [session_page] [varchar] (255) DEFAULT ('') NOT NULL , + [session_viewonline] [int] DEFAULT (1) NOT NULL , + [session_autologin] [int] DEFAULT (0) NOT NULL , + [session_admin] [int] DEFAULT (0) NOT NULL +) ON [PRIMARY] +GO + +ALTER TABLE [phpbb_sessions] WITH NOCHECK ADD + CONSTRAINT [PK_phpbb_sessions] PRIMARY KEY CLUSTERED + ( + [session_id] + ) ON [PRIMARY] +GO + +CREATE INDEX [session_time] ON [phpbb_sessions]([session_time]) ON [PRIMARY] +GO + +CREATE INDEX [session_user_id] ON [phpbb_sessions]([session_user_id]) ON [PRIMARY] +GO + +CREATE INDEX [session_fid] ON [phpbb_sessions]([session_forum_id]) ON [PRIMARY] +GO + + +/* + Table: 'phpbb_sessions_keys' +*/ +CREATE TABLE [phpbb_sessions_keys] ( + [key_id] [char] (32) DEFAULT ('') NOT NULL , + [user_id] [int] DEFAULT (0) NOT NULL , + [last_ip] [varchar] (40) DEFAULT ('') NOT NULL , + [last_login] [int] DEFAULT (0) NOT NULL +) ON [PRIMARY] +GO + +ALTER TABLE [phpbb_sessions_keys] WITH NOCHECK ADD + CONSTRAINT [PK_phpbb_sessions_keys] PRIMARY KEY CLUSTERED + ( + [key_id], + [user_id] + ) ON [PRIMARY] +GO + +CREATE INDEX [last_login] ON [phpbb_sessions_keys]([last_login]) ON [PRIMARY] +GO + + +/* + Table: 'phpbb_sitelist' +*/ +CREATE TABLE [phpbb_sitelist] ( + [site_id] [int] IDENTITY (1, 1) NOT NULL , + [site_ip] [varchar] (40) DEFAULT ('') NOT NULL , + [site_hostname] [varchar] (255) DEFAULT ('') NOT NULL , + [ip_exclude] [int] DEFAULT (0) NOT NULL +) ON [PRIMARY] +GO + +ALTER TABLE [phpbb_sitelist] WITH NOCHECK ADD + CONSTRAINT [PK_phpbb_sitelist] PRIMARY KEY CLUSTERED + ( + [site_id] + ) ON [PRIMARY] +GO + + +/* + Table: 'phpbb_smilies' +*/ +CREATE TABLE [phpbb_smilies] ( + [smiley_id] [int] IDENTITY (1, 1) NOT NULL , + [code] [varchar] (50) DEFAULT ('') NOT NULL , + [emotion] [varchar] (50) DEFAULT ('') NOT NULL , + [smiley_url] [varchar] (50) DEFAULT ('') NOT NULL , + [smiley_width] [int] DEFAULT (0) NOT NULL , + [smiley_height] [int] DEFAULT (0) NOT NULL , + [smiley_order] [int] DEFAULT (0) NOT NULL , + [display_on_posting] [int] DEFAULT (1) NOT NULL +) ON [PRIMARY] +GO + +ALTER TABLE [phpbb_smilies] WITH NOCHECK ADD + CONSTRAINT [PK_phpbb_smilies] PRIMARY KEY CLUSTERED + ( + [smiley_id] + ) ON [PRIMARY] +GO + +CREATE INDEX [display_on_post] ON [phpbb_smilies]([display_on_posting]) ON [PRIMARY] +GO + + +/* + Table: 'phpbb_styles' +*/ +CREATE TABLE [phpbb_styles] ( + [style_id] [int] IDENTITY (1, 1) NOT NULL , + [style_name] [varchar] (255) DEFAULT ('') NOT NULL , + [style_copyright] [varchar] (255) DEFAULT ('') NOT NULL , + [style_active] [int] DEFAULT (1) NOT NULL , + [style_path] [varchar] (100) DEFAULT ('') NOT NULL , + [bbcode_bitfield] [varchar] (255) DEFAULT ('kNg=') NOT NULL , + [style_parent_id] [int] DEFAULT (0) NOT NULL , + [style_parent_tree] [varchar] (8000) DEFAULT ('') NOT NULL +) ON [PRIMARY] +GO + +ALTER TABLE [phpbb_styles] WITH NOCHECK ADD + CONSTRAINT [PK_phpbb_styles] PRIMARY KEY CLUSTERED + ( + [style_id] + ) ON [PRIMARY] +GO + +CREATE UNIQUE INDEX [style_name] ON [phpbb_styles]([style_name]) ON [PRIMARY] +GO + + +/* + Table: 'phpbb_topics' +*/ +CREATE TABLE [phpbb_topics] ( + [topic_id] [int] IDENTITY (1, 1) NOT NULL , + [forum_id] [int] DEFAULT (0) NOT NULL , + [icon_id] [int] DEFAULT (0) NOT NULL , + [topic_attachment] [int] DEFAULT (0) NOT NULL , + [topic_approved] [int] DEFAULT (1) NOT NULL , + [topic_reported] [int] DEFAULT (0) NOT NULL , + [topic_title] [varchar] (255) DEFAULT ('') NOT NULL , + [topic_poster] [int] DEFAULT (0) NOT NULL , + [topic_time] [int] DEFAULT (0) NOT NULL , + [topic_time_limit] [int] DEFAULT (0) NOT NULL , + [topic_views] [int] DEFAULT (0) NOT NULL , + [topic_replies] [int] DEFAULT (0) NOT NULL , + [topic_replies_real] [int] DEFAULT (0) NOT NULL , + [topic_status] [int] DEFAULT (0) NOT NULL , + [topic_type] [int] DEFAULT (0) NOT NULL , + [topic_first_post_id] [int] DEFAULT (0) NOT NULL , + [topic_first_poster_name] [varchar] (255) DEFAULT ('') NOT NULL , + [topic_first_poster_colour] [varchar] (6) DEFAULT ('') NOT NULL , + [topic_last_post_id] [int] DEFAULT (0) NOT NULL , + [topic_last_poster_id] [int] DEFAULT (0) NOT NULL , + [topic_last_poster_name] [varchar] (255) DEFAULT ('') NOT NULL , + [topic_last_poster_colour] [varchar] (6) DEFAULT ('') NOT NULL , + [topic_last_post_subject] [varchar] (255) DEFAULT ('') NOT NULL , + [topic_last_post_time] [int] DEFAULT (0) NOT NULL , + [topic_last_view_time] [int] DEFAULT (0) NOT NULL , + [topic_moved_id] [int] DEFAULT (0) NOT NULL , + [topic_bumped] [int] DEFAULT (0) NOT NULL , + [topic_bumper] [int] DEFAULT (0) NOT NULL , + [poll_title] [varchar] (255) DEFAULT ('') NOT NULL , + [poll_start] [int] DEFAULT (0) NOT NULL , + [poll_length] [int] DEFAULT (0) NOT NULL , + [poll_max_options] [int] DEFAULT (1) NOT NULL , + [poll_last_vote] [int] DEFAULT (0) NOT NULL , + [poll_vote_change] [int] DEFAULT (0) NOT NULL +) ON [PRIMARY] +GO + +ALTER TABLE [phpbb_topics] WITH NOCHECK ADD + CONSTRAINT [PK_phpbb_topics] PRIMARY KEY CLUSTERED + ( + [topic_id] + ) ON [PRIMARY] +GO + +CREATE INDEX [forum_id] ON [phpbb_topics]([forum_id]) ON [PRIMARY] +GO + +CREATE INDEX [forum_id_type] ON [phpbb_topics]([forum_id], [topic_type]) ON [PRIMARY] +GO + +CREATE INDEX [last_post_time] ON [phpbb_topics]([topic_last_post_time]) ON [PRIMARY] +GO + +CREATE INDEX [topic_approved] ON [phpbb_topics]([topic_approved]) ON [PRIMARY] +GO + +CREATE INDEX [forum_appr_last] ON [phpbb_topics]([forum_id], [topic_approved], [topic_last_post_id]) ON [PRIMARY] +GO + +CREATE INDEX [fid_time_moved] ON [phpbb_topics]([forum_id], [topic_last_post_time], [topic_moved_id]) ON [PRIMARY] +GO + + +/* + Table: 'phpbb_topics_track' +*/ +CREATE TABLE [phpbb_topics_track] ( + [user_id] [int] DEFAULT (0) NOT NULL , + [topic_id] [int] DEFAULT (0) NOT NULL , + [forum_id] [int] DEFAULT (0) NOT NULL , + [mark_time] [int] DEFAULT (0) NOT NULL +) ON [PRIMARY] +GO + +ALTER TABLE [phpbb_topics_track] WITH NOCHECK ADD + CONSTRAINT [PK_phpbb_topics_track] PRIMARY KEY CLUSTERED + ( + [user_id], + [topic_id] + ) ON [PRIMARY] +GO + +CREATE INDEX [topic_id] ON [phpbb_topics_track]([topic_id]) ON [PRIMARY] +GO + +CREATE INDEX [forum_id] ON [phpbb_topics_track]([forum_id]) ON [PRIMARY] +GO + + +/* + Table: 'phpbb_topics_posted' +*/ +CREATE TABLE [phpbb_topics_posted] ( + [user_id] [int] DEFAULT (0) NOT NULL , + [topic_id] [int] DEFAULT (0) NOT NULL , + [topic_posted] [int] DEFAULT (0) NOT NULL +) ON [PRIMARY] +GO + +ALTER TABLE [phpbb_topics_posted] WITH NOCHECK ADD + CONSTRAINT [PK_phpbb_topics_posted] PRIMARY KEY CLUSTERED + ( + [user_id], + [topic_id] + ) ON [PRIMARY] +GO + + +/* + Table: 'phpbb_topics_watch' +*/ +CREATE TABLE [phpbb_topics_watch] ( + [topic_id] [int] DEFAULT (0) NOT NULL , + [user_id] [int] DEFAULT (0) NOT NULL , + [notify_status] [int] DEFAULT (0) NOT NULL +) ON [PRIMARY] +GO + +CREATE INDEX [topic_id] ON [phpbb_topics_watch]([topic_id]) ON [PRIMARY] +GO + +CREATE INDEX [user_id] ON [phpbb_topics_watch]([user_id]) ON [PRIMARY] +GO + +CREATE INDEX [notify_stat] ON [phpbb_topics_watch]([notify_status]) ON [PRIMARY] +GO + + +/* + Table: 'phpbb_user_group' +*/ +CREATE TABLE [phpbb_user_group] ( + [group_id] [int] DEFAULT (0) NOT NULL , + [user_id] [int] DEFAULT (0) NOT NULL , + [group_leader] [int] DEFAULT (0) NOT NULL , + [user_pending] [int] DEFAULT (1) NOT NULL +) ON [PRIMARY] +GO + +CREATE INDEX [group_id] ON [phpbb_user_group]([group_id]) ON [PRIMARY] +GO + +CREATE INDEX [user_id] ON [phpbb_user_group]([user_id]) ON [PRIMARY] +GO + +CREATE INDEX [group_leader] ON [phpbb_user_group]([group_leader]) ON [PRIMARY] +GO + + +/* + Table: 'phpbb_users' +*/ +CREATE TABLE [phpbb_users] ( + [user_id] [int] IDENTITY (1, 1) NOT NULL , + [user_type] [int] DEFAULT (0) NOT NULL , + [group_id] [int] DEFAULT (3) NOT NULL , + [user_permissions] [text] DEFAULT ('') NOT NULL , + [user_perm_from] [int] DEFAULT (0) NOT NULL , + [user_ip] [varchar] (40) DEFAULT ('') NOT NULL , + [user_regdate] [int] DEFAULT (0) NOT NULL , + [username] [varchar] (255) DEFAULT ('') NOT NULL , + [username_clean] [varchar] (255) DEFAULT ('') NOT NULL , + [user_password] [varchar] (40) DEFAULT ('') NOT NULL , + [user_passchg] [int] DEFAULT (0) NOT NULL , + [user_pass_convert] [int] DEFAULT (0) NOT NULL , + [user_email] [varchar] (100) DEFAULT ('') NOT NULL , + [user_email_hash] [float] DEFAULT (0) NOT NULL , + [user_birthday] [varchar] (10) DEFAULT ('') NOT NULL , + [user_lastvisit] [int] DEFAULT (0) NOT NULL , + [user_lastmark] [int] DEFAULT (0) NOT NULL , + [user_lastpost_time] [int] DEFAULT (0) NOT NULL , + [user_lastpage] [varchar] (200) DEFAULT ('') NOT NULL , + [user_last_confirm_key] [varchar] (10) DEFAULT ('') NOT NULL , + [user_last_search] [int] DEFAULT (0) NOT NULL , + [user_warnings] [int] DEFAULT (0) NOT NULL , + [user_last_warning] [int] DEFAULT (0) NOT NULL , + [user_login_attempts] [int] DEFAULT (0) NOT NULL , + [user_inactive_reason] [int] DEFAULT (0) NOT NULL , + [user_inactive_time] [int] DEFAULT (0) NOT NULL , + [user_posts] [int] DEFAULT (0) NOT NULL , + [user_lang] [varchar] (30) DEFAULT ('') NOT NULL , + [user_timezone] [varchar] (100) DEFAULT ('UTC') NOT NULL , + [user_dateformat] [varchar] (30) DEFAULT ('d M Y H:i') NOT NULL , + [user_style] [int] DEFAULT (0) NOT NULL , + [user_rank] [int] DEFAULT (0) NOT NULL , + [user_colour] [varchar] (6) DEFAULT ('') NOT NULL , + [user_new_privmsg] [int] DEFAULT (0) NOT NULL , + [user_unread_privmsg] [int] DEFAULT (0) NOT NULL , + [user_last_privmsg] [int] DEFAULT (0) NOT NULL , + [user_message_rules] [int] DEFAULT (0) NOT NULL , + [user_full_folder] [int] DEFAULT (-3) NOT NULL , + [user_emailtime] [int] DEFAULT (0) NOT NULL , + [user_topic_show_days] [int] DEFAULT (0) NOT NULL , + [user_topic_sortby_type] [varchar] (1) DEFAULT ('t') NOT NULL , + [user_topic_sortby_dir] [varchar] (1) DEFAULT ('d') NOT NULL , + [user_post_show_days] [int] DEFAULT (0) NOT NULL , + [user_post_sortby_type] [varchar] (1) DEFAULT ('t') NOT NULL , + [user_post_sortby_dir] [varchar] (1) DEFAULT ('a') NOT NULL , + [user_notify] [int] DEFAULT (0) NOT NULL , + [user_notify_pm] [int] DEFAULT (1) NOT NULL , + [user_notify_type] [int] DEFAULT (0) NOT NULL , + [user_allow_pm] [int] DEFAULT (1) NOT NULL , + [user_allow_viewonline] [int] DEFAULT (1) NOT NULL , + [user_allow_viewemail] [int] DEFAULT (1) NOT NULL , + [user_allow_massemail] [int] DEFAULT (1) NOT NULL , + [user_options] [int] DEFAULT (230271) NOT NULL , + [user_avatar] [varchar] (255) DEFAULT ('') NOT NULL , + [user_avatar_type] [int] DEFAULT (0) NOT NULL , + [user_avatar_width] [int] DEFAULT (0) NOT NULL , + [user_avatar_height] [int] DEFAULT (0) NOT NULL , + [user_sig] [text] DEFAULT ('') NOT NULL , + [user_sig_bbcode_uid] [varchar] (8) DEFAULT ('') NOT NULL , + [user_sig_bbcode_bitfield] [varchar] (255) DEFAULT ('') NOT NULL , + [user_from] [varchar] (100) DEFAULT ('') NOT NULL , + [user_icq] [varchar] (15) DEFAULT ('') NOT NULL , + [user_aim] [varchar] (255) DEFAULT ('') NOT NULL , + [user_yim] [varchar] (255) DEFAULT ('') NOT NULL , + [user_msnm] [varchar] (255) DEFAULT ('') NOT NULL , + [user_jabber] [varchar] (255) DEFAULT ('') NOT NULL , + [user_website] [varchar] (200) DEFAULT ('') NOT NULL , + [user_occ] [varchar] (4000) DEFAULT ('') NOT NULL , + [user_interests] [varchar] (4000) DEFAULT ('') NOT NULL , + [user_actkey] [varchar] (32) DEFAULT ('') NOT NULL , + [user_newpasswd] [varchar] (40) DEFAULT ('') NOT NULL , + [user_form_salt] [varchar] (32) DEFAULT ('') NOT NULL , + [user_new] [int] DEFAULT (1) NOT NULL , + [user_reminded] [int] DEFAULT (0) NOT NULL , + [user_reminded_time] [int] DEFAULT (0) NOT NULL +) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY] +GO + +ALTER TABLE [phpbb_users] WITH NOCHECK ADD + CONSTRAINT [PK_phpbb_users] PRIMARY KEY CLUSTERED + ( + [user_id] + ) ON [PRIMARY] +GO + +CREATE INDEX [user_birthday] ON [phpbb_users]([user_birthday]) ON [PRIMARY] +GO + +CREATE INDEX [user_email_hash] ON [phpbb_users]([user_email_hash]) ON [PRIMARY] +GO + +CREATE INDEX [user_type] ON [phpbb_users]([user_type]) ON [PRIMARY] +GO + +CREATE UNIQUE INDEX [username_clean] ON [phpbb_users]([username_clean]) ON [PRIMARY] +GO + + +/* + Table: 'phpbb_warnings' +*/ +CREATE TABLE [phpbb_warnings] ( + [warning_id] [int] IDENTITY (1, 1) NOT NULL , + [user_id] [int] DEFAULT (0) NOT NULL , + [post_id] [int] DEFAULT (0) NOT NULL , + [log_id] [int] DEFAULT (0) NOT NULL , + [warning_time] [int] DEFAULT (0) NOT NULL +) ON [PRIMARY] +GO + +ALTER TABLE [phpbb_warnings] WITH NOCHECK ADD + CONSTRAINT [PK_phpbb_warnings] PRIMARY KEY CLUSTERED + ( + [warning_id] + ) ON [PRIMARY] +GO + + +/* + Table: 'phpbb_words' +*/ +CREATE TABLE [phpbb_words] ( + [word_id] [int] IDENTITY (1, 1) NOT NULL , + [word] [varchar] (255) DEFAULT ('') NOT NULL , + [replacement] [varchar] (255) DEFAULT ('') NOT NULL +) ON [PRIMARY] +GO + +ALTER TABLE [phpbb_words] WITH NOCHECK ADD + CONSTRAINT [PK_phpbb_words] PRIMARY KEY CLUSTERED + ( + [word_id] + ) ON [PRIMARY] +GO + + +/* + Table: 'phpbb_zebra' +*/ +CREATE TABLE [phpbb_zebra] ( + [user_id] [int] DEFAULT (0) NOT NULL , + [zebra_id] [int] DEFAULT (0) NOT NULL , + [friend] [int] DEFAULT (0) NOT NULL , + [foe] [int] DEFAULT (0) NOT NULL +) ON [PRIMARY] +GO + +ALTER TABLE [phpbb_zebra] WITH NOCHECK ADD + CONSTRAINT [PK_phpbb_zebra] PRIMARY KEY CLUSTERED + ( + [user_id], + [zebra_id] + ) ON [PRIMARY] +GO diff --git a/phpBB/install/schemas/mysql_40_schema.sql b/phpBB/install/schemas/mysql_40_schema.sql index e71afcd5b3..8f2b779649 100644 --- a/phpBB/install/schemas/mysql_40_schema.sql +++ b/phpBB/install/schemas/mysql_40_schema.sql @@ -1,978 +1,976 @@ -# DO NOT EDIT THIS FILE, IT IS GENERATED -# -# To change the contents of this file, edit -# phpBB/develop/create_schema_files.php and -# run it. -# Table: 'phpbb_attachments' -CREATE TABLE phpbb_attachments ( - attach_id mediumint(8) UNSIGNED NOT NULL auto_increment, - post_msg_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - topic_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - in_message tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, - poster_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - is_orphan tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, - physical_filename varbinary(255) DEFAULT '' NOT NULL, - real_filename varbinary(255) DEFAULT '' NOT NULL, - download_count mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - attach_comment blob NOT NULL, - extension varbinary(100) DEFAULT '' NOT NULL, - mimetype varbinary(100) DEFAULT '' NOT NULL, - filesize int(20) UNSIGNED DEFAULT '0' NOT NULL, - filetime int(11) UNSIGNED DEFAULT '0' NOT NULL, - thumbnail tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, - PRIMARY KEY (attach_id), - KEY filetime (filetime), - KEY post_msg_id (post_msg_id), - KEY topic_id (topic_id), - KEY poster_id (poster_id), - KEY is_orphan (is_orphan) -); - - -# Table: 'phpbb_acl_groups' -CREATE TABLE phpbb_acl_groups ( - group_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - forum_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - auth_option_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - auth_role_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - auth_setting tinyint(2) DEFAULT '0' NOT NULL, - KEY group_id (group_id), - KEY auth_opt_id (auth_option_id), - KEY auth_role_id (auth_role_id) -); - - -# Table: 'phpbb_acl_options' -CREATE TABLE phpbb_acl_options ( - auth_option_id mediumint(8) UNSIGNED NOT NULL auto_increment, - auth_option varbinary(50) DEFAULT '' NOT NULL, - is_global tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, - is_local tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, - founder_only tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, - PRIMARY KEY (auth_option_id), - UNIQUE auth_option (auth_option) -); - - -# Table: 'phpbb_acl_roles' -CREATE TABLE phpbb_acl_roles ( - role_id mediumint(8) UNSIGNED NOT NULL auto_increment, - role_name blob NOT NULL, - role_description blob NOT NULL, - role_type varbinary(10) DEFAULT '' NOT NULL, - role_order smallint(4) UNSIGNED DEFAULT '0' NOT NULL, - PRIMARY KEY (role_id), - KEY role_type (role_type), - KEY role_order (role_order) -); - - -# Table: 'phpbb_acl_roles_data' -CREATE TABLE phpbb_acl_roles_data ( - role_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - auth_option_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - auth_setting tinyint(2) DEFAULT '0' NOT NULL, - PRIMARY KEY (role_id, auth_option_id), - KEY ath_op_id (auth_option_id) -); - - -# Table: 'phpbb_acl_users' -CREATE TABLE phpbb_acl_users ( - user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - forum_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - auth_option_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - auth_role_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - auth_setting tinyint(2) DEFAULT '0' NOT NULL, - KEY user_id (user_id), - KEY auth_option_id (auth_option_id), - KEY auth_role_id (auth_role_id) -); - - -# Table: 'phpbb_banlist' -CREATE TABLE phpbb_banlist ( - ban_id mediumint(8) UNSIGNED NOT NULL auto_increment, - ban_userid mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - ban_ip varbinary(40) DEFAULT '' NOT NULL, - ban_email blob NOT NULL, - ban_start int(11) UNSIGNED DEFAULT '0' NOT NULL, - ban_end int(11) UNSIGNED DEFAULT '0' NOT NULL, - ban_exclude tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, - ban_reason blob NOT NULL, - ban_give_reason blob NOT NULL, - PRIMARY KEY (ban_id), - KEY ban_end (ban_end), - KEY ban_user (ban_userid, ban_exclude), - KEY ban_email (ban_email(255), ban_exclude), - KEY ban_ip (ban_ip, ban_exclude) -); - - -# Table: 'phpbb_bbcodes' -CREATE TABLE phpbb_bbcodes ( - bbcode_id smallint(4) UNSIGNED DEFAULT '0' NOT NULL, - bbcode_tag varbinary(16) DEFAULT '' NOT NULL, - bbcode_helpline blob NOT NULL, - display_on_posting tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, - bbcode_match blob NOT NULL, - bbcode_tpl mediumblob NOT NULL, - first_pass_match mediumblob NOT NULL, - first_pass_replace mediumblob NOT NULL, - second_pass_match mediumblob NOT NULL, - second_pass_replace mediumblob NOT NULL, - PRIMARY KEY (bbcode_id), - KEY display_on_post (display_on_posting) -); - - -# Table: 'phpbb_bookmarks' -CREATE TABLE phpbb_bookmarks ( - topic_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - PRIMARY KEY (topic_id, user_id) -); - - -# Table: 'phpbb_bots' -CREATE TABLE phpbb_bots ( - bot_id mediumint(8) UNSIGNED NOT NULL auto_increment, - bot_active tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, - bot_name blob NOT NULL, - user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - bot_agent varbinary(255) DEFAULT '' NOT NULL, - bot_ip varbinary(255) DEFAULT '' NOT NULL, - PRIMARY KEY (bot_id), - KEY bot_active (bot_active) -); - - -# Table: 'phpbb_config' -CREATE TABLE phpbb_config ( - config_name varbinary(255) DEFAULT '' NOT NULL, - config_value blob NOT NULL, - is_dynamic tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, - PRIMARY KEY (config_name), - KEY is_dynamic (is_dynamic) -); - - -# Table: 'phpbb_confirm' -CREATE TABLE phpbb_confirm ( - confirm_id binary(32) DEFAULT '' NOT NULL, - session_id binary(32) DEFAULT '' NOT NULL, - confirm_type tinyint(3) DEFAULT '0' NOT NULL, - code varbinary(8) DEFAULT '' NOT NULL, - seed int(10) UNSIGNED DEFAULT '0' NOT NULL, - attempts mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - PRIMARY KEY (session_id, confirm_id), - KEY confirm_type (confirm_type) -); - - -# Table: 'phpbb_disallow' -CREATE TABLE phpbb_disallow ( - disallow_id mediumint(8) UNSIGNED NOT NULL auto_increment, - disallow_username blob NOT NULL, - PRIMARY KEY (disallow_id) -); - - -# Table: 'phpbb_drafts' -CREATE TABLE phpbb_drafts ( - draft_id mediumint(8) UNSIGNED NOT NULL auto_increment, - user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - topic_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - forum_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - save_time int(11) UNSIGNED DEFAULT '0' NOT NULL, - draft_subject blob NOT NULL, - draft_message mediumblob NOT NULL, - PRIMARY KEY (draft_id), - KEY save_time (save_time) -); - - -# Table: 'phpbb_ext' -CREATE TABLE phpbb_ext ( - ext_name varbinary(255) DEFAULT '' NOT NULL, - ext_active tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, - ext_state blob NOT NULL, - UNIQUE ext_name (ext_name) -); - - -# Table: 'phpbb_extensions' -CREATE TABLE phpbb_extensions ( - extension_id mediumint(8) UNSIGNED NOT NULL auto_increment, - group_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - extension varbinary(100) DEFAULT '' NOT NULL, - PRIMARY KEY (extension_id) -); - - -# Table: 'phpbb_extension_groups' -CREATE TABLE phpbb_extension_groups ( - group_id mediumint(8) UNSIGNED NOT NULL auto_increment, - group_name blob NOT NULL, - cat_id tinyint(2) DEFAULT '0' NOT NULL, - allow_group tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, - download_mode tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, - upload_icon varbinary(255) DEFAULT '' NOT NULL, - max_filesize int(20) UNSIGNED DEFAULT '0' NOT NULL, - allowed_forums blob NOT NULL, - allow_in_pm tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, - PRIMARY KEY (group_id) -); - - -# Table: 'phpbb_forums' -CREATE TABLE phpbb_forums ( - forum_id mediumint(8) UNSIGNED NOT NULL auto_increment, - parent_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - left_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - right_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - forum_parents mediumblob NOT NULL, - forum_name blob NOT NULL, - forum_desc blob NOT NULL, - forum_desc_bitfield varbinary(255) DEFAULT '' NOT NULL, - forum_desc_options int(11) UNSIGNED DEFAULT '7' NOT NULL, - forum_desc_uid varbinary(8) DEFAULT '' NOT NULL, - forum_link blob NOT NULL, - forum_password varbinary(120) DEFAULT '' NOT NULL, - forum_style mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - forum_image varbinary(255) DEFAULT '' NOT NULL, - forum_rules blob NOT NULL, - forum_rules_link blob NOT NULL, - forum_rules_bitfield varbinary(255) DEFAULT '' NOT NULL, - forum_rules_options int(11) UNSIGNED DEFAULT '7' NOT NULL, - forum_rules_uid varbinary(8) DEFAULT '' NOT NULL, - forum_topics_per_page tinyint(4) DEFAULT '0' NOT NULL, - forum_type tinyint(4) DEFAULT '0' NOT NULL, - forum_status tinyint(4) DEFAULT '0' NOT NULL, - forum_posts mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - forum_topics mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - forum_topics_real mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - forum_last_post_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - forum_last_poster_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - forum_last_post_subject blob NOT NULL, - forum_last_post_time int(11) UNSIGNED DEFAULT '0' NOT NULL, - forum_last_poster_name blob NOT NULL, - forum_last_poster_colour varbinary(6) DEFAULT '' NOT NULL, - forum_flags tinyint(4) DEFAULT '32' NOT NULL, - forum_options int(20) UNSIGNED DEFAULT '0' NOT NULL, - display_subforum_list tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, - display_on_index tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, - enable_indexing tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, - enable_icons tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, - enable_prune tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, - prune_next int(11) UNSIGNED DEFAULT '0' NOT NULL, - prune_days mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - prune_viewed mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - prune_freq mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - PRIMARY KEY (forum_id), - KEY left_right_id (left_id, right_id), - KEY forum_lastpost_id (forum_last_post_id) -); - - -# Table: 'phpbb_forums_access' -CREATE TABLE phpbb_forums_access ( - forum_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - session_id binary(32) DEFAULT '' NOT NULL, - PRIMARY KEY (forum_id, user_id, session_id) -); - - -# Table: 'phpbb_forums_track' -CREATE TABLE phpbb_forums_track ( - user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - forum_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - mark_time int(11) UNSIGNED DEFAULT '0' NOT NULL, - PRIMARY KEY (user_id, forum_id) -); - - -# Table: 'phpbb_forums_watch' -CREATE TABLE phpbb_forums_watch ( - forum_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - notify_status tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, - KEY forum_id (forum_id), - KEY user_id (user_id), - KEY notify_stat (notify_status) -); - - -# Table: 'phpbb_groups' -CREATE TABLE phpbb_groups ( - group_id mediumint(8) UNSIGNED NOT NULL auto_increment, - group_type tinyint(4) DEFAULT '1' NOT NULL, - group_founder_manage tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, - group_skip_auth tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, - group_name blob NOT NULL, - group_desc blob NOT NULL, - group_desc_bitfield varbinary(255) DEFAULT '' NOT NULL, - group_desc_options int(11) UNSIGNED DEFAULT '7' NOT NULL, - group_desc_uid varbinary(8) DEFAULT '' NOT NULL, - group_display tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, - group_avatar varbinary(255) DEFAULT '' NOT NULL, - group_avatar_type tinyint(2) DEFAULT '0' NOT NULL, - group_avatar_width smallint(4) UNSIGNED DEFAULT '0' NOT NULL, - group_avatar_height smallint(4) UNSIGNED DEFAULT '0' NOT NULL, - group_rank mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - group_colour varbinary(6) DEFAULT '' NOT NULL, - group_sig_chars mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - group_receive_pm tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, - group_message_limit mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - group_max_recipients mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - group_legend mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - group_teampage mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - PRIMARY KEY (group_id), - KEY group_legend_name (group_legend, group_name(255)) -); - - -# Table: 'phpbb_icons' -CREATE TABLE phpbb_icons ( - icons_id mediumint(8) UNSIGNED NOT NULL auto_increment, - icons_url varbinary(255) DEFAULT '' NOT NULL, - icons_width tinyint(4) DEFAULT '0' NOT NULL, - icons_height tinyint(4) DEFAULT '0' NOT NULL, - icons_order mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - display_on_posting tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, - PRIMARY KEY (icons_id), - KEY display_on_posting (display_on_posting) -); - - -# Table: 'phpbb_lang' -CREATE TABLE phpbb_lang ( - lang_id tinyint(4) NOT NULL auto_increment, - lang_iso varbinary(30) DEFAULT '' NOT NULL, - lang_dir varbinary(30) DEFAULT '' NOT NULL, - lang_english_name blob NOT NULL, - lang_local_name blob NOT NULL, - lang_author blob NOT NULL, - PRIMARY KEY (lang_id), - KEY lang_iso (lang_iso) -); - - -# Table: 'phpbb_log' -CREATE TABLE phpbb_log ( - log_id mediumint(8) UNSIGNED NOT NULL auto_increment, - log_type tinyint(4) DEFAULT '0' NOT NULL, - user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - forum_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - topic_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - reportee_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - log_ip varbinary(40) DEFAULT '' NOT NULL, - log_time int(11) UNSIGNED DEFAULT '0' NOT NULL, - log_operation blob NOT NULL, - log_data mediumblob NOT NULL, - PRIMARY KEY (log_id), - KEY log_type (log_type), - KEY log_time (log_time), - KEY forum_id (forum_id), - KEY topic_id (topic_id), - KEY reportee_id (reportee_id), - KEY user_id (user_id) -); - - -# Table: 'phpbb_login_attempts' -CREATE TABLE phpbb_login_attempts ( - attempt_ip varbinary(40) DEFAULT '' NOT NULL, - attempt_browser varbinary(150) DEFAULT '' NOT NULL, - attempt_forwarded_for varbinary(255) DEFAULT '' NOT NULL, - attempt_time int(11) UNSIGNED DEFAULT '0' NOT NULL, - user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - username blob NOT NULL, - username_clean blob NOT NULL, - KEY att_ip (attempt_ip, attempt_time), - KEY att_for (attempt_forwarded_for, attempt_time), - KEY att_time (attempt_time), - KEY user_id (user_id) -); - - -# Table: 'phpbb_moderator_cache' -CREATE TABLE phpbb_moderator_cache ( - forum_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - username blob NOT NULL, - group_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - group_name blob NOT NULL, - display_on_index tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, - KEY disp_idx (display_on_index), - KEY forum_id (forum_id) -); - - -# Table: 'phpbb_modules' -CREATE TABLE phpbb_modules ( - module_id mediumint(8) UNSIGNED NOT NULL auto_increment, - module_enabled tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, - module_display tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, - module_basename varbinary(255) DEFAULT '' NOT NULL, - module_class varbinary(10) DEFAULT '' NOT NULL, - parent_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - left_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - right_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - module_langname varbinary(255) DEFAULT '' NOT NULL, - module_mode varbinary(255) DEFAULT '' NOT NULL, - module_auth varbinary(255) DEFAULT '' NOT NULL, - PRIMARY KEY (module_id), - KEY left_right_id (left_id, right_id), - KEY module_enabled (module_enabled), - KEY class_left_id (module_class, left_id) -); - - -# Table: 'phpbb_poll_options' -CREATE TABLE phpbb_poll_options ( - poll_option_id tinyint(4) DEFAULT '0' NOT NULL, - topic_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - poll_option_text blob NOT NULL, - poll_option_total mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - KEY poll_opt_id (poll_option_id), - KEY topic_id (topic_id) -); - - -# Table: 'phpbb_poll_votes' -CREATE TABLE phpbb_poll_votes ( - topic_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - poll_option_id tinyint(4) DEFAULT '0' NOT NULL, - vote_user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - vote_user_ip varbinary(40) DEFAULT '' NOT NULL, - KEY topic_id (topic_id), - KEY vote_user_id (vote_user_id), - KEY vote_user_ip (vote_user_ip) -); - - -# Table: 'phpbb_posts' -CREATE TABLE phpbb_posts ( - post_id mediumint(8) UNSIGNED NOT NULL auto_increment, - topic_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - forum_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - poster_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - icon_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - poster_ip varbinary(40) DEFAULT '' NOT NULL, - post_time int(11) UNSIGNED DEFAULT '0' NOT NULL, - post_approved tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, - post_reported tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, - enable_bbcode tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, - enable_smilies tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, - enable_magic_url tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, - enable_sig tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, - post_username blob NOT NULL, - post_subject blob NOT NULL, - post_text mediumblob NOT NULL, - post_checksum varbinary(32) DEFAULT '' NOT NULL, - post_attachment tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, - bbcode_bitfield varbinary(255) DEFAULT '' NOT NULL, - bbcode_uid varbinary(8) DEFAULT '' NOT NULL, - post_postcount tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, - post_edit_time int(11) UNSIGNED DEFAULT '0' NOT NULL, - post_edit_reason blob NOT NULL, - post_edit_user mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - post_edit_count smallint(4) UNSIGNED DEFAULT '0' NOT NULL, - post_edit_locked tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, - PRIMARY KEY (post_id), - KEY forum_id (forum_id), - KEY topic_id (topic_id), - KEY poster_ip (poster_ip), - KEY poster_id (poster_id), - KEY post_approved (post_approved), - KEY post_username (post_username(255)), - KEY tid_post_time (topic_id, post_time) -); - - -# Table: 'phpbb_privmsgs' -CREATE TABLE phpbb_privmsgs ( - msg_id mediumint(8) UNSIGNED NOT NULL auto_increment, - root_level mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - author_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - icon_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - author_ip varbinary(40) DEFAULT '' NOT NULL, - message_time int(11) UNSIGNED DEFAULT '0' NOT NULL, - enable_bbcode tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, - enable_smilies tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, - enable_magic_url tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, - enable_sig tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, - message_subject blob NOT NULL, - message_text mediumblob NOT NULL, - message_edit_reason blob NOT NULL, - message_edit_user mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - message_attachment tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, - bbcode_bitfield varbinary(255) DEFAULT '' NOT NULL, - bbcode_uid varbinary(8) DEFAULT '' NOT NULL, - message_edit_time int(11) UNSIGNED DEFAULT '0' NOT NULL, - message_edit_count smallint(4) UNSIGNED DEFAULT '0' NOT NULL, - to_address blob NOT NULL, - bcc_address blob NOT NULL, - message_reported tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, - PRIMARY KEY (msg_id), - KEY author_ip (author_ip), - KEY message_time (message_time), - KEY author_id (author_id), - KEY root_level (root_level) -); - - -# Table: 'phpbb_privmsgs_folder' -CREATE TABLE phpbb_privmsgs_folder ( - folder_id mediumint(8) UNSIGNED NOT NULL auto_increment, - user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - folder_name blob NOT NULL, - pm_count mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - PRIMARY KEY (folder_id), - KEY user_id (user_id) -); - - -# Table: 'phpbb_privmsgs_rules' -CREATE TABLE phpbb_privmsgs_rules ( - rule_id mediumint(8) UNSIGNED NOT NULL auto_increment, - user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - rule_check mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - rule_connection mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - rule_string blob NOT NULL, - rule_user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - rule_group_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - rule_action mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - rule_folder_id int(11) DEFAULT '0' NOT NULL, - PRIMARY KEY (rule_id), - KEY user_id (user_id) -); - - -# Table: 'phpbb_privmsgs_to' -CREATE TABLE phpbb_privmsgs_to ( - msg_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - author_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - pm_deleted tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, - pm_new tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, - pm_unread tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, - pm_replied tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, - pm_marked tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, - pm_forwarded tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, - folder_id int(11) DEFAULT '0' NOT NULL, - KEY msg_id (msg_id), - KEY author_id (author_id), - KEY usr_flder_id (user_id, folder_id) -); - - -# Table: 'phpbb_profile_fields' -CREATE TABLE phpbb_profile_fields ( - field_id mediumint(8) UNSIGNED NOT NULL auto_increment, - field_name blob NOT NULL, - field_type tinyint(4) DEFAULT '0' NOT NULL, - field_ident varbinary(20) DEFAULT '' NOT NULL, - field_length varbinary(20) DEFAULT '' NOT NULL, - field_minlen varbinary(255) DEFAULT '' NOT NULL, - field_maxlen varbinary(255) DEFAULT '' NOT NULL, - field_novalue blob NOT NULL, - field_default_value blob NOT NULL, - field_validation varbinary(60) DEFAULT '' NOT NULL, - field_required tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, - field_show_novalue tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, - field_show_on_reg tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, - field_show_on_pm tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, - field_show_on_vt tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, - field_show_profile tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, - field_hide tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, - field_no_view tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, - field_active tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, - field_order mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - PRIMARY KEY (field_id), - KEY fld_type (field_type), - KEY fld_ordr (field_order) -); - - -# Table: 'phpbb_profile_fields_data' -CREATE TABLE phpbb_profile_fields_data ( - user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - PRIMARY KEY (user_id) -); - - -# Table: 'phpbb_profile_fields_lang' -CREATE TABLE phpbb_profile_fields_lang ( - field_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - lang_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - option_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - field_type tinyint(4) DEFAULT '0' NOT NULL, - lang_value blob NOT NULL, - PRIMARY KEY (field_id, lang_id, option_id) -); - - -# Table: 'phpbb_profile_lang' -CREATE TABLE phpbb_profile_lang ( - field_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - lang_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - lang_name blob NOT NULL, - lang_explain blob NOT NULL, - lang_default_value blob NOT NULL, - PRIMARY KEY (field_id, lang_id) -); - - -# Table: 'phpbb_ranks' -CREATE TABLE phpbb_ranks ( - rank_id mediumint(8) UNSIGNED NOT NULL auto_increment, - rank_title blob NOT NULL, - rank_min mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - rank_special tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, - rank_image varbinary(255) DEFAULT '' NOT NULL, - PRIMARY KEY (rank_id) -); - - -# Table: 'phpbb_reports' -CREATE TABLE phpbb_reports ( - report_id mediumint(8) UNSIGNED NOT NULL auto_increment, - reason_id smallint(4) UNSIGNED DEFAULT '0' NOT NULL, - post_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - pm_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - user_notify tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, - report_closed tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, - report_time int(11) UNSIGNED DEFAULT '0' NOT NULL, - report_text mediumblob NOT NULL, - reported_post_text mediumblob NOT NULL, - PRIMARY KEY (report_id), - KEY post_id (post_id), - KEY pm_id (pm_id) -); - - -# Table: 'phpbb_reports_reasons' -CREATE TABLE phpbb_reports_reasons ( - reason_id smallint(4) UNSIGNED NOT NULL auto_increment, - reason_title blob NOT NULL, - reason_description mediumblob NOT NULL, - reason_order smallint(4) UNSIGNED DEFAULT '0' NOT NULL, - PRIMARY KEY (reason_id) -); - - -# Table: 'phpbb_search_results' -CREATE TABLE phpbb_search_results ( - search_key varbinary(32) DEFAULT '' NOT NULL, - search_time int(11) UNSIGNED DEFAULT '0' NOT NULL, - search_keywords mediumblob NOT NULL, - search_authors mediumblob NOT NULL, - PRIMARY KEY (search_key) -); - - -# Table: 'phpbb_search_wordlist' -CREATE TABLE phpbb_search_wordlist ( - word_id mediumint(8) UNSIGNED NOT NULL auto_increment, - word_text blob NOT NULL, - word_common tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, - word_count mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - PRIMARY KEY (word_id), - UNIQUE wrd_txt (word_text(255)), - KEY wrd_cnt (word_count) -); - - -# Table: 'phpbb_search_wordmatch' -CREATE TABLE phpbb_search_wordmatch ( - post_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - word_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - title_match tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, - UNIQUE unq_mtch (word_id, post_id, title_match), - KEY word_id (word_id), - KEY post_id (post_id) -); - - -# Table: 'phpbb_sessions' -CREATE TABLE phpbb_sessions ( - session_id binary(32) DEFAULT '' NOT NULL, - session_user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - session_forum_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - session_last_visit int(11) UNSIGNED DEFAULT '0' NOT NULL, - session_start int(11) UNSIGNED DEFAULT '0' NOT NULL, - session_time int(11) UNSIGNED DEFAULT '0' NOT NULL, - session_ip varbinary(40) DEFAULT '' NOT NULL, - session_browser varbinary(150) DEFAULT '' NOT NULL, - session_forwarded_for varbinary(255) DEFAULT '' NOT NULL, - session_page blob NOT NULL, - session_viewonline tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, - session_autologin tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, - session_admin tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, - PRIMARY KEY (session_id), - KEY session_time (session_time), - KEY session_user_id (session_user_id), - KEY session_fid (session_forum_id) -); - - -# Table: 'phpbb_sessions_keys' -CREATE TABLE phpbb_sessions_keys ( - key_id binary(32) DEFAULT '' NOT NULL, - user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - last_ip varbinary(40) DEFAULT '' NOT NULL, - last_login int(11) UNSIGNED DEFAULT '0' NOT NULL, - PRIMARY KEY (key_id, user_id), - KEY last_login (last_login) -); - - -# Table: 'phpbb_sitelist' -CREATE TABLE phpbb_sitelist ( - site_id mediumint(8) UNSIGNED NOT NULL auto_increment, - site_ip varbinary(40) DEFAULT '' NOT NULL, - site_hostname varbinary(255) DEFAULT '' NOT NULL, - ip_exclude tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, - PRIMARY KEY (site_id) -); - - -# Table: 'phpbb_smilies' -CREATE TABLE phpbb_smilies ( - smiley_id mediumint(8) UNSIGNED NOT NULL auto_increment, - code varbinary(150) DEFAULT '' NOT NULL, - emotion varbinary(150) DEFAULT '' NOT NULL, - smiley_url varbinary(50) DEFAULT '' NOT NULL, - smiley_width smallint(4) UNSIGNED DEFAULT '0' NOT NULL, - smiley_height smallint(4) UNSIGNED DEFAULT '0' NOT NULL, - smiley_order mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - display_on_posting tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, - PRIMARY KEY (smiley_id), - KEY display_on_post (display_on_posting) -); - - -# Table: 'phpbb_styles' -CREATE TABLE phpbb_styles ( - style_id mediumint(8) UNSIGNED NOT NULL auto_increment, - style_name blob NOT NULL, - style_copyright blob NOT NULL, - style_active tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, - style_path varbinary(100) DEFAULT '' NOT NULL, - bbcode_bitfield varbinary(255) DEFAULT 'kNg=' NOT NULL, - style_parent_id int(4) UNSIGNED DEFAULT '0' NOT NULL, - style_parent_tree blob NOT NULL, - PRIMARY KEY (style_id), - UNIQUE style_name (style_name(255)) -); - - -# Table: 'phpbb_topics' -CREATE TABLE phpbb_topics ( - topic_id mediumint(8) UNSIGNED NOT NULL auto_increment, - forum_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - icon_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - topic_attachment tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, - topic_approved tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, - topic_reported tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, - topic_title blob NOT NULL, - topic_poster mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - topic_time int(11) UNSIGNED DEFAULT '0' NOT NULL, - topic_time_limit int(11) UNSIGNED DEFAULT '0' NOT NULL, - topic_views mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - topic_replies mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - topic_replies_real mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - topic_status tinyint(3) DEFAULT '0' NOT NULL, - topic_type tinyint(3) DEFAULT '0' NOT NULL, - topic_first_post_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - topic_first_poster_name blob NOT NULL, - topic_first_poster_colour varbinary(6) DEFAULT '' NOT NULL, - topic_last_post_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - topic_last_poster_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - topic_last_poster_name blob NOT NULL, - topic_last_poster_colour varbinary(6) DEFAULT '' NOT NULL, - topic_last_post_subject blob NOT NULL, - topic_last_post_time int(11) UNSIGNED DEFAULT '0' NOT NULL, - topic_last_view_time int(11) UNSIGNED DEFAULT '0' NOT NULL, - topic_moved_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - topic_bumped tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, - topic_bumper mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - poll_title blob NOT NULL, - poll_start int(11) UNSIGNED DEFAULT '0' NOT NULL, - poll_length int(11) UNSIGNED DEFAULT '0' NOT NULL, - poll_max_options tinyint(4) DEFAULT '1' NOT NULL, - poll_last_vote int(11) UNSIGNED DEFAULT '0' NOT NULL, - poll_vote_change tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, - PRIMARY KEY (topic_id), - KEY forum_id (forum_id), - KEY forum_id_type (forum_id, topic_type), - KEY last_post_time (topic_last_post_time), - KEY topic_approved (topic_approved), - KEY forum_appr_last (forum_id, topic_approved, topic_last_post_id), - KEY fid_time_moved (forum_id, topic_last_post_time, topic_moved_id) -); - - -# Table: 'phpbb_topics_track' -CREATE TABLE phpbb_topics_track ( - user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - topic_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - forum_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - mark_time int(11) UNSIGNED DEFAULT '0' NOT NULL, - PRIMARY KEY (user_id, topic_id), - KEY topic_id (topic_id), - KEY forum_id (forum_id) -); - - -# Table: 'phpbb_topics_posted' -CREATE TABLE phpbb_topics_posted ( - user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - topic_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - topic_posted tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, - PRIMARY KEY (user_id, topic_id) -); - - -# Table: 'phpbb_topics_watch' -CREATE TABLE phpbb_topics_watch ( - topic_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - notify_status tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, - KEY topic_id (topic_id), - KEY user_id (user_id), - KEY notify_stat (notify_status) -); - - -# Table: 'phpbb_user_group' -CREATE TABLE phpbb_user_group ( - group_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - group_leader tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, - user_pending tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, - KEY group_id (group_id), - KEY user_id (user_id), - KEY group_leader (group_leader) -); - - -# Table: 'phpbb_users' -CREATE TABLE phpbb_users ( - user_id mediumint(8) UNSIGNED NOT NULL auto_increment, - user_type tinyint(2) DEFAULT '0' NOT NULL, - group_id mediumint(8) UNSIGNED DEFAULT '3' NOT NULL, - user_permissions mediumblob NOT NULL, - user_perm_from mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - user_ip varbinary(40) DEFAULT '' NOT NULL, - user_regdate int(11) UNSIGNED DEFAULT '0' NOT NULL, - username blob NOT NULL, - username_clean blob NOT NULL, - user_password varbinary(120) DEFAULT '' NOT NULL, - user_passchg int(11) UNSIGNED DEFAULT '0' NOT NULL, - user_pass_convert tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, - user_email blob NOT NULL, - user_email_hash bigint(20) DEFAULT '0' NOT NULL, - user_birthday varbinary(10) DEFAULT '' NOT NULL, - user_lastvisit int(11) UNSIGNED DEFAULT '0' NOT NULL, - user_lastmark int(11) UNSIGNED DEFAULT '0' NOT NULL, - user_lastpost_time int(11) UNSIGNED DEFAULT '0' NOT NULL, - user_lastpage blob NOT NULL, - user_last_confirm_key varbinary(10) DEFAULT '' NOT NULL, - user_last_search int(11) UNSIGNED DEFAULT '0' NOT NULL, - user_warnings tinyint(4) DEFAULT '0' NOT NULL, - user_last_warning int(11) UNSIGNED DEFAULT '0' NOT NULL, - user_login_attempts tinyint(4) DEFAULT '0' NOT NULL, - user_inactive_reason tinyint(2) DEFAULT '0' NOT NULL, - user_inactive_time int(11) UNSIGNED DEFAULT '0' NOT NULL, - user_posts mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - user_lang varbinary(30) DEFAULT '' NOT NULL, - user_timezone varbinary(100) DEFAULT 'UTC' NOT NULL, - user_dateformat varbinary(90) DEFAULT 'd M Y H:i' NOT NULL, - user_style mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - user_rank mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - user_colour varbinary(6) DEFAULT '' NOT NULL, - user_new_privmsg int(4) DEFAULT '0' NOT NULL, - user_unread_privmsg int(4) DEFAULT '0' NOT NULL, - user_last_privmsg int(11) UNSIGNED DEFAULT '0' NOT NULL, - user_message_rules tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, - user_full_folder int(11) DEFAULT '-3' NOT NULL, - user_emailtime int(11) UNSIGNED DEFAULT '0' NOT NULL, - user_topic_show_days smallint(4) UNSIGNED DEFAULT '0' NOT NULL, - user_topic_sortby_type varbinary(1) DEFAULT 't' NOT NULL, - user_topic_sortby_dir varbinary(1) DEFAULT 'd' NOT NULL, - user_post_show_days smallint(4) UNSIGNED DEFAULT '0' NOT NULL, - user_post_sortby_type varbinary(1) DEFAULT 't' NOT NULL, - user_post_sortby_dir varbinary(1) DEFAULT 'a' NOT NULL, - user_notify tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, - user_notify_pm tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, - user_notify_type tinyint(4) DEFAULT '0' NOT NULL, - user_allow_pm tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, - user_allow_viewonline tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, - user_allow_viewemail tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, - user_allow_massemail tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, - user_options int(11) UNSIGNED DEFAULT '230271' NOT NULL, - user_avatar varbinary(255) DEFAULT '' NOT NULL, - user_avatar_type tinyint(2) DEFAULT '0' NOT NULL, - user_avatar_width smallint(4) UNSIGNED DEFAULT '0' NOT NULL, - user_avatar_height smallint(4) UNSIGNED DEFAULT '0' NOT NULL, - user_sig mediumblob NOT NULL, - user_sig_bbcode_uid varbinary(8) DEFAULT '' NOT NULL, - user_sig_bbcode_bitfield varbinary(255) DEFAULT '' NOT NULL, - user_from blob NOT NULL, - user_icq varbinary(15) DEFAULT '' NOT NULL, - user_aim blob NOT NULL, - user_yim blob NOT NULL, - user_msnm blob NOT NULL, - user_jabber blob NOT NULL, - user_website blob NOT NULL, - user_occ blob NOT NULL, - user_interests blob NOT NULL, - user_actkey varbinary(32) DEFAULT '' NOT NULL, - user_newpasswd varbinary(120) DEFAULT '' NOT NULL, - user_form_salt varbinary(96) DEFAULT '' NOT NULL, - user_new tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, - user_reminded tinyint(4) DEFAULT '0' NOT NULL, - user_reminded_time int(11) UNSIGNED DEFAULT '0' NOT NULL, - PRIMARY KEY (user_id), - KEY user_birthday (user_birthday), - KEY user_email_hash (user_email_hash), - KEY user_type (user_type), - UNIQUE username_clean (username_clean(255)) -); - - -# Table: 'phpbb_warnings' -CREATE TABLE phpbb_warnings ( - warning_id mediumint(8) UNSIGNED NOT NULL auto_increment, - user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - post_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - log_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - warning_time int(11) UNSIGNED DEFAULT '0' NOT NULL, - PRIMARY KEY (warning_id) -); - - -# Table: 'phpbb_words' -CREATE TABLE phpbb_words ( - word_id mediumint(8) UNSIGNED NOT NULL auto_increment, - word blob NOT NULL, - replacement blob NOT NULL, - PRIMARY KEY (word_id) -); - - -# Table: 'phpbb_zebra' -CREATE TABLE phpbb_zebra ( - user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - zebra_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - friend tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, - foe tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, - PRIMARY KEY (user_id, zebra_id) -); - - +# DO NOT EDIT THIS FILE, IT IS GENERATED +# +# To change the contents of this file, edit +# phpBB/develop/create_schema_files.php and +# run it. +# Table: 'phpbb_attachments' +CREATE TABLE phpbb_attachments ( + attach_id mediumint(8) UNSIGNED NOT NULL auto_increment, + post_msg_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + topic_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + in_message tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + poster_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + is_orphan tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, + physical_filename varbinary(255) DEFAULT '' NOT NULL, + real_filename varbinary(255) DEFAULT '' NOT NULL, + download_count mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + attach_comment blob NOT NULL, + extension varbinary(100) DEFAULT '' NOT NULL, + mimetype varbinary(100) DEFAULT '' NOT NULL, + filesize int(20) UNSIGNED DEFAULT '0' NOT NULL, + filetime int(11) UNSIGNED DEFAULT '0' NOT NULL, + thumbnail tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + PRIMARY KEY (attach_id), + KEY filetime (filetime), + KEY post_msg_id (post_msg_id), + KEY topic_id (topic_id), + KEY poster_id (poster_id), + KEY is_orphan (is_orphan) +); + + +# Table: 'phpbb_acl_groups' +CREATE TABLE phpbb_acl_groups ( + group_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + forum_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + auth_option_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + auth_role_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + auth_setting tinyint(2) DEFAULT '0' NOT NULL, + KEY group_id (group_id), + KEY auth_opt_id (auth_option_id), + KEY auth_role_id (auth_role_id) +); + + +# Table: 'phpbb_acl_options' +CREATE TABLE phpbb_acl_options ( + auth_option_id mediumint(8) UNSIGNED NOT NULL auto_increment, + auth_option varbinary(50) DEFAULT '' NOT NULL, + is_global tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + is_local tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + founder_only tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + PRIMARY KEY (auth_option_id), + UNIQUE auth_option (auth_option) +); + + +# Table: 'phpbb_acl_roles' +CREATE TABLE phpbb_acl_roles ( + role_id mediumint(8) UNSIGNED NOT NULL auto_increment, + role_name blob NOT NULL, + role_description blob NOT NULL, + role_type varbinary(10) DEFAULT '' NOT NULL, + role_order smallint(4) UNSIGNED DEFAULT '0' NOT NULL, + PRIMARY KEY (role_id), + KEY role_type (role_type), + KEY role_order (role_order) +); + + +# Table: 'phpbb_acl_roles_data' +CREATE TABLE phpbb_acl_roles_data ( + role_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + auth_option_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + auth_setting tinyint(2) DEFAULT '0' NOT NULL, + PRIMARY KEY (role_id, auth_option_id), + KEY ath_op_id (auth_option_id) +); + + +# Table: 'phpbb_acl_users' +CREATE TABLE phpbb_acl_users ( + user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + forum_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + auth_option_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + auth_role_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + auth_setting tinyint(2) DEFAULT '0' NOT NULL, + KEY user_id (user_id), + KEY auth_option_id (auth_option_id), + KEY auth_role_id (auth_role_id) +); + + +# Table: 'phpbb_banlist' +CREATE TABLE phpbb_banlist ( + ban_id mediumint(8) UNSIGNED NOT NULL auto_increment, + ban_userid mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + ban_ip varbinary(40) DEFAULT '' NOT NULL, + ban_email blob NOT NULL, + ban_start int(11) UNSIGNED DEFAULT '0' NOT NULL, + ban_end int(11) UNSIGNED DEFAULT '0' NOT NULL, + ban_exclude tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + ban_reason blob NOT NULL, + ban_give_reason blob NOT NULL, + PRIMARY KEY (ban_id), + KEY ban_end (ban_end), + KEY ban_user (ban_userid, ban_exclude), + KEY ban_email (ban_email(255), ban_exclude), + KEY ban_ip (ban_ip, ban_exclude) +); + + +# Table: 'phpbb_bbcodes' +CREATE TABLE phpbb_bbcodes ( + bbcode_id smallint(4) UNSIGNED DEFAULT '0' NOT NULL, + bbcode_tag varbinary(16) DEFAULT '' NOT NULL, + bbcode_helpline blob NOT NULL, + display_on_posting tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + bbcode_match blob NOT NULL, + bbcode_tpl mediumblob NOT NULL, + first_pass_match mediumblob NOT NULL, + first_pass_replace mediumblob NOT NULL, + second_pass_match mediumblob NOT NULL, + second_pass_replace mediumblob NOT NULL, + PRIMARY KEY (bbcode_id), + KEY display_on_post (display_on_posting) +); + + +# Table: 'phpbb_bookmarks' +CREATE TABLE phpbb_bookmarks ( + topic_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + PRIMARY KEY (topic_id, user_id) +); + + +# Table: 'phpbb_bots' +CREATE TABLE phpbb_bots ( + bot_id mediumint(8) UNSIGNED NOT NULL auto_increment, + bot_active tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, + bot_name blob NOT NULL, + user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + bot_agent varbinary(255) DEFAULT '' NOT NULL, + bot_ip varbinary(255) DEFAULT '' NOT NULL, + PRIMARY KEY (bot_id), + KEY bot_active (bot_active) +); + + +# Table: 'phpbb_config' +CREATE TABLE phpbb_config ( + config_name varbinary(255) DEFAULT '' NOT NULL, + config_value blob NOT NULL, + is_dynamic tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + PRIMARY KEY (config_name), + KEY is_dynamic (is_dynamic) +); + + +# Table: 'phpbb_confirm' +CREATE TABLE phpbb_confirm ( + confirm_id binary(32) DEFAULT '' NOT NULL, + session_id binary(32) DEFAULT '' NOT NULL, + confirm_type tinyint(3) DEFAULT '0' NOT NULL, + code varbinary(8) DEFAULT '' NOT NULL, + seed int(10) UNSIGNED DEFAULT '0' NOT NULL, + attempts mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + PRIMARY KEY (session_id, confirm_id), + KEY confirm_type (confirm_type) +); + + +# Table: 'phpbb_disallow' +CREATE TABLE phpbb_disallow ( + disallow_id mediumint(8) UNSIGNED NOT NULL auto_increment, + disallow_username blob NOT NULL, + PRIMARY KEY (disallow_id) +); + + +# Table: 'phpbb_drafts' +CREATE TABLE phpbb_drafts ( + draft_id mediumint(8) UNSIGNED NOT NULL auto_increment, + user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + topic_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + forum_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + save_time int(11) UNSIGNED DEFAULT '0' NOT NULL, + draft_subject blob NOT NULL, + draft_message mediumblob NOT NULL, + PRIMARY KEY (draft_id), + KEY save_time (save_time) +); + + +# Table: 'phpbb_ext' +CREATE TABLE phpbb_ext ( + ext_name varbinary(255) DEFAULT '' NOT NULL, + ext_active tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + ext_state blob NOT NULL, + UNIQUE ext_name (ext_name) +); + + +# Table: 'phpbb_extensions' +CREATE TABLE phpbb_extensions ( + extension_id mediumint(8) UNSIGNED NOT NULL auto_increment, + group_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + extension varbinary(100) DEFAULT '' NOT NULL, + PRIMARY KEY (extension_id) +); + + +# Table: 'phpbb_extension_groups' +CREATE TABLE phpbb_extension_groups ( + group_id mediumint(8) UNSIGNED NOT NULL auto_increment, + group_name blob NOT NULL, + cat_id tinyint(2) DEFAULT '0' NOT NULL, + allow_group tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + download_mode tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, + upload_icon varbinary(255) DEFAULT '' NOT NULL, + max_filesize int(20) UNSIGNED DEFAULT '0' NOT NULL, + allowed_forums blob NOT NULL, + allow_in_pm tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + PRIMARY KEY (group_id) +); + + +# Table: 'phpbb_forums' +CREATE TABLE phpbb_forums ( + forum_id mediumint(8) UNSIGNED NOT NULL auto_increment, + parent_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + left_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + right_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + forum_parents mediumblob NOT NULL, + forum_name blob NOT NULL, + forum_desc blob NOT NULL, + forum_desc_bitfield varbinary(255) DEFAULT '' NOT NULL, + forum_desc_options int(11) UNSIGNED DEFAULT '7' NOT NULL, + forum_desc_uid varbinary(8) DEFAULT '' NOT NULL, + forum_link blob NOT NULL, + forum_password varbinary(120) DEFAULT '' NOT NULL, + forum_style mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + forum_image varbinary(255) DEFAULT '' NOT NULL, + forum_rules blob NOT NULL, + forum_rules_link blob NOT NULL, + forum_rules_bitfield varbinary(255) DEFAULT '' NOT NULL, + forum_rules_options int(11) UNSIGNED DEFAULT '7' NOT NULL, + forum_rules_uid varbinary(8) DEFAULT '' NOT NULL, + forum_topics_per_page tinyint(4) DEFAULT '0' NOT NULL, + forum_type tinyint(4) DEFAULT '0' NOT NULL, + forum_status tinyint(4) DEFAULT '0' NOT NULL, + forum_posts mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + forum_topics mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + forum_topics_real mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + forum_last_post_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + forum_last_poster_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + forum_last_post_subject blob NOT NULL, + forum_last_post_time int(11) UNSIGNED DEFAULT '0' NOT NULL, + forum_last_poster_name blob NOT NULL, + forum_last_poster_colour varbinary(6) DEFAULT '' NOT NULL, + forum_flags tinyint(4) DEFAULT '32' NOT NULL, + forum_options int(20) UNSIGNED DEFAULT '0' NOT NULL, + display_subforum_list tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, + display_on_index tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, + enable_indexing tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, + enable_icons tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, + enable_prune tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + prune_next int(11) UNSIGNED DEFAULT '0' NOT NULL, + prune_days mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + prune_viewed mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + prune_freq mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + PRIMARY KEY (forum_id), + KEY left_right_id (left_id, right_id), + KEY forum_lastpost_id (forum_last_post_id) +); + + +# Table: 'phpbb_forums_access' +CREATE TABLE phpbb_forums_access ( + forum_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + session_id binary(32) DEFAULT '' NOT NULL, + PRIMARY KEY (forum_id, user_id, session_id) +); + + +# Table: 'phpbb_forums_track' +CREATE TABLE phpbb_forums_track ( + user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + forum_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + mark_time int(11) UNSIGNED DEFAULT '0' NOT NULL, + PRIMARY KEY (user_id, forum_id) +); + + +# Table: 'phpbb_forums_watch' +CREATE TABLE phpbb_forums_watch ( + forum_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + notify_status tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + KEY forum_id (forum_id), + KEY user_id (user_id), + KEY notify_stat (notify_status) +); + + +# Table: 'phpbb_groups' +CREATE TABLE phpbb_groups ( + group_id mediumint(8) UNSIGNED NOT NULL auto_increment, + group_type tinyint(4) DEFAULT '1' NOT NULL, + group_founder_manage tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + group_skip_auth tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + group_name blob NOT NULL, + group_desc blob NOT NULL, + group_desc_bitfield varbinary(255) DEFAULT '' NOT NULL, + group_desc_options int(11) UNSIGNED DEFAULT '7' NOT NULL, + group_desc_uid varbinary(8) DEFAULT '' NOT NULL, + group_display tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + group_avatar varbinary(255) DEFAULT '' NOT NULL, + group_avatar_type tinyint(2) DEFAULT '0' NOT NULL, + group_avatar_width smallint(4) UNSIGNED DEFAULT '0' NOT NULL, + group_avatar_height smallint(4) UNSIGNED DEFAULT '0' NOT NULL, + group_rank mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + group_colour varbinary(6) DEFAULT '' NOT NULL, + group_sig_chars mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + group_receive_pm tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + group_message_limit mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + group_max_recipients mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + group_legend mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + group_teampage mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + PRIMARY KEY (group_id), + KEY group_legend_name (group_legend, group_name(255)) +); + + +# Table: 'phpbb_icons' +CREATE TABLE phpbb_icons ( + icons_id mediumint(8) UNSIGNED NOT NULL auto_increment, + icons_url varbinary(255) DEFAULT '' NOT NULL, + icons_width tinyint(4) DEFAULT '0' NOT NULL, + icons_height tinyint(4) DEFAULT '0' NOT NULL, + icons_order mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + display_on_posting tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, + PRIMARY KEY (icons_id), + KEY display_on_posting (display_on_posting) +); + + +# Table: 'phpbb_lang' +CREATE TABLE phpbb_lang ( + lang_id tinyint(4) NOT NULL auto_increment, + lang_iso varbinary(30) DEFAULT '' NOT NULL, + lang_dir varbinary(30) DEFAULT '' NOT NULL, + lang_english_name blob NOT NULL, + lang_local_name blob NOT NULL, + lang_author blob NOT NULL, + PRIMARY KEY (lang_id), + KEY lang_iso (lang_iso) +); + + +# Table: 'phpbb_log' +CREATE TABLE phpbb_log ( + log_id mediumint(8) UNSIGNED NOT NULL auto_increment, + log_type tinyint(4) DEFAULT '0' NOT NULL, + user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + forum_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + topic_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + reportee_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + log_ip varbinary(40) DEFAULT '' NOT NULL, + log_time int(11) UNSIGNED DEFAULT '0' NOT NULL, + log_operation blob NOT NULL, + log_data mediumblob NOT NULL, + PRIMARY KEY (log_id), + KEY log_type (log_type), + KEY log_time (log_time), + KEY forum_id (forum_id), + KEY topic_id (topic_id), + KEY reportee_id (reportee_id), + KEY user_id (user_id) +); + + +# Table: 'phpbb_login_attempts' +CREATE TABLE phpbb_login_attempts ( + attempt_ip varbinary(40) DEFAULT '' NOT NULL, + attempt_browser varbinary(150) DEFAULT '' NOT NULL, + attempt_forwarded_for varbinary(255) DEFAULT '' NOT NULL, + attempt_time int(11) UNSIGNED DEFAULT '0' NOT NULL, + user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + username blob NOT NULL, + username_clean blob NOT NULL, + KEY att_ip (attempt_ip, attempt_time), + KEY att_for (attempt_forwarded_for, attempt_time), + KEY att_time (attempt_time), + KEY user_id (user_id) +); + + +# Table: 'phpbb_moderator_cache' +CREATE TABLE phpbb_moderator_cache ( + forum_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + username blob NOT NULL, + group_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + group_name blob NOT NULL, + display_on_index tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, + KEY disp_idx (display_on_index), + KEY forum_id (forum_id) +); + + +# Table: 'phpbb_modules' +CREATE TABLE phpbb_modules ( + module_id mediumint(8) UNSIGNED NOT NULL auto_increment, + module_enabled tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, + module_display tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, + module_basename varbinary(255) DEFAULT '' NOT NULL, + module_class varbinary(10) DEFAULT '' NOT NULL, + parent_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + left_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + right_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + module_langname varbinary(255) DEFAULT '' NOT NULL, + module_mode varbinary(255) DEFAULT '' NOT NULL, + module_auth varbinary(255) DEFAULT '' NOT NULL, + PRIMARY KEY (module_id), + KEY left_right_id (left_id, right_id), + KEY module_enabled (module_enabled), + KEY class_left_id (module_class, left_id) +); + + +# Table: 'phpbb_poll_options' +CREATE TABLE phpbb_poll_options ( + poll_option_id tinyint(4) DEFAULT '0' NOT NULL, + topic_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + poll_option_text blob NOT NULL, + poll_option_total mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + KEY poll_opt_id (poll_option_id), + KEY topic_id (topic_id) +); + + +# Table: 'phpbb_poll_votes' +CREATE TABLE phpbb_poll_votes ( + topic_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + poll_option_id tinyint(4) DEFAULT '0' NOT NULL, + vote_user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + vote_user_ip varbinary(40) DEFAULT '' NOT NULL, + KEY topic_id (topic_id), + KEY vote_user_id (vote_user_id), + KEY vote_user_ip (vote_user_ip) +); + + +# Table: 'phpbb_posts' +CREATE TABLE phpbb_posts ( + post_id mediumint(8) UNSIGNED NOT NULL auto_increment, + topic_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + forum_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + poster_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + icon_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + poster_ip varbinary(40) DEFAULT '' NOT NULL, + post_time int(11) UNSIGNED DEFAULT '0' NOT NULL, + post_approved tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, + post_reported tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + enable_bbcode tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, + enable_smilies tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, + enable_magic_url tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, + enable_sig tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, + post_username blob NOT NULL, + post_subject blob NOT NULL, + post_text mediumblob NOT NULL, + post_checksum varbinary(32) DEFAULT '' NOT NULL, + post_attachment tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + bbcode_bitfield varbinary(255) DEFAULT '' NOT NULL, + bbcode_uid varbinary(8) DEFAULT '' NOT NULL, + post_postcount tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, + post_edit_time int(11) UNSIGNED DEFAULT '0' NOT NULL, + post_edit_reason blob NOT NULL, + post_edit_user mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + post_edit_count smallint(4) UNSIGNED DEFAULT '0' NOT NULL, + post_edit_locked tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + PRIMARY KEY (post_id), + KEY forum_id (forum_id), + KEY topic_id (topic_id), + KEY poster_ip (poster_ip), + KEY poster_id (poster_id), + KEY post_approved (post_approved), + KEY post_username (post_username(255)), + KEY tid_post_time (topic_id, post_time) +); + + +# Table: 'phpbb_privmsgs' +CREATE TABLE phpbb_privmsgs ( + msg_id mediumint(8) UNSIGNED NOT NULL auto_increment, + root_level mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + author_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + icon_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + author_ip varbinary(40) DEFAULT '' NOT NULL, + message_time int(11) UNSIGNED DEFAULT '0' NOT NULL, + enable_bbcode tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, + enable_smilies tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, + enable_magic_url tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, + enable_sig tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, + message_subject blob NOT NULL, + message_text mediumblob NOT NULL, + message_edit_reason blob NOT NULL, + message_edit_user mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + message_attachment tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + bbcode_bitfield varbinary(255) DEFAULT '' NOT NULL, + bbcode_uid varbinary(8) DEFAULT '' NOT NULL, + message_edit_time int(11) UNSIGNED DEFAULT '0' NOT NULL, + message_edit_count smallint(4) UNSIGNED DEFAULT '0' NOT NULL, + to_address blob NOT NULL, + bcc_address blob NOT NULL, + message_reported tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + PRIMARY KEY (msg_id), + KEY author_ip (author_ip), + KEY message_time (message_time), + KEY author_id (author_id), + KEY root_level (root_level) +); + + +# Table: 'phpbb_privmsgs_folder' +CREATE TABLE phpbb_privmsgs_folder ( + folder_id mediumint(8) UNSIGNED NOT NULL auto_increment, + user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + folder_name blob NOT NULL, + pm_count mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + PRIMARY KEY (folder_id), + KEY user_id (user_id) +); + + +# Table: 'phpbb_privmsgs_rules' +CREATE TABLE phpbb_privmsgs_rules ( + rule_id mediumint(8) UNSIGNED NOT NULL auto_increment, + user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + rule_check mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + rule_connection mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + rule_string blob NOT NULL, + rule_user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + rule_group_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + rule_action mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + rule_folder_id int(11) DEFAULT '0' NOT NULL, + PRIMARY KEY (rule_id), + KEY user_id (user_id) +); + + +# Table: 'phpbb_privmsgs_to' +CREATE TABLE phpbb_privmsgs_to ( + msg_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + author_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + pm_deleted tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + pm_new tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, + pm_unread tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, + pm_replied tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + pm_marked tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + pm_forwarded tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + folder_id int(11) DEFAULT '0' NOT NULL, + KEY msg_id (msg_id), + KEY author_id (author_id), + KEY usr_flder_id (user_id, folder_id) +); + + +# Table: 'phpbb_profile_fields' +CREATE TABLE phpbb_profile_fields ( + field_id mediumint(8) UNSIGNED NOT NULL auto_increment, + field_name blob NOT NULL, + field_type tinyint(4) DEFAULT '0' NOT NULL, + field_ident varbinary(20) DEFAULT '' NOT NULL, + field_length varbinary(20) DEFAULT '' NOT NULL, + field_minlen varbinary(255) DEFAULT '' NOT NULL, + field_maxlen varbinary(255) DEFAULT '' NOT NULL, + field_novalue blob NOT NULL, + field_default_value blob NOT NULL, + field_validation varbinary(60) DEFAULT '' NOT NULL, + field_required tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + field_show_novalue tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + field_show_on_reg tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + field_show_on_pm tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + field_show_on_vt tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + field_show_profile tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + field_hide tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + field_no_view tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + field_active tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + field_order mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + PRIMARY KEY (field_id), + KEY fld_type (field_type), + KEY fld_ordr (field_order) +); + + +# Table: 'phpbb_profile_fields_data' +CREATE TABLE phpbb_profile_fields_data ( + user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + PRIMARY KEY (user_id) +); + + +# Table: 'phpbb_profile_fields_lang' +CREATE TABLE phpbb_profile_fields_lang ( + field_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + lang_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + option_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + field_type tinyint(4) DEFAULT '0' NOT NULL, + lang_value blob NOT NULL, + PRIMARY KEY (field_id, lang_id, option_id) +); + + +# Table: 'phpbb_profile_lang' +CREATE TABLE phpbb_profile_lang ( + field_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + lang_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + lang_name blob NOT NULL, + lang_explain blob NOT NULL, + lang_default_value blob NOT NULL, + PRIMARY KEY (field_id, lang_id) +); + + +# Table: 'phpbb_ranks' +CREATE TABLE phpbb_ranks ( + rank_id mediumint(8) UNSIGNED NOT NULL auto_increment, + rank_title blob NOT NULL, + rank_min mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + rank_special tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + rank_image varbinary(255) DEFAULT '' NOT NULL, + PRIMARY KEY (rank_id) +); + + +# Table: 'phpbb_reports' +CREATE TABLE phpbb_reports ( + report_id mediumint(8) UNSIGNED NOT NULL auto_increment, + reason_id smallint(4) UNSIGNED DEFAULT '0' NOT NULL, + post_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + pm_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + user_notify tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + report_closed tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + report_time int(11) UNSIGNED DEFAULT '0' NOT NULL, + report_text mediumblob NOT NULL, + reported_post_text mediumblob NOT NULL, + PRIMARY KEY (report_id), + KEY post_id (post_id), + KEY pm_id (pm_id) +); + + +# Table: 'phpbb_reports_reasons' +CREATE TABLE phpbb_reports_reasons ( + reason_id smallint(4) UNSIGNED NOT NULL auto_increment, + reason_title blob NOT NULL, + reason_description mediumblob NOT NULL, + reason_order smallint(4) UNSIGNED DEFAULT '0' NOT NULL, + PRIMARY KEY (reason_id) +); + + +# Table: 'phpbb_search_results' +CREATE TABLE phpbb_search_results ( + search_key varbinary(32) DEFAULT '' NOT NULL, + search_time int(11) UNSIGNED DEFAULT '0' NOT NULL, + search_keywords mediumblob NOT NULL, + search_authors mediumblob NOT NULL, + PRIMARY KEY (search_key) +); + + +# Table: 'phpbb_search_wordlist' +CREATE TABLE phpbb_search_wordlist ( + word_id mediumint(8) UNSIGNED NOT NULL auto_increment, + word_text blob NOT NULL, + word_common tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + word_count mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + PRIMARY KEY (word_id), + UNIQUE wrd_txt (word_text(255)), + KEY wrd_cnt (word_count) +); + + +# Table: 'phpbb_search_wordmatch' +CREATE TABLE phpbb_search_wordmatch ( + post_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + word_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + title_match tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + UNIQUE unq_mtch (word_id, post_id, title_match), + KEY word_id (word_id), + KEY post_id (post_id) +); + + +# Table: 'phpbb_sessions' +CREATE TABLE phpbb_sessions ( + session_id binary(32) DEFAULT '' NOT NULL, + session_user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + session_forum_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + session_last_visit int(11) UNSIGNED DEFAULT '0' NOT NULL, + session_start int(11) UNSIGNED DEFAULT '0' NOT NULL, + session_time int(11) UNSIGNED DEFAULT '0' NOT NULL, + session_ip varbinary(40) DEFAULT '' NOT NULL, + session_browser varbinary(150) DEFAULT '' NOT NULL, + session_forwarded_for varbinary(255) DEFAULT '' NOT NULL, + session_page blob NOT NULL, + session_viewonline tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, + session_autologin tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + session_admin tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + PRIMARY KEY (session_id), + KEY session_time (session_time), + KEY session_user_id (session_user_id), + KEY session_fid (session_forum_id) +); + + +# Table: 'phpbb_sessions_keys' +CREATE TABLE phpbb_sessions_keys ( + key_id binary(32) DEFAULT '' NOT NULL, + user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + last_ip varbinary(40) DEFAULT '' NOT NULL, + last_login int(11) UNSIGNED DEFAULT '0' NOT NULL, + PRIMARY KEY (key_id, user_id), + KEY last_login (last_login) +); + + +# Table: 'phpbb_sitelist' +CREATE TABLE phpbb_sitelist ( + site_id mediumint(8) UNSIGNED NOT NULL auto_increment, + site_ip varbinary(40) DEFAULT '' NOT NULL, + site_hostname varbinary(255) DEFAULT '' NOT NULL, + ip_exclude tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + PRIMARY KEY (site_id) +); + + +# Table: 'phpbb_smilies' +CREATE TABLE phpbb_smilies ( + smiley_id mediumint(8) UNSIGNED NOT NULL auto_increment, + code varbinary(150) DEFAULT '' NOT NULL, + emotion varbinary(150) DEFAULT '' NOT NULL, + smiley_url varbinary(50) DEFAULT '' NOT NULL, + smiley_width smallint(4) UNSIGNED DEFAULT '0' NOT NULL, + smiley_height smallint(4) UNSIGNED DEFAULT '0' NOT NULL, + smiley_order mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + display_on_posting tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, + PRIMARY KEY (smiley_id), + KEY display_on_post (display_on_posting) +); + + +# Table: 'phpbb_styles' +CREATE TABLE phpbb_styles ( + style_id mediumint(8) UNSIGNED NOT NULL auto_increment, + style_name blob NOT NULL, + style_copyright blob NOT NULL, + style_active tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, + style_path varbinary(100) DEFAULT '' NOT NULL, + bbcode_bitfield varbinary(255) DEFAULT 'kNg=' NOT NULL, + style_parent_id int(4) UNSIGNED DEFAULT '0' NOT NULL, + style_parent_tree blob NOT NULL, + PRIMARY KEY (style_id), + UNIQUE style_name (style_name(255)) +); + + +# Table: 'phpbb_topics' +CREATE TABLE phpbb_topics ( + topic_id mediumint(8) UNSIGNED NOT NULL auto_increment, + forum_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + icon_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + topic_attachment tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + topic_approved tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, + topic_reported tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + topic_title blob NOT NULL, + topic_poster mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + topic_time int(11) UNSIGNED DEFAULT '0' NOT NULL, + topic_time_limit int(11) UNSIGNED DEFAULT '0' NOT NULL, + topic_views mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + topic_replies mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + topic_replies_real mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + topic_status tinyint(3) DEFAULT '0' NOT NULL, + topic_type tinyint(3) DEFAULT '0' NOT NULL, + topic_first_post_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + topic_first_poster_name blob NOT NULL, + topic_first_poster_colour varbinary(6) DEFAULT '' NOT NULL, + topic_last_post_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + topic_last_poster_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + topic_last_poster_name blob NOT NULL, + topic_last_poster_colour varbinary(6) DEFAULT '' NOT NULL, + topic_last_post_subject blob NOT NULL, + topic_last_post_time int(11) UNSIGNED DEFAULT '0' NOT NULL, + topic_last_view_time int(11) UNSIGNED DEFAULT '0' NOT NULL, + topic_moved_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + topic_bumped tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + topic_bumper mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + poll_title blob NOT NULL, + poll_start int(11) UNSIGNED DEFAULT '0' NOT NULL, + poll_length int(11) UNSIGNED DEFAULT '0' NOT NULL, + poll_max_options tinyint(4) DEFAULT '1' NOT NULL, + poll_last_vote int(11) UNSIGNED DEFAULT '0' NOT NULL, + poll_vote_change tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + PRIMARY KEY (topic_id), + KEY forum_id (forum_id), + KEY forum_id_type (forum_id, topic_type), + KEY last_post_time (topic_last_post_time), + KEY topic_approved (topic_approved), + KEY forum_appr_last (forum_id, topic_approved, topic_last_post_id), + KEY fid_time_moved (forum_id, topic_last_post_time, topic_moved_id) +); + + +# Table: 'phpbb_topics_track' +CREATE TABLE phpbb_topics_track ( + user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + topic_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + forum_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + mark_time int(11) UNSIGNED DEFAULT '0' NOT NULL, + PRIMARY KEY (user_id, topic_id), + KEY topic_id (topic_id), + KEY forum_id (forum_id) +); + + +# Table: 'phpbb_topics_posted' +CREATE TABLE phpbb_topics_posted ( + user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + topic_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + topic_posted tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + PRIMARY KEY (user_id, topic_id) +); + + +# Table: 'phpbb_topics_watch' +CREATE TABLE phpbb_topics_watch ( + topic_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + notify_status tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + KEY topic_id (topic_id), + KEY user_id (user_id), + KEY notify_stat (notify_status) +); + + +# Table: 'phpbb_user_group' +CREATE TABLE phpbb_user_group ( + group_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + group_leader tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + user_pending tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, + KEY group_id (group_id), + KEY user_id (user_id), + KEY group_leader (group_leader) +); + + +# Table: 'phpbb_users' +CREATE TABLE phpbb_users ( + user_id mediumint(8) UNSIGNED NOT NULL auto_increment, + user_type tinyint(2) DEFAULT '0' NOT NULL, + group_id mediumint(8) UNSIGNED DEFAULT '3' NOT NULL, + user_permissions mediumblob NOT NULL, + user_perm_from mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + user_ip varbinary(40) DEFAULT '' NOT NULL, + user_regdate int(11) UNSIGNED DEFAULT '0' NOT NULL, + username blob NOT NULL, + username_clean blob NOT NULL, + user_password varbinary(120) DEFAULT '' NOT NULL, + user_passchg int(11) UNSIGNED DEFAULT '0' NOT NULL, + user_pass_convert tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + user_email blob NOT NULL, + user_email_hash bigint(20) DEFAULT '0' NOT NULL, + user_birthday varbinary(10) DEFAULT '' NOT NULL, + user_lastvisit int(11) UNSIGNED DEFAULT '0' NOT NULL, + user_lastmark int(11) UNSIGNED DEFAULT '0' NOT NULL, + user_lastpost_time int(11) UNSIGNED DEFAULT '0' NOT NULL, + user_lastpage blob NOT NULL, + user_last_confirm_key varbinary(10) DEFAULT '' NOT NULL, + user_last_search int(11) UNSIGNED DEFAULT '0' NOT NULL, + user_warnings tinyint(4) DEFAULT '0' NOT NULL, + user_last_warning int(11) UNSIGNED DEFAULT '0' NOT NULL, + user_login_attempts tinyint(4) DEFAULT '0' NOT NULL, + user_inactive_reason tinyint(2) DEFAULT '0' NOT NULL, + user_inactive_time int(11) UNSIGNED DEFAULT '0' NOT NULL, + user_posts mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + user_lang varbinary(30) DEFAULT '' NOT NULL, + user_timezone varbinary(100) DEFAULT 'UTC' NOT NULL, + user_dateformat varbinary(90) DEFAULT 'd M Y H:i' NOT NULL, + user_style mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + user_rank mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + user_colour varbinary(6) DEFAULT '' NOT NULL, + user_new_privmsg int(4) DEFAULT '0' NOT NULL, + user_unread_privmsg int(4) DEFAULT '0' NOT NULL, + user_last_privmsg int(11) UNSIGNED DEFAULT '0' NOT NULL, + user_message_rules tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + user_full_folder int(11) DEFAULT '-3' NOT NULL, + user_emailtime int(11) UNSIGNED DEFAULT '0' NOT NULL, + user_topic_show_days smallint(4) UNSIGNED DEFAULT '0' NOT NULL, + user_topic_sortby_type varbinary(1) DEFAULT 't' NOT NULL, + user_topic_sortby_dir varbinary(1) DEFAULT 'd' NOT NULL, + user_post_show_days smallint(4) UNSIGNED DEFAULT '0' NOT NULL, + user_post_sortby_type varbinary(1) DEFAULT 't' NOT NULL, + user_post_sortby_dir varbinary(1) DEFAULT 'a' NOT NULL, + user_notify tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + user_notify_pm tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, + user_notify_type tinyint(4) DEFAULT '0' NOT NULL, + user_allow_pm tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, + user_allow_viewonline tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, + user_allow_viewemail tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, + user_allow_massemail tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, + user_options int(11) UNSIGNED DEFAULT '230271' NOT NULL, + user_avatar varbinary(255) DEFAULT '' NOT NULL, + user_avatar_type tinyint(2) DEFAULT '0' NOT NULL, + user_avatar_width smallint(4) UNSIGNED DEFAULT '0' NOT NULL, + user_avatar_height smallint(4) UNSIGNED DEFAULT '0' NOT NULL, + user_sig mediumblob NOT NULL, + user_sig_bbcode_uid varbinary(8) DEFAULT '' NOT NULL, + user_sig_bbcode_bitfield varbinary(255) DEFAULT '' NOT NULL, + user_from blob NOT NULL, + user_icq varbinary(15) DEFAULT '' NOT NULL, + user_aim blob NOT NULL, + user_yim blob NOT NULL, + user_msnm blob NOT NULL, + user_jabber blob NOT NULL, + user_website blob NOT NULL, + user_occ blob NOT NULL, + user_interests blob NOT NULL, + user_actkey varbinary(32) DEFAULT '' NOT NULL, + user_newpasswd varbinary(120) DEFAULT '' NOT NULL, + user_form_salt varbinary(96) DEFAULT '' NOT NULL, + user_new tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, + user_reminded tinyint(4) DEFAULT '0' NOT NULL, + user_reminded_time int(11) UNSIGNED DEFAULT '0' NOT NULL, + PRIMARY KEY (user_id), + KEY user_birthday (user_birthday), + KEY user_email_hash (user_email_hash), + KEY user_type (user_type), + UNIQUE username_clean (username_clean(255)) +); + + +# Table: 'phpbb_warnings' +CREATE TABLE phpbb_warnings ( + warning_id mediumint(8) UNSIGNED NOT NULL auto_increment, + user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + post_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + log_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + warning_time int(11) UNSIGNED DEFAULT '0' NOT NULL, + PRIMARY KEY (warning_id) +); + + +# Table: 'phpbb_words' +CREATE TABLE phpbb_words ( + word_id mediumint(8) UNSIGNED NOT NULL auto_increment, + word blob NOT NULL, + replacement blob NOT NULL, + PRIMARY KEY (word_id) +); + + +# Table: 'phpbb_zebra' +CREATE TABLE phpbb_zebra ( + user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + zebra_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + friend tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + foe tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + PRIMARY KEY (user_id, zebra_id) +); diff --git a/phpBB/install/schemas/mysql_41_schema.sql b/phpBB/install/schemas/mysql_41_schema.sql index 20af6f3566..45da3284b7 100644 --- a/phpBB/install/schemas/mysql_41_schema.sql +++ b/phpBB/install/schemas/mysql_41_schema.sql @@ -1,978 +1,976 @@ -# DO NOT EDIT THIS FILE, IT IS GENERATED -# -# To change the contents of this file, edit -# phpBB/develop/create_schema_files.php and -# run it. -# Table: 'phpbb_attachments' -CREATE TABLE phpbb_attachments ( - attach_id mediumint(8) UNSIGNED NOT NULL auto_increment, - post_msg_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - topic_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - in_message tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, - poster_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - is_orphan tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, - physical_filename varchar(255) DEFAULT '' NOT NULL, - real_filename varchar(255) DEFAULT '' NOT NULL, - download_count mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - attach_comment text NOT NULL, - extension varchar(100) DEFAULT '' NOT NULL, - mimetype varchar(100) DEFAULT '' NOT NULL, - filesize int(20) UNSIGNED DEFAULT '0' NOT NULL, - filetime int(11) UNSIGNED DEFAULT '0' NOT NULL, - thumbnail tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, - PRIMARY KEY (attach_id), - KEY filetime (filetime), - KEY post_msg_id (post_msg_id), - KEY topic_id (topic_id), - KEY poster_id (poster_id), - KEY is_orphan (is_orphan) -) CHARACTER SET `utf8` COLLATE `utf8_bin`; - - -# Table: 'phpbb_acl_groups' -CREATE TABLE phpbb_acl_groups ( - group_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - forum_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - auth_option_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - auth_role_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - auth_setting tinyint(2) DEFAULT '0' NOT NULL, - KEY group_id (group_id), - KEY auth_opt_id (auth_option_id), - KEY auth_role_id (auth_role_id) -) CHARACTER SET `utf8` COLLATE `utf8_bin`; - - -# Table: 'phpbb_acl_options' -CREATE TABLE phpbb_acl_options ( - auth_option_id mediumint(8) UNSIGNED NOT NULL auto_increment, - auth_option varchar(50) DEFAULT '' NOT NULL, - is_global tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, - is_local tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, - founder_only tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, - PRIMARY KEY (auth_option_id), - UNIQUE auth_option (auth_option) -) CHARACTER SET `utf8` COLLATE `utf8_bin`; - - -# Table: 'phpbb_acl_roles' -CREATE TABLE phpbb_acl_roles ( - role_id mediumint(8) UNSIGNED NOT NULL auto_increment, - role_name varchar(255) DEFAULT '' NOT NULL, - role_description text NOT NULL, - role_type varchar(10) DEFAULT '' NOT NULL, - role_order smallint(4) UNSIGNED DEFAULT '0' NOT NULL, - PRIMARY KEY (role_id), - KEY role_type (role_type), - KEY role_order (role_order) -) CHARACTER SET `utf8` COLLATE `utf8_bin`; - - -# Table: 'phpbb_acl_roles_data' -CREATE TABLE phpbb_acl_roles_data ( - role_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - auth_option_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - auth_setting tinyint(2) DEFAULT '0' NOT NULL, - PRIMARY KEY (role_id, auth_option_id), - KEY ath_op_id (auth_option_id) -) CHARACTER SET `utf8` COLLATE `utf8_bin`; - - -# Table: 'phpbb_acl_users' -CREATE TABLE phpbb_acl_users ( - user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - forum_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - auth_option_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - auth_role_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - auth_setting tinyint(2) DEFAULT '0' NOT NULL, - KEY user_id (user_id), - KEY auth_option_id (auth_option_id), - KEY auth_role_id (auth_role_id) -) CHARACTER SET `utf8` COLLATE `utf8_bin`; - - -# Table: 'phpbb_banlist' -CREATE TABLE phpbb_banlist ( - ban_id mediumint(8) UNSIGNED NOT NULL auto_increment, - ban_userid mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - ban_ip varchar(40) DEFAULT '' NOT NULL, - ban_email varchar(100) DEFAULT '' NOT NULL, - ban_start int(11) UNSIGNED DEFAULT '0' NOT NULL, - ban_end int(11) UNSIGNED DEFAULT '0' NOT NULL, - ban_exclude tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, - ban_reason varchar(255) DEFAULT '' NOT NULL, - ban_give_reason varchar(255) DEFAULT '' NOT NULL, - PRIMARY KEY (ban_id), - KEY ban_end (ban_end), - KEY ban_user (ban_userid, ban_exclude), - KEY ban_email (ban_email, ban_exclude), - KEY ban_ip (ban_ip, ban_exclude) -) CHARACTER SET `utf8` COLLATE `utf8_bin`; - - -# Table: 'phpbb_bbcodes' -CREATE TABLE phpbb_bbcodes ( - bbcode_id smallint(4) UNSIGNED DEFAULT '0' NOT NULL, - bbcode_tag varchar(16) DEFAULT '' NOT NULL, - bbcode_helpline varchar(255) DEFAULT '' NOT NULL, - display_on_posting tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, - bbcode_match text NOT NULL, - bbcode_tpl mediumtext NOT NULL, - first_pass_match mediumtext NOT NULL, - first_pass_replace mediumtext NOT NULL, - second_pass_match mediumtext NOT NULL, - second_pass_replace mediumtext NOT NULL, - PRIMARY KEY (bbcode_id), - KEY display_on_post (display_on_posting) -) CHARACTER SET `utf8` COLLATE `utf8_bin`; - - -# Table: 'phpbb_bookmarks' -CREATE TABLE phpbb_bookmarks ( - topic_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - PRIMARY KEY (topic_id, user_id) -) CHARACTER SET `utf8` COLLATE `utf8_bin`; - - -# Table: 'phpbb_bots' -CREATE TABLE phpbb_bots ( - bot_id mediumint(8) UNSIGNED NOT NULL auto_increment, - bot_active tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, - bot_name varchar(255) DEFAULT '' NOT NULL, - user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - bot_agent varchar(255) DEFAULT '' NOT NULL, - bot_ip varchar(255) DEFAULT '' NOT NULL, - PRIMARY KEY (bot_id), - KEY bot_active (bot_active) -) CHARACTER SET `utf8` COLLATE `utf8_bin`; - - -# Table: 'phpbb_config' -CREATE TABLE phpbb_config ( - config_name varchar(255) DEFAULT '' NOT NULL, - config_value varchar(255) DEFAULT '' NOT NULL, - is_dynamic tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, - PRIMARY KEY (config_name), - KEY is_dynamic (is_dynamic) -) CHARACTER SET `utf8` COLLATE `utf8_bin`; - - -# Table: 'phpbb_confirm' -CREATE TABLE phpbb_confirm ( - confirm_id char(32) DEFAULT '' NOT NULL, - session_id char(32) DEFAULT '' NOT NULL, - confirm_type tinyint(3) DEFAULT '0' NOT NULL, - code varchar(8) DEFAULT '' NOT NULL, - seed int(10) UNSIGNED DEFAULT '0' NOT NULL, - attempts mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - PRIMARY KEY (session_id, confirm_id), - KEY confirm_type (confirm_type) -) CHARACTER SET `utf8` COLLATE `utf8_bin`; - - -# Table: 'phpbb_disallow' -CREATE TABLE phpbb_disallow ( - disallow_id mediumint(8) UNSIGNED NOT NULL auto_increment, - disallow_username varchar(255) DEFAULT '' NOT NULL, - PRIMARY KEY (disallow_id) -) CHARACTER SET `utf8` COLLATE `utf8_bin`; - - -# Table: 'phpbb_drafts' -CREATE TABLE phpbb_drafts ( - draft_id mediumint(8) UNSIGNED NOT NULL auto_increment, - user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - topic_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - forum_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - save_time int(11) UNSIGNED DEFAULT '0' NOT NULL, - draft_subject varchar(255) DEFAULT '' NOT NULL, - draft_message mediumtext NOT NULL, - PRIMARY KEY (draft_id), - KEY save_time (save_time) -) CHARACTER SET `utf8` COLLATE `utf8_bin`; - - -# Table: 'phpbb_ext' -CREATE TABLE phpbb_ext ( - ext_name varchar(255) DEFAULT '' NOT NULL, - ext_active tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, - ext_state text NOT NULL, - UNIQUE ext_name (ext_name) -) CHARACTER SET `utf8` COLLATE `utf8_bin`; - - -# Table: 'phpbb_extensions' -CREATE TABLE phpbb_extensions ( - extension_id mediumint(8) UNSIGNED NOT NULL auto_increment, - group_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - extension varchar(100) DEFAULT '' NOT NULL, - PRIMARY KEY (extension_id) -) CHARACTER SET `utf8` COLLATE `utf8_bin`; - - -# Table: 'phpbb_extension_groups' -CREATE TABLE phpbb_extension_groups ( - group_id mediumint(8) UNSIGNED NOT NULL auto_increment, - group_name varchar(255) DEFAULT '' NOT NULL, - cat_id tinyint(2) DEFAULT '0' NOT NULL, - allow_group tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, - download_mode tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, - upload_icon varchar(255) DEFAULT '' NOT NULL, - max_filesize int(20) UNSIGNED DEFAULT '0' NOT NULL, - allowed_forums text NOT NULL, - allow_in_pm tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, - PRIMARY KEY (group_id) -) CHARACTER SET `utf8` COLLATE `utf8_bin`; - - -# Table: 'phpbb_forums' -CREATE TABLE phpbb_forums ( - forum_id mediumint(8) UNSIGNED NOT NULL auto_increment, - parent_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - left_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - right_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - forum_parents mediumtext NOT NULL, - forum_name varchar(255) DEFAULT '' NOT NULL, - forum_desc text NOT NULL, - forum_desc_bitfield varchar(255) DEFAULT '' NOT NULL, - forum_desc_options int(11) UNSIGNED DEFAULT '7' NOT NULL, - forum_desc_uid varchar(8) DEFAULT '' NOT NULL, - forum_link varchar(255) DEFAULT '' NOT NULL, - forum_password varchar(40) DEFAULT '' NOT NULL, - forum_style mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - forum_image varchar(255) DEFAULT '' NOT NULL, - forum_rules text NOT NULL, - forum_rules_link varchar(255) DEFAULT '' NOT NULL, - forum_rules_bitfield varchar(255) DEFAULT '' NOT NULL, - forum_rules_options int(11) UNSIGNED DEFAULT '7' NOT NULL, - forum_rules_uid varchar(8) DEFAULT '' NOT NULL, - forum_topics_per_page tinyint(4) DEFAULT '0' NOT NULL, - forum_type tinyint(4) DEFAULT '0' NOT NULL, - forum_status tinyint(4) DEFAULT '0' NOT NULL, - forum_posts mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - forum_topics mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - forum_topics_real mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - forum_last_post_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - forum_last_poster_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - forum_last_post_subject varchar(255) DEFAULT '' NOT NULL, - forum_last_post_time int(11) UNSIGNED DEFAULT '0' NOT NULL, - forum_last_poster_name varchar(255) DEFAULT '' NOT NULL, - forum_last_poster_colour varchar(6) DEFAULT '' NOT NULL, - forum_flags tinyint(4) DEFAULT '32' NOT NULL, - forum_options int(20) UNSIGNED DEFAULT '0' NOT NULL, - display_subforum_list tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, - display_on_index tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, - enable_indexing tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, - enable_icons tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, - enable_prune tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, - prune_next int(11) UNSIGNED DEFAULT '0' NOT NULL, - prune_days mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - prune_viewed mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - prune_freq mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - PRIMARY KEY (forum_id), - KEY left_right_id (left_id, right_id), - KEY forum_lastpost_id (forum_last_post_id) -) CHARACTER SET `utf8` COLLATE `utf8_bin`; - - -# Table: 'phpbb_forums_access' -CREATE TABLE phpbb_forums_access ( - forum_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - session_id char(32) DEFAULT '' NOT NULL, - PRIMARY KEY (forum_id, user_id, session_id) -) CHARACTER SET `utf8` COLLATE `utf8_bin`; - - -# Table: 'phpbb_forums_track' -CREATE TABLE phpbb_forums_track ( - user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - forum_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - mark_time int(11) UNSIGNED DEFAULT '0' NOT NULL, - PRIMARY KEY (user_id, forum_id) -) CHARACTER SET `utf8` COLLATE `utf8_bin`; - - -# Table: 'phpbb_forums_watch' -CREATE TABLE phpbb_forums_watch ( - forum_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - notify_status tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, - KEY forum_id (forum_id), - KEY user_id (user_id), - KEY notify_stat (notify_status) -) CHARACTER SET `utf8` COLLATE `utf8_bin`; - - -# Table: 'phpbb_groups' -CREATE TABLE phpbb_groups ( - group_id mediumint(8) UNSIGNED NOT NULL auto_increment, - group_type tinyint(4) DEFAULT '1' NOT NULL, - group_founder_manage tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, - group_skip_auth tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, - group_name varchar(255) DEFAULT '' NOT NULL, - group_desc text NOT NULL, - group_desc_bitfield varchar(255) DEFAULT '' NOT NULL, - group_desc_options int(11) UNSIGNED DEFAULT '7' NOT NULL, - group_desc_uid varchar(8) DEFAULT '' NOT NULL, - group_display tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, - group_avatar varchar(255) DEFAULT '' NOT NULL, - group_avatar_type tinyint(2) DEFAULT '0' NOT NULL, - group_avatar_width smallint(4) UNSIGNED DEFAULT '0' NOT NULL, - group_avatar_height smallint(4) UNSIGNED DEFAULT '0' NOT NULL, - group_rank mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - group_colour varchar(6) DEFAULT '' NOT NULL, - group_sig_chars mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - group_receive_pm tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, - group_message_limit mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - group_max_recipients mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - group_legend mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - group_teampage mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - PRIMARY KEY (group_id), - KEY group_legend_name (group_legend, group_name) -) CHARACTER SET `utf8` COLLATE `utf8_bin`; - - -# Table: 'phpbb_icons' -CREATE TABLE phpbb_icons ( - icons_id mediumint(8) UNSIGNED NOT NULL auto_increment, - icons_url varchar(255) DEFAULT '' NOT NULL, - icons_width tinyint(4) DEFAULT '0' NOT NULL, - icons_height tinyint(4) DEFAULT '0' NOT NULL, - icons_order mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - display_on_posting tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, - PRIMARY KEY (icons_id), - KEY display_on_posting (display_on_posting) -) CHARACTER SET `utf8` COLLATE `utf8_bin`; - - -# Table: 'phpbb_lang' -CREATE TABLE phpbb_lang ( - lang_id tinyint(4) NOT NULL auto_increment, - lang_iso varchar(30) DEFAULT '' NOT NULL, - lang_dir varchar(30) DEFAULT '' NOT NULL, - lang_english_name varchar(100) DEFAULT '' NOT NULL, - lang_local_name varchar(255) DEFAULT '' NOT NULL, - lang_author varchar(255) DEFAULT '' NOT NULL, - PRIMARY KEY (lang_id), - KEY lang_iso (lang_iso) -) CHARACTER SET `utf8` COLLATE `utf8_bin`; - - -# Table: 'phpbb_log' -CREATE TABLE phpbb_log ( - log_id mediumint(8) UNSIGNED NOT NULL auto_increment, - log_type tinyint(4) DEFAULT '0' NOT NULL, - user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - forum_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - topic_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - reportee_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - log_ip varchar(40) DEFAULT '' NOT NULL, - log_time int(11) UNSIGNED DEFAULT '0' NOT NULL, - log_operation text NOT NULL, - log_data mediumtext NOT NULL, - PRIMARY KEY (log_id), - KEY log_type (log_type), - KEY log_time (log_time), - KEY forum_id (forum_id), - KEY topic_id (topic_id), - KEY reportee_id (reportee_id), - KEY user_id (user_id) -) CHARACTER SET `utf8` COLLATE `utf8_bin`; - - -# Table: 'phpbb_login_attempts' -CREATE TABLE phpbb_login_attempts ( - attempt_ip varchar(40) DEFAULT '' NOT NULL, - attempt_browser varchar(150) DEFAULT '' NOT NULL, - attempt_forwarded_for varchar(255) DEFAULT '' NOT NULL, - attempt_time int(11) UNSIGNED DEFAULT '0' NOT NULL, - user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - username varchar(255) DEFAULT '0' NOT NULL, - username_clean varchar(255) DEFAULT '0' NOT NULL, - KEY att_ip (attempt_ip, attempt_time), - KEY att_for (attempt_forwarded_for, attempt_time), - KEY att_time (attempt_time), - KEY user_id (user_id) -) CHARACTER SET `utf8` COLLATE `utf8_bin`; - - -# Table: 'phpbb_moderator_cache' -CREATE TABLE phpbb_moderator_cache ( - forum_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - username varchar(255) DEFAULT '' NOT NULL, - group_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - group_name varchar(255) DEFAULT '' NOT NULL, - display_on_index tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, - KEY disp_idx (display_on_index), - KEY forum_id (forum_id) -) CHARACTER SET `utf8` COLLATE `utf8_bin`; - - -# Table: 'phpbb_modules' -CREATE TABLE phpbb_modules ( - module_id mediumint(8) UNSIGNED NOT NULL auto_increment, - module_enabled tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, - module_display tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, - module_basename varchar(255) DEFAULT '' NOT NULL, - module_class varchar(10) DEFAULT '' NOT NULL, - parent_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - left_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - right_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - module_langname varchar(255) DEFAULT '' NOT NULL, - module_mode varchar(255) DEFAULT '' NOT NULL, - module_auth varchar(255) DEFAULT '' NOT NULL, - PRIMARY KEY (module_id), - KEY left_right_id (left_id, right_id), - KEY module_enabled (module_enabled), - KEY class_left_id (module_class, left_id) -) CHARACTER SET `utf8` COLLATE `utf8_bin`; - - -# Table: 'phpbb_poll_options' -CREATE TABLE phpbb_poll_options ( - poll_option_id tinyint(4) DEFAULT '0' NOT NULL, - topic_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - poll_option_text text NOT NULL, - poll_option_total mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - KEY poll_opt_id (poll_option_id), - KEY topic_id (topic_id) -) CHARACTER SET `utf8` COLLATE `utf8_bin`; - - -# Table: 'phpbb_poll_votes' -CREATE TABLE phpbb_poll_votes ( - topic_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - poll_option_id tinyint(4) DEFAULT '0' NOT NULL, - vote_user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - vote_user_ip varchar(40) DEFAULT '' NOT NULL, - KEY topic_id (topic_id), - KEY vote_user_id (vote_user_id), - KEY vote_user_ip (vote_user_ip) -) CHARACTER SET `utf8` COLLATE `utf8_bin`; - - -# Table: 'phpbb_posts' -CREATE TABLE phpbb_posts ( - post_id mediumint(8) UNSIGNED NOT NULL auto_increment, - topic_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - forum_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - poster_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - icon_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - poster_ip varchar(40) DEFAULT '' NOT NULL, - post_time int(11) UNSIGNED DEFAULT '0' NOT NULL, - post_approved tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, - post_reported tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, - enable_bbcode tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, - enable_smilies tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, - enable_magic_url tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, - enable_sig tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, - post_username varchar(255) DEFAULT '' NOT NULL, - post_subject varchar(255) DEFAULT '' NOT NULL COLLATE utf8_unicode_ci, - post_text mediumtext NOT NULL, - post_checksum varchar(32) DEFAULT '' NOT NULL, - post_attachment tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, - bbcode_bitfield varchar(255) DEFAULT '' NOT NULL, - bbcode_uid varchar(8) DEFAULT '' NOT NULL, - post_postcount tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, - post_edit_time int(11) UNSIGNED DEFAULT '0' NOT NULL, - post_edit_reason varchar(255) DEFAULT '' NOT NULL, - post_edit_user mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - post_edit_count smallint(4) UNSIGNED DEFAULT '0' NOT NULL, - post_edit_locked tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, - PRIMARY KEY (post_id), - KEY forum_id (forum_id), - KEY topic_id (topic_id), - KEY poster_ip (poster_ip), - KEY poster_id (poster_id), - KEY post_approved (post_approved), - KEY post_username (post_username), - KEY tid_post_time (topic_id, post_time) -) CHARACTER SET `utf8` COLLATE `utf8_bin`; - - -# Table: 'phpbb_privmsgs' -CREATE TABLE phpbb_privmsgs ( - msg_id mediumint(8) UNSIGNED NOT NULL auto_increment, - root_level mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - author_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - icon_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - author_ip varchar(40) DEFAULT '' NOT NULL, - message_time int(11) UNSIGNED DEFAULT '0' NOT NULL, - enable_bbcode tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, - enable_smilies tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, - enable_magic_url tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, - enable_sig tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, - message_subject varchar(255) DEFAULT '' NOT NULL, - message_text mediumtext NOT NULL, - message_edit_reason varchar(255) DEFAULT '' NOT NULL, - message_edit_user mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - message_attachment tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, - bbcode_bitfield varchar(255) DEFAULT '' NOT NULL, - bbcode_uid varchar(8) DEFAULT '' NOT NULL, - message_edit_time int(11) UNSIGNED DEFAULT '0' NOT NULL, - message_edit_count smallint(4) UNSIGNED DEFAULT '0' NOT NULL, - to_address text NOT NULL, - bcc_address text NOT NULL, - message_reported tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, - PRIMARY KEY (msg_id), - KEY author_ip (author_ip), - KEY message_time (message_time), - KEY author_id (author_id), - KEY root_level (root_level) -) CHARACTER SET `utf8` COLLATE `utf8_bin`; - - -# Table: 'phpbb_privmsgs_folder' -CREATE TABLE phpbb_privmsgs_folder ( - folder_id mediumint(8) UNSIGNED NOT NULL auto_increment, - user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - folder_name varchar(255) DEFAULT '' NOT NULL, - pm_count mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - PRIMARY KEY (folder_id), - KEY user_id (user_id) -) CHARACTER SET `utf8` COLLATE `utf8_bin`; - - -# Table: 'phpbb_privmsgs_rules' -CREATE TABLE phpbb_privmsgs_rules ( - rule_id mediumint(8) UNSIGNED NOT NULL auto_increment, - user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - rule_check mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - rule_connection mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - rule_string varchar(255) DEFAULT '' NOT NULL, - rule_user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - rule_group_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - rule_action mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - rule_folder_id int(11) DEFAULT '0' NOT NULL, - PRIMARY KEY (rule_id), - KEY user_id (user_id) -) CHARACTER SET `utf8` COLLATE `utf8_bin`; - - -# Table: 'phpbb_privmsgs_to' -CREATE TABLE phpbb_privmsgs_to ( - msg_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - author_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - pm_deleted tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, - pm_new tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, - pm_unread tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, - pm_replied tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, - pm_marked tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, - pm_forwarded tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, - folder_id int(11) DEFAULT '0' NOT NULL, - KEY msg_id (msg_id), - KEY author_id (author_id), - KEY usr_flder_id (user_id, folder_id) -) CHARACTER SET `utf8` COLLATE `utf8_bin`; - - -# Table: 'phpbb_profile_fields' -CREATE TABLE phpbb_profile_fields ( - field_id mediumint(8) UNSIGNED NOT NULL auto_increment, - field_name varchar(255) DEFAULT '' NOT NULL, - field_type tinyint(4) DEFAULT '0' NOT NULL, - field_ident varchar(20) DEFAULT '' NOT NULL, - field_length varchar(20) DEFAULT '' NOT NULL, - field_minlen varchar(255) DEFAULT '' NOT NULL, - field_maxlen varchar(255) DEFAULT '' NOT NULL, - field_novalue varchar(255) DEFAULT '' NOT NULL, - field_default_value varchar(255) DEFAULT '' NOT NULL, - field_validation varchar(20) DEFAULT '' NOT NULL, - field_required tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, - field_show_novalue tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, - field_show_on_reg tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, - field_show_on_pm tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, - field_show_on_vt tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, - field_show_profile tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, - field_hide tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, - field_no_view tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, - field_active tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, - field_order mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - PRIMARY KEY (field_id), - KEY fld_type (field_type), - KEY fld_ordr (field_order) -) CHARACTER SET `utf8` COLLATE `utf8_bin`; - - -# Table: 'phpbb_profile_fields_data' -CREATE TABLE phpbb_profile_fields_data ( - user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - PRIMARY KEY (user_id) -) CHARACTER SET `utf8` COLLATE `utf8_bin`; - - -# Table: 'phpbb_profile_fields_lang' -CREATE TABLE phpbb_profile_fields_lang ( - field_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - lang_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - option_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - field_type tinyint(4) DEFAULT '0' NOT NULL, - lang_value varchar(255) DEFAULT '' NOT NULL, - PRIMARY KEY (field_id, lang_id, option_id) -) CHARACTER SET `utf8` COLLATE `utf8_bin`; - - -# Table: 'phpbb_profile_lang' -CREATE TABLE phpbb_profile_lang ( - field_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - lang_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - lang_name varchar(255) DEFAULT '' NOT NULL, - lang_explain text NOT NULL, - lang_default_value varchar(255) DEFAULT '' NOT NULL, - PRIMARY KEY (field_id, lang_id) -) CHARACTER SET `utf8` COLLATE `utf8_bin`; - - -# Table: 'phpbb_ranks' -CREATE TABLE phpbb_ranks ( - rank_id mediumint(8) UNSIGNED NOT NULL auto_increment, - rank_title varchar(255) DEFAULT '' NOT NULL, - rank_min mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - rank_special tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, - rank_image varchar(255) DEFAULT '' NOT NULL, - PRIMARY KEY (rank_id) -) CHARACTER SET `utf8` COLLATE `utf8_bin`; - - -# Table: 'phpbb_reports' -CREATE TABLE phpbb_reports ( - report_id mediumint(8) UNSIGNED NOT NULL auto_increment, - reason_id smallint(4) UNSIGNED DEFAULT '0' NOT NULL, - post_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - pm_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - user_notify tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, - report_closed tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, - report_time int(11) UNSIGNED DEFAULT '0' NOT NULL, - report_text mediumtext NOT NULL, - reported_post_text mediumtext NOT NULL, - PRIMARY KEY (report_id), - KEY post_id (post_id), - KEY pm_id (pm_id) -) CHARACTER SET `utf8` COLLATE `utf8_bin`; - - -# Table: 'phpbb_reports_reasons' -CREATE TABLE phpbb_reports_reasons ( - reason_id smallint(4) UNSIGNED NOT NULL auto_increment, - reason_title varchar(255) DEFAULT '' NOT NULL, - reason_description mediumtext NOT NULL, - reason_order smallint(4) UNSIGNED DEFAULT '0' NOT NULL, - PRIMARY KEY (reason_id) -) CHARACTER SET `utf8` COLLATE `utf8_bin`; - - -# Table: 'phpbb_search_results' -CREATE TABLE phpbb_search_results ( - search_key varchar(32) DEFAULT '' NOT NULL, - search_time int(11) UNSIGNED DEFAULT '0' NOT NULL, - search_keywords mediumtext NOT NULL, - search_authors mediumtext NOT NULL, - PRIMARY KEY (search_key) -) CHARACTER SET `utf8` COLLATE `utf8_bin`; - - -# Table: 'phpbb_search_wordlist' -CREATE TABLE phpbb_search_wordlist ( - word_id mediumint(8) UNSIGNED NOT NULL auto_increment, - word_text varchar(255) DEFAULT '' NOT NULL, - word_common tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, - word_count mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - PRIMARY KEY (word_id), - UNIQUE wrd_txt (word_text), - KEY wrd_cnt (word_count) -) CHARACTER SET `utf8` COLLATE `utf8_bin`; - - -# Table: 'phpbb_search_wordmatch' -CREATE TABLE phpbb_search_wordmatch ( - post_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - word_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - title_match tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, - UNIQUE unq_mtch (word_id, post_id, title_match), - KEY word_id (word_id), - KEY post_id (post_id) -) CHARACTER SET `utf8` COLLATE `utf8_bin`; - - -# Table: 'phpbb_sessions' -CREATE TABLE phpbb_sessions ( - session_id char(32) DEFAULT '' NOT NULL, - session_user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - session_forum_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - session_last_visit int(11) UNSIGNED DEFAULT '0' NOT NULL, - session_start int(11) UNSIGNED DEFAULT '0' NOT NULL, - session_time int(11) UNSIGNED DEFAULT '0' NOT NULL, - session_ip varchar(40) DEFAULT '' NOT NULL, - session_browser varchar(150) DEFAULT '' NOT NULL, - session_forwarded_for varchar(255) DEFAULT '' NOT NULL, - session_page varchar(255) DEFAULT '' NOT NULL, - session_viewonline tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, - session_autologin tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, - session_admin tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, - PRIMARY KEY (session_id), - KEY session_time (session_time), - KEY session_user_id (session_user_id), - KEY session_fid (session_forum_id) -) CHARACTER SET `utf8` COLLATE `utf8_bin`; - - -# Table: 'phpbb_sessions_keys' -CREATE TABLE phpbb_sessions_keys ( - key_id char(32) DEFAULT '' NOT NULL, - user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - last_ip varchar(40) DEFAULT '' NOT NULL, - last_login int(11) UNSIGNED DEFAULT '0' NOT NULL, - PRIMARY KEY (key_id, user_id), - KEY last_login (last_login) -) CHARACTER SET `utf8` COLLATE `utf8_bin`; - - -# Table: 'phpbb_sitelist' -CREATE TABLE phpbb_sitelist ( - site_id mediumint(8) UNSIGNED NOT NULL auto_increment, - site_ip varchar(40) DEFAULT '' NOT NULL, - site_hostname varchar(255) DEFAULT '' NOT NULL, - ip_exclude tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, - PRIMARY KEY (site_id) -) CHARACTER SET `utf8` COLLATE `utf8_bin`; - - -# Table: 'phpbb_smilies' -CREATE TABLE phpbb_smilies ( - smiley_id mediumint(8) UNSIGNED NOT NULL auto_increment, - code varchar(50) DEFAULT '' NOT NULL, - emotion varchar(50) DEFAULT '' NOT NULL, - smiley_url varchar(50) DEFAULT '' NOT NULL, - smiley_width smallint(4) UNSIGNED DEFAULT '0' NOT NULL, - smiley_height smallint(4) UNSIGNED DEFAULT '0' NOT NULL, - smiley_order mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - display_on_posting tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, - PRIMARY KEY (smiley_id), - KEY display_on_post (display_on_posting) -) CHARACTER SET `utf8` COLLATE `utf8_bin`; - - -# Table: 'phpbb_styles' -CREATE TABLE phpbb_styles ( - style_id mediumint(8) UNSIGNED NOT NULL auto_increment, - style_name varchar(255) DEFAULT '' NOT NULL, - style_copyright varchar(255) DEFAULT '' NOT NULL, - style_active tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, - style_path varchar(100) DEFAULT '' NOT NULL, - bbcode_bitfield varchar(255) DEFAULT 'kNg=' NOT NULL, - style_parent_id int(4) UNSIGNED DEFAULT '0' NOT NULL, - style_parent_tree text NOT NULL, - PRIMARY KEY (style_id), - UNIQUE style_name (style_name) -) CHARACTER SET `utf8` COLLATE `utf8_bin`; - - -# Table: 'phpbb_topics' -CREATE TABLE phpbb_topics ( - topic_id mediumint(8) UNSIGNED NOT NULL auto_increment, - forum_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - icon_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - topic_attachment tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, - topic_approved tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, - topic_reported tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, - topic_title varchar(255) DEFAULT '' NOT NULL COLLATE utf8_unicode_ci, - topic_poster mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - topic_time int(11) UNSIGNED DEFAULT '0' NOT NULL, - topic_time_limit int(11) UNSIGNED DEFAULT '0' NOT NULL, - topic_views mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - topic_replies mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - topic_replies_real mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - topic_status tinyint(3) DEFAULT '0' NOT NULL, - topic_type tinyint(3) DEFAULT '0' NOT NULL, - topic_first_post_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - topic_first_poster_name varchar(255) DEFAULT '' NOT NULL, - topic_first_poster_colour varchar(6) DEFAULT '' NOT NULL, - topic_last_post_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - topic_last_poster_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - topic_last_poster_name varchar(255) DEFAULT '' NOT NULL, - topic_last_poster_colour varchar(6) DEFAULT '' NOT NULL, - topic_last_post_subject varchar(255) DEFAULT '' NOT NULL, - topic_last_post_time int(11) UNSIGNED DEFAULT '0' NOT NULL, - topic_last_view_time int(11) UNSIGNED DEFAULT '0' NOT NULL, - topic_moved_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - topic_bumped tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, - topic_bumper mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - poll_title varchar(255) DEFAULT '' NOT NULL, - poll_start int(11) UNSIGNED DEFAULT '0' NOT NULL, - poll_length int(11) UNSIGNED DEFAULT '0' NOT NULL, - poll_max_options tinyint(4) DEFAULT '1' NOT NULL, - poll_last_vote int(11) UNSIGNED DEFAULT '0' NOT NULL, - poll_vote_change tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, - PRIMARY KEY (topic_id), - KEY forum_id (forum_id), - KEY forum_id_type (forum_id, topic_type), - KEY last_post_time (topic_last_post_time), - KEY topic_approved (topic_approved), - KEY forum_appr_last (forum_id, topic_approved, topic_last_post_id), - KEY fid_time_moved (forum_id, topic_last_post_time, topic_moved_id) -) CHARACTER SET `utf8` COLLATE `utf8_bin`; - - -# Table: 'phpbb_topics_track' -CREATE TABLE phpbb_topics_track ( - user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - topic_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - forum_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - mark_time int(11) UNSIGNED DEFAULT '0' NOT NULL, - PRIMARY KEY (user_id, topic_id), - KEY topic_id (topic_id), - KEY forum_id (forum_id) -) CHARACTER SET `utf8` COLLATE `utf8_bin`; - - -# Table: 'phpbb_topics_posted' -CREATE TABLE phpbb_topics_posted ( - user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - topic_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - topic_posted tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, - PRIMARY KEY (user_id, topic_id) -) CHARACTER SET `utf8` COLLATE `utf8_bin`; - - -# Table: 'phpbb_topics_watch' -CREATE TABLE phpbb_topics_watch ( - topic_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - notify_status tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, - KEY topic_id (topic_id), - KEY user_id (user_id), - KEY notify_stat (notify_status) -) CHARACTER SET `utf8` COLLATE `utf8_bin`; - - -# Table: 'phpbb_user_group' -CREATE TABLE phpbb_user_group ( - group_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - group_leader tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, - user_pending tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, - KEY group_id (group_id), - KEY user_id (user_id), - KEY group_leader (group_leader) -) CHARACTER SET `utf8` COLLATE `utf8_bin`; - - -# Table: 'phpbb_users' -CREATE TABLE phpbb_users ( - user_id mediumint(8) UNSIGNED NOT NULL auto_increment, - user_type tinyint(2) DEFAULT '0' NOT NULL, - group_id mediumint(8) UNSIGNED DEFAULT '3' NOT NULL, - user_permissions mediumtext NOT NULL, - user_perm_from mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - user_ip varchar(40) DEFAULT '' NOT NULL, - user_regdate int(11) UNSIGNED DEFAULT '0' NOT NULL, - username varchar(255) DEFAULT '' NOT NULL, - username_clean varchar(255) DEFAULT '' NOT NULL, - user_password varchar(40) DEFAULT '' NOT NULL, - user_passchg int(11) UNSIGNED DEFAULT '0' NOT NULL, - user_pass_convert tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, - user_email varchar(100) DEFAULT '' NOT NULL, - user_email_hash bigint(20) DEFAULT '0' NOT NULL, - user_birthday varchar(10) DEFAULT '' NOT NULL, - user_lastvisit int(11) UNSIGNED DEFAULT '0' NOT NULL, - user_lastmark int(11) UNSIGNED DEFAULT '0' NOT NULL, - user_lastpost_time int(11) UNSIGNED DEFAULT '0' NOT NULL, - user_lastpage varchar(200) DEFAULT '' NOT NULL, - user_last_confirm_key varchar(10) DEFAULT '' NOT NULL, - user_last_search int(11) UNSIGNED DEFAULT '0' NOT NULL, - user_warnings tinyint(4) DEFAULT '0' NOT NULL, - user_last_warning int(11) UNSIGNED DEFAULT '0' NOT NULL, - user_login_attempts tinyint(4) DEFAULT '0' NOT NULL, - user_inactive_reason tinyint(2) DEFAULT '0' NOT NULL, - user_inactive_time int(11) UNSIGNED DEFAULT '0' NOT NULL, - user_posts mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - user_lang varchar(30) DEFAULT '' NOT NULL, - user_timezone varchar(100) DEFAULT 'UTC' NOT NULL, - user_dateformat varchar(30) DEFAULT 'd M Y H:i' NOT NULL, - user_style mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - user_rank mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - user_colour varchar(6) DEFAULT '' NOT NULL, - user_new_privmsg int(4) DEFAULT '0' NOT NULL, - user_unread_privmsg int(4) DEFAULT '0' NOT NULL, - user_last_privmsg int(11) UNSIGNED DEFAULT '0' NOT NULL, - user_message_rules tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, - user_full_folder int(11) DEFAULT '-3' NOT NULL, - user_emailtime int(11) UNSIGNED DEFAULT '0' NOT NULL, - user_topic_show_days smallint(4) UNSIGNED DEFAULT '0' NOT NULL, - user_topic_sortby_type varchar(1) DEFAULT 't' NOT NULL, - user_topic_sortby_dir varchar(1) DEFAULT 'd' NOT NULL, - user_post_show_days smallint(4) UNSIGNED DEFAULT '0' NOT NULL, - user_post_sortby_type varchar(1) DEFAULT 't' NOT NULL, - user_post_sortby_dir varchar(1) DEFAULT 'a' NOT NULL, - user_notify tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, - user_notify_pm tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, - user_notify_type tinyint(4) DEFAULT '0' NOT NULL, - user_allow_pm tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, - user_allow_viewonline tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, - user_allow_viewemail tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, - user_allow_massemail tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, - user_options int(11) UNSIGNED DEFAULT '230271' NOT NULL, - user_avatar varchar(255) DEFAULT '' NOT NULL, - user_avatar_type tinyint(2) DEFAULT '0' NOT NULL, - user_avatar_width smallint(4) UNSIGNED DEFAULT '0' NOT NULL, - user_avatar_height smallint(4) UNSIGNED DEFAULT '0' NOT NULL, - user_sig mediumtext NOT NULL, - user_sig_bbcode_uid varchar(8) DEFAULT '' NOT NULL, - user_sig_bbcode_bitfield varchar(255) DEFAULT '' NOT NULL, - user_from varchar(100) DEFAULT '' NOT NULL, - user_icq varchar(15) DEFAULT '' NOT NULL, - user_aim varchar(255) DEFAULT '' NOT NULL, - user_yim varchar(255) DEFAULT '' NOT NULL, - user_msnm varchar(255) DEFAULT '' NOT NULL, - user_jabber varchar(255) DEFAULT '' NOT NULL, - user_website varchar(200) DEFAULT '' NOT NULL, - user_occ text NOT NULL, - user_interests text NOT NULL, - user_actkey varchar(32) DEFAULT '' NOT NULL, - user_newpasswd varchar(40) DEFAULT '' NOT NULL, - user_form_salt varchar(32) DEFAULT '' NOT NULL, - user_new tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, - user_reminded tinyint(4) DEFAULT '0' NOT NULL, - user_reminded_time int(11) UNSIGNED DEFAULT '0' NOT NULL, - PRIMARY KEY (user_id), - KEY user_birthday (user_birthday), - KEY user_email_hash (user_email_hash), - KEY user_type (user_type), - UNIQUE username_clean (username_clean) -) CHARACTER SET `utf8` COLLATE `utf8_bin`; - - -# Table: 'phpbb_warnings' -CREATE TABLE phpbb_warnings ( - warning_id mediumint(8) UNSIGNED NOT NULL auto_increment, - user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - post_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - log_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - warning_time int(11) UNSIGNED DEFAULT '0' NOT NULL, - PRIMARY KEY (warning_id) -) CHARACTER SET `utf8` COLLATE `utf8_bin`; - - -# Table: 'phpbb_words' -CREATE TABLE phpbb_words ( - word_id mediumint(8) UNSIGNED NOT NULL auto_increment, - word varchar(255) DEFAULT '' NOT NULL, - replacement varchar(255) DEFAULT '' NOT NULL, - PRIMARY KEY (word_id) -) CHARACTER SET `utf8` COLLATE `utf8_bin`; - - -# Table: 'phpbb_zebra' -CREATE TABLE phpbb_zebra ( - user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - zebra_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - friend tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, - foe tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, - PRIMARY KEY (user_id, zebra_id) -) CHARACTER SET `utf8` COLLATE `utf8_bin`; - - +# DO NOT EDIT THIS FILE, IT IS GENERATED +# +# To change the contents of this file, edit +# phpBB/develop/create_schema_files.php and +# run it. +# Table: 'phpbb_attachments' +CREATE TABLE phpbb_attachments ( + attach_id mediumint(8) UNSIGNED NOT NULL auto_increment, + post_msg_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + topic_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + in_message tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + poster_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + is_orphan tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, + physical_filename varchar(255) DEFAULT '' NOT NULL, + real_filename varchar(255) DEFAULT '' NOT NULL, + download_count mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + attach_comment text NOT NULL, + extension varchar(100) DEFAULT '' NOT NULL, + mimetype varchar(100) DEFAULT '' NOT NULL, + filesize int(20) UNSIGNED DEFAULT '0' NOT NULL, + filetime int(11) UNSIGNED DEFAULT '0' NOT NULL, + thumbnail tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + PRIMARY KEY (attach_id), + KEY filetime (filetime), + KEY post_msg_id (post_msg_id), + KEY topic_id (topic_id), + KEY poster_id (poster_id), + KEY is_orphan (is_orphan) +) CHARACTER SET `utf8` COLLATE `utf8_bin`; + + +# Table: 'phpbb_acl_groups' +CREATE TABLE phpbb_acl_groups ( + group_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + forum_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + auth_option_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + auth_role_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + auth_setting tinyint(2) DEFAULT '0' NOT NULL, + KEY group_id (group_id), + KEY auth_opt_id (auth_option_id), + KEY auth_role_id (auth_role_id) +) CHARACTER SET `utf8` COLLATE `utf8_bin`; + + +# Table: 'phpbb_acl_options' +CREATE TABLE phpbb_acl_options ( + auth_option_id mediumint(8) UNSIGNED NOT NULL auto_increment, + auth_option varchar(50) DEFAULT '' NOT NULL, + is_global tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + is_local tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + founder_only tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + PRIMARY KEY (auth_option_id), + UNIQUE auth_option (auth_option) +) CHARACTER SET `utf8` COLLATE `utf8_bin`; + + +# Table: 'phpbb_acl_roles' +CREATE TABLE phpbb_acl_roles ( + role_id mediumint(8) UNSIGNED NOT NULL auto_increment, + role_name varchar(255) DEFAULT '' NOT NULL, + role_description text NOT NULL, + role_type varchar(10) DEFAULT '' NOT NULL, + role_order smallint(4) UNSIGNED DEFAULT '0' NOT NULL, + PRIMARY KEY (role_id), + KEY role_type (role_type), + KEY role_order (role_order) +) CHARACTER SET `utf8` COLLATE `utf8_bin`; + + +# Table: 'phpbb_acl_roles_data' +CREATE TABLE phpbb_acl_roles_data ( + role_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + auth_option_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + auth_setting tinyint(2) DEFAULT '0' NOT NULL, + PRIMARY KEY (role_id, auth_option_id), + KEY ath_op_id (auth_option_id) +) CHARACTER SET `utf8` COLLATE `utf8_bin`; + + +# Table: 'phpbb_acl_users' +CREATE TABLE phpbb_acl_users ( + user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + forum_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + auth_option_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + auth_role_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + auth_setting tinyint(2) DEFAULT '0' NOT NULL, + KEY user_id (user_id), + KEY auth_option_id (auth_option_id), + KEY auth_role_id (auth_role_id) +) CHARACTER SET `utf8` COLLATE `utf8_bin`; + + +# Table: 'phpbb_banlist' +CREATE TABLE phpbb_banlist ( + ban_id mediumint(8) UNSIGNED NOT NULL auto_increment, + ban_userid mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + ban_ip varchar(40) DEFAULT '' NOT NULL, + ban_email varchar(100) DEFAULT '' NOT NULL, + ban_start int(11) UNSIGNED DEFAULT '0' NOT NULL, + ban_end int(11) UNSIGNED DEFAULT '0' NOT NULL, + ban_exclude tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + ban_reason varchar(255) DEFAULT '' NOT NULL, + ban_give_reason varchar(255) DEFAULT '' NOT NULL, + PRIMARY KEY (ban_id), + KEY ban_end (ban_end), + KEY ban_user (ban_userid, ban_exclude), + KEY ban_email (ban_email, ban_exclude), + KEY ban_ip (ban_ip, ban_exclude) +) CHARACTER SET `utf8` COLLATE `utf8_bin`; + + +# Table: 'phpbb_bbcodes' +CREATE TABLE phpbb_bbcodes ( + bbcode_id smallint(4) UNSIGNED DEFAULT '0' NOT NULL, + bbcode_tag varchar(16) DEFAULT '' NOT NULL, + bbcode_helpline varchar(255) DEFAULT '' NOT NULL, + display_on_posting tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + bbcode_match text NOT NULL, + bbcode_tpl mediumtext NOT NULL, + first_pass_match mediumtext NOT NULL, + first_pass_replace mediumtext NOT NULL, + second_pass_match mediumtext NOT NULL, + second_pass_replace mediumtext NOT NULL, + PRIMARY KEY (bbcode_id), + KEY display_on_post (display_on_posting) +) CHARACTER SET `utf8` COLLATE `utf8_bin`; + + +# Table: 'phpbb_bookmarks' +CREATE TABLE phpbb_bookmarks ( + topic_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + PRIMARY KEY (topic_id, user_id) +) CHARACTER SET `utf8` COLLATE `utf8_bin`; + + +# Table: 'phpbb_bots' +CREATE TABLE phpbb_bots ( + bot_id mediumint(8) UNSIGNED NOT NULL auto_increment, + bot_active tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, + bot_name varchar(255) DEFAULT '' NOT NULL, + user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + bot_agent varchar(255) DEFAULT '' NOT NULL, + bot_ip varchar(255) DEFAULT '' NOT NULL, + PRIMARY KEY (bot_id), + KEY bot_active (bot_active) +) CHARACTER SET `utf8` COLLATE `utf8_bin`; + + +# Table: 'phpbb_config' +CREATE TABLE phpbb_config ( + config_name varchar(255) DEFAULT '' NOT NULL, + config_value varchar(255) DEFAULT '' NOT NULL, + is_dynamic tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + PRIMARY KEY (config_name), + KEY is_dynamic (is_dynamic) +) CHARACTER SET `utf8` COLLATE `utf8_bin`; + + +# Table: 'phpbb_confirm' +CREATE TABLE phpbb_confirm ( + confirm_id char(32) DEFAULT '' NOT NULL, + session_id char(32) DEFAULT '' NOT NULL, + confirm_type tinyint(3) DEFAULT '0' NOT NULL, + code varchar(8) DEFAULT '' NOT NULL, + seed int(10) UNSIGNED DEFAULT '0' NOT NULL, + attempts mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + PRIMARY KEY (session_id, confirm_id), + KEY confirm_type (confirm_type) +) CHARACTER SET `utf8` COLLATE `utf8_bin`; + + +# Table: 'phpbb_disallow' +CREATE TABLE phpbb_disallow ( + disallow_id mediumint(8) UNSIGNED NOT NULL auto_increment, + disallow_username varchar(255) DEFAULT '' NOT NULL, + PRIMARY KEY (disallow_id) +) CHARACTER SET `utf8` COLLATE `utf8_bin`; + + +# Table: 'phpbb_drafts' +CREATE TABLE phpbb_drafts ( + draft_id mediumint(8) UNSIGNED NOT NULL auto_increment, + user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + topic_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + forum_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + save_time int(11) UNSIGNED DEFAULT '0' NOT NULL, + draft_subject varchar(255) DEFAULT '' NOT NULL, + draft_message mediumtext NOT NULL, + PRIMARY KEY (draft_id), + KEY save_time (save_time) +) CHARACTER SET `utf8` COLLATE `utf8_bin`; + + +# Table: 'phpbb_ext' +CREATE TABLE phpbb_ext ( + ext_name varchar(255) DEFAULT '' NOT NULL, + ext_active tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + ext_state text NOT NULL, + UNIQUE ext_name (ext_name) +) CHARACTER SET `utf8` COLLATE `utf8_bin`; + + +# Table: 'phpbb_extensions' +CREATE TABLE phpbb_extensions ( + extension_id mediumint(8) UNSIGNED NOT NULL auto_increment, + group_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + extension varchar(100) DEFAULT '' NOT NULL, + PRIMARY KEY (extension_id) +) CHARACTER SET `utf8` COLLATE `utf8_bin`; + + +# Table: 'phpbb_extension_groups' +CREATE TABLE phpbb_extension_groups ( + group_id mediumint(8) UNSIGNED NOT NULL auto_increment, + group_name varchar(255) DEFAULT '' NOT NULL, + cat_id tinyint(2) DEFAULT '0' NOT NULL, + allow_group tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + download_mode tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, + upload_icon varchar(255) DEFAULT '' NOT NULL, + max_filesize int(20) UNSIGNED DEFAULT '0' NOT NULL, + allowed_forums text NOT NULL, + allow_in_pm tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + PRIMARY KEY (group_id) +) CHARACTER SET `utf8` COLLATE `utf8_bin`; + + +# Table: 'phpbb_forums' +CREATE TABLE phpbb_forums ( + forum_id mediumint(8) UNSIGNED NOT NULL auto_increment, + parent_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + left_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + right_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + forum_parents mediumtext NOT NULL, + forum_name varchar(255) DEFAULT '' NOT NULL, + forum_desc text NOT NULL, + forum_desc_bitfield varchar(255) DEFAULT '' NOT NULL, + forum_desc_options int(11) UNSIGNED DEFAULT '7' NOT NULL, + forum_desc_uid varchar(8) DEFAULT '' NOT NULL, + forum_link varchar(255) DEFAULT '' NOT NULL, + forum_password varchar(40) DEFAULT '' NOT NULL, + forum_style mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + forum_image varchar(255) DEFAULT '' NOT NULL, + forum_rules text NOT NULL, + forum_rules_link varchar(255) DEFAULT '' NOT NULL, + forum_rules_bitfield varchar(255) DEFAULT '' NOT NULL, + forum_rules_options int(11) UNSIGNED DEFAULT '7' NOT NULL, + forum_rules_uid varchar(8) DEFAULT '' NOT NULL, + forum_topics_per_page tinyint(4) DEFAULT '0' NOT NULL, + forum_type tinyint(4) DEFAULT '0' NOT NULL, + forum_status tinyint(4) DEFAULT '0' NOT NULL, + forum_posts mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + forum_topics mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + forum_topics_real mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + forum_last_post_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + forum_last_poster_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + forum_last_post_subject varchar(255) DEFAULT '' NOT NULL, + forum_last_post_time int(11) UNSIGNED DEFAULT '0' NOT NULL, + forum_last_poster_name varchar(255) DEFAULT '' NOT NULL, + forum_last_poster_colour varchar(6) DEFAULT '' NOT NULL, + forum_flags tinyint(4) DEFAULT '32' NOT NULL, + forum_options int(20) UNSIGNED DEFAULT '0' NOT NULL, + display_subforum_list tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, + display_on_index tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, + enable_indexing tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, + enable_icons tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, + enable_prune tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + prune_next int(11) UNSIGNED DEFAULT '0' NOT NULL, + prune_days mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + prune_viewed mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + prune_freq mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + PRIMARY KEY (forum_id), + KEY left_right_id (left_id, right_id), + KEY forum_lastpost_id (forum_last_post_id) +) CHARACTER SET `utf8` COLLATE `utf8_bin`; + + +# Table: 'phpbb_forums_access' +CREATE TABLE phpbb_forums_access ( + forum_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + session_id char(32) DEFAULT '' NOT NULL, + PRIMARY KEY (forum_id, user_id, session_id) +) CHARACTER SET `utf8` COLLATE `utf8_bin`; + + +# Table: 'phpbb_forums_track' +CREATE TABLE phpbb_forums_track ( + user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + forum_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + mark_time int(11) UNSIGNED DEFAULT '0' NOT NULL, + PRIMARY KEY (user_id, forum_id) +) CHARACTER SET `utf8` COLLATE `utf8_bin`; + + +# Table: 'phpbb_forums_watch' +CREATE TABLE phpbb_forums_watch ( + forum_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + notify_status tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + KEY forum_id (forum_id), + KEY user_id (user_id), + KEY notify_stat (notify_status) +) CHARACTER SET `utf8` COLLATE `utf8_bin`; + + +# Table: 'phpbb_groups' +CREATE TABLE phpbb_groups ( + group_id mediumint(8) UNSIGNED NOT NULL auto_increment, + group_type tinyint(4) DEFAULT '1' NOT NULL, + group_founder_manage tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + group_skip_auth tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + group_name varchar(255) DEFAULT '' NOT NULL, + group_desc text NOT NULL, + group_desc_bitfield varchar(255) DEFAULT '' NOT NULL, + group_desc_options int(11) UNSIGNED DEFAULT '7' NOT NULL, + group_desc_uid varchar(8) DEFAULT '' NOT NULL, + group_display tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + group_avatar varchar(255) DEFAULT '' NOT NULL, + group_avatar_type tinyint(2) DEFAULT '0' NOT NULL, + group_avatar_width smallint(4) UNSIGNED DEFAULT '0' NOT NULL, + group_avatar_height smallint(4) UNSIGNED DEFAULT '0' NOT NULL, + group_rank mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + group_colour varchar(6) DEFAULT '' NOT NULL, + group_sig_chars mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + group_receive_pm tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + group_message_limit mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + group_max_recipients mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + group_legend mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + group_teampage mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + PRIMARY KEY (group_id), + KEY group_legend_name (group_legend, group_name) +) CHARACTER SET `utf8` COLLATE `utf8_bin`; + + +# Table: 'phpbb_icons' +CREATE TABLE phpbb_icons ( + icons_id mediumint(8) UNSIGNED NOT NULL auto_increment, + icons_url varchar(255) DEFAULT '' NOT NULL, + icons_width tinyint(4) DEFAULT '0' NOT NULL, + icons_height tinyint(4) DEFAULT '0' NOT NULL, + icons_order mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + display_on_posting tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, + PRIMARY KEY (icons_id), + KEY display_on_posting (display_on_posting) +) CHARACTER SET `utf8` COLLATE `utf8_bin`; + + +# Table: 'phpbb_lang' +CREATE TABLE phpbb_lang ( + lang_id tinyint(4) NOT NULL auto_increment, + lang_iso varchar(30) DEFAULT '' NOT NULL, + lang_dir varchar(30) DEFAULT '' NOT NULL, + lang_english_name varchar(100) DEFAULT '' NOT NULL, + lang_local_name varchar(255) DEFAULT '' NOT NULL, + lang_author varchar(255) DEFAULT '' NOT NULL, + PRIMARY KEY (lang_id), + KEY lang_iso (lang_iso) +) CHARACTER SET `utf8` COLLATE `utf8_bin`; + + +# Table: 'phpbb_log' +CREATE TABLE phpbb_log ( + log_id mediumint(8) UNSIGNED NOT NULL auto_increment, + log_type tinyint(4) DEFAULT '0' NOT NULL, + user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + forum_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + topic_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + reportee_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + log_ip varchar(40) DEFAULT '' NOT NULL, + log_time int(11) UNSIGNED DEFAULT '0' NOT NULL, + log_operation text NOT NULL, + log_data mediumtext NOT NULL, + PRIMARY KEY (log_id), + KEY log_type (log_type), + KEY log_time (log_time), + KEY forum_id (forum_id), + KEY topic_id (topic_id), + KEY reportee_id (reportee_id), + KEY user_id (user_id) +) CHARACTER SET `utf8` COLLATE `utf8_bin`; + + +# Table: 'phpbb_login_attempts' +CREATE TABLE phpbb_login_attempts ( + attempt_ip varchar(40) DEFAULT '' NOT NULL, + attempt_browser varchar(150) DEFAULT '' NOT NULL, + attempt_forwarded_for varchar(255) DEFAULT '' NOT NULL, + attempt_time int(11) UNSIGNED DEFAULT '0' NOT NULL, + user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + username varchar(255) DEFAULT '0' NOT NULL, + username_clean varchar(255) DEFAULT '0' NOT NULL, + KEY att_ip (attempt_ip, attempt_time), + KEY att_for (attempt_forwarded_for, attempt_time), + KEY att_time (attempt_time), + KEY user_id (user_id) +) CHARACTER SET `utf8` COLLATE `utf8_bin`; + + +# Table: 'phpbb_moderator_cache' +CREATE TABLE phpbb_moderator_cache ( + forum_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + username varchar(255) DEFAULT '' NOT NULL, + group_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + group_name varchar(255) DEFAULT '' NOT NULL, + display_on_index tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, + KEY disp_idx (display_on_index), + KEY forum_id (forum_id) +) CHARACTER SET `utf8` COLLATE `utf8_bin`; + + +# Table: 'phpbb_modules' +CREATE TABLE phpbb_modules ( + module_id mediumint(8) UNSIGNED NOT NULL auto_increment, + module_enabled tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, + module_display tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, + module_basename varchar(255) DEFAULT '' NOT NULL, + module_class varchar(10) DEFAULT '' NOT NULL, + parent_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + left_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + right_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + module_langname varchar(255) DEFAULT '' NOT NULL, + module_mode varchar(255) DEFAULT '' NOT NULL, + module_auth varchar(255) DEFAULT '' NOT NULL, + PRIMARY KEY (module_id), + KEY left_right_id (left_id, right_id), + KEY module_enabled (module_enabled), + KEY class_left_id (module_class, left_id) +) CHARACTER SET `utf8` COLLATE `utf8_bin`; + + +# Table: 'phpbb_poll_options' +CREATE TABLE phpbb_poll_options ( + poll_option_id tinyint(4) DEFAULT '0' NOT NULL, + topic_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + poll_option_text text NOT NULL, + poll_option_total mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + KEY poll_opt_id (poll_option_id), + KEY topic_id (topic_id) +) CHARACTER SET `utf8` COLLATE `utf8_bin`; + + +# Table: 'phpbb_poll_votes' +CREATE TABLE phpbb_poll_votes ( + topic_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + poll_option_id tinyint(4) DEFAULT '0' NOT NULL, + vote_user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + vote_user_ip varchar(40) DEFAULT '' NOT NULL, + KEY topic_id (topic_id), + KEY vote_user_id (vote_user_id), + KEY vote_user_ip (vote_user_ip) +) CHARACTER SET `utf8` COLLATE `utf8_bin`; + + +# Table: 'phpbb_posts' +CREATE TABLE phpbb_posts ( + post_id mediumint(8) UNSIGNED NOT NULL auto_increment, + topic_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + forum_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + poster_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + icon_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + poster_ip varchar(40) DEFAULT '' NOT NULL, + post_time int(11) UNSIGNED DEFAULT '0' NOT NULL, + post_approved tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, + post_reported tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + enable_bbcode tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, + enable_smilies tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, + enable_magic_url tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, + enable_sig tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, + post_username varchar(255) DEFAULT '' NOT NULL, + post_subject varchar(255) DEFAULT '' NOT NULL COLLATE utf8_unicode_ci, + post_text mediumtext NOT NULL, + post_checksum varchar(32) DEFAULT '' NOT NULL, + post_attachment tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + bbcode_bitfield varchar(255) DEFAULT '' NOT NULL, + bbcode_uid varchar(8) DEFAULT '' NOT NULL, + post_postcount tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, + post_edit_time int(11) UNSIGNED DEFAULT '0' NOT NULL, + post_edit_reason varchar(255) DEFAULT '' NOT NULL, + post_edit_user mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + post_edit_count smallint(4) UNSIGNED DEFAULT '0' NOT NULL, + post_edit_locked tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + PRIMARY KEY (post_id), + KEY forum_id (forum_id), + KEY topic_id (topic_id), + KEY poster_ip (poster_ip), + KEY poster_id (poster_id), + KEY post_approved (post_approved), + KEY post_username (post_username), + KEY tid_post_time (topic_id, post_time) +) CHARACTER SET `utf8` COLLATE `utf8_bin`; + + +# Table: 'phpbb_privmsgs' +CREATE TABLE phpbb_privmsgs ( + msg_id mediumint(8) UNSIGNED NOT NULL auto_increment, + root_level mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + author_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + icon_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + author_ip varchar(40) DEFAULT '' NOT NULL, + message_time int(11) UNSIGNED DEFAULT '0' NOT NULL, + enable_bbcode tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, + enable_smilies tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, + enable_magic_url tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, + enable_sig tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, + message_subject varchar(255) DEFAULT '' NOT NULL, + message_text mediumtext NOT NULL, + message_edit_reason varchar(255) DEFAULT '' NOT NULL, + message_edit_user mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + message_attachment tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + bbcode_bitfield varchar(255) DEFAULT '' NOT NULL, + bbcode_uid varchar(8) DEFAULT '' NOT NULL, + message_edit_time int(11) UNSIGNED DEFAULT '0' NOT NULL, + message_edit_count smallint(4) UNSIGNED DEFAULT '0' NOT NULL, + to_address text NOT NULL, + bcc_address text NOT NULL, + message_reported tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + PRIMARY KEY (msg_id), + KEY author_ip (author_ip), + KEY message_time (message_time), + KEY author_id (author_id), + KEY root_level (root_level) +) CHARACTER SET `utf8` COLLATE `utf8_bin`; + + +# Table: 'phpbb_privmsgs_folder' +CREATE TABLE phpbb_privmsgs_folder ( + folder_id mediumint(8) UNSIGNED NOT NULL auto_increment, + user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + folder_name varchar(255) DEFAULT '' NOT NULL, + pm_count mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + PRIMARY KEY (folder_id), + KEY user_id (user_id) +) CHARACTER SET `utf8` COLLATE `utf8_bin`; + + +# Table: 'phpbb_privmsgs_rules' +CREATE TABLE phpbb_privmsgs_rules ( + rule_id mediumint(8) UNSIGNED NOT NULL auto_increment, + user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + rule_check mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + rule_connection mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + rule_string varchar(255) DEFAULT '' NOT NULL, + rule_user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + rule_group_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + rule_action mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + rule_folder_id int(11) DEFAULT '0' NOT NULL, + PRIMARY KEY (rule_id), + KEY user_id (user_id) +) CHARACTER SET `utf8` COLLATE `utf8_bin`; + + +# Table: 'phpbb_privmsgs_to' +CREATE TABLE phpbb_privmsgs_to ( + msg_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + author_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + pm_deleted tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + pm_new tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, + pm_unread tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, + pm_replied tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + pm_marked tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + pm_forwarded tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + folder_id int(11) DEFAULT '0' NOT NULL, + KEY msg_id (msg_id), + KEY author_id (author_id), + KEY usr_flder_id (user_id, folder_id) +) CHARACTER SET `utf8` COLLATE `utf8_bin`; + + +# Table: 'phpbb_profile_fields' +CREATE TABLE phpbb_profile_fields ( + field_id mediumint(8) UNSIGNED NOT NULL auto_increment, + field_name varchar(255) DEFAULT '' NOT NULL, + field_type tinyint(4) DEFAULT '0' NOT NULL, + field_ident varchar(20) DEFAULT '' NOT NULL, + field_length varchar(20) DEFAULT '' NOT NULL, + field_minlen varchar(255) DEFAULT '' NOT NULL, + field_maxlen varchar(255) DEFAULT '' NOT NULL, + field_novalue varchar(255) DEFAULT '' NOT NULL, + field_default_value varchar(255) DEFAULT '' NOT NULL, + field_validation varchar(20) DEFAULT '' NOT NULL, + field_required tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + field_show_novalue tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + field_show_on_reg tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + field_show_on_pm tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + field_show_on_vt tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + field_show_profile tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + field_hide tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + field_no_view tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + field_active tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + field_order mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + PRIMARY KEY (field_id), + KEY fld_type (field_type), + KEY fld_ordr (field_order) +) CHARACTER SET `utf8` COLLATE `utf8_bin`; + + +# Table: 'phpbb_profile_fields_data' +CREATE TABLE phpbb_profile_fields_data ( + user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + PRIMARY KEY (user_id) +) CHARACTER SET `utf8` COLLATE `utf8_bin`; + + +# Table: 'phpbb_profile_fields_lang' +CREATE TABLE phpbb_profile_fields_lang ( + field_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + lang_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + option_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + field_type tinyint(4) DEFAULT '0' NOT NULL, + lang_value varchar(255) DEFAULT '' NOT NULL, + PRIMARY KEY (field_id, lang_id, option_id) +) CHARACTER SET `utf8` COLLATE `utf8_bin`; + + +# Table: 'phpbb_profile_lang' +CREATE TABLE phpbb_profile_lang ( + field_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + lang_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + lang_name varchar(255) DEFAULT '' NOT NULL, + lang_explain text NOT NULL, + lang_default_value varchar(255) DEFAULT '' NOT NULL, + PRIMARY KEY (field_id, lang_id) +) CHARACTER SET `utf8` COLLATE `utf8_bin`; + + +# Table: 'phpbb_ranks' +CREATE TABLE phpbb_ranks ( + rank_id mediumint(8) UNSIGNED NOT NULL auto_increment, + rank_title varchar(255) DEFAULT '' NOT NULL, + rank_min mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + rank_special tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + rank_image varchar(255) DEFAULT '' NOT NULL, + PRIMARY KEY (rank_id) +) CHARACTER SET `utf8` COLLATE `utf8_bin`; + + +# Table: 'phpbb_reports' +CREATE TABLE phpbb_reports ( + report_id mediumint(8) UNSIGNED NOT NULL auto_increment, + reason_id smallint(4) UNSIGNED DEFAULT '0' NOT NULL, + post_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + pm_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + user_notify tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + report_closed tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + report_time int(11) UNSIGNED DEFAULT '0' NOT NULL, + report_text mediumtext NOT NULL, + reported_post_text mediumtext NOT NULL, + PRIMARY KEY (report_id), + KEY post_id (post_id), + KEY pm_id (pm_id) +) CHARACTER SET `utf8` COLLATE `utf8_bin`; + + +# Table: 'phpbb_reports_reasons' +CREATE TABLE phpbb_reports_reasons ( + reason_id smallint(4) UNSIGNED NOT NULL auto_increment, + reason_title varchar(255) DEFAULT '' NOT NULL, + reason_description mediumtext NOT NULL, + reason_order smallint(4) UNSIGNED DEFAULT '0' NOT NULL, + PRIMARY KEY (reason_id) +) CHARACTER SET `utf8` COLLATE `utf8_bin`; + + +# Table: 'phpbb_search_results' +CREATE TABLE phpbb_search_results ( + search_key varchar(32) DEFAULT '' NOT NULL, + search_time int(11) UNSIGNED DEFAULT '0' NOT NULL, + search_keywords mediumtext NOT NULL, + search_authors mediumtext NOT NULL, + PRIMARY KEY (search_key) +) CHARACTER SET `utf8` COLLATE `utf8_bin`; + + +# Table: 'phpbb_search_wordlist' +CREATE TABLE phpbb_search_wordlist ( + word_id mediumint(8) UNSIGNED NOT NULL auto_increment, + word_text varchar(255) DEFAULT '' NOT NULL, + word_common tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + word_count mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + PRIMARY KEY (word_id), + UNIQUE wrd_txt (word_text), + KEY wrd_cnt (word_count) +) CHARACTER SET `utf8` COLLATE `utf8_bin`; + + +# Table: 'phpbb_search_wordmatch' +CREATE TABLE phpbb_search_wordmatch ( + post_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + word_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + title_match tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + UNIQUE unq_mtch (word_id, post_id, title_match), + KEY word_id (word_id), + KEY post_id (post_id) +) CHARACTER SET `utf8` COLLATE `utf8_bin`; + + +# Table: 'phpbb_sessions' +CREATE TABLE phpbb_sessions ( + session_id char(32) DEFAULT '' NOT NULL, + session_user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + session_forum_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + session_last_visit int(11) UNSIGNED DEFAULT '0' NOT NULL, + session_start int(11) UNSIGNED DEFAULT '0' NOT NULL, + session_time int(11) UNSIGNED DEFAULT '0' NOT NULL, + session_ip varchar(40) DEFAULT '' NOT NULL, + session_browser varchar(150) DEFAULT '' NOT NULL, + session_forwarded_for varchar(255) DEFAULT '' NOT NULL, + session_page varchar(255) DEFAULT '' NOT NULL, + session_viewonline tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, + session_autologin tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + session_admin tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + PRIMARY KEY (session_id), + KEY session_time (session_time), + KEY session_user_id (session_user_id), + KEY session_fid (session_forum_id) +) CHARACTER SET `utf8` COLLATE `utf8_bin`; + + +# Table: 'phpbb_sessions_keys' +CREATE TABLE phpbb_sessions_keys ( + key_id char(32) DEFAULT '' NOT NULL, + user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + last_ip varchar(40) DEFAULT '' NOT NULL, + last_login int(11) UNSIGNED DEFAULT '0' NOT NULL, + PRIMARY KEY (key_id, user_id), + KEY last_login (last_login) +) CHARACTER SET `utf8` COLLATE `utf8_bin`; + + +# Table: 'phpbb_sitelist' +CREATE TABLE phpbb_sitelist ( + site_id mediumint(8) UNSIGNED NOT NULL auto_increment, + site_ip varchar(40) DEFAULT '' NOT NULL, + site_hostname varchar(255) DEFAULT '' NOT NULL, + ip_exclude tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + PRIMARY KEY (site_id) +) CHARACTER SET `utf8` COLLATE `utf8_bin`; + + +# Table: 'phpbb_smilies' +CREATE TABLE phpbb_smilies ( + smiley_id mediumint(8) UNSIGNED NOT NULL auto_increment, + code varchar(50) DEFAULT '' NOT NULL, + emotion varchar(50) DEFAULT '' NOT NULL, + smiley_url varchar(50) DEFAULT '' NOT NULL, + smiley_width smallint(4) UNSIGNED DEFAULT '0' NOT NULL, + smiley_height smallint(4) UNSIGNED DEFAULT '0' NOT NULL, + smiley_order mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + display_on_posting tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, + PRIMARY KEY (smiley_id), + KEY display_on_post (display_on_posting) +) CHARACTER SET `utf8` COLLATE `utf8_bin`; + + +# Table: 'phpbb_styles' +CREATE TABLE phpbb_styles ( + style_id mediumint(8) UNSIGNED NOT NULL auto_increment, + style_name varchar(255) DEFAULT '' NOT NULL, + style_copyright varchar(255) DEFAULT '' NOT NULL, + style_active tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, + style_path varchar(100) DEFAULT '' NOT NULL, + bbcode_bitfield varchar(255) DEFAULT 'kNg=' NOT NULL, + style_parent_id int(4) UNSIGNED DEFAULT '0' NOT NULL, + style_parent_tree text NOT NULL, + PRIMARY KEY (style_id), + UNIQUE style_name (style_name) +) CHARACTER SET `utf8` COLLATE `utf8_bin`; + + +# Table: 'phpbb_topics' +CREATE TABLE phpbb_topics ( + topic_id mediumint(8) UNSIGNED NOT NULL auto_increment, + forum_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + icon_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + topic_attachment tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + topic_approved tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, + topic_reported tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + topic_title varchar(255) DEFAULT '' NOT NULL COLLATE utf8_unicode_ci, + topic_poster mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + topic_time int(11) UNSIGNED DEFAULT '0' NOT NULL, + topic_time_limit int(11) UNSIGNED DEFAULT '0' NOT NULL, + topic_views mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + topic_replies mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + topic_replies_real mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + topic_status tinyint(3) DEFAULT '0' NOT NULL, + topic_type tinyint(3) DEFAULT '0' NOT NULL, + topic_first_post_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + topic_first_poster_name varchar(255) DEFAULT '' NOT NULL, + topic_first_poster_colour varchar(6) DEFAULT '' NOT NULL, + topic_last_post_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + topic_last_poster_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + topic_last_poster_name varchar(255) DEFAULT '' NOT NULL, + topic_last_poster_colour varchar(6) DEFAULT '' NOT NULL, + topic_last_post_subject varchar(255) DEFAULT '' NOT NULL, + topic_last_post_time int(11) UNSIGNED DEFAULT '0' NOT NULL, + topic_last_view_time int(11) UNSIGNED DEFAULT '0' NOT NULL, + topic_moved_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + topic_bumped tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + topic_bumper mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + poll_title varchar(255) DEFAULT '' NOT NULL, + poll_start int(11) UNSIGNED DEFAULT '0' NOT NULL, + poll_length int(11) UNSIGNED DEFAULT '0' NOT NULL, + poll_max_options tinyint(4) DEFAULT '1' NOT NULL, + poll_last_vote int(11) UNSIGNED DEFAULT '0' NOT NULL, + poll_vote_change tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + PRIMARY KEY (topic_id), + KEY forum_id (forum_id), + KEY forum_id_type (forum_id, topic_type), + KEY last_post_time (topic_last_post_time), + KEY topic_approved (topic_approved), + KEY forum_appr_last (forum_id, topic_approved, topic_last_post_id), + KEY fid_time_moved (forum_id, topic_last_post_time, topic_moved_id) +) CHARACTER SET `utf8` COLLATE `utf8_bin`; + + +# Table: 'phpbb_topics_track' +CREATE TABLE phpbb_topics_track ( + user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + topic_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + forum_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + mark_time int(11) UNSIGNED DEFAULT '0' NOT NULL, + PRIMARY KEY (user_id, topic_id), + KEY topic_id (topic_id), + KEY forum_id (forum_id) +) CHARACTER SET `utf8` COLLATE `utf8_bin`; + + +# Table: 'phpbb_topics_posted' +CREATE TABLE phpbb_topics_posted ( + user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + topic_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + topic_posted tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + PRIMARY KEY (user_id, topic_id) +) CHARACTER SET `utf8` COLLATE `utf8_bin`; + + +# Table: 'phpbb_topics_watch' +CREATE TABLE phpbb_topics_watch ( + topic_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + notify_status tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + KEY topic_id (topic_id), + KEY user_id (user_id), + KEY notify_stat (notify_status) +) CHARACTER SET `utf8` COLLATE `utf8_bin`; + + +# Table: 'phpbb_user_group' +CREATE TABLE phpbb_user_group ( + group_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + group_leader tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + user_pending tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, + KEY group_id (group_id), + KEY user_id (user_id), + KEY group_leader (group_leader) +) CHARACTER SET `utf8` COLLATE `utf8_bin`; + + +# Table: 'phpbb_users' +CREATE TABLE phpbb_users ( + user_id mediumint(8) UNSIGNED NOT NULL auto_increment, + user_type tinyint(2) DEFAULT '0' NOT NULL, + group_id mediumint(8) UNSIGNED DEFAULT '3' NOT NULL, + user_permissions mediumtext NOT NULL, + user_perm_from mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + user_ip varchar(40) DEFAULT '' NOT NULL, + user_regdate int(11) UNSIGNED DEFAULT '0' NOT NULL, + username varchar(255) DEFAULT '' NOT NULL, + username_clean varchar(255) DEFAULT '' NOT NULL, + user_password varchar(40) DEFAULT '' NOT NULL, + user_passchg int(11) UNSIGNED DEFAULT '0' NOT NULL, + user_pass_convert tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + user_email varchar(100) DEFAULT '' NOT NULL, + user_email_hash bigint(20) DEFAULT '0' NOT NULL, + user_birthday varchar(10) DEFAULT '' NOT NULL, + user_lastvisit int(11) UNSIGNED DEFAULT '0' NOT NULL, + user_lastmark int(11) UNSIGNED DEFAULT '0' NOT NULL, + user_lastpost_time int(11) UNSIGNED DEFAULT '0' NOT NULL, + user_lastpage varchar(200) DEFAULT '' NOT NULL, + user_last_confirm_key varchar(10) DEFAULT '' NOT NULL, + user_last_search int(11) UNSIGNED DEFAULT '0' NOT NULL, + user_warnings tinyint(4) DEFAULT '0' NOT NULL, + user_last_warning int(11) UNSIGNED DEFAULT '0' NOT NULL, + user_login_attempts tinyint(4) DEFAULT '0' NOT NULL, + user_inactive_reason tinyint(2) DEFAULT '0' NOT NULL, + user_inactive_time int(11) UNSIGNED DEFAULT '0' NOT NULL, + user_posts mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + user_lang varchar(30) DEFAULT '' NOT NULL, + user_timezone varchar(100) DEFAULT 'UTC' NOT NULL, + user_dateformat varchar(30) DEFAULT 'd M Y H:i' NOT NULL, + user_style mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + user_rank mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + user_colour varchar(6) DEFAULT '' NOT NULL, + user_new_privmsg int(4) DEFAULT '0' NOT NULL, + user_unread_privmsg int(4) DEFAULT '0' NOT NULL, + user_last_privmsg int(11) UNSIGNED DEFAULT '0' NOT NULL, + user_message_rules tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + user_full_folder int(11) DEFAULT '-3' NOT NULL, + user_emailtime int(11) UNSIGNED DEFAULT '0' NOT NULL, + user_topic_show_days smallint(4) UNSIGNED DEFAULT '0' NOT NULL, + user_topic_sortby_type varchar(1) DEFAULT 't' NOT NULL, + user_topic_sortby_dir varchar(1) DEFAULT 'd' NOT NULL, + user_post_show_days smallint(4) UNSIGNED DEFAULT '0' NOT NULL, + user_post_sortby_type varchar(1) DEFAULT 't' NOT NULL, + user_post_sortby_dir varchar(1) DEFAULT 'a' NOT NULL, + user_notify tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + user_notify_pm tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, + user_notify_type tinyint(4) DEFAULT '0' NOT NULL, + user_allow_pm tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, + user_allow_viewonline tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, + user_allow_viewemail tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, + user_allow_massemail tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, + user_options int(11) UNSIGNED DEFAULT '230271' NOT NULL, + user_avatar varchar(255) DEFAULT '' NOT NULL, + user_avatar_type tinyint(2) DEFAULT '0' NOT NULL, + user_avatar_width smallint(4) UNSIGNED DEFAULT '0' NOT NULL, + user_avatar_height smallint(4) UNSIGNED DEFAULT '0' NOT NULL, + user_sig mediumtext NOT NULL, + user_sig_bbcode_uid varchar(8) DEFAULT '' NOT NULL, + user_sig_bbcode_bitfield varchar(255) DEFAULT '' NOT NULL, + user_from varchar(100) DEFAULT '' NOT NULL, + user_icq varchar(15) DEFAULT '' NOT NULL, + user_aim varchar(255) DEFAULT '' NOT NULL, + user_yim varchar(255) DEFAULT '' NOT NULL, + user_msnm varchar(255) DEFAULT '' NOT NULL, + user_jabber varchar(255) DEFAULT '' NOT NULL, + user_website varchar(200) DEFAULT '' NOT NULL, + user_occ text NOT NULL, + user_interests text NOT NULL, + user_actkey varchar(32) DEFAULT '' NOT NULL, + user_newpasswd varchar(40) DEFAULT '' NOT NULL, + user_form_salt varchar(32) DEFAULT '' NOT NULL, + user_new tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, + user_reminded tinyint(4) DEFAULT '0' NOT NULL, + user_reminded_time int(11) UNSIGNED DEFAULT '0' NOT NULL, + PRIMARY KEY (user_id), + KEY user_birthday (user_birthday), + KEY user_email_hash (user_email_hash), + KEY user_type (user_type), + UNIQUE username_clean (username_clean) +) CHARACTER SET `utf8` COLLATE `utf8_bin`; + + +# Table: 'phpbb_warnings' +CREATE TABLE phpbb_warnings ( + warning_id mediumint(8) UNSIGNED NOT NULL auto_increment, + user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + post_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + log_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + warning_time int(11) UNSIGNED DEFAULT '0' NOT NULL, + PRIMARY KEY (warning_id) +) CHARACTER SET `utf8` COLLATE `utf8_bin`; + + +# Table: 'phpbb_words' +CREATE TABLE phpbb_words ( + word_id mediumint(8) UNSIGNED NOT NULL auto_increment, + word varchar(255) DEFAULT '' NOT NULL, + replacement varchar(255) DEFAULT '' NOT NULL, + PRIMARY KEY (word_id) +) CHARACTER SET `utf8` COLLATE `utf8_bin`; + + +# Table: 'phpbb_zebra' +CREATE TABLE phpbb_zebra ( + user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + zebra_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + friend tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + foe tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + PRIMARY KEY (user_id, zebra_id) +) CHARACTER SET `utf8` COLLATE `utf8_bin`; diff --git a/phpBB/install/schemas/oracle_schema.sql b/phpBB/install/schemas/oracle_schema.sql index 04155fe28b..02d8042ff7 100644 --- a/phpBB/install/schemas/oracle_schema.sql +++ b/phpBB/install/schemas/oracle_schema.sql @@ -1,1787 +1,1785 @@ -/* - * DO NOT EDIT THIS FILE, IT IS GENERATED - * - * To change the contents of this file, edit - * phpBB/develop/create_schema_files.php and - * run it. - */ - -/* - This first section is optional, however its probably the best method - of running phpBB on Oracle. If you already have a tablespace and user created - for phpBB you can leave this section commented out! - - The first set of statements create a phpBB tablespace and a phpBB user, - make sure you change the password of the phpBB user before you run this script!! -*/ - -/* -CREATE TABLESPACE "PHPBB" - LOGGING - DATAFILE 'E:\ORACLE\ORADATA\LOCAL\PHPBB.ora' - SIZE 10M - AUTOEXTEND ON NEXT 10M - MAXSIZE 100M; - -CREATE USER "PHPBB" - PROFILE "DEFAULT" - IDENTIFIED BY "phpbb_password" - DEFAULT TABLESPACE "PHPBB" - QUOTA UNLIMITED ON "PHPBB" - ACCOUNT UNLOCK; - -GRANT ANALYZE ANY TO "PHPBB"; -GRANT CREATE SEQUENCE TO "PHPBB"; -GRANT CREATE SESSION TO "PHPBB"; -GRANT CREATE TABLE TO "PHPBB"; -GRANT CREATE TRIGGER TO "PHPBB"; -GRANT CREATE VIEW TO "PHPBB"; -GRANT "CONNECT" TO "PHPBB"; - -COMMIT; -DISCONNECT; - -CONNECT phpbb/phpbb_password; -*/ -/* - Table: 'phpbb_attachments' -*/ -CREATE TABLE phpbb_attachments ( - attach_id number(8) NOT NULL, - post_msg_id number(8) DEFAULT '0' NOT NULL, - topic_id number(8) DEFAULT '0' NOT NULL, - in_message number(1) DEFAULT '0' NOT NULL, - poster_id number(8) DEFAULT '0' NOT NULL, - is_orphan number(1) DEFAULT '1' NOT NULL, - physical_filename varchar2(255) DEFAULT '' , - real_filename varchar2(255) DEFAULT '' , - download_count number(8) DEFAULT '0' NOT NULL, - attach_comment clob DEFAULT '' , - extension varchar2(100) DEFAULT '' , - mimetype varchar2(100) DEFAULT '' , - filesize number(20) DEFAULT '0' NOT NULL, - filetime number(11) DEFAULT '0' NOT NULL, - thumbnail number(1) DEFAULT '0' NOT NULL, - CONSTRAINT pk_phpbb_attachments PRIMARY KEY (attach_id) -) -/ - -CREATE INDEX phpbb_attachments_filetime ON phpbb_attachments (filetime) -/ -CREATE INDEX phpbb_attachments_post_msg_id ON phpbb_attachments (post_msg_id) -/ -CREATE INDEX phpbb_attachments_topic_id ON phpbb_attachments (topic_id) -/ -CREATE INDEX phpbb_attachments_poster_id ON phpbb_attachments (poster_id) -/ -CREATE INDEX phpbb_attachments_is_orphan ON phpbb_attachments (is_orphan) -/ - -CREATE SEQUENCE phpbb_attachments_seq -/ - -CREATE OR REPLACE TRIGGER t_phpbb_attachments -BEFORE INSERT ON phpbb_attachments -FOR EACH ROW WHEN ( - new.attach_id IS NULL OR new.attach_id = 0 -) -BEGIN - SELECT phpbb_attachments_seq.nextval - INTO :new.attach_id - FROM dual; -END; -/ - - -/* - Table: 'phpbb_acl_groups' -*/ -CREATE TABLE phpbb_acl_groups ( - group_id number(8) DEFAULT '0' NOT NULL, - forum_id number(8) DEFAULT '0' NOT NULL, - auth_option_id number(8) DEFAULT '0' NOT NULL, - auth_role_id number(8) DEFAULT '0' NOT NULL, - auth_setting number(2) DEFAULT '0' NOT NULL -) -/ - -CREATE INDEX phpbb_acl_groups_group_id ON phpbb_acl_groups (group_id) -/ -CREATE INDEX phpbb_acl_groups_auth_opt_id ON phpbb_acl_groups (auth_option_id) -/ -CREATE INDEX phpbb_acl_groups_auth_role_id ON phpbb_acl_groups (auth_role_id) -/ - -/* - Table: 'phpbb_acl_options' -*/ -CREATE TABLE phpbb_acl_options ( - auth_option_id number(8) NOT NULL, - auth_option varchar2(50) DEFAULT '' , - is_global number(1) DEFAULT '0' NOT NULL, - is_local number(1) DEFAULT '0' NOT NULL, - founder_only number(1) DEFAULT '0' NOT NULL, - CONSTRAINT pk_phpbb_acl_options PRIMARY KEY (auth_option_id), - CONSTRAINT u_phpbb_auth_option UNIQUE (auth_option) -) -/ - - -CREATE SEQUENCE phpbb_acl_options_seq -/ - -CREATE OR REPLACE TRIGGER t_phpbb_acl_options -BEFORE INSERT ON phpbb_acl_options -FOR EACH ROW WHEN ( - new.auth_option_id IS NULL OR new.auth_option_id = 0 -) -BEGIN - SELECT phpbb_acl_options_seq.nextval - INTO :new.auth_option_id - FROM dual; -END; -/ - - -/* - Table: 'phpbb_acl_roles' -*/ -CREATE TABLE phpbb_acl_roles ( - role_id number(8) NOT NULL, - role_name varchar2(765) DEFAULT '' , - role_description clob DEFAULT '' , - role_type varchar2(10) DEFAULT '' , - role_order number(4) DEFAULT '0' NOT NULL, - CONSTRAINT pk_phpbb_acl_roles PRIMARY KEY (role_id) -) -/ - -CREATE INDEX phpbb_acl_roles_role_type ON phpbb_acl_roles (role_type) -/ -CREATE INDEX phpbb_acl_roles_role_order ON phpbb_acl_roles (role_order) -/ - -CREATE SEQUENCE phpbb_acl_roles_seq -/ - -CREATE OR REPLACE TRIGGER t_phpbb_acl_roles -BEFORE INSERT ON phpbb_acl_roles -FOR EACH ROW WHEN ( - new.role_id IS NULL OR new.role_id = 0 -) -BEGIN - SELECT phpbb_acl_roles_seq.nextval - INTO :new.role_id - FROM dual; -END; -/ - - -/* - Table: 'phpbb_acl_roles_data' -*/ -CREATE TABLE phpbb_acl_roles_data ( - role_id number(8) DEFAULT '0' NOT NULL, - auth_option_id number(8) DEFAULT '0' NOT NULL, - auth_setting number(2) DEFAULT '0' NOT NULL, - CONSTRAINT pk_phpbb_acl_roles_data PRIMARY KEY (role_id, auth_option_id) -) -/ - -CREATE INDEX phpbb_acl_roles_data_ath_op_id ON phpbb_acl_roles_data (auth_option_id) -/ - -/* - Table: 'phpbb_acl_users' -*/ -CREATE TABLE phpbb_acl_users ( - user_id number(8) DEFAULT '0' NOT NULL, - forum_id number(8) DEFAULT '0' NOT NULL, - auth_option_id number(8) DEFAULT '0' NOT NULL, - auth_role_id number(8) DEFAULT '0' NOT NULL, - auth_setting number(2) DEFAULT '0' NOT NULL -) -/ - -CREATE INDEX phpbb_acl_users_user_id ON phpbb_acl_users (user_id) -/ -CREATE INDEX phpbb_acl_users_auth_option_id ON phpbb_acl_users (auth_option_id) -/ -CREATE INDEX phpbb_acl_users_auth_role_id ON phpbb_acl_users (auth_role_id) -/ - -/* - Table: 'phpbb_banlist' -*/ -CREATE TABLE phpbb_banlist ( - ban_id number(8) NOT NULL, - ban_userid number(8) DEFAULT '0' NOT NULL, - ban_ip varchar2(40) DEFAULT '' , - ban_email varchar2(300) DEFAULT '' , - ban_start number(11) DEFAULT '0' NOT NULL, - ban_end number(11) DEFAULT '0' NOT NULL, - ban_exclude number(1) DEFAULT '0' NOT NULL, - ban_reason varchar2(765) DEFAULT '' , - ban_give_reason varchar2(765) DEFAULT '' , - CONSTRAINT pk_phpbb_banlist PRIMARY KEY (ban_id) -) -/ - -CREATE INDEX phpbb_banlist_ban_end ON phpbb_banlist (ban_end) -/ -CREATE INDEX phpbb_banlist_ban_user ON phpbb_banlist (ban_userid, ban_exclude) -/ -CREATE INDEX phpbb_banlist_ban_email ON phpbb_banlist (ban_email, ban_exclude) -/ -CREATE INDEX phpbb_banlist_ban_ip ON phpbb_banlist (ban_ip, ban_exclude) -/ - -CREATE SEQUENCE phpbb_banlist_seq -/ - -CREATE OR REPLACE TRIGGER t_phpbb_banlist -BEFORE INSERT ON phpbb_banlist -FOR EACH ROW WHEN ( - new.ban_id IS NULL OR new.ban_id = 0 -) -BEGIN - SELECT phpbb_banlist_seq.nextval - INTO :new.ban_id - FROM dual; -END; -/ - - -/* - Table: 'phpbb_bbcodes' -*/ -CREATE TABLE phpbb_bbcodes ( - bbcode_id number(4) DEFAULT '0' NOT NULL, - bbcode_tag varchar2(16) DEFAULT '' , - bbcode_helpline varchar2(765) DEFAULT '' , - display_on_posting number(1) DEFAULT '0' NOT NULL, - bbcode_match clob DEFAULT '' , - bbcode_tpl clob DEFAULT '' , - first_pass_match clob DEFAULT '' , - first_pass_replace clob DEFAULT '' , - second_pass_match clob DEFAULT '' , - second_pass_replace clob DEFAULT '' , - CONSTRAINT pk_phpbb_bbcodes PRIMARY KEY (bbcode_id) -) -/ - -CREATE INDEX phpbb_bbcodes_display_on_post ON phpbb_bbcodes (display_on_posting) -/ - -/* - Table: 'phpbb_bookmarks' -*/ -CREATE TABLE phpbb_bookmarks ( - topic_id number(8) DEFAULT '0' NOT NULL, - user_id number(8) DEFAULT '0' NOT NULL, - CONSTRAINT pk_phpbb_bookmarks PRIMARY KEY (topic_id, user_id) -) -/ - - -/* - Table: 'phpbb_bots' -*/ -CREATE TABLE phpbb_bots ( - bot_id number(8) NOT NULL, - bot_active number(1) DEFAULT '1' NOT NULL, - bot_name varchar2(765) DEFAULT '' , - user_id number(8) DEFAULT '0' NOT NULL, - bot_agent varchar2(255) DEFAULT '' , - bot_ip varchar2(255) DEFAULT '' , - CONSTRAINT pk_phpbb_bots PRIMARY KEY (bot_id) -) -/ - -CREATE INDEX phpbb_bots_bot_active ON phpbb_bots (bot_active) -/ - -CREATE SEQUENCE phpbb_bots_seq -/ - -CREATE OR REPLACE TRIGGER t_phpbb_bots -BEFORE INSERT ON phpbb_bots -FOR EACH ROW WHEN ( - new.bot_id IS NULL OR new.bot_id = 0 -) -BEGIN - SELECT phpbb_bots_seq.nextval - INTO :new.bot_id - FROM dual; -END; -/ - - -/* - Table: 'phpbb_config' -*/ -CREATE TABLE phpbb_config ( - config_name varchar2(255) DEFAULT '' , - config_value varchar2(765) DEFAULT '' , - is_dynamic number(1) DEFAULT '0' NOT NULL, - CONSTRAINT pk_phpbb_config PRIMARY KEY (config_name) -) -/ - -CREATE INDEX phpbb_config_is_dynamic ON phpbb_config (is_dynamic) -/ - -/* - Table: 'phpbb_confirm' -*/ -CREATE TABLE phpbb_confirm ( - confirm_id char(32) DEFAULT '' , - session_id char(32) DEFAULT '' , - confirm_type number(3) DEFAULT '0' NOT NULL, - code varchar2(8) DEFAULT '' , - seed number(10) DEFAULT '0' NOT NULL, - attempts number(8) DEFAULT '0' NOT NULL, - CONSTRAINT pk_phpbb_confirm PRIMARY KEY (session_id, confirm_id) -) -/ - -CREATE INDEX phpbb_confirm_confirm_type ON phpbb_confirm (confirm_type) -/ - -/* - Table: 'phpbb_disallow' -*/ -CREATE TABLE phpbb_disallow ( - disallow_id number(8) NOT NULL, - disallow_username varchar2(765) DEFAULT '' , - CONSTRAINT pk_phpbb_disallow PRIMARY KEY (disallow_id) -) -/ - - -CREATE SEQUENCE phpbb_disallow_seq -/ - -CREATE OR REPLACE TRIGGER t_phpbb_disallow -BEFORE INSERT ON phpbb_disallow -FOR EACH ROW WHEN ( - new.disallow_id IS NULL OR new.disallow_id = 0 -) -BEGIN - SELECT phpbb_disallow_seq.nextval - INTO :new.disallow_id - FROM dual; -END; -/ - - -/* - Table: 'phpbb_drafts' -*/ -CREATE TABLE phpbb_drafts ( - draft_id number(8) NOT NULL, - user_id number(8) DEFAULT '0' NOT NULL, - topic_id number(8) DEFAULT '0' NOT NULL, - forum_id number(8) DEFAULT '0' NOT NULL, - save_time number(11) DEFAULT '0' NOT NULL, - draft_subject varchar2(765) DEFAULT '' , - draft_message clob DEFAULT '' , - CONSTRAINT pk_phpbb_drafts PRIMARY KEY (draft_id) -) -/ - -CREATE INDEX phpbb_drafts_save_time ON phpbb_drafts (save_time) -/ - -CREATE SEQUENCE phpbb_drafts_seq -/ - -CREATE OR REPLACE TRIGGER t_phpbb_drafts -BEFORE INSERT ON phpbb_drafts -FOR EACH ROW WHEN ( - new.draft_id IS NULL OR new.draft_id = 0 -) -BEGIN - SELECT phpbb_drafts_seq.nextval - INTO :new.draft_id - FROM dual; -END; -/ - - -/* - Table: 'phpbb_ext' -*/ -CREATE TABLE phpbb_ext ( - ext_name varchar2(255) DEFAULT '' , - ext_active number(1) DEFAULT '0' NOT NULL, - ext_state clob DEFAULT '' , - CONSTRAINT u_phpbb_ext_name UNIQUE (ext_name) -) -/ - - -/* - Table: 'phpbb_extensions' -*/ -CREATE TABLE phpbb_extensions ( - extension_id number(8) NOT NULL, - group_id number(8) DEFAULT '0' NOT NULL, - extension varchar2(100) DEFAULT '' , - CONSTRAINT pk_phpbb_extensions PRIMARY KEY (extension_id) -) -/ - - -CREATE SEQUENCE phpbb_extensions_seq -/ - -CREATE OR REPLACE TRIGGER t_phpbb_extensions -BEFORE INSERT ON phpbb_extensions -FOR EACH ROW WHEN ( - new.extension_id IS NULL OR new.extension_id = 0 -) -BEGIN - SELECT phpbb_extensions_seq.nextval - INTO :new.extension_id - FROM dual; -END; -/ - - -/* - Table: 'phpbb_extension_groups' -*/ -CREATE TABLE phpbb_extension_groups ( - group_id number(8) NOT NULL, - group_name varchar2(765) DEFAULT '' , - cat_id number(2) DEFAULT '0' NOT NULL, - allow_group number(1) DEFAULT '0' NOT NULL, - download_mode number(1) DEFAULT '1' NOT NULL, - upload_icon varchar2(255) DEFAULT '' , - max_filesize number(20) DEFAULT '0' NOT NULL, - allowed_forums clob DEFAULT '' , - allow_in_pm number(1) DEFAULT '0' NOT NULL, - CONSTRAINT pk_phpbb_extension_groups PRIMARY KEY (group_id) -) -/ - - -CREATE SEQUENCE phpbb_extension_groups_seq -/ - -CREATE OR REPLACE TRIGGER t_phpbb_extension_groups -BEFORE INSERT ON phpbb_extension_groups -FOR EACH ROW WHEN ( - new.group_id IS NULL OR new.group_id = 0 -) -BEGIN - SELECT phpbb_extension_groups_seq.nextval - INTO :new.group_id - FROM dual; -END; -/ - - -/* - Table: 'phpbb_forums' -*/ -CREATE TABLE phpbb_forums ( - forum_id number(8) NOT NULL, - parent_id number(8) DEFAULT '0' NOT NULL, - left_id number(8) DEFAULT '0' NOT NULL, - right_id number(8) DEFAULT '0' NOT NULL, - forum_parents clob DEFAULT '' , - forum_name varchar2(765) DEFAULT '' , - forum_desc clob DEFAULT '' , - forum_desc_bitfield varchar2(255) DEFAULT '' , - forum_desc_options number(11) DEFAULT '7' NOT NULL, - forum_desc_uid varchar2(8) DEFAULT '' , - forum_link varchar2(765) DEFAULT '' , - forum_password varchar2(120) DEFAULT '' , - forum_style number(8) DEFAULT '0' NOT NULL, - forum_image varchar2(255) DEFAULT '' , - forum_rules clob DEFAULT '' , - forum_rules_link varchar2(765) DEFAULT '' , - forum_rules_bitfield varchar2(255) DEFAULT '' , - forum_rules_options number(11) DEFAULT '7' NOT NULL, - forum_rules_uid varchar2(8) DEFAULT '' , - forum_topics_per_page number(4) DEFAULT '0' NOT NULL, - forum_type number(4) DEFAULT '0' NOT NULL, - forum_status number(4) DEFAULT '0' NOT NULL, - forum_posts number(8) DEFAULT '0' NOT NULL, - forum_topics number(8) DEFAULT '0' NOT NULL, - forum_topics_real number(8) DEFAULT '0' NOT NULL, - forum_last_post_id number(8) DEFAULT '0' NOT NULL, - forum_last_poster_id number(8) DEFAULT '0' NOT NULL, - forum_last_post_subject varchar2(765) DEFAULT '' , - forum_last_post_time number(11) DEFAULT '0' NOT NULL, - forum_last_poster_name varchar2(765) DEFAULT '' , - forum_last_poster_colour varchar2(6) DEFAULT '' , - forum_flags number(4) DEFAULT '32' NOT NULL, - forum_options number(20) DEFAULT '0' NOT NULL, - display_subforum_list number(1) DEFAULT '1' NOT NULL, - display_on_index number(1) DEFAULT '1' NOT NULL, - enable_indexing number(1) DEFAULT '1' NOT NULL, - enable_icons number(1) DEFAULT '1' NOT NULL, - enable_prune number(1) DEFAULT '0' NOT NULL, - prune_next number(11) DEFAULT '0' NOT NULL, - prune_days number(8) DEFAULT '0' NOT NULL, - prune_viewed number(8) DEFAULT '0' NOT NULL, - prune_freq number(8) DEFAULT '0' NOT NULL, - CONSTRAINT pk_phpbb_forums PRIMARY KEY (forum_id) -) -/ - -CREATE INDEX phpbb_forums_left_right_id ON phpbb_forums (left_id, right_id) -/ -CREATE INDEX phpbb_forums_forum_lastpost_id ON phpbb_forums (forum_last_post_id) -/ - -CREATE SEQUENCE phpbb_forums_seq -/ - -CREATE OR REPLACE TRIGGER t_phpbb_forums -BEFORE INSERT ON phpbb_forums -FOR EACH ROW WHEN ( - new.forum_id IS NULL OR new.forum_id = 0 -) -BEGIN - SELECT phpbb_forums_seq.nextval - INTO :new.forum_id - FROM dual; -END; -/ - - -/* - Table: 'phpbb_forums_access' -*/ -CREATE TABLE phpbb_forums_access ( - forum_id number(8) DEFAULT '0' NOT NULL, - user_id number(8) DEFAULT '0' NOT NULL, - session_id char(32) DEFAULT '' , - CONSTRAINT pk_phpbb_forums_access PRIMARY KEY (forum_id, user_id, session_id) -) -/ - - -/* - Table: 'phpbb_forums_track' -*/ -CREATE TABLE phpbb_forums_track ( - user_id number(8) DEFAULT '0' NOT NULL, - forum_id number(8) DEFAULT '0' NOT NULL, - mark_time number(11) DEFAULT '0' NOT NULL, - CONSTRAINT pk_phpbb_forums_track PRIMARY KEY (user_id, forum_id) -) -/ - - -/* - Table: 'phpbb_forums_watch' -*/ -CREATE TABLE phpbb_forums_watch ( - forum_id number(8) DEFAULT '0' NOT NULL, - user_id number(8) DEFAULT '0' NOT NULL, - notify_status number(1) DEFAULT '0' NOT NULL -) -/ - -CREATE INDEX phpbb_forums_watch_forum_id ON phpbb_forums_watch (forum_id) -/ -CREATE INDEX phpbb_forums_watch_user_id ON phpbb_forums_watch (user_id) -/ -CREATE INDEX phpbb_forums_watch_notify_stat ON phpbb_forums_watch (notify_status) -/ - -/* - Table: 'phpbb_groups' -*/ -CREATE TABLE phpbb_groups ( - group_id number(8) NOT NULL, - group_type number(4) DEFAULT '1' NOT NULL, - group_founder_manage number(1) DEFAULT '0' NOT NULL, - group_skip_auth number(1) DEFAULT '0' NOT NULL, - group_name varchar2(255) DEFAULT '' , - group_desc clob DEFAULT '' , - group_desc_bitfield varchar2(255) DEFAULT '' , - group_desc_options number(11) DEFAULT '7' NOT NULL, - group_desc_uid varchar2(8) DEFAULT '' , - group_display number(1) DEFAULT '0' NOT NULL, - group_avatar varchar2(255) DEFAULT '' , - group_avatar_type number(2) DEFAULT '0' NOT NULL, - group_avatar_width number(4) DEFAULT '0' NOT NULL, - group_avatar_height number(4) DEFAULT '0' NOT NULL, - group_rank number(8) DEFAULT '0' NOT NULL, - group_colour varchar2(6) DEFAULT '' , - group_sig_chars number(8) DEFAULT '0' NOT NULL, - group_receive_pm number(1) DEFAULT '0' NOT NULL, - group_message_limit number(8) DEFAULT '0' NOT NULL, - group_max_recipients number(8) DEFAULT '0' NOT NULL, - group_legend number(8) DEFAULT '0' NOT NULL, - group_teampage number(8) DEFAULT '0' NOT NULL, - CONSTRAINT pk_phpbb_groups PRIMARY KEY (group_id) -) -/ - -CREATE INDEX phpbb_groups_group_legend_name ON phpbb_groups (group_legend, group_name) -/ - -CREATE SEQUENCE phpbb_groups_seq -/ - -CREATE OR REPLACE TRIGGER t_phpbb_groups -BEFORE INSERT ON phpbb_groups -FOR EACH ROW WHEN ( - new.group_id IS NULL OR new.group_id = 0 -) -BEGIN - SELECT phpbb_groups_seq.nextval - INTO :new.group_id - FROM dual; -END; -/ - - -/* - Table: 'phpbb_icons' -*/ -CREATE TABLE phpbb_icons ( - icons_id number(8) NOT NULL, - icons_url varchar2(255) DEFAULT '' , - icons_width number(4) DEFAULT '0' NOT NULL, - icons_height number(4) DEFAULT '0' NOT NULL, - icons_order number(8) DEFAULT '0' NOT NULL, - display_on_posting number(1) DEFAULT '1' NOT NULL, - CONSTRAINT pk_phpbb_icons PRIMARY KEY (icons_id) -) -/ - -CREATE INDEX phpbb_icons_display_on_posting ON phpbb_icons (display_on_posting) -/ - -CREATE SEQUENCE phpbb_icons_seq -/ - -CREATE OR REPLACE TRIGGER t_phpbb_icons -BEFORE INSERT ON phpbb_icons -FOR EACH ROW WHEN ( - new.icons_id IS NULL OR new.icons_id = 0 -) -BEGIN - SELECT phpbb_icons_seq.nextval - INTO :new.icons_id - FROM dual; -END; -/ - - -/* - Table: 'phpbb_lang' -*/ -CREATE TABLE phpbb_lang ( - lang_id number(4) NOT NULL, - lang_iso varchar2(30) DEFAULT '' , - lang_dir varchar2(30) DEFAULT '' , - lang_english_name varchar2(300) DEFAULT '' , - lang_local_name varchar2(765) DEFAULT '' , - lang_author varchar2(765) DEFAULT '' , - CONSTRAINT pk_phpbb_lang PRIMARY KEY (lang_id) -) -/ - -CREATE INDEX phpbb_lang_lang_iso ON phpbb_lang (lang_iso) -/ - -CREATE SEQUENCE phpbb_lang_seq -/ - -CREATE OR REPLACE TRIGGER t_phpbb_lang -BEFORE INSERT ON phpbb_lang -FOR EACH ROW WHEN ( - new.lang_id IS NULL OR new.lang_id = 0 -) -BEGIN - SELECT phpbb_lang_seq.nextval - INTO :new.lang_id - FROM dual; -END; -/ - - -/* - Table: 'phpbb_log' -*/ -CREATE TABLE phpbb_log ( - log_id number(8) NOT NULL, - log_type number(4) DEFAULT '0' NOT NULL, - user_id number(8) DEFAULT '0' NOT NULL, - forum_id number(8) DEFAULT '0' NOT NULL, - topic_id number(8) DEFAULT '0' NOT NULL, - reportee_id number(8) DEFAULT '0' NOT NULL, - log_ip varchar2(40) DEFAULT '' , - log_time number(11) DEFAULT '0' NOT NULL, - log_operation clob DEFAULT '' , - log_data clob DEFAULT '' , - CONSTRAINT pk_phpbb_log PRIMARY KEY (log_id) -) -/ - -CREATE INDEX phpbb_log_log_type ON phpbb_log (log_type) -/ -CREATE INDEX phpbb_log_log_time ON phpbb_log (log_time) -/ -CREATE INDEX phpbb_log_forum_id ON phpbb_log (forum_id) -/ -CREATE INDEX phpbb_log_topic_id ON phpbb_log (topic_id) -/ -CREATE INDEX phpbb_log_reportee_id ON phpbb_log (reportee_id) -/ -CREATE INDEX phpbb_log_user_id ON phpbb_log (user_id) -/ - -CREATE SEQUENCE phpbb_log_seq -/ - -CREATE OR REPLACE TRIGGER t_phpbb_log -BEFORE INSERT ON phpbb_log -FOR EACH ROW WHEN ( - new.log_id IS NULL OR new.log_id = 0 -) -BEGIN - SELECT phpbb_log_seq.nextval - INTO :new.log_id - FROM dual; -END; -/ - - -/* - Table: 'phpbb_login_attempts' -*/ -CREATE TABLE phpbb_login_attempts ( - attempt_ip varchar2(40) DEFAULT '' , - attempt_browser varchar2(150) DEFAULT '' , - attempt_forwarded_for varchar2(255) DEFAULT '' , - attempt_time number(11) DEFAULT '0' NOT NULL, - user_id number(8) DEFAULT '0' NOT NULL, - username varchar2(765) DEFAULT '0' NOT NULL, - username_clean varchar2(255) DEFAULT '0' NOT NULL -) -/ - -CREATE INDEX phpbb_login_attempts_att_ip ON phpbb_login_attempts (attempt_ip, attempt_time) -/ -CREATE INDEX phpbb_login_attempts_att_for ON phpbb_login_attempts (attempt_forwarded_for, attempt_time) -/ -CREATE INDEX phpbb_login_attempts_att_time ON phpbb_login_attempts (attempt_time) -/ -CREATE INDEX phpbb_login_attempts_user_id ON phpbb_login_attempts (user_id) -/ - -/* - Table: 'phpbb_moderator_cache' -*/ -CREATE TABLE phpbb_moderator_cache ( - forum_id number(8) DEFAULT '0' NOT NULL, - user_id number(8) DEFAULT '0' NOT NULL, - username varchar2(765) DEFAULT '' , - group_id number(8) DEFAULT '0' NOT NULL, - group_name varchar2(765) DEFAULT '' , - display_on_index number(1) DEFAULT '1' NOT NULL -) -/ - -CREATE INDEX phpbb_moderator_cache_disp_idx ON phpbb_moderator_cache (display_on_index) -/ -CREATE INDEX phpbb_moderator_cache_forum_id ON phpbb_moderator_cache (forum_id) -/ - -/* - Table: 'phpbb_modules' -*/ -CREATE TABLE phpbb_modules ( - module_id number(8) NOT NULL, - module_enabled number(1) DEFAULT '1' NOT NULL, - module_display number(1) DEFAULT '1' NOT NULL, - module_basename varchar2(255) DEFAULT '' , - module_class varchar2(10) DEFAULT '' , - parent_id number(8) DEFAULT '0' NOT NULL, - left_id number(8) DEFAULT '0' NOT NULL, - right_id number(8) DEFAULT '0' NOT NULL, - module_langname varchar2(255) DEFAULT '' , - module_mode varchar2(255) DEFAULT '' , - module_auth varchar2(255) DEFAULT '' , - CONSTRAINT pk_phpbb_modules PRIMARY KEY (module_id) -) -/ - -CREATE INDEX phpbb_modules_left_right_id ON phpbb_modules (left_id, right_id) -/ -CREATE INDEX phpbb_modules_module_enabled ON phpbb_modules (module_enabled) -/ -CREATE INDEX phpbb_modules_class_left_id ON phpbb_modules (module_class, left_id) -/ - -CREATE SEQUENCE phpbb_modules_seq -/ - -CREATE OR REPLACE TRIGGER t_phpbb_modules -BEFORE INSERT ON phpbb_modules -FOR EACH ROW WHEN ( - new.module_id IS NULL OR new.module_id = 0 -) -BEGIN - SELECT phpbb_modules_seq.nextval - INTO :new.module_id - FROM dual; -END; -/ - - -/* - Table: 'phpbb_poll_options' -*/ -CREATE TABLE phpbb_poll_options ( - poll_option_id number(4) DEFAULT '0' NOT NULL, - topic_id number(8) DEFAULT '0' NOT NULL, - poll_option_text clob DEFAULT '' , - poll_option_total number(8) DEFAULT '0' NOT NULL -) -/ - -CREATE INDEX phpbb_poll_options_poll_opt_id ON phpbb_poll_options (poll_option_id) -/ -CREATE INDEX phpbb_poll_options_topic_id ON phpbb_poll_options (topic_id) -/ - -/* - Table: 'phpbb_poll_votes' -*/ -CREATE TABLE phpbb_poll_votes ( - topic_id number(8) DEFAULT '0' NOT NULL, - poll_option_id number(4) DEFAULT '0' NOT NULL, - vote_user_id number(8) DEFAULT '0' NOT NULL, - vote_user_ip varchar2(40) DEFAULT '' -) -/ - -CREATE INDEX phpbb_poll_votes_topic_id ON phpbb_poll_votes (topic_id) -/ -CREATE INDEX phpbb_poll_votes_vote_user_id ON phpbb_poll_votes (vote_user_id) -/ -CREATE INDEX phpbb_poll_votes_vote_user_ip ON phpbb_poll_votes (vote_user_ip) -/ - -/* - Table: 'phpbb_posts' -*/ -CREATE TABLE phpbb_posts ( - post_id number(8) NOT NULL, - topic_id number(8) DEFAULT '0' NOT NULL, - forum_id number(8) DEFAULT '0' NOT NULL, - poster_id number(8) DEFAULT '0' NOT NULL, - icon_id number(8) DEFAULT '0' NOT NULL, - poster_ip varchar2(40) DEFAULT '' , - post_time number(11) DEFAULT '0' NOT NULL, - post_approved number(1) DEFAULT '1' NOT NULL, - post_reported number(1) DEFAULT '0' NOT NULL, - enable_bbcode number(1) DEFAULT '1' NOT NULL, - enable_smilies number(1) DEFAULT '1' NOT NULL, - enable_magic_url number(1) DEFAULT '1' NOT NULL, - enable_sig number(1) DEFAULT '1' NOT NULL, - post_username varchar2(765) DEFAULT '' , - post_subject varchar2(765) DEFAULT '' , - post_text clob DEFAULT '' , - post_checksum varchar2(32) DEFAULT '' , - post_attachment number(1) DEFAULT '0' NOT NULL, - bbcode_bitfield varchar2(255) DEFAULT '' , - bbcode_uid varchar2(8) DEFAULT '' , - post_postcount number(1) DEFAULT '1' NOT NULL, - post_edit_time number(11) DEFAULT '0' NOT NULL, - post_edit_reason varchar2(765) DEFAULT '' , - post_edit_user number(8) DEFAULT '0' NOT NULL, - post_edit_count number(4) DEFAULT '0' NOT NULL, - post_edit_locked number(1) DEFAULT '0' NOT NULL, - CONSTRAINT pk_phpbb_posts PRIMARY KEY (post_id) -) -/ - -CREATE INDEX phpbb_posts_forum_id ON phpbb_posts (forum_id) -/ -CREATE INDEX phpbb_posts_topic_id ON phpbb_posts (topic_id) -/ -CREATE INDEX phpbb_posts_poster_ip ON phpbb_posts (poster_ip) -/ -CREATE INDEX phpbb_posts_poster_id ON phpbb_posts (poster_id) -/ -CREATE INDEX phpbb_posts_post_approved ON phpbb_posts (post_approved) -/ -CREATE INDEX phpbb_posts_post_username ON phpbb_posts (post_username) -/ -CREATE INDEX phpbb_posts_tid_post_time ON phpbb_posts (topic_id, post_time) -/ - -CREATE SEQUENCE phpbb_posts_seq -/ - -CREATE OR REPLACE TRIGGER t_phpbb_posts -BEFORE INSERT ON phpbb_posts -FOR EACH ROW WHEN ( - new.post_id IS NULL OR new.post_id = 0 -) -BEGIN - SELECT phpbb_posts_seq.nextval - INTO :new.post_id - FROM dual; -END; -/ - - -/* - Table: 'phpbb_privmsgs' -*/ -CREATE TABLE phpbb_privmsgs ( - msg_id number(8) NOT NULL, - root_level number(8) DEFAULT '0' NOT NULL, - author_id number(8) DEFAULT '0' NOT NULL, - icon_id number(8) DEFAULT '0' NOT NULL, - author_ip varchar2(40) DEFAULT '' , - message_time number(11) DEFAULT '0' NOT NULL, - enable_bbcode number(1) DEFAULT '1' NOT NULL, - enable_smilies number(1) DEFAULT '1' NOT NULL, - enable_magic_url number(1) DEFAULT '1' NOT NULL, - enable_sig number(1) DEFAULT '1' NOT NULL, - message_subject varchar2(765) DEFAULT '' , - message_text clob DEFAULT '' , - message_edit_reason varchar2(765) DEFAULT '' , - message_edit_user number(8) DEFAULT '0' NOT NULL, - message_attachment number(1) DEFAULT '0' NOT NULL, - bbcode_bitfield varchar2(255) DEFAULT '' , - bbcode_uid varchar2(8) DEFAULT '' , - message_edit_time number(11) DEFAULT '0' NOT NULL, - message_edit_count number(4) DEFAULT '0' NOT NULL, - to_address clob DEFAULT '' , - bcc_address clob DEFAULT '' , - message_reported number(1) DEFAULT '0' NOT NULL, - CONSTRAINT pk_phpbb_privmsgs PRIMARY KEY (msg_id) -) -/ - -CREATE INDEX phpbb_privmsgs_author_ip ON phpbb_privmsgs (author_ip) -/ -CREATE INDEX phpbb_privmsgs_message_time ON phpbb_privmsgs (message_time) -/ -CREATE INDEX phpbb_privmsgs_author_id ON phpbb_privmsgs (author_id) -/ -CREATE INDEX phpbb_privmsgs_root_level ON phpbb_privmsgs (root_level) -/ - -CREATE SEQUENCE phpbb_privmsgs_seq -/ - -CREATE OR REPLACE TRIGGER t_phpbb_privmsgs -BEFORE INSERT ON phpbb_privmsgs -FOR EACH ROW WHEN ( - new.msg_id IS NULL OR new.msg_id = 0 -) -BEGIN - SELECT phpbb_privmsgs_seq.nextval - INTO :new.msg_id - FROM dual; -END; -/ - - -/* - Table: 'phpbb_privmsgs_folder' -*/ -CREATE TABLE phpbb_privmsgs_folder ( - folder_id number(8) NOT NULL, - user_id number(8) DEFAULT '0' NOT NULL, - folder_name varchar2(765) DEFAULT '' , - pm_count number(8) DEFAULT '0' NOT NULL, - CONSTRAINT pk_phpbb_privmsgs_folder PRIMARY KEY (folder_id) -) -/ - -CREATE INDEX phpbb_privmsgs_folder_user_id ON phpbb_privmsgs_folder (user_id) -/ - -CREATE SEQUENCE phpbb_privmsgs_folder_seq -/ - -CREATE OR REPLACE TRIGGER t_phpbb_privmsgs_folder -BEFORE INSERT ON phpbb_privmsgs_folder -FOR EACH ROW WHEN ( - new.folder_id IS NULL OR new.folder_id = 0 -) -BEGIN - SELECT phpbb_privmsgs_folder_seq.nextval - INTO :new.folder_id - FROM dual; -END; -/ - - -/* - Table: 'phpbb_privmsgs_rules' -*/ -CREATE TABLE phpbb_privmsgs_rules ( - rule_id number(8) NOT NULL, - user_id number(8) DEFAULT '0' NOT NULL, - rule_check number(8) DEFAULT '0' NOT NULL, - rule_connection number(8) DEFAULT '0' NOT NULL, - rule_string varchar2(765) DEFAULT '' , - rule_user_id number(8) DEFAULT '0' NOT NULL, - rule_group_id number(8) DEFAULT '0' NOT NULL, - rule_action number(8) DEFAULT '0' NOT NULL, - rule_folder_id number(11) DEFAULT '0' NOT NULL, - CONSTRAINT pk_phpbb_privmsgs_rules PRIMARY KEY (rule_id) -) -/ - -CREATE INDEX phpbb_privmsgs_rules_user_id ON phpbb_privmsgs_rules (user_id) -/ - -CREATE SEQUENCE phpbb_privmsgs_rules_seq -/ - -CREATE OR REPLACE TRIGGER t_phpbb_privmsgs_rules -BEFORE INSERT ON phpbb_privmsgs_rules -FOR EACH ROW WHEN ( - new.rule_id IS NULL OR new.rule_id = 0 -) -BEGIN - SELECT phpbb_privmsgs_rules_seq.nextval - INTO :new.rule_id - FROM dual; -END; -/ - - -/* - Table: 'phpbb_privmsgs_to' -*/ -CREATE TABLE phpbb_privmsgs_to ( - msg_id number(8) DEFAULT '0' NOT NULL, - user_id number(8) DEFAULT '0' NOT NULL, - author_id number(8) DEFAULT '0' NOT NULL, - pm_deleted number(1) DEFAULT '0' NOT NULL, - pm_new number(1) DEFAULT '1' NOT NULL, - pm_unread number(1) DEFAULT '1' NOT NULL, - pm_replied number(1) DEFAULT '0' NOT NULL, - pm_marked number(1) DEFAULT '0' NOT NULL, - pm_forwarded number(1) DEFAULT '0' NOT NULL, - folder_id number(11) DEFAULT '0' NOT NULL -) -/ - -CREATE INDEX phpbb_privmsgs_to_msg_id ON phpbb_privmsgs_to (msg_id) -/ -CREATE INDEX phpbb_privmsgs_to_author_id ON phpbb_privmsgs_to (author_id) -/ -CREATE INDEX phpbb_privmsgs_to_usr_flder_id ON phpbb_privmsgs_to (user_id, folder_id) -/ - -/* - Table: 'phpbb_profile_fields' -*/ -CREATE TABLE phpbb_profile_fields ( - field_id number(8) NOT NULL, - field_name varchar2(765) DEFAULT '' , - field_type number(4) DEFAULT '0' NOT NULL, - field_ident varchar2(20) DEFAULT '' , - field_length varchar2(20) DEFAULT '' , - field_minlen varchar2(255) DEFAULT '' , - field_maxlen varchar2(255) DEFAULT '' , - field_novalue varchar2(765) DEFAULT '' , - field_default_value varchar2(765) DEFAULT '' , - field_validation varchar2(60) DEFAULT '' , - field_required number(1) DEFAULT '0' NOT NULL, - field_show_novalue number(1) DEFAULT '0' NOT NULL, - field_show_on_reg number(1) DEFAULT '0' NOT NULL, - field_show_on_pm number(1) DEFAULT '0' NOT NULL, - field_show_on_vt number(1) DEFAULT '0' NOT NULL, - field_show_profile number(1) DEFAULT '0' NOT NULL, - field_hide number(1) DEFAULT '0' NOT NULL, - field_no_view number(1) DEFAULT '0' NOT NULL, - field_active number(1) DEFAULT '0' NOT NULL, - field_order number(8) DEFAULT '0' NOT NULL, - CONSTRAINT pk_phpbb_profile_fields PRIMARY KEY (field_id) -) -/ - -CREATE INDEX phpbb_profile_fields_fld_type ON phpbb_profile_fields (field_type) -/ -CREATE INDEX phpbb_profile_fields_fld_ordr ON phpbb_profile_fields (field_order) -/ - -CREATE SEQUENCE phpbb_profile_fields_seq -/ - -CREATE OR REPLACE TRIGGER t_phpbb_profile_fields -BEFORE INSERT ON phpbb_profile_fields -FOR EACH ROW WHEN ( - new.field_id IS NULL OR new.field_id = 0 -) -BEGIN - SELECT phpbb_profile_fields_seq.nextval - INTO :new.field_id - FROM dual; -END; -/ - - -/* - Table: 'phpbb_profile_fields_data' -*/ -CREATE TABLE phpbb_profile_fields_data ( - user_id number(8) DEFAULT '0' NOT NULL, - CONSTRAINT pk_phpbb_profile_fields_data PRIMARY KEY (user_id) -) -/ - - -/* - Table: 'phpbb_profile_fields_lang' -*/ -CREATE TABLE phpbb_profile_fields_lang ( - field_id number(8) DEFAULT '0' NOT NULL, - lang_id number(8) DEFAULT '0' NOT NULL, - option_id number(8) DEFAULT '0' NOT NULL, - field_type number(4) DEFAULT '0' NOT NULL, - lang_value varchar2(765) DEFAULT '' , - CONSTRAINT pk_phpbb_profile_fields_lang PRIMARY KEY (field_id, lang_id, option_id) -) -/ - - -/* - Table: 'phpbb_profile_lang' -*/ -CREATE TABLE phpbb_profile_lang ( - field_id number(8) DEFAULT '0' NOT NULL, - lang_id number(8) DEFAULT '0' NOT NULL, - lang_name varchar2(765) DEFAULT '' , - lang_explain clob DEFAULT '' , - lang_default_value varchar2(765) DEFAULT '' , - CONSTRAINT pk_phpbb_profile_lang PRIMARY KEY (field_id, lang_id) -) -/ - - -/* - Table: 'phpbb_ranks' -*/ -CREATE TABLE phpbb_ranks ( - rank_id number(8) NOT NULL, - rank_title varchar2(765) DEFAULT '' , - rank_min number(8) DEFAULT '0' NOT NULL, - rank_special number(1) DEFAULT '0' NOT NULL, - rank_image varchar2(255) DEFAULT '' , - CONSTRAINT pk_phpbb_ranks PRIMARY KEY (rank_id) -) -/ - - -CREATE SEQUENCE phpbb_ranks_seq -/ - -CREATE OR REPLACE TRIGGER t_phpbb_ranks -BEFORE INSERT ON phpbb_ranks -FOR EACH ROW WHEN ( - new.rank_id IS NULL OR new.rank_id = 0 -) -BEGIN - SELECT phpbb_ranks_seq.nextval - INTO :new.rank_id - FROM dual; -END; -/ - - -/* - Table: 'phpbb_reports' -*/ -CREATE TABLE phpbb_reports ( - report_id number(8) NOT NULL, - reason_id number(4) DEFAULT '0' NOT NULL, - post_id number(8) DEFAULT '0' NOT NULL, - pm_id number(8) DEFAULT '0' NOT NULL, - user_id number(8) DEFAULT '0' NOT NULL, - user_notify number(1) DEFAULT '0' NOT NULL, - report_closed number(1) DEFAULT '0' NOT NULL, - report_time number(11) DEFAULT '0' NOT NULL, - report_text clob DEFAULT '' , - reported_post_text clob DEFAULT '' , - CONSTRAINT pk_phpbb_reports PRIMARY KEY (report_id) -) -/ - -CREATE INDEX phpbb_reports_post_id ON phpbb_reports (post_id) -/ -CREATE INDEX phpbb_reports_pm_id ON phpbb_reports (pm_id) -/ - -CREATE SEQUENCE phpbb_reports_seq -/ - -CREATE OR REPLACE TRIGGER t_phpbb_reports -BEFORE INSERT ON phpbb_reports -FOR EACH ROW WHEN ( - new.report_id IS NULL OR new.report_id = 0 -) -BEGIN - SELECT phpbb_reports_seq.nextval - INTO :new.report_id - FROM dual; -END; -/ - - -/* - Table: 'phpbb_reports_reasons' -*/ -CREATE TABLE phpbb_reports_reasons ( - reason_id number(4) NOT NULL, - reason_title varchar2(765) DEFAULT '' , - reason_description clob DEFAULT '' , - reason_order number(4) DEFAULT '0' NOT NULL, - CONSTRAINT pk_phpbb_reports_reasons PRIMARY KEY (reason_id) -) -/ - - -CREATE SEQUENCE phpbb_reports_reasons_seq -/ - -CREATE OR REPLACE TRIGGER t_phpbb_reports_reasons -BEFORE INSERT ON phpbb_reports_reasons -FOR EACH ROW WHEN ( - new.reason_id IS NULL OR new.reason_id = 0 -) -BEGIN - SELECT phpbb_reports_reasons_seq.nextval - INTO :new.reason_id - FROM dual; -END; -/ - - -/* - Table: 'phpbb_search_results' -*/ -CREATE TABLE phpbb_search_results ( - search_key varchar2(32) DEFAULT '' , - search_time number(11) DEFAULT '0' NOT NULL, - search_keywords clob DEFAULT '' , - search_authors clob DEFAULT '' , - CONSTRAINT pk_phpbb_search_results PRIMARY KEY (search_key) -) -/ - - -/* - Table: 'phpbb_search_wordlist' -*/ -CREATE TABLE phpbb_search_wordlist ( - word_id number(8) NOT NULL, - word_text varchar2(765) DEFAULT '' , - word_common number(1) DEFAULT '0' NOT NULL, - word_count number(8) DEFAULT '0' NOT NULL, - CONSTRAINT pk_phpbb_search_wordlist PRIMARY KEY (word_id), - CONSTRAINT u_phpbb_wrd_txt UNIQUE (word_text) -) -/ - -CREATE INDEX phpbb_search_wordlist_wrd_cnt ON phpbb_search_wordlist (word_count) -/ - -CREATE SEQUENCE phpbb_search_wordlist_seq -/ - -CREATE OR REPLACE TRIGGER t_phpbb_search_wordlist -BEFORE INSERT ON phpbb_search_wordlist -FOR EACH ROW WHEN ( - new.word_id IS NULL OR new.word_id = 0 -) -BEGIN - SELECT phpbb_search_wordlist_seq.nextval - INTO :new.word_id - FROM dual; -END; -/ - - -/* - Table: 'phpbb_search_wordmatch' -*/ -CREATE TABLE phpbb_search_wordmatch ( - post_id number(8) DEFAULT '0' NOT NULL, - word_id number(8) DEFAULT '0' NOT NULL, - title_match number(1) DEFAULT '0' NOT NULL, - CONSTRAINT u_phpbb_unq_mtch UNIQUE (word_id, post_id, title_match) -) -/ - -CREATE INDEX phpbb_search_wordmatch_word_id ON phpbb_search_wordmatch (word_id) -/ -CREATE INDEX phpbb_search_wordmatch_post_id ON phpbb_search_wordmatch (post_id) -/ - -/* - Table: 'phpbb_sessions' -*/ -CREATE TABLE phpbb_sessions ( - session_id char(32) DEFAULT '' , - session_user_id number(8) DEFAULT '0' NOT NULL, - session_forum_id number(8) DEFAULT '0' NOT NULL, - session_last_visit number(11) DEFAULT '0' NOT NULL, - session_start number(11) DEFAULT '0' NOT NULL, - session_time number(11) DEFAULT '0' NOT NULL, - session_ip varchar2(40) DEFAULT '' , - session_browser varchar2(150) DEFAULT '' , - session_forwarded_for varchar2(255) DEFAULT '' , - session_page varchar2(765) DEFAULT '' , - session_viewonline number(1) DEFAULT '1' NOT NULL, - session_autologin number(1) DEFAULT '0' NOT NULL, - session_admin number(1) DEFAULT '0' NOT NULL, - CONSTRAINT pk_phpbb_sessions PRIMARY KEY (session_id) -) -/ - -CREATE INDEX phpbb_sessions_session_time ON phpbb_sessions (session_time) -/ -CREATE INDEX phpbb_sessions_session_user_id ON phpbb_sessions (session_user_id) -/ -CREATE INDEX phpbb_sessions_session_fid ON phpbb_sessions (session_forum_id) -/ - -/* - Table: 'phpbb_sessions_keys' -*/ -CREATE TABLE phpbb_sessions_keys ( - key_id char(32) DEFAULT '' , - user_id number(8) DEFAULT '0' NOT NULL, - last_ip varchar2(40) DEFAULT '' , - last_login number(11) DEFAULT '0' NOT NULL, - CONSTRAINT pk_phpbb_sessions_keys PRIMARY KEY (key_id, user_id) -) -/ - -CREATE INDEX phpbb_sessions_keys_last_login ON phpbb_sessions_keys (last_login) -/ - -/* - Table: 'phpbb_sitelist' -*/ -CREATE TABLE phpbb_sitelist ( - site_id number(8) NOT NULL, - site_ip varchar2(40) DEFAULT '' , - site_hostname varchar2(255) DEFAULT '' , - ip_exclude number(1) DEFAULT '0' NOT NULL, - CONSTRAINT pk_phpbb_sitelist PRIMARY KEY (site_id) -) -/ - - -CREATE SEQUENCE phpbb_sitelist_seq -/ - -CREATE OR REPLACE TRIGGER t_phpbb_sitelist -BEFORE INSERT ON phpbb_sitelist -FOR EACH ROW WHEN ( - new.site_id IS NULL OR new.site_id = 0 -) -BEGIN - SELECT phpbb_sitelist_seq.nextval - INTO :new.site_id - FROM dual; -END; -/ - - -/* - Table: 'phpbb_smilies' -*/ -CREATE TABLE phpbb_smilies ( - smiley_id number(8) NOT NULL, - code varchar2(150) DEFAULT '' , - emotion varchar2(150) DEFAULT '' , - smiley_url varchar2(50) DEFAULT '' , - smiley_width number(4) DEFAULT '0' NOT NULL, - smiley_height number(4) DEFAULT '0' NOT NULL, - smiley_order number(8) DEFAULT '0' NOT NULL, - display_on_posting number(1) DEFAULT '1' NOT NULL, - CONSTRAINT pk_phpbb_smilies PRIMARY KEY (smiley_id) -) -/ - -CREATE INDEX phpbb_smilies_display_on_post ON phpbb_smilies (display_on_posting) -/ - -CREATE SEQUENCE phpbb_smilies_seq -/ - -CREATE OR REPLACE TRIGGER t_phpbb_smilies -BEFORE INSERT ON phpbb_smilies -FOR EACH ROW WHEN ( - new.smiley_id IS NULL OR new.smiley_id = 0 -) -BEGIN - SELECT phpbb_smilies_seq.nextval - INTO :new.smiley_id - FROM dual; -END; -/ - - -/* - Table: 'phpbb_styles' -*/ -CREATE TABLE phpbb_styles ( - style_id number(8) NOT NULL, - style_name varchar2(765) DEFAULT '' , - style_copyright varchar2(765) DEFAULT '' , - style_active number(1) DEFAULT '1' NOT NULL, - style_path varchar2(100) DEFAULT '' , - bbcode_bitfield varchar2(255) DEFAULT 'kNg=' NOT NULL, - style_parent_id number(4) DEFAULT '0' NOT NULL, - style_parent_tree clob DEFAULT '' , - CONSTRAINT pk_phpbb_styles PRIMARY KEY (style_id), - CONSTRAINT u_phpbb_style_name UNIQUE (style_name) -) -/ - - -CREATE SEQUENCE phpbb_styles_seq -/ - -CREATE OR REPLACE TRIGGER t_phpbb_styles -BEFORE INSERT ON phpbb_styles -FOR EACH ROW WHEN ( - new.style_id IS NULL OR new.style_id = 0 -) -BEGIN - SELECT phpbb_styles_seq.nextval - INTO :new.style_id - FROM dual; -END; -/ - - -/* - Table: 'phpbb_topics' -*/ -CREATE TABLE phpbb_topics ( - topic_id number(8) NOT NULL, - forum_id number(8) DEFAULT '0' NOT NULL, - icon_id number(8) DEFAULT '0' NOT NULL, - topic_attachment number(1) DEFAULT '0' NOT NULL, - topic_approved number(1) DEFAULT '1' NOT NULL, - topic_reported number(1) DEFAULT '0' NOT NULL, - topic_title varchar2(765) DEFAULT '' , - topic_poster number(8) DEFAULT '0' NOT NULL, - topic_time number(11) DEFAULT '0' NOT NULL, - topic_time_limit number(11) DEFAULT '0' NOT NULL, - topic_views number(8) DEFAULT '0' NOT NULL, - topic_replies number(8) DEFAULT '0' NOT NULL, - topic_replies_real number(8) DEFAULT '0' NOT NULL, - topic_status number(3) DEFAULT '0' NOT NULL, - topic_type number(3) DEFAULT '0' NOT NULL, - topic_first_post_id number(8) DEFAULT '0' NOT NULL, - topic_first_poster_name varchar2(765) DEFAULT '' , - topic_first_poster_colour varchar2(6) DEFAULT '' , - topic_last_post_id number(8) DEFAULT '0' NOT NULL, - topic_last_poster_id number(8) DEFAULT '0' NOT NULL, - topic_last_poster_name varchar2(765) DEFAULT '' , - topic_last_poster_colour varchar2(6) DEFAULT '' , - topic_last_post_subject varchar2(765) DEFAULT '' , - topic_last_post_time number(11) DEFAULT '0' NOT NULL, - topic_last_view_time number(11) DEFAULT '0' NOT NULL, - topic_moved_id number(8) DEFAULT '0' NOT NULL, - topic_bumped number(1) DEFAULT '0' NOT NULL, - topic_bumper number(8) DEFAULT '0' NOT NULL, - poll_title varchar2(765) DEFAULT '' , - poll_start number(11) DEFAULT '0' NOT NULL, - poll_length number(11) DEFAULT '0' NOT NULL, - poll_max_options number(4) DEFAULT '1' NOT NULL, - poll_last_vote number(11) DEFAULT '0' NOT NULL, - poll_vote_change number(1) DEFAULT '0' NOT NULL, - CONSTRAINT pk_phpbb_topics PRIMARY KEY (topic_id) -) -/ - -CREATE INDEX phpbb_topics_forum_id ON phpbb_topics (forum_id) -/ -CREATE INDEX phpbb_topics_forum_id_type ON phpbb_topics (forum_id, topic_type) -/ -CREATE INDEX phpbb_topics_last_post_time ON phpbb_topics (topic_last_post_time) -/ -CREATE INDEX phpbb_topics_topic_approved ON phpbb_topics (topic_approved) -/ -CREATE INDEX phpbb_topics_forum_appr_last ON phpbb_topics (forum_id, topic_approved, topic_last_post_id) -/ -CREATE INDEX phpbb_topics_fid_time_moved ON phpbb_topics (forum_id, topic_last_post_time, topic_moved_id) -/ - -CREATE SEQUENCE phpbb_topics_seq -/ - -CREATE OR REPLACE TRIGGER t_phpbb_topics -BEFORE INSERT ON phpbb_topics -FOR EACH ROW WHEN ( - new.topic_id IS NULL OR new.topic_id = 0 -) -BEGIN - SELECT phpbb_topics_seq.nextval - INTO :new.topic_id - FROM dual; -END; -/ - - -/* - Table: 'phpbb_topics_track' -*/ -CREATE TABLE phpbb_topics_track ( - user_id number(8) DEFAULT '0' NOT NULL, - topic_id number(8) DEFAULT '0' NOT NULL, - forum_id number(8) DEFAULT '0' NOT NULL, - mark_time number(11) DEFAULT '0' NOT NULL, - CONSTRAINT pk_phpbb_topics_track PRIMARY KEY (user_id, topic_id) -) -/ - -CREATE INDEX phpbb_topics_track_topic_id ON phpbb_topics_track (topic_id) -/ -CREATE INDEX phpbb_topics_track_forum_id ON phpbb_topics_track (forum_id) -/ - -/* - Table: 'phpbb_topics_posted' -*/ -CREATE TABLE phpbb_topics_posted ( - user_id number(8) DEFAULT '0' NOT NULL, - topic_id number(8) DEFAULT '0' NOT NULL, - topic_posted number(1) DEFAULT '0' NOT NULL, - CONSTRAINT pk_phpbb_topics_posted PRIMARY KEY (user_id, topic_id) -) -/ - - -/* - Table: 'phpbb_topics_watch' -*/ -CREATE TABLE phpbb_topics_watch ( - topic_id number(8) DEFAULT '0' NOT NULL, - user_id number(8) DEFAULT '0' NOT NULL, - notify_status number(1) DEFAULT '0' NOT NULL -) -/ - -CREATE INDEX phpbb_topics_watch_topic_id ON phpbb_topics_watch (topic_id) -/ -CREATE INDEX phpbb_topics_watch_user_id ON phpbb_topics_watch (user_id) -/ -CREATE INDEX phpbb_topics_watch_notify_stat ON phpbb_topics_watch (notify_status) -/ - -/* - Table: 'phpbb_user_group' -*/ -CREATE TABLE phpbb_user_group ( - group_id number(8) DEFAULT '0' NOT NULL, - user_id number(8) DEFAULT '0' NOT NULL, - group_leader number(1) DEFAULT '0' NOT NULL, - user_pending number(1) DEFAULT '1' NOT NULL -) -/ - -CREATE INDEX phpbb_user_group_group_id ON phpbb_user_group (group_id) -/ -CREATE INDEX phpbb_user_group_user_id ON phpbb_user_group (user_id) -/ -CREATE INDEX phpbb_user_group_group_leader ON phpbb_user_group (group_leader) -/ - -/* - Table: 'phpbb_users' -*/ -CREATE TABLE phpbb_users ( - user_id number(8) NOT NULL, - user_type number(2) DEFAULT '0' NOT NULL, - group_id number(8) DEFAULT '3' NOT NULL, - user_permissions clob DEFAULT '' , - user_perm_from number(8) DEFAULT '0' NOT NULL, - user_ip varchar2(40) DEFAULT '' , - user_regdate number(11) DEFAULT '0' NOT NULL, - username varchar2(255) DEFAULT '' , - username_clean varchar2(255) DEFAULT '' , - user_password varchar2(120) DEFAULT '' , - user_passchg number(11) DEFAULT '0' NOT NULL, - user_pass_convert number(1) DEFAULT '0' NOT NULL, - user_email varchar2(300) DEFAULT '' , - user_email_hash number(20) DEFAULT '0' NOT NULL, - user_birthday varchar2(10) DEFAULT '' , - user_lastvisit number(11) DEFAULT '0' NOT NULL, - user_lastmark number(11) DEFAULT '0' NOT NULL, - user_lastpost_time number(11) DEFAULT '0' NOT NULL, - user_lastpage varchar2(600) DEFAULT '' , - user_last_confirm_key varchar2(10) DEFAULT '' , - user_last_search number(11) DEFAULT '0' NOT NULL, - user_warnings number(4) DEFAULT '0' NOT NULL, - user_last_warning number(11) DEFAULT '0' NOT NULL, - user_login_attempts number(4) DEFAULT '0' NOT NULL, - user_inactive_reason number(2) DEFAULT '0' NOT NULL, - user_inactive_time number(11) DEFAULT '0' NOT NULL, - user_posts number(8) DEFAULT '0' NOT NULL, - user_lang varchar2(30) DEFAULT '' , - user_timezone varchar2(100) DEFAULT 'UTC' NOT NULL, - user_dateformat varchar2(90) DEFAULT 'd M Y H:i' NOT NULL, - user_style number(8) DEFAULT '0' NOT NULL, - user_rank number(8) DEFAULT '0' NOT NULL, - user_colour varchar2(6) DEFAULT '' , - user_new_privmsg number(4) DEFAULT '0' NOT NULL, - user_unread_privmsg number(4) DEFAULT '0' NOT NULL, - user_last_privmsg number(11) DEFAULT '0' NOT NULL, - user_message_rules number(1) DEFAULT '0' NOT NULL, - user_full_folder number(11) DEFAULT '-3' NOT NULL, - user_emailtime number(11) DEFAULT '0' NOT NULL, - user_topic_show_days number(4) DEFAULT '0' NOT NULL, - user_topic_sortby_type varchar2(1) DEFAULT 't' NOT NULL, - user_topic_sortby_dir varchar2(1) DEFAULT 'd' NOT NULL, - user_post_show_days number(4) DEFAULT '0' NOT NULL, - user_post_sortby_type varchar2(1) DEFAULT 't' NOT NULL, - user_post_sortby_dir varchar2(1) DEFAULT 'a' NOT NULL, - user_notify number(1) DEFAULT '0' NOT NULL, - user_notify_pm number(1) DEFAULT '1' NOT NULL, - user_notify_type number(4) DEFAULT '0' NOT NULL, - user_allow_pm number(1) DEFAULT '1' NOT NULL, - user_allow_viewonline number(1) DEFAULT '1' NOT NULL, - user_allow_viewemail number(1) DEFAULT '1' NOT NULL, - user_allow_massemail number(1) DEFAULT '1' NOT NULL, - user_options number(11) DEFAULT '230271' NOT NULL, - user_avatar varchar2(255) DEFAULT '' , - user_avatar_type number(2) DEFAULT '0' NOT NULL, - user_avatar_width number(4) DEFAULT '0' NOT NULL, - user_avatar_height number(4) DEFAULT '0' NOT NULL, - user_sig clob DEFAULT '' , - user_sig_bbcode_uid varchar2(8) DEFAULT '' , - user_sig_bbcode_bitfield varchar2(255) DEFAULT '' , - user_from varchar2(300) DEFAULT '' , - user_icq varchar2(15) DEFAULT '' , - user_aim varchar2(765) DEFAULT '' , - user_yim varchar2(765) DEFAULT '' , - user_msnm varchar2(765) DEFAULT '' , - user_jabber varchar2(765) DEFAULT '' , - user_website varchar2(600) DEFAULT '' , - user_occ clob DEFAULT '' , - user_interests clob DEFAULT '' , - user_actkey varchar2(32) DEFAULT '' , - user_newpasswd varchar2(120) DEFAULT '' , - user_form_salt varchar2(96) DEFAULT '' , - user_new number(1) DEFAULT '1' NOT NULL, - user_reminded number(4) DEFAULT '0' NOT NULL, - user_reminded_time number(11) DEFAULT '0' NOT NULL, - CONSTRAINT pk_phpbb_users PRIMARY KEY (user_id), - CONSTRAINT u_phpbb_username_clean UNIQUE (username_clean) -) -/ - -CREATE INDEX phpbb_users_user_birthday ON phpbb_users (user_birthday) -/ -CREATE INDEX phpbb_users_user_email_hash ON phpbb_users (user_email_hash) -/ -CREATE INDEX phpbb_users_user_type ON phpbb_users (user_type) -/ - -CREATE SEQUENCE phpbb_users_seq -/ - -CREATE OR REPLACE TRIGGER t_phpbb_users -BEFORE INSERT ON phpbb_users -FOR EACH ROW WHEN ( - new.user_id IS NULL OR new.user_id = 0 -) -BEGIN - SELECT phpbb_users_seq.nextval - INTO :new.user_id - FROM dual; -END; -/ - - -/* - Table: 'phpbb_warnings' -*/ -CREATE TABLE phpbb_warnings ( - warning_id number(8) NOT NULL, - user_id number(8) DEFAULT '0' NOT NULL, - post_id number(8) DEFAULT '0' NOT NULL, - log_id number(8) DEFAULT '0' NOT NULL, - warning_time number(11) DEFAULT '0' NOT NULL, - CONSTRAINT pk_phpbb_warnings PRIMARY KEY (warning_id) -) -/ - - -CREATE SEQUENCE phpbb_warnings_seq -/ - -CREATE OR REPLACE TRIGGER t_phpbb_warnings -BEFORE INSERT ON phpbb_warnings -FOR EACH ROW WHEN ( - new.warning_id IS NULL OR new.warning_id = 0 -) -BEGIN - SELECT phpbb_warnings_seq.nextval - INTO :new.warning_id - FROM dual; -END; -/ - - -/* - Table: 'phpbb_words' -*/ -CREATE TABLE phpbb_words ( - word_id number(8) NOT NULL, - word varchar2(765) DEFAULT '' , - replacement varchar2(765) DEFAULT '' , - CONSTRAINT pk_phpbb_words PRIMARY KEY (word_id) -) -/ - - -CREATE SEQUENCE phpbb_words_seq -/ - -CREATE OR REPLACE TRIGGER t_phpbb_words -BEFORE INSERT ON phpbb_words -FOR EACH ROW WHEN ( - new.word_id IS NULL OR new.word_id = 0 -) -BEGIN - SELECT phpbb_words_seq.nextval - INTO :new.word_id - FROM dual; -END; -/ - - -/* - Table: 'phpbb_zebra' -*/ -CREATE TABLE phpbb_zebra ( - user_id number(8) DEFAULT '0' NOT NULL, - zebra_id number(8) DEFAULT '0' NOT NULL, - friend number(1) DEFAULT '0' NOT NULL, - foe number(1) DEFAULT '0' NOT NULL, - CONSTRAINT pk_phpbb_zebra PRIMARY KEY (user_id, zebra_id) -) -/ - - +/* + * DO NOT EDIT THIS FILE, IT IS GENERATED + * + * To change the contents of this file, edit + * phpBB/develop/create_schema_files.php and + * run it. + */ + +/* + This first section is optional, however its probably the best method + of running phpBB on Oracle. If you already have a tablespace and user created + for phpBB you can leave this section commented out! + + The first set of statements create a phpBB tablespace and a phpBB user, + make sure you change the password of the phpBB user before you run this script!! +*/ + +/* +CREATE TABLESPACE "PHPBB" + LOGGING + DATAFILE 'E:\ORACLE\ORADATA\LOCAL\PHPBB.ora' + SIZE 10M + AUTOEXTEND ON NEXT 10M + MAXSIZE 100M; + +CREATE USER "PHPBB" + PROFILE "DEFAULT" + IDENTIFIED BY "phpbb_password" + DEFAULT TABLESPACE "PHPBB" + QUOTA UNLIMITED ON "PHPBB" + ACCOUNT UNLOCK; + +GRANT ANALYZE ANY TO "PHPBB"; +GRANT CREATE SEQUENCE TO "PHPBB"; +GRANT CREATE SESSION TO "PHPBB"; +GRANT CREATE TABLE TO "PHPBB"; +GRANT CREATE TRIGGER TO "PHPBB"; +GRANT CREATE VIEW TO "PHPBB"; +GRANT "CONNECT" TO "PHPBB"; + +COMMIT; +DISCONNECT; + +CONNECT phpbb/phpbb_password; +*/ +/* + Table: 'phpbb_attachments' +*/ +CREATE TABLE phpbb_attachments ( + attach_id number(8) NOT NULL, + post_msg_id number(8) DEFAULT '0' NOT NULL, + topic_id number(8) DEFAULT '0' NOT NULL, + in_message number(1) DEFAULT '0' NOT NULL, + poster_id number(8) DEFAULT '0' NOT NULL, + is_orphan number(1) DEFAULT '1' NOT NULL, + physical_filename varchar2(255) DEFAULT '' , + real_filename varchar2(255) DEFAULT '' , + download_count number(8) DEFAULT '0' NOT NULL, + attach_comment clob DEFAULT '' , + extension varchar2(100) DEFAULT '' , + mimetype varchar2(100) DEFAULT '' , + filesize number(20) DEFAULT '0' NOT NULL, + filetime number(11) DEFAULT '0' NOT NULL, + thumbnail number(1) DEFAULT '0' NOT NULL, + CONSTRAINT pk_phpbb_attachments PRIMARY KEY (attach_id) +) +/ + +CREATE INDEX phpbb_attachments_filetime ON phpbb_attachments (filetime) +/ +CREATE INDEX phpbb_attachments_post_msg_id ON phpbb_attachments (post_msg_id) +/ +CREATE INDEX phpbb_attachments_topic_id ON phpbb_attachments (topic_id) +/ +CREATE INDEX phpbb_attachments_poster_id ON phpbb_attachments (poster_id) +/ +CREATE INDEX phpbb_attachments_is_orphan ON phpbb_attachments (is_orphan) +/ + +CREATE SEQUENCE phpbb_attachments_seq +/ + +CREATE OR REPLACE TRIGGER t_phpbb_attachments +BEFORE INSERT ON phpbb_attachments +FOR EACH ROW WHEN ( + new.attach_id IS NULL OR new.attach_id = 0 +) +BEGIN + SELECT phpbb_attachments_seq.nextval + INTO :new.attach_id + FROM dual; +END; +/ + + +/* + Table: 'phpbb_acl_groups' +*/ +CREATE TABLE phpbb_acl_groups ( + group_id number(8) DEFAULT '0' NOT NULL, + forum_id number(8) DEFAULT '0' NOT NULL, + auth_option_id number(8) DEFAULT '0' NOT NULL, + auth_role_id number(8) DEFAULT '0' NOT NULL, + auth_setting number(2) DEFAULT '0' NOT NULL +) +/ + +CREATE INDEX phpbb_acl_groups_group_id ON phpbb_acl_groups (group_id) +/ +CREATE INDEX phpbb_acl_groups_auth_opt_id ON phpbb_acl_groups (auth_option_id) +/ +CREATE INDEX phpbb_acl_groups_auth_role_id ON phpbb_acl_groups (auth_role_id) +/ + +/* + Table: 'phpbb_acl_options' +*/ +CREATE TABLE phpbb_acl_options ( + auth_option_id number(8) NOT NULL, + auth_option varchar2(50) DEFAULT '' , + is_global number(1) DEFAULT '0' NOT NULL, + is_local number(1) DEFAULT '0' NOT NULL, + founder_only number(1) DEFAULT '0' NOT NULL, + CONSTRAINT pk_phpbb_acl_options PRIMARY KEY (auth_option_id), + CONSTRAINT u_phpbb_auth_option UNIQUE (auth_option) +) +/ + + +CREATE SEQUENCE phpbb_acl_options_seq +/ + +CREATE OR REPLACE TRIGGER t_phpbb_acl_options +BEFORE INSERT ON phpbb_acl_options +FOR EACH ROW WHEN ( + new.auth_option_id IS NULL OR new.auth_option_id = 0 +) +BEGIN + SELECT phpbb_acl_options_seq.nextval + INTO :new.auth_option_id + FROM dual; +END; +/ + + +/* + Table: 'phpbb_acl_roles' +*/ +CREATE TABLE phpbb_acl_roles ( + role_id number(8) NOT NULL, + role_name varchar2(765) DEFAULT '' , + role_description clob DEFAULT '' , + role_type varchar2(10) DEFAULT '' , + role_order number(4) DEFAULT '0' NOT NULL, + CONSTRAINT pk_phpbb_acl_roles PRIMARY KEY (role_id) +) +/ + +CREATE INDEX phpbb_acl_roles_role_type ON phpbb_acl_roles (role_type) +/ +CREATE INDEX phpbb_acl_roles_role_order ON phpbb_acl_roles (role_order) +/ + +CREATE SEQUENCE phpbb_acl_roles_seq +/ + +CREATE OR REPLACE TRIGGER t_phpbb_acl_roles +BEFORE INSERT ON phpbb_acl_roles +FOR EACH ROW WHEN ( + new.role_id IS NULL OR new.role_id = 0 +) +BEGIN + SELECT phpbb_acl_roles_seq.nextval + INTO :new.role_id + FROM dual; +END; +/ + + +/* + Table: 'phpbb_acl_roles_data' +*/ +CREATE TABLE phpbb_acl_roles_data ( + role_id number(8) DEFAULT '0' NOT NULL, + auth_option_id number(8) DEFAULT '0' NOT NULL, + auth_setting number(2) DEFAULT '0' NOT NULL, + CONSTRAINT pk_phpbb_acl_roles_data PRIMARY KEY (role_id, auth_option_id) +) +/ + +CREATE INDEX phpbb_acl_roles_data_ath_op_id ON phpbb_acl_roles_data (auth_option_id) +/ + +/* + Table: 'phpbb_acl_users' +*/ +CREATE TABLE phpbb_acl_users ( + user_id number(8) DEFAULT '0' NOT NULL, + forum_id number(8) DEFAULT '0' NOT NULL, + auth_option_id number(8) DEFAULT '0' NOT NULL, + auth_role_id number(8) DEFAULT '0' NOT NULL, + auth_setting number(2) DEFAULT '0' NOT NULL +) +/ + +CREATE INDEX phpbb_acl_users_user_id ON phpbb_acl_users (user_id) +/ +CREATE INDEX phpbb_acl_users_auth_option_id ON phpbb_acl_users (auth_option_id) +/ +CREATE INDEX phpbb_acl_users_auth_role_id ON phpbb_acl_users (auth_role_id) +/ + +/* + Table: 'phpbb_banlist' +*/ +CREATE TABLE phpbb_banlist ( + ban_id number(8) NOT NULL, + ban_userid number(8) DEFAULT '0' NOT NULL, + ban_ip varchar2(40) DEFAULT '' , + ban_email varchar2(300) DEFAULT '' , + ban_start number(11) DEFAULT '0' NOT NULL, + ban_end number(11) DEFAULT '0' NOT NULL, + ban_exclude number(1) DEFAULT '0' NOT NULL, + ban_reason varchar2(765) DEFAULT '' , + ban_give_reason varchar2(765) DEFAULT '' , + CONSTRAINT pk_phpbb_banlist PRIMARY KEY (ban_id) +) +/ + +CREATE INDEX phpbb_banlist_ban_end ON phpbb_banlist (ban_end) +/ +CREATE INDEX phpbb_banlist_ban_user ON phpbb_banlist (ban_userid, ban_exclude) +/ +CREATE INDEX phpbb_banlist_ban_email ON phpbb_banlist (ban_email, ban_exclude) +/ +CREATE INDEX phpbb_banlist_ban_ip ON phpbb_banlist (ban_ip, ban_exclude) +/ + +CREATE SEQUENCE phpbb_banlist_seq +/ + +CREATE OR REPLACE TRIGGER t_phpbb_banlist +BEFORE INSERT ON phpbb_banlist +FOR EACH ROW WHEN ( + new.ban_id IS NULL OR new.ban_id = 0 +) +BEGIN + SELECT phpbb_banlist_seq.nextval + INTO :new.ban_id + FROM dual; +END; +/ + + +/* + Table: 'phpbb_bbcodes' +*/ +CREATE TABLE phpbb_bbcodes ( + bbcode_id number(4) DEFAULT '0' NOT NULL, + bbcode_tag varchar2(16) DEFAULT '' , + bbcode_helpline varchar2(765) DEFAULT '' , + display_on_posting number(1) DEFAULT '0' NOT NULL, + bbcode_match clob DEFAULT '' , + bbcode_tpl clob DEFAULT '' , + first_pass_match clob DEFAULT '' , + first_pass_replace clob DEFAULT '' , + second_pass_match clob DEFAULT '' , + second_pass_replace clob DEFAULT '' , + CONSTRAINT pk_phpbb_bbcodes PRIMARY KEY (bbcode_id) +) +/ + +CREATE INDEX phpbb_bbcodes_display_on_post ON phpbb_bbcodes (display_on_posting) +/ + +/* + Table: 'phpbb_bookmarks' +*/ +CREATE TABLE phpbb_bookmarks ( + topic_id number(8) DEFAULT '0' NOT NULL, + user_id number(8) DEFAULT '0' NOT NULL, + CONSTRAINT pk_phpbb_bookmarks PRIMARY KEY (topic_id, user_id) +) +/ + + +/* + Table: 'phpbb_bots' +*/ +CREATE TABLE phpbb_bots ( + bot_id number(8) NOT NULL, + bot_active number(1) DEFAULT '1' NOT NULL, + bot_name varchar2(765) DEFAULT '' , + user_id number(8) DEFAULT '0' NOT NULL, + bot_agent varchar2(255) DEFAULT '' , + bot_ip varchar2(255) DEFAULT '' , + CONSTRAINT pk_phpbb_bots PRIMARY KEY (bot_id) +) +/ + +CREATE INDEX phpbb_bots_bot_active ON phpbb_bots (bot_active) +/ + +CREATE SEQUENCE phpbb_bots_seq +/ + +CREATE OR REPLACE TRIGGER t_phpbb_bots +BEFORE INSERT ON phpbb_bots +FOR EACH ROW WHEN ( + new.bot_id IS NULL OR new.bot_id = 0 +) +BEGIN + SELECT phpbb_bots_seq.nextval + INTO :new.bot_id + FROM dual; +END; +/ + + +/* + Table: 'phpbb_config' +*/ +CREATE TABLE phpbb_config ( + config_name varchar2(255) DEFAULT '' , + config_value varchar2(765) DEFAULT '' , + is_dynamic number(1) DEFAULT '0' NOT NULL, + CONSTRAINT pk_phpbb_config PRIMARY KEY (config_name) +) +/ + +CREATE INDEX phpbb_config_is_dynamic ON phpbb_config (is_dynamic) +/ + +/* + Table: 'phpbb_confirm' +*/ +CREATE TABLE phpbb_confirm ( + confirm_id char(32) DEFAULT '' , + session_id char(32) DEFAULT '' , + confirm_type number(3) DEFAULT '0' NOT NULL, + code varchar2(8) DEFAULT '' , + seed number(10) DEFAULT '0' NOT NULL, + attempts number(8) DEFAULT '0' NOT NULL, + CONSTRAINT pk_phpbb_confirm PRIMARY KEY (session_id, confirm_id) +) +/ + +CREATE INDEX phpbb_confirm_confirm_type ON phpbb_confirm (confirm_type) +/ + +/* + Table: 'phpbb_disallow' +*/ +CREATE TABLE phpbb_disallow ( + disallow_id number(8) NOT NULL, + disallow_username varchar2(765) DEFAULT '' , + CONSTRAINT pk_phpbb_disallow PRIMARY KEY (disallow_id) +) +/ + + +CREATE SEQUENCE phpbb_disallow_seq +/ + +CREATE OR REPLACE TRIGGER t_phpbb_disallow +BEFORE INSERT ON phpbb_disallow +FOR EACH ROW WHEN ( + new.disallow_id IS NULL OR new.disallow_id = 0 +) +BEGIN + SELECT phpbb_disallow_seq.nextval + INTO :new.disallow_id + FROM dual; +END; +/ + + +/* + Table: 'phpbb_drafts' +*/ +CREATE TABLE phpbb_drafts ( + draft_id number(8) NOT NULL, + user_id number(8) DEFAULT '0' NOT NULL, + topic_id number(8) DEFAULT '0' NOT NULL, + forum_id number(8) DEFAULT '0' NOT NULL, + save_time number(11) DEFAULT '0' NOT NULL, + draft_subject varchar2(765) DEFAULT '' , + draft_message clob DEFAULT '' , + CONSTRAINT pk_phpbb_drafts PRIMARY KEY (draft_id) +) +/ + +CREATE INDEX phpbb_drafts_save_time ON phpbb_drafts (save_time) +/ + +CREATE SEQUENCE phpbb_drafts_seq +/ + +CREATE OR REPLACE TRIGGER t_phpbb_drafts +BEFORE INSERT ON phpbb_drafts +FOR EACH ROW WHEN ( + new.draft_id IS NULL OR new.draft_id = 0 +) +BEGIN + SELECT phpbb_drafts_seq.nextval + INTO :new.draft_id + FROM dual; +END; +/ + + +/* + Table: 'phpbb_ext' +*/ +CREATE TABLE phpbb_ext ( + ext_name varchar2(255) DEFAULT '' , + ext_active number(1) DEFAULT '0' NOT NULL, + ext_state clob DEFAULT '' , + CONSTRAINT u_phpbb_ext_name UNIQUE (ext_name) +) +/ + + +/* + Table: 'phpbb_extensions' +*/ +CREATE TABLE phpbb_extensions ( + extension_id number(8) NOT NULL, + group_id number(8) DEFAULT '0' NOT NULL, + extension varchar2(100) DEFAULT '' , + CONSTRAINT pk_phpbb_extensions PRIMARY KEY (extension_id) +) +/ + + +CREATE SEQUENCE phpbb_extensions_seq +/ + +CREATE OR REPLACE TRIGGER t_phpbb_extensions +BEFORE INSERT ON phpbb_extensions +FOR EACH ROW WHEN ( + new.extension_id IS NULL OR new.extension_id = 0 +) +BEGIN + SELECT phpbb_extensions_seq.nextval + INTO :new.extension_id + FROM dual; +END; +/ + + +/* + Table: 'phpbb_extension_groups' +*/ +CREATE TABLE phpbb_extension_groups ( + group_id number(8) NOT NULL, + group_name varchar2(765) DEFAULT '' , + cat_id number(2) DEFAULT '0' NOT NULL, + allow_group number(1) DEFAULT '0' NOT NULL, + download_mode number(1) DEFAULT '1' NOT NULL, + upload_icon varchar2(255) DEFAULT '' , + max_filesize number(20) DEFAULT '0' NOT NULL, + allowed_forums clob DEFAULT '' , + allow_in_pm number(1) DEFAULT '0' NOT NULL, + CONSTRAINT pk_phpbb_extension_groups PRIMARY KEY (group_id) +) +/ + + +CREATE SEQUENCE phpbb_extension_groups_seq +/ + +CREATE OR REPLACE TRIGGER t_phpbb_extension_groups +BEFORE INSERT ON phpbb_extension_groups +FOR EACH ROW WHEN ( + new.group_id IS NULL OR new.group_id = 0 +) +BEGIN + SELECT phpbb_extension_groups_seq.nextval + INTO :new.group_id + FROM dual; +END; +/ + + +/* + Table: 'phpbb_forums' +*/ +CREATE TABLE phpbb_forums ( + forum_id number(8) NOT NULL, + parent_id number(8) DEFAULT '0' NOT NULL, + left_id number(8) DEFAULT '0' NOT NULL, + right_id number(8) DEFAULT '0' NOT NULL, + forum_parents clob DEFAULT '' , + forum_name varchar2(765) DEFAULT '' , + forum_desc clob DEFAULT '' , + forum_desc_bitfield varchar2(255) DEFAULT '' , + forum_desc_options number(11) DEFAULT '7' NOT NULL, + forum_desc_uid varchar2(8) DEFAULT '' , + forum_link varchar2(765) DEFAULT '' , + forum_password varchar2(120) DEFAULT '' , + forum_style number(8) DEFAULT '0' NOT NULL, + forum_image varchar2(255) DEFAULT '' , + forum_rules clob DEFAULT '' , + forum_rules_link varchar2(765) DEFAULT '' , + forum_rules_bitfield varchar2(255) DEFAULT '' , + forum_rules_options number(11) DEFAULT '7' NOT NULL, + forum_rules_uid varchar2(8) DEFAULT '' , + forum_topics_per_page number(4) DEFAULT '0' NOT NULL, + forum_type number(4) DEFAULT '0' NOT NULL, + forum_status number(4) DEFAULT '0' NOT NULL, + forum_posts number(8) DEFAULT '0' NOT NULL, + forum_topics number(8) DEFAULT '0' NOT NULL, + forum_topics_real number(8) DEFAULT '0' NOT NULL, + forum_last_post_id number(8) DEFAULT '0' NOT NULL, + forum_last_poster_id number(8) DEFAULT '0' NOT NULL, + forum_last_post_subject varchar2(765) DEFAULT '' , + forum_last_post_time number(11) DEFAULT '0' NOT NULL, + forum_last_poster_name varchar2(765) DEFAULT '' , + forum_last_poster_colour varchar2(6) DEFAULT '' , + forum_flags number(4) DEFAULT '32' NOT NULL, + forum_options number(20) DEFAULT '0' NOT NULL, + display_subforum_list number(1) DEFAULT '1' NOT NULL, + display_on_index number(1) DEFAULT '1' NOT NULL, + enable_indexing number(1) DEFAULT '1' NOT NULL, + enable_icons number(1) DEFAULT '1' NOT NULL, + enable_prune number(1) DEFAULT '0' NOT NULL, + prune_next number(11) DEFAULT '0' NOT NULL, + prune_days number(8) DEFAULT '0' NOT NULL, + prune_viewed number(8) DEFAULT '0' NOT NULL, + prune_freq number(8) DEFAULT '0' NOT NULL, + CONSTRAINT pk_phpbb_forums PRIMARY KEY (forum_id) +) +/ + +CREATE INDEX phpbb_forums_left_right_id ON phpbb_forums (left_id, right_id) +/ +CREATE INDEX phpbb_forums_forum_lastpost_id ON phpbb_forums (forum_last_post_id) +/ + +CREATE SEQUENCE phpbb_forums_seq +/ + +CREATE OR REPLACE TRIGGER t_phpbb_forums +BEFORE INSERT ON phpbb_forums +FOR EACH ROW WHEN ( + new.forum_id IS NULL OR new.forum_id = 0 +) +BEGIN + SELECT phpbb_forums_seq.nextval + INTO :new.forum_id + FROM dual; +END; +/ + + +/* + Table: 'phpbb_forums_access' +*/ +CREATE TABLE phpbb_forums_access ( + forum_id number(8) DEFAULT '0' NOT NULL, + user_id number(8) DEFAULT '0' NOT NULL, + session_id char(32) DEFAULT '' , + CONSTRAINT pk_phpbb_forums_access PRIMARY KEY (forum_id, user_id, session_id) +) +/ + + +/* + Table: 'phpbb_forums_track' +*/ +CREATE TABLE phpbb_forums_track ( + user_id number(8) DEFAULT '0' NOT NULL, + forum_id number(8) DEFAULT '0' NOT NULL, + mark_time number(11) DEFAULT '0' NOT NULL, + CONSTRAINT pk_phpbb_forums_track PRIMARY KEY (user_id, forum_id) +) +/ + + +/* + Table: 'phpbb_forums_watch' +*/ +CREATE TABLE phpbb_forums_watch ( + forum_id number(8) DEFAULT '0' NOT NULL, + user_id number(8) DEFAULT '0' NOT NULL, + notify_status number(1) DEFAULT '0' NOT NULL +) +/ + +CREATE INDEX phpbb_forums_watch_forum_id ON phpbb_forums_watch (forum_id) +/ +CREATE INDEX phpbb_forums_watch_user_id ON phpbb_forums_watch (user_id) +/ +CREATE INDEX phpbb_forums_watch_notify_stat ON phpbb_forums_watch (notify_status) +/ + +/* + Table: 'phpbb_groups' +*/ +CREATE TABLE phpbb_groups ( + group_id number(8) NOT NULL, + group_type number(4) DEFAULT '1' NOT NULL, + group_founder_manage number(1) DEFAULT '0' NOT NULL, + group_skip_auth number(1) DEFAULT '0' NOT NULL, + group_name varchar2(255) DEFAULT '' , + group_desc clob DEFAULT '' , + group_desc_bitfield varchar2(255) DEFAULT '' , + group_desc_options number(11) DEFAULT '7' NOT NULL, + group_desc_uid varchar2(8) DEFAULT '' , + group_display number(1) DEFAULT '0' NOT NULL, + group_avatar varchar2(255) DEFAULT '' , + group_avatar_type number(2) DEFAULT '0' NOT NULL, + group_avatar_width number(4) DEFAULT '0' NOT NULL, + group_avatar_height number(4) DEFAULT '0' NOT NULL, + group_rank number(8) DEFAULT '0' NOT NULL, + group_colour varchar2(6) DEFAULT '' , + group_sig_chars number(8) DEFAULT '0' NOT NULL, + group_receive_pm number(1) DEFAULT '0' NOT NULL, + group_message_limit number(8) DEFAULT '0' NOT NULL, + group_max_recipients number(8) DEFAULT '0' NOT NULL, + group_legend number(8) DEFAULT '0' NOT NULL, + group_teampage number(8) DEFAULT '0' NOT NULL, + CONSTRAINT pk_phpbb_groups PRIMARY KEY (group_id) +) +/ + +CREATE INDEX phpbb_groups_group_legend_name ON phpbb_groups (group_legend, group_name) +/ + +CREATE SEQUENCE phpbb_groups_seq +/ + +CREATE OR REPLACE TRIGGER t_phpbb_groups +BEFORE INSERT ON phpbb_groups +FOR EACH ROW WHEN ( + new.group_id IS NULL OR new.group_id = 0 +) +BEGIN + SELECT phpbb_groups_seq.nextval + INTO :new.group_id + FROM dual; +END; +/ + + +/* + Table: 'phpbb_icons' +*/ +CREATE TABLE phpbb_icons ( + icons_id number(8) NOT NULL, + icons_url varchar2(255) DEFAULT '' , + icons_width number(4) DEFAULT '0' NOT NULL, + icons_height number(4) DEFAULT '0' NOT NULL, + icons_order number(8) DEFAULT '0' NOT NULL, + display_on_posting number(1) DEFAULT '1' NOT NULL, + CONSTRAINT pk_phpbb_icons PRIMARY KEY (icons_id) +) +/ + +CREATE INDEX phpbb_icons_display_on_posting ON phpbb_icons (display_on_posting) +/ + +CREATE SEQUENCE phpbb_icons_seq +/ + +CREATE OR REPLACE TRIGGER t_phpbb_icons +BEFORE INSERT ON phpbb_icons +FOR EACH ROW WHEN ( + new.icons_id IS NULL OR new.icons_id = 0 +) +BEGIN + SELECT phpbb_icons_seq.nextval + INTO :new.icons_id + FROM dual; +END; +/ + + +/* + Table: 'phpbb_lang' +*/ +CREATE TABLE phpbb_lang ( + lang_id number(4) NOT NULL, + lang_iso varchar2(30) DEFAULT '' , + lang_dir varchar2(30) DEFAULT '' , + lang_english_name varchar2(300) DEFAULT '' , + lang_local_name varchar2(765) DEFAULT '' , + lang_author varchar2(765) DEFAULT '' , + CONSTRAINT pk_phpbb_lang PRIMARY KEY (lang_id) +) +/ + +CREATE INDEX phpbb_lang_lang_iso ON phpbb_lang (lang_iso) +/ + +CREATE SEQUENCE phpbb_lang_seq +/ + +CREATE OR REPLACE TRIGGER t_phpbb_lang +BEFORE INSERT ON phpbb_lang +FOR EACH ROW WHEN ( + new.lang_id IS NULL OR new.lang_id = 0 +) +BEGIN + SELECT phpbb_lang_seq.nextval + INTO :new.lang_id + FROM dual; +END; +/ + + +/* + Table: 'phpbb_log' +*/ +CREATE TABLE phpbb_log ( + log_id number(8) NOT NULL, + log_type number(4) DEFAULT '0' NOT NULL, + user_id number(8) DEFAULT '0' NOT NULL, + forum_id number(8) DEFAULT '0' NOT NULL, + topic_id number(8) DEFAULT '0' NOT NULL, + reportee_id number(8) DEFAULT '0' NOT NULL, + log_ip varchar2(40) DEFAULT '' , + log_time number(11) DEFAULT '0' NOT NULL, + log_operation clob DEFAULT '' , + log_data clob DEFAULT '' , + CONSTRAINT pk_phpbb_log PRIMARY KEY (log_id) +) +/ + +CREATE INDEX phpbb_log_log_type ON phpbb_log (log_type) +/ +CREATE INDEX phpbb_log_log_time ON phpbb_log (log_time) +/ +CREATE INDEX phpbb_log_forum_id ON phpbb_log (forum_id) +/ +CREATE INDEX phpbb_log_topic_id ON phpbb_log (topic_id) +/ +CREATE INDEX phpbb_log_reportee_id ON phpbb_log (reportee_id) +/ +CREATE INDEX phpbb_log_user_id ON phpbb_log (user_id) +/ + +CREATE SEQUENCE phpbb_log_seq +/ + +CREATE OR REPLACE TRIGGER t_phpbb_log +BEFORE INSERT ON phpbb_log +FOR EACH ROW WHEN ( + new.log_id IS NULL OR new.log_id = 0 +) +BEGIN + SELECT phpbb_log_seq.nextval + INTO :new.log_id + FROM dual; +END; +/ + + +/* + Table: 'phpbb_login_attempts' +*/ +CREATE TABLE phpbb_login_attempts ( + attempt_ip varchar2(40) DEFAULT '' , + attempt_browser varchar2(150) DEFAULT '' , + attempt_forwarded_for varchar2(255) DEFAULT '' , + attempt_time number(11) DEFAULT '0' NOT NULL, + user_id number(8) DEFAULT '0' NOT NULL, + username varchar2(765) DEFAULT '0' NOT NULL, + username_clean varchar2(255) DEFAULT '0' NOT NULL +) +/ + +CREATE INDEX phpbb_login_attempts_att_ip ON phpbb_login_attempts (attempt_ip, attempt_time) +/ +CREATE INDEX phpbb_login_attempts_att_for ON phpbb_login_attempts (attempt_forwarded_for, attempt_time) +/ +CREATE INDEX phpbb_login_attempts_att_time ON phpbb_login_attempts (attempt_time) +/ +CREATE INDEX phpbb_login_attempts_user_id ON phpbb_login_attempts (user_id) +/ + +/* + Table: 'phpbb_moderator_cache' +*/ +CREATE TABLE phpbb_moderator_cache ( + forum_id number(8) DEFAULT '0' NOT NULL, + user_id number(8) DEFAULT '0' NOT NULL, + username varchar2(765) DEFAULT '' , + group_id number(8) DEFAULT '0' NOT NULL, + group_name varchar2(765) DEFAULT '' , + display_on_index number(1) DEFAULT '1' NOT NULL +) +/ + +CREATE INDEX phpbb_moderator_cache_disp_idx ON phpbb_moderator_cache (display_on_index) +/ +CREATE INDEX phpbb_moderator_cache_forum_id ON phpbb_moderator_cache (forum_id) +/ + +/* + Table: 'phpbb_modules' +*/ +CREATE TABLE phpbb_modules ( + module_id number(8) NOT NULL, + module_enabled number(1) DEFAULT '1' NOT NULL, + module_display number(1) DEFAULT '1' NOT NULL, + module_basename varchar2(255) DEFAULT '' , + module_class varchar2(10) DEFAULT '' , + parent_id number(8) DEFAULT '0' NOT NULL, + left_id number(8) DEFAULT '0' NOT NULL, + right_id number(8) DEFAULT '0' NOT NULL, + module_langname varchar2(255) DEFAULT '' , + module_mode varchar2(255) DEFAULT '' , + module_auth varchar2(255) DEFAULT '' , + CONSTRAINT pk_phpbb_modules PRIMARY KEY (module_id) +) +/ + +CREATE INDEX phpbb_modules_left_right_id ON phpbb_modules (left_id, right_id) +/ +CREATE INDEX phpbb_modules_module_enabled ON phpbb_modules (module_enabled) +/ +CREATE INDEX phpbb_modules_class_left_id ON phpbb_modules (module_class, left_id) +/ + +CREATE SEQUENCE phpbb_modules_seq +/ + +CREATE OR REPLACE TRIGGER t_phpbb_modules +BEFORE INSERT ON phpbb_modules +FOR EACH ROW WHEN ( + new.module_id IS NULL OR new.module_id = 0 +) +BEGIN + SELECT phpbb_modules_seq.nextval + INTO :new.module_id + FROM dual; +END; +/ + + +/* + Table: 'phpbb_poll_options' +*/ +CREATE TABLE phpbb_poll_options ( + poll_option_id number(4) DEFAULT '0' NOT NULL, + topic_id number(8) DEFAULT '0' NOT NULL, + poll_option_text clob DEFAULT '' , + poll_option_total number(8) DEFAULT '0' NOT NULL +) +/ + +CREATE INDEX phpbb_poll_options_poll_opt_id ON phpbb_poll_options (poll_option_id) +/ +CREATE INDEX phpbb_poll_options_topic_id ON phpbb_poll_options (topic_id) +/ + +/* + Table: 'phpbb_poll_votes' +*/ +CREATE TABLE phpbb_poll_votes ( + topic_id number(8) DEFAULT '0' NOT NULL, + poll_option_id number(4) DEFAULT '0' NOT NULL, + vote_user_id number(8) DEFAULT '0' NOT NULL, + vote_user_ip varchar2(40) DEFAULT '' +) +/ + +CREATE INDEX phpbb_poll_votes_topic_id ON phpbb_poll_votes (topic_id) +/ +CREATE INDEX phpbb_poll_votes_vote_user_id ON phpbb_poll_votes (vote_user_id) +/ +CREATE INDEX phpbb_poll_votes_vote_user_ip ON phpbb_poll_votes (vote_user_ip) +/ + +/* + Table: 'phpbb_posts' +*/ +CREATE TABLE phpbb_posts ( + post_id number(8) NOT NULL, + topic_id number(8) DEFAULT '0' NOT NULL, + forum_id number(8) DEFAULT '0' NOT NULL, + poster_id number(8) DEFAULT '0' NOT NULL, + icon_id number(8) DEFAULT '0' NOT NULL, + poster_ip varchar2(40) DEFAULT '' , + post_time number(11) DEFAULT '0' NOT NULL, + post_approved number(1) DEFAULT '1' NOT NULL, + post_reported number(1) DEFAULT '0' NOT NULL, + enable_bbcode number(1) DEFAULT '1' NOT NULL, + enable_smilies number(1) DEFAULT '1' NOT NULL, + enable_magic_url number(1) DEFAULT '1' NOT NULL, + enable_sig number(1) DEFAULT '1' NOT NULL, + post_username varchar2(765) DEFAULT '' , + post_subject varchar2(765) DEFAULT '' , + post_text clob DEFAULT '' , + post_checksum varchar2(32) DEFAULT '' , + post_attachment number(1) DEFAULT '0' NOT NULL, + bbcode_bitfield varchar2(255) DEFAULT '' , + bbcode_uid varchar2(8) DEFAULT '' , + post_postcount number(1) DEFAULT '1' NOT NULL, + post_edit_time number(11) DEFAULT '0' NOT NULL, + post_edit_reason varchar2(765) DEFAULT '' , + post_edit_user number(8) DEFAULT '0' NOT NULL, + post_edit_count number(4) DEFAULT '0' NOT NULL, + post_edit_locked number(1) DEFAULT '0' NOT NULL, + CONSTRAINT pk_phpbb_posts PRIMARY KEY (post_id) +) +/ + +CREATE INDEX phpbb_posts_forum_id ON phpbb_posts (forum_id) +/ +CREATE INDEX phpbb_posts_topic_id ON phpbb_posts (topic_id) +/ +CREATE INDEX phpbb_posts_poster_ip ON phpbb_posts (poster_ip) +/ +CREATE INDEX phpbb_posts_poster_id ON phpbb_posts (poster_id) +/ +CREATE INDEX phpbb_posts_post_approved ON phpbb_posts (post_approved) +/ +CREATE INDEX phpbb_posts_post_username ON phpbb_posts (post_username) +/ +CREATE INDEX phpbb_posts_tid_post_time ON phpbb_posts (topic_id, post_time) +/ + +CREATE SEQUENCE phpbb_posts_seq +/ + +CREATE OR REPLACE TRIGGER t_phpbb_posts +BEFORE INSERT ON phpbb_posts +FOR EACH ROW WHEN ( + new.post_id IS NULL OR new.post_id = 0 +) +BEGIN + SELECT phpbb_posts_seq.nextval + INTO :new.post_id + FROM dual; +END; +/ + + +/* + Table: 'phpbb_privmsgs' +*/ +CREATE TABLE phpbb_privmsgs ( + msg_id number(8) NOT NULL, + root_level number(8) DEFAULT '0' NOT NULL, + author_id number(8) DEFAULT '0' NOT NULL, + icon_id number(8) DEFAULT '0' NOT NULL, + author_ip varchar2(40) DEFAULT '' , + message_time number(11) DEFAULT '0' NOT NULL, + enable_bbcode number(1) DEFAULT '1' NOT NULL, + enable_smilies number(1) DEFAULT '1' NOT NULL, + enable_magic_url number(1) DEFAULT '1' NOT NULL, + enable_sig number(1) DEFAULT '1' NOT NULL, + message_subject varchar2(765) DEFAULT '' , + message_text clob DEFAULT '' , + message_edit_reason varchar2(765) DEFAULT '' , + message_edit_user number(8) DEFAULT '0' NOT NULL, + message_attachment number(1) DEFAULT '0' NOT NULL, + bbcode_bitfield varchar2(255) DEFAULT '' , + bbcode_uid varchar2(8) DEFAULT '' , + message_edit_time number(11) DEFAULT '0' NOT NULL, + message_edit_count number(4) DEFAULT '0' NOT NULL, + to_address clob DEFAULT '' , + bcc_address clob DEFAULT '' , + message_reported number(1) DEFAULT '0' NOT NULL, + CONSTRAINT pk_phpbb_privmsgs PRIMARY KEY (msg_id) +) +/ + +CREATE INDEX phpbb_privmsgs_author_ip ON phpbb_privmsgs (author_ip) +/ +CREATE INDEX phpbb_privmsgs_message_time ON phpbb_privmsgs (message_time) +/ +CREATE INDEX phpbb_privmsgs_author_id ON phpbb_privmsgs (author_id) +/ +CREATE INDEX phpbb_privmsgs_root_level ON phpbb_privmsgs (root_level) +/ + +CREATE SEQUENCE phpbb_privmsgs_seq +/ + +CREATE OR REPLACE TRIGGER t_phpbb_privmsgs +BEFORE INSERT ON phpbb_privmsgs +FOR EACH ROW WHEN ( + new.msg_id IS NULL OR new.msg_id = 0 +) +BEGIN + SELECT phpbb_privmsgs_seq.nextval + INTO :new.msg_id + FROM dual; +END; +/ + + +/* + Table: 'phpbb_privmsgs_folder' +*/ +CREATE TABLE phpbb_privmsgs_folder ( + folder_id number(8) NOT NULL, + user_id number(8) DEFAULT '0' NOT NULL, + folder_name varchar2(765) DEFAULT '' , + pm_count number(8) DEFAULT '0' NOT NULL, + CONSTRAINT pk_phpbb_privmsgs_folder PRIMARY KEY (folder_id) +) +/ + +CREATE INDEX phpbb_privmsgs_folder_user_id ON phpbb_privmsgs_folder (user_id) +/ + +CREATE SEQUENCE phpbb_privmsgs_folder_seq +/ + +CREATE OR REPLACE TRIGGER t_phpbb_privmsgs_folder +BEFORE INSERT ON phpbb_privmsgs_folder +FOR EACH ROW WHEN ( + new.folder_id IS NULL OR new.folder_id = 0 +) +BEGIN + SELECT phpbb_privmsgs_folder_seq.nextval + INTO :new.folder_id + FROM dual; +END; +/ + + +/* + Table: 'phpbb_privmsgs_rules' +*/ +CREATE TABLE phpbb_privmsgs_rules ( + rule_id number(8) NOT NULL, + user_id number(8) DEFAULT '0' NOT NULL, + rule_check number(8) DEFAULT '0' NOT NULL, + rule_connection number(8) DEFAULT '0' NOT NULL, + rule_string varchar2(765) DEFAULT '' , + rule_user_id number(8) DEFAULT '0' NOT NULL, + rule_group_id number(8) DEFAULT '0' NOT NULL, + rule_action number(8) DEFAULT '0' NOT NULL, + rule_folder_id number(11) DEFAULT '0' NOT NULL, + CONSTRAINT pk_phpbb_privmsgs_rules PRIMARY KEY (rule_id) +) +/ + +CREATE INDEX phpbb_privmsgs_rules_user_id ON phpbb_privmsgs_rules (user_id) +/ + +CREATE SEQUENCE phpbb_privmsgs_rules_seq +/ + +CREATE OR REPLACE TRIGGER t_phpbb_privmsgs_rules +BEFORE INSERT ON phpbb_privmsgs_rules +FOR EACH ROW WHEN ( + new.rule_id IS NULL OR new.rule_id = 0 +) +BEGIN + SELECT phpbb_privmsgs_rules_seq.nextval + INTO :new.rule_id + FROM dual; +END; +/ + + +/* + Table: 'phpbb_privmsgs_to' +*/ +CREATE TABLE phpbb_privmsgs_to ( + msg_id number(8) DEFAULT '0' NOT NULL, + user_id number(8) DEFAULT '0' NOT NULL, + author_id number(8) DEFAULT '0' NOT NULL, + pm_deleted number(1) DEFAULT '0' NOT NULL, + pm_new number(1) DEFAULT '1' NOT NULL, + pm_unread number(1) DEFAULT '1' NOT NULL, + pm_replied number(1) DEFAULT '0' NOT NULL, + pm_marked number(1) DEFAULT '0' NOT NULL, + pm_forwarded number(1) DEFAULT '0' NOT NULL, + folder_id number(11) DEFAULT '0' NOT NULL +) +/ + +CREATE INDEX phpbb_privmsgs_to_msg_id ON phpbb_privmsgs_to (msg_id) +/ +CREATE INDEX phpbb_privmsgs_to_author_id ON phpbb_privmsgs_to (author_id) +/ +CREATE INDEX phpbb_privmsgs_to_usr_flder_id ON phpbb_privmsgs_to (user_id, folder_id) +/ + +/* + Table: 'phpbb_profile_fields' +*/ +CREATE TABLE phpbb_profile_fields ( + field_id number(8) NOT NULL, + field_name varchar2(765) DEFAULT '' , + field_type number(4) DEFAULT '0' NOT NULL, + field_ident varchar2(20) DEFAULT '' , + field_length varchar2(20) DEFAULT '' , + field_minlen varchar2(255) DEFAULT '' , + field_maxlen varchar2(255) DEFAULT '' , + field_novalue varchar2(765) DEFAULT '' , + field_default_value varchar2(765) DEFAULT '' , + field_validation varchar2(60) DEFAULT '' , + field_required number(1) DEFAULT '0' NOT NULL, + field_show_novalue number(1) DEFAULT '0' NOT NULL, + field_show_on_reg number(1) DEFAULT '0' NOT NULL, + field_show_on_pm number(1) DEFAULT '0' NOT NULL, + field_show_on_vt number(1) DEFAULT '0' NOT NULL, + field_show_profile number(1) DEFAULT '0' NOT NULL, + field_hide number(1) DEFAULT '0' NOT NULL, + field_no_view number(1) DEFAULT '0' NOT NULL, + field_active number(1) DEFAULT '0' NOT NULL, + field_order number(8) DEFAULT '0' NOT NULL, + CONSTRAINT pk_phpbb_profile_fields PRIMARY KEY (field_id) +) +/ + +CREATE INDEX phpbb_profile_fields_fld_type ON phpbb_profile_fields (field_type) +/ +CREATE INDEX phpbb_profile_fields_fld_ordr ON phpbb_profile_fields (field_order) +/ + +CREATE SEQUENCE phpbb_profile_fields_seq +/ + +CREATE OR REPLACE TRIGGER t_phpbb_profile_fields +BEFORE INSERT ON phpbb_profile_fields +FOR EACH ROW WHEN ( + new.field_id IS NULL OR new.field_id = 0 +) +BEGIN + SELECT phpbb_profile_fields_seq.nextval + INTO :new.field_id + FROM dual; +END; +/ + + +/* + Table: 'phpbb_profile_fields_data' +*/ +CREATE TABLE phpbb_profile_fields_data ( + user_id number(8) DEFAULT '0' NOT NULL, + CONSTRAINT pk_phpbb_profile_fields_data PRIMARY KEY (user_id) +) +/ + + +/* + Table: 'phpbb_profile_fields_lang' +*/ +CREATE TABLE phpbb_profile_fields_lang ( + field_id number(8) DEFAULT '0' NOT NULL, + lang_id number(8) DEFAULT '0' NOT NULL, + option_id number(8) DEFAULT '0' NOT NULL, + field_type number(4) DEFAULT '0' NOT NULL, + lang_value varchar2(765) DEFAULT '' , + CONSTRAINT pk_phpbb_profile_fields_lang PRIMARY KEY (field_id, lang_id, option_id) +) +/ + + +/* + Table: 'phpbb_profile_lang' +*/ +CREATE TABLE phpbb_profile_lang ( + field_id number(8) DEFAULT '0' NOT NULL, + lang_id number(8) DEFAULT '0' NOT NULL, + lang_name varchar2(765) DEFAULT '' , + lang_explain clob DEFAULT '' , + lang_default_value varchar2(765) DEFAULT '' , + CONSTRAINT pk_phpbb_profile_lang PRIMARY KEY (field_id, lang_id) +) +/ + + +/* + Table: 'phpbb_ranks' +*/ +CREATE TABLE phpbb_ranks ( + rank_id number(8) NOT NULL, + rank_title varchar2(765) DEFAULT '' , + rank_min number(8) DEFAULT '0' NOT NULL, + rank_special number(1) DEFAULT '0' NOT NULL, + rank_image varchar2(255) DEFAULT '' , + CONSTRAINT pk_phpbb_ranks PRIMARY KEY (rank_id) +) +/ + + +CREATE SEQUENCE phpbb_ranks_seq +/ + +CREATE OR REPLACE TRIGGER t_phpbb_ranks +BEFORE INSERT ON phpbb_ranks +FOR EACH ROW WHEN ( + new.rank_id IS NULL OR new.rank_id = 0 +) +BEGIN + SELECT phpbb_ranks_seq.nextval + INTO :new.rank_id + FROM dual; +END; +/ + + +/* + Table: 'phpbb_reports' +*/ +CREATE TABLE phpbb_reports ( + report_id number(8) NOT NULL, + reason_id number(4) DEFAULT '0' NOT NULL, + post_id number(8) DEFAULT '0' NOT NULL, + pm_id number(8) DEFAULT '0' NOT NULL, + user_id number(8) DEFAULT '0' NOT NULL, + user_notify number(1) DEFAULT '0' NOT NULL, + report_closed number(1) DEFAULT '0' NOT NULL, + report_time number(11) DEFAULT '0' NOT NULL, + report_text clob DEFAULT '' , + reported_post_text clob DEFAULT '' , + CONSTRAINT pk_phpbb_reports PRIMARY KEY (report_id) +) +/ + +CREATE INDEX phpbb_reports_post_id ON phpbb_reports (post_id) +/ +CREATE INDEX phpbb_reports_pm_id ON phpbb_reports (pm_id) +/ + +CREATE SEQUENCE phpbb_reports_seq +/ + +CREATE OR REPLACE TRIGGER t_phpbb_reports +BEFORE INSERT ON phpbb_reports +FOR EACH ROW WHEN ( + new.report_id IS NULL OR new.report_id = 0 +) +BEGIN + SELECT phpbb_reports_seq.nextval + INTO :new.report_id + FROM dual; +END; +/ + + +/* + Table: 'phpbb_reports_reasons' +*/ +CREATE TABLE phpbb_reports_reasons ( + reason_id number(4) NOT NULL, + reason_title varchar2(765) DEFAULT '' , + reason_description clob DEFAULT '' , + reason_order number(4) DEFAULT '0' NOT NULL, + CONSTRAINT pk_phpbb_reports_reasons PRIMARY KEY (reason_id) +) +/ + + +CREATE SEQUENCE phpbb_reports_reasons_seq +/ + +CREATE OR REPLACE TRIGGER t_phpbb_reports_reasons +BEFORE INSERT ON phpbb_reports_reasons +FOR EACH ROW WHEN ( + new.reason_id IS NULL OR new.reason_id = 0 +) +BEGIN + SELECT phpbb_reports_reasons_seq.nextval + INTO :new.reason_id + FROM dual; +END; +/ + + +/* + Table: 'phpbb_search_results' +*/ +CREATE TABLE phpbb_search_results ( + search_key varchar2(32) DEFAULT '' , + search_time number(11) DEFAULT '0' NOT NULL, + search_keywords clob DEFAULT '' , + search_authors clob DEFAULT '' , + CONSTRAINT pk_phpbb_search_results PRIMARY KEY (search_key) +) +/ + + +/* + Table: 'phpbb_search_wordlist' +*/ +CREATE TABLE phpbb_search_wordlist ( + word_id number(8) NOT NULL, + word_text varchar2(765) DEFAULT '' , + word_common number(1) DEFAULT '0' NOT NULL, + word_count number(8) DEFAULT '0' NOT NULL, + CONSTRAINT pk_phpbb_search_wordlist PRIMARY KEY (word_id), + CONSTRAINT u_phpbb_wrd_txt UNIQUE (word_text) +) +/ + +CREATE INDEX phpbb_search_wordlist_wrd_cnt ON phpbb_search_wordlist (word_count) +/ + +CREATE SEQUENCE phpbb_search_wordlist_seq +/ + +CREATE OR REPLACE TRIGGER t_phpbb_search_wordlist +BEFORE INSERT ON phpbb_search_wordlist +FOR EACH ROW WHEN ( + new.word_id IS NULL OR new.word_id = 0 +) +BEGIN + SELECT phpbb_search_wordlist_seq.nextval + INTO :new.word_id + FROM dual; +END; +/ + + +/* + Table: 'phpbb_search_wordmatch' +*/ +CREATE TABLE phpbb_search_wordmatch ( + post_id number(8) DEFAULT '0' NOT NULL, + word_id number(8) DEFAULT '0' NOT NULL, + title_match number(1) DEFAULT '0' NOT NULL, + CONSTRAINT u_phpbb_unq_mtch UNIQUE (word_id, post_id, title_match) +) +/ + +CREATE INDEX phpbb_search_wordmatch_word_id ON phpbb_search_wordmatch (word_id) +/ +CREATE INDEX phpbb_search_wordmatch_post_id ON phpbb_search_wordmatch (post_id) +/ + +/* + Table: 'phpbb_sessions' +*/ +CREATE TABLE phpbb_sessions ( + session_id char(32) DEFAULT '' , + session_user_id number(8) DEFAULT '0' NOT NULL, + session_forum_id number(8) DEFAULT '0' NOT NULL, + session_last_visit number(11) DEFAULT '0' NOT NULL, + session_start number(11) DEFAULT '0' NOT NULL, + session_time number(11) DEFAULT '0' NOT NULL, + session_ip varchar2(40) DEFAULT '' , + session_browser varchar2(150) DEFAULT '' , + session_forwarded_for varchar2(255) DEFAULT '' , + session_page varchar2(765) DEFAULT '' , + session_viewonline number(1) DEFAULT '1' NOT NULL, + session_autologin number(1) DEFAULT '0' NOT NULL, + session_admin number(1) DEFAULT '0' NOT NULL, + CONSTRAINT pk_phpbb_sessions PRIMARY KEY (session_id) +) +/ + +CREATE INDEX phpbb_sessions_session_time ON phpbb_sessions (session_time) +/ +CREATE INDEX phpbb_sessions_session_user_id ON phpbb_sessions (session_user_id) +/ +CREATE INDEX phpbb_sessions_session_fid ON phpbb_sessions (session_forum_id) +/ + +/* + Table: 'phpbb_sessions_keys' +*/ +CREATE TABLE phpbb_sessions_keys ( + key_id char(32) DEFAULT '' , + user_id number(8) DEFAULT '0' NOT NULL, + last_ip varchar2(40) DEFAULT '' , + last_login number(11) DEFAULT '0' NOT NULL, + CONSTRAINT pk_phpbb_sessions_keys PRIMARY KEY (key_id, user_id) +) +/ + +CREATE INDEX phpbb_sessions_keys_last_login ON phpbb_sessions_keys (last_login) +/ + +/* + Table: 'phpbb_sitelist' +*/ +CREATE TABLE phpbb_sitelist ( + site_id number(8) NOT NULL, + site_ip varchar2(40) DEFAULT '' , + site_hostname varchar2(255) DEFAULT '' , + ip_exclude number(1) DEFAULT '0' NOT NULL, + CONSTRAINT pk_phpbb_sitelist PRIMARY KEY (site_id) +) +/ + + +CREATE SEQUENCE phpbb_sitelist_seq +/ + +CREATE OR REPLACE TRIGGER t_phpbb_sitelist +BEFORE INSERT ON phpbb_sitelist +FOR EACH ROW WHEN ( + new.site_id IS NULL OR new.site_id = 0 +) +BEGIN + SELECT phpbb_sitelist_seq.nextval + INTO :new.site_id + FROM dual; +END; +/ + + +/* + Table: 'phpbb_smilies' +*/ +CREATE TABLE phpbb_smilies ( + smiley_id number(8) NOT NULL, + code varchar2(150) DEFAULT '' , + emotion varchar2(150) DEFAULT '' , + smiley_url varchar2(50) DEFAULT '' , + smiley_width number(4) DEFAULT '0' NOT NULL, + smiley_height number(4) DEFAULT '0' NOT NULL, + smiley_order number(8) DEFAULT '0' NOT NULL, + display_on_posting number(1) DEFAULT '1' NOT NULL, + CONSTRAINT pk_phpbb_smilies PRIMARY KEY (smiley_id) +) +/ + +CREATE INDEX phpbb_smilies_display_on_post ON phpbb_smilies (display_on_posting) +/ + +CREATE SEQUENCE phpbb_smilies_seq +/ + +CREATE OR REPLACE TRIGGER t_phpbb_smilies +BEFORE INSERT ON phpbb_smilies +FOR EACH ROW WHEN ( + new.smiley_id IS NULL OR new.smiley_id = 0 +) +BEGIN + SELECT phpbb_smilies_seq.nextval + INTO :new.smiley_id + FROM dual; +END; +/ + + +/* + Table: 'phpbb_styles' +*/ +CREATE TABLE phpbb_styles ( + style_id number(8) NOT NULL, + style_name varchar2(765) DEFAULT '' , + style_copyright varchar2(765) DEFAULT '' , + style_active number(1) DEFAULT '1' NOT NULL, + style_path varchar2(100) DEFAULT '' , + bbcode_bitfield varchar2(255) DEFAULT 'kNg=' NOT NULL, + style_parent_id number(4) DEFAULT '0' NOT NULL, + style_parent_tree clob DEFAULT '' , + CONSTRAINT pk_phpbb_styles PRIMARY KEY (style_id), + CONSTRAINT u_phpbb_style_name UNIQUE (style_name) +) +/ + + +CREATE SEQUENCE phpbb_styles_seq +/ + +CREATE OR REPLACE TRIGGER t_phpbb_styles +BEFORE INSERT ON phpbb_styles +FOR EACH ROW WHEN ( + new.style_id IS NULL OR new.style_id = 0 +) +BEGIN + SELECT phpbb_styles_seq.nextval + INTO :new.style_id + FROM dual; +END; +/ + + +/* + Table: 'phpbb_topics' +*/ +CREATE TABLE phpbb_topics ( + topic_id number(8) NOT NULL, + forum_id number(8) DEFAULT '0' NOT NULL, + icon_id number(8) DEFAULT '0' NOT NULL, + topic_attachment number(1) DEFAULT '0' NOT NULL, + topic_approved number(1) DEFAULT '1' NOT NULL, + topic_reported number(1) DEFAULT '0' NOT NULL, + topic_title varchar2(765) DEFAULT '' , + topic_poster number(8) DEFAULT '0' NOT NULL, + topic_time number(11) DEFAULT '0' NOT NULL, + topic_time_limit number(11) DEFAULT '0' NOT NULL, + topic_views number(8) DEFAULT '0' NOT NULL, + topic_replies number(8) DEFAULT '0' NOT NULL, + topic_replies_real number(8) DEFAULT '0' NOT NULL, + topic_status number(3) DEFAULT '0' NOT NULL, + topic_type number(3) DEFAULT '0' NOT NULL, + topic_first_post_id number(8) DEFAULT '0' NOT NULL, + topic_first_poster_name varchar2(765) DEFAULT '' , + topic_first_poster_colour varchar2(6) DEFAULT '' , + topic_last_post_id number(8) DEFAULT '0' NOT NULL, + topic_last_poster_id number(8) DEFAULT '0' NOT NULL, + topic_last_poster_name varchar2(765) DEFAULT '' , + topic_last_poster_colour varchar2(6) DEFAULT '' , + topic_last_post_subject varchar2(765) DEFAULT '' , + topic_last_post_time number(11) DEFAULT '0' NOT NULL, + topic_last_view_time number(11) DEFAULT '0' NOT NULL, + topic_moved_id number(8) DEFAULT '0' NOT NULL, + topic_bumped number(1) DEFAULT '0' NOT NULL, + topic_bumper number(8) DEFAULT '0' NOT NULL, + poll_title varchar2(765) DEFAULT '' , + poll_start number(11) DEFAULT '0' NOT NULL, + poll_length number(11) DEFAULT '0' NOT NULL, + poll_max_options number(4) DEFAULT '1' NOT NULL, + poll_last_vote number(11) DEFAULT '0' NOT NULL, + poll_vote_change number(1) DEFAULT '0' NOT NULL, + CONSTRAINT pk_phpbb_topics PRIMARY KEY (topic_id) +) +/ + +CREATE INDEX phpbb_topics_forum_id ON phpbb_topics (forum_id) +/ +CREATE INDEX phpbb_topics_forum_id_type ON phpbb_topics (forum_id, topic_type) +/ +CREATE INDEX phpbb_topics_last_post_time ON phpbb_topics (topic_last_post_time) +/ +CREATE INDEX phpbb_topics_topic_approved ON phpbb_topics (topic_approved) +/ +CREATE INDEX phpbb_topics_forum_appr_last ON phpbb_topics (forum_id, topic_approved, topic_last_post_id) +/ +CREATE INDEX phpbb_topics_fid_time_moved ON phpbb_topics (forum_id, topic_last_post_time, topic_moved_id) +/ + +CREATE SEQUENCE phpbb_topics_seq +/ + +CREATE OR REPLACE TRIGGER t_phpbb_topics +BEFORE INSERT ON phpbb_topics +FOR EACH ROW WHEN ( + new.topic_id IS NULL OR new.topic_id = 0 +) +BEGIN + SELECT phpbb_topics_seq.nextval + INTO :new.topic_id + FROM dual; +END; +/ + + +/* + Table: 'phpbb_topics_track' +*/ +CREATE TABLE phpbb_topics_track ( + user_id number(8) DEFAULT '0' NOT NULL, + topic_id number(8) DEFAULT '0' NOT NULL, + forum_id number(8) DEFAULT '0' NOT NULL, + mark_time number(11) DEFAULT '0' NOT NULL, + CONSTRAINT pk_phpbb_topics_track PRIMARY KEY (user_id, topic_id) +) +/ + +CREATE INDEX phpbb_topics_track_topic_id ON phpbb_topics_track (topic_id) +/ +CREATE INDEX phpbb_topics_track_forum_id ON phpbb_topics_track (forum_id) +/ + +/* + Table: 'phpbb_topics_posted' +*/ +CREATE TABLE phpbb_topics_posted ( + user_id number(8) DEFAULT '0' NOT NULL, + topic_id number(8) DEFAULT '0' NOT NULL, + topic_posted number(1) DEFAULT '0' NOT NULL, + CONSTRAINT pk_phpbb_topics_posted PRIMARY KEY (user_id, topic_id) +) +/ + + +/* + Table: 'phpbb_topics_watch' +*/ +CREATE TABLE phpbb_topics_watch ( + topic_id number(8) DEFAULT '0' NOT NULL, + user_id number(8) DEFAULT '0' NOT NULL, + notify_status number(1) DEFAULT '0' NOT NULL +) +/ + +CREATE INDEX phpbb_topics_watch_topic_id ON phpbb_topics_watch (topic_id) +/ +CREATE INDEX phpbb_topics_watch_user_id ON phpbb_topics_watch (user_id) +/ +CREATE INDEX phpbb_topics_watch_notify_stat ON phpbb_topics_watch (notify_status) +/ + +/* + Table: 'phpbb_user_group' +*/ +CREATE TABLE phpbb_user_group ( + group_id number(8) DEFAULT '0' NOT NULL, + user_id number(8) DEFAULT '0' NOT NULL, + group_leader number(1) DEFAULT '0' NOT NULL, + user_pending number(1) DEFAULT '1' NOT NULL +) +/ + +CREATE INDEX phpbb_user_group_group_id ON phpbb_user_group (group_id) +/ +CREATE INDEX phpbb_user_group_user_id ON phpbb_user_group (user_id) +/ +CREATE INDEX phpbb_user_group_group_leader ON phpbb_user_group (group_leader) +/ + +/* + Table: 'phpbb_users' +*/ +CREATE TABLE phpbb_users ( + user_id number(8) NOT NULL, + user_type number(2) DEFAULT '0' NOT NULL, + group_id number(8) DEFAULT '3' NOT NULL, + user_permissions clob DEFAULT '' , + user_perm_from number(8) DEFAULT '0' NOT NULL, + user_ip varchar2(40) DEFAULT '' , + user_regdate number(11) DEFAULT '0' NOT NULL, + username varchar2(255) DEFAULT '' , + username_clean varchar2(255) DEFAULT '' , + user_password varchar2(120) DEFAULT '' , + user_passchg number(11) DEFAULT '0' NOT NULL, + user_pass_convert number(1) DEFAULT '0' NOT NULL, + user_email varchar2(300) DEFAULT '' , + user_email_hash number(20) DEFAULT '0' NOT NULL, + user_birthday varchar2(10) DEFAULT '' , + user_lastvisit number(11) DEFAULT '0' NOT NULL, + user_lastmark number(11) DEFAULT '0' NOT NULL, + user_lastpost_time number(11) DEFAULT '0' NOT NULL, + user_lastpage varchar2(600) DEFAULT '' , + user_last_confirm_key varchar2(10) DEFAULT '' , + user_last_search number(11) DEFAULT '0' NOT NULL, + user_warnings number(4) DEFAULT '0' NOT NULL, + user_last_warning number(11) DEFAULT '0' NOT NULL, + user_login_attempts number(4) DEFAULT '0' NOT NULL, + user_inactive_reason number(2) DEFAULT '0' NOT NULL, + user_inactive_time number(11) DEFAULT '0' NOT NULL, + user_posts number(8) DEFAULT '0' NOT NULL, + user_lang varchar2(30) DEFAULT '' , + user_timezone varchar2(100) DEFAULT 'UTC' NOT NULL, + user_dateformat varchar2(90) DEFAULT 'd M Y H:i' NOT NULL, + user_style number(8) DEFAULT '0' NOT NULL, + user_rank number(8) DEFAULT '0' NOT NULL, + user_colour varchar2(6) DEFAULT '' , + user_new_privmsg number(4) DEFAULT '0' NOT NULL, + user_unread_privmsg number(4) DEFAULT '0' NOT NULL, + user_last_privmsg number(11) DEFAULT '0' NOT NULL, + user_message_rules number(1) DEFAULT '0' NOT NULL, + user_full_folder number(11) DEFAULT '-3' NOT NULL, + user_emailtime number(11) DEFAULT '0' NOT NULL, + user_topic_show_days number(4) DEFAULT '0' NOT NULL, + user_topic_sortby_type varchar2(1) DEFAULT 't' NOT NULL, + user_topic_sortby_dir varchar2(1) DEFAULT 'd' NOT NULL, + user_post_show_days number(4) DEFAULT '0' NOT NULL, + user_post_sortby_type varchar2(1) DEFAULT 't' NOT NULL, + user_post_sortby_dir varchar2(1) DEFAULT 'a' NOT NULL, + user_notify number(1) DEFAULT '0' NOT NULL, + user_notify_pm number(1) DEFAULT '1' NOT NULL, + user_notify_type number(4) DEFAULT '0' NOT NULL, + user_allow_pm number(1) DEFAULT '1' NOT NULL, + user_allow_viewonline number(1) DEFAULT '1' NOT NULL, + user_allow_viewemail number(1) DEFAULT '1' NOT NULL, + user_allow_massemail number(1) DEFAULT '1' NOT NULL, + user_options number(11) DEFAULT '230271' NOT NULL, + user_avatar varchar2(255) DEFAULT '' , + user_avatar_type number(2) DEFAULT '0' NOT NULL, + user_avatar_width number(4) DEFAULT '0' NOT NULL, + user_avatar_height number(4) DEFAULT '0' NOT NULL, + user_sig clob DEFAULT '' , + user_sig_bbcode_uid varchar2(8) DEFAULT '' , + user_sig_bbcode_bitfield varchar2(255) DEFAULT '' , + user_from varchar2(300) DEFAULT '' , + user_icq varchar2(15) DEFAULT '' , + user_aim varchar2(765) DEFAULT '' , + user_yim varchar2(765) DEFAULT '' , + user_msnm varchar2(765) DEFAULT '' , + user_jabber varchar2(765) DEFAULT '' , + user_website varchar2(600) DEFAULT '' , + user_occ clob DEFAULT '' , + user_interests clob DEFAULT '' , + user_actkey varchar2(32) DEFAULT '' , + user_newpasswd varchar2(120) DEFAULT '' , + user_form_salt varchar2(96) DEFAULT '' , + user_new number(1) DEFAULT '1' NOT NULL, + user_reminded number(4) DEFAULT '0' NOT NULL, + user_reminded_time number(11) DEFAULT '0' NOT NULL, + CONSTRAINT pk_phpbb_users PRIMARY KEY (user_id), + CONSTRAINT u_phpbb_username_clean UNIQUE (username_clean) +) +/ + +CREATE INDEX phpbb_users_user_birthday ON phpbb_users (user_birthday) +/ +CREATE INDEX phpbb_users_user_email_hash ON phpbb_users (user_email_hash) +/ +CREATE INDEX phpbb_users_user_type ON phpbb_users (user_type) +/ + +CREATE SEQUENCE phpbb_users_seq +/ + +CREATE OR REPLACE TRIGGER t_phpbb_users +BEFORE INSERT ON phpbb_users +FOR EACH ROW WHEN ( + new.user_id IS NULL OR new.user_id = 0 +) +BEGIN + SELECT phpbb_users_seq.nextval + INTO :new.user_id + FROM dual; +END; +/ + + +/* + Table: 'phpbb_warnings' +*/ +CREATE TABLE phpbb_warnings ( + warning_id number(8) NOT NULL, + user_id number(8) DEFAULT '0' NOT NULL, + post_id number(8) DEFAULT '0' NOT NULL, + log_id number(8) DEFAULT '0' NOT NULL, + warning_time number(11) DEFAULT '0' NOT NULL, + CONSTRAINT pk_phpbb_warnings PRIMARY KEY (warning_id) +) +/ + + +CREATE SEQUENCE phpbb_warnings_seq +/ + +CREATE OR REPLACE TRIGGER t_phpbb_warnings +BEFORE INSERT ON phpbb_warnings +FOR EACH ROW WHEN ( + new.warning_id IS NULL OR new.warning_id = 0 +) +BEGIN + SELECT phpbb_warnings_seq.nextval + INTO :new.warning_id + FROM dual; +END; +/ + + +/* + Table: 'phpbb_words' +*/ +CREATE TABLE phpbb_words ( + word_id number(8) NOT NULL, + word varchar2(765) DEFAULT '' , + replacement varchar2(765) DEFAULT '' , + CONSTRAINT pk_phpbb_words PRIMARY KEY (word_id) +) +/ + + +CREATE SEQUENCE phpbb_words_seq +/ + +CREATE OR REPLACE TRIGGER t_phpbb_words +BEFORE INSERT ON phpbb_words +FOR EACH ROW WHEN ( + new.word_id IS NULL OR new.word_id = 0 +) +BEGIN + SELECT phpbb_words_seq.nextval + INTO :new.word_id + FROM dual; +END; +/ + + +/* + Table: 'phpbb_zebra' +*/ +CREATE TABLE phpbb_zebra ( + user_id number(8) DEFAULT '0' NOT NULL, + zebra_id number(8) DEFAULT '0' NOT NULL, + friend number(1) DEFAULT '0' NOT NULL, + foe number(1) DEFAULT '0' NOT NULL, + CONSTRAINT pk_phpbb_zebra PRIMARY KEY (user_id, zebra_id) +) +/ diff --git a/phpBB/install/schemas/postgres_schema.sql b/phpBB/install/schemas/postgres_schema.sql index 659a32bf19..e1678c9cc5 100644 --- a/phpBB/install/schemas/postgres_schema.sql +++ b/phpBB/install/schemas/postgres_schema.sql @@ -1,1240 +1,1236 @@ -/* - * DO NOT EDIT THIS FILE, IT IS GENERATED - * - * To change the contents of this file, edit - * phpBB/develop/create_schema_files.php and - * run it. - */ - -BEGIN; - -/* - Domain definition -*/ -CREATE DOMAIN varchar_ci AS varchar(255) NOT NULL DEFAULT ''::character varying; - -/* - Operation Functions -*/ -CREATE FUNCTION _varchar_ci_equal(varchar_ci, varchar_ci) RETURNS boolean AS 'SELECT LOWER($1) = LOWER($2)' LANGUAGE SQL STRICT; -CREATE FUNCTION _varchar_ci_not_equal(varchar_ci, varchar_ci) RETURNS boolean AS 'SELECT LOWER($1) != LOWER($2)' LANGUAGE SQL STRICT; -CREATE FUNCTION _varchar_ci_less_than(varchar_ci, varchar_ci) RETURNS boolean AS 'SELECT LOWER($1) < LOWER($2)' LANGUAGE SQL STRICT; -CREATE FUNCTION _varchar_ci_less_equal(varchar_ci, varchar_ci) RETURNS boolean AS 'SELECT LOWER($1) <= LOWER($2)' LANGUAGE SQL STRICT; -CREATE FUNCTION _varchar_ci_greater_than(varchar_ci, varchar_ci) RETURNS boolean AS 'SELECT LOWER($1) > LOWER($2)' LANGUAGE SQL STRICT; -CREATE FUNCTION _varchar_ci_greater_equals(varchar_ci, varchar_ci) RETURNS boolean AS 'SELECT LOWER($1) >= LOWER($2)' LANGUAGE SQL STRICT; - -/* - Operators -*/ -CREATE OPERATOR <( - PROCEDURE = _varchar_ci_less_than, - LEFTARG = varchar_ci, - RIGHTARG = varchar_ci, - COMMUTATOR = >, - NEGATOR = >=, - RESTRICT = scalarltsel, - JOIN = scalarltjoinsel); - -CREATE OPERATOR <=( - PROCEDURE = _varchar_ci_less_equal, - LEFTARG = varchar_ci, - RIGHTARG = varchar_ci, - COMMUTATOR = >=, - NEGATOR = >, - RESTRICT = scalarltsel, - JOIN = scalarltjoinsel); - -CREATE OPERATOR >( - PROCEDURE = _varchar_ci_greater_than, - LEFTARG = varchar_ci, - RIGHTARG = varchar_ci, - COMMUTATOR = <, - NEGATOR = <=, - RESTRICT = scalargtsel, - JOIN = scalargtjoinsel); - -CREATE OPERATOR >=( - PROCEDURE = _varchar_ci_greater_equals, - LEFTARG = varchar_ci, - RIGHTARG = varchar_ci, - COMMUTATOR = <=, - NEGATOR = <, - RESTRICT = scalargtsel, - JOIN = scalargtjoinsel); - -CREATE OPERATOR <>( - PROCEDURE = _varchar_ci_not_equal, - LEFTARG = varchar_ci, - RIGHTARG = varchar_ci, - COMMUTATOR = <>, - NEGATOR = =, - RESTRICT = neqsel, - JOIN = neqjoinsel); - -CREATE OPERATOR =( - PROCEDURE = _varchar_ci_equal, - LEFTARG = varchar_ci, - RIGHTARG = varchar_ci, - COMMUTATOR = =, - NEGATOR = <>, - RESTRICT = eqsel, - JOIN = eqjoinsel, - HASHES, - MERGES, - SORT1= <); - -/* - Table: 'phpbb_attachments' -*/ -CREATE SEQUENCE phpbb_attachments_seq; - -CREATE TABLE phpbb_attachments ( - attach_id INT4 DEFAULT nextval('phpbb_attachments_seq'), - post_msg_id INT4 DEFAULT '0' NOT NULL CHECK (post_msg_id >= 0), - topic_id INT4 DEFAULT '0' NOT NULL CHECK (topic_id >= 0), - in_message INT2 DEFAULT '0' NOT NULL CHECK (in_message >= 0), - poster_id INT4 DEFAULT '0' NOT NULL CHECK (poster_id >= 0), - is_orphan INT2 DEFAULT '1' NOT NULL CHECK (is_orphan >= 0), - physical_filename varchar(255) DEFAULT '' NOT NULL, - real_filename varchar(255) DEFAULT '' NOT NULL, - download_count INT4 DEFAULT '0' NOT NULL CHECK (download_count >= 0), - attach_comment varchar(4000) DEFAULT '' NOT NULL, - extension varchar(100) DEFAULT '' NOT NULL, - mimetype varchar(100) DEFAULT '' NOT NULL, - filesize INT4 DEFAULT '0' NOT NULL CHECK (filesize >= 0), - filetime INT4 DEFAULT '0' NOT NULL CHECK (filetime >= 0), - thumbnail INT2 DEFAULT '0' NOT NULL CHECK (thumbnail >= 0), - PRIMARY KEY (attach_id) -); - -CREATE INDEX phpbb_attachments_filetime ON phpbb_attachments (filetime); -CREATE INDEX phpbb_attachments_post_msg_id ON phpbb_attachments (post_msg_id); -CREATE INDEX phpbb_attachments_topic_id ON phpbb_attachments (topic_id); -CREATE INDEX phpbb_attachments_poster_id ON phpbb_attachments (poster_id); -CREATE INDEX phpbb_attachments_is_orphan ON phpbb_attachments (is_orphan); - -/* - Table: 'phpbb_acl_groups' -*/ -CREATE TABLE phpbb_acl_groups ( - group_id INT4 DEFAULT '0' NOT NULL CHECK (group_id >= 0), - forum_id INT4 DEFAULT '0' NOT NULL CHECK (forum_id >= 0), - auth_option_id INT4 DEFAULT '0' NOT NULL CHECK (auth_option_id >= 0), - auth_role_id INT4 DEFAULT '0' NOT NULL CHECK (auth_role_id >= 0), - auth_setting INT2 DEFAULT '0' NOT NULL -); - -CREATE INDEX phpbb_acl_groups_group_id ON phpbb_acl_groups (group_id); -CREATE INDEX phpbb_acl_groups_auth_opt_id ON phpbb_acl_groups (auth_option_id); -CREATE INDEX phpbb_acl_groups_auth_role_id ON phpbb_acl_groups (auth_role_id); - -/* - Table: 'phpbb_acl_options' -*/ -CREATE SEQUENCE phpbb_acl_options_seq; - -CREATE TABLE phpbb_acl_options ( - auth_option_id INT4 DEFAULT nextval('phpbb_acl_options_seq'), - auth_option varchar(50) DEFAULT '' NOT NULL, - is_global INT2 DEFAULT '0' NOT NULL CHECK (is_global >= 0), - is_local INT2 DEFAULT '0' NOT NULL CHECK (is_local >= 0), - founder_only INT2 DEFAULT '0' NOT NULL CHECK (founder_only >= 0), - PRIMARY KEY (auth_option_id) -); - -CREATE UNIQUE INDEX phpbb_acl_options_auth_option ON phpbb_acl_options (auth_option); - -/* - Table: 'phpbb_acl_roles' -*/ -CREATE SEQUENCE phpbb_acl_roles_seq; - -CREATE TABLE phpbb_acl_roles ( - role_id INT4 DEFAULT nextval('phpbb_acl_roles_seq'), - role_name varchar(255) DEFAULT '' NOT NULL, - role_description varchar(4000) DEFAULT '' NOT NULL, - role_type varchar(10) DEFAULT '' NOT NULL, - role_order INT2 DEFAULT '0' NOT NULL CHECK (role_order >= 0), - PRIMARY KEY (role_id) -); - -CREATE INDEX phpbb_acl_roles_role_type ON phpbb_acl_roles (role_type); -CREATE INDEX phpbb_acl_roles_role_order ON phpbb_acl_roles (role_order); - -/* - Table: 'phpbb_acl_roles_data' -*/ -CREATE TABLE phpbb_acl_roles_data ( - role_id INT4 DEFAULT '0' NOT NULL CHECK (role_id >= 0), - auth_option_id INT4 DEFAULT '0' NOT NULL CHECK (auth_option_id >= 0), - auth_setting INT2 DEFAULT '0' NOT NULL, - PRIMARY KEY (role_id, auth_option_id) -); - -CREATE INDEX phpbb_acl_roles_data_ath_op_id ON phpbb_acl_roles_data (auth_option_id); - -/* - Table: 'phpbb_acl_users' -*/ -CREATE TABLE phpbb_acl_users ( - user_id INT4 DEFAULT '0' NOT NULL CHECK (user_id >= 0), - forum_id INT4 DEFAULT '0' NOT NULL CHECK (forum_id >= 0), - auth_option_id INT4 DEFAULT '0' NOT NULL CHECK (auth_option_id >= 0), - auth_role_id INT4 DEFAULT '0' NOT NULL CHECK (auth_role_id >= 0), - auth_setting INT2 DEFAULT '0' NOT NULL -); - -CREATE INDEX phpbb_acl_users_user_id ON phpbb_acl_users (user_id); -CREATE INDEX phpbb_acl_users_auth_option_id ON phpbb_acl_users (auth_option_id); -CREATE INDEX phpbb_acl_users_auth_role_id ON phpbb_acl_users (auth_role_id); - -/* - Table: 'phpbb_banlist' -*/ -CREATE SEQUENCE phpbb_banlist_seq; - -CREATE TABLE phpbb_banlist ( - ban_id INT4 DEFAULT nextval('phpbb_banlist_seq'), - ban_userid INT4 DEFAULT '0' NOT NULL CHECK (ban_userid >= 0), - ban_ip varchar(40) DEFAULT '' NOT NULL, - ban_email varchar(100) DEFAULT '' NOT NULL, - ban_start INT4 DEFAULT '0' NOT NULL CHECK (ban_start >= 0), - ban_end INT4 DEFAULT '0' NOT NULL CHECK (ban_end >= 0), - ban_exclude INT2 DEFAULT '0' NOT NULL CHECK (ban_exclude >= 0), - ban_reason varchar(255) DEFAULT '' NOT NULL, - ban_give_reason varchar(255) DEFAULT '' NOT NULL, - PRIMARY KEY (ban_id) -); - -CREATE INDEX phpbb_banlist_ban_end ON phpbb_banlist (ban_end); -CREATE INDEX phpbb_banlist_ban_user ON phpbb_banlist (ban_userid, ban_exclude); -CREATE INDEX phpbb_banlist_ban_email ON phpbb_banlist (ban_email, ban_exclude); -CREATE INDEX phpbb_banlist_ban_ip ON phpbb_banlist (ban_ip, ban_exclude); - -/* - Table: 'phpbb_bbcodes' -*/ -CREATE TABLE phpbb_bbcodes ( - bbcode_id INT2 DEFAULT '0' NOT NULL CHECK (bbcode_id >= 0), - bbcode_tag varchar(16) DEFAULT '' NOT NULL, - bbcode_helpline varchar(255) DEFAULT '' NOT NULL, - display_on_posting INT2 DEFAULT '0' NOT NULL CHECK (display_on_posting >= 0), - bbcode_match varchar(4000) DEFAULT '' NOT NULL, - bbcode_tpl TEXT DEFAULT '' NOT NULL, - first_pass_match TEXT DEFAULT '' NOT NULL, - first_pass_replace TEXT DEFAULT '' NOT NULL, - second_pass_match TEXT DEFAULT '' NOT NULL, - second_pass_replace TEXT DEFAULT '' NOT NULL, - PRIMARY KEY (bbcode_id) -); - -CREATE INDEX phpbb_bbcodes_display_on_post ON phpbb_bbcodes (display_on_posting); - -/* - Table: 'phpbb_bookmarks' -*/ -CREATE TABLE phpbb_bookmarks ( - topic_id INT4 DEFAULT '0' NOT NULL CHECK (topic_id >= 0), - user_id INT4 DEFAULT '0' NOT NULL CHECK (user_id >= 0), - PRIMARY KEY (topic_id, user_id) -); - - -/* - Table: 'phpbb_bots' -*/ -CREATE SEQUENCE phpbb_bots_seq; - -CREATE TABLE phpbb_bots ( - bot_id INT4 DEFAULT nextval('phpbb_bots_seq'), - bot_active INT2 DEFAULT '1' NOT NULL CHECK (bot_active >= 0), - bot_name varchar(255) DEFAULT '' NOT NULL, - user_id INT4 DEFAULT '0' NOT NULL CHECK (user_id >= 0), - bot_agent varchar(255) DEFAULT '' NOT NULL, - bot_ip varchar(255) DEFAULT '' NOT NULL, - PRIMARY KEY (bot_id) -); - -CREATE INDEX phpbb_bots_bot_active ON phpbb_bots (bot_active); - -/* - Table: 'phpbb_config' -*/ -CREATE TABLE phpbb_config ( - config_name varchar(255) DEFAULT '' NOT NULL, - config_value varchar(255) DEFAULT '' NOT NULL, - is_dynamic INT2 DEFAULT '0' NOT NULL CHECK (is_dynamic >= 0), - PRIMARY KEY (config_name) -); - -CREATE INDEX phpbb_config_is_dynamic ON phpbb_config (is_dynamic); - -/* - Table: 'phpbb_confirm' -*/ -CREATE TABLE phpbb_confirm ( - confirm_id char(32) DEFAULT '' NOT NULL, - session_id char(32) DEFAULT '' NOT NULL, - confirm_type INT2 DEFAULT '0' NOT NULL, - code varchar(8) DEFAULT '' NOT NULL, - seed INT4 DEFAULT '0' NOT NULL CHECK (seed >= 0), - attempts INT4 DEFAULT '0' NOT NULL CHECK (attempts >= 0), - PRIMARY KEY (session_id, confirm_id) -); - -CREATE INDEX phpbb_confirm_confirm_type ON phpbb_confirm (confirm_type); - -/* - Table: 'phpbb_disallow' -*/ -CREATE SEQUENCE phpbb_disallow_seq; - -CREATE TABLE phpbb_disallow ( - disallow_id INT4 DEFAULT nextval('phpbb_disallow_seq'), - disallow_username varchar(255) DEFAULT '' NOT NULL, - PRIMARY KEY (disallow_id) -); - - -/* - Table: 'phpbb_drafts' -*/ -CREATE SEQUENCE phpbb_drafts_seq; - -CREATE TABLE phpbb_drafts ( - draft_id INT4 DEFAULT nextval('phpbb_drafts_seq'), - user_id INT4 DEFAULT '0' NOT NULL CHECK (user_id >= 0), - topic_id INT4 DEFAULT '0' NOT NULL CHECK (topic_id >= 0), - forum_id INT4 DEFAULT '0' NOT NULL CHECK (forum_id >= 0), - save_time INT4 DEFAULT '0' NOT NULL CHECK (save_time >= 0), - draft_subject varchar(255) DEFAULT '' NOT NULL, - draft_message TEXT DEFAULT '' NOT NULL, - PRIMARY KEY (draft_id) -); - -CREATE INDEX phpbb_drafts_save_time ON phpbb_drafts (save_time); - -/* - Table: 'phpbb_ext' -*/ -CREATE TABLE phpbb_ext ( - ext_name varchar(255) DEFAULT '' NOT NULL, - ext_active INT2 DEFAULT '0' NOT NULL CHECK (ext_active >= 0), - ext_state varchar(8000) DEFAULT '' NOT NULL -); - -CREATE UNIQUE INDEX phpbb_ext_ext_name ON phpbb_ext (ext_name); - -/* - Table: 'phpbb_extensions' -*/ -CREATE SEQUENCE phpbb_extensions_seq; - -CREATE TABLE phpbb_extensions ( - extension_id INT4 DEFAULT nextval('phpbb_extensions_seq'), - group_id INT4 DEFAULT '0' NOT NULL CHECK (group_id >= 0), - extension varchar(100) DEFAULT '' NOT NULL, - PRIMARY KEY (extension_id) -); - - -/* - Table: 'phpbb_extension_groups' -*/ -CREATE SEQUENCE phpbb_extension_groups_seq; - -CREATE TABLE phpbb_extension_groups ( - group_id INT4 DEFAULT nextval('phpbb_extension_groups_seq'), - group_name varchar(255) DEFAULT '' NOT NULL, - cat_id INT2 DEFAULT '0' NOT NULL, - allow_group INT2 DEFAULT '0' NOT NULL CHECK (allow_group >= 0), - download_mode INT2 DEFAULT '1' NOT NULL CHECK (download_mode >= 0), - upload_icon varchar(255) DEFAULT '' NOT NULL, - max_filesize INT4 DEFAULT '0' NOT NULL CHECK (max_filesize >= 0), - allowed_forums varchar(8000) DEFAULT '' NOT NULL, - allow_in_pm INT2 DEFAULT '0' NOT NULL CHECK (allow_in_pm >= 0), - PRIMARY KEY (group_id) -); - - -/* - Table: 'phpbb_forums' -*/ -CREATE SEQUENCE phpbb_forums_seq; - -CREATE TABLE phpbb_forums ( - forum_id INT4 DEFAULT nextval('phpbb_forums_seq'), - parent_id INT4 DEFAULT '0' NOT NULL CHECK (parent_id >= 0), - left_id INT4 DEFAULT '0' NOT NULL CHECK (left_id >= 0), - right_id INT4 DEFAULT '0' NOT NULL CHECK (right_id >= 0), - forum_parents TEXT DEFAULT '' NOT NULL, - forum_name varchar(255) DEFAULT '' NOT NULL, - forum_desc varchar(4000) DEFAULT '' NOT NULL, - forum_desc_bitfield varchar(255) DEFAULT '' NOT NULL, - forum_desc_options INT4 DEFAULT '7' NOT NULL CHECK (forum_desc_options >= 0), - forum_desc_uid varchar(8) DEFAULT '' NOT NULL, - forum_link varchar(255) DEFAULT '' NOT NULL, - forum_password varchar(40) DEFAULT '' NOT NULL, - forum_style INT4 DEFAULT '0' NOT NULL CHECK (forum_style >= 0), - forum_image varchar(255) DEFAULT '' NOT NULL, - forum_rules varchar(4000) DEFAULT '' NOT NULL, - forum_rules_link varchar(255) DEFAULT '' NOT NULL, - forum_rules_bitfield varchar(255) DEFAULT '' NOT NULL, - forum_rules_options INT4 DEFAULT '7' NOT NULL CHECK (forum_rules_options >= 0), - forum_rules_uid varchar(8) DEFAULT '' NOT NULL, - forum_topics_per_page INT2 DEFAULT '0' NOT NULL, - forum_type INT2 DEFAULT '0' NOT NULL, - forum_status INT2 DEFAULT '0' NOT NULL, - forum_posts INT4 DEFAULT '0' NOT NULL CHECK (forum_posts >= 0), - forum_topics INT4 DEFAULT '0' NOT NULL CHECK (forum_topics >= 0), - forum_topics_real INT4 DEFAULT '0' NOT NULL CHECK (forum_topics_real >= 0), - forum_last_post_id INT4 DEFAULT '0' NOT NULL CHECK (forum_last_post_id >= 0), - forum_last_poster_id INT4 DEFAULT '0' NOT NULL CHECK (forum_last_poster_id >= 0), - forum_last_post_subject varchar(255) DEFAULT '' NOT NULL, - forum_last_post_time INT4 DEFAULT '0' NOT NULL CHECK (forum_last_post_time >= 0), - forum_last_poster_name varchar(255) DEFAULT '' NOT NULL, - forum_last_poster_colour varchar(6) DEFAULT '' NOT NULL, - forum_flags INT2 DEFAULT '32' NOT NULL, - forum_options INT4 DEFAULT '0' NOT NULL CHECK (forum_options >= 0), - display_subforum_list INT2 DEFAULT '1' NOT NULL CHECK (display_subforum_list >= 0), - display_on_index INT2 DEFAULT '1' NOT NULL CHECK (display_on_index >= 0), - enable_indexing INT2 DEFAULT '1' NOT NULL CHECK (enable_indexing >= 0), - enable_icons INT2 DEFAULT '1' NOT NULL CHECK (enable_icons >= 0), - enable_prune INT2 DEFAULT '0' NOT NULL CHECK (enable_prune >= 0), - prune_next INT4 DEFAULT '0' NOT NULL CHECK (prune_next >= 0), - prune_days INT4 DEFAULT '0' NOT NULL CHECK (prune_days >= 0), - prune_viewed INT4 DEFAULT '0' NOT NULL CHECK (prune_viewed >= 0), - prune_freq INT4 DEFAULT '0' NOT NULL CHECK (prune_freq >= 0), - PRIMARY KEY (forum_id) -); - -CREATE INDEX phpbb_forums_left_right_id ON phpbb_forums (left_id, right_id); -CREATE INDEX phpbb_forums_forum_lastpost_id ON phpbb_forums (forum_last_post_id); - -/* - Table: 'phpbb_forums_access' -*/ -CREATE TABLE phpbb_forums_access ( - forum_id INT4 DEFAULT '0' NOT NULL CHECK (forum_id >= 0), - user_id INT4 DEFAULT '0' NOT NULL CHECK (user_id >= 0), - session_id char(32) DEFAULT '' NOT NULL, - PRIMARY KEY (forum_id, user_id, session_id) -); - - -/* - Table: 'phpbb_forums_track' -*/ -CREATE TABLE phpbb_forums_track ( - user_id INT4 DEFAULT '0' NOT NULL CHECK (user_id >= 0), - forum_id INT4 DEFAULT '0' NOT NULL CHECK (forum_id >= 0), - mark_time INT4 DEFAULT '0' NOT NULL CHECK (mark_time >= 0), - PRIMARY KEY (user_id, forum_id) -); - - -/* - Table: 'phpbb_forums_watch' -*/ -CREATE TABLE phpbb_forums_watch ( - forum_id INT4 DEFAULT '0' NOT NULL CHECK (forum_id >= 0), - user_id INT4 DEFAULT '0' NOT NULL CHECK (user_id >= 0), - notify_status INT2 DEFAULT '0' NOT NULL CHECK (notify_status >= 0) -); - -CREATE INDEX phpbb_forums_watch_forum_id ON phpbb_forums_watch (forum_id); -CREATE INDEX phpbb_forums_watch_user_id ON phpbb_forums_watch (user_id); -CREATE INDEX phpbb_forums_watch_notify_stat ON phpbb_forums_watch (notify_status); - -/* - Table: 'phpbb_groups' -*/ -CREATE SEQUENCE phpbb_groups_seq; - -CREATE TABLE phpbb_groups ( - group_id INT4 DEFAULT nextval('phpbb_groups_seq'), - group_type INT2 DEFAULT '1' NOT NULL, - group_founder_manage INT2 DEFAULT '0' NOT NULL CHECK (group_founder_manage >= 0), - group_skip_auth INT2 DEFAULT '0' NOT NULL CHECK (group_skip_auth >= 0), - group_name varchar_ci DEFAULT '' NOT NULL, - group_desc varchar(4000) DEFAULT '' NOT NULL, - group_desc_bitfield varchar(255) DEFAULT '' NOT NULL, - group_desc_options INT4 DEFAULT '7' NOT NULL CHECK (group_desc_options >= 0), - group_desc_uid varchar(8) DEFAULT '' NOT NULL, - group_display INT2 DEFAULT '0' NOT NULL CHECK (group_display >= 0), - group_avatar varchar(255) DEFAULT '' NOT NULL, - group_avatar_type INT2 DEFAULT '0' NOT NULL, - group_avatar_width INT2 DEFAULT '0' NOT NULL CHECK (group_avatar_width >= 0), - group_avatar_height INT2 DEFAULT '0' NOT NULL CHECK (group_avatar_height >= 0), - group_rank INT4 DEFAULT '0' NOT NULL CHECK (group_rank >= 0), - group_colour varchar(6) DEFAULT '' NOT NULL, - group_sig_chars INT4 DEFAULT '0' NOT NULL CHECK (group_sig_chars >= 0), - group_receive_pm INT2 DEFAULT '0' NOT NULL CHECK (group_receive_pm >= 0), - group_message_limit INT4 DEFAULT '0' NOT NULL CHECK (group_message_limit >= 0), - group_max_recipients INT4 DEFAULT '0' NOT NULL CHECK (group_max_recipients >= 0), - group_legend INT4 DEFAULT '0' NOT NULL CHECK (group_legend >= 0), - group_teampage INT4 DEFAULT '0' NOT NULL CHECK (group_teampage >= 0), - PRIMARY KEY (group_id) -); - -CREATE INDEX phpbb_groups_group_legend_name ON phpbb_groups (group_legend, group_name); - -/* - Table: 'phpbb_icons' -*/ -CREATE SEQUENCE phpbb_icons_seq; - -CREATE TABLE phpbb_icons ( - icons_id INT4 DEFAULT nextval('phpbb_icons_seq'), - icons_url varchar(255) DEFAULT '' NOT NULL, - icons_width INT2 DEFAULT '0' NOT NULL, - icons_height INT2 DEFAULT '0' NOT NULL, - icons_order INT4 DEFAULT '0' NOT NULL CHECK (icons_order >= 0), - display_on_posting INT2 DEFAULT '1' NOT NULL CHECK (display_on_posting >= 0), - PRIMARY KEY (icons_id) -); - -CREATE INDEX phpbb_icons_display_on_posting ON phpbb_icons (display_on_posting); - -/* - Table: 'phpbb_lang' -*/ -CREATE SEQUENCE phpbb_lang_seq; - -CREATE TABLE phpbb_lang ( - lang_id INT2 DEFAULT nextval('phpbb_lang_seq'), - lang_iso varchar(30) DEFAULT '' NOT NULL, - lang_dir varchar(30) DEFAULT '' NOT NULL, - lang_english_name varchar(100) DEFAULT '' NOT NULL, - lang_local_name varchar(255) DEFAULT '' NOT NULL, - lang_author varchar(255) DEFAULT '' NOT NULL, - PRIMARY KEY (lang_id) -); - -CREATE INDEX phpbb_lang_lang_iso ON phpbb_lang (lang_iso); - -/* - Table: 'phpbb_log' -*/ -CREATE SEQUENCE phpbb_log_seq; - -CREATE TABLE phpbb_log ( - log_id INT4 DEFAULT nextval('phpbb_log_seq'), - log_type INT2 DEFAULT '0' NOT NULL, - user_id INT4 DEFAULT '0' NOT NULL CHECK (user_id >= 0), - forum_id INT4 DEFAULT '0' NOT NULL CHECK (forum_id >= 0), - topic_id INT4 DEFAULT '0' NOT NULL CHECK (topic_id >= 0), - reportee_id INT4 DEFAULT '0' NOT NULL CHECK (reportee_id >= 0), - log_ip varchar(40) DEFAULT '' NOT NULL, - log_time INT4 DEFAULT '0' NOT NULL CHECK (log_time >= 0), - log_operation varchar(4000) DEFAULT '' NOT NULL, - log_data TEXT DEFAULT '' NOT NULL, - PRIMARY KEY (log_id) -); - -CREATE INDEX phpbb_log_log_type ON phpbb_log (log_type); -CREATE INDEX phpbb_log_log_time ON phpbb_log (log_time); -CREATE INDEX phpbb_log_forum_id ON phpbb_log (forum_id); -CREATE INDEX phpbb_log_topic_id ON phpbb_log (topic_id); -CREATE INDEX phpbb_log_reportee_id ON phpbb_log (reportee_id); -CREATE INDEX phpbb_log_user_id ON phpbb_log (user_id); - -/* - Table: 'phpbb_login_attempts' -*/ -CREATE TABLE phpbb_login_attempts ( - attempt_ip varchar(40) DEFAULT '' NOT NULL, - attempt_browser varchar(150) DEFAULT '' NOT NULL, - attempt_forwarded_for varchar(255) DEFAULT '' NOT NULL, - attempt_time INT4 DEFAULT '0' NOT NULL CHECK (attempt_time >= 0), - user_id INT4 DEFAULT '0' NOT NULL CHECK (user_id >= 0), - username varchar(255) DEFAULT '0' NOT NULL, - username_clean varchar_ci DEFAULT '0' NOT NULL -); - -CREATE INDEX phpbb_login_attempts_att_ip ON phpbb_login_attempts (attempt_ip, attempt_time); -CREATE INDEX phpbb_login_attempts_att_for ON phpbb_login_attempts (attempt_forwarded_for, attempt_time); -CREATE INDEX phpbb_login_attempts_att_time ON phpbb_login_attempts (attempt_time); -CREATE INDEX phpbb_login_attempts_user_id ON phpbb_login_attempts (user_id); - -/* - Table: 'phpbb_moderator_cache' -*/ -CREATE TABLE phpbb_moderator_cache ( - forum_id INT4 DEFAULT '0' NOT NULL CHECK (forum_id >= 0), - user_id INT4 DEFAULT '0' NOT NULL CHECK (user_id >= 0), - username varchar(255) DEFAULT '' NOT NULL, - group_id INT4 DEFAULT '0' NOT NULL CHECK (group_id >= 0), - group_name varchar(255) DEFAULT '' NOT NULL, - display_on_index INT2 DEFAULT '1' NOT NULL CHECK (display_on_index >= 0) -); - -CREATE INDEX phpbb_moderator_cache_disp_idx ON phpbb_moderator_cache (display_on_index); -CREATE INDEX phpbb_moderator_cache_forum_id ON phpbb_moderator_cache (forum_id); - -/* - Table: 'phpbb_modules' -*/ -CREATE SEQUENCE phpbb_modules_seq; - -CREATE TABLE phpbb_modules ( - module_id INT4 DEFAULT nextval('phpbb_modules_seq'), - module_enabled INT2 DEFAULT '1' NOT NULL CHECK (module_enabled >= 0), - module_display INT2 DEFAULT '1' NOT NULL CHECK (module_display >= 0), - module_basename varchar(255) DEFAULT '' NOT NULL, - module_class varchar(10) DEFAULT '' NOT NULL, - parent_id INT4 DEFAULT '0' NOT NULL CHECK (parent_id >= 0), - left_id INT4 DEFAULT '0' NOT NULL CHECK (left_id >= 0), - right_id INT4 DEFAULT '0' NOT NULL CHECK (right_id >= 0), - module_langname varchar(255) DEFAULT '' NOT NULL, - module_mode varchar(255) DEFAULT '' NOT NULL, - module_auth varchar(255) DEFAULT '' NOT NULL, - PRIMARY KEY (module_id) -); - -CREATE INDEX phpbb_modules_left_right_id ON phpbb_modules (left_id, right_id); -CREATE INDEX phpbb_modules_module_enabled ON phpbb_modules (module_enabled); -CREATE INDEX phpbb_modules_class_left_id ON phpbb_modules (module_class, left_id); - -/* - Table: 'phpbb_poll_options' -*/ -CREATE TABLE phpbb_poll_options ( - poll_option_id INT2 DEFAULT '0' NOT NULL, - topic_id INT4 DEFAULT '0' NOT NULL CHECK (topic_id >= 0), - poll_option_text varchar(4000) DEFAULT '' NOT NULL, - poll_option_total INT4 DEFAULT '0' NOT NULL CHECK (poll_option_total >= 0) -); - -CREATE INDEX phpbb_poll_options_poll_opt_id ON phpbb_poll_options (poll_option_id); -CREATE INDEX phpbb_poll_options_topic_id ON phpbb_poll_options (topic_id); - -/* - Table: 'phpbb_poll_votes' -*/ -CREATE TABLE phpbb_poll_votes ( - topic_id INT4 DEFAULT '0' NOT NULL CHECK (topic_id >= 0), - poll_option_id INT2 DEFAULT '0' NOT NULL, - vote_user_id INT4 DEFAULT '0' NOT NULL CHECK (vote_user_id >= 0), - vote_user_ip varchar(40) DEFAULT '' NOT NULL -); - -CREATE INDEX phpbb_poll_votes_topic_id ON phpbb_poll_votes (topic_id); -CREATE INDEX phpbb_poll_votes_vote_user_id ON phpbb_poll_votes (vote_user_id); -CREATE INDEX phpbb_poll_votes_vote_user_ip ON phpbb_poll_votes (vote_user_ip); - -/* - Table: 'phpbb_posts' -*/ -CREATE SEQUENCE phpbb_posts_seq; - -CREATE TABLE phpbb_posts ( - post_id INT4 DEFAULT nextval('phpbb_posts_seq'), - topic_id INT4 DEFAULT '0' NOT NULL CHECK (topic_id >= 0), - forum_id INT4 DEFAULT '0' NOT NULL CHECK (forum_id >= 0), - poster_id INT4 DEFAULT '0' NOT NULL CHECK (poster_id >= 0), - icon_id INT4 DEFAULT '0' NOT NULL CHECK (icon_id >= 0), - poster_ip varchar(40) DEFAULT '' NOT NULL, - post_time INT4 DEFAULT '0' NOT NULL CHECK (post_time >= 0), - post_approved INT2 DEFAULT '1' NOT NULL CHECK (post_approved >= 0), - post_reported INT2 DEFAULT '0' NOT NULL CHECK (post_reported >= 0), - enable_bbcode INT2 DEFAULT '1' NOT NULL CHECK (enable_bbcode >= 0), - enable_smilies INT2 DEFAULT '1' NOT NULL CHECK (enable_smilies >= 0), - enable_magic_url INT2 DEFAULT '1' NOT NULL CHECK (enable_magic_url >= 0), - enable_sig INT2 DEFAULT '1' NOT NULL CHECK (enable_sig >= 0), - post_username varchar(255) DEFAULT '' NOT NULL, - post_subject varchar(255) DEFAULT '' NOT NULL, - post_text TEXT DEFAULT '' NOT NULL, - post_checksum varchar(32) DEFAULT '' NOT NULL, - post_attachment INT2 DEFAULT '0' NOT NULL CHECK (post_attachment >= 0), - bbcode_bitfield varchar(255) DEFAULT '' NOT NULL, - bbcode_uid varchar(8) DEFAULT '' NOT NULL, - post_postcount INT2 DEFAULT '1' NOT NULL CHECK (post_postcount >= 0), - post_edit_time INT4 DEFAULT '0' NOT NULL CHECK (post_edit_time >= 0), - post_edit_reason varchar(255) DEFAULT '' NOT NULL, - post_edit_user INT4 DEFAULT '0' NOT NULL CHECK (post_edit_user >= 0), - post_edit_count INT2 DEFAULT '0' NOT NULL CHECK (post_edit_count >= 0), - post_edit_locked INT2 DEFAULT '0' NOT NULL CHECK (post_edit_locked >= 0), - PRIMARY KEY (post_id) -); - -CREATE INDEX phpbb_posts_forum_id ON phpbb_posts (forum_id); -CREATE INDEX phpbb_posts_topic_id ON phpbb_posts (topic_id); -CREATE INDEX phpbb_posts_poster_ip ON phpbb_posts (poster_ip); -CREATE INDEX phpbb_posts_poster_id ON phpbb_posts (poster_id); -CREATE INDEX phpbb_posts_post_approved ON phpbb_posts (post_approved); -CREATE INDEX phpbb_posts_post_username ON phpbb_posts (post_username); -CREATE INDEX phpbb_posts_tid_post_time ON phpbb_posts (topic_id, post_time); - -/* - Table: 'phpbb_privmsgs' -*/ -CREATE SEQUENCE phpbb_privmsgs_seq; - -CREATE TABLE phpbb_privmsgs ( - msg_id INT4 DEFAULT nextval('phpbb_privmsgs_seq'), - root_level INT4 DEFAULT '0' NOT NULL CHECK (root_level >= 0), - author_id INT4 DEFAULT '0' NOT NULL CHECK (author_id >= 0), - icon_id INT4 DEFAULT '0' NOT NULL CHECK (icon_id >= 0), - author_ip varchar(40) DEFAULT '' NOT NULL, - message_time INT4 DEFAULT '0' NOT NULL CHECK (message_time >= 0), - enable_bbcode INT2 DEFAULT '1' NOT NULL CHECK (enable_bbcode >= 0), - enable_smilies INT2 DEFAULT '1' NOT NULL CHECK (enable_smilies >= 0), - enable_magic_url INT2 DEFAULT '1' NOT NULL CHECK (enable_magic_url >= 0), - enable_sig INT2 DEFAULT '1' NOT NULL CHECK (enable_sig >= 0), - message_subject varchar(255) DEFAULT '' NOT NULL, - message_text TEXT DEFAULT '' NOT NULL, - message_edit_reason varchar(255) DEFAULT '' NOT NULL, - message_edit_user INT4 DEFAULT '0' NOT NULL CHECK (message_edit_user >= 0), - message_attachment INT2 DEFAULT '0' NOT NULL CHECK (message_attachment >= 0), - bbcode_bitfield varchar(255) DEFAULT '' NOT NULL, - bbcode_uid varchar(8) DEFAULT '' NOT NULL, - message_edit_time INT4 DEFAULT '0' NOT NULL CHECK (message_edit_time >= 0), - message_edit_count INT2 DEFAULT '0' NOT NULL CHECK (message_edit_count >= 0), - to_address varchar(4000) DEFAULT '' NOT NULL, - bcc_address varchar(4000) DEFAULT '' NOT NULL, - message_reported INT2 DEFAULT '0' NOT NULL CHECK (message_reported >= 0), - PRIMARY KEY (msg_id) -); - -CREATE INDEX phpbb_privmsgs_author_ip ON phpbb_privmsgs (author_ip); -CREATE INDEX phpbb_privmsgs_message_time ON phpbb_privmsgs (message_time); -CREATE INDEX phpbb_privmsgs_author_id ON phpbb_privmsgs (author_id); -CREATE INDEX phpbb_privmsgs_root_level ON phpbb_privmsgs (root_level); - -/* - Table: 'phpbb_privmsgs_folder' -*/ -CREATE SEQUENCE phpbb_privmsgs_folder_seq; - -CREATE TABLE phpbb_privmsgs_folder ( - folder_id INT4 DEFAULT nextval('phpbb_privmsgs_folder_seq'), - user_id INT4 DEFAULT '0' NOT NULL CHECK (user_id >= 0), - folder_name varchar(255) DEFAULT '' NOT NULL, - pm_count INT4 DEFAULT '0' NOT NULL CHECK (pm_count >= 0), - PRIMARY KEY (folder_id) -); - -CREATE INDEX phpbb_privmsgs_folder_user_id ON phpbb_privmsgs_folder (user_id); - -/* - Table: 'phpbb_privmsgs_rules' -*/ -CREATE SEQUENCE phpbb_privmsgs_rules_seq; - -CREATE TABLE phpbb_privmsgs_rules ( - rule_id INT4 DEFAULT nextval('phpbb_privmsgs_rules_seq'), - user_id INT4 DEFAULT '0' NOT NULL CHECK (user_id >= 0), - rule_check INT4 DEFAULT '0' NOT NULL CHECK (rule_check >= 0), - rule_connection INT4 DEFAULT '0' NOT NULL CHECK (rule_connection >= 0), - rule_string varchar(255) DEFAULT '' NOT NULL, - rule_user_id INT4 DEFAULT '0' NOT NULL CHECK (rule_user_id >= 0), - rule_group_id INT4 DEFAULT '0' NOT NULL CHECK (rule_group_id >= 0), - rule_action INT4 DEFAULT '0' NOT NULL CHECK (rule_action >= 0), - rule_folder_id INT4 DEFAULT '0' NOT NULL, - PRIMARY KEY (rule_id) -); - -CREATE INDEX phpbb_privmsgs_rules_user_id ON phpbb_privmsgs_rules (user_id); - -/* - Table: 'phpbb_privmsgs_to' -*/ -CREATE TABLE phpbb_privmsgs_to ( - msg_id INT4 DEFAULT '0' NOT NULL CHECK (msg_id >= 0), - user_id INT4 DEFAULT '0' NOT NULL CHECK (user_id >= 0), - author_id INT4 DEFAULT '0' NOT NULL CHECK (author_id >= 0), - pm_deleted INT2 DEFAULT '0' NOT NULL CHECK (pm_deleted >= 0), - pm_new INT2 DEFAULT '1' NOT NULL CHECK (pm_new >= 0), - pm_unread INT2 DEFAULT '1' NOT NULL CHECK (pm_unread >= 0), - pm_replied INT2 DEFAULT '0' NOT NULL CHECK (pm_replied >= 0), - pm_marked INT2 DEFAULT '0' NOT NULL CHECK (pm_marked >= 0), - pm_forwarded INT2 DEFAULT '0' NOT NULL CHECK (pm_forwarded >= 0), - folder_id INT4 DEFAULT '0' NOT NULL -); - -CREATE INDEX phpbb_privmsgs_to_msg_id ON phpbb_privmsgs_to (msg_id); -CREATE INDEX phpbb_privmsgs_to_author_id ON phpbb_privmsgs_to (author_id); -CREATE INDEX phpbb_privmsgs_to_usr_flder_id ON phpbb_privmsgs_to (user_id, folder_id); - -/* - Table: 'phpbb_profile_fields' -*/ -CREATE SEQUENCE phpbb_profile_fields_seq; - -CREATE TABLE phpbb_profile_fields ( - field_id INT4 DEFAULT nextval('phpbb_profile_fields_seq'), - field_name varchar(255) DEFAULT '' NOT NULL, - field_type INT2 DEFAULT '0' NOT NULL, - field_ident varchar(20) DEFAULT '' NOT NULL, - field_length varchar(20) DEFAULT '' NOT NULL, - field_minlen varchar(255) DEFAULT '' NOT NULL, - field_maxlen varchar(255) DEFAULT '' NOT NULL, - field_novalue varchar(255) DEFAULT '' NOT NULL, - field_default_value varchar(255) DEFAULT '' NOT NULL, - field_validation varchar(20) DEFAULT '' NOT NULL, - field_required INT2 DEFAULT '0' NOT NULL CHECK (field_required >= 0), - field_show_novalue INT2 DEFAULT '0' NOT NULL CHECK (field_show_novalue >= 0), - field_show_on_reg INT2 DEFAULT '0' NOT NULL CHECK (field_show_on_reg >= 0), - field_show_on_pm INT2 DEFAULT '0' NOT NULL CHECK (field_show_on_pm >= 0), - field_show_on_vt INT2 DEFAULT '0' NOT NULL CHECK (field_show_on_vt >= 0), - field_show_profile INT2 DEFAULT '0' NOT NULL CHECK (field_show_profile >= 0), - field_hide INT2 DEFAULT '0' NOT NULL CHECK (field_hide >= 0), - field_no_view INT2 DEFAULT '0' NOT NULL CHECK (field_no_view >= 0), - field_active INT2 DEFAULT '0' NOT NULL CHECK (field_active >= 0), - field_order INT4 DEFAULT '0' NOT NULL CHECK (field_order >= 0), - PRIMARY KEY (field_id) -); - -CREATE INDEX phpbb_profile_fields_fld_type ON phpbb_profile_fields (field_type); -CREATE INDEX phpbb_profile_fields_fld_ordr ON phpbb_profile_fields (field_order); - -/* - Table: 'phpbb_profile_fields_data' -*/ -CREATE TABLE phpbb_profile_fields_data ( - user_id INT4 DEFAULT '0' NOT NULL CHECK (user_id >= 0), - PRIMARY KEY (user_id) -); - - -/* - Table: 'phpbb_profile_fields_lang' -*/ -CREATE TABLE phpbb_profile_fields_lang ( - field_id INT4 DEFAULT '0' NOT NULL CHECK (field_id >= 0), - lang_id INT4 DEFAULT '0' NOT NULL CHECK (lang_id >= 0), - option_id INT4 DEFAULT '0' NOT NULL CHECK (option_id >= 0), - field_type INT2 DEFAULT '0' NOT NULL, - lang_value varchar(255) DEFAULT '' NOT NULL, - PRIMARY KEY (field_id, lang_id, option_id) -); - - -/* - Table: 'phpbb_profile_lang' -*/ -CREATE TABLE phpbb_profile_lang ( - field_id INT4 DEFAULT '0' NOT NULL CHECK (field_id >= 0), - lang_id INT4 DEFAULT '0' NOT NULL CHECK (lang_id >= 0), - lang_name varchar(255) DEFAULT '' NOT NULL, - lang_explain varchar(4000) DEFAULT '' NOT NULL, - lang_default_value varchar(255) DEFAULT '' NOT NULL, - PRIMARY KEY (field_id, lang_id) -); - - -/* - Table: 'phpbb_ranks' -*/ -CREATE SEQUENCE phpbb_ranks_seq; - -CREATE TABLE phpbb_ranks ( - rank_id INT4 DEFAULT nextval('phpbb_ranks_seq'), - rank_title varchar(255) DEFAULT '' NOT NULL, - rank_min INT4 DEFAULT '0' NOT NULL CHECK (rank_min >= 0), - rank_special INT2 DEFAULT '0' NOT NULL CHECK (rank_special >= 0), - rank_image varchar(255) DEFAULT '' NOT NULL, - PRIMARY KEY (rank_id) -); - - -/* - Table: 'phpbb_reports' -*/ -CREATE SEQUENCE phpbb_reports_seq; - -CREATE TABLE phpbb_reports ( - report_id INT4 DEFAULT nextval('phpbb_reports_seq'), - reason_id INT2 DEFAULT '0' NOT NULL CHECK (reason_id >= 0), - post_id INT4 DEFAULT '0' NOT NULL CHECK (post_id >= 0), - pm_id INT4 DEFAULT '0' NOT NULL CHECK (pm_id >= 0), - user_id INT4 DEFAULT '0' NOT NULL CHECK (user_id >= 0), - user_notify INT2 DEFAULT '0' NOT NULL CHECK (user_notify >= 0), - report_closed INT2 DEFAULT '0' NOT NULL CHECK (report_closed >= 0), - report_time INT4 DEFAULT '0' NOT NULL CHECK (report_time >= 0), - report_text TEXT DEFAULT '' NOT NULL, - reported_post_text TEXT DEFAULT '' NOT NULL, - PRIMARY KEY (report_id) -); - -CREATE INDEX phpbb_reports_post_id ON phpbb_reports (post_id); -CREATE INDEX phpbb_reports_pm_id ON phpbb_reports (pm_id); - -/* - Table: 'phpbb_reports_reasons' -*/ -CREATE SEQUENCE phpbb_reports_reasons_seq; - -CREATE TABLE phpbb_reports_reasons ( - reason_id INT2 DEFAULT nextval('phpbb_reports_reasons_seq'), - reason_title varchar(255) DEFAULT '' NOT NULL, - reason_description TEXT DEFAULT '' NOT NULL, - reason_order INT2 DEFAULT '0' NOT NULL CHECK (reason_order >= 0), - PRIMARY KEY (reason_id) -); - - -/* - Table: 'phpbb_search_results' -*/ -CREATE TABLE phpbb_search_results ( - search_key varchar(32) DEFAULT '' NOT NULL, - search_time INT4 DEFAULT '0' NOT NULL CHECK (search_time >= 0), - search_keywords TEXT DEFAULT '' NOT NULL, - search_authors TEXT DEFAULT '' NOT NULL, - PRIMARY KEY (search_key) -); - - -/* - Table: 'phpbb_search_wordlist' -*/ -CREATE SEQUENCE phpbb_search_wordlist_seq; - -CREATE TABLE phpbb_search_wordlist ( - word_id INT4 DEFAULT nextval('phpbb_search_wordlist_seq'), - word_text varchar(255) DEFAULT '' NOT NULL, - word_common INT2 DEFAULT '0' NOT NULL CHECK (word_common >= 0), - word_count INT4 DEFAULT '0' NOT NULL CHECK (word_count >= 0), - PRIMARY KEY (word_id) -); - -CREATE UNIQUE INDEX phpbb_search_wordlist_wrd_txt ON phpbb_search_wordlist (word_text); -CREATE INDEX phpbb_search_wordlist_wrd_cnt ON phpbb_search_wordlist (word_count); - -/* - Table: 'phpbb_search_wordmatch' -*/ -CREATE TABLE phpbb_search_wordmatch ( - post_id INT4 DEFAULT '0' NOT NULL CHECK (post_id >= 0), - word_id INT4 DEFAULT '0' NOT NULL CHECK (word_id >= 0), - title_match INT2 DEFAULT '0' NOT NULL CHECK (title_match >= 0) -); - -CREATE UNIQUE INDEX phpbb_search_wordmatch_unq_mtch ON phpbb_search_wordmatch (word_id, post_id, title_match); -CREATE INDEX phpbb_search_wordmatch_word_id ON phpbb_search_wordmatch (word_id); -CREATE INDEX phpbb_search_wordmatch_post_id ON phpbb_search_wordmatch (post_id); - -/* - Table: 'phpbb_sessions' -*/ -CREATE TABLE phpbb_sessions ( - session_id char(32) DEFAULT '' NOT NULL, - session_user_id INT4 DEFAULT '0' NOT NULL CHECK (session_user_id >= 0), - session_forum_id INT4 DEFAULT '0' NOT NULL CHECK (session_forum_id >= 0), - session_last_visit INT4 DEFAULT '0' NOT NULL CHECK (session_last_visit >= 0), - session_start INT4 DEFAULT '0' NOT NULL CHECK (session_start >= 0), - session_time INT4 DEFAULT '0' NOT NULL CHECK (session_time >= 0), - session_ip varchar(40) DEFAULT '' NOT NULL, - session_browser varchar(150) DEFAULT '' NOT NULL, - session_forwarded_for varchar(255) DEFAULT '' NOT NULL, - session_page varchar(255) DEFAULT '' NOT NULL, - session_viewonline INT2 DEFAULT '1' NOT NULL CHECK (session_viewonline >= 0), - session_autologin INT2 DEFAULT '0' NOT NULL CHECK (session_autologin >= 0), - session_admin INT2 DEFAULT '0' NOT NULL CHECK (session_admin >= 0), - PRIMARY KEY (session_id) -); - -CREATE INDEX phpbb_sessions_session_time ON phpbb_sessions (session_time); -CREATE INDEX phpbb_sessions_session_user_id ON phpbb_sessions (session_user_id); -CREATE INDEX phpbb_sessions_session_fid ON phpbb_sessions (session_forum_id); - -/* - Table: 'phpbb_sessions_keys' -*/ -CREATE TABLE phpbb_sessions_keys ( - key_id char(32) DEFAULT '' NOT NULL, - user_id INT4 DEFAULT '0' NOT NULL CHECK (user_id >= 0), - last_ip varchar(40) DEFAULT '' NOT NULL, - last_login INT4 DEFAULT '0' NOT NULL CHECK (last_login >= 0), - PRIMARY KEY (key_id, user_id) -); - -CREATE INDEX phpbb_sessions_keys_last_login ON phpbb_sessions_keys (last_login); - -/* - Table: 'phpbb_sitelist' -*/ -CREATE SEQUENCE phpbb_sitelist_seq; - -CREATE TABLE phpbb_sitelist ( - site_id INT4 DEFAULT nextval('phpbb_sitelist_seq'), - site_ip varchar(40) DEFAULT '' NOT NULL, - site_hostname varchar(255) DEFAULT '' NOT NULL, - ip_exclude INT2 DEFAULT '0' NOT NULL CHECK (ip_exclude >= 0), - PRIMARY KEY (site_id) -); - - -/* - Table: 'phpbb_smilies' -*/ -CREATE SEQUENCE phpbb_smilies_seq; - -CREATE TABLE phpbb_smilies ( - smiley_id INT4 DEFAULT nextval('phpbb_smilies_seq'), - code varchar(50) DEFAULT '' NOT NULL, - emotion varchar(50) DEFAULT '' NOT NULL, - smiley_url varchar(50) DEFAULT '' NOT NULL, - smiley_width INT2 DEFAULT '0' NOT NULL CHECK (smiley_width >= 0), - smiley_height INT2 DEFAULT '0' NOT NULL CHECK (smiley_height >= 0), - smiley_order INT4 DEFAULT '0' NOT NULL CHECK (smiley_order >= 0), - display_on_posting INT2 DEFAULT '1' NOT NULL CHECK (display_on_posting >= 0), - PRIMARY KEY (smiley_id) -); - -CREATE INDEX phpbb_smilies_display_on_post ON phpbb_smilies (display_on_posting); - -/* - Table: 'phpbb_styles' -*/ -CREATE SEQUENCE phpbb_styles_seq; - -CREATE TABLE phpbb_styles ( - style_id INT4 DEFAULT nextval('phpbb_styles_seq'), - style_name varchar(255) DEFAULT '' NOT NULL, - style_copyright varchar(255) DEFAULT '' NOT NULL, - style_active INT2 DEFAULT '1' NOT NULL CHECK (style_active >= 0), - style_path varchar(100) DEFAULT '' NOT NULL, - bbcode_bitfield varchar(255) DEFAULT 'kNg=' NOT NULL, - style_parent_id INT4 DEFAULT '0' NOT NULL CHECK (style_parent_id >= 0), - style_parent_tree varchar(8000) DEFAULT '' NOT NULL, - PRIMARY KEY (style_id) -); - -CREATE UNIQUE INDEX phpbb_styles_style_name ON phpbb_styles (style_name); - -/* - Table: 'phpbb_topics' -*/ -CREATE SEQUENCE phpbb_topics_seq; - -CREATE TABLE phpbb_topics ( - topic_id INT4 DEFAULT nextval('phpbb_topics_seq'), - forum_id INT4 DEFAULT '0' NOT NULL CHECK (forum_id >= 0), - icon_id INT4 DEFAULT '0' NOT NULL CHECK (icon_id >= 0), - topic_attachment INT2 DEFAULT '0' NOT NULL CHECK (topic_attachment >= 0), - topic_approved INT2 DEFAULT '1' NOT NULL CHECK (topic_approved >= 0), - topic_reported INT2 DEFAULT '0' NOT NULL CHECK (topic_reported >= 0), - topic_title varchar(255) DEFAULT '' NOT NULL, - topic_poster INT4 DEFAULT '0' NOT NULL CHECK (topic_poster >= 0), - topic_time INT4 DEFAULT '0' NOT NULL CHECK (topic_time >= 0), - topic_time_limit INT4 DEFAULT '0' NOT NULL CHECK (topic_time_limit >= 0), - topic_views INT4 DEFAULT '0' NOT NULL CHECK (topic_views >= 0), - topic_replies INT4 DEFAULT '0' NOT NULL CHECK (topic_replies >= 0), - topic_replies_real INT4 DEFAULT '0' NOT NULL CHECK (topic_replies_real >= 0), - topic_status INT2 DEFAULT '0' NOT NULL, - topic_type INT2 DEFAULT '0' NOT NULL, - topic_first_post_id INT4 DEFAULT '0' NOT NULL CHECK (topic_first_post_id >= 0), - topic_first_poster_name varchar(255) DEFAULT '' NOT NULL, - topic_first_poster_colour varchar(6) DEFAULT '' NOT NULL, - topic_last_post_id INT4 DEFAULT '0' NOT NULL CHECK (topic_last_post_id >= 0), - topic_last_poster_id INT4 DEFAULT '0' NOT NULL CHECK (topic_last_poster_id >= 0), - topic_last_poster_name varchar(255) DEFAULT '' NOT NULL, - topic_last_poster_colour varchar(6) DEFAULT '' NOT NULL, - topic_last_post_subject varchar(255) DEFAULT '' NOT NULL, - topic_last_post_time INT4 DEFAULT '0' NOT NULL CHECK (topic_last_post_time >= 0), - topic_last_view_time INT4 DEFAULT '0' NOT NULL CHECK (topic_last_view_time >= 0), - topic_moved_id INT4 DEFAULT '0' NOT NULL CHECK (topic_moved_id >= 0), - topic_bumped INT2 DEFAULT '0' NOT NULL CHECK (topic_bumped >= 0), - topic_bumper INT4 DEFAULT '0' NOT NULL CHECK (topic_bumper >= 0), - poll_title varchar(255) DEFAULT '' NOT NULL, - poll_start INT4 DEFAULT '0' NOT NULL CHECK (poll_start >= 0), - poll_length INT4 DEFAULT '0' NOT NULL CHECK (poll_length >= 0), - poll_max_options INT2 DEFAULT '1' NOT NULL, - poll_last_vote INT4 DEFAULT '0' NOT NULL CHECK (poll_last_vote >= 0), - poll_vote_change INT2 DEFAULT '0' NOT NULL CHECK (poll_vote_change >= 0), - PRIMARY KEY (topic_id) -); - -CREATE INDEX phpbb_topics_forum_id ON phpbb_topics (forum_id); -CREATE INDEX phpbb_topics_forum_id_type ON phpbb_topics (forum_id, topic_type); -CREATE INDEX phpbb_topics_last_post_time ON phpbb_topics (topic_last_post_time); -CREATE INDEX phpbb_topics_topic_approved ON phpbb_topics (topic_approved); -CREATE INDEX phpbb_topics_forum_appr_last ON phpbb_topics (forum_id, topic_approved, topic_last_post_id); -CREATE INDEX phpbb_topics_fid_time_moved ON phpbb_topics (forum_id, topic_last_post_time, topic_moved_id); - -/* - Table: 'phpbb_topics_track' -*/ -CREATE TABLE phpbb_topics_track ( - user_id INT4 DEFAULT '0' NOT NULL CHECK (user_id >= 0), - topic_id INT4 DEFAULT '0' NOT NULL CHECK (topic_id >= 0), - forum_id INT4 DEFAULT '0' NOT NULL CHECK (forum_id >= 0), - mark_time INT4 DEFAULT '0' NOT NULL CHECK (mark_time >= 0), - PRIMARY KEY (user_id, topic_id) -); - -CREATE INDEX phpbb_topics_track_topic_id ON phpbb_topics_track (topic_id); -CREATE INDEX phpbb_topics_track_forum_id ON phpbb_topics_track (forum_id); - -/* - Table: 'phpbb_topics_posted' -*/ -CREATE TABLE phpbb_topics_posted ( - user_id INT4 DEFAULT '0' NOT NULL CHECK (user_id >= 0), - topic_id INT4 DEFAULT '0' NOT NULL CHECK (topic_id >= 0), - topic_posted INT2 DEFAULT '0' NOT NULL CHECK (topic_posted >= 0), - PRIMARY KEY (user_id, topic_id) -); - - -/* - Table: 'phpbb_topics_watch' -*/ -CREATE TABLE phpbb_topics_watch ( - topic_id INT4 DEFAULT '0' NOT NULL CHECK (topic_id >= 0), - user_id INT4 DEFAULT '0' NOT NULL CHECK (user_id >= 0), - notify_status INT2 DEFAULT '0' NOT NULL CHECK (notify_status >= 0) -); - -CREATE INDEX phpbb_topics_watch_topic_id ON phpbb_topics_watch (topic_id); -CREATE INDEX phpbb_topics_watch_user_id ON phpbb_topics_watch (user_id); -CREATE INDEX phpbb_topics_watch_notify_stat ON phpbb_topics_watch (notify_status); - -/* - Table: 'phpbb_user_group' -*/ -CREATE TABLE phpbb_user_group ( - group_id INT4 DEFAULT '0' NOT NULL CHECK (group_id >= 0), - user_id INT4 DEFAULT '0' NOT NULL CHECK (user_id >= 0), - group_leader INT2 DEFAULT '0' NOT NULL CHECK (group_leader >= 0), - user_pending INT2 DEFAULT '1' NOT NULL CHECK (user_pending >= 0) -); - -CREATE INDEX phpbb_user_group_group_id ON phpbb_user_group (group_id); -CREATE INDEX phpbb_user_group_user_id ON phpbb_user_group (user_id); -CREATE INDEX phpbb_user_group_group_leader ON phpbb_user_group (group_leader); - -/* - Table: 'phpbb_users' -*/ -CREATE SEQUENCE phpbb_users_seq; - -CREATE TABLE phpbb_users ( - user_id INT4 DEFAULT nextval('phpbb_users_seq'), - user_type INT2 DEFAULT '0' NOT NULL, - group_id INT4 DEFAULT '3' NOT NULL CHECK (group_id >= 0), - user_permissions TEXT DEFAULT '' NOT NULL, - user_perm_from INT4 DEFAULT '0' NOT NULL CHECK (user_perm_from >= 0), - user_ip varchar(40) DEFAULT '' NOT NULL, - user_regdate INT4 DEFAULT '0' NOT NULL CHECK (user_regdate >= 0), - username varchar_ci DEFAULT '' NOT NULL, - username_clean varchar_ci DEFAULT '' NOT NULL, - user_password varchar(40) DEFAULT '' NOT NULL, - user_passchg INT4 DEFAULT '0' NOT NULL CHECK (user_passchg >= 0), - user_pass_convert INT2 DEFAULT '0' NOT NULL CHECK (user_pass_convert >= 0), - user_email varchar(100) DEFAULT '' NOT NULL, - user_email_hash INT8 DEFAULT '0' NOT NULL, - user_birthday varchar(10) DEFAULT '' NOT NULL, - user_lastvisit INT4 DEFAULT '0' NOT NULL CHECK (user_lastvisit >= 0), - user_lastmark INT4 DEFAULT '0' NOT NULL CHECK (user_lastmark >= 0), - user_lastpost_time INT4 DEFAULT '0' NOT NULL CHECK (user_lastpost_time >= 0), - user_lastpage varchar(200) DEFAULT '' NOT NULL, - user_last_confirm_key varchar(10) DEFAULT '' NOT NULL, - user_last_search INT4 DEFAULT '0' NOT NULL CHECK (user_last_search >= 0), - user_warnings INT2 DEFAULT '0' NOT NULL, - user_last_warning INT4 DEFAULT '0' NOT NULL CHECK (user_last_warning >= 0), - user_login_attempts INT2 DEFAULT '0' NOT NULL, - user_inactive_reason INT2 DEFAULT '0' NOT NULL, - user_inactive_time INT4 DEFAULT '0' NOT NULL CHECK (user_inactive_time >= 0), - user_posts INT4 DEFAULT '0' NOT NULL CHECK (user_posts >= 0), - user_lang varchar(30) DEFAULT '' NOT NULL, - user_timezone varchar(100) DEFAULT 'UTC' NOT NULL, - user_dateformat varchar(30) DEFAULT 'd M Y H:i' NOT NULL, - user_style INT4 DEFAULT '0' NOT NULL CHECK (user_style >= 0), - user_rank INT4 DEFAULT '0' NOT NULL CHECK (user_rank >= 0), - user_colour varchar(6) DEFAULT '' NOT NULL, - user_new_privmsg INT4 DEFAULT '0' NOT NULL, - user_unread_privmsg INT4 DEFAULT '0' NOT NULL, - user_last_privmsg INT4 DEFAULT '0' NOT NULL CHECK (user_last_privmsg >= 0), - user_message_rules INT2 DEFAULT '0' NOT NULL CHECK (user_message_rules >= 0), - user_full_folder INT4 DEFAULT '-3' NOT NULL, - user_emailtime INT4 DEFAULT '0' NOT NULL CHECK (user_emailtime >= 0), - user_topic_show_days INT2 DEFAULT '0' NOT NULL CHECK (user_topic_show_days >= 0), - user_topic_sortby_type varchar(1) DEFAULT 't' NOT NULL, - user_topic_sortby_dir varchar(1) DEFAULT 'd' NOT NULL, - user_post_show_days INT2 DEFAULT '0' NOT NULL CHECK (user_post_show_days >= 0), - user_post_sortby_type varchar(1) DEFAULT 't' NOT NULL, - user_post_sortby_dir varchar(1) DEFAULT 'a' NOT NULL, - user_notify INT2 DEFAULT '0' NOT NULL CHECK (user_notify >= 0), - user_notify_pm INT2 DEFAULT '1' NOT NULL CHECK (user_notify_pm >= 0), - user_notify_type INT2 DEFAULT '0' NOT NULL, - user_allow_pm INT2 DEFAULT '1' NOT NULL CHECK (user_allow_pm >= 0), - user_allow_viewonline INT2 DEFAULT '1' NOT NULL CHECK (user_allow_viewonline >= 0), - user_allow_viewemail INT2 DEFAULT '1' NOT NULL CHECK (user_allow_viewemail >= 0), - user_allow_massemail INT2 DEFAULT '1' NOT NULL CHECK (user_allow_massemail >= 0), - user_options INT4 DEFAULT '230271' NOT NULL CHECK (user_options >= 0), - user_avatar varchar(255) DEFAULT '' NOT NULL, - user_avatar_type INT2 DEFAULT '0' NOT NULL, - user_avatar_width INT2 DEFAULT '0' NOT NULL CHECK (user_avatar_width >= 0), - user_avatar_height INT2 DEFAULT '0' NOT NULL CHECK (user_avatar_height >= 0), - user_sig TEXT DEFAULT '' NOT NULL, - user_sig_bbcode_uid varchar(8) DEFAULT '' NOT NULL, - user_sig_bbcode_bitfield varchar(255) DEFAULT '' NOT NULL, - user_from varchar(100) DEFAULT '' NOT NULL, - user_icq varchar(15) DEFAULT '' NOT NULL, - user_aim varchar(255) DEFAULT '' NOT NULL, - user_yim varchar(255) DEFAULT '' NOT NULL, - user_msnm varchar(255) DEFAULT '' NOT NULL, - user_jabber varchar(255) DEFAULT '' NOT NULL, - user_website varchar(200) DEFAULT '' NOT NULL, - user_occ varchar(4000) DEFAULT '' NOT NULL, - user_interests varchar(4000) DEFAULT '' NOT NULL, - user_actkey varchar(32) DEFAULT '' NOT NULL, - user_newpasswd varchar(40) DEFAULT '' NOT NULL, - user_form_salt varchar(32) DEFAULT '' NOT NULL, - user_new INT2 DEFAULT '1' NOT NULL CHECK (user_new >= 0), - user_reminded INT2 DEFAULT '0' NOT NULL, - user_reminded_time INT4 DEFAULT '0' NOT NULL CHECK (user_reminded_time >= 0), - PRIMARY KEY (user_id) -); - -CREATE INDEX phpbb_users_user_birthday ON phpbb_users (user_birthday); -CREATE INDEX phpbb_users_user_email_hash ON phpbb_users (user_email_hash); -CREATE INDEX phpbb_users_user_type ON phpbb_users (user_type); -CREATE UNIQUE INDEX phpbb_users_username_clean ON phpbb_users (username_clean); - -/* - Table: 'phpbb_warnings' -*/ -CREATE SEQUENCE phpbb_warnings_seq; - -CREATE TABLE phpbb_warnings ( - warning_id INT4 DEFAULT nextval('phpbb_warnings_seq'), - user_id INT4 DEFAULT '0' NOT NULL CHECK (user_id >= 0), - post_id INT4 DEFAULT '0' NOT NULL CHECK (post_id >= 0), - log_id INT4 DEFAULT '0' NOT NULL CHECK (log_id >= 0), - warning_time INT4 DEFAULT '0' NOT NULL CHECK (warning_time >= 0), - PRIMARY KEY (warning_id) -); - - -/* - Table: 'phpbb_words' -*/ -CREATE SEQUENCE phpbb_words_seq; - -CREATE TABLE phpbb_words ( - word_id INT4 DEFAULT nextval('phpbb_words_seq'), - word varchar(255) DEFAULT '' NOT NULL, - replacement varchar(255) DEFAULT '' NOT NULL, - PRIMARY KEY (word_id) -); - - -/* - Table: 'phpbb_zebra' -*/ -CREATE TABLE phpbb_zebra ( - user_id INT4 DEFAULT '0' NOT NULL CHECK (user_id >= 0), - zebra_id INT4 DEFAULT '0' NOT NULL CHECK (zebra_id >= 0), - friend INT2 DEFAULT '0' NOT NULL CHECK (friend >= 0), - foe INT2 DEFAULT '0' NOT NULL CHECK (foe >= 0), - PRIMARY KEY (user_id, zebra_id) -); - - - -COMMIT; \ No newline at end of file +/* + * DO NOT EDIT THIS FILE, IT IS GENERATED + * + * To change the contents of this file, edit + * phpBB/develop/create_schema_files.php and + * run it. + */ + +BEGIN; + +/* + Domain definition +*/ +CREATE DOMAIN varchar_ci AS varchar(255) NOT NULL DEFAULT ''::character varying; + +/* + Operation Functions +*/ +CREATE FUNCTION _varchar_ci_equal(varchar_ci, varchar_ci) RETURNS boolean AS 'SELECT LOWER($1) = LOWER($2)' LANGUAGE SQL STRICT; +CREATE FUNCTION _varchar_ci_not_equal(varchar_ci, varchar_ci) RETURNS boolean AS 'SELECT LOWER($1) != LOWER($2)' LANGUAGE SQL STRICT; +CREATE FUNCTION _varchar_ci_less_than(varchar_ci, varchar_ci) RETURNS boolean AS 'SELECT LOWER($1) < LOWER($2)' LANGUAGE SQL STRICT; +CREATE FUNCTION _varchar_ci_less_equal(varchar_ci, varchar_ci) RETURNS boolean AS 'SELECT LOWER($1) <= LOWER($2)' LANGUAGE SQL STRICT; +CREATE FUNCTION _varchar_ci_greater_than(varchar_ci, varchar_ci) RETURNS boolean AS 'SELECT LOWER($1) > LOWER($2)' LANGUAGE SQL STRICT; +CREATE FUNCTION _varchar_ci_greater_equals(varchar_ci, varchar_ci) RETURNS boolean AS 'SELECT LOWER($1) >= LOWER($2)' LANGUAGE SQL STRICT; + +/* + Operators +*/ +CREATE OPERATOR <( + PROCEDURE = _varchar_ci_less_than, + LEFTARG = varchar_ci, + RIGHTARG = varchar_ci, + COMMUTATOR = >, + NEGATOR = >=, + RESTRICT = scalarltsel, + JOIN = scalarltjoinsel); + +CREATE OPERATOR <=( + PROCEDURE = _varchar_ci_less_equal, + LEFTARG = varchar_ci, + RIGHTARG = varchar_ci, + COMMUTATOR = >=, + NEGATOR = >, + RESTRICT = scalarltsel, + JOIN = scalarltjoinsel); + +CREATE OPERATOR >( + PROCEDURE = _varchar_ci_greater_than, + LEFTARG = varchar_ci, + RIGHTARG = varchar_ci, + COMMUTATOR = <, + NEGATOR = <=, + RESTRICT = scalargtsel, + JOIN = scalargtjoinsel); + +CREATE OPERATOR >=( + PROCEDURE = _varchar_ci_greater_equals, + LEFTARG = varchar_ci, + RIGHTARG = varchar_ci, + COMMUTATOR = <=, + NEGATOR = <, + RESTRICT = scalargtsel, + JOIN = scalargtjoinsel); + +CREATE OPERATOR <>( + PROCEDURE = _varchar_ci_not_equal, + LEFTARG = varchar_ci, + RIGHTARG = varchar_ci, + COMMUTATOR = <>, + NEGATOR = =, + RESTRICT = neqsel, + JOIN = neqjoinsel); + +CREATE OPERATOR =( + PROCEDURE = _varchar_ci_equal, + LEFTARG = varchar_ci, + RIGHTARG = varchar_ci, + COMMUTATOR = =, + NEGATOR = <>, + RESTRICT = eqsel, + JOIN = eqjoinsel, + HASHES, + MERGES, + SORT1= <); + +/* + Table: 'phpbb_attachments' +*/ +CREATE SEQUENCE phpbb_attachments_seq; + +CREATE TABLE phpbb_attachments ( + attach_id INT4 DEFAULT nextval('phpbb_attachments_seq'), + post_msg_id INT4 DEFAULT '0' NOT NULL CHECK (post_msg_id >= 0), + topic_id INT4 DEFAULT '0' NOT NULL CHECK (topic_id >= 0), + in_message INT2 DEFAULT '0' NOT NULL CHECK (in_message >= 0), + poster_id INT4 DEFAULT '0' NOT NULL CHECK (poster_id >= 0), + is_orphan INT2 DEFAULT '1' NOT NULL CHECK (is_orphan >= 0), + physical_filename varchar(255) DEFAULT '' NOT NULL, + real_filename varchar(255) DEFAULT '' NOT NULL, + download_count INT4 DEFAULT '0' NOT NULL CHECK (download_count >= 0), + attach_comment varchar(4000) DEFAULT '' NOT NULL, + extension varchar(100) DEFAULT '' NOT NULL, + mimetype varchar(100) DEFAULT '' NOT NULL, + filesize INT4 DEFAULT '0' NOT NULL CHECK (filesize >= 0), + filetime INT4 DEFAULT '0' NOT NULL CHECK (filetime >= 0), + thumbnail INT2 DEFAULT '0' NOT NULL CHECK (thumbnail >= 0), + PRIMARY KEY (attach_id) +); + +CREATE INDEX phpbb_attachments_filetime ON phpbb_attachments (filetime); +CREATE INDEX phpbb_attachments_post_msg_id ON phpbb_attachments (post_msg_id); +CREATE INDEX phpbb_attachments_topic_id ON phpbb_attachments (topic_id); +CREATE INDEX phpbb_attachments_poster_id ON phpbb_attachments (poster_id); +CREATE INDEX phpbb_attachments_is_orphan ON phpbb_attachments (is_orphan); + +/* + Table: 'phpbb_acl_groups' +*/ +CREATE TABLE phpbb_acl_groups ( + group_id INT4 DEFAULT '0' NOT NULL CHECK (group_id >= 0), + forum_id INT4 DEFAULT '0' NOT NULL CHECK (forum_id >= 0), + auth_option_id INT4 DEFAULT '0' NOT NULL CHECK (auth_option_id >= 0), + auth_role_id INT4 DEFAULT '0' NOT NULL CHECK (auth_role_id >= 0), + auth_setting INT2 DEFAULT '0' NOT NULL +); + +CREATE INDEX phpbb_acl_groups_group_id ON phpbb_acl_groups (group_id); +CREATE INDEX phpbb_acl_groups_auth_opt_id ON phpbb_acl_groups (auth_option_id); +CREATE INDEX phpbb_acl_groups_auth_role_id ON phpbb_acl_groups (auth_role_id); + +/* + Table: 'phpbb_acl_options' +*/ +CREATE SEQUENCE phpbb_acl_options_seq; + +CREATE TABLE phpbb_acl_options ( + auth_option_id INT4 DEFAULT nextval('phpbb_acl_options_seq'), + auth_option varchar(50) DEFAULT '' NOT NULL, + is_global INT2 DEFAULT '0' NOT NULL CHECK (is_global >= 0), + is_local INT2 DEFAULT '0' NOT NULL CHECK (is_local >= 0), + founder_only INT2 DEFAULT '0' NOT NULL CHECK (founder_only >= 0), + PRIMARY KEY (auth_option_id) +); + +CREATE UNIQUE INDEX phpbb_acl_options_auth_option ON phpbb_acl_options (auth_option); + +/* + Table: 'phpbb_acl_roles' +*/ +CREATE SEQUENCE phpbb_acl_roles_seq; + +CREATE TABLE phpbb_acl_roles ( + role_id INT4 DEFAULT nextval('phpbb_acl_roles_seq'), + role_name varchar(255) DEFAULT '' NOT NULL, + role_description varchar(4000) DEFAULT '' NOT NULL, + role_type varchar(10) DEFAULT '' NOT NULL, + role_order INT2 DEFAULT '0' NOT NULL CHECK (role_order >= 0), + PRIMARY KEY (role_id) +); + +CREATE INDEX phpbb_acl_roles_role_type ON phpbb_acl_roles (role_type); +CREATE INDEX phpbb_acl_roles_role_order ON phpbb_acl_roles (role_order); + +/* + Table: 'phpbb_acl_roles_data' +*/ +CREATE TABLE phpbb_acl_roles_data ( + role_id INT4 DEFAULT '0' NOT NULL CHECK (role_id >= 0), + auth_option_id INT4 DEFAULT '0' NOT NULL CHECK (auth_option_id >= 0), + auth_setting INT2 DEFAULT '0' NOT NULL, + PRIMARY KEY (role_id, auth_option_id) +); + +CREATE INDEX phpbb_acl_roles_data_ath_op_id ON phpbb_acl_roles_data (auth_option_id); + +/* + Table: 'phpbb_acl_users' +*/ +CREATE TABLE phpbb_acl_users ( + user_id INT4 DEFAULT '0' NOT NULL CHECK (user_id >= 0), + forum_id INT4 DEFAULT '0' NOT NULL CHECK (forum_id >= 0), + auth_option_id INT4 DEFAULT '0' NOT NULL CHECK (auth_option_id >= 0), + auth_role_id INT4 DEFAULT '0' NOT NULL CHECK (auth_role_id >= 0), + auth_setting INT2 DEFAULT '0' NOT NULL +); + +CREATE INDEX phpbb_acl_users_user_id ON phpbb_acl_users (user_id); +CREATE INDEX phpbb_acl_users_auth_option_id ON phpbb_acl_users (auth_option_id); +CREATE INDEX phpbb_acl_users_auth_role_id ON phpbb_acl_users (auth_role_id); + +/* + Table: 'phpbb_banlist' +*/ +CREATE SEQUENCE phpbb_banlist_seq; + +CREATE TABLE phpbb_banlist ( + ban_id INT4 DEFAULT nextval('phpbb_banlist_seq'), + ban_userid INT4 DEFAULT '0' NOT NULL CHECK (ban_userid >= 0), + ban_ip varchar(40) DEFAULT '' NOT NULL, + ban_email varchar(100) DEFAULT '' NOT NULL, + ban_start INT4 DEFAULT '0' NOT NULL CHECK (ban_start >= 0), + ban_end INT4 DEFAULT '0' NOT NULL CHECK (ban_end >= 0), + ban_exclude INT2 DEFAULT '0' NOT NULL CHECK (ban_exclude >= 0), + ban_reason varchar(255) DEFAULT '' NOT NULL, + ban_give_reason varchar(255) DEFAULT '' NOT NULL, + PRIMARY KEY (ban_id) +); + +CREATE INDEX phpbb_banlist_ban_end ON phpbb_banlist (ban_end); +CREATE INDEX phpbb_banlist_ban_user ON phpbb_banlist (ban_userid, ban_exclude); +CREATE INDEX phpbb_banlist_ban_email ON phpbb_banlist (ban_email, ban_exclude); +CREATE INDEX phpbb_banlist_ban_ip ON phpbb_banlist (ban_ip, ban_exclude); + +/* + Table: 'phpbb_bbcodes' +*/ +CREATE TABLE phpbb_bbcodes ( + bbcode_id INT2 DEFAULT '0' NOT NULL CHECK (bbcode_id >= 0), + bbcode_tag varchar(16) DEFAULT '' NOT NULL, + bbcode_helpline varchar(255) DEFAULT '' NOT NULL, + display_on_posting INT2 DEFAULT '0' NOT NULL CHECK (display_on_posting >= 0), + bbcode_match varchar(4000) DEFAULT '' NOT NULL, + bbcode_tpl TEXT DEFAULT '' NOT NULL, + first_pass_match TEXT DEFAULT '' NOT NULL, + first_pass_replace TEXT DEFAULT '' NOT NULL, + second_pass_match TEXT DEFAULT '' NOT NULL, + second_pass_replace TEXT DEFAULT '' NOT NULL, + PRIMARY KEY (bbcode_id) +); + +CREATE INDEX phpbb_bbcodes_display_on_post ON phpbb_bbcodes (display_on_posting); + +/* + Table: 'phpbb_bookmarks' +*/ +CREATE TABLE phpbb_bookmarks ( + topic_id INT4 DEFAULT '0' NOT NULL CHECK (topic_id >= 0), + user_id INT4 DEFAULT '0' NOT NULL CHECK (user_id >= 0), + PRIMARY KEY (topic_id, user_id) +); + + +/* + Table: 'phpbb_bots' +*/ +CREATE SEQUENCE phpbb_bots_seq; + +CREATE TABLE phpbb_bots ( + bot_id INT4 DEFAULT nextval('phpbb_bots_seq'), + bot_active INT2 DEFAULT '1' NOT NULL CHECK (bot_active >= 0), + bot_name varchar(255) DEFAULT '' NOT NULL, + user_id INT4 DEFAULT '0' NOT NULL CHECK (user_id >= 0), + bot_agent varchar(255) DEFAULT '' NOT NULL, + bot_ip varchar(255) DEFAULT '' NOT NULL, + PRIMARY KEY (bot_id) +); + +CREATE INDEX phpbb_bots_bot_active ON phpbb_bots (bot_active); + +/* + Table: 'phpbb_config' +*/ +CREATE TABLE phpbb_config ( + config_name varchar(255) DEFAULT '' NOT NULL, + config_value varchar(255) DEFAULT '' NOT NULL, + is_dynamic INT2 DEFAULT '0' NOT NULL CHECK (is_dynamic >= 0), + PRIMARY KEY (config_name) +); + +CREATE INDEX phpbb_config_is_dynamic ON phpbb_config (is_dynamic); + +/* + Table: 'phpbb_confirm' +*/ +CREATE TABLE phpbb_confirm ( + confirm_id char(32) DEFAULT '' NOT NULL, + session_id char(32) DEFAULT '' NOT NULL, + confirm_type INT2 DEFAULT '0' NOT NULL, + code varchar(8) DEFAULT '' NOT NULL, + seed INT4 DEFAULT '0' NOT NULL CHECK (seed >= 0), + attempts INT4 DEFAULT '0' NOT NULL CHECK (attempts >= 0), + PRIMARY KEY (session_id, confirm_id) +); + +CREATE INDEX phpbb_confirm_confirm_type ON phpbb_confirm (confirm_type); + +/* + Table: 'phpbb_disallow' +*/ +CREATE SEQUENCE phpbb_disallow_seq; + +CREATE TABLE phpbb_disallow ( + disallow_id INT4 DEFAULT nextval('phpbb_disallow_seq'), + disallow_username varchar(255) DEFAULT '' NOT NULL, + PRIMARY KEY (disallow_id) +); + + +/* + Table: 'phpbb_drafts' +*/ +CREATE SEQUENCE phpbb_drafts_seq; + +CREATE TABLE phpbb_drafts ( + draft_id INT4 DEFAULT nextval('phpbb_drafts_seq'), + user_id INT4 DEFAULT '0' NOT NULL CHECK (user_id >= 0), + topic_id INT4 DEFAULT '0' NOT NULL CHECK (topic_id >= 0), + forum_id INT4 DEFAULT '0' NOT NULL CHECK (forum_id >= 0), + save_time INT4 DEFAULT '0' NOT NULL CHECK (save_time >= 0), + draft_subject varchar(255) DEFAULT '' NOT NULL, + draft_message TEXT DEFAULT '' NOT NULL, + PRIMARY KEY (draft_id) +); + +CREATE INDEX phpbb_drafts_save_time ON phpbb_drafts (save_time); + +/* + Table: 'phpbb_ext' +*/ +CREATE TABLE phpbb_ext ( + ext_name varchar(255) DEFAULT '' NOT NULL, + ext_active INT2 DEFAULT '0' NOT NULL CHECK (ext_active >= 0), + ext_state varchar(8000) DEFAULT '' NOT NULL +); + +CREATE UNIQUE INDEX phpbb_ext_ext_name ON phpbb_ext (ext_name); + +/* + Table: 'phpbb_extensions' +*/ +CREATE SEQUENCE phpbb_extensions_seq; + +CREATE TABLE phpbb_extensions ( + extension_id INT4 DEFAULT nextval('phpbb_extensions_seq'), + group_id INT4 DEFAULT '0' NOT NULL CHECK (group_id >= 0), + extension varchar(100) DEFAULT '' NOT NULL, + PRIMARY KEY (extension_id) +); + + +/* + Table: 'phpbb_extension_groups' +*/ +CREATE SEQUENCE phpbb_extension_groups_seq; + +CREATE TABLE phpbb_extension_groups ( + group_id INT4 DEFAULT nextval('phpbb_extension_groups_seq'), + group_name varchar(255) DEFAULT '' NOT NULL, + cat_id INT2 DEFAULT '0' NOT NULL, + allow_group INT2 DEFAULT '0' NOT NULL CHECK (allow_group >= 0), + download_mode INT2 DEFAULT '1' NOT NULL CHECK (download_mode >= 0), + upload_icon varchar(255) DEFAULT '' NOT NULL, + max_filesize INT4 DEFAULT '0' NOT NULL CHECK (max_filesize >= 0), + allowed_forums varchar(8000) DEFAULT '' NOT NULL, + allow_in_pm INT2 DEFAULT '0' NOT NULL CHECK (allow_in_pm >= 0), + PRIMARY KEY (group_id) +); + + +/* + Table: 'phpbb_forums' +*/ +CREATE SEQUENCE phpbb_forums_seq; + +CREATE TABLE phpbb_forums ( + forum_id INT4 DEFAULT nextval('phpbb_forums_seq'), + parent_id INT4 DEFAULT '0' NOT NULL CHECK (parent_id >= 0), + left_id INT4 DEFAULT '0' NOT NULL CHECK (left_id >= 0), + right_id INT4 DEFAULT '0' NOT NULL CHECK (right_id >= 0), + forum_parents TEXT DEFAULT '' NOT NULL, + forum_name varchar(255) DEFAULT '' NOT NULL, + forum_desc varchar(4000) DEFAULT '' NOT NULL, + forum_desc_bitfield varchar(255) DEFAULT '' NOT NULL, + forum_desc_options INT4 DEFAULT '7' NOT NULL CHECK (forum_desc_options >= 0), + forum_desc_uid varchar(8) DEFAULT '' NOT NULL, + forum_link varchar(255) DEFAULT '' NOT NULL, + forum_password varchar(40) DEFAULT '' NOT NULL, + forum_style INT4 DEFAULT '0' NOT NULL CHECK (forum_style >= 0), + forum_image varchar(255) DEFAULT '' NOT NULL, + forum_rules varchar(4000) DEFAULT '' NOT NULL, + forum_rules_link varchar(255) DEFAULT '' NOT NULL, + forum_rules_bitfield varchar(255) DEFAULT '' NOT NULL, + forum_rules_options INT4 DEFAULT '7' NOT NULL CHECK (forum_rules_options >= 0), + forum_rules_uid varchar(8) DEFAULT '' NOT NULL, + forum_topics_per_page INT2 DEFAULT '0' NOT NULL, + forum_type INT2 DEFAULT '0' NOT NULL, + forum_status INT2 DEFAULT '0' NOT NULL, + forum_posts INT4 DEFAULT '0' NOT NULL CHECK (forum_posts >= 0), + forum_topics INT4 DEFAULT '0' NOT NULL CHECK (forum_topics >= 0), + forum_topics_real INT4 DEFAULT '0' NOT NULL CHECK (forum_topics_real >= 0), + forum_last_post_id INT4 DEFAULT '0' NOT NULL CHECK (forum_last_post_id >= 0), + forum_last_poster_id INT4 DEFAULT '0' NOT NULL CHECK (forum_last_poster_id >= 0), + forum_last_post_subject varchar(255) DEFAULT '' NOT NULL, + forum_last_post_time INT4 DEFAULT '0' NOT NULL CHECK (forum_last_post_time >= 0), + forum_last_poster_name varchar(255) DEFAULT '' NOT NULL, + forum_last_poster_colour varchar(6) DEFAULT '' NOT NULL, + forum_flags INT2 DEFAULT '32' NOT NULL, + forum_options INT4 DEFAULT '0' NOT NULL CHECK (forum_options >= 0), + display_subforum_list INT2 DEFAULT '1' NOT NULL CHECK (display_subforum_list >= 0), + display_on_index INT2 DEFAULT '1' NOT NULL CHECK (display_on_index >= 0), + enable_indexing INT2 DEFAULT '1' NOT NULL CHECK (enable_indexing >= 0), + enable_icons INT2 DEFAULT '1' NOT NULL CHECK (enable_icons >= 0), + enable_prune INT2 DEFAULT '0' NOT NULL CHECK (enable_prune >= 0), + prune_next INT4 DEFAULT '0' NOT NULL CHECK (prune_next >= 0), + prune_days INT4 DEFAULT '0' NOT NULL CHECK (prune_days >= 0), + prune_viewed INT4 DEFAULT '0' NOT NULL CHECK (prune_viewed >= 0), + prune_freq INT4 DEFAULT '0' NOT NULL CHECK (prune_freq >= 0), + PRIMARY KEY (forum_id) +); + +CREATE INDEX phpbb_forums_left_right_id ON phpbb_forums (left_id, right_id); +CREATE INDEX phpbb_forums_forum_lastpost_id ON phpbb_forums (forum_last_post_id); + +/* + Table: 'phpbb_forums_access' +*/ +CREATE TABLE phpbb_forums_access ( + forum_id INT4 DEFAULT '0' NOT NULL CHECK (forum_id >= 0), + user_id INT4 DEFAULT '0' NOT NULL CHECK (user_id >= 0), + session_id char(32) DEFAULT '' NOT NULL, + PRIMARY KEY (forum_id, user_id, session_id) +); + + +/* + Table: 'phpbb_forums_track' +*/ +CREATE TABLE phpbb_forums_track ( + user_id INT4 DEFAULT '0' NOT NULL CHECK (user_id >= 0), + forum_id INT4 DEFAULT '0' NOT NULL CHECK (forum_id >= 0), + mark_time INT4 DEFAULT '0' NOT NULL CHECK (mark_time >= 0), + PRIMARY KEY (user_id, forum_id) +); + + +/* + Table: 'phpbb_forums_watch' +*/ +CREATE TABLE phpbb_forums_watch ( + forum_id INT4 DEFAULT '0' NOT NULL CHECK (forum_id >= 0), + user_id INT4 DEFAULT '0' NOT NULL CHECK (user_id >= 0), + notify_status INT2 DEFAULT '0' NOT NULL CHECK (notify_status >= 0) +); + +CREATE INDEX phpbb_forums_watch_forum_id ON phpbb_forums_watch (forum_id); +CREATE INDEX phpbb_forums_watch_user_id ON phpbb_forums_watch (user_id); +CREATE INDEX phpbb_forums_watch_notify_stat ON phpbb_forums_watch (notify_status); + +/* + Table: 'phpbb_groups' +*/ +CREATE SEQUENCE phpbb_groups_seq; + +CREATE TABLE phpbb_groups ( + group_id INT4 DEFAULT nextval('phpbb_groups_seq'), + group_type INT2 DEFAULT '1' NOT NULL, + group_founder_manage INT2 DEFAULT '0' NOT NULL CHECK (group_founder_manage >= 0), + group_skip_auth INT2 DEFAULT '0' NOT NULL CHECK (group_skip_auth >= 0), + group_name varchar_ci DEFAULT '' NOT NULL, + group_desc varchar(4000) DEFAULT '' NOT NULL, + group_desc_bitfield varchar(255) DEFAULT '' NOT NULL, + group_desc_options INT4 DEFAULT '7' NOT NULL CHECK (group_desc_options >= 0), + group_desc_uid varchar(8) DEFAULT '' NOT NULL, + group_display INT2 DEFAULT '0' NOT NULL CHECK (group_display >= 0), + group_avatar varchar(255) DEFAULT '' NOT NULL, + group_avatar_type INT2 DEFAULT '0' NOT NULL, + group_avatar_width INT2 DEFAULT '0' NOT NULL CHECK (group_avatar_width >= 0), + group_avatar_height INT2 DEFAULT '0' NOT NULL CHECK (group_avatar_height >= 0), + group_rank INT4 DEFAULT '0' NOT NULL CHECK (group_rank >= 0), + group_colour varchar(6) DEFAULT '' NOT NULL, + group_sig_chars INT4 DEFAULT '0' NOT NULL CHECK (group_sig_chars >= 0), + group_receive_pm INT2 DEFAULT '0' NOT NULL CHECK (group_receive_pm >= 0), + group_message_limit INT4 DEFAULT '0' NOT NULL CHECK (group_message_limit >= 0), + group_max_recipients INT4 DEFAULT '0' NOT NULL CHECK (group_max_recipients >= 0), + group_legend INT4 DEFAULT '0' NOT NULL CHECK (group_legend >= 0), + group_teampage INT4 DEFAULT '0' NOT NULL CHECK (group_teampage >= 0), + PRIMARY KEY (group_id) +); + +CREATE INDEX phpbb_groups_group_legend_name ON phpbb_groups (group_legend, group_name); + +/* + Table: 'phpbb_icons' +*/ +CREATE SEQUENCE phpbb_icons_seq; + +CREATE TABLE phpbb_icons ( + icons_id INT4 DEFAULT nextval('phpbb_icons_seq'), + icons_url varchar(255) DEFAULT '' NOT NULL, + icons_width INT2 DEFAULT '0' NOT NULL, + icons_height INT2 DEFAULT '0' NOT NULL, + icons_order INT4 DEFAULT '0' NOT NULL CHECK (icons_order >= 0), + display_on_posting INT2 DEFAULT '1' NOT NULL CHECK (display_on_posting >= 0), + PRIMARY KEY (icons_id) +); + +CREATE INDEX phpbb_icons_display_on_posting ON phpbb_icons (display_on_posting); + +/* + Table: 'phpbb_lang' +*/ +CREATE SEQUENCE phpbb_lang_seq; + +CREATE TABLE phpbb_lang ( + lang_id INT2 DEFAULT nextval('phpbb_lang_seq'), + lang_iso varchar(30) DEFAULT '' NOT NULL, + lang_dir varchar(30) DEFAULT '' NOT NULL, + lang_english_name varchar(100) DEFAULT '' NOT NULL, + lang_local_name varchar(255) DEFAULT '' NOT NULL, + lang_author varchar(255) DEFAULT '' NOT NULL, + PRIMARY KEY (lang_id) +); + +CREATE INDEX phpbb_lang_lang_iso ON phpbb_lang (lang_iso); + +/* + Table: 'phpbb_log' +*/ +CREATE SEQUENCE phpbb_log_seq; + +CREATE TABLE phpbb_log ( + log_id INT4 DEFAULT nextval('phpbb_log_seq'), + log_type INT2 DEFAULT '0' NOT NULL, + user_id INT4 DEFAULT '0' NOT NULL CHECK (user_id >= 0), + forum_id INT4 DEFAULT '0' NOT NULL CHECK (forum_id >= 0), + topic_id INT4 DEFAULT '0' NOT NULL CHECK (topic_id >= 0), + reportee_id INT4 DEFAULT '0' NOT NULL CHECK (reportee_id >= 0), + log_ip varchar(40) DEFAULT '' NOT NULL, + log_time INT4 DEFAULT '0' NOT NULL CHECK (log_time >= 0), + log_operation varchar(4000) DEFAULT '' NOT NULL, + log_data TEXT DEFAULT '' NOT NULL, + PRIMARY KEY (log_id) +); + +CREATE INDEX phpbb_log_log_type ON phpbb_log (log_type); +CREATE INDEX phpbb_log_log_time ON phpbb_log (log_time); +CREATE INDEX phpbb_log_forum_id ON phpbb_log (forum_id); +CREATE INDEX phpbb_log_topic_id ON phpbb_log (topic_id); +CREATE INDEX phpbb_log_reportee_id ON phpbb_log (reportee_id); +CREATE INDEX phpbb_log_user_id ON phpbb_log (user_id); + +/* + Table: 'phpbb_login_attempts' +*/ +CREATE TABLE phpbb_login_attempts ( + attempt_ip varchar(40) DEFAULT '' NOT NULL, + attempt_browser varchar(150) DEFAULT '' NOT NULL, + attempt_forwarded_for varchar(255) DEFAULT '' NOT NULL, + attempt_time INT4 DEFAULT '0' NOT NULL CHECK (attempt_time >= 0), + user_id INT4 DEFAULT '0' NOT NULL CHECK (user_id >= 0), + username varchar(255) DEFAULT '0' NOT NULL, + username_clean varchar_ci DEFAULT '0' NOT NULL +); + +CREATE INDEX phpbb_login_attempts_att_ip ON phpbb_login_attempts (attempt_ip, attempt_time); +CREATE INDEX phpbb_login_attempts_att_for ON phpbb_login_attempts (attempt_forwarded_for, attempt_time); +CREATE INDEX phpbb_login_attempts_att_time ON phpbb_login_attempts (attempt_time); +CREATE INDEX phpbb_login_attempts_user_id ON phpbb_login_attempts (user_id); + +/* + Table: 'phpbb_moderator_cache' +*/ +CREATE TABLE phpbb_moderator_cache ( + forum_id INT4 DEFAULT '0' NOT NULL CHECK (forum_id >= 0), + user_id INT4 DEFAULT '0' NOT NULL CHECK (user_id >= 0), + username varchar(255) DEFAULT '' NOT NULL, + group_id INT4 DEFAULT '0' NOT NULL CHECK (group_id >= 0), + group_name varchar(255) DEFAULT '' NOT NULL, + display_on_index INT2 DEFAULT '1' NOT NULL CHECK (display_on_index >= 0) +); + +CREATE INDEX phpbb_moderator_cache_disp_idx ON phpbb_moderator_cache (display_on_index); +CREATE INDEX phpbb_moderator_cache_forum_id ON phpbb_moderator_cache (forum_id); + +/* + Table: 'phpbb_modules' +*/ +CREATE SEQUENCE phpbb_modules_seq; + +CREATE TABLE phpbb_modules ( + module_id INT4 DEFAULT nextval('phpbb_modules_seq'), + module_enabled INT2 DEFAULT '1' NOT NULL CHECK (module_enabled >= 0), + module_display INT2 DEFAULT '1' NOT NULL CHECK (module_display >= 0), + module_basename varchar(255) DEFAULT '' NOT NULL, + module_class varchar(10) DEFAULT '' NOT NULL, + parent_id INT4 DEFAULT '0' NOT NULL CHECK (parent_id >= 0), + left_id INT4 DEFAULT '0' NOT NULL CHECK (left_id >= 0), + right_id INT4 DEFAULT '0' NOT NULL CHECK (right_id >= 0), + module_langname varchar(255) DEFAULT '' NOT NULL, + module_mode varchar(255) DEFAULT '' NOT NULL, + module_auth varchar(255) DEFAULT '' NOT NULL, + PRIMARY KEY (module_id) +); + +CREATE INDEX phpbb_modules_left_right_id ON phpbb_modules (left_id, right_id); +CREATE INDEX phpbb_modules_module_enabled ON phpbb_modules (module_enabled); +CREATE INDEX phpbb_modules_class_left_id ON phpbb_modules (module_class, left_id); + +/* + Table: 'phpbb_poll_options' +*/ +CREATE TABLE phpbb_poll_options ( + poll_option_id INT2 DEFAULT '0' NOT NULL, + topic_id INT4 DEFAULT '0' NOT NULL CHECK (topic_id >= 0), + poll_option_text varchar(4000) DEFAULT '' NOT NULL, + poll_option_total INT4 DEFAULT '0' NOT NULL CHECK (poll_option_total >= 0) +); + +CREATE INDEX phpbb_poll_options_poll_opt_id ON phpbb_poll_options (poll_option_id); +CREATE INDEX phpbb_poll_options_topic_id ON phpbb_poll_options (topic_id); + +/* + Table: 'phpbb_poll_votes' +*/ +CREATE TABLE phpbb_poll_votes ( + topic_id INT4 DEFAULT '0' NOT NULL CHECK (topic_id >= 0), + poll_option_id INT2 DEFAULT '0' NOT NULL, + vote_user_id INT4 DEFAULT '0' NOT NULL CHECK (vote_user_id >= 0), + vote_user_ip varchar(40) DEFAULT '' NOT NULL +); + +CREATE INDEX phpbb_poll_votes_topic_id ON phpbb_poll_votes (topic_id); +CREATE INDEX phpbb_poll_votes_vote_user_id ON phpbb_poll_votes (vote_user_id); +CREATE INDEX phpbb_poll_votes_vote_user_ip ON phpbb_poll_votes (vote_user_ip); + +/* + Table: 'phpbb_posts' +*/ +CREATE SEQUENCE phpbb_posts_seq; + +CREATE TABLE phpbb_posts ( + post_id INT4 DEFAULT nextval('phpbb_posts_seq'), + topic_id INT4 DEFAULT '0' NOT NULL CHECK (topic_id >= 0), + forum_id INT4 DEFAULT '0' NOT NULL CHECK (forum_id >= 0), + poster_id INT4 DEFAULT '0' NOT NULL CHECK (poster_id >= 0), + icon_id INT4 DEFAULT '0' NOT NULL CHECK (icon_id >= 0), + poster_ip varchar(40) DEFAULT '' NOT NULL, + post_time INT4 DEFAULT '0' NOT NULL CHECK (post_time >= 0), + post_approved INT2 DEFAULT '1' NOT NULL CHECK (post_approved >= 0), + post_reported INT2 DEFAULT '0' NOT NULL CHECK (post_reported >= 0), + enable_bbcode INT2 DEFAULT '1' NOT NULL CHECK (enable_bbcode >= 0), + enable_smilies INT2 DEFAULT '1' NOT NULL CHECK (enable_smilies >= 0), + enable_magic_url INT2 DEFAULT '1' NOT NULL CHECK (enable_magic_url >= 0), + enable_sig INT2 DEFAULT '1' NOT NULL CHECK (enable_sig >= 0), + post_username varchar(255) DEFAULT '' NOT NULL, + post_subject varchar(255) DEFAULT '' NOT NULL, + post_text TEXT DEFAULT '' NOT NULL, + post_checksum varchar(32) DEFAULT '' NOT NULL, + post_attachment INT2 DEFAULT '0' NOT NULL CHECK (post_attachment >= 0), + bbcode_bitfield varchar(255) DEFAULT '' NOT NULL, + bbcode_uid varchar(8) DEFAULT '' NOT NULL, + post_postcount INT2 DEFAULT '1' NOT NULL CHECK (post_postcount >= 0), + post_edit_time INT4 DEFAULT '0' NOT NULL CHECK (post_edit_time >= 0), + post_edit_reason varchar(255) DEFAULT '' NOT NULL, + post_edit_user INT4 DEFAULT '0' NOT NULL CHECK (post_edit_user >= 0), + post_edit_count INT2 DEFAULT '0' NOT NULL CHECK (post_edit_count >= 0), + post_edit_locked INT2 DEFAULT '0' NOT NULL CHECK (post_edit_locked >= 0), + PRIMARY KEY (post_id) +); + +CREATE INDEX phpbb_posts_forum_id ON phpbb_posts (forum_id); +CREATE INDEX phpbb_posts_topic_id ON phpbb_posts (topic_id); +CREATE INDEX phpbb_posts_poster_ip ON phpbb_posts (poster_ip); +CREATE INDEX phpbb_posts_poster_id ON phpbb_posts (poster_id); +CREATE INDEX phpbb_posts_post_approved ON phpbb_posts (post_approved); +CREATE INDEX phpbb_posts_post_username ON phpbb_posts (post_username); +CREATE INDEX phpbb_posts_tid_post_time ON phpbb_posts (topic_id, post_time); + +/* + Table: 'phpbb_privmsgs' +*/ +CREATE SEQUENCE phpbb_privmsgs_seq; + +CREATE TABLE phpbb_privmsgs ( + msg_id INT4 DEFAULT nextval('phpbb_privmsgs_seq'), + root_level INT4 DEFAULT '0' NOT NULL CHECK (root_level >= 0), + author_id INT4 DEFAULT '0' NOT NULL CHECK (author_id >= 0), + icon_id INT4 DEFAULT '0' NOT NULL CHECK (icon_id >= 0), + author_ip varchar(40) DEFAULT '' NOT NULL, + message_time INT4 DEFAULT '0' NOT NULL CHECK (message_time >= 0), + enable_bbcode INT2 DEFAULT '1' NOT NULL CHECK (enable_bbcode >= 0), + enable_smilies INT2 DEFAULT '1' NOT NULL CHECK (enable_smilies >= 0), + enable_magic_url INT2 DEFAULT '1' NOT NULL CHECK (enable_magic_url >= 0), + enable_sig INT2 DEFAULT '1' NOT NULL CHECK (enable_sig >= 0), + message_subject varchar(255) DEFAULT '' NOT NULL, + message_text TEXT DEFAULT '' NOT NULL, + message_edit_reason varchar(255) DEFAULT '' NOT NULL, + message_edit_user INT4 DEFAULT '0' NOT NULL CHECK (message_edit_user >= 0), + message_attachment INT2 DEFAULT '0' NOT NULL CHECK (message_attachment >= 0), + bbcode_bitfield varchar(255) DEFAULT '' NOT NULL, + bbcode_uid varchar(8) DEFAULT '' NOT NULL, + message_edit_time INT4 DEFAULT '0' NOT NULL CHECK (message_edit_time >= 0), + message_edit_count INT2 DEFAULT '0' NOT NULL CHECK (message_edit_count >= 0), + to_address varchar(4000) DEFAULT '' NOT NULL, + bcc_address varchar(4000) DEFAULT '' NOT NULL, + message_reported INT2 DEFAULT '0' NOT NULL CHECK (message_reported >= 0), + PRIMARY KEY (msg_id) +); + +CREATE INDEX phpbb_privmsgs_author_ip ON phpbb_privmsgs (author_ip); +CREATE INDEX phpbb_privmsgs_message_time ON phpbb_privmsgs (message_time); +CREATE INDEX phpbb_privmsgs_author_id ON phpbb_privmsgs (author_id); +CREATE INDEX phpbb_privmsgs_root_level ON phpbb_privmsgs (root_level); + +/* + Table: 'phpbb_privmsgs_folder' +*/ +CREATE SEQUENCE phpbb_privmsgs_folder_seq; + +CREATE TABLE phpbb_privmsgs_folder ( + folder_id INT4 DEFAULT nextval('phpbb_privmsgs_folder_seq'), + user_id INT4 DEFAULT '0' NOT NULL CHECK (user_id >= 0), + folder_name varchar(255) DEFAULT '' NOT NULL, + pm_count INT4 DEFAULT '0' NOT NULL CHECK (pm_count >= 0), + PRIMARY KEY (folder_id) +); + +CREATE INDEX phpbb_privmsgs_folder_user_id ON phpbb_privmsgs_folder (user_id); + +/* + Table: 'phpbb_privmsgs_rules' +*/ +CREATE SEQUENCE phpbb_privmsgs_rules_seq; + +CREATE TABLE phpbb_privmsgs_rules ( + rule_id INT4 DEFAULT nextval('phpbb_privmsgs_rules_seq'), + user_id INT4 DEFAULT '0' NOT NULL CHECK (user_id >= 0), + rule_check INT4 DEFAULT '0' NOT NULL CHECK (rule_check >= 0), + rule_connection INT4 DEFAULT '0' NOT NULL CHECK (rule_connection >= 0), + rule_string varchar(255) DEFAULT '' NOT NULL, + rule_user_id INT4 DEFAULT '0' NOT NULL CHECK (rule_user_id >= 0), + rule_group_id INT4 DEFAULT '0' NOT NULL CHECK (rule_group_id >= 0), + rule_action INT4 DEFAULT '0' NOT NULL CHECK (rule_action >= 0), + rule_folder_id INT4 DEFAULT '0' NOT NULL, + PRIMARY KEY (rule_id) +); + +CREATE INDEX phpbb_privmsgs_rules_user_id ON phpbb_privmsgs_rules (user_id); + +/* + Table: 'phpbb_privmsgs_to' +*/ +CREATE TABLE phpbb_privmsgs_to ( + msg_id INT4 DEFAULT '0' NOT NULL CHECK (msg_id >= 0), + user_id INT4 DEFAULT '0' NOT NULL CHECK (user_id >= 0), + author_id INT4 DEFAULT '0' NOT NULL CHECK (author_id >= 0), + pm_deleted INT2 DEFAULT '0' NOT NULL CHECK (pm_deleted >= 0), + pm_new INT2 DEFAULT '1' NOT NULL CHECK (pm_new >= 0), + pm_unread INT2 DEFAULT '1' NOT NULL CHECK (pm_unread >= 0), + pm_replied INT2 DEFAULT '0' NOT NULL CHECK (pm_replied >= 0), + pm_marked INT2 DEFAULT '0' NOT NULL CHECK (pm_marked >= 0), + pm_forwarded INT2 DEFAULT '0' NOT NULL CHECK (pm_forwarded >= 0), + folder_id INT4 DEFAULT '0' NOT NULL +); + +CREATE INDEX phpbb_privmsgs_to_msg_id ON phpbb_privmsgs_to (msg_id); +CREATE INDEX phpbb_privmsgs_to_author_id ON phpbb_privmsgs_to (author_id); +CREATE INDEX phpbb_privmsgs_to_usr_flder_id ON phpbb_privmsgs_to (user_id, folder_id); + +/* + Table: 'phpbb_profile_fields' +*/ +CREATE SEQUENCE phpbb_profile_fields_seq; + +CREATE TABLE phpbb_profile_fields ( + field_id INT4 DEFAULT nextval('phpbb_profile_fields_seq'), + field_name varchar(255) DEFAULT '' NOT NULL, + field_type INT2 DEFAULT '0' NOT NULL, + field_ident varchar(20) DEFAULT '' NOT NULL, + field_length varchar(20) DEFAULT '' NOT NULL, + field_minlen varchar(255) DEFAULT '' NOT NULL, + field_maxlen varchar(255) DEFAULT '' NOT NULL, + field_novalue varchar(255) DEFAULT '' NOT NULL, + field_default_value varchar(255) DEFAULT '' NOT NULL, + field_validation varchar(20) DEFAULT '' NOT NULL, + field_required INT2 DEFAULT '0' NOT NULL CHECK (field_required >= 0), + field_show_novalue INT2 DEFAULT '0' NOT NULL CHECK (field_show_novalue >= 0), + field_show_on_reg INT2 DEFAULT '0' NOT NULL CHECK (field_show_on_reg >= 0), + field_show_on_pm INT2 DEFAULT '0' NOT NULL CHECK (field_show_on_pm >= 0), + field_show_on_vt INT2 DEFAULT '0' NOT NULL CHECK (field_show_on_vt >= 0), + field_show_profile INT2 DEFAULT '0' NOT NULL CHECK (field_show_profile >= 0), + field_hide INT2 DEFAULT '0' NOT NULL CHECK (field_hide >= 0), + field_no_view INT2 DEFAULT '0' NOT NULL CHECK (field_no_view >= 0), + field_active INT2 DEFAULT '0' NOT NULL CHECK (field_active >= 0), + field_order INT4 DEFAULT '0' NOT NULL CHECK (field_order >= 0), + PRIMARY KEY (field_id) +); + +CREATE INDEX phpbb_profile_fields_fld_type ON phpbb_profile_fields (field_type); +CREATE INDEX phpbb_profile_fields_fld_ordr ON phpbb_profile_fields (field_order); + +/* + Table: 'phpbb_profile_fields_data' +*/ +CREATE TABLE phpbb_profile_fields_data ( + user_id INT4 DEFAULT '0' NOT NULL CHECK (user_id >= 0), + PRIMARY KEY (user_id) +); + + +/* + Table: 'phpbb_profile_fields_lang' +*/ +CREATE TABLE phpbb_profile_fields_lang ( + field_id INT4 DEFAULT '0' NOT NULL CHECK (field_id >= 0), + lang_id INT4 DEFAULT '0' NOT NULL CHECK (lang_id >= 0), + option_id INT4 DEFAULT '0' NOT NULL CHECK (option_id >= 0), + field_type INT2 DEFAULT '0' NOT NULL, + lang_value varchar(255) DEFAULT '' NOT NULL, + PRIMARY KEY (field_id, lang_id, option_id) +); + + +/* + Table: 'phpbb_profile_lang' +*/ +CREATE TABLE phpbb_profile_lang ( + field_id INT4 DEFAULT '0' NOT NULL CHECK (field_id >= 0), + lang_id INT4 DEFAULT '0' NOT NULL CHECK (lang_id >= 0), + lang_name varchar(255) DEFAULT '' NOT NULL, + lang_explain varchar(4000) DEFAULT '' NOT NULL, + lang_default_value varchar(255) DEFAULT '' NOT NULL, + PRIMARY KEY (field_id, lang_id) +); + + +/* + Table: 'phpbb_ranks' +*/ +CREATE SEQUENCE phpbb_ranks_seq; + +CREATE TABLE phpbb_ranks ( + rank_id INT4 DEFAULT nextval('phpbb_ranks_seq'), + rank_title varchar(255) DEFAULT '' NOT NULL, + rank_min INT4 DEFAULT '0' NOT NULL CHECK (rank_min >= 0), + rank_special INT2 DEFAULT '0' NOT NULL CHECK (rank_special >= 0), + rank_image varchar(255) DEFAULT '' NOT NULL, + PRIMARY KEY (rank_id) +); + + +/* + Table: 'phpbb_reports' +*/ +CREATE SEQUENCE phpbb_reports_seq; + +CREATE TABLE phpbb_reports ( + report_id INT4 DEFAULT nextval('phpbb_reports_seq'), + reason_id INT2 DEFAULT '0' NOT NULL CHECK (reason_id >= 0), + post_id INT4 DEFAULT '0' NOT NULL CHECK (post_id >= 0), + pm_id INT4 DEFAULT '0' NOT NULL CHECK (pm_id >= 0), + user_id INT4 DEFAULT '0' NOT NULL CHECK (user_id >= 0), + user_notify INT2 DEFAULT '0' NOT NULL CHECK (user_notify >= 0), + report_closed INT2 DEFAULT '0' NOT NULL CHECK (report_closed >= 0), + report_time INT4 DEFAULT '0' NOT NULL CHECK (report_time >= 0), + report_text TEXT DEFAULT '' NOT NULL, + reported_post_text TEXT DEFAULT '' NOT NULL, + PRIMARY KEY (report_id) +); + +CREATE INDEX phpbb_reports_post_id ON phpbb_reports (post_id); +CREATE INDEX phpbb_reports_pm_id ON phpbb_reports (pm_id); + +/* + Table: 'phpbb_reports_reasons' +*/ +CREATE SEQUENCE phpbb_reports_reasons_seq; + +CREATE TABLE phpbb_reports_reasons ( + reason_id INT2 DEFAULT nextval('phpbb_reports_reasons_seq'), + reason_title varchar(255) DEFAULT '' NOT NULL, + reason_description TEXT DEFAULT '' NOT NULL, + reason_order INT2 DEFAULT '0' NOT NULL CHECK (reason_order >= 0), + PRIMARY KEY (reason_id) +); + + +/* + Table: 'phpbb_search_results' +*/ +CREATE TABLE phpbb_search_results ( + search_key varchar(32) DEFAULT '' NOT NULL, + search_time INT4 DEFAULT '0' NOT NULL CHECK (search_time >= 0), + search_keywords TEXT DEFAULT '' NOT NULL, + search_authors TEXT DEFAULT '' NOT NULL, + PRIMARY KEY (search_key) +); + + +/* + Table: 'phpbb_search_wordlist' +*/ +CREATE SEQUENCE phpbb_search_wordlist_seq; + +CREATE TABLE phpbb_search_wordlist ( + word_id INT4 DEFAULT nextval('phpbb_search_wordlist_seq'), + word_text varchar(255) DEFAULT '' NOT NULL, + word_common INT2 DEFAULT '0' NOT NULL CHECK (word_common >= 0), + word_count INT4 DEFAULT '0' NOT NULL CHECK (word_count >= 0), + PRIMARY KEY (word_id) +); + +CREATE UNIQUE INDEX phpbb_search_wordlist_wrd_txt ON phpbb_search_wordlist (word_text); +CREATE INDEX phpbb_search_wordlist_wrd_cnt ON phpbb_search_wordlist (word_count); + +/* + Table: 'phpbb_search_wordmatch' +*/ +CREATE TABLE phpbb_search_wordmatch ( + post_id INT4 DEFAULT '0' NOT NULL CHECK (post_id >= 0), + word_id INT4 DEFAULT '0' NOT NULL CHECK (word_id >= 0), + title_match INT2 DEFAULT '0' NOT NULL CHECK (title_match >= 0) +); + +CREATE UNIQUE INDEX phpbb_search_wordmatch_unq_mtch ON phpbb_search_wordmatch (word_id, post_id, title_match); +CREATE INDEX phpbb_search_wordmatch_word_id ON phpbb_search_wordmatch (word_id); +CREATE INDEX phpbb_search_wordmatch_post_id ON phpbb_search_wordmatch (post_id); + +/* + Table: 'phpbb_sessions' +*/ +CREATE TABLE phpbb_sessions ( + session_id char(32) DEFAULT '' NOT NULL, + session_user_id INT4 DEFAULT '0' NOT NULL CHECK (session_user_id >= 0), + session_forum_id INT4 DEFAULT '0' NOT NULL CHECK (session_forum_id >= 0), + session_last_visit INT4 DEFAULT '0' NOT NULL CHECK (session_last_visit >= 0), + session_start INT4 DEFAULT '0' NOT NULL CHECK (session_start >= 0), + session_time INT4 DEFAULT '0' NOT NULL CHECK (session_time >= 0), + session_ip varchar(40) DEFAULT '' NOT NULL, + session_browser varchar(150) DEFAULT '' NOT NULL, + session_forwarded_for varchar(255) DEFAULT '' NOT NULL, + session_page varchar(255) DEFAULT '' NOT NULL, + session_viewonline INT2 DEFAULT '1' NOT NULL CHECK (session_viewonline >= 0), + session_autologin INT2 DEFAULT '0' NOT NULL CHECK (session_autologin >= 0), + session_admin INT2 DEFAULT '0' NOT NULL CHECK (session_admin >= 0), + PRIMARY KEY (session_id) +); + +CREATE INDEX phpbb_sessions_session_time ON phpbb_sessions (session_time); +CREATE INDEX phpbb_sessions_session_user_id ON phpbb_sessions (session_user_id); +CREATE INDEX phpbb_sessions_session_fid ON phpbb_sessions (session_forum_id); + +/* + Table: 'phpbb_sessions_keys' +*/ +CREATE TABLE phpbb_sessions_keys ( + key_id char(32) DEFAULT '' NOT NULL, + user_id INT4 DEFAULT '0' NOT NULL CHECK (user_id >= 0), + last_ip varchar(40) DEFAULT '' NOT NULL, + last_login INT4 DEFAULT '0' NOT NULL CHECK (last_login >= 0), + PRIMARY KEY (key_id, user_id) +); + +CREATE INDEX phpbb_sessions_keys_last_login ON phpbb_sessions_keys (last_login); + +/* + Table: 'phpbb_sitelist' +*/ +CREATE SEQUENCE phpbb_sitelist_seq; + +CREATE TABLE phpbb_sitelist ( + site_id INT4 DEFAULT nextval('phpbb_sitelist_seq'), + site_ip varchar(40) DEFAULT '' NOT NULL, + site_hostname varchar(255) DEFAULT '' NOT NULL, + ip_exclude INT2 DEFAULT '0' NOT NULL CHECK (ip_exclude >= 0), + PRIMARY KEY (site_id) +); + + +/* + Table: 'phpbb_smilies' +*/ +CREATE SEQUENCE phpbb_smilies_seq; + +CREATE TABLE phpbb_smilies ( + smiley_id INT4 DEFAULT nextval('phpbb_smilies_seq'), + code varchar(50) DEFAULT '' NOT NULL, + emotion varchar(50) DEFAULT '' NOT NULL, + smiley_url varchar(50) DEFAULT '' NOT NULL, + smiley_width INT2 DEFAULT '0' NOT NULL CHECK (smiley_width >= 0), + smiley_height INT2 DEFAULT '0' NOT NULL CHECK (smiley_height >= 0), + smiley_order INT4 DEFAULT '0' NOT NULL CHECK (smiley_order >= 0), + display_on_posting INT2 DEFAULT '1' NOT NULL CHECK (display_on_posting >= 0), + PRIMARY KEY (smiley_id) +); + +CREATE INDEX phpbb_smilies_display_on_post ON phpbb_smilies (display_on_posting); + +/* + Table: 'phpbb_styles' +*/ +CREATE SEQUENCE phpbb_styles_seq; + +CREATE TABLE phpbb_styles ( + style_id INT4 DEFAULT nextval('phpbb_styles_seq'), + style_name varchar(255) DEFAULT '' NOT NULL, + style_copyright varchar(255) DEFAULT '' NOT NULL, + style_active INT2 DEFAULT '1' NOT NULL CHECK (style_active >= 0), + style_path varchar(100) DEFAULT '' NOT NULL, + bbcode_bitfield varchar(255) DEFAULT 'kNg=' NOT NULL, + style_parent_id INT4 DEFAULT '0' NOT NULL CHECK (style_parent_id >= 0), + style_parent_tree varchar(8000) DEFAULT '' NOT NULL, + PRIMARY KEY (style_id) +); + +CREATE UNIQUE INDEX phpbb_styles_style_name ON phpbb_styles (style_name); + +/* + Table: 'phpbb_topics' +*/ +CREATE SEQUENCE phpbb_topics_seq; + +CREATE TABLE phpbb_topics ( + topic_id INT4 DEFAULT nextval('phpbb_topics_seq'), + forum_id INT4 DEFAULT '0' NOT NULL CHECK (forum_id >= 0), + icon_id INT4 DEFAULT '0' NOT NULL CHECK (icon_id >= 0), + topic_attachment INT2 DEFAULT '0' NOT NULL CHECK (topic_attachment >= 0), + topic_approved INT2 DEFAULT '1' NOT NULL CHECK (topic_approved >= 0), + topic_reported INT2 DEFAULT '0' NOT NULL CHECK (topic_reported >= 0), + topic_title varchar(255) DEFAULT '' NOT NULL, + topic_poster INT4 DEFAULT '0' NOT NULL CHECK (topic_poster >= 0), + topic_time INT4 DEFAULT '0' NOT NULL CHECK (topic_time >= 0), + topic_time_limit INT4 DEFAULT '0' NOT NULL CHECK (topic_time_limit >= 0), + topic_views INT4 DEFAULT '0' NOT NULL CHECK (topic_views >= 0), + topic_replies INT4 DEFAULT '0' NOT NULL CHECK (topic_replies >= 0), + topic_replies_real INT4 DEFAULT '0' NOT NULL CHECK (topic_replies_real >= 0), + topic_status INT2 DEFAULT '0' NOT NULL, + topic_type INT2 DEFAULT '0' NOT NULL, + topic_first_post_id INT4 DEFAULT '0' NOT NULL CHECK (topic_first_post_id >= 0), + topic_first_poster_name varchar(255) DEFAULT '' NOT NULL, + topic_first_poster_colour varchar(6) DEFAULT '' NOT NULL, + topic_last_post_id INT4 DEFAULT '0' NOT NULL CHECK (topic_last_post_id >= 0), + topic_last_poster_id INT4 DEFAULT '0' NOT NULL CHECK (topic_last_poster_id >= 0), + topic_last_poster_name varchar(255) DEFAULT '' NOT NULL, + topic_last_poster_colour varchar(6) DEFAULT '' NOT NULL, + topic_last_post_subject varchar(255) DEFAULT '' NOT NULL, + topic_last_post_time INT4 DEFAULT '0' NOT NULL CHECK (topic_last_post_time >= 0), + topic_last_view_time INT4 DEFAULT '0' NOT NULL CHECK (topic_last_view_time >= 0), + topic_moved_id INT4 DEFAULT '0' NOT NULL CHECK (topic_moved_id >= 0), + topic_bumped INT2 DEFAULT '0' NOT NULL CHECK (topic_bumped >= 0), + topic_bumper INT4 DEFAULT '0' NOT NULL CHECK (topic_bumper >= 0), + poll_title varchar(255) DEFAULT '' NOT NULL, + poll_start INT4 DEFAULT '0' NOT NULL CHECK (poll_start >= 0), + poll_length INT4 DEFAULT '0' NOT NULL CHECK (poll_length >= 0), + poll_max_options INT2 DEFAULT '1' NOT NULL, + poll_last_vote INT4 DEFAULT '0' NOT NULL CHECK (poll_last_vote >= 0), + poll_vote_change INT2 DEFAULT '0' NOT NULL CHECK (poll_vote_change >= 0), + PRIMARY KEY (topic_id) +); + +CREATE INDEX phpbb_topics_forum_id ON phpbb_topics (forum_id); +CREATE INDEX phpbb_topics_forum_id_type ON phpbb_topics (forum_id, topic_type); +CREATE INDEX phpbb_topics_last_post_time ON phpbb_topics (topic_last_post_time); +CREATE INDEX phpbb_topics_topic_approved ON phpbb_topics (topic_approved); +CREATE INDEX phpbb_topics_forum_appr_last ON phpbb_topics (forum_id, topic_approved, topic_last_post_id); +CREATE INDEX phpbb_topics_fid_time_moved ON phpbb_topics (forum_id, topic_last_post_time, topic_moved_id); + +/* + Table: 'phpbb_topics_track' +*/ +CREATE TABLE phpbb_topics_track ( + user_id INT4 DEFAULT '0' NOT NULL CHECK (user_id >= 0), + topic_id INT4 DEFAULT '0' NOT NULL CHECK (topic_id >= 0), + forum_id INT4 DEFAULT '0' NOT NULL CHECK (forum_id >= 0), + mark_time INT4 DEFAULT '0' NOT NULL CHECK (mark_time >= 0), + PRIMARY KEY (user_id, topic_id) +); + +CREATE INDEX phpbb_topics_track_topic_id ON phpbb_topics_track (topic_id); +CREATE INDEX phpbb_topics_track_forum_id ON phpbb_topics_track (forum_id); + +/* + Table: 'phpbb_topics_posted' +*/ +CREATE TABLE phpbb_topics_posted ( + user_id INT4 DEFAULT '0' NOT NULL CHECK (user_id >= 0), + topic_id INT4 DEFAULT '0' NOT NULL CHECK (topic_id >= 0), + topic_posted INT2 DEFAULT '0' NOT NULL CHECK (topic_posted >= 0), + PRIMARY KEY (user_id, topic_id) +); + + +/* + Table: 'phpbb_topics_watch' +*/ +CREATE TABLE phpbb_topics_watch ( + topic_id INT4 DEFAULT '0' NOT NULL CHECK (topic_id >= 0), + user_id INT4 DEFAULT '0' NOT NULL CHECK (user_id >= 0), + notify_status INT2 DEFAULT '0' NOT NULL CHECK (notify_status >= 0) +); + +CREATE INDEX phpbb_topics_watch_topic_id ON phpbb_topics_watch (topic_id); +CREATE INDEX phpbb_topics_watch_user_id ON phpbb_topics_watch (user_id); +CREATE INDEX phpbb_topics_watch_notify_stat ON phpbb_topics_watch (notify_status); + +/* + Table: 'phpbb_user_group' +*/ +CREATE TABLE phpbb_user_group ( + group_id INT4 DEFAULT '0' NOT NULL CHECK (group_id >= 0), + user_id INT4 DEFAULT '0' NOT NULL CHECK (user_id >= 0), + group_leader INT2 DEFAULT '0' NOT NULL CHECK (group_leader >= 0), + user_pending INT2 DEFAULT '1' NOT NULL CHECK (user_pending >= 0) +); + +CREATE INDEX phpbb_user_group_group_id ON phpbb_user_group (group_id); +CREATE INDEX phpbb_user_group_user_id ON phpbb_user_group (user_id); +CREATE INDEX phpbb_user_group_group_leader ON phpbb_user_group (group_leader); + +/* + Table: 'phpbb_users' +*/ +CREATE SEQUENCE phpbb_users_seq; + +CREATE TABLE phpbb_users ( + user_id INT4 DEFAULT nextval('phpbb_users_seq'), + user_type INT2 DEFAULT '0' NOT NULL, + group_id INT4 DEFAULT '3' NOT NULL CHECK (group_id >= 0), + user_permissions TEXT DEFAULT '' NOT NULL, + user_perm_from INT4 DEFAULT '0' NOT NULL CHECK (user_perm_from >= 0), + user_ip varchar(40) DEFAULT '' NOT NULL, + user_regdate INT4 DEFAULT '0' NOT NULL CHECK (user_regdate >= 0), + username varchar_ci DEFAULT '' NOT NULL, + username_clean varchar_ci DEFAULT '' NOT NULL, + user_password varchar(40) DEFAULT '' NOT NULL, + user_passchg INT4 DEFAULT '0' NOT NULL CHECK (user_passchg >= 0), + user_pass_convert INT2 DEFAULT '0' NOT NULL CHECK (user_pass_convert >= 0), + user_email varchar(100) DEFAULT '' NOT NULL, + user_email_hash INT8 DEFAULT '0' NOT NULL, + user_birthday varchar(10) DEFAULT '' NOT NULL, + user_lastvisit INT4 DEFAULT '0' NOT NULL CHECK (user_lastvisit >= 0), + user_lastmark INT4 DEFAULT '0' NOT NULL CHECK (user_lastmark >= 0), + user_lastpost_time INT4 DEFAULT '0' NOT NULL CHECK (user_lastpost_time >= 0), + user_lastpage varchar(200) DEFAULT '' NOT NULL, + user_last_confirm_key varchar(10) DEFAULT '' NOT NULL, + user_last_search INT4 DEFAULT '0' NOT NULL CHECK (user_last_search >= 0), + user_warnings INT2 DEFAULT '0' NOT NULL, + user_last_warning INT4 DEFAULT '0' NOT NULL CHECK (user_last_warning >= 0), + user_login_attempts INT2 DEFAULT '0' NOT NULL, + user_inactive_reason INT2 DEFAULT '0' NOT NULL, + user_inactive_time INT4 DEFAULT '0' NOT NULL CHECK (user_inactive_time >= 0), + user_posts INT4 DEFAULT '0' NOT NULL CHECK (user_posts >= 0), + user_lang varchar(30) DEFAULT '' NOT NULL, + user_timezone varchar(100) DEFAULT 'UTC' NOT NULL, + user_dateformat varchar(30) DEFAULT 'd M Y H:i' NOT NULL, + user_style INT4 DEFAULT '0' NOT NULL CHECK (user_style >= 0), + user_rank INT4 DEFAULT '0' NOT NULL CHECK (user_rank >= 0), + user_colour varchar(6) DEFAULT '' NOT NULL, + user_new_privmsg INT4 DEFAULT '0' NOT NULL, + user_unread_privmsg INT4 DEFAULT '0' NOT NULL, + user_last_privmsg INT4 DEFAULT '0' NOT NULL CHECK (user_last_privmsg >= 0), + user_message_rules INT2 DEFAULT '0' NOT NULL CHECK (user_message_rules >= 0), + user_full_folder INT4 DEFAULT '-3' NOT NULL, + user_emailtime INT4 DEFAULT '0' NOT NULL CHECK (user_emailtime >= 0), + user_topic_show_days INT2 DEFAULT '0' NOT NULL CHECK (user_topic_show_days >= 0), + user_topic_sortby_type varchar(1) DEFAULT 't' NOT NULL, + user_topic_sortby_dir varchar(1) DEFAULT 'd' NOT NULL, + user_post_show_days INT2 DEFAULT '0' NOT NULL CHECK (user_post_show_days >= 0), + user_post_sortby_type varchar(1) DEFAULT 't' NOT NULL, + user_post_sortby_dir varchar(1) DEFAULT 'a' NOT NULL, + user_notify INT2 DEFAULT '0' NOT NULL CHECK (user_notify >= 0), + user_notify_pm INT2 DEFAULT '1' NOT NULL CHECK (user_notify_pm >= 0), + user_notify_type INT2 DEFAULT '0' NOT NULL, + user_allow_pm INT2 DEFAULT '1' NOT NULL CHECK (user_allow_pm >= 0), + user_allow_viewonline INT2 DEFAULT '1' NOT NULL CHECK (user_allow_viewonline >= 0), + user_allow_viewemail INT2 DEFAULT '1' NOT NULL CHECK (user_allow_viewemail >= 0), + user_allow_massemail INT2 DEFAULT '1' NOT NULL CHECK (user_allow_massemail >= 0), + user_options INT4 DEFAULT '230271' NOT NULL CHECK (user_options >= 0), + user_avatar varchar(255) DEFAULT '' NOT NULL, + user_avatar_type INT2 DEFAULT '0' NOT NULL, + user_avatar_width INT2 DEFAULT '0' NOT NULL CHECK (user_avatar_width >= 0), + user_avatar_height INT2 DEFAULT '0' NOT NULL CHECK (user_avatar_height >= 0), + user_sig TEXT DEFAULT '' NOT NULL, + user_sig_bbcode_uid varchar(8) DEFAULT '' NOT NULL, + user_sig_bbcode_bitfield varchar(255) DEFAULT '' NOT NULL, + user_from varchar(100) DEFAULT '' NOT NULL, + user_icq varchar(15) DEFAULT '' NOT NULL, + user_aim varchar(255) DEFAULT '' NOT NULL, + user_yim varchar(255) DEFAULT '' NOT NULL, + user_msnm varchar(255) DEFAULT '' NOT NULL, + user_jabber varchar(255) DEFAULT '' NOT NULL, + user_website varchar(200) DEFAULT '' NOT NULL, + user_occ varchar(4000) DEFAULT '' NOT NULL, + user_interests varchar(4000) DEFAULT '' NOT NULL, + user_actkey varchar(32) DEFAULT '' NOT NULL, + user_newpasswd varchar(40) DEFAULT '' NOT NULL, + user_form_salt varchar(32) DEFAULT '' NOT NULL, + user_new INT2 DEFAULT '1' NOT NULL CHECK (user_new >= 0), + user_reminded INT2 DEFAULT '0' NOT NULL, + user_reminded_time INT4 DEFAULT '0' NOT NULL CHECK (user_reminded_time >= 0), + PRIMARY KEY (user_id) +); + +CREATE INDEX phpbb_users_user_birthday ON phpbb_users (user_birthday); +CREATE INDEX phpbb_users_user_email_hash ON phpbb_users (user_email_hash); +CREATE INDEX phpbb_users_user_type ON phpbb_users (user_type); +CREATE UNIQUE INDEX phpbb_users_username_clean ON phpbb_users (username_clean); + +/* + Table: 'phpbb_warnings' +*/ +CREATE SEQUENCE phpbb_warnings_seq; + +CREATE TABLE phpbb_warnings ( + warning_id INT4 DEFAULT nextval('phpbb_warnings_seq'), + user_id INT4 DEFAULT '0' NOT NULL CHECK (user_id >= 0), + post_id INT4 DEFAULT '0' NOT NULL CHECK (post_id >= 0), + log_id INT4 DEFAULT '0' NOT NULL CHECK (log_id >= 0), + warning_time INT4 DEFAULT '0' NOT NULL CHECK (warning_time >= 0), + PRIMARY KEY (warning_id) +); + + +/* + Table: 'phpbb_words' +*/ +CREATE SEQUENCE phpbb_words_seq; + +CREATE TABLE phpbb_words ( + word_id INT4 DEFAULT nextval('phpbb_words_seq'), + word varchar(255) DEFAULT '' NOT NULL, + replacement varchar(255) DEFAULT '' NOT NULL, + PRIMARY KEY (word_id) +); + + +/* + Table: 'phpbb_zebra' +*/ +CREATE TABLE phpbb_zebra ( + user_id INT4 DEFAULT '0' NOT NULL CHECK (user_id >= 0), + zebra_id INT4 DEFAULT '0' NOT NULL CHECK (zebra_id >= 0), + friend INT2 DEFAULT '0' NOT NULL CHECK (friend >= 0), + foe INT2 DEFAULT '0' NOT NULL CHECK (foe >= 0), + PRIMARY KEY (user_id, zebra_id) +); diff --git a/phpBB/install/schemas/schema_data.sql b/phpBB/install/schemas/schema_data.sql index ea7864bd4c..938b11388b 100644 --- a/phpBB/install/schemas/schema_data.sql +++ b/phpBB/install/schemas/schema_data.sql @@ -314,6 +314,7 @@ INSERT INTO phpbb_acl_options (auth_option, is_local) VALUES ('f_subscribe', 1); INSERT INTO phpbb_acl_options (auth_option, is_local) VALUES ('f_user_lock', 1); INSERT INTO phpbb_acl_options (auth_option, is_local) VALUES ('f_vote', 1); INSERT INTO phpbb_acl_options (auth_option, is_local) VALUES ('f_votechg', 1); +INSERT INTO phpbb_acl_options (auth_option, is_local) VALUES ('f_restore', 1); # -- Moderator related auth options INSERT INTO phpbb_acl_options (auth_option, is_local, is_global) VALUES ('m_', 1, 1); @@ -327,6 +328,7 @@ INSERT INTO phpbb_acl_options (auth_option, is_local, is_global) VALUES ('m_merg INSERT INTO phpbb_acl_options (auth_option, is_local, is_global) VALUES ('m_move', 1, 1); INSERT INTO phpbb_acl_options (auth_option, is_local, is_global) VALUES ('m_report', 1, 1); INSERT INTO phpbb_acl_options (auth_option, is_local, is_global) VALUES ('m_split', 1, 1); +INSERT INTO phpbb_acl_options (auth_option, is_local, is_global) VALUES ('m_restore', 1, 1); # -- Global moderator auth option (not a local option) INSERT INTO phpbb_acl_options (auth_option, is_local, is_global) VALUES ('m_ban', 0, 1); diff --git a/phpBB/install/schemas/sqlite_schema.sql b/phpBB/install/schemas/sqlite_schema.sql index 8360bc30ea..361e0ca9c6 100644 --- a/phpBB/install/schemas/sqlite_schema.sql +++ b/phpBB/install/schemas/sqlite_schema.sql @@ -1,951 +1,947 @@ -# DO NOT EDIT THIS FILE, IT IS GENERATED -# -# To change the contents of this file, edit -# phpBB/develop/create_schema_files.php and -# run it. -BEGIN TRANSACTION; - -# Table: 'phpbb_attachments' -CREATE TABLE phpbb_attachments ( - attach_id INTEGER PRIMARY KEY NOT NULL , - post_msg_id INTEGER UNSIGNED NOT NULL DEFAULT '0', - topic_id INTEGER UNSIGNED NOT NULL DEFAULT '0', - in_message INTEGER UNSIGNED NOT NULL DEFAULT '0', - poster_id INTEGER UNSIGNED NOT NULL DEFAULT '0', - is_orphan INTEGER UNSIGNED NOT NULL DEFAULT '1', - physical_filename varchar(255) NOT NULL DEFAULT '', - real_filename varchar(255) NOT NULL DEFAULT '', - download_count INTEGER UNSIGNED NOT NULL DEFAULT '0', - attach_comment text(65535) NOT NULL DEFAULT '', - extension varchar(100) NOT NULL DEFAULT '', - mimetype varchar(100) NOT NULL DEFAULT '', - filesize INTEGER UNSIGNED NOT NULL DEFAULT '0', - filetime INTEGER UNSIGNED NOT NULL DEFAULT '0', - thumbnail INTEGER UNSIGNED NOT NULL DEFAULT '0' -); - -CREATE INDEX phpbb_attachments_filetime ON phpbb_attachments (filetime); -CREATE INDEX phpbb_attachments_post_msg_id ON phpbb_attachments (post_msg_id); -CREATE INDEX phpbb_attachments_topic_id ON phpbb_attachments (topic_id); -CREATE INDEX phpbb_attachments_poster_id ON phpbb_attachments (poster_id); -CREATE INDEX phpbb_attachments_is_orphan ON phpbb_attachments (is_orphan); - -# Table: 'phpbb_acl_groups' -CREATE TABLE phpbb_acl_groups ( - group_id INTEGER UNSIGNED NOT NULL DEFAULT '0', - forum_id INTEGER UNSIGNED NOT NULL DEFAULT '0', - auth_option_id INTEGER UNSIGNED NOT NULL DEFAULT '0', - auth_role_id INTEGER UNSIGNED NOT NULL DEFAULT '0', - auth_setting tinyint(2) NOT NULL DEFAULT '0' -); - -CREATE INDEX phpbb_acl_groups_group_id ON phpbb_acl_groups (group_id); -CREATE INDEX phpbb_acl_groups_auth_opt_id ON phpbb_acl_groups (auth_option_id); -CREATE INDEX phpbb_acl_groups_auth_role_id ON phpbb_acl_groups (auth_role_id); - -# Table: 'phpbb_acl_options' -CREATE TABLE phpbb_acl_options ( - auth_option_id INTEGER PRIMARY KEY NOT NULL , - auth_option varchar(50) NOT NULL DEFAULT '', - is_global INTEGER UNSIGNED NOT NULL DEFAULT '0', - is_local INTEGER UNSIGNED NOT NULL DEFAULT '0', - founder_only INTEGER UNSIGNED NOT NULL DEFAULT '0' -); - -CREATE UNIQUE INDEX phpbb_acl_options_auth_option ON phpbb_acl_options (auth_option); - -# Table: 'phpbb_acl_roles' -CREATE TABLE phpbb_acl_roles ( - role_id INTEGER PRIMARY KEY NOT NULL , - role_name varchar(255) NOT NULL DEFAULT '', - role_description text(65535) NOT NULL DEFAULT '', - role_type varchar(10) NOT NULL DEFAULT '', - role_order INTEGER UNSIGNED NOT NULL DEFAULT '0' -); - -CREATE INDEX phpbb_acl_roles_role_type ON phpbb_acl_roles (role_type); -CREATE INDEX phpbb_acl_roles_role_order ON phpbb_acl_roles (role_order); - -# Table: 'phpbb_acl_roles_data' -CREATE TABLE phpbb_acl_roles_data ( - role_id INTEGER UNSIGNED NOT NULL DEFAULT '0', - auth_option_id INTEGER UNSIGNED NOT NULL DEFAULT '0', - auth_setting tinyint(2) NOT NULL DEFAULT '0', - PRIMARY KEY (role_id, auth_option_id) -); - -CREATE INDEX phpbb_acl_roles_data_ath_op_id ON phpbb_acl_roles_data (auth_option_id); - -# Table: 'phpbb_acl_users' -CREATE TABLE phpbb_acl_users ( - user_id INTEGER UNSIGNED NOT NULL DEFAULT '0', - forum_id INTEGER UNSIGNED NOT NULL DEFAULT '0', - auth_option_id INTEGER UNSIGNED NOT NULL DEFAULT '0', - auth_role_id INTEGER UNSIGNED NOT NULL DEFAULT '0', - auth_setting tinyint(2) NOT NULL DEFAULT '0' -); - -CREATE INDEX phpbb_acl_users_user_id ON phpbb_acl_users (user_id); -CREATE INDEX phpbb_acl_users_auth_option_id ON phpbb_acl_users (auth_option_id); -CREATE INDEX phpbb_acl_users_auth_role_id ON phpbb_acl_users (auth_role_id); - -# Table: 'phpbb_banlist' -CREATE TABLE phpbb_banlist ( - ban_id INTEGER PRIMARY KEY NOT NULL , - ban_userid INTEGER UNSIGNED NOT NULL DEFAULT '0', - ban_ip varchar(40) NOT NULL DEFAULT '', - ban_email varchar(100) NOT NULL DEFAULT '', - ban_start INTEGER UNSIGNED NOT NULL DEFAULT '0', - ban_end INTEGER UNSIGNED NOT NULL DEFAULT '0', - ban_exclude INTEGER UNSIGNED NOT NULL DEFAULT '0', - ban_reason varchar(255) NOT NULL DEFAULT '', - ban_give_reason varchar(255) NOT NULL DEFAULT '' -); - -CREATE INDEX phpbb_banlist_ban_end ON phpbb_banlist (ban_end); -CREATE INDEX phpbb_banlist_ban_user ON phpbb_banlist (ban_userid, ban_exclude); -CREATE INDEX phpbb_banlist_ban_email ON phpbb_banlist (ban_email, ban_exclude); -CREATE INDEX phpbb_banlist_ban_ip ON phpbb_banlist (ban_ip, ban_exclude); - -# Table: 'phpbb_bbcodes' -CREATE TABLE phpbb_bbcodes ( - bbcode_id INTEGER UNSIGNED NOT NULL DEFAULT '0', - bbcode_tag varchar(16) NOT NULL DEFAULT '', - bbcode_helpline varchar(255) NOT NULL DEFAULT '', - display_on_posting INTEGER UNSIGNED NOT NULL DEFAULT '0', - bbcode_match text(65535) NOT NULL DEFAULT '', - bbcode_tpl mediumtext(16777215) NOT NULL DEFAULT '', - first_pass_match mediumtext(16777215) NOT NULL DEFAULT '', - first_pass_replace mediumtext(16777215) NOT NULL DEFAULT '', - second_pass_match mediumtext(16777215) NOT NULL DEFAULT '', - second_pass_replace mediumtext(16777215) NOT NULL DEFAULT '', - PRIMARY KEY (bbcode_id) -); - -CREATE INDEX phpbb_bbcodes_display_on_post ON phpbb_bbcodes (display_on_posting); - -# Table: 'phpbb_bookmarks' -CREATE TABLE phpbb_bookmarks ( - topic_id INTEGER UNSIGNED NOT NULL DEFAULT '0', - user_id INTEGER UNSIGNED NOT NULL DEFAULT '0', - PRIMARY KEY (topic_id, user_id) -); - - -# Table: 'phpbb_bots' -CREATE TABLE phpbb_bots ( - bot_id INTEGER PRIMARY KEY NOT NULL , - bot_active INTEGER UNSIGNED NOT NULL DEFAULT '1', - bot_name text(65535) NOT NULL DEFAULT '', - user_id INTEGER UNSIGNED NOT NULL DEFAULT '0', - bot_agent varchar(255) NOT NULL DEFAULT '', - bot_ip varchar(255) NOT NULL DEFAULT '' -); - -CREATE INDEX phpbb_bots_bot_active ON phpbb_bots (bot_active); - -# Table: 'phpbb_config' -CREATE TABLE phpbb_config ( - config_name varchar(255) NOT NULL DEFAULT '', - config_value varchar(255) NOT NULL DEFAULT '', - is_dynamic INTEGER UNSIGNED NOT NULL DEFAULT '0', - PRIMARY KEY (config_name) -); - -CREATE INDEX phpbb_config_is_dynamic ON phpbb_config (is_dynamic); - -# Table: 'phpbb_confirm' -CREATE TABLE phpbb_confirm ( - confirm_id char(32) NOT NULL DEFAULT '', - session_id char(32) NOT NULL DEFAULT '', - confirm_type tinyint(3) NOT NULL DEFAULT '0', - code varchar(8) NOT NULL DEFAULT '', - seed INTEGER UNSIGNED NOT NULL DEFAULT '0', - attempts INTEGER UNSIGNED NOT NULL DEFAULT '0', - PRIMARY KEY (session_id, confirm_id) -); - -CREATE INDEX phpbb_confirm_confirm_type ON phpbb_confirm (confirm_type); - -# Table: 'phpbb_disallow' -CREATE TABLE phpbb_disallow ( - disallow_id INTEGER PRIMARY KEY NOT NULL , - disallow_username varchar(255) NOT NULL DEFAULT '' -); - - -# Table: 'phpbb_drafts' -CREATE TABLE phpbb_drafts ( - draft_id INTEGER PRIMARY KEY NOT NULL , - user_id INTEGER UNSIGNED NOT NULL DEFAULT '0', - topic_id INTEGER UNSIGNED NOT NULL DEFAULT '0', - forum_id INTEGER UNSIGNED NOT NULL DEFAULT '0', - save_time INTEGER UNSIGNED NOT NULL DEFAULT '0', - draft_subject text(65535) NOT NULL DEFAULT '', - draft_message mediumtext(16777215) NOT NULL DEFAULT '' -); - -CREATE INDEX phpbb_drafts_save_time ON phpbb_drafts (save_time); - -# Table: 'phpbb_ext' -CREATE TABLE phpbb_ext ( - ext_name varchar(255) NOT NULL DEFAULT '', - ext_active INTEGER UNSIGNED NOT NULL DEFAULT '0', - ext_state text(65535) NOT NULL DEFAULT '' -); - -CREATE UNIQUE INDEX phpbb_ext_ext_name ON phpbb_ext (ext_name); - -# Table: 'phpbb_extensions' -CREATE TABLE phpbb_extensions ( - extension_id INTEGER PRIMARY KEY NOT NULL , - group_id INTEGER UNSIGNED NOT NULL DEFAULT '0', - extension varchar(100) NOT NULL DEFAULT '' -); - - -# Table: 'phpbb_extension_groups' -CREATE TABLE phpbb_extension_groups ( - group_id INTEGER PRIMARY KEY NOT NULL , - group_name varchar(255) NOT NULL DEFAULT '', - cat_id tinyint(2) NOT NULL DEFAULT '0', - allow_group INTEGER UNSIGNED NOT NULL DEFAULT '0', - download_mode INTEGER UNSIGNED NOT NULL DEFAULT '1', - upload_icon varchar(255) NOT NULL DEFAULT '', - max_filesize INTEGER UNSIGNED NOT NULL DEFAULT '0', - allowed_forums text(65535) NOT NULL DEFAULT '', - allow_in_pm INTEGER UNSIGNED NOT NULL DEFAULT '0' -); - - -# Table: 'phpbb_forums' -CREATE TABLE phpbb_forums ( - forum_id INTEGER PRIMARY KEY NOT NULL , - parent_id INTEGER UNSIGNED NOT NULL DEFAULT '0', - left_id INTEGER UNSIGNED NOT NULL DEFAULT '0', - right_id INTEGER UNSIGNED NOT NULL DEFAULT '0', - forum_parents mediumtext(16777215) NOT NULL DEFAULT '', - forum_name text(65535) NOT NULL DEFAULT '', - forum_desc text(65535) NOT NULL DEFAULT '', - forum_desc_bitfield varchar(255) NOT NULL DEFAULT '', - forum_desc_options INTEGER UNSIGNED NOT NULL DEFAULT '7', - forum_desc_uid varchar(8) NOT NULL DEFAULT '', - forum_link varchar(255) NOT NULL DEFAULT '', - forum_password varchar(40) NOT NULL DEFAULT '', - forum_style INTEGER UNSIGNED NOT NULL DEFAULT '0', - forum_image varchar(255) NOT NULL DEFAULT '', - forum_rules text(65535) NOT NULL DEFAULT '', - forum_rules_link varchar(255) NOT NULL DEFAULT '', - forum_rules_bitfield varchar(255) NOT NULL DEFAULT '', - forum_rules_options INTEGER UNSIGNED NOT NULL DEFAULT '7', - forum_rules_uid varchar(8) NOT NULL DEFAULT '', - forum_topics_per_page tinyint(4) NOT NULL DEFAULT '0', - forum_type tinyint(4) NOT NULL DEFAULT '0', - forum_status tinyint(4) NOT NULL DEFAULT '0', - forum_posts INTEGER UNSIGNED NOT NULL DEFAULT '0', - forum_topics INTEGER UNSIGNED NOT NULL DEFAULT '0', - forum_topics_real INTEGER UNSIGNED NOT NULL DEFAULT '0', - forum_last_post_id INTEGER UNSIGNED NOT NULL DEFAULT '0', - forum_last_poster_id INTEGER UNSIGNED NOT NULL DEFAULT '0', - forum_last_post_subject text(65535) NOT NULL DEFAULT '', - forum_last_post_time INTEGER UNSIGNED NOT NULL DEFAULT '0', - forum_last_poster_name varchar(255) NOT NULL DEFAULT '', - forum_last_poster_colour varchar(6) NOT NULL DEFAULT '', - forum_flags tinyint(4) NOT NULL DEFAULT '32', - forum_options INTEGER UNSIGNED NOT NULL DEFAULT '0', - display_subforum_list INTEGER UNSIGNED NOT NULL DEFAULT '1', - display_on_index INTEGER UNSIGNED NOT NULL DEFAULT '1', - enable_indexing INTEGER UNSIGNED NOT NULL DEFAULT '1', - enable_icons INTEGER UNSIGNED NOT NULL DEFAULT '1', - enable_prune INTEGER UNSIGNED NOT NULL DEFAULT '0', - prune_next INTEGER UNSIGNED NOT NULL DEFAULT '0', - prune_days INTEGER UNSIGNED NOT NULL DEFAULT '0', - prune_viewed INTEGER UNSIGNED NOT NULL DEFAULT '0', - prune_freq INTEGER UNSIGNED NOT NULL DEFAULT '0' -); - -CREATE INDEX phpbb_forums_left_right_id ON phpbb_forums (left_id, right_id); -CREATE INDEX phpbb_forums_forum_lastpost_id ON phpbb_forums (forum_last_post_id); - -# Table: 'phpbb_forums_access' -CREATE TABLE phpbb_forums_access ( - forum_id INTEGER UNSIGNED NOT NULL DEFAULT '0', - user_id INTEGER UNSIGNED NOT NULL DEFAULT '0', - session_id char(32) NOT NULL DEFAULT '', - PRIMARY KEY (forum_id, user_id, session_id) -); - - -# Table: 'phpbb_forums_track' -CREATE TABLE phpbb_forums_track ( - user_id INTEGER UNSIGNED NOT NULL DEFAULT '0', - forum_id INTEGER UNSIGNED NOT NULL DEFAULT '0', - mark_time INTEGER UNSIGNED NOT NULL DEFAULT '0', - PRIMARY KEY (user_id, forum_id) -); - - -# Table: 'phpbb_forums_watch' -CREATE TABLE phpbb_forums_watch ( - forum_id INTEGER UNSIGNED NOT NULL DEFAULT '0', - user_id INTEGER UNSIGNED NOT NULL DEFAULT '0', - notify_status INTEGER UNSIGNED NOT NULL DEFAULT '0' -); - -CREATE INDEX phpbb_forums_watch_forum_id ON phpbb_forums_watch (forum_id); -CREATE INDEX phpbb_forums_watch_user_id ON phpbb_forums_watch (user_id); -CREATE INDEX phpbb_forums_watch_notify_stat ON phpbb_forums_watch (notify_status); - -# Table: 'phpbb_groups' -CREATE TABLE phpbb_groups ( - group_id INTEGER PRIMARY KEY NOT NULL , - group_type tinyint(4) NOT NULL DEFAULT '1', - group_founder_manage INTEGER UNSIGNED NOT NULL DEFAULT '0', - group_skip_auth INTEGER UNSIGNED NOT NULL DEFAULT '0', - group_name varchar(255) NOT NULL DEFAULT '', - group_desc text(65535) NOT NULL DEFAULT '', - group_desc_bitfield varchar(255) NOT NULL DEFAULT '', - group_desc_options INTEGER UNSIGNED NOT NULL DEFAULT '7', - group_desc_uid varchar(8) NOT NULL DEFAULT '', - group_display INTEGER UNSIGNED NOT NULL DEFAULT '0', - group_avatar varchar(255) NOT NULL DEFAULT '', - group_avatar_type tinyint(2) NOT NULL DEFAULT '0', - group_avatar_width INTEGER UNSIGNED NOT NULL DEFAULT '0', - group_avatar_height INTEGER UNSIGNED NOT NULL DEFAULT '0', - group_rank INTEGER UNSIGNED NOT NULL DEFAULT '0', - group_colour varchar(6) NOT NULL DEFAULT '', - group_sig_chars INTEGER UNSIGNED NOT NULL DEFAULT '0', - group_receive_pm INTEGER UNSIGNED NOT NULL DEFAULT '0', - group_message_limit INTEGER UNSIGNED NOT NULL DEFAULT '0', - group_max_recipients INTEGER UNSIGNED NOT NULL DEFAULT '0', - group_legend INTEGER UNSIGNED NOT NULL DEFAULT '0', - group_teampage INTEGER UNSIGNED NOT NULL DEFAULT '0' -); - -CREATE INDEX phpbb_groups_group_legend_name ON phpbb_groups (group_legend, group_name); - -# Table: 'phpbb_icons' -CREATE TABLE phpbb_icons ( - icons_id INTEGER PRIMARY KEY NOT NULL , - icons_url varchar(255) NOT NULL DEFAULT '', - icons_width tinyint(4) NOT NULL DEFAULT '0', - icons_height tinyint(4) NOT NULL DEFAULT '0', - icons_order INTEGER UNSIGNED NOT NULL DEFAULT '0', - display_on_posting INTEGER UNSIGNED NOT NULL DEFAULT '1' -); - -CREATE INDEX phpbb_icons_display_on_posting ON phpbb_icons (display_on_posting); - -# Table: 'phpbb_lang' -CREATE TABLE phpbb_lang ( - lang_id INTEGER PRIMARY KEY NOT NULL , - lang_iso varchar(30) NOT NULL DEFAULT '', - lang_dir varchar(30) NOT NULL DEFAULT '', - lang_english_name varchar(100) NOT NULL DEFAULT '', - lang_local_name varchar(255) NOT NULL DEFAULT '', - lang_author varchar(255) NOT NULL DEFAULT '' -); - -CREATE INDEX phpbb_lang_lang_iso ON phpbb_lang (lang_iso); - -# Table: 'phpbb_log' -CREATE TABLE phpbb_log ( - log_id INTEGER PRIMARY KEY NOT NULL , - log_type tinyint(4) NOT NULL DEFAULT '0', - user_id INTEGER UNSIGNED NOT NULL DEFAULT '0', - forum_id INTEGER UNSIGNED NOT NULL DEFAULT '0', - topic_id INTEGER UNSIGNED NOT NULL DEFAULT '0', - reportee_id INTEGER UNSIGNED NOT NULL DEFAULT '0', - log_ip varchar(40) NOT NULL DEFAULT '', - log_time INTEGER UNSIGNED NOT NULL DEFAULT '0', - log_operation text(65535) NOT NULL DEFAULT '', - log_data mediumtext(16777215) NOT NULL DEFAULT '' -); - -CREATE INDEX phpbb_log_log_type ON phpbb_log (log_type); -CREATE INDEX phpbb_log_log_time ON phpbb_log (log_time); -CREATE INDEX phpbb_log_forum_id ON phpbb_log (forum_id); -CREATE INDEX phpbb_log_topic_id ON phpbb_log (topic_id); -CREATE INDEX phpbb_log_reportee_id ON phpbb_log (reportee_id); -CREATE INDEX phpbb_log_user_id ON phpbb_log (user_id); - -# Table: 'phpbb_login_attempts' -CREATE TABLE phpbb_login_attempts ( - attempt_ip varchar(40) NOT NULL DEFAULT '', - attempt_browser varchar(150) NOT NULL DEFAULT '', - attempt_forwarded_for varchar(255) NOT NULL DEFAULT '', - attempt_time INTEGER UNSIGNED NOT NULL DEFAULT '0', - user_id INTEGER UNSIGNED NOT NULL DEFAULT '0', - username varchar(255) NOT NULL DEFAULT '0', - username_clean varchar(255) NOT NULL DEFAULT '0' -); - -CREATE INDEX phpbb_login_attempts_att_ip ON phpbb_login_attempts (attempt_ip, attempt_time); -CREATE INDEX phpbb_login_attempts_att_for ON phpbb_login_attempts (attempt_forwarded_for, attempt_time); -CREATE INDEX phpbb_login_attempts_att_time ON phpbb_login_attempts (attempt_time); -CREATE INDEX phpbb_login_attempts_user_id ON phpbb_login_attempts (user_id); - -# Table: 'phpbb_moderator_cache' -CREATE TABLE phpbb_moderator_cache ( - forum_id INTEGER UNSIGNED NOT NULL DEFAULT '0', - user_id INTEGER UNSIGNED NOT NULL DEFAULT '0', - username varchar(255) NOT NULL DEFAULT '', - group_id INTEGER UNSIGNED NOT NULL DEFAULT '0', - group_name varchar(255) NOT NULL DEFAULT '', - display_on_index INTEGER UNSIGNED NOT NULL DEFAULT '1' -); - -CREATE INDEX phpbb_moderator_cache_disp_idx ON phpbb_moderator_cache (display_on_index); -CREATE INDEX phpbb_moderator_cache_forum_id ON phpbb_moderator_cache (forum_id); - -# Table: 'phpbb_modules' -CREATE TABLE phpbb_modules ( - module_id INTEGER PRIMARY KEY NOT NULL , - module_enabled INTEGER UNSIGNED NOT NULL DEFAULT '1', - module_display INTEGER UNSIGNED NOT NULL DEFAULT '1', - module_basename varchar(255) NOT NULL DEFAULT '', - module_class varchar(10) NOT NULL DEFAULT '', - parent_id INTEGER UNSIGNED NOT NULL DEFAULT '0', - left_id INTEGER UNSIGNED NOT NULL DEFAULT '0', - right_id INTEGER UNSIGNED NOT NULL DEFAULT '0', - module_langname varchar(255) NOT NULL DEFAULT '', - module_mode varchar(255) NOT NULL DEFAULT '', - module_auth varchar(255) NOT NULL DEFAULT '' -); - -CREATE INDEX phpbb_modules_left_right_id ON phpbb_modules (left_id, right_id); -CREATE INDEX phpbb_modules_module_enabled ON phpbb_modules (module_enabled); -CREATE INDEX phpbb_modules_class_left_id ON phpbb_modules (module_class, left_id); - -# Table: 'phpbb_poll_options' -CREATE TABLE phpbb_poll_options ( - poll_option_id tinyint(4) NOT NULL DEFAULT '0', - topic_id INTEGER UNSIGNED NOT NULL DEFAULT '0', - poll_option_text text(65535) NOT NULL DEFAULT '', - poll_option_total INTEGER UNSIGNED NOT NULL DEFAULT '0' -); - -CREATE INDEX phpbb_poll_options_poll_opt_id ON phpbb_poll_options (poll_option_id); -CREATE INDEX phpbb_poll_options_topic_id ON phpbb_poll_options (topic_id); - -# Table: 'phpbb_poll_votes' -CREATE TABLE phpbb_poll_votes ( - topic_id INTEGER UNSIGNED NOT NULL DEFAULT '0', - poll_option_id tinyint(4) NOT NULL DEFAULT '0', - vote_user_id INTEGER UNSIGNED NOT NULL DEFAULT '0', - vote_user_ip varchar(40) NOT NULL DEFAULT '' -); - -CREATE INDEX phpbb_poll_votes_topic_id ON phpbb_poll_votes (topic_id); -CREATE INDEX phpbb_poll_votes_vote_user_id ON phpbb_poll_votes (vote_user_id); -CREATE INDEX phpbb_poll_votes_vote_user_ip ON phpbb_poll_votes (vote_user_ip); - -# Table: 'phpbb_posts' -CREATE TABLE phpbb_posts ( - post_id INTEGER PRIMARY KEY NOT NULL , - topic_id INTEGER UNSIGNED NOT NULL DEFAULT '0', - forum_id INTEGER UNSIGNED NOT NULL DEFAULT '0', - poster_id INTEGER UNSIGNED NOT NULL DEFAULT '0', - icon_id INTEGER UNSIGNED NOT NULL DEFAULT '0', - poster_ip varchar(40) NOT NULL DEFAULT '', - post_time INTEGER UNSIGNED NOT NULL DEFAULT '0', - post_approved INTEGER UNSIGNED NOT NULL DEFAULT '1', - post_reported INTEGER UNSIGNED NOT NULL DEFAULT '0', - enable_bbcode INTEGER UNSIGNED NOT NULL DEFAULT '1', - enable_smilies INTEGER UNSIGNED NOT NULL DEFAULT '1', - enable_magic_url INTEGER UNSIGNED NOT NULL DEFAULT '1', - enable_sig INTEGER UNSIGNED NOT NULL DEFAULT '1', - post_username varchar(255) NOT NULL DEFAULT '', - post_subject text(65535) NOT NULL DEFAULT '', - post_text mediumtext(16777215) NOT NULL DEFAULT '', - post_checksum varchar(32) NOT NULL DEFAULT '', - post_attachment INTEGER UNSIGNED NOT NULL DEFAULT '0', - bbcode_bitfield varchar(255) NOT NULL DEFAULT '', - bbcode_uid varchar(8) NOT NULL DEFAULT '', - post_postcount INTEGER UNSIGNED NOT NULL DEFAULT '1', - post_edit_time INTEGER UNSIGNED NOT NULL DEFAULT '0', - post_edit_reason text(65535) NOT NULL DEFAULT '', - post_edit_user INTEGER UNSIGNED NOT NULL DEFAULT '0', - post_edit_count INTEGER UNSIGNED NOT NULL DEFAULT '0', - post_edit_locked INTEGER UNSIGNED NOT NULL DEFAULT '0' -); - -CREATE INDEX phpbb_posts_forum_id ON phpbb_posts (forum_id); -CREATE INDEX phpbb_posts_topic_id ON phpbb_posts (topic_id); -CREATE INDEX phpbb_posts_poster_ip ON phpbb_posts (poster_ip); -CREATE INDEX phpbb_posts_poster_id ON phpbb_posts (poster_id); -CREATE INDEX phpbb_posts_post_approved ON phpbb_posts (post_approved); -CREATE INDEX phpbb_posts_post_username ON phpbb_posts (post_username); -CREATE INDEX phpbb_posts_tid_post_time ON phpbb_posts (topic_id, post_time); - -# Table: 'phpbb_privmsgs' -CREATE TABLE phpbb_privmsgs ( - msg_id INTEGER PRIMARY KEY NOT NULL , - root_level INTEGER UNSIGNED NOT NULL DEFAULT '0', - author_id INTEGER UNSIGNED NOT NULL DEFAULT '0', - icon_id INTEGER UNSIGNED NOT NULL DEFAULT '0', - author_ip varchar(40) NOT NULL DEFAULT '', - message_time INTEGER UNSIGNED NOT NULL DEFAULT '0', - enable_bbcode INTEGER UNSIGNED NOT NULL DEFAULT '1', - enable_smilies INTEGER UNSIGNED NOT NULL DEFAULT '1', - enable_magic_url INTEGER UNSIGNED NOT NULL DEFAULT '1', - enable_sig INTEGER UNSIGNED NOT NULL DEFAULT '1', - message_subject text(65535) NOT NULL DEFAULT '', - message_text mediumtext(16777215) NOT NULL DEFAULT '', - message_edit_reason text(65535) NOT NULL DEFAULT '', - message_edit_user INTEGER UNSIGNED NOT NULL DEFAULT '0', - message_attachment INTEGER UNSIGNED NOT NULL DEFAULT '0', - bbcode_bitfield varchar(255) NOT NULL DEFAULT '', - bbcode_uid varchar(8) NOT NULL DEFAULT '', - message_edit_time INTEGER UNSIGNED NOT NULL DEFAULT '0', - message_edit_count INTEGER UNSIGNED NOT NULL DEFAULT '0', - to_address text(65535) NOT NULL DEFAULT '', - bcc_address text(65535) NOT NULL DEFAULT '', - message_reported INTEGER UNSIGNED NOT NULL DEFAULT '0' -); - -CREATE INDEX phpbb_privmsgs_author_ip ON phpbb_privmsgs (author_ip); -CREATE INDEX phpbb_privmsgs_message_time ON phpbb_privmsgs (message_time); -CREATE INDEX phpbb_privmsgs_author_id ON phpbb_privmsgs (author_id); -CREATE INDEX phpbb_privmsgs_root_level ON phpbb_privmsgs (root_level); - -# Table: 'phpbb_privmsgs_folder' -CREATE TABLE phpbb_privmsgs_folder ( - folder_id INTEGER PRIMARY KEY NOT NULL , - user_id INTEGER UNSIGNED NOT NULL DEFAULT '0', - folder_name varchar(255) NOT NULL DEFAULT '', - pm_count INTEGER UNSIGNED NOT NULL DEFAULT '0' -); - -CREATE INDEX phpbb_privmsgs_folder_user_id ON phpbb_privmsgs_folder (user_id); - -# Table: 'phpbb_privmsgs_rules' -CREATE TABLE phpbb_privmsgs_rules ( - rule_id INTEGER PRIMARY KEY NOT NULL , - user_id INTEGER UNSIGNED NOT NULL DEFAULT '0', - rule_check INTEGER UNSIGNED NOT NULL DEFAULT '0', - rule_connection INTEGER UNSIGNED NOT NULL DEFAULT '0', - rule_string varchar(255) NOT NULL DEFAULT '', - rule_user_id INTEGER UNSIGNED NOT NULL DEFAULT '0', - rule_group_id INTEGER UNSIGNED NOT NULL DEFAULT '0', - rule_action INTEGER UNSIGNED NOT NULL DEFAULT '0', - rule_folder_id int(11) NOT NULL DEFAULT '0' -); - -CREATE INDEX phpbb_privmsgs_rules_user_id ON phpbb_privmsgs_rules (user_id); - -# Table: 'phpbb_privmsgs_to' -CREATE TABLE phpbb_privmsgs_to ( - msg_id INTEGER UNSIGNED NOT NULL DEFAULT '0', - user_id INTEGER UNSIGNED NOT NULL DEFAULT '0', - author_id INTEGER UNSIGNED NOT NULL DEFAULT '0', - pm_deleted INTEGER UNSIGNED NOT NULL DEFAULT '0', - pm_new INTEGER UNSIGNED NOT NULL DEFAULT '1', - pm_unread INTEGER UNSIGNED NOT NULL DEFAULT '1', - pm_replied INTEGER UNSIGNED NOT NULL DEFAULT '0', - pm_marked INTEGER UNSIGNED NOT NULL DEFAULT '0', - pm_forwarded INTEGER UNSIGNED NOT NULL DEFAULT '0', - folder_id int(11) NOT NULL DEFAULT '0' -); - -CREATE INDEX phpbb_privmsgs_to_msg_id ON phpbb_privmsgs_to (msg_id); -CREATE INDEX phpbb_privmsgs_to_author_id ON phpbb_privmsgs_to (author_id); -CREATE INDEX phpbb_privmsgs_to_usr_flder_id ON phpbb_privmsgs_to (user_id, folder_id); - -# Table: 'phpbb_profile_fields' -CREATE TABLE phpbb_profile_fields ( - field_id INTEGER PRIMARY KEY NOT NULL , - field_name varchar(255) NOT NULL DEFAULT '', - field_type tinyint(4) NOT NULL DEFAULT '0', - field_ident varchar(20) NOT NULL DEFAULT '', - field_length varchar(20) NOT NULL DEFAULT '', - field_minlen varchar(255) NOT NULL DEFAULT '', - field_maxlen varchar(255) NOT NULL DEFAULT '', - field_novalue varchar(255) NOT NULL DEFAULT '', - field_default_value varchar(255) NOT NULL DEFAULT '', - field_validation varchar(20) NOT NULL DEFAULT '', - field_required INTEGER UNSIGNED NOT NULL DEFAULT '0', - field_show_novalue INTEGER UNSIGNED NOT NULL DEFAULT '0', - field_show_on_reg INTEGER UNSIGNED NOT NULL DEFAULT '0', - field_show_on_pm INTEGER UNSIGNED NOT NULL DEFAULT '0', - field_show_on_vt INTEGER UNSIGNED NOT NULL DEFAULT '0', - field_show_profile INTEGER UNSIGNED NOT NULL DEFAULT '0', - field_hide INTEGER UNSIGNED NOT NULL DEFAULT '0', - field_no_view INTEGER UNSIGNED NOT NULL DEFAULT '0', - field_active INTEGER UNSIGNED NOT NULL DEFAULT '0', - field_order INTEGER UNSIGNED NOT NULL DEFAULT '0' -); - -CREATE INDEX phpbb_profile_fields_fld_type ON phpbb_profile_fields (field_type); -CREATE INDEX phpbb_profile_fields_fld_ordr ON phpbb_profile_fields (field_order); - -# Table: 'phpbb_profile_fields_data' -CREATE TABLE phpbb_profile_fields_data ( - user_id INTEGER UNSIGNED NOT NULL DEFAULT '0', - PRIMARY KEY (user_id) -); - - -# Table: 'phpbb_profile_fields_lang' -CREATE TABLE phpbb_profile_fields_lang ( - field_id INTEGER UNSIGNED NOT NULL DEFAULT '0', - lang_id INTEGER UNSIGNED NOT NULL DEFAULT '0', - option_id INTEGER UNSIGNED NOT NULL DEFAULT '0', - field_type tinyint(4) NOT NULL DEFAULT '0', - lang_value varchar(255) NOT NULL DEFAULT '', - PRIMARY KEY (field_id, lang_id, option_id) -); - - -# Table: 'phpbb_profile_lang' -CREATE TABLE phpbb_profile_lang ( - field_id INTEGER UNSIGNED NOT NULL DEFAULT '0', - lang_id INTEGER UNSIGNED NOT NULL DEFAULT '0', - lang_name varchar(255) NOT NULL DEFAULT '', - lang_explain text(65535) NOT NULL DEFAULT '', - lang_default_value varchar(255) NOT NULL DEFAULT '', - PRIMARY KEY (field_id, lang_id) -); - - -# Table: 'phpbb_ranks' -CREATE TABLE phpbb_ranks ( - rank_id INTEGER PRIMARY KEY NOT NULL , - rank_title varchar(255) NOT NULL DEFAULT '', - rank_min INTEGER UNSIGNED NOT NULL DEFAULT '0', - rank_special INTEGER UNSIGNED NOT NULL DEFAULT '0', - rank_image varchar(255) NOT NULL DEFAULT '' -); - - -# Table: 'phpbb_reports' -CREATE TABLE phpbb_reports ( - report_id INTEGER PRIMARY KEY NOT NULL , - reason_id INTEGER UNSIGNED NOT NULL DEFAULT '0', - post_id INTEGER UNSIGNED NOT NULL DEFAULT '0', - pm_id INTEGER UNSIGNED NOT NULL DEFAULT '0', - user_id INTEGER UNSIGNED NOT NULL DEFAULT '0', - user_notify INTEGER UNSIGNED NOT NULL DEFAULT '0', - report_closed INTEGER UNSIGNED NOT NULL DEFAULT '0', - report_time INTEGER UNSIGNED NOT NULL DEFAULT '0', - report_text mediumtext(16777215) NOT NULL DEFAULT '', - reported_post_text mediumtext(16777215) NOT NULL DEFAULT '' -); - -CREATE INDEX phpbb_reports_post_id ON phpbb_reports (post_id); -CREATE INDEX phpbb_reports_pm_id ON phpbb_reports (pm_id); - -# Table: 'phpbb_reports_reasons' -CREATE TABLE phpbb_reports_reasons ( - reason_id INTEGER PRIMARY KEY NOT NULL , - reason_title varchar(255) NOT NULL DEFAULT '', - reason_description mediumtext(16777215) NOT NULL DEFAULT '', - reason_order INTEGER UNSIGNED NOT NULL DEFAULT '0' -); - - -# Table: 'phpbb_search_results' -CREATE TABLE phpbb_search_results ( - search_key varchar(32) NOT NULL DEFAULT '', - search_time INTEGER UNSIGNED NOT NULL DEFAULT '0', - search_keywords mediumtext(16777215) NOT NULL DEFAULT '', - search_authors mediumtext(16777215) NOT NULL DEFAULT '', - PRIMARY KEY (search_key) -); - - -# Table: 'phpbb_search_wordlist' -CREATE TABLE phpbb_search_wordlist ( - word_id INTEGER PRIMARY KEY NOT NULL , - word_text varchar(255) NOT NULL DEFAULT '', - word_common INTEGER UNSIGNED NOT NULL DEFAULT '0', - word_count INTEGER UNSIGNED NOT NULL DEFAULT '0' -); - -CREATE UNIQUE INDEX phpbb_search_wordlist_wrd_txt ON phpbb_search_wordlist (word_text); -CREATE INDEX phpbb_search_wordlist_wrd_cnt ON phpbb_search_wordlist (word_count); - -# Table: 'phpbb_search_wordmatch' -CREATE TABLE phpbb_search_wordmatch ( - post_id INTEGER UNSIGNED NOT NULL DEFAULT '0', - word_id INTEGER UNSIGNED NOT NULL DEFAULT '0', - title_match INTEGER UNSIGNED NOT NULL DEFAULT '0' -); - -CREATE UNIQUE INDEX phpbb_search_wordmatch_unq_mtch ON phpbb_search_wordmatch (word_id, post_id, title_match); -CREATE INDEX phpbb_search_wordmatch_word_id ON phpbb_search_wordmatch (word_id); -CREATE INDEX phpbb_search_wordmatch_post_id ON phpbb_search_wordmatch (post_id); - -# Table: 'phpbb_sessions' -CREATE TABLE phpbb_sessions ( - session_id char(32) NOT NULL DEFAULT '', - session_user_id INTEGER UNSIGNED NOT NULL DEFAULT '0', - session_forum_id INTEGER UNSIGNED NOT NULL DEFAULT '0', - session_last_visit INTEGER UNSIGNED NOT NULL DEFAULT '0', - session_start INTEGER UNSIGNED NOT NULL DEFAULT '0', - session_time INTEGER UNSIGNED NOT NULL DEFAULT '0', - session_ip varchar(40) NOT NULL DEFAULT '', - session_browser varchar(150) NOT NULL DEFAULT '', - session_forwarded_for varchar(255) NOT NULL DEFAULT '', - session_page varchar(255) NOT NULL DEFAULT '', - session_viewonline INTEGER UNSIGNED NOT NULL DEFAULT '1', - session_autologin INTEGER UNSIGNED NOT NULL DEFAULT '0', - session_admin INTEGER UNSIGNED NOT NULL DEFAULT '0', - PRIMARY KEY (session_id) -); - -CREATE INDEX phpbb_sessions_session_time ON phpbb_sessions (session_time); -CREATE INDEX phpbb_sessions_session_user_id ON phpbb_sessions (session_user_id); -CREATE INDEX phpbb_sessions_session_fid ON phpbb_sessions (session_forum_id); - -# Table: 'phpbb_sessions_keys' -CREATE TABLE phpbb_sessions_keys ( - key_id char(32) NOT NULL DEFAULT '', - user_id INTEGER UNSIGNED NOT NULL DEFAULT '0', - last_ip varchar(40) NOT NULL DEFAULT '', - last_login INTEGER UNSIGNED NOT NULL DEFAULT '0', - PRIMARY KEY (key_id, user_id) -); - -CREATE INDEX phpbb_sessions_keys_last_login ON phpbb_sessions_keys (last_login); - -# Table: 'phpbb_sitelist' -CREATE TABLE phpbb_sitelist ( - site_id INTEGER PRIMARY KEY NOT NULL , - site_ip varchar(40) NOT NULL DEFAULT '', - site_hostname varchar(255) NOT NULL DEFAULT '', - ip_exclude INTEGER UNSIGNED NOT NULL DEFAULT '0' -); - - -# Table: 'phpbb_smilies' -CREATE TABLE phpbb_smilies ( - smiley_id INTEGER PRIMARY KEY NOT NULL , - code varchar(50) NOT NULL DEFAULT '', - emotion varchar(50) NOT NULL DEFAULT '', - smiley_url varchar(50) NOT NULL DEFAULT '', - smiley_width INTEGER UNSIGNED NOT NULL DEFAULT '0', - smiley_height INTEGER UNSIGNED NOT NULL DEFAULT '0', - smiley_order INTEGER UNSIGNED NOT NULL DEFAULT '0', - display_on_posting INTEGER UNSIGNED NOT NULL DEFAULT '1' -); - -CREATE INDEX phpbb_smilies_display_on_post ON phpbb_smilies (display_on_posting); - -# Table: 'phpbb_styles' -CREATE TABLE phpbb_styles ( - style_id INTEGER PRIMARY KEY NOT NULL , - style_name varchar(255) NOT NULL DEFAULT '', - style_copyright varchar(255) NOT NULL DEFAULT '', - style_active INTEGER UNSIGNED NOT NULL DEFAULT '1', - style_path varchar(100) NOT NULL DEFAULT '', - bbcode_bitfield varchar(255) NOT NULL DEFAULT 'kNg=', - style_parent_id INTEGER UNSIGNED NOT NULL DEFAULT '0', - style_parent_tree text(65535) NOT NULL DEFAULT '' -); - -CREATE UNIQUE INDEX phpbb_styles_style_name ON phpbb_styles (style_name); - -# Table: 'phpbb_topics' -CREATE TABLE phpbb_topics ( - topic_id INTEGER PRIMARY KEY NOT NULL , - forum_id INTEGER UNSIGNED NOT NULL DEFAULT '0', - icon_id INTEGER UNSIGNED NOT NULL DEFAULT '0', - topic_attachment INTEGER UNSIGNED NOT NULL DEFAULT '0', - topic_approved INTEGER UNSIGNED NOT NULL DEFAULT '1', - topic_reported INTEGER UNSIGNED NOT NULL DEFAULT '0', - topic_title text(65535) NOT NULL DEFAULT '', - topic_poster INTEGER UNSIGNED NOT NULL DEFAULT '0', - topic_time INTEGER UNSIGNED NOT NULL DEFAULT '0', - topic_time_limit INTEGER UNSIGNED NOT NULL DEFAULT '0', - topic_views INTEGER UNSIGNED NOT NULL DEFAULT '0', - topic_replies INTEGER UNSIGNED NOT NULL DEFAULT '0', - topic_replies_real INTEGER UNSIGNED NOT NULL DEFAULT '0', - topic_status tinyint(3) NOT NULL DEFAULT '0', - topic_type tinyint(3) NOT NULL DEFAULT '0', - topic_first_post_id INTEGER UNSIGNED NOT NULL DEFAULT '0', - topic_first_poster_name varchar(255) NOT NULL DEFAULT '', - topic_first_poster_colour varchar(6) NOT NULL DEFAULT '', - topic_last_post_id INTEGER UNSIGNED NOT NULL DEFAULT '0', - topic_last_poster_id INTEGER UNSIGNED NOT NULL DEFAULT '0', - topic_last_poster_name varchar(255) NOT NULL DEFAULT '', - topic_last_poster_colour varchar(6) NOT NULL DEFAULT '', - topic_last_post_subject text(65535) NOT NULL DEFAULT '', - topic_last_post_time INTEGER UNSIGNED NOT NULL DEFAULT '0', - topic_last_view_time INTEGER UNSIGNED NOT NULL DEFAULT '0', - topic_moved_id INTEGER UNSIGNED NOT NULL DEFAULT '0', - topic_bumped INTEGER UNSIGNED NOT NULL DEFAULT '0', - topic_bumper INTEGER UNSIGNED NOT NULL DEFAULT '0', - poll_title text(65535) NOT NULL DEFAULT '', - poll_start INTEGER UNSIGNED NOT NULL DEFAULT '0', - poll_length INTEGER UNSIGNED NOT NULL DEFAULT '0', - poll_max_options tinyint(4) NOT NULL DEFAULT '1', - poll_last_vote INTEGER UNSIGNED NOT NULL DEFAULT '0', - poll_vote_change INTEGER UNSIGNED NOT NULL DEFAULT '0' -); - -CREATE INDEX phpbb_topics_forum_id ON phpbb_topics (forum_id); -CREATE INDEX phpbb_topics_forum_id_type ON phpbb_topics (forum_id, topic_type); -CREATE INDEX phpbb_topics_last_post_time ON phpbb_topics (topic_last_post_time); -CREATE INDEX phpbb_topics_topic_approved ON phpbb_topics (topic_approved); -CREATE INDEX phpbb_topics_forum_appr_last ON phpbb_topics (forum_id, topic_approved, topic_last_post_id); -CREATE INDEX phpbb_topics_fid_time_moved ON phpbb_topics (forum_id, topic_last_post_time, topic_moved_id); - -# Table: 'phpbb_topics_track' -CREATE TABLE phpbb_topics_track ( - user_id INTEGER UNSIGNED NOT NULL DEFAULT '0', - topic_id INTEGER UNSIGNED NOT NULL DEFAULT '0', - forum_id INTEGER UNSIGNED NOT NULL DEFAULT '0', - mark_time INTEGER UNSIGNED NOT NULL DEFAULT '0', - PRIMARY KEY (user_id, topic_id) -); - -CREATE INDEX phpbb_topics_track_topic_id ON phpbb_topics_track (topic_id); -CREATE INDEX phpbb_topics_track_forum_id ON phpbb_topics_track (forum_id); - -# Table: 'phpbb_topics_posted' -CREATE TABLE phpbb_topics_posted ( - user_id INTEGER UNSIGNED NOT NULL DEFAULT '0', - topic_id INTEGER UNSIGNED NOT NULL DEFAULT '0', - topic_posted INTEGER UNSIGNED NOT NULL DEFAULT '0', - PRIMARY KEY (user_id, topic_id) -); - - -# Table: 'phpbb_topics_watch' -CREATE TABLE phpbb_topics_watch ( - topic_id INTEGER UNSIGNED NOT NULL DEFAULT '0', - user_id INTEGER UNSIGNED NOT NULL DEFAULT '0', - notify_status INTEGER UNSIGNED NOT NULL DEFAULT '0' -); - -CREATE INDEX phpbb_topics_watch_topic_id ON phpbb_topics_watch (topic_id); -CREATE INDEX phpbb_topics_watch_user_id ON phpbb_topics_watch (user_id); -CREATE INDEX phpbb_topics_watch_notify_stat ON phpbb_topics_watch (notify_status); - -# Table: 'phpbb_user_group' -CREATE TABLE phpbb_user_group ( - group_id INTEGER UNSIGNED NOT NULL DEFAULT '0', - user_id INTEGER UNSIGNED NOT NULL DEFAULT '0', - group_leader INTEGER UNSIGNED NOT NULL DEFAULT '0', - user_pending INTEGER UNSIGNED NOT NULL DEFAULT '1' -); - -CREATE INDEX phpbb_user_group_group_id ON phpbb_user_group (group_id); -CREATE INDEX phpbb_user_group_user_id ON phpbb_user_group (user_id); -CREATE INDEX phpbb_user_group_group_leader ON phpbb_user_group (group_leader); - -# Table: 'phpbb_users' -CREATE TABLE phpbb_users ( - user_id INTEGER PRIMARY KEY NOT NULL , - user_type tinyint(2) NOT NULL DEFAULT '0', - group_id INTEGER UNSIGNED NOT NULL DEFAULT '3', - user_permissions mediumtext(16777215) NOT NULL DEFAULT '', - user_perm_from INTEGER UNSIGNED NOT NULL DEFAULT '0', - user_ip varchar(40) NOT NULL DEFAULT '', - user_regdate INTEGER UNSIGNED NOT NULL DEFAULT '0', - username varchar(255) NOT NULL DEFAULT '', - username_clean varchar(255) NOT NULL DEFAULT '', - user_password varchar(40) NOT NULL DEFAULT '', - user_passchg INTEGER UNSIGNED NOT NULL DEFAULT '0', - user_pass_convert INTEGER UNSIGNED NOT NULL DEFAULT '0', - user_email varchar(100) NOT NULL DEFAULT '', - user_email_hash bigint(20) NOT NULL DEFAULT '0', - user_birthday varchar(10) NOT NULL DEFAULT '', - user_lastvisit INTEGER UNSIGNED NOT NULL DEFAULT '0', - user_lastmark INTEGER UNSIGNED NOT NULL DEFAULT '0', - user_lastpost_time INTEGER UNSIGNED NOT NULL DEFAULT '0', - user_lastpage varchar(200) NOT NULL DEFAULT '', - user_last_confirm_key varchar(10) NOT NULL DEFAULT '', - user_last_search INTEGER UNSIGNED NOT NULL DEFAULT '0', - user_warnings tinyint(4) NOT NULL DEFAULT '0', - user_last_warning INTEGER UNSIGNED NOT NULL DEFAULT '0', - user_login_attempts tinyint(4) NOT NULL DEFAULT '0', - user_inactive_reason tinyint(2) NOT NULL DEFAULT '0', - user_inactive_time INTEGER UNSIGNED NOT NULL DEFAULT '0', - user_posts INTEGER UNSIGNED NOT NULL DEFAULT '0', - user_lang varchar(30) NOT NULL DEFAULT '', - user_timezone varchar(100) NOT NULL DEFAULT 'UTC', - user_dateformat varchar(30) NOT NULL DEFAULT 'd M Y H:i', - user_style INTEGER UNSIGNED NOT NULL DEFAULT '0', - user_rank INTEGER UNSIGNED NOT NULL DEFAULT '0', - user_colour varchar(6) NOT NULL DEFAULT '', - user_new_privmsg int(4) NOT NULL DEFAULT '0', - user_unread_privmsg int(4) NOT NULL DEFAULT '0', - user_last_privmsg INTEGER UNSIGNED NOT NULL DEFAULT '0', - user_message_rules INTEGER UNSIGNED NOT NULL DEFAULT '0', - user_full_folder int(11) NOT NULL DEFAULT '-3', - user_emailtime INTEGER UNSIGNED NOT NULL DEFAULT '0', - user_topic_show_days INTEGER UNSIGNED NOT NULL DEFAULT '0', - user_topic_sortby_type varchar(1) NOT NULL DEFAULT 't', - user_topic_sortby_dir varchar(1) NOT NULL DEFAULT 'd', - user_post_show_days INTEGER UNSIGNED NOT NULL DEFAULT '0', - user_post_sortby_type varchar(1) NOT NULL DEFAULT 't', - user_post_sortby_dir varchar(1) NOT NULL DEFAULT 'a', - user_notify INTEGER UNSIGNED NOT NULL DEFAULT '0', - user_notify_pm INTEGER UNSIGNED NOT NULL DEFAULT '1', - user_notify_type tinyint(4) NOT NULL DEFAULT '0', - user_allow_pm INTEGER UNSIGNED NOT NULL DEFAULT '1', - user_allow_viewonline INTEGER UNSIGNED NOT NULL DEFAULT '1', - user_allow_viewemail INTEGER UNSIGNED NOT NULL DEFAULT '1', - user_allow_massemail INTEGER UNSIGNED NOT NULL DEFAULT '1', - user_options INTEGER UNSIGNED NOT NULL DEFAULT '230271', - user_avatar varchar(255) NOT NULL DEFAULT '', - user_avatar_type tinyint(2) NOT NULL DEFAULT '0', - user_avatar_width INTEGER UNSIGNED NOT NULL DEFAULT '0', - user_avatar_height INTEGER UNSIGNED NOT NULL DEFAULT '0', - user_sig mediumtext(16777215) NOT NULL DEFAULT '', - user_sig_bbcode_uid varchar(8) NOT NULL DEFAULT '', - user_sig_bbcode_bitfield varchar(255) NOT NULL DEFAULT '', - user_from varchar(100) NOT NULL DEFAULT '', - user_icq varchar(15) NOT NULL DEFAULT '', - user_aim varchar(255) NOT NULL DEFAULT '', - user_yim varchar(255) NOT NULL DEFAULT '', - user_msnm varchar(255) NOT NULL DEFAULT '', - user_jabber varchar(255) NOT NULL DEFAULT '', - user_website varchar(200) NOT NULL DEFAULT '', - user_occ text(65535) NOT NULL DEFAULT '', - user_interests text(65535) NOT NULL DEFAULT '', - user_actkey varchar(32) NOT NULL DEFAULT '', - user_newpasswd varchar(40) NOT NULL DEFAULT '', - user_form_salt varchar(32) NOT NULL DEFAULT '', - user_new INTEGER UNSIGNED NOT NULL DEFAULT '1', - user_reminded tinyint(4) NOT NULL DEFAULT '0', - user_reminded_time INTEGER UNSIGNED NOT NULL DEFAULT '0' -); - -CREATE INDEX phpbb_users_user_birthday ON phpbb_users (user_birthday); -CREATE INDEX phpbb_users_user_email_hash ON phpbb_users (user_email_hash); -CREATE INDEX phpbb_users_user_type ON phpbb_users (user_type); -CREATE UNIQUE INDEX phpbb_users_username_clean ON phpbb_users (username_clean); - -# Table: 'phpbb_warnings' -CREATE TABLE phpbb_warnings ( - warning_id INTEGER PRIMARY KEY NOT NULL , - user_id INTEGER UNSIGNED NOT NULL DEFAULT '0', - post_id INTEGER UNSIGNED NOT NULL DEFAULT '0', - log_id INTEGER UNSIGNED NOT NULL DEFAULT '0', - warning_time INTEGER UNSIGNED NOT NULL DEFAULT '0' -); - - -# Table: 'phpbb_words' -CREATE TABLE phpbb_words ( - word_id INTEGER PRIMARY KEY NOT NULL , - word varchar(255) NOT NULL DEFAULT '', - replacement varchar(255) NOT NULL DEFAULT '' -); - - -# Table: 'phpbb_zebra' -CREATE TABLE phpbb_zebra ( - user_id INTEGER UNSIGNED NOT NULL DEFAULT '0', - zebra_id INTEGER UNSIGNED NOT NULL DEFAULT '0', - friend INTEGER UNSIGNED NOT NULL DEFAULT '0', - foe INTEGER UNSIGNED NOT NULL DEFAULT '0', - PRIMARY KEY (user_id, zebra_id) -); - - - -COMMIT; \ No newline at end of file +# DO NOT EDIT THIS FILE, IT IS GENERATED +# +# To change the contents of this file, edit +# phpBB/develop/create_schema_files.php and +# run it. +BEGIN TRANSACTION; + +# Table: 'phpbb_attachments' +CREATE TABLE phpbb_attachments ( + attach_id INTEGER PRIMARY KEY NOT NULL , + post_msg_id INTEGER UNSIGNED NOT NULL DEFAULT '0', + topic_id INTEGER UNSIGNED NOT NULL DEFAULT '0', + in_message INTEGER UNSIGNED NOT NULL DEFAULT '0', + poster_id INTEGER UNSIGNED NOT NULL DEFAULT '0', + is_orphan INTEGER UNSIGNED NOT NULL DEFAULT '1', + physical_filename varchar(255) NOT NULL DEFAULT '', + real_filename varchar(255) NOT NULL DEFAULT '', + download_count INTEGER UNSIGNED NOT NULL DEFAULT '0', + attach_comment text(65535) NOT NULL DEFAULT '', + extension varchar(100) NOT NULL DEFAULT '', + mimetype varchar(100) NOT NULL DEFAULT '', + filesize INTEGER UNSIGNED NOT NULL DEFAULT '0', + filetime INTEGER UNSIGNED NOT NULL DEFAULT '0', + thumbnail INTEGER UNSIGNED NOT NULL DEFAULT '0' +); + +CREATE INDEX phpbb_attachments_filetime ON phpbb_attachments (filetime); +CREATE INDEX phpbb_attachments_post_msg_id ON phpbb_attachments (post_msg_id); +CREATE INDEX phpbb_attachments_topic_id ON phpbb_attachments (topic_id); +CREATE INDEX phpbb_attachments_poster_id ON phpbb_attachments (poster_id); +CREATE INDEX phpbb_attachments_is_orphan ON phpbb_attachments (is_orphan); + +# Table: 'phpbb_acl_groups' +CREATE TABLE phpbb_acl_groups ( + group_id INTEGER UNSIGNED NOT NULL DEFAULT '0', + forum_id INTEGER UNSIGNED NOT NULL DEFAULT '0', + auth_option_id INTEGER UNSIGNED NOT NULL DEFAULT '0', + auth_role_id INTEGER UNSIGNED NOT NULL DEFAULT '0', + auth_setting tinyint(2) NOT NULL DEFAULT '0' +); + +CREATE INDEX phpbb_acl_groups_group_id ON phpbb_acl_groups (group_id); +CREATE INDEX phpbb_acl_groups_auth_opt_id ON phpbb_acl_groups (auth_option_id); +CREATE INDEX phpbb_acl_groups_auth_role_id ON phpbb_acl_groups (auth_role_id); + +# Table: 'phpbb_acl_options' +CREATE TABLE phpbb_acl_options ( + auth_option_id INTEGER PRIMARY KEY NOT NULL , + auth_option varchar(50) NOT NULL DEFAULT '', + is_global INTEGER UNSIGNED NOT NULL DEFAULT '0', + is_local INTEGER UNSIGNED NOT NULL DEFAULT '0', + founder_only INTEGER UNSIGNED NOT NULL DEFAULT '0' +); + +CREATE UNIQUE INDEX phpbb_acl_options_auth_option ON phpbb_acl_options (auth_option); + +# Table: 'phpbb_acl_roles' +CREATE TABLE phpbb_acl_roles ( + role_id INTEGER PRIMARY KEY NOT NULL , + role_name varchar(255) NOT NULL DEFAULT '', + role_description text(65535) NOT NULL DEFAULT '', + role_type varchar(10) NOT NULL DEFAULT '', + role_order INTEGER UNSIGNED NOT NULL DEFAULT '0' +); + +CREATE INDEX phpbb_acl_roles_role_type ON phpbb_acl_roles (role_type); +CREATE INDEX phpbb_acl_roles_role_order ON phpbb_acl_roles (role_order); + +# Table: 'phpbb_acl_roles_data' +CREATE TABLE phpbb_acl_roles_data ( + role_id INTEGER UNSIGNED NOT NULL DEFAULT '0', + auth_option_id INTEGER UNSIGNED NOT NULL DEFAULT '0', + auth_setting tinyint(2) NOT NULL DEFAULT '0', + PRIMARY KEY (role_id, auth_option_id) +); + +CREATE INDEX phpbb_acl_roles_data_ath_op_id ON phpbb_acl_roles_data (auth_option_id); + +# Table: 'phpbb_acl_users' +CREATE TABLE phpbb_acl_users ( + user_id INTEGER UNSIGNED NOT NULL DEFAULT '0', + forum_id INTEGER UNSIGNED NOT NULL DEFAULT '0', + auth_option_id INTEGER UNSIGNED NOT NULL DEFAULT '0', + auth_role_id INTEGER UNSIGNED NOT NULL DEFAULT '0', + auth_setting tinyint(2) NOT NULL DEFAULT '0' +); + +CREATE INDEX phpbb_acl_users_user_id ON phpbb_acl_users (user_id); +CREATE INDEX phpbb_acl_users_auth_option_id ON phpbb_acl_users (auth_option_id); +CREATE INDEX phpbb_acl_users_auth_role_id ON phpbb_acl_users (auth_role_id); + +# Table: 'phpbb_banlist' +CREATE TABLE phpbb_banlist ( + ban_id INTEGER PRIMARY KEY NOT NULL , + ban_userid INTEGER UNSIGNED NOT NULL DEFAULT '0', + ban_ip varchar(40) NOT NULL DEFAULT '', + ban_email varchar(100) NOT NULL DEFAULT '', + ban_start INTEGER UNSIGNED NOT NULL DEFAULT '0', + ban_end INTEGER UNSIGNED NOT NULL DEFAULT '0', + ban_exclude INTEGER UNSIGNED NOT NULL DEFAULT '0', + ban_reason varchar(255) NOT NULL DEFAULT '', + ban_give_reason varchar(255) NOT NULL DEFAULT '' +); + +CREATE INDEX phpbb_banlist_ban_end ON phpbb_banlist (ban_end); +CREATE INDEX phpbb_banlist_ban_user ON phpbb_banlist (ban_userid, ban_exclude); +CREATE INDEX phpbb_banlist_ban_email ON phpbb_banlist (ban_email, ban_exclude); +CREATE INDEX phpbb_banlist_ban_ip ON phpbb_banlist (ban_ip, ban_exclude); + +# Table: 'phpbb_bbcodes' +CREATE TABLE phpbb_bbcodes ( + bbcode_id INTEGER UNSIGNED NOT NULL DEFAULT '0', + bbcode_tag varchar(16) NOT NULL DEFAULT '', + bbcode_helpline varchar(255) NOT NULL DEFAULT '', + display_on_posting INTEGER UNSIGNED NOT NULL DEFAULT '0', + bbcode_match text(65535) NOT NULL DEFAULT '', + bbcode_tpl mediumtext(16777215) NOT NULL DEFAULT '', + first_pass_match mediumtext(16777215) NOT NULL DEFAULT '', + first_pass_replace mediumtext(16777215) NOT NULL DEFAULT '', + second_pass_match mediumtext(16777215) NOT NULL DEFAULT '', + second_pass_replace mediumtext(16777215) NOT NULL DEFAULT '', + PRIMARY KEY (bbcode_id) +); + +CREATE INDEX phpbb_bbcodes_display_on_post ON phpbb_bbcodes (display_on_posting); + +# Table: 'phpbb_bookmarks' +CREATE TABLE phpbb_bookmarks ( + topic_id INTEGER UNSIGNED NOT NULL DEFAULT '0', + user_id INTEGER UNSIGNED NOT NULL DEFAULT '0', + PRIMARY KEY (topic_id, user_id) +); + + +# Table: 'phpbb_bots' +CREATE TABLE phpbb_bots ( + bot_id INTEGER PRIMARY KEY NOT NULL , + bot_active INTEGER UNSIGNED NOT NULL DEFAULT '1', + bot_name text(65535) NOT NULL DEFAULT '', + user_id INTEGER UNSIGNED NOT NULL DEFAULT '0', + bot_agent varchar(255) NOT NULL DEFAULT '', + bot_ip varchar(255) NOT NULL DEFAULT '' +); + +CREATE INDEX phpbb_bots_bot_active ON phpbb_bots (bot_active); + +# Table: 'phpbb_config' +CREATE TABLE phpbb_config ( + config_name varchar(255) NOT NULL DEFAULT '', + config_value varchar(255) NOT NULL DEFAULT '', + is_dynamic INTEGER UNSIGNED NOT NULL DEFAULT '0', + PRIMARY KEY (config_name) +); + +CREATE INDEX phpbb_config_is_dynamic ON phpbb_config (is_dynamic); + +# Table: 'phpbb_confirm' +CREATE TABLE phpbb_confirm ( + confirm_id char(32) NOT NULL DEFAULT '', + session_id char(32) NOT NULL DEFAULT '', + confirm_type tinyint(3) NOT NULL DEFAULT '0', + code varchar(8) NOT NULL DEFAULT '', + seed INTEGER UNSIGNED NOT NULL DEFAULT '0', + attempts INTEGER UNSIGNED NOT NULL DEFAULT '0', + PRIMARY KEY (session_id, confirm_id) +); + +CREATE INDEX phpbb_confirm_confirm_type ON phpbb_confirm (confirm_type); + +# Table: 'phpbb_disallow' +CREATE TABLE phpbb_disallow ( + disallow_id INTEGER PRIMARY KEY NOT NULL , + disallow_username varchar(255) NOT NULL DEFAULT '' +); + + +# Table: 'phpbb_drafts' +CREATE TABLE phpbb_drafts ( + draft_id INTEGER PRIMARY KEY NOT NULL , + user_id INTEGER UNSIGNED NOT NULL DEFAULT '0', + topic_id INTEGER UNSIGNED NOT NULL DEFAULT '0', + forum_id INTEGER UNSIGNED NOT NULL DEFAULT '0', + save_time INTEGER UNSIGNED NOT NULL DEFAULT '0', + draft_subject text(65535) NOT NULL DEFAULT '', + draft_message mediumtext(16777215) NOT NULL DEFAULT '' +); + +CREATE INDEX phpbb_drafts_save_time ON phpbb_drafts (save_time); + +# Table: 'phpbb_ext' +CREATE TABLE phpbb_ext ( + ext_name varchar(255) NOT NULL DEFAULT '', + ext_active INTEGER UNSIGNED NOT NULL DEFAULT '0', + ext_state text(65535) NOT NULL DEFAULT '' +); + +CREATE UNIQUE INDEX phpbb_ext_ext_name ON phpbb_ext (ext_name); + +# Table: 'phpbb_extensions' +CREATE TABLE phpbb_extensions ( + extension_id INTEGER PRIMARY KEY NOT NULL , + group_id INTEGER UNSIGNED NOT NULL DEFAULT '0', + extension varchar(100) NOT NULL DEFAULT '' +); + + +# Table: 'phpbb_extension_groups' +CREATE TABLE phpbb_extension_groups ( + group_id INTEGER PRIMARY KEY NOT NULL , + group_name varchar(255) NOT NULL DEFAULT '', + cat_id tinyint(2) NOT NULL DEFAULT '0', + allow_group INTEGER UNSIGNED NOT NULL DEFAULT '0', + download_mode INTEGER UNSIGNED NOT NULL DEFAULT '1', + upload_icon varchar(255) NOT NULL DEFAULT '', + max_filesize INTEGER UNSIGNED NOT NULL DEFAULT '0', + allowed_forums text(65535) NOT NULL DEFAULT '', + allow_in_pm INTEGER UNSIGNED NOT NULL DEFAULT '0' +); + + +# Table: 'phpbb_forums' +CREATE TABLE phpbb_forums ( + forum_id INTEGER PRIMARY KEY NOT NULL , + parent_id INTEGER UNSIGNED NOT NULL DEFAULT '0', + left_id INTEGER UNSIGNED NOT NULL DEFAULT '0', + right_id INTEGER UNSIGNED NOT NULL DEFAULT '0', + forum_parents mediumtext(16777215) NOT NULL DEFAULT '', + forum_name text(65535) NOT NULL DEFAULT '', + forum_desc text(65535) NOT NULL DEFAULT '', + forum_desc_bitfield varchar(255) NOT NULL DEFAULT '', + forum_desc_options INTEGER UNSIGNED NOT NULL DEFAULT '7', + forum_desc_uid varchar(8) NOT NULL DEFAULT '', + forum_link varchar(255) NOT NULL DEFAULT '', + forum_password varchar(40) NOT NULL DEFAULT '', + forum_style INTEGER UNSIGNED NOT NULL DEFAULT '0', + forum_image varchar(255) NOT NULL DEFAULT '', + forum_rules text(65535) NOT NULL DEFAULT '', + forum_rules_link varchar(255) NOT NULL DEFAULT '', + forum_rules_bitfield varchar(255) NOT NULL DEFAULT '', + forum_rules_options INTEGER UNSIGNED NOT NULL DEFAULT '7', + forum_rules_uid varchar(8) NOT NULL DEFAULT '', + forum_topics_per_page tinyint(4) NOT NULL DEFAULT '0', + forum_type tinyint(4) NOT NULL DEFAULT '0', + forum_status tinyint(4) NOT NULL DEFAULT '0', + forum_posts INTEGER UNSIGNED NOT NULL DEFAULT '0', + forum_topics INTEGER UNSIGNED NOT NULL DEFAULT '0', + forum_topics_real INTEGER UNSIGNED NOT NULL DEFAULT '0', + forum_last_post_id INTEGER UNSIGNED NOT NULL DEFAULT '0', + forum_last_poster_id INTEGER UNSIGNED NOT NULL DEFAULT '0', + forum_last_post_subject text(65535) NOT NULL DEFAULT '', + forum_last_post_time INTEGER UNSIGNED NOT NULL DEFAULT '0', + forum_last_poster_name varchar(255) NOT NULL DEFAULT '', + forum_last_poster_colour varchar(6) NOT NULL DEFAULT '', + forum_flags tinyint(4) NOT NULL DEFAULT '32', + forum_options INTEGER UNSIGNED NOT NULL DEFAULT '0', + display_subforum_list INTEGER UNSIGNED NOT NULL DEFAULT '1', + display_on_index INTEGER UNSIGNED NOT NULL DEFAULT '1', + enable_indexing INTEGER UNSIGNED NOT NULL DEFAULT '1', + enable_icons INTEGER UNSIGNED NOT NULL DEFAULT '1', + enable_prune INTEGER UNSIGNED NOT NULL DEFAULT '0', + prune_next INTEGER UNSIGNED NOT NULL DEFAULT '0', + prune_days INTEGER UNSIGNED NOT NULL DEFAULT '0', + prune_viewed INTEGER UNSIGNED NOT NULL DEFAULT '0', + prune_freq INTEGER UNSIGNED NOT NULL DEFAULT '0' +); + +CREATE INDEX phpbb_forums_left_right_id ON phpbb_forums (left_id, right_id); +CREATE INDEX phpbb_forums_forum_lastpost_id ON phpbb_forums (forum_last_post_id); + +# Table: 'phpbb_forums_access' +CREATE TABLE phpbb_forums_access ( + forum_id INTEGER UNSIGNED NOT NULL DEFAULT '0', + user_id INTEGER UNSIGNED NOT NULL DEFAULT '0', + session_id char(32) NOT NULL DEFAULT '', + PRIMARY KEY (forum_id, user_id, session_id) +); + + +# Table: 'phpbb_forums_track' +CREATE TABLE phpbb_forums_track ( + user_id INTEGER UNSIGNED NOT NULL DEFAULT '0', + forum_id INTEGER UNSIGNED NOT NULL DEFAULT '0', + mark_time INTEGER UNSIGNED NOT NULL DEFAULT '0', + PRIMARY KEY (user_id, forum_id) +); + + +# Table: 'phpbb_forums_watch' +CREATE TABLE phpbb_forums_watch ( + forum_id INTEGER UNSIGNED NOT NULL DEFAULT '0', + user_id INTEGER UNSIGNED NOT NULL DEFAULT '0', + notify_status INTEGER UNSIGNED NOT NULL DEFAULT '0' +); + +CREATE INDEX phpbb_forums_watch_forum_id ON phpbb_forums_watch (forum_id); +CREATE INDEX phpbb_forums_watch_user_id ON phpbb_forums_watch (user_id); +CREATE INDEX phpbb_forums_watch_notify_stat ON phpbb_forums_watch (notify_status); + +# Table: 'phpbb_groups' +CREATE TABLE phpbb_groups ( + group_id INTEGER PRIMARY KEY NOT NULL , + group_type tinyint(4) NOT NULL DEFAULT '1', + group_founder_manage INTEGER UNSIGNED NOT NULL DEFAULT '0', + group_skip_auth INTEGER UNSIGNED NOT NULL DEFAULT '0', + group_name varchar(255) NOT NULL DEFAULT '', + group_desc text(65535) NOT NULL DEFAULT '', + group_desc_bitfield varchar(255) NOT NULL DEFAULT '', + group_desc_options INTEGER UNSIGNED NOT NULL DEFAULT '7', + group_desc_uid varchar(8) NOT NULL DEFAULT '', + group_display INTEGER UNSIGNED NOT NULL DEFAULT '0', + group_avatar varchar(255) NOT NULL DEFAULT '', + group_avatar_type tinyint(2) NOT NULL DEFAULT '0', + group_avatar_width INTEGER UNSIGNED NOT NULL DEFAULT '0', + group_avatar_height INTEGER UNSIGNED NOT NULL DEFAULT '0', + group_rank INTEGER UNSIGNED NOT NULL DEFAULT '0', + group_colour varchar(6) NOT NULL DEFAULT '', + group_sig_chars INTEGER UNSIGNED NOT NULL DEFAULT '0', + group_receive_pm INTEGER UNSIGNED NOT NULL DEFAULT '0', + group_message_limit INTEGER UNSIGNED NOT NULL DEFAULT '0', + group_max_recipients INTEGER UNSIGNED NOT NULL DEFAULT '0', + group_legend INTEGER UNSIGNED NOT NULL DEFAULT '0', + group_teampage INTEGER UNSIGNED NOT NULL DEFAULT '0' +); + +CREATE INDEX phpbb_groups_group_legend_name ON phpbb_groups (group_legend, group_name); + +# Table: 'phpbb_icons' +CREATE TABLE phpbb_icons ( + icons_id INTEGER PRIMARY KEY NOT NULL , + icons_url varchar(255) NOT NULL DEFAULT '', + icons_width tinyint(4) NOT NULL DEFAULT '0', + icons_height tinyint(4) NOT NULL DEFAULT '0', + icons_order INTEGER UNSIGNED NOT NULL DEFAULT '0', + display_on_posting INTEGER UNSIGNED NOT NULL DEFAULT '1' +); + +CREATE INDEX phpbb_icons_display_on_posting ON phpbb_icons (display_on_posting); + +# Table: 'phpbb_lang' +CREATE TABLE phpbb_lang ( + lang_id INTEGER PRIMARY KEY NOT NULL , + lang_iso varchar(30) NOT NULL DEFAULT '', + lang_dir varchar(30) NOT NULL DEFAULT '', + lang_english_name varchar(100) NOT NULL DEFAULT '', + lang_local_name varchar(255) NOT NULL DEFAULT '', + lang_author varchar(255) NOT NULL DEFAULT '' +); + +CREATE INDEX phpbb_lang_lang_iso ON phpbb_lang (lang_iso); + +# Table: 'phpbb_log' +CREATE TABLE phpbb_log ( + log_id INTEGER PRIMARY KEY NOT NULL , + log_type tinyint(4) NOT NULL DEFAULT '0', + user_id INTEGER UNSIGNED NOT NULL DEFAULT '0', + forum_id INTEGER UNSIGNED NOT NULL DEFAULT '0', + topic_id INTEGER UNSIGNED NOT NULL DEFAULT '0', + reportee_id INTEGER UNSIGNED NOT NULL DEFAULT '0', + log_ip varchar(40) NOT NULL DEFAULT '', + log_time INTEGER UNSIGNED NOT NULL DEFAULT '0', + log_operation text(65535) NOT NULL DEFAULT '', + log_data mediumtext(16777215) NOT NULL DEFAULT '' +); + +CREATE INDEX phpbb_log_log_type ON phpbb_log (log_type); +CREATE INDEX phpbb_log_log_time ON phpbb_log (log_time); +CREATE INDEX phpbb_log_forum_id ON phpbb_log (forum_id); +CREATE INDEX phpbb_log_topic_id ON phpbb_log (topic_id); +CREATE INDEX phpbb_log_reportee_id ON phpbb_log (reportee_id); +CREATE INDEX phpbb_log_user_id ON phpbb_log (user_id); + +# Table: 'phpbb_login_attempts' +CREATE TABLE phpbb_login_attempts ( + attempt_ip varchar(40) NOT NULL DEFAULT '', + attempt_browser varchar(150) NOT NULL DEFAULT '', + attempt_forwarded_for varchar(255) NOT NULL DEFAULT '', + attempt_time INTEGER UNSIGNED NOT NULL DEFAULT '0', + user_id INTEGER UNSIGNED NOT NULL DEFAULT '0', + username varchar(255) NOT NULL DEFAULT '0', + username_clean varchar(255) NOT NULL DEFAULT '0' +); + +CREATE INDEX phpbb_login_attempts_att_ip ON phpbb_login_attempts (attempt_ip, attempt_time); +CREATE INDEX phpbb_login_attempts_att_for ON phpbb_login_attempts (attempt_forwarded_for, attempt_time); +CREATE INDEX phpbb_login_attempts_att_time ON phpbb_login_attempts (attempt_time); +CREATE INDEX phpbb_login_attempts_user_id ON phpbb_login_attempts (user_id); + +# Table: 'phpbb_moderator_cache' +CREATE TABLE phpbb_moderator_cache ( + forum_id INTEGER UNSIGNED NOT NULL DEFAULT '0', + user_id INTEGER UNSIGNED NOT NULL DEFAULT '0', + username varchar(255) NOT NULL DEFAULT '', + group_id INTEGER UNSIGNED NOT NULL DEFAULT '0', + group_name varchar(255) NOT NULL DEFAULT '', + display_on_index INTEGER UNSIGNED NOT NULL DEFAULT '1' +); + +CREATE INDEX phpbb_moderator_cache_disp_idx ON phpbb_moderator_cache (display_on_index); +CREATE INDEX phpbb_moderator_cache_forum_id ON phpbb_moderator_cache (forum_id); + +# Table: 'phpbb_modules' +CREATE TABLE phpbb_modules ( + module_id INTEGER PRIMARY KEY NOT NULL , + module_enabled INTEGER UNSIGNED NOT NULL DEFAULT '1', + module_display INTEGER UNSIGNED NOT NULL DEFAULT '1', + module_basename varchar(255) NOT NULL DEFAULT '', + module_class varchar(10) NOT NULL DEFAULT '', + parent_id INTEGER UNSIGNED NOT NULL DEFAULT '0', + left_id INTEGER UNSIGNED NOT NULL DEFAULT '0', + right_id INTEGER UNSIGNED NOT NULL DEFAULT '0', + module_langname varchar(255) NOT NULL DEFAULT '', + module_mode varchar(255) NOT NULL DEFAULT '', + module_auth varchar(255) NOT NULL DEFAULT '' +); + +CREATE INDEX phpbb_modules_left_right_id ON phpbb_modules (left_id, right_id); +CREATE INDEX phpbb_modules_module_enabled ON phpbb_modules (module_enabled); +CREATE INDEX phpbb_modules_class_left_id ON phpbb_modules (module_class, left_id); + +# Table: 'phpbb_poll_options' +CREATE TABLE phpbb_poll_options ( + poll_option_id tinyint(4) NOT NULL DEFAULT '0', + topic_id INTEGER UNSIGNED NOT NULL DEFAULT '0', + poll_option_text text(65535) NOT NULL DEFAULT '', + poll_option_total INTEGER UNSIGNED NOT NULL DEFAULT '0' +); + +CREATE INDEX phpbb_poll_options_poll_opt_id ON phpbb_poll_options (poll_option_id); +CREATE INDEX phpbb_poll_options_topic_id ON phpbb_poll_options (topic_id); + +# Table: 'phpbb_poll_votes' +CREATE TABLE phpbb_poll_votes ( + topic_id INTEGER UNSIGNED NOT NULL DEFAULT '0', + poll_option_id tinyint(4) NOT NULL DEFAULT '0', + vote_user_id INTEGER UNSIGNED NOT NULL DEFAULT '0', + vote_user_ip varchar(40) NOT NULL DEFAULT '' +); + +CREATE INDEX phpbb_poll_votes_topic_id ON phpbb_poll_votes (topic_id); +CREATE INDEX phpbb_poll_votes_vote_user_id ON phpbb_poll_votes (vote_user_id); +CREATE INDEX phpbb_poll_votes_vote_user_ip ON phpbb_poll_votes (vote_user_ip); + +# Table: 'phpbb_posts' +CREATE TABLE phpbb_posts ( + post_id INTEGER PRIMARY KEY NOT NULL , + topic_id INTEGER UNSIGNED NOT NULL DEFAULT '0', + forum_id INTEGER UNSIGNED NOT NULL DEFAULT '0', + poster_id INTEGER UNSIGNED NOT NULL DEFAULT '0', + icon_id INTEGER UNSIGNED NOT NULL DEFAULT '0', + poster_ip varchar(40) NOT NULL DEFAULT '', + post_time INTEGER UNSIGNED NOT NULL DEFAULT '0', + post_approved INTEGER UNSIGNED NOT NULL DEFAULT '1', + post_reported INTEGER UNSIGNED NOT NULL DEFAULT '0', + enable_bbcode INTEGER UNSIGNED NOT NULL DEFAULT '1', + enable_smilies INTEGER UNSIGNED NOT NULL DEFAULT '1', + enable_magic_url INTEGER UNSIGNED NOT NULL DEFAULT '1', + enable_sig INTEGER UNSIGNED NOT NULL DEFAULT '1', + post_username varchar(255) NOT NULL DEFAULT '', + post_subject text(65535) NOT NULL DEFAULT '', + post_text mediumtext(16777215) NOT NULL DEFAULT '', + post_checksum varchar(32) NOT NULL DEFAULT '', + post_attachment INTEGER UNSIGNED NOT NULL DEFAULT '0', + bbcode_bitfield varchar(255) NOT NULL DEFAULT '', + bbcode_uid varchar(8) NOT NULL DEFAULT '', + post_postcount INTEGER UNSIGNED NOT NULL DEFAULT '1', + post_edit_time INTEGER UNSIGNED NOT NULL DEFAULT '0', + post_edit_reason text(65535) NOT NULL DEFAULT '', + post_edit_user INTEGER UNSIGNED NOT NULL DEFAULT '0', + post_edit_count INTEGER UNSIGNED NOT NULL DEFAULT '0', + post_edit_locked INTEGER UNSIGNED NOT NULL DEFAULT '0' +); + +CREATE INDEX phpbb_posts_forum_id ON phpbb_posts (forum_id); +CREATE INDEX phpbb_posts_topic_id ON phpbb_posts (topic_id); +CREATE INDEX phpbb_posts_poster_ip ON phpbb_posts (poster_ip); +CREATE INDEX phpbb_posts_poster_id ON phpbb_posts (poster_id); +CREATE INDEX phpbb_posts_post_approved ON phpbb_posts (post_approved); +CREATE INDEX phpbb_posts_post_username ON phpbb_posts (post_username); +CREATE INDEX phpbb_posts_tid_post_time ON phpbb_posts (topic_id, post_time); + +# Table: 'phpbb_privmsgs' +CREATE TABLE phpbb_privmsgs ( + msg_id INTEGER PRIMARY KEY NOT NULL , + root_level INTEGER UNSIGNED NOT NULL DEFAULT '0', + author_id INTEGER UNSIGNED NOT NULL DEFAULT '0', + icon_id INTEGER UNSIGNED NOT NULL DEFAULT '0', + author_ip varchar(40) NOT NULL DEFAULT '', + message_time INTEGER UNSIGNED NOT NULL DEFAULT '0', + enable_bbcode INTEGER UNSIGNED NOT NULL DEFAULT '1', + enable_smilies INTEGER UNSIGNED NOT NULL DEFAULT '1', + enable_magic_url INTEGER UNSIGNED NOT NULL DEFAULT '1', + enable_sig INTEGER UNSIGNED NOT NULL DEFAULT '1', + message_subject text(65535) NOT NULL DEFAULT '', + message_text mediumtext(16777215) NOT NULL DEFAULT '', + message_edit_reason text(65535) NOT NULL DEFAULT '', + message_edit_user INTEGER UNSIGNED NOT NULL DEFAULT '0', + message_attachment INTEGER UNSIGNED NOT NULL DEFAULT '0', + bbcode_bitfield varchar(255) NOT NULL DEFAULT '', + bbcode_uid varchar(8) NOT NULL DEFAULT '', + message_edit_time INTEGER UNSIGNED NOT NULL DEFAULT '0', + message_edit_count INTEGER UNSIGNED NOT NULL DEFAULT '0', + to_address text(65535) NOT NULL DEFAULT '', + bcc_address text(65535) NOT NULL DEFAULT '', + message_reported INTEGER UNSIGNED NOT NULL DEFAULT '0' +); + +CREATE INDEX phpbb_privmsgs_author_ip ON phpbb_privmsgs (author_ip); +CREATE INDEX phpbb_privmsgs_message_time ON phpbb_privmsgs (message_time); +CREATE INDEX phpbb_privmsgs_author_id ON phpbb_privmsgs (author_id); +CREATE INDEX phpbb_privmsgs_root_level ON phpbb_privmsgs (root_level); + +# Table: 'phpbb_privmsgs_folder' +CREATE TABLE phpbb_privmsgs_folder ( + folder_id INTEGER PRIMARY KEY NOT NULL , + user_id INTEGER UNSIGNED NOT NULL DEFAULT '0', + folder_name varchar(255) NOT NULL DEFAULT '', + pm_count INTEGER UNSIGNED NOT NULL DEFAULT '0' +); + +CREATE INDEX phpbb_privmsgs_folder_user_id ON phpbb_privmsgs_folder (user_id); + +# Table: 'phpbb_privmsgs_rules' +CREATE TABLE phpbb_privmsgs_rules ( + rule_id INTEGER PRIMARY KEY NOT NULL , + user_id INTEGER UNSIGNED NOT NULL DEFAULT '0', + rule_check INTEGER UNSIGNED NOT NULL DEFAULT '0', + rule_connection INTEGER UNSIGNED NOT NULL DEFAULT '0', + rule_string varchar(255) NOT NULL DEFAULT '', + rule_user_id INTEGER UNSIGNED NOT NULL DEFAULT '0', + rule_group_id INTEGER UNSIGNED NOT NULL DEFAULT '0', + rule_action INTEGER UNSIGNED NOT NULL DEFAULT '0', + rule_folder_id int(11) NOT NULL DEFAULT '0' +); + +CREATE INDEX phpbb_privmsgs_rules_user_id ON phpbb_privmsgs_rules (user_id); + +# Table: 'phpbb_privmsgs_to' +CREATE TABLE phpbb_privmsgs_to ( + msg_id INTEGER UNSIGNED NOT NULL DEFAULT '0', + user_id INTEGER UNSIGNED NOT NULL DEFAULT '0', + author_id INTEGER UNSIGNED NOT NULL DEFAULT '0', + pm_deleted INTEGER UNSIGNED NOT NULL DEFAULT '0', + pm_new INTEGER UNSIGNED NOT NULL DEFAULT '1', + pm_unread INTEGER UNSIGNED NOT NULL DEFAULT '1', + pm_replied INTEGER UNSIGNED NOT NULL DEFAULT '0', + pm_marked INTEGER UNSIGNED NOT NULL DEFAULT '0', + pm_forwarded INTEGER UNSIGNED NOT NULL DEFAULT '0', + folder_id int(11) NOT NULL DEFAULT '0' +); + +CREATE INDEX phpbb_privmsgs_to_msg_id ON phpbb_privmsgs_to (msg_id); +CREATE INDEX phpbb_privmsgs_to_author_id ON phpbb_privmsgs_to (author_id); +CREATE INDEX phpbb_privmsgs_to_usr_flder_id ON phpbb_privmsgs_to (user_id, folder_id); + +# Table: 'phpbb_profile_fields' +CREATE TABLE phpbb_profile_fields ( + field_id INTEGER PRIMARY KEY NOT NULL , + field_name varchar(255) NOT NULL DEFAULT '', + field_type tinyint(4) NOT NULL DEFAULT '0', + field_ident varchar(20) NOT NULL DEFAULT '', + field_length varchar(20) NOT NULL DEFAULT '', + field_minlen varchar(255) NOT NULL DEFAULT '', + field_maxlen varchar(255) NOT NULL DEFAULT '', + field_novalue varchar(255) NOT NULL DEFAULT '', + field_default_value varchar(255) NOT NULL DEFAULT '', + field_validation varchar(20) NOT NULL DEFAULT '', + field_required INTEGER UNSIGNED NOT NULL DEFAULT '0', + field_show_novalue INTEGER UNSIGNED NOT NULL DEFAULT '0', + field_show_on_reg INTEGER UNSIGNED NOT NULL DEFAULT '0', + field_show_on_pm INTEGER UNSIGNED NOT NULL DEFAULT '0', + field_show_on_vt INTEGER UNSIGNED NOT NULL DEFAULT '0', + field_show_profile INTEGER UNSIGNED NOT NULL DEFAULT '0', + field_hide INTEGER UNSIGNED NOT NULL DEFAULT '0', + field_no_view INTEGER UNSIGNED NOT NULL DEFAULT '0', + field_active INTEGER UNSIGNED NOT NULL DEFAULT '0', + field_order INTEGER UNSIGNED NOT NULL DEFAULT '0' +); + +CREATE INDEX phpbb_profile_fields_fld_type ON phpbb_profile_fields (field_type); +CREATE INDEX phpbb_profile_fields_fld_ordr ON phpbb_profile_fields (field_order); + +# Table: 'phpbb_profile_fields_data' +CREATE TABLE phpbb_profile_fields_data ( + user_id INTEGER UNSIGNED NOT NULL DEFAULT '0', + PRIMARY KEY (user_id) +); + + +# Table: 'phpbb_profile_fields_lang' +CREATE TABLE phpbb_profile_fields_lang ( + field_id INTEGER UNSIGNED NOT NULL DEFAULT '0', + lang_id INTEGER UNSIGNED NOT NULL DEFAULT '0', + option_id INTEGER UNSIGNED NOT NULL DEFAULT '0', + field_type tinyint(4) NOT NULL DEFAULT '0', + lang_value varchar(255) NOT NULL DEFAULT '', + PRIMARY KEY (field_id, lang_id, option_id) +); + + +# Table: 'phpbb_profile_lang' +CREATE TABLE phpbb_profile_lang ( + field_id INTEGER UNSIGNED NOT NULL DEFAULT '0', + lang_id INTEGER UNSIGNED NOT NULL DEFAULT '0', + lang_name varchar(255) NOT NULL DEFAULT '', + lang_explain text(65535) NOT NULL DEFAULT '', + lang_default_value varchar(255) NOT NULL DEFAULT '', + PRIMARY KEY (field_id, lang_id) +); + + +# Table: 'phpbb_ranks' +CREATE TABLE phpbb_ranks ( + rank_id INTEGER PRIMARY KEY NOT NULL , + rank_title varchar(255) NOT NULL DEFAULT '', + rank_min INTEGER UNSIGNED NOT NULL DEFAULT '0', + rank_special INTEGER UNSIGNED NOT NULL DEFAULT '0', + rank_image varchar(255) NOT NULL DEFAULT '' +); + + +# Table: 'phpbb_reports' +CREATE TABLE phpbb_reports ( + report_id INTEGER PRIMARY KEY NOT NULL , + reason_id INTEGER UNSIGNED NOT NULL DEFAULT '0', + post_id INTEGER UNSIGNED NOT NULL DEFAULT '0', + pm_id INTEGER UNSIGNED NOT NULL DEFAULT '0', + user_id INTEGER UNSIGNED NOT NULL DEFAULT '0', + user_notify INTEGER UNSIGNED NOT NULL DEFAULT '0', + report_closed INTEGER UNSIGNED NOT NULL DEFAULT '0', + report_time INTEGER UNSIGNED NOT NULL DEFAULT '0', + report_text mediumtext(16777215) NOT NULL DEFAULT '', + reported_post_text mediumtext(16777215) NOT NULL DEFAULT '' +); + +CREATE INDEX phpbb_reports_post_id ON phpbb_reports (post_id); +CREATE INDEX phpbb_reports_pm_id ON phpbb_reports (pm_id); + +# Table: 'phpbb_reports_reasons' +CREATE TABLE phpbb_reports_reasons ( + reason_id INTEGER PRIMARY KEY NOT NULL , + reason_title varchar(255) NOT NULL DEFAULT '', + reason_description mediumtext(16777215) NOT NULL DEFAULT '', + reason_order INTEGER UNSIGNED NOT NULL DEFAULT '0' +); + + +# Table: 'phpbb_search_results' +CREATE TABLE phpbb_search_results ( + search_key varchar(32) NOT NULL DEFAULT '', + search_time INTEGER UNSIGNED NOT NULL DEFAULT '0', + search_keywords mediumtext(16777215) NOT NULL DEFAULT '', + search_authors mediumtext(16777215) NOT NULL DEFAULT '', + PRIMARY KEY (search_key) +); + + +# Table: 'phpbb_search_wordlist' +CREATE TABLE phpbb_search_wordlist ( + word_id INTEGER PRIMARY KEY NOT NULL , + word_text varchar(255) NOT NULL DEFAULT '', + word_common INTEGER UNSIGNED NOT NULL DEFAULT '0', + word_count INTEGER UNSIGNED NOT NULL DEFAULT '0' +); + +CREATE UNIQUE INDEX phpbb_search_wordlist_wrd_txt ON phpbb_search_wordlist (word_text); +CREATE INDEX phpbb_search_wordlist_wrd_cnt ON phpbb_search_wordlist (word_count); + +# Table: 'phpbb_search_wordmatch' +CREATE TABLE phpbb_search_wordmatch ( + post_id INTEGER UNSIGNED NOT NULL DEFAULT '0', + word_id INTEGER UNSIGNED NOT NULL DEFAULT '0', + title_match INTEGER UNSIGNED NOT NULL DEFAULT '0' +); + +CREATE UNIQUE INDEX phpbb_search_wordmatch_unq_mtch ON phpbb_search_wordmatch (word_id, post_id, title_match); +CREATE INDEX phpbb_search_wordmatch_word_id ON phpbb_search_wordmatch (word_id); +CREATE INDEX phpbb_search_wordmatch_post_id ON phpbb_search_wordmatch (post_id); + +# Table: 'phpbb_sessions' +CREATE TABLE phpbb_sessions ( + session_id char(32) NOT NULL DEFAULT '', + session_user_id INTEGER UNSIGNED NOT NULL DEFAULT '0', + session_forum_id INTEGER UNSIGNED NOT NULL DEFAULT '0', + session_last_visit INTEGER UNSIGNED NOT NULL DEFAULT '0', + session_start INTEGER UNSIGNED NOT NULL DEFAULT '0', + session_time INTEGER UNSIGNED NOT NULL DEFAULT '0', + session_ip varchar(40) NOT NULL DEFAULT '', + session_browser varchar(150) NOT NULL DEFAULT '', + session_forwarded_for varchar(255) NOT NULL DEFAULT '', + session_page varchar(255) NOT NULL DEFAULT '', + session_viewonline INTEGER UNSIGNED NOT NULL DEFAULT '1', + session_autologin INTEGER UNSIGNED NOT NULL DEFAULT '0', + session_admin INTEGER UNSIGNED NOT NULL DEFAULT '0', + PRIMARY KEY (session_id) +); + +CREATE INDEX phpbb_sessions_session_time ON phpbb_sessions (session_time); +CREATE INDEX phpbb_sessions_session_user_id ON phpbb_sessions (session_user_id); +CREATE INDEX phpbb_sessions_session_fid ON phpbb_sessions (session_forum_id); + +# Table: 'phpbb_sessions_keys' +CREATE TABLE phpbb_sessions_keys ( + key_id char(32) NOT NULL DEFAULT '', + user_id INTEGER UNSIGNED NOT NULL DEFAULT '0', + last_ip varchar(40) NOT NULL DEFAULT '', + last_login INTEGER UNSIGNED NOT NULL DEFAULT '0', + PRIMARY KEY (key_id, user_id) +); + +CREATE INDEX phpbb_sessions_keys_last_login ON phpbb_sessions_keys (last_login); + +# Table: 'phpbb_sitelist' +CREATE TABLE phpbb_sitelist ( + site_id INTEGER PRIMARY KEY NOT NULL , + site_ip varchar(40) NOT NULL DEFAULT '', + site_hostname varchar(255) NOT NULL DEFAULT '', + ip_exclude INTEGER UNSIGNED NOT NULL DEFAULT '0' +); + + +# Table: 'phpbb_smilies' +CREATE TABLE phpbb_smilies ( + smiley_id INTEGER PRIMARY KEY NOT NULL , + code varchar(50) NOT NULL DEFAULT '', + emotion varchar(50) NOT NULL DEFAULT '', + smiley_url varchar(50) NOT NULL DEFAULT '', + smiley_width INTEGER UNSIGNED NOT NULL DEFAULT '0', + smiley_height INTEGER UNSIGNED NOT NULL DEFAULT '0', + smiley_order INTEGER UNSIGNED NOT NULL DEFAULT '0', + display_on_posting INTEGER UNSIGNED NOT NULL DEFAULT '1' +); + +CREATE INDEX phpbb_smilies_display_on_post ON phpbb_smilies (display_on_posting); + +# Table: 'phpbb_styles' +CREATE TABLE phpbb_styles ( + style_id INTEGER PRIMARY KEY NOT NULL , + style_name varchar(255) NOT NULL DEFAULT '', + style_copyright varchar(255) NOT NULL DEFAULT '', + style_active INTEGER UNSIGNED NOT NULL DEFAULT '1', + style_path varchar(100) NOT NULL DEFAULT '', + bbcode_bitfield varchar(255) NOT NULL DEFAULT 'kNg=', + style_parent_id INTEGER UNSIGNED NOT NULL DEFAULT '0', + style_parent_tree text(65535) NOT NULL DEFAULT '' +); + +CREATE UNIQUE INDEX phpbb_styles_style_name ON phpbb_styles (style_name); + +# Table: 'phpbb_topics' +CREATE TABLE phpbb_topics ( + topic_id INTEGER PRIMARY KEY NOT NULL , + forum_id INTEGER UNSIGNED NOT NULL DEFAULT '0', + icon_id INTEGER UNSIGNED NOT NULL DEFAULT '0', + topic_attachment INTEGER UNSIGNED NOT NULL DEFAULT '0', + topic_approved INTEGER UNSIGNED NOT NULL DEFAULT '1', + topic_reported INTEGER UNSIGNED NOT NULL DEFAULT '0', + topic_title text(65535) NOT NULL DEFAULT '', + topic_poster INTEGER UNSIGNED NOT NULL DEFAULT '0', + topic_time INTEGER UNSIGNED NOT NULL DEFAULT '0', + topic_time_limit INTEGER UNSIGNED NOT NULL DEFAULT '0', + topic_views INTEGER UNSIGNED NOT NULL DEFAULT '0', + topic_replies INTEGER UNSIGNED NOT NULL DEFAULT '0', + topic_replies_real INTEGER UNSIGNED NOT NULL DEFAULT '0', + topic_status tinyint(3) NOT NULL DEFAULT '0', + topic_type tinyint(3) NOT NULL DEFAULT '0', + topic_first_post_id INTEGER UNSIGNED NOT NULL DEFAULT '0', + topic_first_poster_name varchar(255) NOT NULL DEFAULT '', + topic_first_poster_colour varchar(6) NOT NULL DEFAULT '', + topic_last_post_id INTEGER UNSIGNED NOT NULL DEFAULT '0', + topic_last_poster_id INTEGER UNSIGNED NOT NULL DEFAULT '0', + topic_last_poster_name varchar(255) NOT NULL DEFAULT '', + topic_last_poster_colour varchar(6) NOT NULL DEFAULT '', + topic_last_post_subject text(65535) NOT NULL DEFAULT '', + topic_last_post_time INTEGER UNSIGNED NOT NULL DEFAULT '0', + topic_last_view_time INTEGER UNSIGNED NOT NULL DEFAULT '0', + topic_moved_id INTEGER UNSIGNED NOT NULL DEFAULT '0', + topic_bumped INTEGER UNSIGNED NOT NULL DEFAULT '0', + topic_bumper INTEGER UNSIGNED NOT NULL DEFAULT '0', + poll_title text(65535) NOT NULL DEFAULT '', + poll_start INTEGER UNSIGNED NOT NULL DEFAULT '0', + poll_length INTEGER UNSIGNED NOT NULL DEFAULT '0', + poll_max_options tinyint(4) NOT NULL DEFAULT '1', + poll_last_vote INTEGER UNSIGNED NOT NULL DEFAULT '0', + poll_vote_change INTEGER UNSIGNED NOT NULL DEFAULT '0' +); + +CREATE INDEX phpbb_topics_forum_id ON phpbb_topics (forum_id); +CREATE INDEX phpbb_topics_forum_id_type ON phpbb_topics (forum_id, topic_type); +CREATE INDEX phpbb_topics_last_post_time ON phpbb_topics (topic_last_post_time); +CREATE INDEX phpbb_topics_topic_approved ON phpbb_topics (topic_approved); +CREATE INDEX phpbb_topics_forum_appr_last ON phpbb_topics (forum_id, topic_approved, topic_last_post_id); +CREATE INDEX phpbb_topics_fid_time_moved ON phpbb_topics (forum_id, topic_last_post_time, topic_moved_id); + +# Table: 'phpbb_topics_track' +CREATE TABLE phpbb_topics_track ( + user_id INTEGER UNSIGNED NOT NULL DEFAULT '0', + topic_id INTEGER UNSIGNED NOT NULL DEFAULT '0', + forum_id INTEGER UNSIGNED NOT NULL DEFAULT '0', + mark_time INTEGER UNSIGNED NOT NULL DEFAULT '0', + PRIMARY KEY (user_id, topic_id) +); + +CREATE INDEX phpbb_topics_track_topic_id ON phpbb_topics_track (topic_id); +CREATE INDEX phpbb_topics_track_forum_id ON phpbb_topics_track (forum_id); + +# Table: 'phpbb_topics_posted' +CREATE TABLE phpbb_topics_posted ( + user_id INTEGER UNSIGNED NOT NULL DEFAULT '0', + topic_id INTEGER UNSIGNED NOT NULL DEFAULT '0', + topic_posted INTEGER UNSIGNED NOT NULL DEFAULT '0', + PRIMARY KEY (user_id, topic_id) +); + + +# Table: 'phpbb_topics_watch' +CREATE TABLE phpbb_topics_watch ( + topic_id INTEGER UNSIGNED NOT NULL DEFAULT '0', + user_id INTEGER UNSIGNED NOT NULL DEFAULT '0', + notify_status INTEGER UNSIGNED NOT NULL DEFAULT '0' +); + +CREATE INDEX phpbb_topics_watch_topic_id ON phpbb_topics_watch (topic_id); +CREATE INDEX phpbb_topics_watch_user_id ON phpbb_topics_watch (user_id); +CREATE INDEX phpbb_topics_watch_notify_stat ON phpbb_topics_watch (notify_status); + +# Table: 'phpbb_user_group' +CREATE TABLE phpbb_user_group ( + group_id INTEGER UNSIGNED NOT NULL DEFAULT '0', + user_id INTEGER UNSIGNED NOT NULL DEFAULT '0', + group_leader INTEGER UNSIGNED NOT NULL DEFAULT '0', + user_pending INTEGER UNSIGNED NOT NULL DEFAULT '1' +); + +CREATE INDEX phpbb_user_group_group_id ON phpbb_user_group (group_id); +CREATE INDEX phpbb_user_group_user_id ON phpbb_user_group (user_id); +CREATE INDEX phpbb_user_group_group_leader ON phpbb_user_group (group_leader); + +# Table: 'phpbb_users' +CREATE TABLE phpbb_users ( + user_id INTEGER PRIMARY KEY NOT NULL , + user_type tinyint(2) NOT NULL DEFAULT '0', + group_id INTEGER UNSIGNED NOT NULL DEFAULT '3', + user_permissions mediumtext(16777215) NOT NULL DEFAULT '', + user_perm_from INTEGER UNSIGNED NOT NULL DEFAULT '0', + user_ip varchar(40) NOT NULL DEFAULT '', + user_regdate INTEGER UNSIGNED NOT NULL DEFAULT '0', + username varchar(255) NOT NULL DEFAULT '', + username_clean varchar(255) NOT NULL DEFAULT '', + user_password varchar(40) NOT NULL DEFAULT '', + user_passchg INTEGER UNSIGNED NOT NULL DEFAULT '0', + user_pass_convert INTEGER UNSIGNED NOT NULL DEFAULT '0', + user_email varchar(100) NOT NULL DEFAULT '', + user_email_hash bigint(20) NOT NULL DEFAULT '0', + user_birthday varchar(10) NOT NULL DEFAULT '', + user_lastvisit INTEGER UNSIGNED NOT NULL DEFAULT '0', + user_lastmark INTEGER UNSIGNED NOT NULL DEFAULT '0', + user_lastpost_time INTEGER UNSIGNED NOT NULL DEFAULT '0', + user_lastpage varchar(200) NOT NULL DEFAULT '', + user_last_confirm_key varchar(10) NOT NULL DEFAULT '', + user_last_search INTEGER UNSIGNED NOT NULL DEFAULT '0', + user_warnings tinyint(4) NOT NULL DEFAULT '0', + user_last_warning INTEGER UNSIGNED NOT NULL DEFAULT '0', + user_login_attempts tinyint(4) NOT NULL DEFAULT '0', + user_inactive_reason tinyint(2) NOT NULL DEFAULT '0', + user_inactive_time INTEGER UNSIGNED NOT NULL DEFAULT '0', + user_posts INTEGER UNSIGNED NOT NULL DEFAULT '0', + user_lang varchar(30) NOT NULL DEFAULT '', + user_timezone varchar(100) NOT NULL DEFAULT 'UTC', + user_dateformat varchar(30) NOT NULL DEFAULT 'd M Y H:i', + user_style INTEGER UNSIGNED NOT NULL DEFAULT '0', + user_rank INTEGER UNSIGNED NOT NULL DEFAULT '0', + user_colour varchar(6) NOT NULL DEFAULT '', + user_new_privmsg int(4) NOT NULL DEFAULT '0', + user_unread_privmsg int(4) NOT NULL DEFAULT '0', + user_last_privmsg INTEGER UNSIGNED NOT NULL DEFAULT '0', + user_message_rules INTEGER UNSIGNED NOT NULL DEFAULT '0', + user_full_folder int(11) NOT NULL DEFAULT '-3', + user_emailtime INTEGER UNSIGNED NOT NULL DEFAULT '0', + user_topic_show_days INTEGER UNSIGNED NOT NULL DEFAULT '0', + user_topic_sortby_type varchar(1) NOT NULL DEFAULT 't', + user_topic_sortby_dir varchar(1) NOT NULL DEFAULT 'd', + user_post_show_days INTEGER UNSIGNED NOT NULL DEFAULT '0', + user_post_sortby_type varchar(1) NOT NULL DEFAULT 't', + user_post_sortby_dir varchar(1) NOT NULL DEFAULT 'a', + user_notify INTEGER UNSIGNED NOT NULL DEFAULT '0', + user_notify_pm INTEGER UNSIGNED NOT NULL DEFAULT '1', + user_notify_type tinyint(4) NOT NULL DEFAULT '0', + user_allow_pm INTEGER UNSIGNED NOT NULL DEFAULT '1', + user_allow_viewonline INTEGER UNSIGNED NOT NULL DEFAULT '1', + user_allow_viewemail INTEGER UNSIGNED NOT NULL DEFAULT '1', + user_allow_massemail INTEGER UNSIGNED NOT NULL DEFAULT '1', + user_options INTEGER UNSIGNED NOT NULL DEFAULT '230271', + user_avatar varchar(255) NOT NULL DEFAULT '', + user_avatar_type tinyint(2) NOT NULL DEFAULT '0', + user_avatar_width INTEGER UNSIGNED NOT NULL DEFAULT '0', + user_avatar_height INTEGER UNSIGNED NOT NULL DEFAULT '0', + user_sig mediumtext(16777215) NOT NULL DEFAULT '', + user_sig_bbcode_uid varchar(8) NOT NULL DEFAULT '', + user_sig_bbcode_bitfield varchar(255) NOT NULL DEFAULT '', + user_from varchar(100) NOT NULL DEFAULT '', + user_icq varchar(15) NOT NULL DEFAULT '', + user_aim varchar(255) NOT NULL DEFAULT '', + user_yim varchar(255) NOT NULL DEFAULT '', + user_msnm varchar(255) NOT NULL DEFAULT '', + user_jabber varchar(255) NOT NULL DEFAULT '', + user_website varchar(200) NOT NULL DEFAULT '', + user_occ text(65535) NOT NULL DEFAULT '', + user_interests text(65535) NOT NULL DEFAULT '', + user_actkey varchar(32) NOT NULL DEFAULT '', + user_newpasswd varchar(40) NOT NULL DEFAULT '', + user_form_salt varchar(32) NOT NULL DEFAULT '', + user_new INTEGER UNSIGNED NOT NULL DEFAULT '1', + user_reminded tinyint(4) NOT NULL DEFAULT '0', + user_reminded_time INTEGER UNSIGNED NOT NULL DEFAULT '0' +); + +CREATE INDEX phpbb_users_user_birthday ON phpbb_users (user_birthday); +CREATE INDEX phpbb_users_user_email_hash ON phpbb_users (user_email_hash); +CREATE INDEX phpbb_users_user_type ON phpbb_users (user_type); +CREATE UNIQUE INDEX phpbb_users_username_clean ON phpbb_users (username_clean); + +# Table: 'phpbb_warnings' +CREATE TABLE phpbb_warnings ( + warning_id INTEGER PRIMARY KEY NOT NULL , + user_id INTEGER UNSIGNED NOT NULL DEFAULT '0', + post_id INTEGER UNSIGNED NOT NULL DEFAULT '0', + log_id INTEGER UNSIGNED NOT NULL DEFAULT '0', + warning_time INTEGER UNSIGNED NOT NULL DEFAULT '0' +); + + +# Table: 'phpbb_words' +CREATE TABLE phpbb_words ( + word_id INTEGER PRIMARY KEY NOT NULL , + word varchar(255) NOT NULL DEFAULT '', + replacement varchar(255) NOT NULL DEFAULT '' +); + + +# Table: 'phpbb_zebra' +CREATE TABLE phpbb_zebra ( + user_id INTEGER UNSIGNED NOT NULL DEFAULT '0', + zebra_id INTEGER UNSIGNED NOT NULL DEFAULT '0', + friend INTEGER UNSIGNED NOT NULL DEFAULT '0', + foe INTEGER UNSIGNED NOT NULL DEFAULT '0', + PRIMARY KEY (user_id, zebra_id) +); diff --git a/phpBB/mcp.php b/phpBB/mcp.php index d04a297cf9..984925789f 100644 --- a/phpBB/mcp.php +++ b/phpBB/mcp.php @@ -483,7 +483,7 @@ function get_post_data($post_ids, $acl_list = false, $read_tracking = false) continue; } - if (!$row['post_approved'] && !$auth->acl_get('m_approve', $row['forum_id'])) + if ($row['post_visibility'] == ITEM_UNAPPROVED && !$auth->acl_get('m_approve', $row['forum_id'])) { // Moderators without the permission to approve post should at least not see them. ;) continue; @@ -619,7 +619,7 @@ function mcp_sorting($mode, &$sort_days, &$sort_key, &$sort_dir, &$sort_by_sql, if (!$auth->acl_get('m_approve', $forum_id)) { - $sql .= 'AND topic_approved = 1'; + $sql .= 'AND post_visibility = ' . ITEM_APPROVED; } break; @@ -635,7 +635,7 @@ function mcp_sorting($mode, &$sort_days, &$sort_key, &$sort_dir, &$sort_by_sql, if (!$auth->acl_get('m_approve', $forum_id)) { - $sql .= 'AND post_approved = 1'; + $sql .= 'AND post_visibility = ' . ITEM_APPROVED; } break; @@ -648,7 +648,7 @@ function mcp_sorting($mode, &$sort_days, &$sort_key, &$sort_dir, &$sort_by_sql, $sql = 'SELECT COUNT(p.post_id) AS total FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . " t $where_sql " . $db->sql_in_set('p.forum_id', ($forum_id) ? array($forum_id) : array_intersect(get_forum_list('f_read'), get_forum_list('m_approve'))) . ' - AND p.post_approved = 0 + AND p.post_visibility = ' . ITEM_UNAPPROVED . ' AND t.topic_id = p.topic_id AND t.topic_first_post_id <> p.post_id'; @@ -666,7 +666,7 @@ function mcp_sorting($mode, &$sort_days, &$sort_key, &$sort_dir, &$sort_by_sql, $sql = 'SELECT COUNT(topic_id) AS total FROM ' . TOPICS_TABLE . " $where_sql " . $db->sql_in_set('forum_id', ($forum_id) ? array($forum_id) : array_intersect(get_forum_list('f_read'), get_forum_list('m_approve'))) . ' - AND topic_approved = 0'; + AND topic_visibility = ' . ITEM_UNAPPROVED; if ($min_time) { diff --git a/phpBB/memberlist.php b/phpBB/memberlist.php index f142d182bc..f8cb55ccc4 100644 --- a/phpBB/memberlist.php +++ b/phpBB/memberlist.php @@ -613,7 +613,7 @@ switch ($mode) $sql = 'SELECT COUNT(post_id) as posts_in_queue FROM ' . POSTS_TABLE . ' WHERE poster_id = ' . $user_id . ' - AND post_approved = 0'; + AND post_visibility = ' . ITEM_UNAPPROVED; $result = $db->sql_query($sql); $member['posts_in_queue'] = (int) $db->sql_fetchfield('posts_in_queue'); $db->sql_freeresult($result); diff --git a/phpBB/posting.php b/phpBB/posting.php index a17578e343..273499c1e4 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -86,8 +86,8 @@ switch ($mode) $sql = 'SELECT f.*, t.* FROM ' . TOPICS_TABLE . ' t, ' . FORUMS_TABLE . " f WHERE t.topic_id = $topic_id - AND f.forum_id = t.forum_id" . - (($auth->acl_get('m_approve', $forum_id)) ? '' : ' AND t.topic_approved = 1'); + AND f.forum_id = t.forum_id + AND " . topic_visibility::get_visibility_sql('topic', $forum_id, 't.'); break; case 'quote': @@ -114,8 +114,8 @@ switch ($mode) WHERE p.post_id = $post_id AND t.topic_id = p.topic_id AND u.user_id = p.poster_id - AND f.forum_id = t.forum_id" . - (($auth->acl_get('m_approve', $forum_id)) ? '' : ' AND p.post_approved = 1'); + AND f.forum_id = t.forum_id + AND " . topic_visibility::get_visibility_sql('topic', $forum_id, 't.'); break; case 'smilies': @@ -163,7 +163,7 @@ if (!$post_data) // Not able to reply to unapproved posts/topics // TODO: add more descriptive language key -if ($auth->acl_get('m_approve', $forum_id) && ((($mode == 'reply' || $mode == 'bump') && !$post_data['topic_approved']) || ($mode == 'quote' && !$post_data['post_approved']))) +if ($auth->acl_get('m_approve', $forum_id) && ((($mode == 'reply' || $mode == 'bump') && $post_data['topic_visibility'] == ITEM_UNAPPROVED) || ($mode == 'quote' && $post_data['post_visibility'] == ITEM_UNAPPROVED))) { trigger_error(($mode == 'reply' || $mode == 'bump') ? 'TOPIC_UNAPPROVED' : 'POST_UNAPPROVED'); } @@ -1063,8 +1063,8 @@ if ($submit || $preview || $refresh) 'attachment_data' => $message_parser->attachment_data, 'filename_data' => $message_parser->filename_data, - 'topic_approved' => (isset($post_data['topic_approved'])) ? $post_data['topic_approved'] : false, - 'post_approved' => (isset($post_data['post_approved'])) ? $post_data['post_approved'] : false, + 'topic_visibility' => (isset($post_data['topic_visibility'])) ? $post_data['topic_visibility'] : false, + 'post_visibility' => (isset($post_data['post_visibility'])) ? $post_data['post_visibility'] : false, ); if ($mode == 'edit') @@ -1514,9 +1514,9 @@ function handle_post_delete($forum_id, $topic_id, $post_id, &$post_data) 'topic_first_post_id' => $post_data['topic_first_post_id'], 'topic_last_post_id' => $post_data['topic_last_post_id'], 'topic_replies_real' => $post_data['topic_replies_real'], - 'topic_approved' => $post_data['topic_approved'], + 'topic_visibility' => $post_data['topic_visibility'], 'topic_type' => $post_data['topic_type'], - 'post_approved' => $post_data['post_approved'], + 'post_visibility' => $post_data['post_visibility'], 'post_reported' => $post_data['post_reported'], 'post_time' => $post_data['post_time'], 'poster_id' => $post_data['poster_id'], diff --git a/phpBB/search.php b/phpBB/search.php index 190da5247f..7bf941f127 100644 --- a/phpBB/search.php +++ b/phpBB/search.php @@ -249,7 +249,7 @@ if ($keywords || $author || $author_id || $search_id || $submit) } $db->sql_freeresult($result); - // find out in which forums the user is allowed to view approved posts +/* // find out in which forums the user is allowed to view approved posts if ($auth->acl_get('m_approve')) { $m_approve_fid_ary = array(-1); @@ -265,6 +265,8 @@ if ($keywords || $author || $author_id || $search_id || $submit) $m_approve_fid_ary = array(); $m_approve_fid_sql = ' AND p.post_approved = 1'; } +*/ + $m_approve_fid_sql = ' AND ' . topic_visibility::get_visibility_sql_global('post', $ex_fid_ary, 'p.'); if ($reset_search_forum) { @@ -523,17 +525,17 @@ if ($keywords || $author || $author_id || $search_id || $submit) // make sure that some arrays are always in the same order sort($ex_fid_ary); - sort($m_approve_fid_ary); +// @TODO sort($m_approve_fid_ary); sort($author_id_ary); if (!empty($search->search_query)) { - $total_match_count = $search->keyword_search($show_results, $search_fields, $search_terms, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_fid_ary, $topic_id, $author_id_ary, $sql_author_match, $id_ary, $start, $per_page); + $total_match_count = $search->keyword_search($show_results, $search_fields, $search_terms, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_fid_sql, $topic_id, $author_id_ary, $sql_author_match, $id_ary, $start, $per_page); } else if (sizeof($author_id_ary)) { $firstpost_only = ($search_fields === 'firstpost' || $search_fields == 'titleonly') ? true : false; - $total_match_count = $search->author_search($show_results, $firstpost_only, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_fid_ary, $topic_id, $author_id_ary, $sql_author_match, $id_ary, $start, $per_page); + $total_match_count = $search->author_search($show_results, $firstpost_only, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_fid_sql, $topic_id, $author_id_ary, $sql_author_match, $id_ary, $start, $per_page); } // For some searches we need to print out the "no results" page directly to allow re-sorting/refining the search options. @@ -548,7 +550,7 @@ if ($keywords || $author || $author_id || $search_id || $submit) { $sql_where .= $db->sql_in_set(($show_results == 'posts') ? 'p.post_id' : 't.topic_id', $id_ary); $sql_where .= (sizeof($ex_fid_ary)) ? ' AND (' . $db->sql_in_set('f.forum_id', $ex_fid_ary, true) . ' OR f.forum_id IS NULL)' : ''; - $sql_where .= ($show_results == 'posts') ? $m_approve_fid_sql : str_replace(array('p.post_approved', 'p.forum_id'), array('t.topic_approved', 't.forum_id'), $m_approve_fid_sql); + $sql_where .= ($show_results == 'posts') ? $m_approve_fid_sql : str_replace(array('p.post_visibility', 'p.forum_id'), array('t.topic_visibility', 't.forum_id'), $m_approve_fid_sql); } if ($show_results == 'posts') @@ -882,8 +884,9 @@ if ($keywords || $author || $author_id || $search_id || $submit) $unread_topic = (isset($topic_tracking_info[$forum_id][$row['topic_id']]) && $row['topic_last_post_time'] > $topic_tracking_info[$forum_id][$row['topic_id']]) ? true : false; - $topic_unapproved = (!$row['topic_approved'] && $auth->acl_get('m_approve', $forum_id)) ? true : false; - $posts_unapproved = ($row['topic_approved'] && $row['topic_replies'] < $row['topic_replies_real'] && $auth->acl_get('m_approve', $forum_id)) ? true : false; + $topic_unapproved = ($row['topic_visibility'] == ITEM_UNAPPROVED && $auth->acl_get('m_approve', $forum_id)) ? true : false; + $posts_unapproved = ($row['topic_visibility'] == ITEM_APPROVED && $row['topic_replies'] < $row['topic_replies_real'] && $auth->acl_get('m_approve', $forum_id)) ? true : false; + $topic_deleted = ($row['topic_visibility'] == ITEM_DELETED) ? true : false; $u_mcp_queue = ($topic_unapproved || $posts_unapproved) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&mode=' . (($topic_unapproved) ? 'approve_details' : 'unapproved_posts') . "&t=$result_topic_id", true, $user->session_id) : ''; $row['topic_title'] = preg_replace('#(?!<.*)(?]*(?:)#is', '$1', $row['topic_title']); @@ -911,6 +914,7 @@ if ($keywords || $author || $author_id || $search_id || $submit) 'TOPIC_ICON_IMG_HEIGHT' => (!empty($icons[$row['icon_id']])) ? $icons[$row['icon_id']]['height'] : '', 'ATTACH_ICON_IMG' => ($auth->acl_get('u_download') && $auth->acl_get('f_download', $forum_id) && $row['topic_attachment']) ? $user->img('icon_topic_attach', $user->lang['TOTAL_ATTACHMENTS']) : '', 'UNAPPROVED_IMG' => ($topic_unapproved || $posts_unapproved) ? $user->img('icon_topic_unapproved', ($topic_unapproved) ? 'TOPIC_UNAPPROVED' : 'POSTS_UNAPPROVED') : '', + 'DELETED_IMG' => ($topic_deleted) ? $user->img(/*TODO*/) : '', 'S_TOPIC_TYPE' => $row['topic_type'], 'S_USER_POSTED' => (!empty($row['topic_posted'])) ? true : false, @@ -919,6 +923,7 @@ if ($keywords || $author || $author_id || $search_id || $submit) 'S_TOPIC_REPORTED' => (!empty($row['topic_reported']) && $auth->acl_get('m_report', $forum_id)) ? true : false, 'S_TOPIC_UNAPPROVED' => $topic_unapproved, 'S_POSTS_UNAPPROVED' => $posts_unapproved, + 'S_TOPIC_DELETED' => $topic_deleted, 'U_LAST_POST' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", $view_topic_url_params . '&p=' . $row['topic_last_post_id']) . '#p' . $row['topic_last_post_id'], 'U_LAST_POST_AUTHOR' => get_username_string('profile', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']), diff --git a/phpBB/viewforum.php b/phpBB/viewforum.php index 783c7181d2..2c29d92cd8 100644 --- a/phpBB/viewforum.php +++ b/phpBB/viewforum.php @@ -241,7 +241,7 @@ if ($sort_days) AND (topic_last_post_time >= $min_post_time OR topic_type = " . POST_ANNOUNCE . ' OR topic_type = ' . POST_GLOBAL . ') - ' . (($auth->acl_get('m_approve', $forum_id)) ? '' : 'AND topic_approved = 1'); + AND ' . topic_visibility::get_visibility_sql('topic', $forum_id); $result = $db->sql_query($sql); $topics_count = (int) $db->sql_fetchfield('num_topics'); $db->sql_freeresult($result); @@ -353,7 +353,7 @@ $sql_array = array( 'LEFT_JOIN' => array(), ); -$sql_approved = ($auth->acl_get('m_approve', $forum_id)) ? '' : 'AND t.topic_approved = 1'; +$sql_approved = 'AND ' . topic_visibility::get_visibility_sql('topic', $forum_id, 't.'); if ($user->data['is_registered']) { @@ -685,8 +685,9 @@ if (sizeof($topic_list)) $view_topic_url_params = 'f=' . $row['forum_id'] . '&t=' . $topic_id; $view_topic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", $view_topic_url_params); - $topic_unapproved = (!$row['topic_approved'] && $auth->acl_get('m_approve', $row['forum_id'])) ? true : false; - $posts_unapproved = ($row['topic_approved'] && $row['topic_replies'] < $row['topic_replies_real'] && $auth->acl_get('m_approve', $row['forum_id'])) ? true : false; + $topic_unapproved = ($row['topic_visibility'] == ITEM_UNAPPROVED && $auth->acl_get('m_approve', $row['forum_id'])); + $posts_unapproved = ($row['topic_visibility'] == ITEM_APPROVED && $row['topic_replies'] < $row['topic_replies_real'] && $auth->acl_get('m_approve', $row['forum_id'])); + $topic_deleted = ($row['topic_visibility'] == ITEM_DELETED); $u_mcp_queue = ($topic_unapproved || $posts_unapproved) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&mode=' . (($topic_unapproved) ? 'approve_details' : 'unapproved_posts') . "&t=$topic_id", true, $user->session_id) : ''; // Send vars to template @@ -719,6 +720,7 @@ if (sizeof($topic_list)) 'TOPIC_ICON_IMG_HEIGHT' => (!empty($icons[$row['icon_id']])) ? $icons[$row['icon_id']]['height'] : '', 'ATTACH_ICON_IMG' => ($auth->acl_get('u_download') && $auth->acl_get('f_download', $row['forum_id']) && $row['topic_attachment']) ? $user->img('icon_topic_attach', $user->lang['TOTAL_ATTACHMENTS']) : '', 'UNAPPROVED_IMG' => ($topic_unapproved || $posts_unapproved) ? $user->img('icon_topic_unapproved', ($topic_unapproved) ? 'TOPIC_UNAPPROVED' : 'POSTS_UNAPPROVED') : '', + 'DELETED_IMG' => ($topic_deleted) ? $user->img(/*TODO*/) : '', 'S_TOPIC_TYPE' => $row['topic_type'], 'S_USER_POSTED' => (isset($row['topic_posted']) && $row['topic_posted']) ? true : false, @@ -726,6 +728,7 @@ if (sizeof($topic_list)) 'S_TOPIC_REPORTED' => (!empty($row['topic_reported']) && $auth->acl_get('m_report', $row['forum_id'])) ? true : false, 'S_TOPIC_UNAPPROVED' => $topic_unapproved, 'S_POSTS_UNAPPROVED' => $posts_unapproved, + 'S_TOPIC_DELETED' => $topic_deleted, 'S_HAS_POLL' => ($row['poll_start']) ? true : false, 'S_POST_ANNOUNCE' => ($row['topic_type'] == POST_ANNOUNCE) ? true : false, 'S_POST_GLOBAL' => ($row['topic_type'] == POST_GLOBAL) ? true : false, diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index 3fde5b5e03..282c23cd70 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -83,7 +83,7 @@ if ($view && !$post_id) $sql = 'SELECT post_id, topic_id, forum_id FROM ' . POSTS_TABLE . " WHERE topic_id = $topic_id - " . (($auth->acl_get('m_approve', $forum_id)) ? '' : 'AND post_approved = 1') . " + AND " . topic_visibility::get_visibility_sql('post', $forum_id) . " AND post_time > $topic_last_read AND forum_id = $forum_id ORDER BY post_time ASC"; @@ -137,7 +137,7 @@ if ($view && !$post_id) WHERE forum_id = ' . $row['forum_id'] . " AND topic_moved_id = 0 AND topic_last_post_time $sql_condition {$row['topic_last_post_time']} - " . (($auth->acl_get('m_approve', $row['forum_id'])) ? '' : 'AND topic_approved = 1') . " + AND" . topic_visibility::get_visibility_sql('topic', $row['forum_id']) . " ORDER BY topic_last_post_time $sql_ordering"; $result = $db->sql_query_limit($sql, 1); $row = $db->sql_fetchrow($result); @@ -174,7 +174,7 @@ $sql_array = array( // The FROM-Order is quite important here, else t.* columns can not be correctly bound. if ($post_id) { - $sql_array['SELECT'] .= ', p.post_approved, p.post_time, p.post_id'; + $sql_array['SELECT'] .= ', p.post_visibility, p.post_time, p.post_id'; $sql_array['FROM'][POSTS_TABLE] = 'p'; } @@ -249,7 +249,7 @@ $forum_id = (int) $topic_data['forum_id']; if ($post_id) { // are we where we are supposed to be? - if (!$topic_data['post_approved'] && !$auth->acl_get('m_approve', $topic_data['forum_id'])) + if ($topic_data['post_visibility'] == ITEM_UNAPPROVED && !$auth->acl_get('m_approve', $topic_data['forum_id'])) { // If post_id was submitted, we try at least to display the topic as a last resort... if ($topic_id) @@ -277,7 +277,7 @@ if ($post_id) $sql = 'SELECT COUNT(p.post_id) AS prev_posts FROM ' . POSTS_TABLE . " p WHERE p.topic_id = {$topic_data['topic_id']} - " . ((!$auth->acl_get('m_approve', $forum_id)) ? 'AND p.post_approved = 1' : ''); + " . topic_visibility::get_visibility_sql('post', $forum_id, 'p'); if ($sort_dir == 'd') { @@ -315,7 +315,13 @@ if (($topic_data['topic_type'] == POST_STICKY || $topic_data['topic_type'] == PO // Setup look and feel $user->setup('viewtopic', $topic_data['forum_style']); -if (!$topic_data['topic_approved'] && !$auth->acl_get('m_approve', $forum_id)) +/* the topic "does not exist": +* if the topic is unapproved and the user cannot approve it +* if the topic is deleted and the user cannot restore it +* NB: restoring a topic has two cases: moderator restore and poster restore. +*/ +if (($topic_data['topic_visibility'] == ITEM_UNAPPROVED && !$auth->acl_get('m_approve', $forum_id)) + || ($topic_data['topic_visibility'] == ITEM_DELETED && (!$auth->acl_get('m_restore', $forum_id) || ($user->data['user_id'] == $topic_data['topic_poster'] && $auth->acl_get('f_restore', $forum_id))))) { trigger_error('NO_TOPIC'); } @@ -402,7 +408,7 @@ if ($sort_days) FROM ' . POSTS_TABLE . " WHERE topic_id = $topic_id AND post_time >= $min_post_time - " . (($auth->acl_get('m_approve', $forum_id)) ? '' : 'AND post_approved = 1'); + AND " . topic_visibility::get_visibility_sql('post', $forum_id); $result = $db->sql_query($sql); $total_posts = (int) $db->sql_fetchfield('num_posts'); $db->sql_freeresult($result); @@ -938,7 +944,7 @@ $i = $i_total = 0; $sql = 'SELECT p.post_id FROM ' . POSTS_TABLE . ' p' . (($join_user_sql[$sort_key]) ? ', ' . USERS_TABLE . ' u': '') . " WHERE p.topic_id = $topic_id - " . ((!$auth->acl_get('m_approve', $forum_id)) ? 'AND p.post_approved = 1' : '') . " + AND " . topic_visibility::get_visibility_sql('post', $forum_id, 'p.') . " " . (($join_user_sql[$sort_key]) ? 'AND u.user_id = p.poster_id': '') . " $limit_posts_time ORDER BY $sql_sort_order"; @@ -1020,7 +1026,7 @@ while ($row = $db->sql_fetchrow($result)) { $attach_list[] = (int) $row['post_id']; - if ($row['post_approved']) + if ($row['post_visibility'] == ITEM_UNAPPROVED) { $has_attachments = true; } @@ -1046,7 +1052,7 @@ while ($row = $db->sql_fetchrow($result)) // Make sure the icon actually exists 'icon_id' => (isset($icons[$row['icon_id']]['img'], $icons[$row['icon_id']]['height'], $icons[$row['icon_id']]['width'])) ? $row['icon_id'] : 0, 'post_attachment' => $row['post_attachment'], - 'post_approved' => $row['post_approved'], + 'post_visibility' => $row['post_visibility'], 'post_reported' => $row['post_reported'], 'post_username' => $row['post_username'], 'post_text' => $row['post_text'], @@ -1313,8 +1319,8 @@ if (sizeof($attach_list)) $sql = 'SELECT a.post_msg_id as post_id FROM ' . ATTACHMENTS_TABLE . ' a, ' . POSTS_TABLE . " p WHERE p.topic_id = $topic_id - AND p.post_approved = 1 - AND p.topic_id = a.topic_id"; + AND p.post_visibility = " . ITEM_APPROVED . ' + AND p.topic_id = a.topic_id'; $result = $db->sql_query_limit($sql, 1); $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); @@ -1605,7 +1611,7 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i) 'S_HAS_ATTACHMENTS' => (!empty($attachments[$row['post_id']])) ? true : false, 'S_MULTIPLE_ATTACHMENTS' => !empty($attachments[$row['post_id']]) && sizeof($attachments[$row['post_id']]) > 1, - 'S_POST_UNAPPROVED' => ($row['post_approved']) ? false : true, + 'S_POST_UNAPPROVED' => ($row['post_visibility'] == ITEM_APPROVED) ? false : true, 'S_POST_REPORTED' => ($row['post_reported'] && $auth->acl_get('m_report', $forum_id)) ? true : false, 'S_DISPLAY_NOTICE' => $display_notice && $row['post_attachment'], 'S_FRIEND' => ($row['friend']) ? true : false, From 244f6e2ddc7818125edc273be1d83a5298ce6589 Mon Sep 17 00:00:00 2001 From: Josh Woody Date: Fri, 18 Jun 2010 08:29:53 -0500 Subject: [PATCH 0082/2494] [feature/soft-delete] Correct some mistakes in e8d47 Notably: Uncomment the die() in create_schema_files, and add the class that makes everything tick. PHPBB3-9657 --- phpBB/includes/class_visibility.php | 137 ++++++++++++++++++++++++++++ 1 file changed, 137 insertions(+) create mode 100644 phpBB/includes/class_visibility.php diff --git a/phpBB/includes/class_visibility.php b/phpBB/includes/class_visibility.php new file mode 100644 index 0000000000..28fc584b76 --- /dev/null +++ b/phpBB/includes/class_visibility.php @@ -0,0 +1,137 @@ +acl_get('m_approve', $forum_id)) + { + $status_ary[] = ITEM_UNAPPROVED; + } + + if ($auth->acl_get('m_restore', $forum_id)) + { + $status_ary[] = ITEM_DELETED; + } + + $clause = $db->sql_in_set($table_alias . $mode . '_visibility', $status_ary); + + // only allow the user to view deleted posts he himself made + if ($auth->acl_get('f_restore', $forum_id)) + { + $clause = 'AND (' . $clause . " + OR ($table_alias{$mode}_visibility = " . ITEM_DELETED . " + AND {$table_alias}poster_id = " . $user->data['user_id'] . '))'; + + } + + return $clause; + } + + public function get_visibility_sql_global($mode, $exclude_forum_ids = array(), $table_alias = '') + { + global $auth, $db, $user; + + // users can always see approved posts + $where_sql = "($table_alias{$mode}_visibility = " . ITEM_APPROVED; + + // in set notation: {approve_forums} = {m_approve} - {exclude_forums} + $approve_forums = array_diff(array_keys($auth->acl_getf('m_approve', true)), $exclude_forum_ids); + if (sizeof($approve_forums)) + { + // users can view unapproved topics in certain forums. specify them. + $where_sql .= " OR ($table_alias{$mode}_visibility = " . ITEM_UNAPPROVED . ' + AND ' . $db->sql_in_set($table_alias . 'forum_id', $approve_forums) . ')'; + } + + // this is exactly the same logic as for approve forums, above + $restore_forums = array_diff(array_keys($auth->acl_getf('m_restore', true)), $exclude_forum_ids); + if (sizeof($restore_forums)) + { + $where_sql .= " OR ($table_alias{$mode}_visibility = " . ITEM_DELETED . ' + AND ' . $db->sql_in_set($table_alias . 'forum_id', $restore_forums) . ')'; + } + + // we also allow the user to view deleted posts he himself made + $user_restore_forums = array_diff(array_keys($auth->acl_getf('f_restore', true)), $exclude_forum_ids); + if (sizeof($user_restore_forums)) + { + // specify the poster ID, the visibility type, and the forums we're interested in + $where_sql .= " OR ($table_alias{$mode}poster_id = " . $user->data['user_id'] . " + AND $table_alias{$mode}_visibility = " . ITEM_DELETED . " + AND " . $db->sql_in_set($table_alias . 'forum_id', $user_restore_forums) . ')'; + } + + $where_sql .= ')'; + + return $where_sql; + } + + public function set_topic_visibility($visibility, $topic_id, $forum_id) + { + global $db; + + $sql = 'UPDATE ' . TOPICS_TABLE . ' SET topic_visibility = ' . (int) $visibility . ' + WHERE topic_id = ' . (int) $topic_id; + $db->sql_query($sql); + + if ($visibility != ITEM_APPROVED) + { + $sql = 'SELECT post_id FROM ' . POSTS_TABLE . ' + WHERE topic_id = ' . (int) $topic_id; + $result = $db->sql_query($sql); + + $status = true; + while ($row = $db->sql_fetchrow($result)) + { + $status = min($status, self::set_post_visibility($visibility, false, $topic_id, $forum_id, true, true)); + } + } + else + { + // TOOD: figure out which posts we actually care about + $status = self::set_post_visibility($visibility, 0, false, $forum_id, true, true); + } + + return $status; + } + + public function set_post_visibility($visibility, $post_id, $topic_id, $forum_id, $is_starter, $is_latest) + { + global $db; + + if ($post_id) + { + $where_sql = 'post_id = ' . (int) $post_id; + } + else if ($topic_id) + { + $where_sql = 'topic_id = ' . (int) $topic_id; + } + else + { + // throw new MissingArgumentsException(); <-- a nice idea + return false; + } + + $sql = 'UPDATE ' . POSTS_TABLE . ' SET post_visibility = ' . (int) $visibility . ' + WHERE ' . $where_sql; + $db->sql_query($sql); + + if ($is_starter || $is_latest) + { + update_post_information('topic', $topic_id, false); + update_post_information('forum', $forum_id, false); + } + + // if we're changing the starter, we need to change the rest of the topic + if ($is_starter && !$is_latest) + { + self::set_topic_visibility($visibility, $topic_id, $forum_id); + } + } +} +?> From c32d76080605f843bb23e9a608c368d4b5dc55d8 Mon Sep 17 00:00:00 2001 From: Josh Woody Date: Sun, 20 Jun 2010 15:01:26 -0500 Subject: [PATCH 0083/2494] [feature/soft-delete] I told you I was going to rename the class! Rename topic_visibility class to phpbb_visibility. Also a bit of work to the class itself, mostly cleanup and adding the comments that I'd previously written. PHPBB3-9657 --- phpBB/feed.php | 10 ++-- phpBB/includes/class_visibility.php | 85 ++++++++++++++++++++-------- phpBB/includes/functions_posting.php | 6 +- phpBB/includes/mcp/mcp_forum.php | 2 +- phpBB/includes/mcp/mcp_topic.php | 2 +- phpBB/posting.php | 4 +- phpBB/search.php | 2 +- phpBB/viewforum.php | 4 +- phpBB/viewtopic.php | 10 ++-- 9 files changed, 82 insertions(+), 43 deletions(-) diff --git a/phpBB/feed.php b/phpBB/feed.php index a806cdd608..89ee5a3bbe 100644 --- a/phpBB/feed.php +++ b/phpBB/feed.php @@ -760,7 +760,7 @@ class phpbb_feed_overall extends phpbb_feed_post_base FROM ' . TOPICS_TABLE . ' WHERE ' . $db->sql_in_set('forum_id', $forum_ids) . ' AND topic_moved_id = 0 - AND ' . topic_visibility::get_visibility_sql_global('topic') . ' + AND ' . phpbb_visibility::get_visibility_sql_global('topic') . ' ORDER BY topic_last_post_time DESC'; $result = $db->sql_query_limit($sql, $this->num_items); @@ -795,7 +795,7 @@ class phpbb_feed_overall extends phpbb_feed_post_base ), ), 'WHERE' => $db->sql_in_set('p.topic_id', $topic_ids) . ' - AND ' . topic_visibility::get_visibility_sql('post', array(), 'p.') . ' + AND ' . phpbb_visibility::get_visibility_sql('post', array(), 'p.') . ' AND p.post_time >= ' . $min_post_time . ' AND u.user_id = p.poster_id', 'ORDER_BY' => 'p.post_time DESC', @@ -892,7 +892,7 @@ class phpbb_feed_forum extends phpbb_feed_post_base FROM ' . TOPICS_TABLE . ' WHERE forum_id = ' . $this->forum_id . ' AND topic_moved_id = 0 - AND ' . topic_visibility::get_visibility_sql('topic', $this->forum_id) . ' + AND ' . phpbb_visibility::get_visibility_sql('topic', $this->forum_id) . ' ORDER BY topic_last_post_time DESC'; $result = $db->sql_query_limit($sql, $this->num_items); @@ -919,7 +919,7 @@ class phpbb_feed_forum extends phpbb_feed_post_base USERS_TABLE => 'u', ), 'WHERE' => $db->sql_in_set('p.topic_id', $topic_ids) . ' - AND ' . topic_visibility::get_visibility_sql('post', $this->forum_id, 'p.') . ' + AND ' . phpbb_visibility::get_visibility_sql('post', $this->forum_id, 'p.') . ' AND p.post_time >= ' . $min_post_time . ' AND p.poster_id = u.user_id', 'ORDER_BY' => 'p.post_time DESC', @@ -1025,7 +1025,7 @@ class phpbb_feed_topic extends phpbb_feed_post_base USERS_TABLE => 'u', ), 'WHERE' => 'p.topic_id = ' . $this->topic_id . ' - AND ' . topic_visibility::get_visibility_sql('post', $this->forum_id, 'p.') . ' + AND ' . phpbb_visibility::get_visibility_sql('post', $this->forum_id, 'p.') . ' AND p.poster_id = u.user_id', 'ORDER_BY' => 'p.post_time DESC', ); diff --git a/phpBB/includes/class_visibility.php b/phpBB/includes/class_visibility.php index 28fc584b76..46f188d833 100644 --- a/phpBB/includes/class_visibility.php +++ b/phpBB/includes/class_visibility.php @@ -1,7 +1,35 @@ sql_query($sql); - if ($visibility != ITEM_APPROVED) - { - $sql = 'SELECT post_id FROM ' . POSTS_TABLE . ' - WHERE topic_id = ' . (int) $topic_id; - $result = $db->sql_query($sql); + // if we're approving, disapproving, or deleteing a topic, assume that + // we are adjusting _all_ posts in that topic. + $status = self::set_post_visibility($visibility, false, $topic_id, $forum_id, true, true); - $status = true; - while ($row = $db->sql_fetchrow($result)) - { - $status = min($status, self::set_post_visibility($visibility, false, $topic_id, $forum_id, true, true)); - } - } - else - { - // TOOD: figure out which posts we actually care about - $status = self::set_post_visibility($visibility, 0, false, $forum_id, true, true); - } return $status; } + /** + * @param $visibility - int - element of {ITEM_UNAPPROVED, ITEM_APPROVED, ITEM_DELETED} + * @param $post_id - int - the post ID to act on + * @param $topic_id - int - forum where $post_id is found + * @param $forum_id - int - forum ID where $topic_id resides + * @param $is_starter - bool - is this the first post of the topic + * @param $is_latest - bool - is this the last post of the topic + */ public function set_post_visibility($visibility, $post_id, $topic_id, $forum_id, $is_starter, $is_latest) { global $db; + // if we're changing the starter, we need to change the rest of the topic + if ($is_starter && !$is_latest) + { + return self::set_topic_visibility($visibility, $topic_id, $forum_id); + } + if ($post_id) { $where_sql = 'post_id = ' . (int) $post_id; @@ -121,17 +165,12 @@ class topic_visibility WHERE ' . $where_sql; $db->sql_query($sql); + // Sync the first/last topic information if needed if ($is_starter || $is_latest) { update_post_information('topic', $topic_id, false); update_post_information('forum', $forum_id, false); } - - // if we're changing the starter, we need to change the rest of the topic - if ($is_starter && !$is_latest) - { - self::set_topic_visibility($visibility, $topic_id, $forum_id); - } } } ?> diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index 2f51200b48..12448ea0ce 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -993,7 +993,7 @@ function topic_review($topic_id, $forum_id, $mode = 'topic_review', $cur_post_id $sql = 'SELECT p.post_id FROM ' . POSTS_TABLE . ' p' . " WHERE p.topic_id = $topic_id - AND " . topic_visibility::get_visibility_sql('post', $forum_id, 'p.') . ' + AND " . phpbb_visibility::get_visibility_sql('post', $forum_id, 'p.') . ' ' . (($mode == 'post_review') ? " AND p.post_id > $cur_post_id" : '') . ' ' . (($mode == 'post_review_edit') ? " AND p.post_id = $cur_post_id" : '') . ' ORDER BY p.post_time '; @@ -1542,7 +1542,7 @@ function delete_post($forum_id, $topic_id, $post_id, &$data) $sql = 'SELECT MAX(post_id) as last_post_id FROM ' . POSTS_TABLE . " WHERE topic_id = $topic_id - AND " . topic_visibility::get_visibility_sql('post', $forum_id); + AND " . phpbb_visibility::get_visibility_sql('post', $forum_id); $result = $db->sql_query($sql); $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); @@ -1555,7 +1555,7 @@ function delete_post($forum_id, $topic_id, $post_id, &$data) $sql = 'SELECT post_id FROM ' . POSTS_TABLE . " WHERE topic_id = $topic_id - AND " . topic_visibility::get_visibility_sql('post', $forum_id) . ' + AND " . phpbb_visibility::get_visibility_sql('post', $forum_id) . ' AND post_time > ' . $data['post_time'] . ' ORDER BY post_time ASC'; $result = $db->sql_query_limit($sql, 1); diff --git a/phpBB/includes/mcp/mcp_forum.php b/phpBB/includes/mcp/mcp_forum.php index 48b9c7c2d3..90c0224b40 100644 --- a/phpBB/includes/mcp/mcp_forum.php +++ b/phpBB/includes/mcp/mcp_forum.php @@ -154,7 +154,7 @@ function mcp_forum_view($id, $mode, $action, $forum_info) $sql = 'SELECT t.topic_id FROM ' . TOPICS_TABLE . ' t WHERE t.forum_id = ' . $forum_id . ' - ' . topic_visibility::get_visibility_sql('topic', $forum_id, 't.') . " + ' . phpbb_visibility::get_visibility_sql('topic', $forum_id, 't.') . " $limit_time_sql ORDER BY t.topic_type DESC, $sort_order_sql"; $result = $db->sql_query_limit($sql, $topics_per_page, $start); diff --git a/phpBB/includes/mcp/mcp_topic.php b/phpBB/includes/mcp/mcp_topic.php index f6fd12f0c4..5c25da7a9d 100644 --- a/phpBB/includes/mcp/mcp_topic.php +++ b/phpBB/includes/mcp/mcp_topic.php @@ -146,7 +146,7 @@ function mcp_topic_view($id, $mode, $action) FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . ' u WHERE ' . (($action == 'reports') ? 'p.post_reported = 1 AND ' : '') . ' p.topic_id = ' . $topic_id . ' - AND ' . topic_visibility::get_visibility_sql('post', $topic_info['forum_id'], 'p.') . ' + AND ' . phpbb_visibility::get_visibility_sql('post', $topic_info['forum_id'], 'p.') . ' AND p.poster_id = u.user_id ' . $limit_time_sql . ' ORDER BY ' . $sort_order_sql; diff --git a/phpBB/posting.php b/phpBB/posting.php index 273499c1e4..30b897c068 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -87,7 +87,7 @@ switch ($mode) FROM ' . TOPICS_TABLE . ' t, ' . FORUMS_TABLE . " f WHERE t.topic_id = $topic_id AND f.forum_id = t.forum_id - AND " . topic_visibility::get_visibility_sql('topic', $forum_id, 't.'); + AND " . phpbb_visibility::get_visibility_sql('topic', $forum_id, 't.'); break; case 'quote': @@ -115,7 +115,7 @@ switch ($mode) AND t.topic_id = p.topic_id AND u.user_id = p.poster_id AND f.forum_id = t.forum_id - AND " . topic_visibility::get_visibility_sql('topic', $forum_id, 't.'); + AND " . phpbb_visibility::get_visibility_sql('topic', $forum_id, 't.'); break; case 'smilies': diff --git a/phpBB/search.php b/phpBB/search.php index 7bf941f127..9ff3c2e027 100644 --- a/phpBB/search.php +++ b/phpBB/search.php @@ -266,7 +266,7 @@ if ($keywords || $author || $author_id || $search_id || $submit) $m_approve_fid_sql = ' AND p.post_approved = 1'; } */ - $m_approve_fid_sql = ' AND ' . topic_visibility::get_visibility_sql_global('post', $ex_fid_ary, 'p.'); + $m_approve_fid_sql = ' AND ' . phpbb_visibility::get_visibility_sql_global('post', $ex_fid_ary, 'p.'); if ($reset_search_forum) { diff --git a/phpBB/viewforum.php b/phpBB/viewforum.php index 2c29d92cd8..c775d33631 100644 --- a/phpBB/viewforum.php +++ b/phpBB/viewforum.php @@ -241,7 +241,7 @@ if ($sort_days) AND (topic_last_post_time >= $min_post_time OR topic_type = " . POST_ANNOUNCE . ' OR topic_type = ' . POST_GLOBAL . ') - AND ' . topic_visibility::get_visibility_sql('topic', $forum_id); + AND ' . phpbb_visibility::get_visibility_sql('topic', $forum_id); $result = $db->sql_query($sql); $topics_count = (int) $db->sql_fetchfield('num_topics'); $db->sql_freeresult($result); @@ -353,7 +353,7 @@ $sql_array = array( 'LEFT_JOIN' => array(), ); -$sql_approved = 'AND ' . topic_visibility::get_visibility_sql('topic', $forum_id, 't.'); +$sql_approved = 'AND ' . phpbb_visibility::get_visibility_sql('topic', $forum_id, 't.'); if ($user->data['is_registered']) { diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index 282c23cd70..b6c47211f7 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -83,7 +83,7 @@ if ($view && !$post_id) $sql = 'SELECT post_id, topic_id, forum_id FROM ' . POSTS_TABLE . " WHERE topic_id = $topic_id - AND " . topic_visibility::get_visibility_sql('post', $forum_id) . " + AND " . phpbb_visibility::get_visibility_sql('post', $forum_id) . " AND post_time > $topic_last_read AND forum_id = $forum_id ORDER BY post_time ASC"; @@ -137,7 +137,7 @@ if ($view && !$post_id) WHERE forum_id = ' . $row['forum_id'] . " AND topic_moved_id = 0 AND topic_last_post_time $sql_condition {$row['topic_last_post_time']} - AND" . topic_visibility::get_visibility_sql('topic', $row['forum_id']) . " + AND" . phpbb_visibility::get_visibility_sql('topic', $row['forum_id']) . " ORDER BY topic_last_post_time $sql_ordering"; $result = $db->sql_query_limit($sql, 1); $row = $db->sql_fetchrow($result); @@ -277,7 +277,7 @@ if ($post_id) $sql = 'SELECT COUNT(p.post_id) AS prev_posts FROM ' . POSTS_TABLE . " p WHERE p.topic_id = {$topic_data['topic_id']} - " . topic_visibility::get_visibility_sql('post', $forum_id, 'p'); + " . phpbb_visibility::get_visibility_sql('post', $forum_id, 'p'); if ($sort_dir == 'd') { @@ -408,7 +408,7 @@ if ($sort_days) FROM ' . POSTS_TABLE . " WHERE topic_id = $topic_id AND post_time >= $min_post_time - AND " . topic_visibility::get_visibility_sql('post', $forum_id); + AND " . phpbb_visibility::get_visibility_sql('post', $forum_id); $result = $db->sql_query($sql); $total_posts = (int) $db->sql_fetchfield('num_posts'); $db->sql_freeresult($result); @@ -944,7 +944,7 @@ $i = $i_total = 0; $sql = 'SELECT p.post_id FROM ' . POSTS_TABLE . ' p' . (($join_user_sql[$sort_key]) ? ', ' . USERS_TABLE . ' u': '') . " WHERE p.topic_id = $topic_id - AND " . topic_visibility::get_visibility_sql('post', $forum_id, 'p.') . " + AND " . phpbb_visibility::get_visibility_sql('post', $forum_id, 'p.') . " " . (($join_user_sql[$sort_key]) ? 'AND u.user_id = p.poster_id': '') . " $limit_posts_time ORDER BY $sql_sort_order"; From fb13ab83e476d2afbc7bb181f7ab90df98f996da Mon Sep 17 00:00:00 2001 From: Josh Woody Date: Sun, 27 Jun 2010 14:22:36 -0500 Subject: [PATCH 0084/2494] [feature/soft-delete] Implement the ability to soft-delete and restore posts The soft delete feature seems to work. Tests are pending. A real icon is pending. Add the permissions and the interface to soft-delete posts. Also able to restore posts via the MCP queue PHPBB3-9657 --- phpBB/includes/class_visibility.php | 265 +++++++++++++++++- phpBB/includes/functions_posting.php | 116 ++++---- phpBB/includes/mcp/info/mcp_queue.php | 1 + phpBB/includes/mcp/mcp_queue.php | 152 ++-------- phpBB/install/schemas/schema_data.sql | 4 +- phpBB/language/en/acp/common.php | 2 + phpBB/language/en/acp/permissions_phpbb.php | 5 + phpBB/language/en/mcp.php | 2 + phpBB/language/en/posting.php | 2 + phpBB/language/en/viewtopic.php | 2 + phpBB/mcp.php | 6 +- phpBB/posting.php | 51 +++- .../prosilver/imageset/icon_topic_deleted.png | Bin 0 -> 964 bytes phpBB/styles/prosilver/imageset/imageset.cfg | 117 ++++++++ .../styles/prosilver/template/mcp_queue.html | 5 + .../prosilver/template/posting_editor.html | 7 + .../prosilver/template/viewforum_body.html | 2 +- .../prosilver/template/viewtopic_body.html | 2 + phpBB/viewforum.php | 3 +- phpBB/viewtopic.php | 6 +- 20 files changed, 553 insertions(+), 197 deletions(-) create mode 100644 phpBB/styles/prosilver/imageset/icon_topic_deleted.png create mode 100644 phpBB/styles/prosilver/imageset/imageset.cfg diff --git a/phpBB/includes/class_visibility.php b/phpBB/includes/class_visibility.php index 46f188d833..9798e938b1 100644 --- a/phpBB/includes/class_visibility.php +++ b/phpBB/includes/class_visibility.php @@ -125,7 +125,6 @@ class phpbb_visibility // we are adjusting _all_ posts in that topic. $status = self::set_post_visibility($visibility, false, $topic_id, $forum_id, true, true); - return $status; } @@ -172,5 +171,267 @@ class phpbb_visibility update_post_information('forum', $forum_id, false); } } + + /** + * Can the current logged-in user soft-delete posts? + * @param $forum_id - int - the forum ID whose permissions to check + * @param $poster_id - int - the poster ID of the post in question + * @param $post_locked - bool - is the post locked? + * @return bool + */ + public function can_soft_delete($forum_id, $poster_id, $post_locked) + { + global $auth, $user; + + if ($auth->acl_get('m_softdelete', $forum_id)) + { + return true; + } + else if ($auth->acl_get('f_softdelete', $forum_id) && $poster_id == $user->data['poster_id'] && !$post_locked) + { + return true; + } + return false; + } + + /** + * Can the current logged-in user restore soft-deleted posts? + * @param $forum_id - int - the forum ID whose permissions to check + * @param $poster_id - int - the poster ID of the post in question + * @param $post_locked - bool - is the post locked? + * @return bool + */ + public function can_restore($forum_id, $poster_id, $post_locked) + { + global $auth, $user; + + if ($auth->acl_get('m_restore', $forum_id)) + { + return true; + } + else if ($auth->acl_get('f_restore', $forum_id) && $poster_id == $user->data['user_id'] && !$post_locked) + { + return true; + } + return false; + } + + /** + * Do the required math to hide a complete topic (going from approved to + * unapproved or from approved to deleted) + * @param $topic_id - int - the topic to act on + * @param $forum_id - int - the forum where the topic resides + * @param $topic_row - array - data about the topic, may be empty at call time + * @param $sql_data - array - populated with the SQL changes, may be empty at call time + * @return void + */ + public function hide_topic($topic_id, $forum_id, &$topic_row, &$sql_data) + { + global $auth, $config, $db; + + // Do we need to grab some topic informations? + if (!sizeof($topic_row)) + { + $sql = 'SELECT topic_type, topic_replies, topic_replies_real, topic_visibility + FROM ' . TOPICS_TABLE . ' + WHERE topic_id = ' . $topic_id; + $result = $db->sql_query($sql); + $topic_row = $db->sql_fetchrow($result); + $db->sql_freeresult($result); + } + + // If this is the only post remaining we do not need to decrement topic_replies. + // Also do not decrement if first post - then the topic_replies will not be adjusted if approving the topic again. + + // If this is an edited topic or the first post the topic gets completely disapproved later on... + $sql_data[FORUMS_TABLE] = 'forum_topics = forum_topics - 1'; + $sql_data[FORUMS_TABLE] = 'forum_posts = forum_posts - ' . ($topic_row['topic_replies'] + 1); + + set_config_count('num_topics', -1, true); + set_config_count('num_posts', ($topic_row['topic_replies'] + 1) * (-1), true); + + // Only decrement this post, since this is the one non-approved now + if ($auth->acl_get('f_postcount', $forum_id)) + { + $sql_data[USERS_TABLE] = 'user_posts = user_posts - 1'; + } + } + + /** + * Do the required math to hide a single post (going from approved to + * unapproved or from approved to deleted) + * Notably, we do _not_ need the post ID to do this operation. We're only changing statistic caches + * @param $forum_id - int - the forum where the topic resides + * @param $current_time - int - passed for consistency instead of calling time() internally + * @param $sql_data - array - populated with the SQL changes, may be empty at call time + * @return void + */ + public function hide_post($forum_id, $current_time, &$sql_data) + { + global $auth, $config, $db; + + $sql_data[TOPICS_TABLE] = 'topic_replies = topic_replies - 1, topic_last_view_time = ' . $current_time; + $sql_data[FORUMS_TABLE] = 'forum_posts = forum_posts - 1'; + + set_config_count('num_posts', -1, true); + + if ($auth->acl_get('f_postcount', $forum_id)) + { + $sql_data[USERS_TABLE] = 'user_posts = user_posts - 1'; + } + } + + /** + * One function to rule them all ... and unhide posts and topics. This could + * reasonably be broken up, I straight copied this code from the mcp_queue.php + * file here for global access. + * @param $mode - string - member of the set {'approve', 'restore'} + * @param $post_info - array - Contains info from post U topics table about + * the posts/topics in question + * @param $post_id_list - array of ints - the set of posts being worked on + */ + public function unhide_posts_topics($mode, $post_info, $post_id_list) + { + global $db, $config; + + // If Topic -> total_topics = total_topics+1, total_posts = total_posts+1, forum_topics = forum_topics+1, forum_posts = forum_posts+1 + // If Post -> total_posts = total_posts+1, forum_posts = forum_posts+1, topic_replies = topic_replies+1 + + $total_topics = $total_posts = 0; + $topic_approve_sql = $post_approve_sql = $topic_id_list = $forum_id_list = $approve_log = array(); + $user_posts_sql = $post_approved_list = array(); + + foreach ($post_info as $post_id => $post_data) + { + if ($post_data['post_visibility'] == ITEM_APPROVED) + { + $post_approved_list[] = $post_id; + continue; + } + + $topic_id_list[$post_data['topic_id']] = 1; + + if ($post_data['forum_id']) + { + $forum_id_list[$post_data['forum_id']] = 1; + } + + // User post update (we do not care about topic or post, since user posts are strictly connected to posts) + // But we care about forums where post counts get not increased. ;) + if ($post_data['post_postcount']) + { + $user_posts_sql[$post_data['poster_id']] = (empty($user_posts_sql[$post_data['poster_id']])) ? 1 : $user_posts_sql[$post_data['poster_id']] + 1; + } + + // Topic or Post. ;) + if ($post_data['topic_first_post_id'] == $post_id) + { + if ($post_data['forum_id']) + { + $total_topics++; + } + $topic_approve_sql[] = $post_data['topic_id']; + + $approve_log[] = array( + 'type' => 'topic', + 'post_subject' => $post_data['post_subject'], + 'forum_id' => $post_data['forum_id'], + 'topic_id' => $post_data['topic_id'], + ); + } + else + { + $approve_log[] = array( + 'type' => 'post', + 'post_subject' => $post_data['post_subject'], + 'forum_id' => $post_data['forum_id'], + 'topic_id' => $post_data['topic_id'], + ); + } + + if ($post_data['forum_id']) + { + $total_posts++; + + // Increment by topic_replies if we approve a topic... + // This works because we do not adjust the topic_replies when re-approving a topic after an edit. + if ($post_data['topic_first_post_id'] == $post_id && $post_data['topic_replies']) + { + $total_posts += $post_data['topic_replies']; + } + } + + $post_approve_sql[] = $post_id; + } + + $post_id_list = array_values(array_diff($post_id_list, $post_approved_list)); + for ($i = 0, $size = sizeof($post_approved_list); $i < $size; $i++) + { + unset($post_info[$post_approved_list[$i]]); + } + + if (sizeof($topic_approve_sql)) + { + $sql = 'UPDATE ' . TOPICS_TABLE . ' + SET topic_visibility = ' . ITEM_APPROVED . ' + WHERE ' . $db->sql_in_set('topic_id', $topic_approve_sql); + $db->sql_query($sql); + } + + if (sizeof($post_approve_sql)) + { + $sql = 'UPDATE ' . POSTS_TABLE . ' + SET post_visibility = ' . ITEM_APPROVED . ' + WHERE ' . $db->sql_in_set('post_id', $post_approve_sql); + $db->sql_query($sql); + } + + unset($topic_approve_sql, $post_approve_sql); + + foreach ($approve_log as $log_data) + { + add_log('mod', $log_data['forum_id'], $log_data['topic_id'], ($log_data['type'] == 'topic') ? 'LOG_TOPIC_' . strtoupper($mode) . 'D' : 'LOG_POST_' . strtoupper($mode) . 'D', $log_data['post_subject']); + } + + if (sizeof($user_posts_sql)) + { + // Try to minimize the query count by merging users with the same post count additions + $user_posts_update = array(); + + foreach ($user_posts_sql as $user_id => $user_posts) + { + $user_posts_update[$user_posts][] = $user_id; + } + + foreach ($user_posts_update as $user_posts => $user_id_ary) + { + $sql = 'UPDATE ' . USERS_TABLE . ' + SET user_posts = user_posts + ' . $user_posts . ' + WHERE ' . $db->sql_in_set('user_id', $user_id_ary); + $db->sql_query($sql); + } + } + + if ($total_topics) + { + set_config_count('num_topics', $total_topics, true); + } + + if ($total_posts) + { + set_config_count('num_posts', $total_posts, true); + } + + if (!function_exists('sync')) + { + global $phpbb_root_path, $phpEx; + include ($phpbb_root_path . 'includes/functions_admin.'.$phpEx); + } + + sync('topic', 'topic_id', array_keys($topic_id_list), true); + sync('forum', 'forum_id', array_keys($forum_id_list), true, true); + unset($topic_id_list, $forum_id_list); + + return true; + } } -?> diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index 12448ea0ce..b264e35a93 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -1411,7 +1411,7 @@ function user_notification($mode, $subject, $topic_title, $forum_name, $forum_id /** * Delete Post */ -function delete_post($forum_id, $topic_id, $post_id, &$data) +function delete_post($forum_id, $topic_id, $post_id, &$data, $is_soft = false) { global $db, $user, $auth; global $config, $phpEx, $phpbb_root_path; @@ -1422,10 +1422,14 @@ function delete_post($forum_id, $topic_id, $post_id, &$data) { $post_mode = 'delete_topic'; } - else if ($data['topic_first_post_id'] == $post_id) + else if ($data['topic_first_post_id'] == $post_id && !$is_soft) { $post_mode = 'delete_first_post'; } + else if ($data['topic_first_post_id'] == $post_id && $is_soft) + { + $post_mode = 'delete_topic'; + } else if ($data['topic_last_post_id'] == $post_id) { $post_mode = 'delete_last_post'; @@ -1460,14 +1464,22 @@ function delete_post($forum_id, $topic_id, $post_id, &$data) $db->sql_freeresult($result); } - if (!delete_posts('post_id', array($post_id), false, false)) + if ($is_soft) { - // Try to delete topic, we may had an previous error causing inconsistency - if ($post_mode == 'delete_topic') + phpbb_visibility::set_post_visibility(ITEM_DELETED, $post_id, $topic_id, $forum_id, ($data['topic_first_post_id'] == $post_id), ($data['topic_last_post_id'] == $post_id)); + phpbb_visibility::hide_post($forum_id, time(), $sql_data); + } + else + { + if (!delete_posts('post_id', array($post_id), false, false)) { - delete_topics('topic_id', array($topic_id), false); + // Try to delete topic, we may had an previous error causing inconsistency + if ($post_mode == 'delete_topic') + { + delete_topics('topic_id', array($topic_id), false); + } + trigger_error('ALREADY_DELETED'); } - trigger_error('ALREADY_DELETED'); } $db->sql_transaction('commit'); @@ -1486,17 +1498,31 @@ function delete_post($forum_id, $topic_id, $post_id, &$data) update_post_information('forum', $updated_forum); } - delete_topics('topic_id', array($topic_id), false); - - $sql_data[FORUMS_TABLE] .= 'forum_topics_real = forum_topics_real - 1'; - $sql_data[FORUMS_TABLE] .= ($data['topic_visibility'] == ITEM_APPROVED) ? ', forum_posts = forum_posts - 1, forum_topics = forum_topics - 1' : ''; - - $update_sql = update_post_information('forum', $forum_id, true); - if (sizeof($update_sql)) + if ($is_soft) { - $sql_data[FORUMS_TABLE] .= ($sql_data[FORUMS_TABLE]) ? ', ' : ''; - $sql_data[FORUMS_TABLE] .= implode(', ', $update_sql[$forum_id]); + $topic_row = array(); + phpbb_visibility::set_topic_visibility(POST_DELETED, $topic_id, $forum_id); + phpbb_visibility::hide_topic($topic_id, $forum_id, $topic_row, $sql_data); } + else + { + delete_topics('topic_id', array($topic_id), false); + + + if ($data['topic_type'] != POST_GLOBAL) + { + $sql_data[FORUMS_TABLE] .= 'forum_topics_real = forum_topics_real - 1'; + $sql_data[FORUMS_TABLE] .= ($data['topic_visibility'] == ITEM_APPROVED) ? ', forum_posts = forum_posts - 1, forum_topics = forum_topics - 1' : ''; + } + + $update_sql = update_post_information('forum', $forum_id, true); + if (sizeof($update_sql)) + { + $sql_data[FORUMS_TABLE] .= ($sql_data[FORUMS_TABLE]) ? ', ' : ''; + $sql_data[FORUMS_TABLE] .= implode(', ', $update_sql[$forum_id]); + } + } + break; case 'delete_first_post': @@ -1520,19 +1546,27 @@ function delete_post($forum_id, $topic_id, $post_id, &$data) break; case 'delete_last_post': - $sql_data[FORUMS_TABLE] = ($data['post_visibility'] == ITEM_APPROVED) ? 'forum_posts = forum_posts - 1' : ''; - - $update_sql = update_post_information('forum', $forum_id, true); - if (sizeof($update_sql)) + if ($is_soft) { - $sql_data[FORUMS_TABLE] .= ($sql_data[FORUMS_TABLE]) ? ', ' : ''; - $sql_data[FORUMS_TABLE] .= implode(', ', $update_sql[$forum_id]); + phpbb_visibility::hide_post($forum_id, time(), $sql_data); + phpbb_visibility::set_post_visibility($post_id, $topic_id, $forum_id, false, true); + } + else + { + $sql_data[FORUMS_TABLE] = ($data['post_visibility'] == ITEM_APPROVED) ? 'forum_posts = forum_posts - 1' : ''; + + $update_sql = update_post_information('forum', $forum_id, true); + if (sizeof($update_sql)) + { + $sql_data[FORUMS_TABLE] .= ($sql_data[FORUMS_TABLE]) ? ', ' : ''; + $sql_data[FORUMS_TABLE] .= implode(', ', $update_sql[$forum_id]); + } + + $sql_data[TOPICS_TABLE] = 'topic_bumped = 0, topic_bumper = 0, topic_replies_real = topic_replies_real - 1' . (($data['post_visibility'] == ITEM_APPROVED) ? ', topic_replies = topic_replies - 1' : ''); } - $sql_data[TOPICS_TABLE] = 'topic_bumped = 0, topic_bumper = 0, topic_replies_real = topic_replies_real - 1' . (($data['post_visibility'] == ITEM_APPROVED) ? ', topic_replies = topic_replies - 1' : ''); - $update_sql = update_post_information('topic', $topic_id, true); - if (sizeof($update_sql)) + if (sizeof($update_sql) && !$is_soft) { $sql_data[TOPICS_TABLE] .= ', ' . implode(', ', $update_sql[$topic_id]); $next_post_id = (int) str_replace('topic_last_post_id = ', '', $update_sql[$topic_id][0]); @@ -1702,7 +1736,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u // Mods are able to force approved/unapproved posts. True means the post is approved, false the post is unapproved if (isset($data['force_approved_state'])) { - $post_approval = ($data['force_approved_state']) ? 1 : 0; + $post_approval = ($data['force_approved_state']) ? ITEM_APPROVED : ITEM_UNAPPROVED; } // Start the transaction here @@ -1915,32 +1949,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u // Correctly set back the topic replies and forum posts... only if the topic was approved before and now gets disapproved if (!$post_approval && $data['topic_visibility'] == ITEM_APPROVED) { - // Do we need to grab some topic informations? - if (!sizeof($topic_row)) - { - $sql = 'SELECT topic_type, topic_replies, topic_replies_real, topic_visibility - FROM ' . TOPICS_TABLE . ' - WHERE topic_id = ' . $data['topic_id']; - $result = $db->sql_query($sql); - $topic_row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - } - - // If this is the only post remaining we do not need to decrement topic_replies. - // Also do not decrement if first post - then the topic_replies will not be adjusted if approving the topic again. - - // If this is an edited topic or the first post the topic gets completely disapproved later on... - $sql_data[FORUMS_TABLE]['stat'][] = 'forum_topics = forum_topics - 1'; - $sql_data[FORUMS_TABLE]['stat'][] = 'forum_posts = forum_posts - ' . ($topic_row['topic_replies'] + 1); - - set_config_count('num_topics', -1, true); - set_config_count('num_posts', ($topic_row['topic_replies'] + 1) * (-1), true); - - // Only decrement this post, since this is the one non-approved now - if ($auth->acl_get('f_postcount', $data['forum_id'])) - { - $sql_data[USERS_TABLE]['stat'][] = 'user_posts = user_posts - 1'; - } + phpbb_visibility::hide_topic($data['topic_id'], $data['forum_id'], $topic_row, $sql_data); } break; @@ -1951,6 +1960,8 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u // Correctly set back the topic replies and forum posts... but only if the post was approved before. if (!$post_approval && $data['post_visibility'] == ITEM_APPROVED) { + //phpbb_visibility::hide_post($forum_id, $current_time, $sql_data); + // ^^ hide_post SQL is identical, except that it does not include the ['stat'] sub-array $sql_data[TOPICS_TABLE]['stat'][] = 'topic_replies = topic_replies - 1, topic_last_view_time = ' . $current_time; $sql_data[FORUMS_TABLE]['stat'][] = 'forum_posts = forum_posts - 1'; @@ -1960,6 +1971,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u { $sql_data[USERS_TABLE]['stat'][] = 'user_posts = user_posts - 1'; } + } break; diff --git a/phpBB/includes/mcp/info/mcp_queue.php b/phpBB/includes/mcp/info/mcp_queue.php index 7ad79f9781..31e9cc9af6 100644 --- a/phpBB/includes/mcp/info/mcp_queue.php +++ b/phpBB/includes/mcp/info/mcp_queue.php @@ -21,6 +21,7 @@ class mcp_queue_info 'modes' => array( 'unapproved_topics' => array('title' => 'MCP_QUEUE_UNAPPROVED_TOPICS', 'auth' => 'aclf_m_approve', 'cat' => array('MCP_QUEUE')), 'unapproved_posts' => array('title' => 'MCP_QUEUE_UNAPPROVED_POSTS', 'auth' => 'aclf_m_approve', 'cat' => array('MCP_QUEUE')), + 'deleted_posts' => array('title' => 'MCP_QUEUE_DELETED_POSTS', 'auth' => 'aclf_m_restore', 'cat' => array('MCP_QUEUE')), 'approve_details' => array('title' => 'MCP_QUEUE_APPROVE_DETAILS', 'auth' => 'acl_m_approve,$id || (!$id && aclf_m_approve)', 'cat' => array('MCP_QUEUE')), ), ); diff --git a/phpBB/includes/mcp/mcp_queue.php b/phpBB/includes/mcp/mcp_queue.php index 833f924efc..c19fb9b2b6 100644 --- a/phpBB/includes/mcp/mcp_queue.php +++ b/phpBB/includes/mcp/mcp_queue.php @@ -46,6 +46,7 @@ class mcp_queue { case 'approve': case 'disapprove': + case 'restore': include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx); $post_id_list = request_var('post_id_list', array(0)); @@ -59,6 +60,10 @@ class mcp_queue { approve_post($post_id_list, 'queue', $mode); } + else if ($action == 'restore') + { +// do something + } else { disapprove_post($post_id_list, 'queue', $mode); @@ -224,6 +229,16 @@ class mcp_queue case 'unapproved_topics': case 'unapproved_posts': + case 'deleted_posts': + if ($mode == 'deleted_posts') + { + $m_perm = 'm_restore'; + } + else + { + $m_perm = 'm_approve'; + } + $user->add_lang(array('viewtopic', 'viewforum')); $topic_id = request_var('t', 0); @@ -242,7 +257,7 @@ class mcp_queue $forum_id = $topic_info['forum_id']; } - $forum_list_approve = get_forum_list('m_approve', false, true); + $forum_list_approve = get_forum_list($m_perm, false, true); $forum_list_read = array_flip(get_forum_list('f_read', true, true)); // Flipped so we can isset() the forum IDs // Remove forums we cannot read @@ -277,7 +292,7 @@ class mcp_queue } else { - $forum_info = get_forum_data(array($forum_id), 'm_approve'); + $forum_info = get_forum_data(array($forum_id), $m_perm); if (!sizeof($forum_info)) { @@ -304,8 +319,10 @@ class mcp_queue $forum_names = array(); - if ($mode == 'unapproved_posts') + if ($mode == 'unapproved_posts' || $mode == 'deleted_posts') { + $visibility_const = ($mode == 'unapproved_posts') ? ITEM_UNAPPROVED : ITEM_DELETED; + $sql = 'SELECT p.post_id FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t' . (($sort_order_sql[0] == 'u') ? ', ' . USERS_TABLE . ' u' : '') . ' WHERE ' . $db->sql_in_set('p.forum_id', $forum_list) . ' @@ -425,13 +442,14 @@ class mcp_queue // Now display the page $template->assign_vars(array( 'L_DISPLAY_ITEMS' => ($mode == 'unapproved_posts') ? $user->lang['DISPLAY_POSTS'] : $user->lang['DISPLAY_TOPICS'], - 'L_EXPLAIN' => ($mode == 'unapproved_posts') ? $user->lang['MCP_QUEUE_UNAPPROVED_POSTS_EXPLAIN'] : $user->lang['MCP_QUEUE_UNAPPROVED_TOPICS_EXPLAIN'], - 'L_TITLE' => ($mode == 'unapproved_posts') ? $user->lang['MCP_QUEUE_UNAPPROVED_POSTS'] : $user->lang['MCP_QUEUE_UNAPPROVED_TOPICS'], + 'L_EXPLAIN' => $user->lang['MCP_QUEUE_' . strtoupper($mode) . '_EXPLAIN'], + 'L_TITLE' => $user->lang['MCP_QUEUE_' . strtoupper($mode)], 'L_ONLY_TOPIC' => ($topic_id) ? sprintf($user->lang['ONLY_TOPIC'], $topic_info['topic_title']) : '', 'S_FORUM_OPTIONS' => $forum_options, 'S_MCP_ACTION' => build_url(array('t', 'f', 'sd', 'st', 'sk')), - 'S_TOPICS' => ($mode == 'unapproved_posts') ? false : true, + 'S_TOPICS' => ($mode == 'unapproved_topics') ? true : false, + 'S_RESTORE' => ($mode == 'deleted_posts') ? true : false, 'PAGE_NUMBER' => phpbb_on_page($template, $user, $base_url, $total, $config['topics_per_page'], $start), 'TOPIC_ID' => $topic_id, @@ -475,127 +493,7 @@ function approve_post($post_id_list, $id, $mode) { $notify_poster = (isset($_REQUEST['notify_poster'])) ? true : false; - // If Topic -> total_topics = total_topics+1, total_posts = total_posts+1, forum_topics = forum_topics+1, forum_posts = forum_posts+1 - // If Post -> total_posts = total_posts+1, forum_posts = forum_posts+1, topic_replies = topic_replies+1 - - $total_topics = $total_posts = 0; - $topic_approve_sql = $post_approve_sql = $topic_id_list = $forum_id_list = $approve_log = array(); - $user_posts_sql = $post_approved_list = array(); - - foreach ($post_info as $post_id => $post_data) - { - if ($post_data['post_visibility'] == ITEM_APPROVED) - { - $post_approved_list[] = $post_id; - continue; - } - - $topic_id_list[$post_data['topic_id']] = 1; - $forum_id_list[$post_data['forum_id']] = 1; - - // User post update (we do not care about topic or post, since user posts are strictly connected to posts) - // But we care about forums where post counts get not increased. ;) - if ($post_data['post_postcount']) - { - $user_posts_sql[$post_data['poster_id']] = (empty($user_posts_sql[$post_data['poster_id']])) ? 1 : $user_posts_sql[$post_data['poster_id']] + 1; - } - - // Topic or Post. ;) - if ($post_data['topic_first_post_id'] == $post_id) - { - $total_topics++; - $topic_approve_sql[] = $post_data['topic_id']; - - $approve_log[] = array( - 'type' => 'topic', - 'post_subject' => $post_data['post_subject'], - 'forum_id' => $post_data['forum_id'], - 'topic_id' => $post_data['topic_id'], - ); - } - else - { - $approve_log[] = array( - 'type' => 'post', - 'post_subject' => $post_data['post_subject'], - 'forum_id' => $post_data['forum_id'], - 'topic_id' => $post_data['topic_id'], - ); - } - - $total_posts++; - - // Increment by topic_replies if we approve a topic... - // This works because we do not adjust the topic_replies when re-approving a topic after an edit. - if ($post_data['topic_first_post_id'] == $post_id && $post_data['topic_replies']) - { - $total_posts += $post_data['topic_replies']; - } - - $post_approve_sql[] = $post_id; - } - - $post_id_list = array_values(array_diff($post_id_list, $post_approved_list)); - for ($i = 0, $size = sizeof($post_approved_list); $i < $size; $i++) - { - unset($post_info[$post_approved_list[$i]]); - } - - if (sizeof($topic_approve_sql)) - { - $sql = 'UPDATE ' . TOPICS_TABLE . ' - SET topic_visibility = ' . ITEM_APPROVED . ' - WHERE ' . $db->sql_in_set('topic_id', $topic_approve_sql); - $db->sql_query($sql); - } - - if (sizeof($post_approve_sql)) - { - $sql = 'UPDATE ' . POSTS_TABLE . ' - SET post_visibility = ' . ITEM_APPROVED . ' - WHERE ' . $db->sql_in_set('post_id', $post_approve_sql); - $db->sql_query($sql); - } - - unset($topic_approve_sql, $post_approve_sql); - - foreach ($approve_log as $log_data) - { - add_log('mod', $log_data['forum_id'], $log_data['topic_id'], ($log_data['type'] == 'topic') ? 'LOG_TOPIC_APPROVED' : 'LOG_POST_APPROVED', $log_data['post_subject']); - } - - if (sizeof($user_posts_sql)) - { - // Try to minimize the query count by merging users with the same post count additions - $user_posts_update = array(); - - foreach ($user_posts_sql as $user_id => $user_posts) - { - $user_posts_update[$user_posts][] = $user_id; - } - - foreach ($user_posts_update as $user_posts => $user_id_ary) - { - $sql = 'UPDATE ' . USERS_TABLE . ' - SET user_posts = user_posts + ' . $user_posts . ' - WHERE ' . $db->sql_in_set('user_id', $user_id_ary); - $db->sql_query($sql); - } - } - - if ($total_topics) - { - set_config_count('num_topics', $total_topics, true); - } - - if ($total_posts) - { - set_config_count('num_posts', $total_posts, true); - } - - sync('topic', 'topic_id', array_keys($topic_id_list), true); - sync('forum', 'forum_id', array_keys($forum_id_list), true, true); - unset($topic_id_list, $forum_id_list); + phpbb_visibility::unhide_posts_topics('approve', $post_info, $post_id_list); $messenger = new messenger(); diff --git a/phpBB/install/schemas/schema_data.sql b/phpBB/install/schemas/schema_data.sql index 938b11388b..e70e3db4d4 100644 --- a/phpBB/install/schemas/schema_data.sql +++ b/phpBB/install/schemas/schema_data.sql @@ -315,6 +315,7 @@ INSERT INTO phpbb_acl_options (auth_option, is_local) VALUES ('f_user_lock', 1); INSERT INTO phpbb_acl_options (auth_option, is_local) VALUES ('f_vote', 1); INSERT INTO phpbb_acl_options (auth_option, is_local) VALUES ('f_votechg', 1); INSERT INTO phpbb_acl_options (auth_option, is_local) VALUES ('f_restore', 1); +INSERT INTO phpbb_acl_options (auth_option, is_local) VALUES ('f_softdelete', 1); # -- Moderator related auth options INSERT INTO phpbb_acl_options (auth_option, is_local, is_global) VALUES ('m_', 1, 1); @@ -329,6 +330,7 @@ INSERT INTO phpbb_acl_options (auth_option, is_local, is_global) VALUES ('m_move INSERT INTO phpbb_acl_options (auth_option, is_local, is_global) VALUES ('m_report', 1, 1); INSERT INTO phpbb_acl_options (auth_option, is_local, is_global) VALUES ('m_split', 1, 1); INSERT INTO phpbb_acl_options (auth_option, is_local, is_global) VALUES ('m_restore', 1, 1); +INSERT INTO phpbb_acl_options (auth_option, is_local, is_global) VALUES ('m_softdelete', 1, 1); # -- Global moderator auth option (not a local option) INSERT INTO phpbb_acl_options (auth_option, is_local, is_global) VALUES ('m_ban', 0, 1); @@ -513,7 +515,7 @@ INSERT INTO phpbb_acl_roles_data (role_id, auth_option_id, auth_setting) SELECT INSERT INTO phpbb_acl_roles_data (role_id, auth_option_id, auth_setting) SELECT 11, auth_option_id, 1 FROM phpbb_acl_options WHERE auth_option LIKE 'm_%' AND auth_option NOT IN ('m_ban', 'm_chgposter'); # Simple Moderator (m_) -INSERT INTO phpbb_acl_roles_data (role_id, auth_option_id, auth_setting) SELECT 12, auth_option_id, 1 FROM phpbb_acl_options WHERE auth_option LIKE 'm_%' AND auth_option IN ('m_', 'm_delete', 'm_edit', 'm_info', 'm_report'); +INSERT INTO phpbb_acl_roles_data (role_id, auth_option_id, auth_setting) SELECT 12, auth_option_id, 1 FROM phpbb_acl_options WHERE auth_option LIKE 'm_%' AND auth_option IN ('m_', 'm_delete', 'm_softdelete', 'm_restore', 'm_edit', 'm_info', 'm_report'); # Queue Moderator (m_) INSERT INTO phpbb_acl_roles_data (role_id, auth_option_id, auth_setting) SELECT 13, auth_option_id, 1 FROM phpbb_acl_options WHERE auth_option LIKE 'm_%' AND auth_option IN ('m_', 'm_approve', 'm_edit'); diff --git a/phpBB/language/en/acp/common.php b/phpBB/language/en/acp/common.php index 04df897dba..91a35311bc 100644 --- a/phpBB/language/en/acp/common.php +++ b/phpBB/language/en/acp/common.php @@ -554,12 +554,14 @@ $lang = array_merge($lang, array( 'LOG_POST_APPROVED' => 'Approved post
    » %s', 'LOG_POST_DISAPPROVED' => 'Disapproved post “%1$s” with the following reason
    » %2$s', 'LOG_POST_EDITED' => 'Edited post “%1$s” written by
    » %2$s', + 'LOG_POST_RESTORED' => 'Restored post
    » %s', 'LOG_REPORT_CLOSED' => 'Closed report
    » %s', 'LOG_REPORT_DELETED' => 'Deleted report
    » %s', 'LOG_SPLIT_DESTINATION' => 'Moved split posts
    » to %s', 'LOG_SPLIT_SOURCE' => 'Split posts
    » from %s', 'LOG_TOPIC_APPROVED' => 'Approved topic
    » %s', + 'LOG_TOPIC_RESTORED' => 'Restored topic
    » %s', 'LOG_TOPIC_DISAPPROVED' => 'Disapproved topic “%1$s” with the following reason
    %2$s', 'LOG_TOPIC_RESYNC' => 'Resynchronised topic counters
    » %s', 'LOG_TOPIC_TYPE_CHANGED' => 'Changed topic type
    » %s', diff --git a/phpBB/language/en/acp/permissions_phpbb.php b/phpBB/language/en/acp/permissions_phpbb.php index 17649693fa..0a089f9dc1 100644 --- a/phpBB/language/en/acp/permissions_phpbb.php +++ b/phpBB/language/en/acp/permissions_phpbb.php @@ -156,6 +156,8 @@ $lang = array_merge($lang, array( 'acl_f_flash' => array('lang' => 'Can use [flash] BBCode tag', 'cat' => 'content'), 'acl_f_edit' => array('lang' => 'Can edit own posts', 'cat' => 'actions'), + 'acl_f_softdelete' => array('lang' => 'Can soft delete own posts', 'cat' => 'actions'), + 'acl_f_restore' => array('lang' => 'Can restore own posts', 'cat' => 'actions'), 'acl_f_delete' => array('lang' => 'Can delete own posts', 'cat' => 'actions'), 'acl_f_user_lock' => array('lang' => 'Can lock own topics', 'cat' => 'actions'), 'acl_f_bump' => array('lang' => 'Can bump topics', 'cat' => 'actions'), @@ -177,12 +179,15 @@ $lang = array_merge($lang, array( 'acl_m_approve' => array('lang' => 'Can approve posts', 'cat' => 'post_actions'), 'acl_m_report' => array('lang' => 'Can close and delete reports', 'cat' => 'post_actions'), 'acl_m_chgposter' => array('lang' => 'Can change post author', 'cat' => 'post_actions'), + 'acl_m_softdelete' => array('lang' => 'Can soft delete posts', 'cat' => 'post_actions'), + 'acl_m_restore' => array('lang' => 'Can restore deleted posts', 'cat' => 'post_actions'), 'acl_m_move' => array('lang' => 'Can move topics', 'cat' => 'topic_actions'), 'acl_m_lock' => array('lang' => 'Can lock topics', 'cat' => 'topic_actions'), 'acl_m_split' => array('lang' => 'Can split topics', 'cat' => 'topic_actions'), 'acl_m_merge' => array('lang' => 'Can merge topics', 'cat' => 'topic_actions'), + 'acl_m_info' => array('lang' => 'Can view post details', 'cat' => 'misc'), 'acl_m_warn' => array('lang' => 'Can issue warnings
    This setting is only assigned globally. It is not forum based.', 'cat' => 'misc'), // This moderator setting is only global (and not local) 'acl_m_ban' => array('lang' => 'Can manage bans
    This setting is only assigned globally. It is not forum based.', 'cat' => 'misc'), // This moderator setting is only global (and not local) diff --git a/phpBB/language/en/mcp.php b/phpBB/language/en/mcp.php index eaa2d7e3a5..175fa72829 100644 --- a/phpBB/language/en/mcp.php +++ b/phpBB/language/en/mcp.php @@ -201,6 +201,8 @@ $lang = array_merge($lang, array( 'MCP_QUEUE_UNAPPROVED_POSTS_EXPLAIN' => 'This is a list of all posts which require approving before they will be visible to users.', 'MCP_QUEUE_UNAPPROVED_TOPICS' => 'Topics awaiting approval', 'MCP_QUEUE_UNAPPROVED_TOPICS_EXPLAIN' => 'This is a list of all topics which require approving before they will be visible to users.', + 'MCP_QUEUE_DELETED_POSTS' => 'Deleted posts', + 'MCP_QUEUE_DELETED_POSTS_EXPLAIN' => 'This is a list of all posts which have been soft deleted. You can restore or permanently delete the posts from this screen.', 'MCP_VIEW_USER' => 'View warnings for a specific user', diff --git a/phpBB/language/en/posting.php b/phpBB/language/en/posting.php index 086bd6ffb0..c0edc068dd 100644 --- a/phpBB/language/en/posting.php +++ b/phpBB/language/en/posting.php @@ -209,6 +209,8 @@ $lang = array_merge($lang, array( 'SMILIES' => 'Smilies', 'SMILIES_ARE_OFF' => 'Smilies are OFF', 'SMILIES_ARE_ON' => 'Smilies are ON', + 'SOFT_DELETE_POST' => 'Soft Delete', + 'SOFT_DELETE_POST_EXPLAIN' => 'Soft Deletion can be un-done', 'STICKY_ANNOUNCE_TIME_LIMIT'=> 'Sticky/Announcement time limit', 'STICK_TOPIC_FOR' => 'Stick topic for', 'STICK_TOPIC_FOR_EXPLAIN' => 'Enter 0 or leave blank for a never ending Sticky/Announcement. Please note that this number is relative to the date of the post.', diff --git a/phpBB/language/en/viewtopic.php b/phpBB/language/en/viewtopic.php index 278c064fe7..ce66a5b8e2 100644 --- a/phpBB/language/en/viewtopic.php +++ b/phpBB/language/en/viewtopic.php @@ -89,6 +89,7 @@ $lang = array_merge($lang, array( 'POLL_ENDED_AT' => 'Poll ended at %s', 'POLL_RUN_TILL' => 'Poll runs till %s', 'POLL_VOTED_OPTION' => 'You voted for this option', + 'POST_DELETED_RESTORE' => 'This post has been deleted. It can be restored.', 'PRINT_TOPIC' => 'Print view', 'QUICK_MOD' => 'Quick-mod tools', @@ -96,6 +97,7 @@ $lang = array_merge($lang, array( 'QUOTE' => 'Quote', 'REPLY_TO_TOPIC' => 'Reply to topic', + 'RESTORE' => 'Restore', 'RETURN_POST' => '%sReturn to the post%s', 'SUBMIT_VOTE' => 'Submit vote', diff --git a/phpBB/mcp.php b/phpBB/mcp.php index 984925789f..9877c469b9 100644 --- a/phpBB/mcp.php +++ b/phpBB/mcp.php @@ -640,6 +640,8 @@ function mcp_sorting($mode, &$sort_days, &$sort_key, &$sort_dir, &$sort_by_sql, break; case 'unapproved_posts': + case 'deleted_posts': + $visibility_const = ($mode == 'unapproved_posts') ? ITEM_UNAPPROVED : ITEM_DELETED; $type = 'posts'; $default_key = 't'; $default_dir = 'd'; @@ -648,7 +650,7 @@ function mcp_sorting($mode, &$sort_days, &$sort_key, &$sort_dir, &$sort_by_sql, $sql = 'SELECT COUNT(p.post_id) AS total FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . " t $where_sql " . $db->sql_in_set('p.forum_id', ($forum_id) ? array($forum_id) : array_intersect(get_forum_list('f_read'), get_forum_list('m_approve'))) . ' - AND p.post_visibility = ' . ITEM_UNAPPROVED . ' + AND p.post_visibility = ' . $visibility_const . ' AND t.topic_id = p.topic_id AND t.topic_first_post_id <> p.post_id'; @@ -796,7 +798,7 @@ function mcp_sorting($mode, &$sort_days, &$sort_key, &$sort_dir, &$sort_by_sql, 'S_SELECT_SORT_DAYS' => $s_limit_days) ); - if (($sort_days && $mode != 'viewlogs') || in_array($mode, array('reports', 'unapproved_topics', 'unapproved_posts')) || $where_sql != 'WHERE') + if (($sort_days && $mode != 'viewlogs') || in_array($mode, array('reports', 'unapproved_topics', 'unapproved_posts', 'deleted_posts')) || $where_sql != 'WHERE') { $result = $db->sql_query($sql); $total = (int) $db->sql_fetchfield('total'); diff --git a/phpBB/posting.php b/phpBB/posting.php index 30b897c068..221d469b4a 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -38,8 +38,20 @@ $load = (isset($_POST['load'])) ? true : false; $delete = (isset($_POST['delete'])) ? true : false; $cancel = (isset($_POST['cancel']) && !isset($_POST['save'])) ? true : false; -$refresh = (isset($_POST['add_file']) || isset($_POST['delete_file']) || isset($_POST['cancel_unglobalise']) || $save || $load || $preview) ? true : false; -$mode = ($delete && !$preview && !$refresh && $submit) ? 'delete' : request_var('mode', ''); +$refresh = (isset($_POST['add_file']) || isset($_POST['delete_file']) || isset($_POST['cancel_unglobalise']) || $save || $load || $preview); +$mode = request_var('mode', ''); + +if ($submit && !$refresh) +{ + if (isset($_POST['soft_delete'])) + { + $mode = 'soft_delete'; + } + else if (isset($_POST['delete'])) + { + $mode = 'delete'; + } +} $error = $post_data = array(); $current_time = time(); @@ -93,6 +105,7 @@ switch ($mode) case 'quote': case 'edit': case 'delete': + case 'soft_delete': if (!$post_id) { $user->setup('posting'); @@ -168,6 +181,13 @@ if ($auth->acl_get('m_approve', $forum_id) && ((($mode == 'reply' || $mode == 'b trigger_error(($mode == 'reply' || $mode == 'bump') ? 'TOPIC_UNAPPROVED' : 'POST_UNAPPROVED'); } +if ($mode == 'edit' && $post_data['post_visibility'] == ITEM_DELETED && !isset($_POST['soft_delete']) && phpbb_visibility::can_restore($forum_id, $post_data['poster_id'], $post_data['post_edit_locked'])) +{ + // don't feel that a confirm_box is needed for this + // do not return / trigger_error after this because the post content can also be changed + phpbb_visibility::unhide_posts_topics('restore', array($post_id => $post_data), array($post_id)); +} + if ($mode == 'popup') { upload_popup($post_data['forum_style']); @@ -259,6 +279,13 @@ switch ($mode) $is_authed = true; } break; + + case 'soft_delete': + if ($user->data['is_registered'] && $auth->acl_gets('f_softdelete', 'm_softdelete', $forum_id)) + { + $is_authed = true; + } + break; } if (!$is_authed) @@ -306,9 +333,9 @@ if ($mode == 'edit' && !$auth->acl_get('m_edit', $forum_id)) } // Handle delete mode... -if ($mode == 'delete') +if ($mode == 'delete' || $mode == 'soft_delete') { - handle_post_delete($forum_id, $topic_id, $post_id, $post_data); + handle_post_delete($forum_id, $topic_id, $post_id, $post_data, ($mode == 'soft_delete')); return; } @@ -1401,6 +1428,10 @@ $template->assign_vars(array( 'S_LOCK_TOPIC_CHECKED' => ($lock_topic_checked) ? ' checked="checked"' : '', 'S_LOCK_POST_ALLOWED' => ($mode == 'edit' && $auth->acl_get('m_edit', $forum_id)) ? true : false, 'S_LOCK_POST_CHECKED' => ($lock_post_checked) ? ' checked="checked"' : '', + 'S_SOFT_DELETE_CHECKED' => ($mode == 'edit' && $post_data['post_visibility'] == ITEM_DELETED) ? ' checked="checked"' : '', + 'S_SOFT_DELETE_ALLOWED' => (phpbb_visibility::can_soft_delete($forum_id, $post_data['poster_id'], $lock_post_checked)) ? true : false, + 'S_RESTORE_ALLOWED' => (phpbb_visibility::can_restore($forum_id, $post_data['poster_id'], $lock_post_checked)) ? true : false, + 'S_IS_DELETED' => ($post_data['post_visibility'] == POST_DELETED) ? true : false, 'S_LINKS_ALLOWED' => $url_status, 'S_MAGIC_URL_CHECKED' => ($urls_checked) ? ' checked="checked"' : '', 'S_TYPE_TOGGLE' => $topic_type_toggle, @@ -1494,19 +1525,21 @@ function upload_popup($forum_style = 0) /** * Do the various checks required for removing posts as well as removing it */ -function handle_post_delete($forum_id, $topic_id, $post_id, &$post_data) +function handle_post_delete($forum_id, $topic_id, $post_id, &$post_data, $is_soft) { global $user, $db, $auth, $config; global $phpbb_root_path, $phpEx; + $perm_check = ($is_soft) ? 'softdelete' : 'delete'; + // If moderator removing post or user itself removing post, present a confirmation screen - if ($auth->acl_get('m_delete', $forum_id) || ($post_data['poster_id'] == $user->data['user_id'] && $user->data['is_registered'] && $auth->acl_get('f_delete', $forum_id) && $post_id == $post_data['topic_last_post_id'] && !$post_data['post_edit_locked'] && ($post_data['post_time'] > time() - ($config['delete_time'] * 60) || !$config['delete_time']))) + if ($auth->acl_get("m_$perm_check", $forum_id) || ($post_data['poster_id'] == $user->data['user_id'] && $user->data['is_registered'] && $auth->acl_get("f_$perm_check", $forum_id) && $post_id == $post_data['topic_last_post_id'] && !$post_data['post_edit_locked'] && ($post_data['post_time'] > time() - ($config['delete_time'] * 60) || !$config['delete_time']))) { $s_hidden_fields = build_hidden_fields(array( 'p' => $post_id, 'f' => $forum_id, - 'mode' => 'delete') - ); + 'mode' => ($is_soft) ? 'soft_delete' : 'delete', + )); if (confirm_box(true)) { @@ -1523,7 +1556,7 @@ function handle_post_delete($forum_id, $topic_id, $post_id, &$post_data) 'post_postcount' => $post_data['post_postcount'] ); - $next_post_id = delete_post($forum_id, $topic_id, $post_id, $data); + $next_post_id = delete_post($forum_id, $topic_id, $post_id, $data, $is_soft); $post_username = ($post_data['poster_id'] == ANONYMOUS && !empty($post_data['post_username'])) ? $post_data['post_username'] : $post_data['username']; if ($next_post_id === false) diff --git a/phpBB/styles/prosilver/imageset/icon_topic_deleted.png b/phpBB/styles/prosilver/imageset/icon_topic_deleted.png new file mode 100644 index 0000000000000000000000000000000000000000..e5359030f300ba8aeba1721d73a9508085e0cd7b GIT binary patch literal 964 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbKJOS+@4BLl=OKpFe+g9XuVAkUn?jtWzh?-F^5ZC?wp) z#r^fS?;Ca=OfRZjwSLR%SFe_=*>d;(qqA3U?mKv>r+3oR$B(z~+|}3H`}p~*qN1vU z$Br#nv~2U1EyquuT(WLQa&pG{jhm01x-@C>)SbHzhR3DcxpjBbrcF0*+{n$zJ9P5= zp1pe;n_5ycvaj8|d-m+v!-o%V*>!m9*6mw1Z<@D!RaIs6kt4@;>^Zb+@BW>;cDeh9 zPM@*x#=ZO7cWke(uiwA-(3FXNFQ30ScjnabqleF4xbXM?|Jtg$<;z#D+i~c~x$6^V z&hMKr?c({1`%j#o)ZcgL*yRfs&bPJqSlBuj6&4>je!9H8IzBe`NKe01NDqe~VoS-Ncbty{PM|NrmBz*7K>u!fQ# zzhEGDAOV8~t9LpuUD$cLIEGZ*O1hA~b;Fh|+tV&x;tJ?3=6}k{p}?kWeRI;55;gbh zEi%U@OsQ~fU`R?3HoQ9Vapy+v@HM<0-H!~JI278H&Q|z0Ua6VAho|zVl-t`Bpt1?i z1r1WxdWRK%*0>y=y3q@$jLlPAHY`6gHq!AJlj6E0c2AJ9Dcm0uLr;YUCVG}ky^!{R z0jP{myk0t9(M@==hyBb`9IW7u6sfLW zs>iE+xC*FjMYut5i4Kp^xzf-{0>vLz0hP7=@~M+uyUIX2IWTbL0iSbVW#-S*gF8gI z`L=CMy*}Z=3Xrm@Fu}yay5|{b&oc4~xBUVud;UcKIU7@2x^12DYlz7DaB)LpQI3L5 jD<(gAuy#E=hXKPJN6U2<5(@pmSY_~Z^>bP0l+XkKyf!Oh literal 0 HcmV?d00001 diff --git a/phpBB/styles/prosilver/imageset/imageset.cfg b/phpBB/styles/prosilver/imageset/imageset.cfg new file mode 100644 index 0000000000..bfcf357045 --- /dev/null +++ b/phpBB/styles/prosilver/imageset/imageset.cfg @@ -0,0 +1,117 @@ +# +# phpBB Imageset Configuration File +# +# @package phpBB3 +# @copyright (c) 2006 phpBB Group +# @license http://opensource.org/licenses/gpl-license.php GNU Public License +# +# +# At the left is the name, please do not change this +# At the right the value is entered +# For on/off options the valid values are on, off, 1, 0, true and false +# +# Values get trimmed, if you want to add a space in front or at the end of +# the value, then enclose the value with single or double quotes. +# Single and double quotes do not need to be escaped. +# +# + +# General Information about this style +name = prosilver +copyright = © phpBB Group, 2007 +version = 3.0.7 + +# Images +img_site_logo = site_logo.gif*52*139 +img_poll_left = +img_poll_center = +img_poll_right = +img_icon_friend = +img_icon_foe = + +img_forum_link = forum_link.gif*27*27 +img_forum_read = forum_read.gif*27*27 +img_forum_read_locked = forum_read_locked.gif*27*27 +img_forum_read_subforum = forum_read_subforum.gif*27*27 +img_forum_unread = forum_unread.gif*27*27 +img_forum_unread_locked = forum_unread_locked.gif*27*27 +img_forum_unread_subforum = forum_unread_subforum.gif*27*27 + +img_topic_moved = topic_moved.gif*27*27 + +img_topic_read = topic_read.gif*27*27 +img_topic_read_mine = topic_read_mine.gif*27*27 +img_topic_read_hot = topic_read_hot.gif*27*27 +img_topic_read_hot_mine = topic_read_hot_mine.gif*27*27 +img_topic_read_locked = topic_read_locked.gif*27*27 +img_topic_read_locked_mine = topic_read_locked_mine.gif*27*27 + +img_topic_unread = topic_unread.gif*27*27 +img_topic_unread_mine = topic_unread_mine.gif*27*27 +img_topic_unread_hot = topic_unread_hot.gif*27*27 +img_topic_unread_hot_mine = topic_unread_hot_mine.gif*27*27 +img_topic_unread_locked = topic_unread_locked.gif*27*27 +img_topic_unread_locked_mine = topic_unread_locked_mine.gif*27*27 + +img_sticky_read = sticky_read.gif*27*27 +img_sticky_read_mine = sticky_read_mine.gif*27*27 +img_sticky_read_locked = sticky_read_locked.gif*27*27 +img_sticky_read_locked_mine = sticky_read_locked_mine.gif*27*27 +img_sticky_unread = sticky_unread.gif*27*27 +img_sticky_unread_mine = sticky_unread_mine.gif*27*27 +img_sticky_unread_locked = sticky_unread_locked.gif*27*27 +img_sticky_unread_locked_mine = sticky_unread_locked_mine.gif*27*27 + +img_announce_read = announce_read.gif*27*27 +img_announce_read_mine = announce_read_mine.gif*27*27 +img_announce_read_locked = announce_read_locked.gif*27*27 +img_announce_read_locked_mine = announce_read_locked_mine.gif*27*27 +img_announce_unread = announce_unread.gif*27*27 +img_announce_unread_mine = announce_unread_mine.gif*27*27 +img_announce_unread_locked = announce_unread_locked.gif*27*27 +img_announce_unread_locked_mine = announce_unread_locked_mine.gif*27*27 + +img_global_read = announce_read.gif*27*27 +img_global_read_mine = announce_read_mine.gif*27*27 +img_global_read_locked = announce_read_locked.gif*27*27 +img_global_read_locked_mine = announce_read_locked_mine.gif*27*27 +img_global_unread = announce_unread.gif*27*27 +img_global_unread_mine = announce_unread_mine.gif*27*27 +img_global_unread_locked = announce_unread_locked.gif*27*27 +img_global_unread_locked_mine = announce_unread_locked_mine.gif*27*27 + +img_subforum_read = subforum_read.gif*9*11 +img_subforum_unread = subforum_unread.gif*9*11 + +img_pm_read = topic_read.gif*27*27 +img_pm_unread = topic_unread.gif*27*27 + +img_icon_back_top = icon_back_top.gif*11*11 + +img_icon_contact_aim = icon_contact_aim.gif*20*20 +img_icon_contact_email = icon_contact_email.gif*20*20 +img_icon_contact_icq = icon_contact_icq.gif*20*20 +img_icon_contact_jabber = icon_contact_jabber.gif*20*20 +img_icon_contact_msnm = icon_contact_msnm.gif*20*20 + +img_icon_contact_www = icon_contact_www.gif*20*20 +img_icon_contact_yahoo = icon_contact_yahoo.gif*20*20 + +img_icon_post_delete = icon_post_delete.gif*20*20 + +img_icon_post_info = icon_post_info.gif*20*20 + +img_icon_post_report = icon_post_report.gif*20*20 +img_icon_post_target = icon_post_target.gif*9*11 +img_icon_post_target_unread = icon_post_target_unread.gif*9*11 + +img_icon_topic_attach = icon_topic_attach.gif*10*7 +img_icon_topic_latest = icon_topic_latest.gif*9*11 +img_icon_topic_newest = icon_topic_newest.gif*9*11 +img_icon_topic_reported = icon_topic_reported.gif*14*16 +img_icon_topic_unapproved = icon_topic_unapproved.gif*14*16 +img_icon_topic_deleted = icon_topic_deleted.png*16*16 + +img_icon_user_profile = + +img_icon_user_warn = icon_user_warn.gif*20*20 diff --git a/phpBB/styles/prosilver/template/mcp_queue.html b/phpBB/styles/prosilver/template/mcp_queue.html index 93483ae02a..4b48674673 100644 --- a/phpBB/styles/prosilver/template/mcp_queue.html +++ b/phpBB/styles/prosilver/template/mcp_queue.html @@ -94,8 +94,13 @@
    + +   + +   +
    diff --git a/phpBB/styles/prosilver/template/posting_editor.html b/phpBB/styles/prosilver/template/posting_editor.html index 99e518d486..f8fccf2d2f 100644 --- a/phpBB/styles/prosilver/template/posting_editor.html +++ b/phpBB/styles/prosilver/template/posting_editor.html @@ -83,6 +83,13 @@ + +
    +
    +
    +
    + +
    diff --git a/phpBB/styles/prosilver/template/viewforum_body.html b/phpBB/styles/prosilver/template/viewforum_body.html index 373a172918..7f3703eabb 100644 --- a/phpBB/styles/prosilver/template/viewforum_body.html +++ b/phpBB/styles/prosilver/template/viewforum_body.html @@ -144,7 +144,7 @@
    style="background-image: url({T_ICONS_PATH}{topicrow.TOPIC_ICON_IMG}); background-repeat: no-repeat;" title="{topicrow.TOPIC_FOLDER_IMG_ALT}">{NEWEST_POST_IMG} {topicrow.TOPIC_TITLE} {topicrow.UNAPPROVED_IMG} - {REPORTED_IMG}
    + {REPORTED_IMG}{topicrow.DELETED_IMG}
    + + +

    + {notifications.TITLE}
    + {notifications.TIME} +

    + \ No newline at end of file From 32a966b21da7051def3bd2ae608f3f2457d22476 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Sat, 8 Sep 2012 12:28:58 -0500 Subject: [PATCH 0110/2494] [ticket/11103] Private Message type notification Also cleanup PHPBB3-11103 --- phpBB/includes/notifications/service.php | 68 +++++++++---- phpBB/includes/notifications/type/base.php | 2 +- .../includes/notifications/type/interface.php | 4 +- phpBB/includes/notifications/type/pm.php | 97 +++++++++++++++++++ phpBB/includes/notifications/type/post.php | 12 ++- 5 files changed, 162 insertions(+), 21 deletions(-) create mode 100644 phpBB/includes/notifications/type/pm.php diff --git a/phpBB/includes/notifications/service.php b/phpBB/includes/notifications/service.php index 8db414cb16..059c2b420d 100644 --- a/phpBB/includes/notifications/service.php +++ b/phpBB/includes/notifications/service.php @@ -87,9 +87,9 @@ class phpbb_notifications_service while ($row = $this->db->sql_fetchrow($result)) { - $type_class_name = $this->get_type_class_name($row['item_type'], true); + $item_type_class_name = $this->get_item_type_class_name($row['item_type'], true); - $notification = new $type_class_name($this->phpbb_container, $row); + $notification = new $item_type_class_name($this->phpbb_container, $row); $notification->users($this->users); $user_ids = array_merge($user_ids, $notification->users_to_query()); @@ -123,13 +123,18 @@ class phpbb_notifications_service /** * Add a notification * - * @param string $type Type identifier - * @param int $type_id Identifier within the type + * @param string $item_type Type identifier + * @param int $item_id Identifier within the type * @param array $data Data specific for this type that will be inserted */ - public function add_notifications($type, $data) + public function add_notifications($item_type, $data) { - $type_class_name = $this->get_type_class_name($type); + $item_type_class_name = $this->get_item_type_class_name($item_type); + + $item_id = $item_type_class_name::get_item_id($data); + + // Update any existing notifications for this item + $this->update_notifications($item_type, $item_id, $data); $notify_users = array(); $notification_objects = $notification_methods = array(); @@ -150,10 +155,22 @@ class phpbb_notifications_service } $this->db->sql_freeresult($result); + // Make sure not to send new notifications to users who've already been notified about this item + // This may happen when an item was added, but now new users are able to see the item + $sql = 'SELECT user_id FROM ' . NOTIFICATIONS_TABLE . " + WHERE item_type = '" . $this->db->sql_escape($item_type) . "' + AND item_id = " . (int) $item_id; + $result = $this->db->sql_query($sql); + while ($row = $this->db->sql_fetchrow($result)) + { + unset($notify_users[$row['user_id']]); + } + $this->db->sql_freeresult($result); + // Go through each user so we can insert a row in the DB and then notify them by their desired means foreach ($notify_users as $user => $methods) { - $notification = new $type_class_name($this->phpbb_container); + $notification = new $item_type_class_name($this->phpbb_container); $notification->user_id = (int) $user; @@ -188,34 +205,49 @@ class phpbb_notifications_service /** * Update a notification * - * @param string $type Type identifier - * @param int $type_id Identifier within the type + * @param string $item_type Type identifier + * @param int $item_id Identifier within the type * @param array $data Data specific for this type that will be updated */ - public function update_notifications($type, $type_id, $data) + public function update_notifications($item_type, $item_id, $data) { - $type_class_name = $this->get_type_class_name($type); + $item_type_class_name = $this->get_item_type_class_name($item_type); - $notification = new $type_class_name($this->phpbb_container); + $notification = new $item_type_class_name($this->phpbb_container); $update_array = $notification->create_update_array($data); $sql = 'UPDATE ' . NOTIFICATIONS_TABLE . ' SET ' . $this->db->sql_build_array('UPDATE', $update_array) . " - WHERE item_type = '" . $this->db->sql_escape($type) . "' - AND item_id = " . (int) $type_id; + WHERE item_type = '" . $this->db->sql_escape($item_type) . "' + AND item_id = " . (int) $item_id; $this->db->sql_query($sql); } /** - * Helper to get the notifications type class name and clean it if unsafe + * Delete a notification + * + * @param string $item_type Type identifier + * @param int $item_id Identifier within the type + * @param array $data Data specific for this type that will be updated */ - private function get_type_class_name(&$type, $safe = false) + public function delete_notifications($item_type, $item_id) + { + $sql = 'DELETE FROM ' . NOTIFICATIONS_TABLE . " + WHERE item_type = '" . $this->db->sql_escape($item_type) . "' + AND item_id = " . (int) $item_id; + $this->db->sql_query($sql); + } + + /** + * Helper to get the notifications item type class name and clean it if unsafe + */ + private function get_item_type_class_name(&$item_type, $safe = false) { if (!$safe) { - $type = preg_replace('#[^a-z]#', '', $type); + $item_type = preg_replace('#[^a-z]#', '', $item_type); } - return 'phpbb_notifications_type_' . $type; + return 'phpbb_notifications_type_' . $item_type; } } diff --git a/phpBB/includes/notifications/type/base.php b/phpBB/includes/notifications/type/base.php index 1b01e1d46c..89143873a8 100644 --- a/phpBB/includes/notifications/type/base.php +++ b/phpBB/includes/notifications/type/base.php @@ -157,7 +157,7 @@ abstract class phpbb_notifications_type_base implements phpbb_notifications_type { // Defaults $data = array_merge(array( - 'item_type' => $this->get_type(), + 'item_type' => $this->get_item_type(), 'time' => time(), 'unread' => true, diff --git a/phpBB/includes/notifications/type/interface.php b/phpBB/includes/notifications/type/interface.php index 57de755c82..b1ee9ae0b6 100644 --- a/phpBB/includes/notifications/type/interface.php +++ b/phpBB/includes/notifications/type/interface.php @@ -21,7 +21,9 @@ if (!defined('IN_PHPBB')) */ interface phpbb_notifications_type_interface { - public function get_type(); + public static function get_item_type(); + + public static function get_item_id($post); public function get_title(); diff --git a/phpBB/includes/notifications/type/pm.php b/phpBB/includes/notifications/type/pm.php new file mode 100644 index 0000000000..f86050486e --- /dev/null +++ b/phpBB/includes/notifications/type/pm.php @@ -0,0 +1,97 @@ +get_user($this->get_data('author_id')); + + $username = get_username_string('no_profile', $user_data['user_id'], $user_data['username'], $user_data['user_colour']); + + return $username . ' sent you a private message titled: ' . $this->get_data('message_subject'); + } + + /** + * Get the url to this item + * + * @return string URL + */ + public function get_url() + { + return append_sid($this->phpbb_root_path . 'ucp.' . $this->php_ext, "i=pm&mode=view&p={$this->item_id}"); + } + + /** + * Users needed to query before this notification can be displayed + * + * @return array Array of user_ids + */ + public function users_to_query() + { + return array($this->data['author_id']); + } + + /** + * Function for preparing the data for insertion in an SQL query + * (The service handles insertion) + * + * @param array $post Data from submit_post + * + * @return array Array of data ready to be inserted into the database + */ + public function create_insert_array($post) + { + $this->item_id = $post['msg_id']; + + $this->set_data('author_id', $post['author_id']); + + $this->set_data('message_subject', $post['message_subject']); + + $this->time = $post['message_time']; + + return parent::create_insert_array($post); + } +} diff --git a/phpBB/includes/notifications/type/post.php b/phpBB/includes/notifications/type/post.php index 4b343650a1..9bd343d288 100644 --- a/phpBB/includes/notifications/type/post.php +++ b/phpBB/includes/notifications/type/post.php @@ -25,11 +25,21 @@ class phpbb_notifications_type_post extends phpbb_notifications_type_base * Get the type of notification this is * phpbb_notifications_type_ */ - public function get_type() + public static function get_item_type() { return 'post'; } + /** + * Get the id of the + * + * @param array $post The data from the post + */ + public static function get_item_id($post) + { + return $post['post_id']; + } + /** * Get the title of this notification * From b59463552644ca4afd9e8ca7edd761ae382fc8ed Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Sat, 8 Sep 2012 13:09:34 -0500 Subject: [PATCH 0111/2494] [ticket/11103] Add tables to the database updater and installer PHPBB3-11103 --- phpBB/develop/create_schema_files.php | 41 ++++++++++++++++ phpBB/includes/notifications/method/base.php | 32 +++++++++++++ .../notifications/method/interface.php | 1 + phpBB/includes/notifications/service.php | 38 +++++++-------- phpBB/install/database_update.php | 47 +++++++++++++++++++ 5 files changed, 140 insertions(+), 19 deletions(-) diff --git a/phpBB/develop/create_schema_files.php b/phpBB/develop/create_schema_files.php index 6eb4a80199..88aa9b70dd 100644 --- a/phpBB/develop/create_schema_files.php +++ b/phpBB/develop/create_schema_files.php @@ -1295,6 +1295,28 @@ function get_schema_struct() ), ); + $schema_data['phpbb_notifications'] = array( + 'COLUMNS' => array( + 'item_type' => array('UINT', 0), + 'item_id' => array('UINT', 0), + 'user_id' => array('UINT', 0), + 'unread' => array('BOOL', 1), + 'time' => array('TIMESTAMP', 1), + 'data' => array('TEXT_UNI', ''), + ), + 'PRIMARY_KEY' => array( + 'item_type', + 'item_id', + 'user_id', + ), + 'KEYS' => array( + 'item_type' => array('INDEX', 'item_type'), + 'item_id' => array('INDEX', 'item_id'), + 'user_id' => array('INDEX', 'user_id'), + 'time' => array('INDEX', 'time'), + ), + ); + $schema_data['phpbb_poll_options'] = array( 'COLUMNS' => array( 'poll_option_id' => array('TINT:4', 0), @@ -1751,6 +1773,25 @@ function get_schema_struct() ), ); + $schema_data['phpbb_user_notifications'] = array( + 'COLUMNS' => array( + 'item_type' => array('UINT', 0), + 'item_id' => array('UINT', 0), + 'user_id' => array('UINT', 0), + 'method' => array('VCHAR:25', ''), + ), + 'PRIMARY_KEY' => array( + 'item_type', + 'item_id', + 'user_id', + 'method', + ), + 'KEYS' => array( + 'it' => array('INDEX', 'item_type'), + 'uid' => array('INDEX', 'user_id'), + ), + ); + $schema_data['phpbb_user_group'] = array( 'COLUMNS' => array( 'group_id' => array('UINT', 0), diff --git a/phpBB/includes/notifications/method/base.php b/phpBB/includes/notifications/method/base.php index 1c223df045..dbf851a059 100644 --- a/phpBB/includes/notifications/method/base.php +++ b/phpBB/includes/notifications/method/base.php @@ -27,6 +27,13 @@ abstract class phpbb_notifications_method_base implements phpbb_notifications_me protected $db; protected $user; + /** + * Queue of messages to be sent + * + * @var array + */ + protected $queue = array(); + public function __construct(ContainerBuilder $phpbb_container, $data = array()) { // phpBB Container @@ -36,4 +43,29 @@ abstract class phpbb_notifications_method_base implements phpbb_notifications_me $this->db = $phpbb_container->get('dbal.conn'); $this->user = $phpbb_container->get('user'); } + + /** + * Add a notification to the queue + * + * @param phpbb_notifications_type_interface $notification + */ + public function add_to_queue(phpbb_notifications_type_interface $notification) + { + $this->queue[] = $notification; + } + + /** + * Basic run queue function. + * Child methods should override this function if there are more efficient methods to mass-notification + */ + public function run_queue() + { + foreach ($this->queue as $notification) + { + $this->notify($notification); + } + + // Empty queue + $this->queue = array(); + } } diff --git a/phpBB/includes/notifications/method/interface.php b/phpBB/includes/notifications/method/interface.php index 2d8a8b605e..f18d005b8b 100644 --- a/phpBB/includes/notifications/method/interface.php +++ b/phpBB/includes/notifications/method/interface.php @@ -21,4 +21,5 @@ if (!defined('IN_PHPBB')) */ interface phpbb_notifications_method_interface { + public function notify($notification); } diff --git a/phpBB/includes/notifications/service.php b/phpBB/includes/notifications/service.php index 059c2b420d..32211b26cf 100644 --- a/phpBB/includes/notifications/service.php +++ b/phpBB/includes/notifications/service.php @@ -33,25 +33,6 @@ class phpbb_notifications_service */ protected $users; - /** - * Desired notifications - * unique by (type, type_id, user_id, method) - * if multiple methods are desired, multiple rows will exist. - * - * method of "none" will over-ride any other options - * - * type - * type_id - * user_id - * method - * none (will never receive notifications) - * standard (listed in notifications window - * popup? - * email - * jabber - * sms? - */ - public function __construct(ContainerBuilder $phpbb_container) { $this->phpbb_container = $phpbb_container; @@ -140,6 +121,25 @@ class phpbb_notifications_service $notification_objects = $notification_methods = array(); $new_rows = array(); + /** + * Desired notifications + * unique by (type, type_id, user_id, method) + * if multiple methods are desired, multiple rows will exist. + * + * method of "none" will over-ride any other options + * + * item_type + * item_id + * user_id + * method + * none (will never receive notifications) + * standard (listed in notifications window + * popup? + * email + * jabber + * sms? + */ + // find out which users want to receive this type of notification $sql = 'SELECT user_id FROM ' . USERS_TABLE . ' WHERE ' . $this->db->sql_in_set('user_id', array(2)); diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 0b470ced26..99e40ddee9 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -106,6 +106,14 @@ if (!defined('EXT_TABLE')) { define('EXT_TABLE', $table_prefix . 'ext'); } +if (!defined('NOTIFICATIONS_TABLE')) +{ + define('NOTIFICATIONS_TABLE', $table_prefix . 'notifications'); +} +if (!defined('USER_NOTIFICATIONS_TABLE')) +{ + define('USER_NOTIFICATIONS_TABLE', $table_prefix . 'user_notifications'); +} $phpbb_class_loader_ext = new phpbb_class_loader('phpbb_ext_', $phpbb_root_path . 'ext/', ".$phpEx"); $phpbb_class_loader_ext->register(); @@ -1097,6 +1105,45 @@ function database_update_info() 'ext_name' => array('UNIQUE', 'ext_name'), ), ), + NOTIFICATIONS_TABLE => array( + 'COLUMNS' => array( + 'item_type' => array('UINT', 0), + 'item_id' => array('UINT', 0), + 'user_id' => array('UINT', 0), + 'unread' => array('BOOL', 1), + 'time' => array('TIMESTAMP', 1), + 'data' => array('TEXT_UNI', ''), + ), + 'PRIMARY_KEY' => array( + 'item_type', + 'item_id', + 'user_id', + ), + 'KEYS' => array( + 'item_type' => array('INDEX', 'item_type'), + 'item_id' => array('INDEX', 'item_id'), + 'user_id' => array('INDEX', 'user_id'), + 'time' => array('INDEX', 'time'), + ), + ), + USER_NOTIFICATIONS_TABLE => array( + 'COLUMNS' => array( + 'item_type' => array('UINT', 0), + 'item_id' => array('UINT', 0), + 'user_id' => array('UINT', 0), + 'method' => array('VCHAR:25', ''), + ), + 'PRIMARY_KEY' => array( + 'item_type', + 'item_id', + 'user_id', + 'method', + ), + 'KEYS' => array( + 'it' => array('INDEX', 'item_type'), + 'uid' => array('INDEX', 'user_id'), + ), + ), ), 'add_columns' => array( GROUPS_TABLE => array( From 7b0b6fc63c2593cafaa84cc38a9b3029af1ed369 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Sat, 8 Sep 2012 13:40:05 -0500 Subject: [PATCH 0112/2494] [ticket/11103] Forgot a constant PHPBB3-11103 --- phpBB/includes/constants.php | 1 + phpBB/includes/notifications/method/email.php | 10 +++++++++- phpBB/includes/notifications/type/pm.php | 2 ++ phpBB/includes/notifications/type/post.php | 2 ++ 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/phpBB/includes/constants.php b/phpBB/includes/constants.php index de289c73dc..7a3c73e987 100644 --- a/phpBB/includes/constants.php +++ b/phpBB/includes/constants.php @@ -273,6 +273,7 @@ define('TOPICS_POSTED_TABLE', $table_prefix . 'topics_posted'); define('TOPICS_TRACK_TABLE', $table_prefix . 'topics_track'); define('TOPICS_WATCH_TABLE', $table_prefix . 'topics_watch'); define('USER_GROUP_TABLE', $table_prefix . 'user_group'); +define('USER_NOTIFICATIONS_TABLE', $table_prefix . 'user_notifications'); define('USERS_TABLE', $table_prefix . 'users'); define('WARNINGS_TABLE', $table_prefix . 'warnings'); define('WORDS_TABLE', $table_prefix . 'words'); diff --git a/phpBB/includes/notifications/method/email.php b/phpBB/includes/notifications/method/email.php index b06e2c018e..0c3cb4bd85 100644 --- a/phpBB/includes/notifications/method/email.php +++ b/phpBB/includes/notifications/method/email.php @@ -17,11 +17,19 @@ if (!defined('IN_PHPBB')) /** * Email notification method class +* This class handles sending emails for notifications +* * @package notifications */ class phpbb_notifications_method_email extends phpbb_notifications_method_base { - function notify() + public static function is_available() + { + // Email is always available + return true; + } + + public function notify() { // email the user } diff --git a/phpBB/includes/notifications/type/pm.php b/phpBB/includes/notifications/type/pm.php index f86050486e..191c0b7e7f 100644 --- a/phpBB/includes/notifications/type/pm.php +++ b/phpBB/includes/notifications/type/pm.php @@ -17,6 +17,8 @@ if (!defined('IN_PHPBB')) /** * Private message notifications class +* This class handles notifications for private messages +* * @package notifications */ class phpbb_notifications_type_pm extends phpbb_notifications_type_base diff --git a/phpBB/includes/notifications/type/post.php b/phpBB/includes/notifications/type/post.php index 9bd343d288..addaa30ea6 100644 --- a/phpBB/includes/notifications/type/post.php +++ b/phpBB/includes/notifications/type/post.php @@ -17,6 +17,8 @@ if (!defined('IN_PHPBB')) /** * Post notifications class +* This class handles notifications for replies to a topic +* * @package notifications */ class phpbb_notifications_type_post extends phpbb_notifications_type_base From 7fee0cfdf60c9aeebcd498d2f41696bb7fed2dd0 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Sat, 8 Sep 2012 15:48:46 -0500 Subject: [PATCH 0113/2494] [ticket/11103] Work on the pm type and email method PHPBB3-11103 --- phpBB/includes/functions_privmsgs.php | 13 ++++ phpBB/includes/notifications/method/base.php | 11 ++- phpBB/includes/notifications/method/email.php | 61 ++++++++++++++++ phpBB/includes/notifications/service.php | 14 +--- phpBB/includes/notifications/type/base.php | 13 ++-- .../includes/notifications/type/interface.php | 6 +- phpBB/includes/notifications/type/pm.php | 69 +++++++++++++++++-- 7 files changed, 159 insertions(+), 28 deletions(-) diff --git a/phpBB/includes/functions_privmsgs.php b/phpBB/includes/functions_privmsgs.php index 9e055a319f..99ad2ad791 100644 --- a/phpBB/includes/functions_privmsgs.php +++ b/phpBB/includes/functions_privmsgs.php @@ -1855,6 +1855,19 @@ function submit_pm($mode, $subject, &$data, $put_in_outbox = true) */ function pm_notification($mode, $author, $recipients, $subject, $message, $msg_id) { + global $phpbb_container; + + $phpbb_notifications = $phpbb_container->get('notifications'); + + $phpbb_notifications->add_notifications('pm', array( + 'author_id' => $author, + 'recipients' => $recipients, + 'message_subject' => $subject, + 'msg_id' => $msg_id, + )); + + return; + global $db, $user, $config, $phpbb_root_path, $phpEx, $auth; $subject = censor_text($subject); diff --git a/phpBB/includes/notifications/method/base.php b/phpBB/includes/notifications/method/base.php index dbf851a059..98c06509c6 100644 --- a/phpBB/includes/notifications/method/base.php +++ b/phpBB/includes/notifications/method/base.php @@ -26,6 +26,8 @@ abstract class phpbb_notifications_method_base implements phpbb_notifications_me protected $phpbb_container; protected $db; protected $user; + protected $phpbb_root_path; + protected $php_ext; /** * Queue of messages to be sent @@ -42,6 +44,9 @@ abstract class phpbb_notifications_method_base implements phpbb_notifications_me // Some common things we're going to use $this->db = $phpbb_container->get('dbal.conn'); $this->user = $phpbb_container->get('user'); + + $this->phpbb_root_path = $phpbb_container->getParameter('core.root_path'); + $this->php_ext = $phpbb_container->getParameter('core.php_ext'); } /** @@ -65,7 +70,11 @@ abstract class phpbb_notifications_method_base implements phpbb_notifications_me $this->notify($notification); } - // Empty queue + $this->empty_queue(); + } + + protected function empty_queue() + { $this->queue = array(); } } diff --git a/phpBB/includes/notifications/method/email.php b/phpBB/includes/notifications/method/email.php index 0c3cb4bd85..725ede7913 100644 --- a/phpBB/includes/notifications/method/email.php +++ b/phpBB/includes/notifications/method/email.php @@ -33,4 +33,65 @@ class phpbb_notifications_method_email extends phpbb_notifications_method_base { // email the user } + + public function run_queue() + { + if (!sizeof($this->queue)) + { + return; + } + + // Load all users we want to notify (we need their email address) + $user_ids = $users = array(); + foreach ($this->queue as $notification) + { + $user_ids[] = $notification->user_id; + } + + $sql = 'SELECT * FROM ' . USERS_TABLE . ' + WHERE ' . $this->db->sql_in_set('user_id', $user_ids); + $result = $this->db->sql_query($sql); + while ($row = $this->db->sql_fetchrow($result)) + { + $users[$row['user_id']] = $row; + } + $this->db->sql_freeresult($result); + + // Load the messenger + if (!class_exists('messenger')) + { + include($this->phpbb_root_path . 'includes/functions_messenger.' . $this->php_ext); + } + $messenger = new messenger(); + $board_url = generate_board_url(); + + // Time to go through the queue and send emails + foreach ($this->queue as $notification) + { + $notification->users($users); + + $user = $notification->get_user(); + + $messenger->template('privmsg_notify', $user['user_lang']); + + $messenger->to($user['user_email'], $user['username']); + + $messenger->assign_vars(array( + 'SUBJECT' => htmlspecialchars_decode($notification->get_title()), + 'AUTHOR_NAME' => '', + 'USERNAME' => htmlspecialchars_decode($user['username']), + + 'U_INBOX' => $board_url . "/ucp.{$this->php_ext}?i=pm&folder=inbox", + 'U_VIEW_MESSAGE' => $board_url . "/ucp.{$this->php_ext}?i=pm&mode=view&p={$notification->get_item_id()}", + )); + + $messenger->send($addr['method']); + } + + // Save the queue in the messenger class (has to be called or these emails could be lost?) + $messenger->save_queue(); + + // We're done, empty the queue + $this->empty_queue(); + } } diff --git a/phpBB/includes/notifications/service.php b/phpBB/includes/notifications/service.php index 32211b26cf..ba57fe9f72 100644 --- a/phpBB/includes/notifications/service.php +++ b/phpBB/includes/notifications/service.php @@ -141,19 +141,7 @@ class phpbb_notifications_service */ // find out which users want to receive this type of notification - $sql = 'SELECT user_id FROM ' . USERS_TABLE . ' - WHERE ' . $this->db->sql_in_set('user_id', array(2)); - $result = $this->db->sql_query($sql); - while ($row = $this->db->sql_fetchrow($result)) - { - if (!isset($notify_users[$row['user_id']])) - { - $notify_users[$row['user_id']] = array(); - } - - $notify_users[$row['user_id']][] = ''; - } - $this->db->sql_freeresult($result); + $notify_users = $item_type_class_name::find_users_for_notification($data); // Make sure not to send new notifications to users who've already been notified about this item // This may happen when an item was added, but now new users are able to see the item diff --git a/phpBB/includes/notifications/type/base.php b/phpBB/includes/notifications/type/base.php index 89143873a8..f031abae77 100644 --- a/phpBB/includes/notifications/type/base.php +++ b/phpBB/includes/notifications/type/base.php @@ -58,6 +58,7 @@ abstract class phpbb_notifications_type_base implements phpbb_notifications_type // Some common things we're going to use $this->db = $phpbb_container->get('dbal.conn'); + $this->phpbb_root_path = $phpbb_container->getParameter('core.root_path'); $this->php_ext = $phpbb_container->getParameter('core.php_ext'); @@ -114,7 +115,7 @@ abstract class phpbb_notifications_type_base implements phpbb_notifications_type * @param int $user_id * @return array */ - protected function get_user($user_id) + public function get_user($user_id) { return $this->users[$user_id]; } @@ -149,11 +150,11 @@ abstract class phpbb_notifications_type_base implements phpbb_notifications_type * Function for preparing the data for insertion in an SQL query * (The service handles insertion) * - * @param array $special_data Data unique to this notification type + * @param array $type_data Data unique to this notification type * * @return array Array of data ready to be inserted into the database */ - public function create_insert_array($special_data) + public function create_insert_array($type_data) { // Defaults $data = array_merge(array( @@ -173,13 +174,13 @@ abstract class phpbb_notifications_type_base implements phpbb_notifications_type * Function for preparing the data for update in an SQL query * (The service handles insertion) * - * @param array $special_data Data unique to this notification type + * @param array $type_data Data unique to this notification type * * @return array Array of data ready to be updated in the database */ - public function create_update_array($special_data) + public function create_update_array($type_data) { - $data = $this->create_insert_array($special_data); + $data = $this->create_insert_array($type_data); // Unset data unique to each row unset( diff --git a/phpBB/includes/notifications/type/interface.php b/phpBB/includes/notifications/type/interface.php index b1ee9ae0b6..b710a75606 100644 --- a/phpBB/includes/notifications/type/interface.php +++ b/phpBB/includes/notifications/type/interface.php @@ -23,11 +23,13 @@ interface phpbb_notifications_type_interface { public static function get_item_type(); - public static function get_item_id($post); + public static function get_item_id($type_data); public function get_title(); public function get_url(); - public function create_insert_array($special_data); + public function create_insert_array($type_data); + + public function find_users_for_notification($type_data); } diff --git a/phpBB/includes/notifications/type/pm.php b/phpBB/includes/notifications/type/pm.php index 191c0b7e7f..7685a49614 100644 --- a/phpBB/includes/notifications/type/pm.php +++ b/phpBB/includes/notifications/type/pm.php @@ -84,16 +84,73 @@ class phpbb_notifications_type_pm extends phpbb_notifications_type_base * * @return array Array of data ready to be inserted into the database */ - public function create_insert_array($post) + public function create_insert_array($pm) { - $this->item_id = $post['msg_id']; + $this->item_id = $pm['msg_id']; - $this->set_data('author_id', $post['author_id']); + $this->set_data('author_id', $pm['author_id']); - $this->set_data('message_subject', $post['message_subject']); + $this->set_data('message_subject', $pm['message_subject']); - $this->time = $post['message_time']; + return parent::create_insert_array($pm); + } - return parent::create_insert_array($post); + /** + * Find the users who want to receive notifications + * + * @param array $pm Data from + * @return array + */ + public function find_users_for_notification($pm) + { + $user = $this->phpbb_container->get('user'); + + // Exclude guests, current user and banned users from notifications + unset($pm['recipients'][ANONYMOUS], $pm['recipients'][$user->data['user_id']]); + + if (!sizeof($pm['recipients'])) + { + return; + } + + if (!function_exists('phpbb_get_banned_user_ids')) + { + include($phpbb_root_path . 'includes/functions_user.' . $phpEx); + } + $banned_users = phpbb_get_banned_user_ids(array_keys($pm['recipients'])); + $pm['recipients'] = array_diff(array_keys($pm['recipients']), $banned_users); + + if (!sizeof($pm['recipients'])) + { + return; + } + + $sql = 'SELECT user_id, user_notify_pm, user_notify_type + FROM ' . USERS_TABLE . ' + WHERE ' . $db->sql_in_set('user_id', $pm['recipients']); + $result = $db->sql_query($sql); + + $pm['recipients'] = array(); + + while ($row = $db->sql_fetchrow($result)) + { + if ($row['user_notify_pm']) + { + $pm['recipients'][$row['user_id']] = array(); + + if ($row['user_notify_type'] == NOTIFY_EMAIL || $row['user_notify_type'] == NOTIFY_BOTH) + { + $pm['recipients'][$row['user_id']][] = 'email'; + } + + if ($row['user_notify_type'] == NOTIFY_IM || $row['user_notify_type'] == NOTIFY_BOTH) + { + $pm['recipients'][$row['user_id']][] = 'jabber'; + } + } + } + $db->sql_freeresult($result); + + return $pm['recipients']; } } From a4eb8bf47a77cb2637bfad5db20ab9f0dc236059 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Sat, 8 Sep 2012 15:49:22 -0500 Subject: [PATCH 0114/2494] [ticket/11103] Jabber notification method base PHPBB3-11103 --- .../includes/notifications/method/jabber.php | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 phpBB/includes/notifications/method/jabber.php diff --git a/phpBB/includes/notifications/method/jabber.php b/phpBB/includes/notifications/method/jabber.php new file mode 100644 index 0000000000..15614db96c --- /dev/null +++ b/phpBB/includes/notifications/method/jabber.php @@ -0,0 +1,36 @@ + Date: Sat, 8 Sep 2012 16:02:32 -0500 Subject: [PATCH 0115/2494] [ticket/11103] Fixing some db columns that were of the incorrect type PHPBB3-11103 --- phpBB/develop/create_schema_files.php | 4 ++-- phpBB/includes/notifications/service.php | 7 ++++++- phpBB/includes/notifications/type/interface.php | 2 +- phpBB/includes/notifications/type/pm.php | 11 +++++++---- phpBB/includes/notifications/type/post.php | 2 ++ phpBB/install/database_update.php | 8 ++++---- 6 files changed, 22 insertions(+), 12 deletions(-) diff --git a/phpBB/develop/create_schema_files.php b/phpBB/develop/create_schema_files.php index 88aa9b70dd..a2f7463dd4 100644 --- a/phpBB/develop/create_schema_files.php +++ b/phpBB/develop/create_schema_files.php @@ -1297,7 +1297,7 @@ function get_schema_struct() $schema_data['phpbb_notifications'] = array( 'COLUMNS' => array( - 'item_type' => array('UINT', 0), + 'item_type' => array('VCHAR:25', ''), 'item_id' => array('UINT', 0), 'user_id' => array('UINT', 0), 'unread' => array('BOOL', 1), @@ -1775,7 +1775,7 @@ function get_schema_struct() $schema_data['phpbb_user_notifications'] = array( 'COLUMNS' => array( - 'item_type' => array('UINT', 0), + 'item_type' => array('VCHAR:25', ''), 'item_id' => array('UINT', 0), 'user_id' => array('UINT', 0), 'method' => array('VCHAR:25', ''), diff --git a/phpBB/includes/notifications/service.php b/phpBB/includes/notifications/service.php index ba57fe9f72..a689e1c68a 100644 --- a/phpBB/includes/notifications/service.php +++ b/phpBB/includes/notifications/service.php @@ -141,7 +141,7 @@ class phpbb_notifications_service */ // find out which users want to receive this type of notification - $notify_users = $item_type_class_name::find_users_for_notification($data); + $notify_users = $item_type_class_name::find_users_for_notification($this->phpbb_container, $data); // Make sure not to send new notifications to users who've already been notified about this item // This may happen when an item was added, but now new users are able to see the item @@ -155,6 +155,11 @@ class phpbb_notifications_service } $this->db->sql_freeresult($result); + if (!sizeof($notify_users)) + { + return; + } + // Go through each user so we can insert a row in the DB and then notify them by their desired means foreach ($notify_users as $user => $methods) { diff --git a/phpBB/includes/notifications/type/interface.php b/phpBB/includes/notifications/type/interface.php index b710a75606..ccd963ba06 100644 --- a/phpBB/includes/notifications/type/interface.php +++ b/phpBB/includes/notifications/type/interface.php @@ -31,5 +31,5 @@ interface phpbb_notifications_type_interface public function create_insert_array($type_data); - public function find_users_for_notification($type_data); + public static function find_users_for_notification(ContainerBuilder $phpbb_container, $type_data); } diff --git a/phpBB/includes/notifications/type/pm.php b/phpBB/includes/notifications/type/pm.php index 7685a49614..2b2a835470 100644 --- a/phpBB/includes/notifications/type/pm.php +++ b/phpBB/includes/notifications/type/pm.php @@ -7,6 +7,8 @@ * */ +use Symfony\Component\DependencyInjection\ContainerBuilder; + /** * @ignore */ @@ -101,12 +103,13 @@ class phpbb_notifications_type_pm extends phpbb_notifications_type_base * @param array $pm Data from * @return array */ - public function find_users_for_notification($pm) + public static function find_users_for_notification(ContainerBuilder $phpbb_container, $pm) { - $user = $this->phpbb_container->get('user'); + $db = $phpbb_container->get('dbal.conn'); + $user = $phpbb_container->get('user'); // Exclude guests, current user and banned users from notifications - unset($pm['recipients'][ANONYMOUS], $pm['recipients'][$user->data['user_id']]); + unset($pm['recipients'][ANONYMOUS]);//, $pm['recipients'][$user->data['user_id']]); if (!sizeof($pm['recipients'])) { @@ -115,7 +118,7 @@ class phpbb_notifications_type_pm extends phpbb_notifications_type_base if (!function_exists('phpbb_get_banned_user_ids')) { - include($phpbb_root_path . 'includes/functions_user.' . $phpEx); + include($phpbb_container->getParameter('core.root_path') . 'includes/functions_user.' . $phpbb_container->getParameter('core.php_ext')); } $banned_users = phpbb_get_banned_user_ids(array_keys($pm['recipients'])); $pm['recipients'] = array_diff(array_keys($pm['recipients']), $banned_users); diff --git a/phpBB/includes/notifications/type/post.php b/phpBB/includes/notifications/type/post.php index addaa30ea6..920a53bcf2 100644 --- a/phpBB/includes/notifications/type/post.php +++ b/phpBB/includes/notifications/type/post.php @@ -7,6 +7,8 @@ * */ +use Symfony\Component\DependencyInjection\ContainerBuilder; + /** * @ignore */ diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 99e40ddee9..c3c2da4451 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -1107,7 +1107,7 @@ function database_update_info() ), NOTIFICATIONS_TABLE => array( 'COLUMNS' => array( - 'item_type' => array('UINT', 0), + 'item_type' => array('VCHAR:25', ''), 'item_id' => array('UINT', 0), 'user_id' => array('UINT', 0), 'unread' => array('BOOL', 1), @@ -1128,7 +1128,7 @@ function database_update_info() ), USER_NOTIFICATIONS_TABLE => array( 'COLUMNS' => array( - 'item_type' => array('UINT', 0), + 'item_type' => array('VCHAR:25', ''), 'item_id' => array('UINT', 0), 'user_id' => array('UINT', 0), 'method' => array('VCHAR:25', ''), @@ -2676,10 +2676,10 @@ function change_database_data(&$no_updates, $version) // Create config value for displaying last subject on forum list if (!isset($config['display_last_subject'])) - { + { $config->set('display_last_subject', '1'); } - + $no_updates = false; if (!isset($config['assets_version'])) From 86b801df7304d43f117bea762710149c25385260 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Sat, 8 Sep 2012 16:12:20 -0500 Subject: [PATCH 0116/2494] [ticket/11103] Some fixes for the email method PHPBB3-11103 --- phpBB/includes/functions_privmsgs.php | 25 ++++++++----------- phpBB/includes/notifications/method/email.php | 8 +++--- phpBB/includes/notifications/service.php | 11 ++++---- phpBB/includes/notifications/type/base.php | 2 -- 4 files changed, 20 insertions(+), 26 deletions(-) diff --git a/phpBB/includes/functions_privmsgs.php b/phpBB/includes/functions_privmsgs.php index 99ad2ad791..8002765ee2 100644 --- a/phpBB/includes/functions_privmsgs.php +++ b/phpBB/includes/functions_privmsgs.php @@ -1543,6 +1543,7 @@ function get_folder_status($folder_id, $folder) function submit_pm($mode, $subject, &$data, $put_in_outbox = true) { global $db, $auth, $config, $phpEx, $template, $user, $phpbb_root_path; + global $phpbb_container; // We do not handle erasing pms here if ($mode == 'delete') @@ -1844,7 +1845,16 @@ function submit_pm($mode, $subject, &$data, $put_in_outbox = true) // Send Notifications if ($mode != 'edit') { - pm_notification($mode, $data['from_username'], $recipients, $subject, $data['message'], $data['msg_id']); + $phpbb_notifications = $phpbb_container->get('notifications'); + + $phpbb_notifications->add_notifications('pm', array( + 'author_id' => $data['from_user_id'], + 'recipients' => $recipients, + 'message_subject' => $subject, + 'msg_id' => $data['msg_id'], + )); + + //pm_notification($mode, $data['from_username'], $recipients, $subject, $data['message'], $data['msg_id']); } return $data['msg_id']; @@ -1855,19 +1865,6 @@ function submit_pm($mode, $subject, &$data, $put_in_outbox = true) */ function pm_notification($mode, $author, $recipients, $subject, $message, $msg_id) { - global $phpbb_container; - - $phpbb_notifications = $phpbb_container->get('notifications'); - - $phpbb_notifications->add_notifications('pm', array( - 'author_id' => $author, - 'recipients' => $recipients, - 'message_subject' => $subject, - 'msg_id' => $msg_id, - )); - - return; - global $db, $user, $config, $phpbb_root_path, $phpEx, $auth; $subject = censor_text($subject); diff --git a/phpBB/includes/notifications/method/email.php b/phpBB/includes/notifications/method/email.php index 725ede7913..0120485cff 100644 --- a/phpBB/includes/notifications/method/email.php +++ b/phpBB/includes/notifications/method/email.php @@ -29,7 +29,7 @@ class phpbb_notifications_method_email extends phpbb_notifications_method_base return true; } - public function notify() + public function notify($notification) { // email the user } @@ -70,7 +70,7 @@ class phpbb_notifications_method_email extends phpbb_notifications_method_base { $notification->users($users); - $user = $notification->get_user(); + $user = $notification->get_user($notification->user_id); $messenger->template('privmsg_notify', $user['user_lang']); @@ -82,10 +82,10 @@ class phpbb_notifications_method_email extends phpbb_notifications_method_base 'USERNAME' => htmlspecialchars_decode($user['username']), 'U_INBOX' => $board_url . "/ucp.{$this->php_ext}?i=pm&folder=inbox", - 'U_VIEW_MESSAGE' => $board_url . "/ucp.{$this->php_ext}?i=pm&mode=view&p={$notification->get_item_id()}", + 'U_VIEW_MESSAGE' => $board_url . "/ucp.{$this->php_ext}?i=pm&mode=view&p={$notification->item_id}", )); - $messenger->send($addr['method']); + $messenger->send('email'); } // Save the queue in the messenger class (has to be called or these emails could be lost?) diff --git a/phpBB/includes/notifications/service.php b/phpBB/includes/notifications/service.php index a689e1c68a..74e2e29e1a 100644 --- a/phpBB/includes/notifications/service.php +++ b/phpBB/includes/notifications/service.php @@ -172,15 +172,14 @@ class phpbb_notifications_service foreach ($methods as $method) { // setup the notification methods and add the notification to the queue - if ($row['method']) + if ($method) { - if (!isset($notification_methods[$row['method']])) + if (!isset($notification_methods[$method])) { - $method_class_name = 'phpbb_notifications_method_' . $row['method']; - $notification_methods[$row['method']] = new $method_class_name(); + $method_class_name = 'phpbb_notifications_method_' . $method; + $notification_methods[$method] = new $method_class_name($this->phpbb_container); } - - $notification_methods[$row['method']]->add_to_queue($notification); + $notification_methods[$method]->add_to_queue($notification); } } } diff --git a/phpBB/includes/notifications/type/base.php b/phpBB/includes/notifications/type/base.php index f031abae77..32d8f58ff3 100644 --- a/phpBB/includes/notifications/type/base.php +++ b/phpBB/includes/notifications/type/base.php @@ -37,7 +37,6 @@ abstract class phpbb_notifications_type_base implements phpbb_notifications_type /** * Indentification data - * notification_id * item_type * item_id * user_id @@ -141,7 +140,6 @@ abstract class phpbb_notifications_type_base implements phpbb_notifications_type 'URL' => $this->get_url(), 'TIME' => $user->format_date($this->time), - 'ID' => $this->notification_id, 'UNREAD' => $this->unread, )); } From 16a0757f2a21ad2ca36a9463c822539c9ea14d30 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Sat, 8 Sep 2012 17:28:13 -0500 Subject: [PATCH 0117/2494] [ticket/11103] Order notifications properly PHPBB3-11103 --- phpBB/includes/notifications/service.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/phpBB/includes/notifications/service.php b/phpBB/includes/notifications/service.php index 74e2e29e1a..4794472883 100644 --- a/phpBB/includes/notifications/service.php +++ b/phpBB/includes/notifications/service.php @@ -46,6 +46,8 @@ class phpbb_notifications_service * * @param array $options Optional options to control what notifications are loaded * user_id User id to load notifications for (Default: $user->data['user_id']) + * order_by Order by (Default: time) + * order_dir Order direction (Default: DESC) * limit Number of notifications to load (Default: 5) * start Notifications offset (Default: 0) */ @@ -58,12 +60,15 @@ class phpbb_notifications_service 'user_id' => $user->data['user_id'], 'limit' => 5, 'start' => 0, + 'order_by' => 'time', + 'order_dir' => 'DESC', ), $options); $notifications = $user_ids = array(); $sql = 'SELECT * FROM ' . NOTIFICATIONS_TABLE . ' - WHERE user_id = ' . (int) $options['user_id']; + WHERE user_id = ' . (int) $options['user_id'] . ' + ORDER BY ' . $this->db->sql_escape($options['order_by']) . ' ' . $this->db->sql_escape($options['order_dir']); $result = $this->db->sql_query_limit($sql, $options['limit'], $options['start']); while ($row = $this->db->sql_fetchrow($result)) From 6983f380c55779054b545e4760bf250e8ecace2e Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Sat, 8 Sep 2012 17:48:13 -0500 Subject: [PATCH 0118/2494] [ticket/11103] Full url function PHPBB3-11103 --- phpBB/includes/notifications/method/email.php | 11 ++++++----- phpBB/includes/notifications/type/interface.php | 2 ++ phpBB/includes/notifications/type/pm.php | 12 +++++++++++- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/phpBB/includes/notifications/method/email.php b/phpBB/includes/notifications/method/email.php index 0120485cff..b1979296b9 100644 --- a/phpBB/includes/notifications/method/email.php +++ b/phpBB/includes/notifications/method/email.php @@ -23,6 +23,10 @@ if (!defined('IN_PHPBB')) */ class phpbb_notifications_method_email extends phpbb_notifications_method_base { + /** + * Is this method available for the user? + * This is checked on the notifications options + */ public static function is_available() { // Email is always available @@ -77,12 +81,9 @@ class phpbb_notifications_method_email extends phpbb_notifications_method_base $messenger->to($user['user_email'], $user['username']); $messenger->assign_vars(array( - 'SUBJECT' => htmlspecialchars_decode($notification->get_title()), - 'AUTHOR_NAME' => '', - 'USERNAME' => htmlspecialchars_decode($user['username']), + 'SUBJECT' => htmlspecialchars_decode($notification->get_title()), - 'U_INBOX' => $board_url . "/ucp.{$this->php_ext}?i=pm&folder=inbox", - 'U_VIEW_MESSAGE' => $board_url . "/ucp.{$this->php_ext}?i=pm&mode=view&p={$notification->item_id}", + 'U_VIEW_MESSAGE' => $notification->get_full_url(), )); $messenger->send('email'); diff --git a/phpBB/includes/notifications/type/interface.php b/phpBB/includes/notifications/type/interface.php index ccd963ba06..03e24358a9 100644 --- a/phpBB/includes/notifications/type/interface.php +++ b/phpBB/includes/notifications/type/interface.php @@ -29,6 +29,8 @@ interface phpbb_notifications_type_interface public function get_url(); + public function get_full_url(); + public function create_insert_array($type_data); public static function find_users_for_notification(ContainerBuilder $phpbb_container, $type_data); diff --git a/phpBB/includes/notifications/type/pm.php b/phpBB/includes/notifications/type/pm.php index 2b2a835470..50c67de21a 100644 --- a/phpBB/includes/notifications/type/pm.php +++ b/phpBB/includes/notifications/type/pm.php @@ -65,7 +65,17 @@ class phpbb_notifications_type_pm extends phpbb_notifications_type_base */ public function get_url() { - return append_sid($this->phpbb_root_path . 'ucp.' . $this->php_ext, "i=pm&mode=view&p={$this->item_id}"); + return append_sid($this->phpbb_root_path . 'ucp.' . $this->php_ext, "i=pm&mode=view&p={$this->item_id}"); + } + + /** + * Get the full url to this item + * + * @return string URL + */ + public function get_full_url() + { + return generate_board_url() . "/ucp.{$this->php_ext}?i=pm&mode=view&p={$this->item_id}"; } /** From 98a03090a05b1d7651c05ad23802973cf20dcf6b Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Sat, 8 Sep 2012 21:05:49 -0500 Subject: [PATCH 0119/2494] [ticket/11103] Move banned user checking to email method This will make sure banned users are never sent notification emails PHPBB3-11103 --- phpBB/includes/notifications/method/email.php | 12 ++++++++++++ phpBB/includes/notifications/type/pm.php | 16 ++-------------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/phpBB/includes/notifications/method/email.php b/phpBB/includes/notifications/method/email.php index b1979296b9..2b80b5bf3a 100644 --- a/phpBB/includes/notifications/method/email.php +++ b/phpBB/includes/notifications/method/email.php @@ -52,6 +52,13 @@ class phpbb_notifications_method_email extends phpbb_notifications_method_base $user_ids[] = $notification->user_id; } + // We do not send emails to banned users + if (!function_exists('phpbb_get_banned_user_ids')) + { + include($phpbb_container->getParameter('core.root_path') . 'includes/functions_user.' . $phpbb_container->getParameter('core.php_ext')); + } + $banned_users = phpbb_get_banned_user_ids($user_ids); + $sql = 'SELECT * FROM ' . USERS_TABLE . ' WHERE ' . $this->db->sql_in_set('user_id', $user_ids); $result = $this->db->sql_query($sql); @@ -72,6 +79,11 @@ class phpbb_notifications_method_email extends phpbb_notifications_method_base // Time to go through the queue and send emails foreach ($this->queue as $notification) { + if (in_array($notification->user_id, $banned_users)) + { + continue; + } + $notification->users($users); $user = $notification->get_user($notification->user_id); diff --git a/phpBB/includes/notifications/type/pm.php b/phpBB/includes/notifications/type/pm.php index 50c67de21a..92026c08d7 100644 --- a/phpBB/includes/notifications/type/pm.php +++ b/phpBB/includes/notifications/type/pm.php @@ -118,20 +118,8 @@ class phpbb_notifications_type_pm extends phpbb_notifications_type_base $db = $phpbb_container->get('dbal.conn'); $user = $phpbb_container->get('user'); - // Exclude guests, current user and banned users from notifications - unset($pm['recipients'][ANONYMOUS]);//, $pm['recipients'][$user->data['user_id']]); - - if (!sizeof($pm['recipients'])) - { - return; - } - - if (!function_exists('phpbb_get_banned_user_ids')) - { - include($phpbb_container->getParameter('core.root_path') . 'includes/functions_user.' . $phpbb_container->getParameter('core.php_ext')); - } - $banned_users = phpbb_get_banned_user_ids(array_keys($pm['recipients'])); - $pm['recipients'] = array_diff(array_keys($pm['recipients']), $banned_users); + // Exclude guests and current user from notifications + unset($pm['recipients'][ANONYMOUS], $pm['recipients'][$user->data['user_id']]); if (!sizeof($pm['recipients'])) { From 4b4ea7c5cde7c9f3684ca325c110f81eda593d67 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Sun, 9 Sep 2012 10:19:46 -0500 Subject: [PATCH 0120/2494] [ticket/11103] The service now handles all user loading itself Delete pm notifications when pms are deleted PHPBB3-11103 --- phpBB/includes/functions_privmsgs.php | 112 +++--------------- phpBB/includes/notifications/method/base.php | 25 +++- phpBB/includes/notifications/method/email.php | 14 +-- phpBB/includes/notifications/service.php | 101 +++++++++------- phpBB/includes/notifications/type/base.php | 24 +--- .../includes/notifications/type/interface.php | 4 +- phpBB/includes/notifications/type/pm.php | 98 ++++++++------- 7 files changed, 155 insertions(+), 223 deletions(-) diff --git a/phpBB/includes/functions_privmsgs.php b/phpBB/includes/functions_privmsgs.php index 8002765ee2..88c5bd8e2a 100644 --- a/phpBB/includes/functions_privmsgs.php +++ b/phpBB/includes/functions_privmsgs.php @@ -982,6 +982,7 @@ function handle_mark_actions($user_id, $mark_action) function delete_pm($user_id, $msg_ids, $folder_id) { global $db, $user, $phpbb_root_path, $phpEx; + global $phpbb_container; $user_id = (int) $user_id; $folder_id = (int) $folder_id; @@ -1093,6 +1094,10 @@ function delete_pm($user_id, $msg_ids, $folder_id) $user->data['user_unread_privmsg'] -= $num_unread; } + // Delete Notifications + $phpbb_notifications = $phpbb_container->get('notifications'); + $phpbb_notifications->delete_notifications('pm', array_keys($delete_rows)); + // Now we have to check which messages we can delete completely $sql = 'SELECT msg_id FROM ' . PRIVMSGS_TO_TABLE . ' @@ -1843,106 +1848,25 @@ function submit_pm($mode, $subject, &$data, $put_in_outbox = true) $db->sql_transaction('commit'); // Send Notifications - if ($mode != 'edit') + $phpbb_notifications = $phpbb_container->get('notifications'); + + $pm_data = array_merge($data, array( + 'message_subject' => $subject, + 'recipients' => $recipients, + )); + + if ($mode == 'edit') { - $phpbb_notifications = $phpbb_container->get('notifications'); - - $phpbb_notifications->add_notifications('pm', array( - 'author_id' => $data['from_user_id'], - 'recipients' => $recipients, - 'message_subject' => $subject, - 'msg_id' => $data['msg_id'], - )); - - //pm_notification($mode, $data['from_username'], $recipients, $subject, $data['message'], $data['msg_id']); + $phpbb_notifications->update_notifications('pm', $pm_data); + } + else + { + $phpbb_notifications->add_notifications('pm', $pm_data); } return $data['msg_id']; } -/** -* PM Notification -*/ -function pm_notification($mode, $author, $recipients, $subject, $message, $msg_id) -{ - global $db, $user, $config, $phpbb_root_path, $phpEx, $auth; - - $subject = censor_text($subject); - - // Exclude guests, current user and banned users from notifications - unset($recipients[ANONYMOUS], $recipients[$user->data['user_id']]); - - if (!sizeof($recipients)) - { - return; - } - - if (!function_exists('phpbb_get_banned_user_ids')) - { - include($phpbb_root_path . 'includes/functions_user.' . $phpEx); - } - $banned_users = phpbb_get_banned_user_ids(array_keys($recipients)); - $recipients = array_diff(array_keys($recipients), $banned_users); - - if (!sizeof($recipients)) - { - return; - } - - $sql = 'SELECT user_id, username, user_email, user_lang, user_notify_pm, user_notify_type, user_jabber - FROM ' . USERS_TABLE . ' - WHERE ' . $db->sql_in_set('user_id', $recipients); - $result = $db->sql_query($sql); - - $msg_list_ary = array(); - while ($row = $db->sql_fetchrow($result)) - { - if ($row['user_notify_pm'] == 1 && trim($row['user_email'])) - { - $msg_list_ary[] = array( - 'method' => $row['user_notify_type'], - 'email' => $row['user_email'], - 'jabber' => $row['user_jabber'], - 'name' => $row['username'], - 'lang' => $row['user_lang'] - ); - } - } - $db->sql_freeresult($result); - - if (!sizeof($msg_list_ary)) - { - return; - } - - include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx); - $messenger = new messenger(); - - foreach ($msg_list_ary as $pos => $addr) - { - $messenger->template('privmsg_notify', $addr['lang']); - - $messenger->to($addr['email'], $addr['name']); - $messenger->im($addr['jabber'], $addr['name']); - - $messenger->assign_vars(array( - 'SUBJECT' => htmlspecialchars_decode($subject), - 'AUTHOR_NAME' => htmlspecialchars_decode($author), - 'USERNAME' => htmlspecialchars_decode($addr['name']), - - 'U_INBOX' => generate_board_url() . "/ucp.$phpEx?i=pm&folder=inbox", - 'U_VIEW_MESSAGE' => generate_board_url() . "/ucp.$phpEx?i=pm&mode=view&p=$msg_id", - )); - - $messenger->send($addr['method']); - } - unset($msg_list_ary); - - $messenger->save_queue(); - - unset($messenger); -} - /** * Display Message History */ diff --git a/phpBB/includes/notifications/method/base.php b/phpBB/includes/notifications/method/base.php index 98c06509c6..3ed9d3f33c 100644 --- a/phpBB/includes/notifications/method/base.php +++ b/phpBB/includes/notifications/method/base.php @@ -24,11 +24,31 @@ if (!defined('IN_PHPBB')) abstract class phpbb_notifications_method_base implements phpbb_notifications_method_interface { protected $phpbb_container; + protected $service; protected $db; protected $user; protected $phpbb_root_path; protected $php_ext; + /** + * Desired notifications + * unique by (type, type_id, user_id, method) + * if multiple methods are desired, multiple rows will exist. + * + * method of "none" will over-ride any other options + * + * item_type + * item_id + * user_id + * method + * none (will never receive notifications) + * standard (listed in notifications window + * popup? + * email + * jabber + * sms? + */ + /** * Queue of messages to be sent * @@ -36,11 +56,14 @@ abstract class phpbb_notifications_method_base implements phpbb_notifications_me */ protected $queue = array(); - public function __construct(ContainerBuilder $phpbb_container, $data = array()) + public function __construct(ContainerBuilder $phpbb_container) { // phpBB Container $this->phpbb_container = $phpbb_container; + // Service + $this->service = $phpbb_container->get('notifications'); + // Some common things we're going to use $this->db = $phpbb_container->get('dbal.conn'); $this->user = $phpbb_container->get('user'); diff --git a/phpBB/includes/notifications/method/email.php b/phpBB/includes/notifications/method/email.php index 2b80b5bf3a..50df9a6c56 100644 --- a/phpBB/includes/notifications/method/email.php +++ b/phpBB/includes/notifications/method/email.php @@ -59,14 +59,8 @@ class phpbb_notifications_method_email extends phpbb_notifications_method_base } $banned_users = phpbb_get_banned_user_ids($user_ids); - $sql = 'SELECT * FROM ' . USERS_TABLE . ' - WHERE ' . $this->db->sql_in_set('user_id', $user_ids); - $result = $this->db->sql_query($sql); - while ($row = $this->db->sql_fetchrow($result)) - { - $users[$row['user_id']] = $row; - } - $this->db->sql_freeresult($result); + // Load all the users we need + $this->service->load_users($user_ids); // Load the messenger if (!class_exists('messenger')) @@ -84,9 +78,7 @@ class phpbb_notifications_method_email extends phpbb_notifications_method_base continue; } - $notification->users($users); - - $user = $notification->get_user($notification->user_id); + $user = $this->service->get_user($notification->user_id); $messenger->template('privmsg_notify', $user['user_lang']); diff --git a/phpBB/includes/notifications/service.php b/phpBB/includes/notifications/service.php index 4794472883..50ceb1584a 100644 --- a/phpBB/includes/notifications/service.php +++ b/phpBB/includes/notifications/service.php @@ -31,7 +31,7 @@ class phpbb_notifications_service * * @var array Array of user data that we've loaded from the DB */ - protected $users; + protected $users = array(); public function __construct(ContainerBuilder $phpbb_container) { @@ -76,7 +76,6 @@ class phpbb_notifications_service $item_type_class_name = $this->get_item_type_class_name($row['item_type'], true); $notification = new $item_type_class_name($this->phpbb_container, $row); - $notification->users($this->users); $user_ids = array_merge($user_ids, $notification->users_to_query()); @@ -84,24 +83,7 @@ class phpbb_notifications_service } $this->db->sql_freeresult($result); - // Load the users - $user_ids = array_unique($user_ids); - - // @todo do not load users we already have in $this->users - - if (sizeof($user_ids)) - { - // @todo do not select everything - $sql = 'SELECT * FROM ' . USERS_TABLE . ' - WHERE ' . $this->db->sql_in_set('user_id', $user_ids); - $result = $this->db->sql_query($sql); - - while ($row = $this->db->sql_fetchrow($result)) - { - $this->users[$row['user_id']] = $row; - } - $this->db->sql_freeresult($result); - } + $this->load_users($user_ids); return $notifications; } @@ -122,32 +104,16 @@ class phpbb_notifications_service // Update any existing notifications for this item $this->update_notifications($item_type, $item_id, $data); - $notify_users = array(); + $notify_users = $user_ids = array(); $notification_objects = $notification_methods = array(); $new_rows = array(); - /** - * Desired notifications - * unique by (type, type_id, user_id, method) - * if multiple methods are desired, multiple rows will exist. - * - * method of "none" will over-ride any other options - * - * item_type - * item_id - * user_id - * method - * none (will never receive notifications) - * standard (listed in notifications window - * popup? - * email - * jabber - * sms? - */ - // find out which users want to receive this type of notification $notify_users = $item_type_class_name::find_users_for_notification($this->phpbb_container, $data); + // Never send notifications to the anonymous user or the current user! + $notify_users = array_diff($notify_users, array(ANONYMOUS, $this->phpbb_container->get('user')->data['user_id'])); + // Make sure not to send new notifications to users who've already been notified about this item // This may happen when an item was added, but now new users are able to see the item $sql = 'SELECT user_id FROM ' . NOTIFICATIONS_TABLE . " @@ -172,8 +138,12 @@ class phpbb_notifications_service $notification->user_id = (int) $user; + // Store the creation array in our new rows that will be inserted later $new_rows[] = $notification->create_insert_array($data); + // Users are needed to send notifications + $user_ids = array_merge($user_ids, $notification->users_to_query()); + foreach ($methods as $method) { // setup the notification methods and add the notification to the queue @@ -184,6 +154,7 @@ class phpbb_notifications_service $method_class_name = 'phpbb_notifications_method_' . $method; $notification_methods[$method] = new $method_class_name($this->phpbb_container); } + $notification_methods[$method]->add_to_queue($notification); } } @@ -192,6 +163,9 @@ class phpbb_notifications_service // insert into the db $this->db->sql_multi_insert(NOTIFICATIONS_TABLE, $new_rows); + // We need to load all of the users to send notifications + $this->load_users($user_ids); + // run the queue for each method to send notifications foreach ($notification_methods as $method) { @@ -203,13 +177,14 @@ class phpbb_notifications_service * Update a notification * * @param string $item_type Type identifier - * @param int $item_id Identifier within the type * @param array $data Data specific for this type that will be updated */ - public function update_notifications($item_type, $item_id, $data) + public function update_notifications($item_type, $data) { $item_type_class_name = $this->get_item_type_class_name($item_type); + $item_id = $item_type_class_name::get_item_id($data); + $notification = new $item_type_class_name($this->phpbb_container); $update_array = $notification->create_update_array($data); @@ -224,17 +199,55 @@ class phpbb_notifications_service * Delete a notification * * @param string $item_type Type identifier - * @param int $item_id Identifier within the type + * @param int|array $item_id Identifier within the type (or array of ids) * @param array $data Data specific for this type that will be updated */ public function delete_notifications($item_type, $item_id) { $sql = 'DELETE FROM ' . NOTIFICATIONS_TABLE . " WHERE item_type = '" . $this->db->sql_escape($item_type) . "' - AND item_id = " . (int) $item_id; + AND " . (is_array($item_id) ? $this->db->sql_in_set('item_id', $item_id) : 'item_id = ' . (int) $item_id); $this->db->sql_query($sql); } + /** + * Load user helper + * + * @param array $user_ids + */ + public function load_users($user_ids) + { + // Load the users + $user_ids = array_unique($user_ids); + + // Do not load users we already have in $this->users + $user_ids = array_diff($user_ids, array_keys($this->users)); + + if (sizeof($user_ids)) + { + $sql = 'SELECT * FROM ' . USERS_TABLE . ' + WHERE ' . $this->db->sql_in_set('user_id', $user_ids); + $result = $this->db->sql_query($sql); + + while ($row = $this->db->sql_fetchrow($result)) + { + $this->users[$row['user_id']] = $row; + } + $this->db->sql_freeresult($result); + } + } + + /** + * Get a user row from our users cache + * + * @param int $user_id + * @return array + */ + public function get_user($user_id) + { + return $this->users[$user_id]; + } + /** * Helper to get the notifications item type class name and clean it if unsafe */ diff --git a/phpBB/includes/notifications/type/base.php b/phpBB/includes/notifications/type/base.php index 32d8f58ff3..b0b8801a7e 100644 --- a/phpBB/includes/notifications/type/base.php +++ b/phpBB/includes/notifications/type/base.php @@ -24,6 +24,7 @@ if (!defined('IN_PHPBB')) abstract class phpbb_notifications_type_base implements phpbb_notifications_type_interface { protected $phpbb_container; + protected $service; protected $db; protected $phpbb_root_path; protected $php_ext; @@ -55,6 +56,9 @@ abstract class phpbb_notifications_type_base implements phpbb_notifications_type // phpBB Container $this->phpbb_container = $phpbb_container; + // Service + $this->service = $phpbb_container->get('notifications'); + // Some common things we're going to use $this->db = $phpbb_container->get('dbal.conn'); @@ -99,26 +103,6 @@ abstract class phpbb_notifications_type_base implements phpbb_notifications_type $this->data['data'][$name] = $value; } - /** - * Function to store the users loaded from the database (for output to the template) - * (The service handles this) - */ - public function users(&$users) - { - $this->users = &$users; - } - - /** - * Get a user row from our users cache - * - * @param int $user_id - * @return array - */ - public function get_user($user_id) - { - return $this->users[$user_id]; - } - /** * Output the notification to the template * diff --git a/phpBB/includes/notifications/type/interface.php b/phpBB/includes/notifications/type/interface.php index 03e24358a9..85fe41f6ef 100644 --- a/phpBB/includes/notifications/type/interface.php +++ b/phpBB/includes/notifications/type/interface.php @@ -25,6 +25,8 @@ interface phpbb_notifications_type_interface public static function get_item_id($type_data); + public static function find_users_for_notification(ContainerBuilder $phpbb_container, $type_data); + public function get_title(); public function get_url(); @@ -32,6 +34,4 @@ interface phpbb_notifications_type_interface public function get_full_url(); public function create_insert_array($type_data); - - public static function find_users_for_notification(ContainerBuilder $phpbb_container, $type_data); } diff --git a/phpBB/includes/notifications/type/pm.php b/phpBB/includes/notifications/type/pm.php index 92026c08d7..8b8f41d1c2 100644 --- a/phpBB/includes/notifications/type/pm.php +++ b/phpBB/includes/notifications/type/pm.php @@ -44,6 +44,50 @@ class phpbb_notifications_type_pm extends phpbb_notifications_type_base return $pm['msg_id']; } + /** + * Find the users who want to receive notifications + * + * @param array $pm Data from + * @return array + */ + public static function find_users_for_notification(ContainerBuilder $phpbb_container, $pm) + { + $service = $phpbb_container->get('notifications'); + $db = $phpbb_container->get('dbal.conn'); + $user = $phpbb_container->get('user'); + + if (!sizeof($pm['recipients'])) + { + return array(); + } + + $service->load_users(array_keys($pm['recipients'])); + + $notify_users = array(); + + foreach (array_keys($pm['recipients']) as $user_id) + { + $recipient = $service->get_user($user_id); + + if ($recipient['user_notify_pm']) + { + $notify_users[$recipient['user_id']] = array(); + + if ($recipient['user_notify_type'] == NOTIFY_EMAIL || $recipient['user_notify_type'] == NOTIFY_BOTH) + { + $notify_users[$recipient['user_id']][] = 'email'; + } + + if ($recipient['user_notify_type'] == NOTIFY_IM || $recipient['user_notify_type'] == NOTIFY_BOTH) + { + $notify_users[$recipient['user_id']][] = 'jabber'; + } + } + } + + return $notify_users; + } + /** * Get the title of this notification * @@ -51,7 +95,7 @@ class phpbb_notifications_type_pm extends phpbb_notifications_type_base */ public function get_title() { - $user_data = $this->get_user($this->get_data('author_id')); + $user_data = $this->service->get_user($this->get_data('from_user_id')); $username = get_username_string('no_profile', $user_data['user_id'], $user_data['username'], $user_data['user_colour']); @@ -85,7 +129,7 @@ class phpbb_notifications_type_pm extends phpbb_notifications_type_base */ public function users_to_query() { - return array($this->data['author_id']); + return array($this->data['from_user_id']); } /** @@ -100,58 +144,10 @@ class phpbb_notifications_type_pm extends phpbb_notifications_type_base { $this->item_id = $pm['msg_id']; - $this->set_data('author_id', $pm['author_id']); + $this->set_data('from_user_id', $pm['from_user_id']); $this->set_data('message_subject', $pm['message_subject']); return parent::create_insert_array($pm); } - - /** - * Find the users who want to receive notifications - * - * @param array $pm Data from - * @return array - */ - public static function find_users_for_notification(ContainerBuilder $phpbb_container, $pm) - { - $db = $phpbb_container->get('dbal.conn'); - $user = $phpbb_container->get('user'); - - // Exclude guests and current user from notifications - unset($pm['recipients'][ANONYMOUS], $pm['recipients'][$user->data['user_id']]); - - if (!sizeof($pm['recipients'])) - { - return; - } - - $sql = 'SELECT user_id, user_notify_pm, user_notify_type - FROM ' . USERS_TABLE . ' - WHERE ' . $db->sql_in_set('user_id', $pm['recipients']); - $result = $db->sql_query($sql); - - $pm['recipients'] = array(); - - while ($row = $db->sql_fetchrow($result)) - { - if ($row['user_notify_pm']) - { - $pm['recipients'][$row['user_id']] = array(); - - if ($row['user_notify_type'] == NOTIFY_EMAIL || $row['user_notify_type'] == NOTIFY_BOTH) - { - $pm['recipients'][$row['user_id']][] = 'email'; - } - - if ($row['user_notify_type'] == NOTIFY_IM || $row['user_notify_type'] == NOTIFY_BOTH) - { - $pm['recipients'][$row['user_id']][] = 'jabber'; - } - } - } - $db->sql_freeresult($result); - - return $pm['recipients']; - } } From ff45c9aa7c077fc0a03c64764917d1efcccf48f4 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Sun, 9 Sep 2012 10:36:22 -0500 Subject: [PATCH 0121/2494] [ticket/11103] General notification email template. PHPBB3-11103 --- phpBB/includes/notifications/method/base.php | 13 +---------- phpBB/includes/notifications/method/email.php | 15 ++++++------- .../notifications/method/interface.php | 2 +- phpBB/includes/notifications/service.php | 2 +- phpBB/includes/notifications/type/base.php | 22 ++++++++++++++++++- .../includes/notifications/type/interface.php | 4 ++++ phpBB/includes/notifications/type/pm.php | 20 +++++++++++++---- phpBB/language/en/email/notification.txt | 16 ++++++++++++++ 8 files changed, 67 insertions(+), 27 deletions(-) create mode 100644 phpBB/language/en/email/notification.txt diff --git a/phpBB/includes/notifications/method/base.php b/phpBB/includes/notifications/method/base.php index 3ed9d3f33c..b860fcffda 100644 --- a/phpBB/includes/notifications/method/base.php +++ b/phpBB/includes/notifications/method/base.php @@ -83,19 +83,8 @@ abstract class phpbb_notifications_method_base implements phpbb_notifications_me } /** - * Basic run queue function. - * Child methods should override this function if there are more efficient methods to mass-notification + * Empty the queue */ - public function run_queue() - { - foreach ($this->queue as $notification) - { - $this->notify($notification); - } - - $this->empty_queue(); - } - protected function empty_queue() { $this->queue = array(); diff --git a/phpBB/includes/notifications/method/email.php b/phpBB/includes/notifications/method/email.php index 50df9a6c56..69546be73f 100644 --- a/phpBB/includes/notifications/method/email.php +++ b/phpBB/includes/notifications/method/email.php @@ -33,12 +33,7 @@ class phpbb_notifications_method_email extends phpbb_notifications_method_base return true; } - public function notify($notification) - { - // email the user - } - - public function run_queue() + public function notify() { if (!sizeof($this->queue)) { @@ -80,14 +75,18 @@ class phpbb_notifications_method_email extends phpbb_notifications_method_base $user = $this->service->get_user($notification->user_id); - $messenger->template('privmsg_notify', $user['user_lang']); + $messenger->template('notification', $user['user_lang']); $messenger->to($user['user_email'], $user['username']); $messenger->assign_vars(array( - 'SUBJECT' => htmlspecialchars_decode($notification->get_title()), + 'USERNAME' => $user['username'], + + 'MESSAGE' => htmlspecialchars_decode($notification->get_title()), 'U_VIEW_MESSAGE' => $notification->get_full_url(), + + 'U_UNSUBSCRIBE' => $notification->get_unsubscribe_url(), )); $messenger->send('email'); diff --git a/phpBB/includes/notifications/method/interface.php b/phpBB/includes/notifications/method/interface.php index f18d005b8b..7d7f3abcd0 100644 --- a/phpBB/includes/notifications/method/interface.php +++ b/phpBB/includes/notifications/method/interface.php @@ -21,5 +21,5 @@ if (!defined('IN_PHPBB')) */ interface phpbb_notifications_method_interface { - public function notify($notification); + public function notify(); } diff --git a/phpBB/includes/notifications/service.php b/phpBB/includes/notifications/service.php index 50ceb1584a..463798fa07 100644 --- a/phpBB/includes/notifications/service.php +++ b/phpBB/includes/notifications/service.php @@ -169,7 +169,7 @@ class phpbb_notifications_service // run the queue for each method to send notifications foreach ($notification_methods as $method) { - $method->run_queue(); + $method->notify(); } } diff --git a/phpBB/includes/notifications/type/base.php b/phpBB/includes/notifications/type/base.php index b0b8801a7e..91cc9f175a 100644 --- a/phpBB/includes/notifications/type/base.php +++ b/phpBB/includes/notifications/type/base.php @@ -120,7 +120,7 @@ abstract class phpbb_notifications_type_base implements phpbb_notifications_type ), $options); $template->assign_block_vars($options['template_block'], array( - 'TITLE' => $this->get_title(), + 'TITLE' => $this->get_formatted_title(), 'URL' => $this->get_url(), 'TIME' => $user->format_date($this->time), @@ -173,4 +173,24 @@ abstract class phpbb_notifications_type_base implements phpbb_notifications_type return $data; } + + /** + * Get the formatted title of this notification (fall-back) + * + * @return string + */ + public function get_formatted_title() + { + return $this->get_title(); + } + + /** + * URL to unsubscribe to this notification + * + * @param string|bool $method Method name to unsubscribe from (email|jabber|etc), False to unsubscribe from all notifications for this item + */ + public function get_unsubscribe_url($method = false) + { + return false; + } } diff --git a/phpBB/includes/notifications/type/interface.php b/phpBB/includes/notifications/type/interface.php index 85fe41f6ef..c165815835 100644 --- a/phpBB/includes/notifications/type/interface.php +++ b/phpBB/includes/notifications/type/interface.php @@ -29,9 +29,13 @@ interface phpbb_notifications_type_interface public function get_title(); + public function get_formatted_title(); + public function get_url(); public function get_full_url(); + public function get_unsubscribe_url($method); + public function create_insert_array($type_data); } diff --git a/phpBB/includes/notifications/type/pm.php b/phpBB/includes/notifications/type/pm.php index 8b8f41d1c2..702ec39c16 100644 --- a/phpBB/includes/notifications/type/pm.php +++ b/phpBB/includes/notifications/type/pm.php @@ -89,7 +89,21 @@ class phpbb_notifications_type_pm extends phpbb_notifications_type_base } /** - * Get the title of this notification + * Get the HTML formatted title of this notification + * + * @return string + */ + public function get_formatted_title() + { + $user_data = $this->service->get_user($this->get_data('from_user_id')); + + $username = get_username_string('no_profile', $user_data['user_id'], $user_data['username'], $user_data['user_colour']); + + return $username . ' sent you a private message titled: ' . $this->get_data('message_subject'); + } + + /** + * Get the plain text title of this notification * * @return string */ @@ -97,9 +111,7 @@ class phpbb_notifications_type_pm extends phpbb_notifications_type_base { $user_data = $this->service->get_user($this->get_data('from_user_id')); - $username = get_username_string('no_profile', $user_data['user_id'], $user_data['username'], $user_data['user_colour']); - - return $username . ' sent you a private message titled: ' . $this->get_data('message_subject'); + return $user_data['username'] . ' sent you a private message titled: ' . $this->get_data('message_subject'); } /** diff --git a/phpBB/language/en/email/notification.txt b/phpBB/language/en/email/notification.txt new file mode 100644 index 0000000000..ed35e96c85 --- /dev/null +++ b/phpBB/language/en/email/notification.txt @@ -0,0 +1,16 @@ +Subject: Notification from {SITENAME} + +Hello {USERNAME}, + +{MESSAGE} + +You can view this by clicking on the following link: + +{U_VIEW_MESSAGE} + + +You may unsubscribe by clicking on the following link: +{U_UNSUBSCRIBE} + + +{EMAIL_SIG} \ No newline at end of file From 570fe6cee87da807f0917cdc0c84aee604b50510 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Sun, 9 Sep 2012 12:27:37 -0500 Subject: [PATCH 0122/2494] [ticket/11103] Do not initialize the notifications in common.php DIC initializes it when it is needed. PHPBB3-11103 --- phpBB/common.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/phpBB/common.php b/phpBB/common.php index 52879deb9c..281eb88c4d 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -146,9 +146,6 @@ if (!$config['use_system_cron']) $cron = $phpbb_container->get('cron.manager'); } -// Load notifications -$phpbb_notifications = $phpbb_container->get('notifications'); - /** * Main event which is triggered on every page * From 74e2a8f893a2e7a69ba129a74dd0b3c31e742e79 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Sun, 9 Sep 2012 13:29:47 -0500 Subject: [PATCH 0123/2494] [ticket/11103] Post notifications PHPBB3-11103 --- phpBB/includes/functions_posting.php | 252 ++------------------- phpBB/includes/mcp/mcp_queue.php | 6 +- phpBB/includes/notifications/type/base.php | 32 +++ phpBB/includes/notifications/type/pm.php | 2 + phpBB/includes/notifications/type/post.php | 71 +++++- 5 files changed, 122 insertions(+), 241 deletions(-) diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index c50395a5df..6c5c4535a3 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -61,7 +61,7 @@ function generate_smilies($mode, $forum_id) 'body' => 'posting_smilies.html') ); - generate_pagination(append_sid("{$phpbb_root_path}posting.$phpEx", 'mode=smilies&f=' . $forum_id), $smiley_count, $config['smilies_per_page'], $start); + generate_pagination(append_sid("{$phpbb_root_path}posting.$phpEx", 'mode=smilies&f=' . $forum_id), $smiley_count, $config['smilies_per_page'], $start); } $display_link = false; @@ -1173,237 +1173,6 @@ function topic_review($topic_id, $forum_id, $mode = 'topic_review', $cur_post_id return true; } -/** -* User Notification -*/ -function user_notification($mode, $subject, $topic_title, $forum_name, $forum_id, $topic_id, $post_id) -{ - global $db, $user, $config, $phpbb_root_path, $phpEx, $auth; - - $topic_notification = ($mode == 'reply' || $mode == 'quote') ? true : false; - $forum_notification = ($mode == 'post') ? true : false; - - if (!$topic_notification && !$forum_notification) - { - trigger_error('NO_MODE'); - } - - if (($topic_notification && !$config['allow_topic_notify']) || ($forum_notification && !$config['allow_forum_notify'])) - { - return; - } - - $topic_title = ($topic_notification) ? $topic_title : $subject; - $topic_title = censor_text($topic_title); - - // Exclude guests, current user and banned users from notifications - if (!function_exists('phpbb_get_banned_user_ids')) - { - include($phpbb_root_path . 'includes/functions_user.' . $phpEx); - } - $sql_ignore_users = phpbb_get_banned_user_ids(); - $sql_ignore_users[ANONYMOUS] = ANONYMOUS; - $sql_ignore_users[$user->data['user_id']] = $user->data['user_id']; - - $notify_rows = array(); - - // -- get forum_userids || topic_userids - $sql = 'SELECT u.user_id, u.username, u.user_email, u.user_lang, u.user_notify_type, u.user_jabber - FROM ' . (($topic_notification) ? TOPICS_WATCH_TABLE : FORUMS_WATCH_TABLE) . ' w, ' . USERS_TABLE . ' u - WHERE w.' . (($topic_notification) ? 'topic_id' : 'forum_id') . ' = ' . (($topic_notification) ? $topic_id : $forum_id) . ' - AND ' . $db->sql_in_set('w.user_id', $sql_ignore_users, true) . ' - AND w.notify_status = ' . NOTIFY_YES . ' - AND u.user_type IN (' . USER_NORMAL . ', ' . USER_FOUNDER . ') - AND u.user_id = w.user_id'; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $notify_user_id = (int) $row['user_id']; - $notify_rows[$notify_user_id] = array( - 'user_id' => $notify_user_id, - 'username' => $row['username'], - 'user_email' => $row['user_email'], - 'user_jabber' => $row['user_jabber'], - 'user_lang' => $row['user_lang'], - 'notify_type' => ($topic_notification) ? 'topic' : 'forum', - 'template' => ($topic_notification) ? 'topic_notify' : 'newtopic_notify', - 'method' => $row['user_notify_type'], - 'allowed' => false - ); - - // Add users who have been already notified to ignore list - $sql_ignore_users[$notify_user_id] = $notify_user_id; - } - $db->sql_freeresult($result); - - // forum notification is sent to those not already receiving topic notifications - if ($topic_notification) - { - $sql = 'SELECT u.user_id, u.username, u.user_email, u.user_lang, u.user_notify_type, u.user_jabber - FROM ' . FORUMS_WATCH_TABLE . ' fw, ' . USERS_TABLE . " u - WHERE fw.forum_id = $forum_id - AND " . $db->sql_in_set('fw.user_id', $sql_ignore_users, true) . ' - AND fw.notify_status = ' . NOTIFY_YES . ' - AND u.user_type IN (' . USER_NORMAL . ', ' . USER_FOUNDER . ') - AND u.user_id = fw.user_id'; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $notify_user_id = (int) $row['user_id']; - $notify_rows[$notify_user_id] = array( - 'user_id' => $notify_user_id, - 'username' => $row['username'], - 'user_email' => $row['user_email'], - 'user_jabber' => $row['user_jabber'], - 'user_lang' => $row['user_lang'], - 'notify_type' => 'forum', - 'template' => 'forum_notify', - 'method' => $row['user_notify_type'], - 'allowed' => false - ); - } - $db->sql_freeresult($result); - } - - if (!sizeof($notify_rows)) - { - return; - } - - // Make sure users are allowed to read the forum - foreach ($auth->acl_get_list(array_keys($notify_rows), 'f_read', $forum_id) as $forum_id => $forum_ary) - { - foreach ($forum_ary as $auth_option => $user_ary) - { - foreach ($user_ary as $user_id) - { - $notify_rows[$user_id]['allowed'] = true; - } - } - } - - // Now, we have to do a little step before really sending, we need to distinguish our users a little bit. ;) - $msg_users = $delete_ids = $update_notification = array(); - foreach ($notify_rows as $user_id => $row) - { - if (!$row['allowed'] || !trim($row['user_email'])) - { - $delete_ids[$row['notify_type']][] = $row['user_id']; - } - else - { - $msg_users[] = $row; - $update_notification[$row['notify_type']][] = $row['user_id']; - - /* - * We also update the forums watch table for this user when we are - * sending out a topic notification to prevent sending out another - * notification in case this user is also subscribed to the forum - * this topic was posted in. - * Since an UPDATE query is used, this has no effect on users only - * subscribed to the topic (i.e. no row is created) and should not - * be a performance issue. - */ - if ($row['notify_type'] === 'topic') - { - $update_notification['forum'][] = $row['user_id']; - } - } - } - unset($notify_rows); - - // Now, we are able to really send out notifications - if (sizeof($msg_users)) - { - include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx); - $messenger = new messenger(); - - $msg_list_ary = array(); - foreach ($msg_users as $row) - { - $pos = (!isset($msg_list_ary[$row['template']])) ? 0 : sizeof($msg_list_ary[$row['template']]); - - $msg_list_ary[$row['template']][$pos]['method'] = $row['method']; - $msg_list_ary[$row['template']][$pos]['email'] = $row['user_email']; - $msg_list_ary[$row['template']][$pos]['jabber'] = $row['user_jabber']; - $msg_list_ary[$row['template']][$pos]['name'] = $row['username']; - $msg_list_ary[$row['template']][$pos]['lang'] = $row['user_lang']; - $msg_list_ary[$row['template']][$pos]['user_id']= $row['user_id']; - } - unset($msg_users); - - foreach ($msg_list_ary as $email_template => $email_list) - { - foreach ($email_list as $addr) - { - $messenger->template($email_template, $addr['lang']); - - $messenger->to($addr['email'], $addr['name']); - $messenger->im($addr['jabber'], $addr['name']); - - $messenger->assign_vars(array( - 'USERNAME' => htmlspecialchars_decode($addr['name']), - 'TOPIC_TITLE' => htmlspecialchars_decode($topic_title), - 'FORUM_NAME' => htmlspecialchars_decode($forum_name), - - 'U_FORUM' => generate_board_url() . "/viewforum.$phpEx?f=$forum_id", - 'U_TOPIC' => generate_board_url() . "/viewtopic.$phpEx?f=$forum_id&t=$topic_id", - 'U_NEWEST_POST' => generate_board_url() . "/viewtopic.$phpEx?f=$forum_id&t=$topic_id&p=$post_id&e=$post_id", - 'U_STOP_WATCHING_TOPIC' => generate_board_url() . "/viewtopic.$phpEx?uid={$addr['user_id']}&f=$forum_id&t=$topic_id&unwatch=topic", - 'U_STOP_WATCHING_FORUM' => generate_board_url() . "/viewforum.$phpEx?uid={$addr['user_id']}&f=$forum_id&unwatch=forum", - )); - - $messenger->send($addr['method']); - } - } - unset($msg_list_ary); - - $messenger->save_queue(); - } - - // Handle the DB updates - $db->sql_transaction('begin'); - - if (!empty($update_notification['topic'])) - { - $sql = 'UPDATE ' . TOPICS_WATCH_TABLE . ' - SET notify_status = ' . NOTIFY_NO . " - WHERE topic_id = $topic_id - AND " . $db->sql_in_set('user_id', $update_notification['topic']); - $db->sql_query($sql); - } - - if (!empty($update_notification['forum'])) - { - $sql = 'UPDATE ' . FORUMS_WATCH_TABLE . ' - SET notify_status = ' . NOTIFY_NO . " - WHERE forum_id = $forum_id - AND " . $db->sql_in_set('user_id', $update_notification['forum']); - $db->sql_query($sql); - } - - // Now delete the user_ids not authorised to receive notifications on this topic/forum - if (!empty($delete_ids['topic'])) - { - $sql = 'DELETE FROM ' . TOPICS_WATCH_TABLE . " - WHERE topic_id = $topic_id - AND " . $db->sql_in_set('user_id', $delete_ids['topic']); - $db->sql_query($sql); - } - - if (!empty($delete_ids['forum'])) - { - $sql = 'DELETE FROM ' . FORUMS_WATCH_TABLE . " - WHERE forum_id = $forum_id - AND " . $db->sql_in_set('user_id', $delete_ids['forum']); - $db->sql_query($sql); - } - - $db->sql_transaction('commit'); -} - // // Post handling functions // @@ -1640,6 +1409,7 @@ function delete_post($forum_id, $topic_id, $post_id, &$data) function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $update_message = true, $update_search_index = true) { global $db, $auth, $user, $config, $phpEx, $template, $phpbb_root_path; + global $phpbb_container; // We do not handle erasing posts here if ($mode == 'delete') @@ -2452,7 +2222,23 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u // Send Notifications if (($mode == 'reply' || $mode == 'quote' || $mode == 'post') && $post_approval) { - user_notification($mode, $subject, $data['topic_title'], $data['forum_name'], $data['forum_id'], $data['topic_id'], $data['post_id']); + $notifications = $phpbb_container->get('notifications'); + + switch ($mode) + { + case 'reply' : + case 'quote' : + $notifications->add_notifications('post', array_merge($data, array( + 'post_username' => $username, + ))); + break; + + case 'post' : + $notifications->add_notifications('topic', array_merge($data, array( + 'post_username' => $username, + ))); + break; + } } $params = $add_anchor = ''; diff --git a/phpBB/includes/mcp/mcp_queue.php b/phpBB/includes/mcp/mcp_queue.php index b44685b8a3..d5c431e478 100644 --- a/phpBB/includes/mcp/mcp_queue.php +++ b/phpBB/includes/mcp/mcp_queue.php @@ -421,7 +421,7 @@ class mcp_queue $base_url = $this->u_action . "&f=$forum_id&st=$sort_days&sk=$sort_key&sd=$sort_dir"; phpbb_generate_template_pagination($template, $base_url, 'pagination', 'start', $total, $config['topics_per_page'], $start); - + // Now display the page $template->assign_vars(array( 'L_DISPLAY_ITEMS' => ($mode == 'unapproved_posts') ? $user->lang['DISPLAY_POSTS'] : $user->lang['DISPLAY_TOPICS'], @@ -639,12 +639,12 @@ function approve_post($post_id_list, $id, $mode) if ($post_id == $post_data['topic_first_post_id'] && $post_id == $post_data['topic_last_post_id']) { // Forum Notifications - user_notification('post', $post_data['topic_title'], $post_data['topic_title'], $post_data['forum_name'], $post_data['forum_id'], $post_data['topic_id'], $post_id); + $notifications->add_notifications('topic', $post_data); } else { // Topic Notifications - user_notification('reply', $post_data['post_subject'], $post_data['topic_title'], $post_data['forum_name'], $post_data['forum_id'], $post_data['topic_id'], $post_id); + $notifications->add_notifications('post', $post_data); } } diff --git a/phpBB/includes/notifications/type/base.php b/phpBB/includes/notifications/type/base.php index 91cc9f175a..df273f9e81 100644 --- a/phpBB/includes/notifications/type/base.php +++ b/phpBB/includes/notifications/type/base.php @@ -174,6 +174,38 @@ abstract class phpbb_notifications_type_base implements phpbb_notifications_type return $data; } + /** + * Find the users who want to receive notifications (helper) + * + * @param ContainerBuilder $phpbb_container + * @param array $item_id The item_id to search for + * + * @return array + */ + protected static function _find_users_for_notification(ContainerBuilder $phpbb_container, $item_id) + { + $db = $phpbb_container->get('dbal.conn'); + + $rowset = array(); + + $sql = 'SELECT * FROM ' . USER_NOTIFICATIONS_TABLE . " + WHERE item_type = '" . static::get_item_type() . "' + AND item_id = " . (int) $item_id; + $result = $db->sql_query($sql); + while ($row = $db->sql_fetchrow($result)) + { + if (!isset($rowset[$row['user_id']])) + { + $rowset[$row['user_id']] = array(); + } + + $rowset[$row['user_id']][] = $row['method']; + } + $db->sql_freeresult($result); + + return $rowset; + } + /** * Get the formatted title of this notification (fall-back) * diff --git a/phpBB/includes/notifications/type/pm.php b/phpBB/includes/notifications/type/pm.php index 702ec39c16..e060b5d658 100644 --- a/phpBB/includes/notifications/type/pm.php +++ b/phpBB/includes/notifications/type/pm.php @@ -47,7 +47,9 @@ class phpbb_notifications_type_pm extends phpbb_notifications_type_base /** * Find the users who want to receive notifications * + * @param ContainerBuilder $phpbb_container * @param array $pm Data from + * * @return array */ public static function find_users_for_notification(ContainerBuilder $phpbb_container, $pm) diff --git a/phpBB/includes/notifications/type/post.php b/phpBB/includes/notifications/type/post.php index 920a53bcf2..96faa0131c 100644 --- a/phpBB/includes/notifications/type/post.php +++ b/phpBB/includes/notifications/type/post.php @@ -44,6 +44,61 @@ class phpbb_notifications_type_post extends phpbb_notifications_type_base return $post['post_id']; } + /** + * Find the users who want to receive notifications + * + * @param ContainerBuilder $phpbb_container + * @param array $post Data from + * + * @return array + */ + public static function find_users_for_notification(ContainerBuilder $phpbb_container, $post) + { + $users = parent::_find_users_for_notification($phpbb_container, $post['topic_id']); + + if (!sizeof($users)) + { + return array(); + } + + $auth_read = $phpbb_container->get('auth')->acl_get_list(array_keys($users), 'f_read', $post['forum_id']); + + if (empty($auth_read)) + { + return array(); + } + + $notify_users = array(); + + foreach ($auth_read[$post['forum_id']]['f_read'] as $user_id) + { + $notify_users[$user_id] = $users[$user_id]; + } + + return $notify_users; + } + + /** + * Get the HTML formatted title of this notification + * + * @return string + */ + public function get_formatted_title() + { + if ($this->get_data('post_username')) + { + $username = $this->get_data('post_username'); + } + else + { + $user_data = $this->service->get_user($this->get_data('poster_id')); + + $username = get_username_string('no_profile', $user_data['user_id'], $user_data['username'], $user_data['user_colour']); + } + + return $username . ' posted in the topic ' . censor_text($this->get_data('topic_title')); + } + /** * Get the title of this notification * @@ -57,9 +112,7 @@ class phpbb_notifications_type_post extends phpbb_notifications_type_base } else { - $user_data = $this->get_user($this->get_data('poster_id')); - - $username = get_username_string('no_profile', $user_data['user_id'], $user_data['username'], $user_data['user_colour']); + $username = $user_data['username']; } return $username . ' posted in the topic ' . censor_text($this->get_data('topic_title')); @@ -75,6 +128,16 @@ class phpbb_notifications_type_post extends phpbb_notifications_type_base return append_sid($this->phpbb_root_path . 'viewtopic.' . $this->php_ext, "p={$this->item_id}#p{$this->item_id}"); } + /** + * Get the full url to this item + * + * @return string URL + */ + public function get_full_url() + { + return generate_board_url() . "/viewtopic.{$this->php_ext}?p={$this->item_id}#p{$this->item_id}"; + } + /** * Users needed to query before this notification can be displayed * @@ -103,8 +166,6 @@ class phpbb_notifications_type_post extends phpbb_notifications_type_base $this->set_data('post_username', $post['post_username']); - $this->time = $post['post_time']; - return parent::create_insert_array($post); } } From 3624d2c50ac1acca767c5642767102b97fd6b832 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Sun, 9 Sep 2012 14:20:14 -0500 Subject: [PATCH 0124/2494] [ticket/11103] Use the language system, topic notifications PHPBB3-11103 --- phpBB/includes/notifications/method/email.php | 8 +- phpBB/includes/notifications/type/pm.php | 4 +- phpBB/includes/notifications/type/post.php | 8 +- phpBB/includes/notifications/type/topic.php | 185 ++++++++++++++++++ phpBB/language/en/common.php | 3 + 5 files changed, 200 insertions(+), 8 deletions(-) create mode 100644 phpBB/includes/notifications/type/topic.php diff --git a/phpBB/includes/notifications/method/email.php b/phpBB/includes/notifications/method/email.php index 69546be73f..d6468c9dc3 100644 --- a/phpBB/includes/notifications/method/email.php +++ b/phpBB/includes/notifications/method/email.php @@ -50,7 +50,7 @@ class phpbb_notifications_method_email extends phpbb_notifications_method_base // We do not send emails to banned users if (!function_exists('phpbb_get_banned_user_ids')) { - include($phpbb_container->getParameter('core.root_path') . 'includes/functions_user.' . $phpbb_container->getParameter('core.php_ext')); + include($this->phpbb_container->getParameter('core.root_path') . 'includes/functions_user.' . $this->phpbb_container->getParameter('core.php_ext')); } $banned_users = phpbb_get_banned_user_ids($user_ids); @@ -68,13 +68,13 @@ class phpbb_notifications_method_email extends phpbb_notifications_method_base // Time to go through the queue and send emails foreach ($this->queue as $notification) { - if (in_array($notification->user_id, $banned_users)) + $user = $this->service->get_user($notification->user_id); + + if ($user['user_type'] == USER_IGNORE || in_array($notification->user_id, $banned_users)) { continue; } - $user = $this->service->get_user($notification->user_id); - $messenger->template('notification', $user['user_lang']); $messenger->to($user['user_email'], $user['username']); diff --git a/phpBB/includes/notifications/type/pm.php b/phpBB/includes/notifications/type/pm.php index e060b5d658..3368b171df 100644 --- a/phpBB/includes/notifications/type/pm.php +++ b/phpBB/includes/notifications/type/pm.php @@ -101,7 +101,7 @@ class phpbb_notifications_type_pm extends phpbb_notifications_type_base $username = get_username_string('no_profile', $user_data['user_id'], $user_data['username'], $user_data['user_colour']); - return $username . ' sent you a private message titled: ' . $this->get_data('message_subject'); + return $this->phpbb_container->get('user')->lang('NOTIFICATION_PM', $username, $this->get_data('message_subject')); } /** @@ -113,7 +113,7 @@ class phpbb_notifications_type_pm extends phpbb_notifications_type_base { $user_data = $this->service->get_user($this->get_data('from_user_id')); - return $user_data['username'] . ' sent you a private message titled: ' . $this->get_data('message_subject'); + return $this->phpbb_container->get('user')->lang('NOTIFICATION_PM', $user_data['username'], $this->get_data('message_subject')); } /** diff --git a/phpBB/includes/notifications/type/post.php b/phpBB/includes/notifications/type/post.php index 96faa0131c..04e269737e 100644 --- a/phpBB/includes/notifications/type/post.php +++ b/phpBB/includes/notifications/type/post.php @@ -96,7 +96,7 @@ class phpbb_notifications_type_post extends phpbb_notifications_type_base $username = get_username_string('no_profile', $user_data['user_id'], $user_data['username'], $user_data['user_colour']); } - return $username . ' posted in the topic ' . censor_text($this->get_data('topic_title')); + return $this->phpbb_container->get('user')->lang('NOTIFICATION_POST', $username, censor_text($this->get_data('topic_title'))); } /** @@ -112,10 +112,12 @@ class phpbb_notifications_type_post extends phpbb_notifications_type_base } else { + $user_data = $this->service->get_user($this->get_data('poster_id')); + $username = $user_data['username']; } - return $username . ' posted in the topic ' . censor_text($this->get_data('topic_title')); + return $this->phpbb_container->get('user')->lang('NOTIFICATION_POST', $username, censor_text($this->get_data('topic_title'))); } /** @@ -166,6 +168,8 @@ class phpbb_notifications_type_post extends phpbb_notifications_type_base $this->set_data('post_username', $post['post_username']); + $this->set_data('forum_name', $post['forum_name']); + return parent::create_insert_array($post); } } diff --git a/phpBB/includes/notifications/type/topic.php b/phpBB/includes/notifications/type/topic.php new file mode 100644 index 0000000000..f58419a633 --- /dev/null +++ b/phpBB/includes/notifications/type/topic.php @@ -0,0 +1,185 @@ +get('auth')->acl_get_list(array_keys($users), 'f_read', $topic['forum_id']); + + if (empty($auth_read)) + { + return array(); + } + + $notify_users = array(); + + foreach ($auth_read[$topic['forum_id']]['f_read'] as $user_id) + { + $notify_users[$user_id] = $users[$user_id]; + } + + return $notify_users; + } + + /** + * Get the HTML formatted title of this notification + * + * @return string + */ + public function get_formatted_title() + { + if ($this->get_data('post_username')) + { + $username = $this->get_data('post_username'); + } + else + { + $user_data = $this->service->get_user($this->get_data('poster_id')); + + $username = get_username_string('no_profile', $user_data['user_id'], $user_data['username'], $user_data['user_colour']); + } + + return $this->phpbb_container->get('user')->lang( + 'NOTIFICATION_TOPIC', + $username, + censor_text($this->get_data('topic_title')), + $this->get_data('forum_name') + ); + } + + /** + * Get the title of this notification + * + * @return string + */ + public function get_title() + { + if ($this->get_data('post_username')) + { + $username = $this->get_data('post_username'); + } + else + { + $user_data = $this->service->get_user($this->get_data('poster_id')); + + $username = $user_data['username']; + } + + return $this->phpbb_container->get('user')->lang( + 'NOTIFICATION_TOPIC', + $username, + censor_text($this->get_data('topic_title')), + $this->get_data('forum_name') + ); + } + + /** + * Get the url to this item + * + * @return string URL + */ + public function get_url() + { + return append_sid($this->phpbb_root_path . 'viewtopic.' . $this->php_ext, "t{$this->item_id}"); + } + + /** + * Get the full url to this item + * + * @return string URL + */ + public function get_full_url() + { + return generate_board_url() . "/viewtopic.{$this->php_ext}?t{$this->item_id}"; + } + + /** + * Users needed to query before this notification can be displayed + * + * @return array Array of user_ids + */ + public function users_to_query() + { + return array($this->data['poster_id']); + } + + /** + * Function for preparing the data for insertion in an SQL query + * (The service handles insertion) + * + * @param array $post Data from submit_post + * + * @return array Array of data ready to be inserted into the database + */ + public function create_insert_array($post) + { + $this->item_id = $post['post_id']; + + $this->set_data('poster_id', $post['poster_id']); + + $this->set_data('topic_title', $post['topic_title']); + + $this->set_data('post_username', $post['post_username']); + + $this->set_data('forum_name', $post['forum_name']); + + return parent::create_insert_array($post); + } +} diff --git a/phpBB/language/en/common.php b/phpBB/language/en/common.php index e6022e3b79..23f205dcc7 100644 --- a/phpBB/language/en/common.php +++ b/phpBB/language/en/common.php @@ -385,6 +385,9 @@ $lang = array_merge($lang, array( 'NOT_AUTHORISED' => 'You are not authorised to access this area.', 'NOT_WATCHING_FORUM' => 'You are no longer subscribed to updates on this forum.', 'NOT_WATCHING_TOPIC' => 'You are no longer subscribed to this topic.', + 'NOTIFICATION_PM' => '%1$s sent you a Private Message titled: %2$s.', + 'NOTIFICATION_POST' => '%1$s replied to the topic "%2$s".', + 'NOTIFICATION_TOPIC' => '%1$s posted a new topic "%2$s" in the forum "%3$s".', 'NOTIFY_ADMIN' => 'Please notify the board administrator or webmaster.', 'NOTIFY_ADMIN_EMAIL' => 'Please notify the board administrator or webmaster: %1$s', 'NO_ACCESS_ATTACHMENT' => 'You are not allowed to access this file.', From e09f25d59707fc842b073fa2909cefc3d16ecbf3 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Sun, 9 Sep 2012 14:55:40 -0500 Subject: [PATCH 0125/2494] [ticket/11103] Update notifications on post/topic edit PHPBB3-11103 --- phpBB/includes/functions_posting.php | 19 ++++++++++++++++--- phpBB/includes/notifications/service.php | 6 +++--- phpBB/includes/notifications/type/post.php | 14 +++++++++++--- phpBB/includes/notifications/type/topic.php | 8 ++++---- 4 files changed, 34 insertions(+), 13 deletions(-) diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index 6c5c4535a3..64840bfa51 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -2220,12 +2220,18 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u } // Send Notifications - if (($mode == 'reply' || $mode == 'quote' || $mode == 'post') && $post_approval) + if ($post_approval) { $notifications = $phpbb_container->get('notifications'); switch ($mode) { + case 'post' : + $notifications->add_notifications('topic', array_merge($data, array( + 'post_username' => $username, + ))); + break; + case 'reply' : case 'quote' : $notifications->add_notifications('post', array_merge($data, array( @@ -2233,8 +2239,15 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u ))); break; - case 'post' : - $notifications->add_notifications('topic', array_merge($data, array( + case 'edit_topic' : + case 'edit_first_post' : + case 'edit' : + case 'edit_last_post' : + $notifications->update_notifications('topic', array_merge($data, array( + 'post_username' => $username, + 'topic_title' => $subject, + ))); + $notifications->update_notifications('post', array_merge($data, array( 'post_username' => $username, ))); break; diff --git a/phpBB/includes/notifications/service.php b/phpBB/includes/notifications/service.php index 463798fa07..112cbae3fd 100644 --- a/phpBB/includes/notifications/service.php +++ b/phpBB/includes/notifications/service.php @@ -58,10 +58,10 @@ class phpbb_notifications_service // Merge default options $options = array_merge(array( 'user_id' => $user->data['user_id'], - 'limit' => 5, - 'start' => 0, 'order_by' => 'time', 'order_dir' => 'DESC', + 'limit' => 5, + 'start' => 0, ), $options); $notifications = $user_ids = array(); @@ -147,7 +147,7 @@ class phpbb_notifications_service foreach ($methods as $method) { // setup the notification methods and add the notification to the queue - if ($method) + if ($method) // blank means we just insert it as a notification, but do not notify them by any other means { if (!isset($notification_methods[$method])) { diff --git a/phpBB/includes/notifications/type/post.php b/phpBB/includes/notifications/type/post.php index 04e269737e..efada4220e 100644 --- a/phpBB/includes/notifications/type/post.php +++ b/phpBB/includes/notifications/type/post.php @@ -96,7 +96,11 @@ class phpbb_notifications_type_post extends phpbb_notifications_type_base $username = get_username_string('no_profile', $user_data['user_id'], $user_data['username'], $user_data['user_colour']); } - return $this->phpbb_container->get('user')->lang('NOTIFICATION_POST', $username, censor_text($this->get_data('topic_title'))); + return $this->phpbb_container->get('user')->lang( + 'NOTIFICATION_POST', + $username, + censor_text($this->get_data('topic_title')) + ); } /** @@ -117,7 +121,11 @@ class phpbb_notifications_type_post extends phpbb_notifications_type_base $username = $user_data['username']; } - return $this->phpbb_container->get('user')->lang('NOTIFICATION_POST', $username, censor_text($this->get_data('topic_title'))); + return $this->phpbb_container->get('user')->lang( + 'NOTIFICATION_POST', + $username, + censor_text($this->get_data('topic_title')) + ); } /** @@ -166,7 +174,7 @@ class phpbb_notifications_type_post extends phpbb_notifications_type_base $this->set_data('topic_title', $post['topic_title']); - $this->set_data('post_username', $post['post_username']); + $this->set_data('post_username', (($post['post_username'] != $this->phpbb_container->get('user')->data['username']) ? $post['post_username'] : '')); $this->set_data('forum_name', $post['forum_name']); diff --git a/phpBB/includes/notifications/type/topic.php b/phpBB/includes/notifications/type/topic.php index f58419a633..ee8c21fd9c 100644 --- a/phpBB/includes/notifications/type/topic.php +++ b/phpBB/includes/notifications/type/topic.php @@ -137,7 +137,7 @@ class phpbb_notifications_type_topic extends phpbb_notifications_type_base */ public function get_url() { - return append_sid($this->phpbb_root_path . 'viewtopic.' . $this->php_ext, "t{$this->item_id}"); + return append_sid($this->phpbb_root_path . 'viewtopic.' . $this->php_ext, "t={$this->item_id}"); } /** @@ -147,7 +147,7 @@ class phpbb_notifications_type_topic extends phpbb_notifications_type_base */ public function get_full_url() { - return generate_board_url() . "/viewtopic.{$this->php_ext}?t{$this->item_id}"; + return generate_board_url() . "/viewtopic.{$this->php_ext}?t={$this->item_id}"; } /** @@ -170,13 +170,13 @@ class phpbb_notifications_type_topic extends phpbb_notifications_type_base */ public function create_insert_array($post) { - $this->item_id = $post['post_id']; + $this->item_id = $post['topic_id']; $this->set_data('poster_id', $post['poster_id']); $this->set_data('topic_title', $post['topic_title']); - $this->set_data('post_username', $post['post_username']); + $this->set_data('post_username', (($post['post_username'] != $this->phpbb_container->get('user')->data['username']) ? $post['post_username'] : '')); $this->set_data('forum_name', $post['forum_name']); From 5502f3c4aa30ce72131f2a55bcfa3db7a4059427 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Sun, 9 Sep 2012 17:20:39 -0500 Subject: [PATCH 0126/2494] [ticket/11103] Restyle the notification list Very rough (lots of inline CSS, very ugly) PHPBB3-11103 --- phpBB/includes/functions.php | 2 +- phpBB/includes/functions_display.php | 7 +-- phpBB/includes/mcp/mcp_queue.php | 4 +- phpBB/includes/notifications/service.php | 14 ++++++ phpBB/includes/notifications/type/base.php | 44 ++++++++++++------- phpBB/includes/notifications/type/pm.php | 8 ++++ phpBB/includes/notifications/type/post.php | 8 ++++ phpBB/includes/notifications/type/topic.php | 8 ++++ .../prosilver/template/overall_header.html | 25 +++++++---- phpBB/styles/prosilver/theme/common.css | 8 ++++ 10 files changed, 98 insertions(+), 30 deletions(-) diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 7632ea1fcb..e5c7839894 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -5096,7 +5096,7 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0 $phpbb_notifications = $phpbb_container->get('notifications'); foreach ($phpbb_notifications->load_notifications() as $notification) { - $notification->display(); + $template->assign_block_vars('notifications', $notification->prepare_for_display()); } // application/xhtml+xml not used because of IE diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php index 8328b9ee7a..84cb47867e 100644 --- a/phpBB/includes/functions_display.php +++ b/phpBB/includes/functions_display.php @@ -1319,10 +1319,11 @@ function get_user_rank($user_rank, $user_posts, &$rank_title, &$rank_img, &$rank * @param string $avatar_height Height of users avatar * @param string $alt Optional language string for alt tag within image, can be a language key or text * @param bool $ignore_config Ignores the config-setting, to be still able to view the avatar in the UCP +* @param string $custom_css Custom CSS class to apply to the image * * @return string Avatar image */ -function get_user_avatar($avatar, $avatar_type, $avatar_width, $avatar_height, $alt = 'USER_AVATAR', $ignore_config = false) +function get_user_avatar($avatar, $avatar_type, $avatar_width, $avatar_height, $alt = 'USER_AVATAR', $ignore_config = false, $custom_css = '') { global $user, $config, $phpbb_root_path, $phpEx; global $phpbb_dispatcher; @@ -1343,7 +1344,7 @@ function get_user_avatar($avatar, $avatar_type, $avatar_width, $avatar_height, $ * @var string overwrite_avatar If set, this string will be the avatar * @since 3.1-A1 */ - $vars = array('avatar', 'avatar_type', 'avatar_width', 'avatar_height', 'alt', 'ignore_config', 'overwrite_avatar'); + $vars = array('avatar', 'avatar_type', 'avatar_width', 'avatar_height', 'alt', 'ignore_config', 'overwrite_avatar', 'custom_css'); extract($phpbb_dispatcher->trigger_event('core.user_get_avatar', compact($vars))); if ($overwrite_avatar) @@ -1385,7 +1386,7 @@ function get_user_avatar($avatar, $avatar_type, $avatar_width, $avatar_height, $ } $avatar_img .= $avatar; - return '' . ((!empty($user->lang[$alt])) ? $user->lang[$alt] : $alt) . ''; + return '' . ((!empty($user->lang[$alt])) ? $user->lang[$alt] : $alt) . ''; } /** diff --git a/phpBB/includes/mcp/mcp_queue.php b/phpBB/includes/mcp/mcp_queue.php index d5c431e478..1d9a2dfedc 100644 --- a/phpBB/includes/mcp/mcp_queue.php +++ b/phpBB/includes/mcp/mcp_queue.php @@ -451,7 +451,7 @@ function approve_post($post_id_list, $id, $mode) { global $db, $template, $user, $config; global $phpEx, $phpbb_root_path; - global $request; + global $request, $phpbb_container; if (!check_ids($post_id_list, POSTS_TABLE, 'post_id', array('m_approve'))) { @@ -634,6 +634,8 @@ function approve_post($post_id_list, $id, $mode) // Send out normal user notifications $email_sig = str_replace('
    ', "\n", "-- \n" . $config['board_email_sig']); + $notifications = $phpbb_container->get('notifications'); + foreach ($post_info as $post_id => $post_data) { if ($post_id == $post_data['topic_first_post_id'] && $post_id == $post_data['topic_last_post_id']) diff --git a/phpBB/includes/notifications/service.php b/phpBB/includes/notifications/service.php index 112cbae3fd..5dcfeb127b 100644 --- a/phpBB/includes/notifications/service.php +++ b/phpBB/includes/notifications/service.php @@ -210,6 +210,20 @@ class phpbb_notifications_service $this->db->sql_query($sql); } + public function add_subscription($item_type, $item_id, $method = '') + { + $this->get_item_type_class_name($item_type); + + $sql = 'INSERT INTO ' . USER_NOTIFICATIONS_TABLE . ' ' . + $this->db->sql_build_array('INSERT', array( + 'item_type' => $item_type, + 'item_id' => (int) $item_id, + 'user_id' => $this->phpbb_container->get('user')->data['user_id'], + 'method' => $method, + )); + $this->db->sql_query($sql); + } + /** * Load user helper * diff --git a/phpBB/includes/notifications/type/base.php b/phpBB/includes/notifications/type/base.php index df273f9e81..e60b20c449 100644 --- a/phpBB/includes/notifications/type/base.php +++ b/phpBB/includes/notifications/type/base.php @@ -104,28 +104,23 @@ abstract class phpbb_notifications_type_base implements phpbb_notifications_type } /** - * Output the notification to the template - * - * @param array $options Array of options - * template_block Template block name to output to (Default: notifications) + * Prepare to output the notification to the template */ - public function display($options = array()) + public function prepare_for_display() { - $template = $this->phpbb_container->get('template'); $user = $this->phpbb_container->get('user'); - // Merge default options - $options = array_merge(array( - 'template_block' => 'notifications', - ), $options); + return array( + 'AVATAR' => $this->get_avatar(), - $template->assign_block_vars($options['template_block'], array( - 'TITLE' => $this->get_formatted_title(), - 'URL' => $this->get_url(), - 'TIME' => $user->format_date($this->time), + 'FORMATTED_TITLE' => $this->get_formatted_title(), + 'TITLE' => $this->get_title(), - 'UNREAD' => $this->unread, - )); + 'URL' => $this->get_url(), + 'TIME' => $user->format_date($this->time), + + 'UNREAD' => $this->unread, + ); } /** @@ -206,6 +201,13 @@ abstract class phpbb_notifications_type_base implements phpbb_notifications_type return $rowset; } + protected function _get_avatar($user_id) + { + $user = $this->service->get_user($user_id); + + return get_user_avatar($user['user_avatar'], $user['user_avatar_type'], $user['user_avatar_width'], $user['user_avatar_height'], $user['username'], false, 'notifications-avatar'); + } + /** * Get the formatted title of this notification (fall-back) * @@ -217,7 +219,7 @@ abstract class phpbb_notifications_type_base implements phpbb_notifications_type } /** - * URL to unsubscribe to this notification + * URL to unsubscribe to this notification (fall-back) * * @param string|bool $method Method name to unsubscribe from (email|jabber|etc), False to unsubscribe from all notifications for this item */ @@ -225,4 +227,12 @@ abstract class phpbb_notifications_type_base implements phpbb_notifications_type { return false; } + + /** + * Get the user's avatar (fall-back) + */ + public function get_avatar() + { + return ''; + } } diff --git a/phpBB/includes/notifications/type/pm.php b/phpBB/includes/notifications/type/pm.php index 3368b171df..c78efcdd55 100644 --- a/phpBB/includes/notifications/type/pm.php +++ b/phpBB/includes/notifications/type/pm.php @@ -90,6 +90,14 @@ class phpbb_notifications_type_pm extends phpbb_notifications_type_base return $notify_users; } + /** + * Get the user's avatar + */ + public function get_avatar() + { + return $this->_get_avatar($this->get_data('from_user_id')); + } + /** * Get the HTML formatted title of this notification * diff --git a/phpBB/includes/notifications/type/post.php b/phpBB/includes/notifications/type/post.php index efada4220e..f374114890 100644 --- a/phpBB/includes/notifications/type/post.php +++ b/phpBB/includes/notifications/type/post.php @@ -78,6 +78,14 @@ class phpbb_notifications_type_post extends phpbb_notifications_type_base return $notify_users; } + /** + * Get the user's avatar + */ + public function get_avatar() + { + return $this->_get_avatar($this->get_data('poster_id')); + } + /** * Get the HTML formatted title of this notification * diff --git a/phpBB/includes/notifications/type/topic.php b/phpBB/includes/notifications/type/topic.php index ee8c21fd9c..51a95d5e19 100644 --- a/phpBB/includes/notifications/type/topic.php +++ b/phpBB/includes/notifications/type/topic.php @@ -78,6 +78,14 @@ class phpbb_notifications_type_topic extends phpbb_notifications_type_base return $notify_users; } + /** + * Get the user's avatar + */ + public function get_avatar() + { + return $this->_get_avatar($this->get_data('poster_id')); + } + /** * Get the HTML formatted title of this notification * diff --git a/phpBB/styles/prosilver/template/overall_header.html b/phpBB/styles/prosilver/template/overall_header.html index 77fdb230ad..1695f8d03a 100644 --- a/phpBB/styles/prosilver/template/overall_header.html +++ b/phpBB/styles/prosilver/template/overall_header.html @@ -132,6 +132,22 @@
    diff --git a/phpBB/adm/style/acp_groups.html b/phpBB/adm/style/acp_groups.html index b38d61bef3..e96adcee90 100644 --- a/phpBB/adm/style/acp_groups.html +++ b/phpBB/adm/style/acp_groups.html @@ -17,7 +17,7 @@ -
    enctype="multipart/form-data"> + enctype="multipart/form-data" enctype="multipart/form-data">
    {L_GROUP_DETAILS} diff --git a/phpBB/includes/avatar/driver/local.php b/phpBB/includes/avatar/driver/local.php index 080921c325..cdee983d9e 100644 --- a/phpBB/includes/avatar/driver/local.php +++ b/phpBB/includes/avatar/driver/local.php @@ -91,11 +91,12 @@ class phpbb_avatar_driver_local extends phpbb_avatar_driver $template->assign_block_vars('av_local_row.av_local_col', array( 'AVATAR_IMAGE' => $this->phpbb_root_path . $this->config['avatar_gallery_path'] . '/' . $img['file'], - 'AVATAR_NAME' => $img['name'], - 'AVATAR_FILE' => $img['filename'], + 'AVATAR_NAME' => $img['name'], + 'AVATAR_FILE' => $img['filename'], )); $template->assign_block_vars('av_local_row.av_local_option', array( + 'AVATAR_FILE' => $img['filename'], 'S_OPTIONS_AVATAR' => $img['filename'] )); From 7521c077a9c0b3201dffcbe33114d9da715eb9e0 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 18 Nov 2012 23:16:37 +0100 Subject: [PATCH 0466/2494] [feature/avatars] Miscellaenous template fixes PHPBB3-10018 --- phpBB/adm/style/acp_avatar_options_local.html | 3 +-- phpBB/styles/prosilver/template/ucp_avatar_options_local.html | 4 ++-- .../styles/subsilver2/template/ucp_avatar_options_local.html | 4 ++++ 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/phpBB/adm/style/acp_avatar_options_local.html b/phpBB/adm/style/acp_avatar_options_local.html index b317cd2aa5..08ec170195 100644 --- a/phpBB/adm/style/acp_avatar_options_local.html +++ b/phpBB/adm/style/acp_avatar_options_local.html @@ -7,9 +7,8 @@  
    -
    - +
    diff --git a/phpBB/styles/prosilver/template/ucp_avatar_options_local.html b/phpBB/styles/prosilver/template/ucp_avatar_options_local.html index 9ca9b6e9ec..8b46dfa7f5 100644 --- a/phpBB/styles/prosilver/template/ucp_avatar_options_local.html +++ b/phpBB/styles/prosilver/template/ucp_avatar_options_local.html @@ -9,8 +9,8 @@ diff --git a/phpBB/styles/subsilver2/template/ucp_avatar_options_local.html b/phpBB/styles/subsilver2/template/ucp_avatar_options_local.html index 37ac864b27..352052f9f4 100644 --- a/phpBB/styles/subsilver2/template/ucp_avatar_options_local.html +++ b/phpBB/styles/subsilver2/template/ucp_avatar_options_local.html @@ -22,6 +22,10 @@ + + + +
    {L_NO_AVATAR_CATEGORY}
    From bea6e845d3c0c25f5f84ad13fcf22f42f1249561 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 19 Nov 2012 00:27:22 +0100 Subject: [PATCH 0467/2494] [feature/avatars] Use https for gravatar PHPBB3-10018 --- phpBB/includes/avatar/driver/gravatar.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/phpBB/includes/avatar/driver/gravatar.php b/phpBB/includes/avatar/driver/gravatar.php index b07af59366..b8f23b04a9 100644 --- a/phpBB/includes/avatar/driver/gravatar.php +++ b/phpBB/includes/avatar/driver/gravatar.php @@ -56,7 +56,7 @@ class phpbb_avatar_driver_gravatar extends phpbb_avatar_driver */ public function get_custom_html($row, $ignore_config = false, $alt = '') { - $html = ' Date: Mon, 19 Nov 2012 00:30:18 +0100 Subject: [PATCH 0468/2494] [feature/avatars] Fix the docs and small naming fixes PHPBB3-10018 --- phpBB/includes/avatar/driver/driver.php | 2 +- phpBB/includes/avatar/driver/gravatar.php | 4 +-- phpBB/includes/avatar/driver/interface.php | 34 ++++++++++++++++--- phpBB/includes/avatar/driver/local.php | 4 ++- phpBB/includes/avatar/driver/upload.php | 4 ++- phpBB/includes/avatar/manager.php | 38 +++++++++++++++++----- phpBB/install/database_update.php | 5 +++ 7 files changed, 71 insertions(+), 20 deletions(-) diff --git a/phpBB/includes/avatar/driver/driver.php b/phpBB/includes/avatar/driver/driver.php index 9a213ce730..1e899b7c50 100644 --- a/phpBB/includes/avatar/driver/driver.php +++ b/phpBB/includes/avatar/driver/driver.php @@ -81,7 +81,7 @@ abstract class phpbb_avatar_driver implements phpbb_avatar_driver_interface public $custom_html = false; /** - * Construct an driver object + * Construct a driver object * * @param $config The phpBB configuration * @param $request The request object diff --git a/phpBB/includes/avatar/driver/gravatar.php b/phpBB/includes/avatar/driver/gravatar.php index b8f23b04a9..036800fd45 100644 --- a/phpBB/includes/avatar/driver/gravatar.php +++ b/phpBB/includes/avatar/driver/gravatar.php @@ -19,11 +19,10 @@ if (!defined('IN_PHPBB')) * Handles avatars hosted at gravatar.com * @package avatars */ -// @todo: rename classes to phpbb_ext_foo_avatar_driver_foo and similar class phpbb_avatar_driver_gravatar extends phpbb_avatar_driver { /** - * We'll need to create a different type of avatar for gravatar + * @inheritdoc */ public $custom_html = true; @@ -32,7 +31,6 @@ class phpbb_avatar_driver_gravatar extends phpbb_avatar_driver */ public function get_data($row, $ignore_config = false) { - // @todo: add allow_avatar_gravatar to database_update.php etc. if ($ignore_config || $this->config['allow_avatar_gravatar']) { return array( diff --git a/phpBB/includes/avatar/driver/interface.php b/phpBB/includes/avatar/driver/interface.php index f066470174..11dbffa65d 100644 --- a/phpBB/includes/avatar/driver/interface.php +++ b/phpBB/includes/avatar/driver/interface.php @@ -51,27 +51,51 @@ interface phpbb_avatar_driver_interface public function get_custom_html($row, $ignore_config = false, $alt = ''); /** - * @TODO + * Prepare form for changing the settings of this avatar + * + * @param object $template The template object + * @param array $row The user data or group data that has been cleaned with + * phpbb_avatar_manager::clean_row + * @param array &$error The reference to an error array + * + * @return bool Returns true if form has been successfully prepared **/ public function prepare_form($template, $row, &$error); /** - * @TODO + * Process form data + * + * @param object $template The template object + * @param array $row The user data or group data that has been cleaned with + * phpbb_avatar_manager::clean_row + * @param array &$error The reference to an error array + * + * @return array An array containing the avatar data as follows: + * ['avatar'], ['avatar_width'], ['avatar_height'] **/ public function process_form($template, $row, &$error); /** - * @TODO + * Delete avatar + * + * @param array $row The user data or group data that has been cleaned with + * phpbb_avatar_manager::clean_row + * + * @return bool True if avatar has been deleted or there is no need to delete **/ public function delete($row); /** - * @TODO + * Check if avatar is enabled + * + * @return bool True if avatar is enabled, false if it's disabled **/ public function is_enabled(); /** - * @TODO + * Get the avatars template name + * + * @return string The avatars template name **/ public function get_template_name(); } diff --git a/phpBB/includes/avatar/driver/local.php b/phpBB/includes/avatar/driver/local.php index cdee983d9e..9b3807ee4b 100644 --- a/phpBB/includes/avatar/driver/local.php +++ b/phpBB/includes/avatar/driver/local.php @@ -132,7 +132,9 @@ class phpbb_avatar_driver_local extends phpbb_avatar_driver } /** - * @TODO + * Get a list of avatars that are locally available + * + * @return array An array containing the locally available avatars */ private function get_avatar_list() { diff --git a/phpBB/includes/avatar/driver/upload.php b/phpBB/includes/avatar/driver/upload.php index 8f044ca37f..c9913548fc 100644 --- a/phpBB/includes/avatar/driver/upload.php +++ b/phpBB/includes/avatar/driver/upload.php @@ -139,7 +139,9 @@ class phpbb_avatar_driver_upload extends phpbb_avatar_driver } /** - * @TODO + * Check if user is able to upload an avatar + * + * @return bool True if user can upload, false if not */ private function can_upload() { diff --git a/phpBB/includes/avatar/manager.php b/phpBB/includes/avatar/manager.php index 546cdcdc05..7c7bd6c7ba 100644 --- a/phpBB/includes/avatar/manager.php +++ b/phpBB/includes/avatar/manager.php @@ -26,25 +26,37 @@ class phpbb_avatar_manager private $request; private $cache; private static $valid_drivers = false; - private $tasks; + private $avatar_drivers; private $container; /** - * @TODO + * Construct an avatar manager object + * + * @param $phpbb_root_path The path to the phpBB root + * @param $phpEx The php file extension + * @param $config The phpBB configuration + * @param $request The request object + * @param $cache A cache driver + * @param $avatar_drivers The avatars drivers passed via the service container + * @param $container The container object **/ - public function __construct($phpbb_root_path, $phpEx, phpbb_config $config, phpbb_request $request, phpbb_cache_driver_interface $cache, $tasks, $container) + public function __construct($phpbb_root_path, $phpEx, phpbb_config $config, phpbb_request $request, phpbb_cache_driver_interface $cache, $avatar_drivers, $container) { $this->phpbb_root_path = $phpbb_root_path; $this->phpEx = $phpEx; $this->config = $config; $this->request = $request; $this->cache = $cache; - $this->tasks = $tasks; + $this->avatar_drivers = $avatar_drivers; $this->container = $container; } /** - * @TODO + * Get the driver object specified by the avatar type + * + * @param string The avatar type; by default an avatar's service container name + * + * @return object The avatar driver object **/ public function get_driver($avatar_type) { @@ -87,14 +99,15 @@ class phpbb_avatar_manager } /** - * @TODO + * Load the list of valid drivers + * This is executed once and fills self::$valid_drivers **/ private function load_valid_drivers() { - if (!empty($this->tasks)) + if (!empty($this->avatar_drivers)) { self::$valid_drivers = array(); - foreach ($this->tasks as $driver) + foreach ($this->avatar_drivers as $driver) { self::$valid_drivers[] = $driver->get_name(); } @@ -102,7 +115,9 @@ class phpbb_avatar_manager } /** - * @TODO + * Get a list of valid avatar drivers + * + * @return array An array containing a list of the valid avatar drivers **/ public function get_valid_drivers() { @@ -116,6 +131,11 @@ class phpbb_avatar_manager /** * Strip out user_ and group_ prefixes from keys + * + * @param array $row The user data or group data + * + * @return array The user data or group data with keys that have been + * stripped from the preceding "user_" or "group_" **/ public static function clean_row($row) { diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 9498d3963b..2015ef0475 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -2740,6 +2740,11 @@ function change_database_data(&$no_updates, $version) AND module_mode = \'avatar\''; _sql($sql, $errored, $error_ary); + if (!isset($config['allow_avatar_gravatar'])) + { + $config->set('allow_avatar_gravatar', ''); + } + $no_updates = false; if (!isset($config['assets_version'])) From 858c59279c0f8b07412dec676c96d9b291d91897 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 19 Nov 2012 23:50:34 +0100 Subject: [PATCH 0469/2494] [feature/avatars] Use protected instead of private PHPBB3-10018 --- phpBB/includes/avatar/driver/driver.php | 2 +- phpBB/includes/avatar/driver/local.php | 2 +- phpBB/includes/avatar/driver/upload.php | 2 +- phpBB/includes/avatar/manager.php | 18 +++++++++--------- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/phpBB/includes/avatar/driver/driver.php b/phpBB/includes/avatar/driver/driver.php index 1e899b7c50..ef0c8ce44e 100644 --- a/phpBB/includes/avatar/driver/driver.php +++ b/phpBB/includes/avatar/driver/driver.php @@ -21,7 +21,7 @@ if (!defined('IN_PHPBB')) */ abstract class phpbb_avatar_driver implements phpbb_avatar_driver_interface { - private $name; + protected $name; /** * Returns the name of the driver. diff --git a/phpBB/includes/avatar/driver/local.php b/phpBB/includes/avatar/driver/local.php index 9b3807ee4b..d0ad8708b0 100644 --- a/phpBB/includes/avatar/driver/local.php +++ b/phpBB/includes/avatar/driver/local.php @@ -136,7 +136,7 @@ class phpbb_avatar_driver_local extends phpbb_avatar_driver * * @return array An array containing the locally available avatars */ - private function get_avatar_list() + protected function get_avatar_list() { $avatar_list = ($this->cache == null) ? false : $this->cache->get('av_local_list'); diff --git a/phpBB/includes/avatar/driver/upload.php b/phpBB/includes/avatar/driver/upload.php index c9913548fc..9475cad7a1 100644 --- a/phpBB/includes/avatar/driver/upload.php +++ b/phpBB/includes/avatar/driver/upload.php @@ -143,7 +143,7 @@ class phpbb_avatar_driver_upload extends phpbb_avatar_driver * * @return bool True if user can upload, false if not */ - private function can_upload() + protected function can_upload() { return (file_exists($this->phpbb_root_path . $this->config['avatar_path']) && phpbb_is_writable($this->phpbb_root_path . $this->config['avatar_path']) && (@ini_get('file_uploads') || strtolower(@ini_get('file_uploads')) == 'on')); } diff --git a/phpBB/includes/avatar/manager.php b/phpBB/includes/avatar/manager.php index 7c7bd6c7ba..0d36118dbc 100644 --- a/phpBB/includes/avatar/manager.php +++ b/phpBB/includes/avatar/manager.php @@ -20,14 +20,14 @@ if (!defined('IN_PHPBB')) */ class phpbb_avatar_manager { - private $phpbb_root_path; - private $phpEx; - private $config; - private $request; - private $cache; - private static $valid_drivers = false; - private $avatar_drivers; - private $container; + protected $phpbb_root_path; + protected $phpEx; + protected $config; + protected $request; + protected $cache; + protected static $valid_drivers = false; + protected $avatar_drivers; + protected $container; /** * Construct an avatar manager object @@ -102,7 +102,7 @@ class phpbb_avatar_manager * Load the list of valid drivers * This is executed once and fills self::$valid_drivers **/ - private function load_valid_drivers() + protected function load_valid_drivers() { if (!empty($this->avatar_drivers)) { From 2afb8b9df873c3f9572a32ab7a62ea8ba8d8a45b Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Tue, 20 Nov 2012 18:14:48 -0600 Subject: [PATCH 0470/2494] [ticket/11103] Create user loader class, update for DIC Create a very basic user loader class to handle querying/storing user data in a centralized location. Use DIC collection service for notification types/methods. Cleanup unused dependencies. Fix some other issues. PHPBB3-11103 --- phpBB/config/notifications.yml | 82 ++++------- phpBB/config/services.yml | 18 ++- phpBB/config/tables.yml | 1 + phpBB/includes/functions.php | 36 ++--- phpBB/includes/functions_admin.php | 16 +- phpBB/includes/functions_posting.php | 30 ++-- phpBB/includes/functions_privmsgs.php | 14 +- phpBB/includes/mcp/mcp_pm_reports.php | 2 +- phpBB/includes/mcp/mcp_queue.php | 28 ++-- phpBB/includes/mcp/mcp_reports.php | 10 +- phpBB/includes/notification/manager.php | 131 +++++++---------- phpBB/includes/notification/method/base.php | 14 +- phpBB/includes/notification/method/email.php | 4 +- phpBB/includes/notification/type/base.php | 39 ++--- phpBB/includes/notification/type/bookmark.php | 4 +- phpBB/includes/notification/type/pm.php | 8 +- phpBB/includes/notification/type/post.php | 10 +- phpBB/includes/notification/type/quote.php | 10 +- .../includes/notification/type/report_pm.php | 4 +- .../notification/type/report_pm_closed.php | 2 +- .../notification/type/report_post.php | 4 +- .../notification/type/report_post_closed.php | 4 +- phpBB/includes/notification/type/topic.php | 6 +- phpBB/includes/user_loader.php | 118 +++++++++++++++ phpBB/install/database_update.php | 12 +- phpBB/report.php | 4 +- tests/mock/container_builder.php | 19 +++ .../notifications_notification_manager.php | 69 +++++++++ .../ext/test/notification/type/test.php | 7 +- tests/notification/notification.php | 137 +++++++++++------- 30 files changed, 518 insertions(+), 325 deletions(-) create mode 100644 phpBB/includes/user_loader.php create mode 100644 tests/mock/notifications_notification_manager.php diff --git a/phpBB/config/notifications.yml b/phpBB/config/notifications.yml index 7c8e05494c..f8a5b5f9fa 100644 --- a/phpBB/config/notifications.yml +++ b/phpBB/config/notifications.yml @@ -1,12 +1,24 @@ services: + notification.type_collection: + class: phpbb_di_service_collection + arguments: + - @service_container + tags: + - { name: service_collection, tag: notification.type } + + notification.method_collection: + class: phpbb_di_service_collection + arguments: + - @service_container + tags: + - { name: service_collection, tag: notification.method } + notification.type.approve_post: class: phpbb_notification_type_approve_post arguments: - - @notification_manager + - @user_loader - @dbal.conn - @cache.driver - - @template - - @ext.manager - @user - @auth - @config @@ -20,11 +32,9 @@ services: notification.type.approve_topic: class: phpbb_notification_type_approve_topic arguments: - - @notification_manager + - @user_loader - @dbal.conn - @cache.driver - - @template - - @ext.manager - @user - @auth - @config @@ -38,11 +48,9 @@ services: notification.type.bookmark: class: phpbb_notification_type_bookmark arguments: - - @notification_manager + - @user_loader - @dbal.conn - @cache.driver - - @template - - @ext.manager - @user - @auth - @config @@ -56,11 +64,9 @@ services: notification.type.disapprove_post: class: phpbb_notification_type_disapprove_post arguments: - - @notification_manager + - @user_loader - @dbal.conn - @cache.driver - - @template - - @ext.manager - @user - @auth - @config @@ -74,11 +80,9 @@ services: notification.type.disapprove_topic: class: phpbb_notification_type_disapprove_topic arguments: - - @notification_manager + - @user_loader - @dbal.conn - @cache.driver - - @template - - @ext.manager - @user - @auth - @config @@ -92,11 +96,9 @@ services: notification.type.pm: class: phpbb_notification_type_pm arguments: - - @notification_manager + - @user_loader - @dbal.conn - @cache.driver - - @template - - @ext.manager - @user - @auth - @config @@ -110,11 +112,9 @@ services: notification.type.post: class: phpbb_notification_type_post arguments: - - @notification_manager + - @user_loader - @dbal.conn - @cache.driver - - @template - - @ext.manager - @user - @auth - @config @@ -128,11 +128,9 @@ services: notification.type.post_in_queue: class: phpbb_notification_type_post_in_queue arguments: - - @notification_manager + - @user_loader - @dbal.conn - @cache.driver - - @template - - @ext.manager - @user - @auth - @config @@ -146,11 +144,9 @@ services: notification.type.quote: class: phpbb_notification_type_quote arguments: - - @notification_manager + - @user_loader - @dbal.conn - @cache.driver - - @template - - @ext.manager - @user - @auth - @config @@ -164,11 +160,9 @@ services: notification.type.report_pm: class: phpbb_notification_type_report_pm arguments: - - @notification_manager + - @user_loader - @dbal.conn - @cache.driver - - @template - - @ext.manager - @user - @auth - @config @@ -182,11 +176,9 @@ services: notification.type.report_pm_closed: class: phpbb_notification_type_report_pm_closed arguments: - - @notification_manager + - @user_loader - @dbal.conn - @cache.driver - - @template - - @ext.manager - @user - @auth - @config @@ -200,11 +192,9 @@ services: notification.type.report_post: class: phpbb_notification_type_report_post arguments: - - @notification_manager + - @user_loader - @dbal.conn - @cache.driver - - @template - - @ext.manager - @user - @auth - @config @@ -218,11 +208,9 @@ services: notification.type.report_post_closed: class: phpbb_notification_type_report_post arguments: - - @notification_manager + - @user_loader - @dbal.conn - @cache.driver - - @template - - @ext.manager - @user - @auth - @config @@ -236,11 +224,9 @@ services: notification.type.topic: class: phpbb_notification_type_topic arguments: - - @notification_manager + - @user_loader - @dbal.conn - @cache.driver - - @template - - @ext.manager - @user - @auth - @config @@ -254,11 +240,9 @@ services: notification.type.topic_in_queue: class: phpbb_notification_type_topic_in_queue arguments: - - @notification_manager + - @user_loader - @dbal.conn - @cache.driver - - @template - - @ext.manager - @user - @auth - @config @@ -272,11 +256,9 @@ services: notification.method.email: class: phpbb_notification_method_email arguments: - - @notification_manager + - @user_loader - @dbal.conn - @cache.driver - - @template - - @ext.manager - @user - @auth - @config @@ -288,11 +270,9 @@ services: notification.method.jabber: class: phpbb_notification_method_jabber arguments: - - @notification_manager + - @user_loader - @dbal.conn - @cache.driver - - @template - - @ext.manager - @user - @auth - @config diff --git a/phpBB/config/services.yml b/phpBB/config/services.yml index af80d28b15..bbc28e903f 100644 --- a/phpBB/config/services.yml +++ b/phpBB/config/services.yml @@ -97,14 +97,12 @@ services: notification_manager: class: phpbb_notification_manager arguments: - - @container + - @notification.type_collection + - @notification.method_collection + - @service_container + - @user_loader - @dbal.conn - - @cache.driver - - @template - - @ext.manager - @user - - @auth - - @config - %core.root_path% - %core.php_ext% - %tables.notifications% @@ -151,3 +149,11 @@ services: user: class: phpbb_user + + user_loader: + class: phpbb_user_loader + arguments: + - @dbal.conn + - %core.root_path% + - %core.php_ext% + - %tables.users% diff --git a/phpBB/config/tables.yml b/phpBB/config/tables.yml index 8791c5e89b..528470d6ca 100644 --- a/phpBB/config/tables.yml +++ b/phpBB/config/tables.yml @@ -3,3 +3,4 @@ parameters: tables.ext: %core.table_prefix%ext tables.notifications: %core.table_prefix%notifications tables.user_notifications: %core.table_prefix%user_notifications + tables.users: %core.table_prefix%users diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 4e26d2c642..283ed4a657 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -1331,12 +1331,12 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $ // Mark all topic notifications read for this user $phpbb_notifications->mark_notifications_read(array( - 'phpbb_notification_type_topic', - 'phpbb_notification_type_quote', - 'phpbb_notification_type_bookmark', - 'phpbb_notification_type_post', - 'phpbb_notification_type_approve_topic', - 'phpbb_notification_type_approve_post', + 'topic', + 'quote', + 'bookmark', + 'post', + 'approve_topic', + 'approve_post', ), false, $user->data['user_id'], $post_time); if ($config['load_db_lastread'] && $user->data['is_registered']) @@ -1394,8 +1394,8 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $ } $phpbb_notifications->mark_notifications_read_by_parent(array( - 'phpbb_notification_type_topic', - 'phpbb_notification_type_approve_topic', + 'topic', + 'approve_topic', ), $forum_id, $user->data['user_id'], $post_time); // Mark all post/quote notifications read for this user in this forum @@ -1411,10 +1411,10 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $ $db->sql_freeresult($result); $phpbb_notifications->mark_notifications_read_by_parent(array( - 'phpbb_notification_type_quote', - 'phpbb_notification_type_bookmark', - 'phpbb_notification_type_post', - 'phpbb_notification_type_approve_post', + 'quote', + 'bookmark', + 'post', + 'approve_post', ), $topic_ids, $user->data['user_id'], $post_time); // Add 0 to forums array to mark global announcements correctly @@ -1516,14 +1516,14 @@ function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0, $ // Mark post notifications read for this user in this topic $phpbb_notifications->mark_notifications_read(array( - 'phpbb_notification_type_topic', - 'phpbb_notification_type_approve_topic', + 'topic', + 'approve_topic', ), $topic_id, $user->data['user_id'], $post_time); $phpbb_notifications->mark_notifications_read_by_parent(array( - 'phpbb_notification_type_quote', - 'phpbb_notification_type_bookmark', - 'phpbb_notification_type_post', - 'phpbb_notification_type_approve_post', + 'quote', + 'bookmark', + 'post', + 'approve_post', ), $topic_id, $user->data['user_id'], $post_time); if ($config['load_db_lastread'] && $user->data['is_registered']) diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index fdae1905a0..e15bf12279 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -717,9 +717,9 @@ function delete_topics($where_type, $where_ids, $auto_sync = true, $post_count_s } $phpbb_notifications->delete_notifications(array( - 'phpbb_notification_type_topic', - 'phpbb_notification_type_approve_topic', - 'phpbb_notification_type_topic_in_queue', + 'topic', + 'approve_topic', + 'topic_in_queue', ), $topic_ids); return $return; @@ -901,11 +901,11 @@ function delete_posts($where_type, $where_ids, $auto_sync = true, $posted_sync = } $phpbb_notifications->delete_notifications(array( - 'phpbb_notification_type_quote', - 'phpbb_notification_type_bookmark', - 'phpbb_notification_type_post', - 'phpbb_notification_type_approve_post', - 'phpbb_notification_type_post_in_queue', + 'quote', + 'bookmark', + 'post', + 'approve_post', + 'post_in_queue', ), $post_ids); return sizeof($post_ids); diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index 4df199d72d..8ba1fed6a7 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -2237,17 +2237,17 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u { case 'post': $phpbb_notifications->add_notifications(array( - 'phpbb_notification_type_quote', - 'phpbb_notification_type_topic', + 'quote', + 'topic', ), $notification_data); break; case 'reply': case 'quote': $phpbb_notifications->add_notifications(array( - 'phpbb_notification_type_quote', - 'phpbb_notification_type_bookmark', - 'phpbb_notification_type_post', + 'quote', + 'bookmark', + 'post', ), $notification_data); break; @@ -2256,10 +2256,10 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u case 'edit': case 'edit_last_post': $phpbb_notifications->update_notifications(array( - 'phpbb_notification_type_quote', - 'phpbb_notification_type_bookmark', - 'phpbb_notification_type_topic', - 'phpbb_notification_type_post', + 'quote', + 'bookmark', + 'topic', + 'post', ), $notification_data); break; } @@ -2269,23 +2269,23 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u switch ($mode) { case 'post': - $phpbb_notifications->add_notifications('phpbb_notification_type_topic_in_queue', $notification_data); + $phpbb_notifications->add_notifications('topic_in_queue', $notification_data); break; case 'reply': case 'quote': - $phpbb_notifications->add_notifications('phpbb_notification_type_post_in_queue', $notification_data); + $phpbb_notifications->add_notifications('post_in_queue', $notification_data); break; case 'edit_topic': case 'edit_first_post': case 'edit': case 'edit_last_post': - $phpbb_notifications->delete_notifications('phpbb_notification_type_topic', $data['topic_id']); + $phpbb_notifications->delete_notifications('topic', $data['topic_id']); $phpbb_notifications->delete_notifications(array( - 'phpbb_notification_type_quote', - 'phpbb_notification_type_bookmark', - 'phpbb_notification_type_post', + 'quote', + 'bookmark', + 'post', ), $data['post_id']); break; } diff --git a/phpBB/includes/functions_privmsgs.php b/phpBB/includes/functions_privmsgs.php index 54e8ced679..ae8ffbe90e 100644 --- a/phpBB/includes/functions_privmsgs.php +++ b/phpBB/includes/functions_privmsgs.php @@ -878,7 +878,7 @@ function update_unread_status($unread, $msg_id, $user_id, $folder_id) global $db, $user, $phpbb_notifications; - $phpbb_notifications->mark_notifications_read('phpbb_notification_type_pm', $msg_id, $user_id); + $phpbb_notifications->mark_notifications_read('pm', $msg_id, $user_id); $sql = 'UPDATE ' . PRIVMSGS_TO_TABLE . " SET pm_unread = 0 @@ -1096,7 +1096,7 @@ function delete_pm($user_id, $msg_ids, $folder_id) $user->data['user_unread_privmsg'] -= $num_unread; } - $phpbb_notifications->delete_notifications('phpbb_notification_type_pm', array_keys($delete_rows)); + $phpbb_notifications->delete_notifications('pm', array_keys($delete_rows)); // Now we have to check which messages we can delete completely $sql = 'SELECT msg_id @@ -1277,7 +1277,7 @@ function phpbb_delete_users_pms($user_ids) AND ' . $db->sql_in_set('msg_id', $delivered_msg); $db->sql_query($sql); - $phpbb_notifications->delete_notifications('phpbb_notification_type_pm', $delivered_msg); + $phpbb_notifications->delete_notifications('pm', $delivered_msg); } if (!empty($undelivered_msg)) @@ -1290,7 +1290,7 @@ function phpbb_delete_users_pms($user_ids) WHERE ' . $db->sql_in_set('msg_id', $undelivered_msg); $db->sql_query($sql); - $phpbb_notifications->delete_notifications('phpbb_notification_type_pm', $undelivered_msg); + $phpbb_notifications->delete_notifications('pm', $undelivered_msg); } } @@ -1334,7 +1334,7 @@ function phpbb_delete_users_pms($user_ids) WHERE ' . $db->sql_in_set('msg_id', $delete_ids); $db->sql_query($sql); - $phpbb_notifications->delete_notifications('phpbb_notification_type_pm', $delete_ids); + $phpbb_notifications->delete_notifications('pm', $delete_ids); } } @@ -1879,11 +1879,11 @@ function submit_pm($mode, $subject, &$data, $put_in_outbox = true) if ($mode == 'edit') { - $phpbb_notifications->update_notifications('phpbb_notification_type_pm', $pm_data); + $phpbb_notifications->update_notifications('pm', $pm_data); } else { - $phpbb_notifications->add_notifications('phpbb_notification_type_pm', $pm_data); + $phpbb_notifications->add_notifications('pm', $pm_data); } return $data['msg_id']; diff --git a/phpBB/includes/mcp/mcp_pm_reports.php b/phpBB/includes/mcp/mcp_pm_reports.php index 2a52a0b4fd..4ba1b2fd0c 100644 --- a/phpBB/includes/mcp/mcp_pm_reports.php +++ b/phpBB/includes/mcp/mcp_pm_reports.php @@ -90,7 +90,7 @@ class mcp_pm_reports trigger_error('NO_REPORT'); } - $phpbb_notifications->mark_notifications_read_by_parent('phpbb_notification_type_report_pm', $report_id, $user->data['user_id']); + $phpbb_notifications->mark_notifications_read_by_parent('report_pm', $report_id, $user->data['user_id']); $pm_id = $report['pm_id']; $report_id = $report['report_id']; diff --git a/phpBB/includes/mcp/mcp_queue.php b/phpBB/includes/mcp/mcp_queue.php index f13ce914bf..4a3d443006 100644 --- a/phpBB/includes/mcp/mcp_queue.php +++ b/phpBB/includes/mcp/mcp_queue.php @@ -86,7 +86,7 @@ class mcp_queue { $post_id = (int) $topic_info[$topic_id]['topic_first_post_id']; - $phpbb_notifications->mark_notifications_read('phpbb_notification_type_topic_in_queue', $topic_id, $user->data['user_id']); + $phpbb_notifications->mark_notifications_read('topic_in_queue', $topic_id, $user->data['user_id']); } else { @@ -94,7 +94,7 @@ class mcp_queue } } - $phpbb_notifications->mark_notifications_read('phpbb_notification_type_post_in_queue', $post_id, $user->data['user_id']); + $phpbb_notifications->mark_notifications_read('post_in_queue', $post_id, $user->data['user_id']); $post_info = get_post_data(array($post_id), 'm_approve', true); @@ -610,28 +610,28 @@ function approve_post($post_id_list, $id, $mode) { if ($post_id == $post_data['topic_first_post_id'] && $post_id == $post_data['topic_last_post_id']) { - $phpbb_notifications->delete_notifications('phpbb_notification_type_topic_in_queue', $post_data['topic_id']); + $phpbb_notifications->delete_notifications('topic_in_queue', $post_data['topic_id']); - $phpbb_notifications->add_notifications('phpbb_notification_type_topic', $post_data); + $phpbb_notifications->add_notifications('topic', $post_data); if ($notify_poster) { - $phpbb_notifications->add_notifications('phpbb_notification_type_approve_topic', $post_data); + $phpbb_notifications->add_notifications('approve_topic', $post_data); } } else { - $phpbb_notifications->delete_notifications('phpbb_notification_type_post_in_queue', $post_id); + $phpbb_notifications->delete_notifications('post_in_queue', $post_id); $phpbb_notifications->add_notifications(array( - 'phpbb_notification_type_quote', - 'phpbb_notification_type_bookmark', - 'phpbb_notification_type_post', + 'quote', + 'bookmark', + 'post', ), $post_data); if ($notify_poster) { - $phpbb_notifications->add_notifications('phpbb_notification_type_approve_post', $post_data); + $phpbb_notifications->add_notifications('approve_post', $post_data); } } } @@ -859,11 +859,11 @@ function disapprove_post($post_id_list, $id, $mode) { if ($post_id == $post_data['topic_first_post_id'] && $post_id == $post_data['topic_last_post_id']) { - $phpbb_notifications->delete_notifications('phpbb_notification_type_topic_in_queue', $post_data['topic_id']); + $phpbb_notifications->delete_notifications('topic_in_queue', $post_data['topic_id']); } else { - $phpbb_notifications->delete_notifications('phpbb_notification_type_post_in_queue', $post_id); + $phpbb_notifications->delete_notifications('post_in_queue', $post_id); } } @@ -909,14 +909,14 @@ function disapprove_post($post_id_list, $id, $mode) { if ($notify_poster) { - $phpbb_notifications->add_notifications('phpbb_notification_type_disapprove_topic', $post_data); + $phpbb_notifications->add_notifications('disapprove_topic', $post_data); } } else { if ($notify_poster) { - $phpbb_notifications->add_notifications('phpbb_notification_type_disapprove_post', $post_data); + $phpbb_notifications->add_notifications('disapprove_post', $post_data); } } } diff --git a/phpBB/includes/mcp/mcp_reports.php b/phpBB/includes/mcp/mcp_reports.php index 41cdbc75d6..85723ab3f7 100644 --- a/phpBB/includes/mcp/mcp_reports.php +++ b/phpBB/includes/mcp/mcp_reports.php @@ -88,7 +88,7 @@ class mcp_reports trigger_error('NO_REPORT'); } - $phpbb_notifications->mark_notifications_read('phpbb_notification_type_report_post', $post_id, $user->data['user_id']); + $phpbb_notifications->mark_notifications_read('report_post', $post_id, $user->data['user_id']); if (!$report_id && $report['report_closed']) { @@ -647,20 +647,20 @@ function close_report($report_id_list, $mode, $action, $pm = false) if ($pm) { - $phpbb_notifications->add_notifications('phpbb_notification_type_report_pm_closed', array_merge($post_info[$post_id], array( + $phpbb_notifications->add_notifications('report_pm_closed', array_merge($post_info[$post_id], array( 'reporter' => $reporter['user_id'], 'closer_id' => $user->data['user_id'], 'from_user_id' => $post_info[$post_id]['author_id'], ))); - $phpbb_notifications->delete_notifications('phpbb_notification_type_report_pm', $post_id); + $phpbb_notifications->delete_notifications('report_pm', $post_id); } else { - $phpbb_notifications->add_notifications('phpbb_notification_type_report_post_closed', array_merge($post_info[$post_id], array( + $phpbb_notifications->add_notifications('report_post_closed', array_merge($post_info[$post_id], array( 'reporter' => $reporter['user_id'], 'closer_id' => $user->data['user_id'], ))); - $phpbb_notifications->delete_notifications('phpbb_notification_type_report_post', $post_id); + $phpbb_notifications->delete_notifications('report_post', $post_id); } } } diff --git a/phpBB/includes/notification/manager.php b/phpBB/includes/notification/manager.php index 3d0ada4a43..fbfe388c80 100644 --- a/phpBB/includes/notification/manager.php +++ b/phpBB/includes/notification/manager.php @@ -7,8 +7,6 @@ * */ -use Symfony\Component\DependencyInjection\ContainerBuilder; - /** * @ignore */ @@ -23,30 +21,24 @@ if (!defined('IN_PHPBB')) */ class phpbb_notification_manager { + /** @var array */ + protected $notification_types = null; + + /** @var array */ + protected $notification_methods = null; + /** @var ContainerBuilder */ protected $phpbb_container = null; - + + /** @var phpbb_user_loader */ + protected $user_loader = null; + /** @var dbal */ protected $db = null; - /** @var phpbb_cache_service */ - protected $cache = null; - - /** @var phpbb_template */ - protected $template = null; - - /** @var phpbb_extension_manager */ - protected $extension_manager = null; - /** @var phpbb_user */ protected $user = null; - /** @var phpbb_auth */ - protected $auth = null; - - /** @var phpbb_config */ - protected $config = null; - /** @var string */ protected $phpbb_root_path = null; @@ -59,23 +51,15 @@ class phpbb_notification_manager /** @var string */ protected $user_notifications_table = null; - /** - * Users loaded from the DB - * - * @var array Array of user data that we've loaded from the DB - */ - protected $users = array(); - - public function __construct(ContainerBuilder $phpbb_container, dbal $db, phpbb_cache_driver_interface $cache, phpbb_template $template, phpbb_extension_manager $extension_manager, $user, phpbb_auth $auth, phpbb_config $config, $phpbb_root_path, $php_ext, $notifications_table, $user_notifications_table) + public function __construct($notification_types, $notification_methods, $phpbb_container, phpbb_user_loader $user_loader, dbal $db, $user, $phpbb_root_path, $php_ext, $notifications_table, $user_notifications_table) { + $this->notification_types = $notification_types; + $this->notification_methods = $notification_methods; $this->phpbb_container = $phpbb_container; + + $this->user_loader = $user_loader; $this->db = $db; - $this->cache = $cache; - $this->template = $template; - $this->extension_manager = $extension_manager; $this->user = $user; - $this->auth = $auth; - $this->config = $config; $this->phpbb_root_path = $phpbb_root_path; $this->php_ext = $php_ext; @@ -209,7 +193,7 @@ class phpbb_notification_manager $notifications[$row['notification_id']] = $notification; } - $this->load_users($user_ids); + $this->user_loader->load_users($user_ids); // Allow each type to load its own special items foreach ($load_special as $item_type => $data) @@ -334,7 +318,7 @@ class phpbb_notification_manager return $notified_users; } - $item_id = $item_type::get_item_id($data); + $item_id = $this->get_item_type_class($item_type)->get_item_id($data); // find out which users want to receive this type of notification $notify_users = $this->get_item_type_class($item_type)->find_users_for_notification($data, $options); @@ -363,7 +347,7 @@ class phpbb_notification_manager return; } - $item_id = $item_type::get_item_id($data); + $item_id = $this->get_item_type_class($item_type)->get_item_id($data); $user_ids = array(); $notification_objects = $notification_methods = array(); @@ -428,7 +412,7 @@ class phpbb_notification_manager $this->db->sql_multi_insert($this->notifications_table, $new_rows); // We need to load all of the users to send notifications - $this->load_users($user_ids); + $this->user_loader->load_users($user_ids); // run the queue for each method to send notifications foreach ($notification_methods as $method) @@ -467,7 +451,7 @@ class phpbb_notification_manager } } - $item_id = $item_type::get_item_id($data); + $item_id = $notification->get_item_id($data); $update_array = $notification->create_update_array($data); $sql = 'UPDATE ' . $this->notifications_table . ' @@ -511,7 +495,7 @@ class phpbb_notification_manager { $subscription_types = array(); - foreach ($this->phpbb_container->findTaggedServiceIds('notification.type') as $type_name => $data) + foreach ($this->notification_types as $type_name => $data) { $type = $this->get_item_type_class($type_name); @@ -547,7 +531,7 @@ class phpbb_notification_manager { $subscription_methods = array(); - foreach ($this->phpbb_container->findTaggedServiceIds('notification.method') as $method_name => $data) + foreach ($this->notification_methods as $method_name => $data) { $method = $this->get_method_class($method_name); @@ -758,53 +742,12 @@ class phpbb_notification_manager $this->db->sql_query($sql); } - /** - * Load user helper - * - * @param array $user_ids - */ - public function load_users($user_ids) - { - $user_ids[] = ANONYMOUS; - - // Load the users - $user_ids = array_unique($user_ids); - - // Do not load users we already have in $this->users - $user_ids = array_diff($user_ids, array_keys($this->users)); - - if (sizeof($user_ids)) - { - $sql = 'SELECT * - FROM ' . USERS_TABLE . ' - WHERE ' . $this->db->sql_in_set('user_id', $user_ids); - $result = $this->db->sql_query($sql); - - while ($row = $this->db->sql_fetchrow($result)) - { - $this->users[$row['user_id']] = $row; - } - $this->db->sql_freeresult($result); - } - } - - /** - * Get a user row from our users cache - * - * @param int $user_id - * @return array - */ - public function get_user($user_id) - { - return (isset($this->users[$user_id])) ? $this->users[$user_id] : $this->users[ANONYMOUS]; - } - /** * Helper to get the notifications item type class and set it up */ public function get_item_type_class($item_type, $data = array()) { - $item = $this->phpbb_container->get($item_type); + $item = $this->load_object('notification.type.' . $item_type); $item->set_initial_data($data); @@ -816,6 +759,32 @@ class phpbb_notification_manager */ public function get_method_class($method_name) { - return $this->phpbb_container->get($method_name); + return $this->load_object('notification.method.' . $method_name); + } + + /** + * Helper to load objects (notification types/methods) + */ + protected function load_object($object_name) + { + // Here we cannot just use ContainerBuilder->get(name) + // The reason for this is because get handles services + // which are initialized once and shared. Here we need + // separate new objects because we pass around objects + // that store row data in each object, which would lead + // to over-writing of data if we used get() + + $parameterBag = $this->phpbb_container->getParameterBag(); + $definition = $this->phpbb_container->getDefinition($object_name); + $arguments = $this->phpbb_container->resolveServices( + $parameterBag->unescapeValue($parameterBag->resolveValue($definition->getArguments())) + ); + $r = new \ReflectionClass($parameterBag->resolveValue($definition->getClass())); + + $object = null === $r->getConstructor() ? $r->newInstance() : $r->newInstanceArgs($arguments); + + $object->set_notification_manager($this); + + return $object; } } diff --git a/phpBB/includes/notification/method/base.php b/phpBB/includes/notification/method/base.php index 88ec2674be..3f85d62a09 100644 --- a/phpBB/includes/notification/method/base.php +++ b/phpBB/includes/notification/method/base.php @@ -24,6 +24,9 @@ abstract class phpbb_notification_method_base implements phpbb_notification_meth /** @var phpbb_notification_manager */ protected $notification_manager = null; + /** @var phpbb_user_loader */ + protected $user_loader = null; + /** @var dbal */ protected $db = null; @@ -58,13 +61,11 @@ abstract class phpbb_notification_method_base implements phpbb_notification_meth */ protected $queue = array(); - public function __construct(phpbb_notification_manager $notification_manager, dbal $db, phpbb_cache_driver_interface $cache, phpbb_template $template, phpbb_extension_manager $extension_manager, $user, phpbb_auth $auth, phpbb_config $config, $phpbb_root_path, $php_ext) + public function __construct(phpbb_user_loader $user_loader, dbal $db, phpbb_cache_driver_interface $cache, $user, phpbb_auth $auth, phpbb_config $config, $phpbb_root_path, $php_ext) { - $this->notification_manager = $notification_manager; + $this->user_loader = $user_loader; $this->db = $db; $this->cache = $cache; - $this->template = $template; - $this->extension_manager = $extension_manager; $this->user = $user; $this->auth = $auth; $this->config = $config; @@ -72,6 +73,11 @@ abstract class phpbb_notification_method_base implements phpbb_notification_meth $this->php_ext = $php_ext; } + public function set_notification_manager(phpbb_notification_manager $notification_manager) + { + $this->notification_manager = $notification_manager; + } + /** * Add a notification to the queue * diff --git a/phpBB/includes/notification/method/email.php b/phpBB/includes/notification/method/email.php index 2ff30b177f..429dfda2ba 100644 --- a/phpBB/includes/notification/method/email.php +++ b/phpBB/includes/notification/method/email.php @@ -82,7 +82,7 @@ class phpbb_notification_method_email extends phpbb_notification_method_base $banned_users = phpbb_get_banned_user_ids($user_ids); // Load all the users we need - $this->notification_manager->load_users($user_ids); + $this->user_loader->load_users($user_ids); // Load the messenger if (!class_exists('messenger')) @@ -100,7 +100,7 @@ class phpbb_notification_method_email extends phpbb_notification_method_base continue; } - $user = $this->notification_manager->get_user($notification->user_id); + $user = $this->user_loader->get_user($notification->user_id); if ($user['user_type'] == USER_IGNORE || in_array($notification->user_id, $banned_users)) { diff --git a/phpBB/includes/notification/type/base.php b/phpBB/includes/notification/type/base.php index 419dce3dd0..d596c06167 100644 --- a/phpBB/includes/notification/type/base.php +++ b/phpBB/includes/notification/type/base.php @@ -24,6 +24,9 @@ abstract class phpbb_notification_type_base implements phpbb_notification_type_i /** @var phpbb_notification_manager */ protected $notification_manager = null; + /** @var phpbb_user_loader */ + protected $user_loader = null; + /** @var dbal */ protected $db = null; @@ -33,9 +36,6 @@ abstract class phpbb_notification_type_base implements phpbb_notification_type_i /** @var phpbb_template */ protected $template = null; - /** @var phpbb_extension_manager */ - protected $extension_manager = null; - /** @var phpbb_user */ protected $user = null; @@ -84,13 +84,11 @@ abstract class phpbb_notification_type_base implements phpbb_notification_type_i */ private $data = array(); - public function __construct(phpbb_notification_manager $notification_manager, dbal $db, phpbb_cache_driver_interface $cache, phpbb_template $template, phpbb_extension_manager $extension_manager, $user, phpbb_auth $auth, phpbb_config $config, $phpbb_root_path, $php_ext, $notifications_table, $user_notifications_table) + public function __construct(phpbb_user_loader $user_loader, dbal $db, phpbb_cache_driver_interface $cache, $user, phpbb_auth $auth, phpbb_config $config, $phpbb_root_path, $php_ext, $notifications_table, $user_notifications_table) { - $this->notification_manager = $notification_manager; + $this->user_loader = $user_loader; $this->db = $db; $this->cache = $cache; - $this->template = $template; - $this->extension_manager = $extension_manager; $this->user = $user; $this->auth = $auth; $this->config = $config; @@ -102,6 +100,11 @@ abstract class phpbb_notification_type_base implements phpbb_notification_type_i $this->user_notifications_table = $user_notifications_table; } + public function set_notification_manager(phpbb_notification_manager $notification_manager) + { + $this->notification_manager = $notification_manager; + } + /** * Set initial data from the database * @@ -357,7 +360,7 @@ abstract class phpbb_notification_type_base implements phpbb_notification_type_i $rowset = $resulting_user_ids = array(); $sql = 'SELECT user_id, method, notify - FROM ' . USER_NOTIFICATIONS_TABLE . ' + FROM ' . $this->user_notifications_table . ' WHERE ' . $this->db->sql_in_set('user_id', $user_ids) . " AND item_type = '" . $this->db->sql_escape($options['item_type']) . "' AND item_id = " . (int) $options['item_id']; @@ -394,24 +397,6 @@ abstract class phpbb_notification_type_base implements phpbb_notification_type_i return $rowset; } - /** - * Get avatar helper - * - * @param int $user_id - * @return string - */ - protected function get_user_avatar($user_id) - { - $user = $this->notification_manager->get_user($user_id); - - if (!function_exists('get_user_avatar')) - { - include($this->phpbb_root_path . 'includes/functions_display.' . $this->php_ext); - } - - return get_user_avatar($user['user_avatar'], $user['user_avatar_type'], $user['user_avatar_width'], $user['user_avatar_height'], $user['username'], false, 'notifications-avatar'); - } - /** * Mark this item read/unread helper * @@ -435,7 +420,7 @@ abstract class phpbb_notification_type_base implements phpbb_notification_type_i return $where; } - $sql = 'UPDATE ' . NOTIFICATIONS_TABLE . ' + $sql = 'UPDATE ' . $this->notifications_table . ' SET unread = ' . (int) $this->unread . ' WHERE ' . $where; $this->db->sql_query($sql); diff --git a/phpBB/includes/notification/type/bookmark.php b/phpBB/includes/notification/type/bookmark.php index a40bbde5e4..a17d8f5db7 100644 --- a/phpBB/includes/notification/type/bookmark.php +++ b/phpBB/includes/notification/type/bookmark.php @@ -102,7 +102,7 @@ class phpbb_notification_type_bookmark extends phpbb_notification_type_post // Try to find the users who already have been notified about replies and have not read the topic since and just update their notifications $update_notifications = array(); $sql = 'SELECT * - FROM ' . NOTIFICATIONS_TABLE . " + FROM ' . $this->notifications_table . " WHERE item_type = '" . $this->get_type() . "' AND item_parent_id = " . (int) self::get_item_parent_id($post) . ' AND unread = 1 @@ -114,7 +114,7 @@ class phpbb_notification_type_bookmark extends phpbb_notification_type_post unset($notify_users[$row['user_id']]); $notification = $this->notification_manager->get_item_type_class($this->get_type(), $row); - $sql = 'UPDATE ' . NOTIFICATIONS_TABLE . ' + $sql = 'UPDATE ' . $this->notifications_table . ' SET ' . $this->db->sql_build_array('UPDATE', $notification->add_responders($post)) . ' WHERE notification_id = ' . $row['notification_id']; $this->db->sql_query($sql); diff --git a/phpBB/includes/notification/type/pm.php b/phpBB/includes/notification/type/pm.php index fbdf351062..1eaeb1a250 100644 --- a/phpBB/includes/notification/type/pm.php +++ b/phpBB/includes/notification/type/pm.php @@ -92,7 +92,7 @@ class phpbb_notification_type_pm extends phpbb_notification_type_base unset($pm['recipients'][$pm['from_user_id']]); - $this->notification_manager->load_users(array_keys($pm['recipients'])); + $this->user_loader->load_users(array_keys($pm['recipients'])); return $this->check_user_notification_options(array_keys($pm['recipients']), $options); } @@ -102,7 +102,7 @@ class phpbb_notification_type_pm extends phpbb_notification_type_base */ public function get_avatar() { - return $this->get_user_avatar($this->get_data('from_user_id')); + return $this->user_loader->get_avatar($this->get_data('from_user_id')); } /** @@ -112,7 +112,7 @@ class phpbb_notification_type_pm extends phpbb_notification_type_base */ public function get_title() { - $user_data = $this->notification_manager->get_user($this->get_data('from_user_id')); + $user_data = $this->user_loader->get_user($this->get_data('from_user_id')); $username = get_username_string('no_profile', $user_data['user_id'], $user_data['username'], $user_data['user_colour']); @@ -136,7 +136,7 @@ class phpbb_notification_type_pm extends phpbb_notification_type_base */ public function get_email_template_variables() { - $user_data = $this->notification_manager->get_user($this->get_data('from_user_id')); + $user_data = $this->user_loader->get_user($this->get_data('from_user_id')); return array( 'AUTHOR_NAME' => htmlspecialchars_decode($user_data['username']), diff --git a/phpBB/includes/notification/type/post.php b/phpBB/includes/notification/type/post.php index a99558efe7..7e06779982 100644 --- a/phpBB/includes/notification/type/post.php +++ b/phpBB/includes/notification/type/post.php @@ -123,7 +123,7 @@ class phpbb_notification_type_post extends phpbb_notification_type_base // Try to find the users who already have been notified about replies and have not read the topic since and just update their notifications $update_notifications = array(); $sql = 'SELECT * - FROM ' . NOTIFICATIONS_TABLE . " + FROM ' . $this->notifications_table . " WHERE item_type = '" . $this->get_type() . "' AND item_parent_id = " . (int) self::get_item_parent_id($post) . ' AND unread = 1 @@ -135,7 +135,7 @@ class phpbb_notification_type_post extends phpbb_notification_type_base unset($notify_users[$row['user_id']]); $notification = $this->notification_manager->get_item_type_class($this->get_type(), $row); - $sql = 'UPDATE ' . NOTIFICATIONS_TABLE . ' + $sql = 'UPDATE ' . $this->notifications_table . ' SET ' . $this->db->sql_build_array('UPDATE', $notification->add_responders($post)) . ' WHERE notification_id = ' . $row['notification_id']; $this->db->sql_query($sql); @@ -150,7 +150,7 @@ class phpbb_notification_type_post extends phpbb_notification_type_base */ public function get_avatar() { - return $this->get_user_avatar($this->get_data('poster_id')); + return $this->user_loader->get_avatar($this->get_data('poster_id')); } /** @@ -181,7 +181,7 @@ class phpbb_notification_type_post extends phpbb_notification_type_base } else { - $user_data = $this->notification_manager->get_user($responder['poster_id']); + $user_data = $this->user_loader->get_user($responder['poster_id']); $usernames[] = get_username_string('no_profile', $user_data['user_id'], $user_data['username'], $user_data['user_colour']); } @@ -217,7 +217,7 @@ class phpbb_notification_type_post extends phpbb_notification_type_base } else { - $user_data = $this->notification_manager->get_user($this->get_data('poster_id')); + $user_data = $this->user_loader->get_user($this->get_data('poster_id')); $username = get_username_string('username', $user_data['user_id'], $user_data['username'], $user_data['user_colour']); } diff --git a/phpBB/includes/notification/type/quote.php b/phpBB/includes/notification/type/quote.php index f45bb1ae7d..1796343a0e 100644 --- a/phpBB/includes/notification/type/quote.php +++ b/phpBB/includes/notification/type/quote.php @@ -121,7 +121,7 @@ class phpbb_notification_type_quote extends phpbb_notification_type_post // Try to find the users who already have been notified about replies and have not read the topic since and just update their notifications $update_notifications = array(); $sql = 'SELECT * - FROM ' . NOTIFICATIONS_TABLE . " + FROM ' . $this->notifications_table . " WHERE item_type = '" . $this->get_type() . "' AND item_parent_id = " . (int) self::get_item_parent_id($post) . ' AND unread = 1 @@ -133,7 +133,7 @@ class phpbb_notification_type_quote extends phpbb_notification_type_post unset($notify_users[$row['user_id']]); $notification = $this->notification_manager->get_item_type_class($this->get_type(), $row); - $sql = 'UPDATE ' . NOTIFICATIONS_TABLE . ' + $sql = 'UPDATE ' . $this->notifications_table . ' SET ' . $this->db->sql_build_array('UPDATE', $notification->add_responders($post)) . ' WHERE notification_id = ' . $row['notification_id']; $this->db->sql_query($sql); @@ -152,7 +152,7 @@ class phpbb_notification_type_quote extends phpbb_notification_type_post { $old_notifications = array(); $sql = 'SELECT user_id - FROM ' . NOTIFICATIONS_TABLE . " + FROM ' . $this->notifications_table . " WHERE item_type = '" . $this->get_type() . "' AND item_id = " . self::get_item_id($post) . ' AND is_enabled = 1'; @@ -182,7 +182,7 @@ class phpbb_notification_type_quote extends phpbb_notification_type_post // Remove the necessary notifications if (!empty($remove_notifications)) { - $sql = 'DELETE FROM ' . NOTIFICATIONS_TABLE . " + $sql = 'DELETE FROM ' . $this->notifications_table . " WHERE item_type = '" . $this->get_type() . "' AND item_id = " . self::get_item_id($post) . ' AND ' . $this->db->sql_in_set('user_id', $remove_notifications); @@ -210,7 +210,7 @@ class phpbb_notification_type_quote extends phpbb_notification_type_post */ public function get_email_template_variables() { - $user_data = $this->notification_manager->get_user($this->get_data('poster_id')); + $user_data = $this->user_loader->get_user($this->get_data('poster_id')); return array_merge(parent::get_email_template_variables(), array( 'AUTHOR_NAME' => htmlspecialchars_decode($user_data['username']), diff --git a/phpBB/includes/notification/type/report_pm.php b/phpBB/includes/notification/type/report_pm.php index 9bdc59a4ef..73e22dc83b 100644 --- a/phpBB/includes/notification/type/report_pm.php +++ b/phpBB/includes/notification/type/report_pm.php @@ -160,7 +160,7 @@ class phpbb_notification_type_report_pm extends phpbb_notification_type_pm { $this->user->add_lang('mcp'); - $user_data = $this->notification_manager->get_user($this->get_data('reporter_id')); + $user_data = $this->user_loader->get_user($this->get_data('reporter_id')); $username = get_username_string('no_profile', $user_data['user_id'], $user_data['username'], $user_data['user_colour']); @@ -197,7 +197,7 @@ class phpbb_notification_type_report_pm extends phpbb_notification_type_pm */ public function get_avatar() { - return $this->get_user_avatar($this->get_data('reporter_id')); + return $this->user_loader->get_avatar($this->get_data('reporter_id')); } /** diff --git a/phpBB/includes/notification/type/report_pm_closed.php b/phpBB/includes/notification/type/report_pm_closed.php index de87c9f760..51e5204304 100644 --- a/phpBB/includes/notification/type/report_pm_closed.php +++ b/phpBB/includes/notification/type/report_pm_closed.php @@ -106,7 +106,7 @@ class phpbb_notification_type_report_pm_closed extends phpbb_notification_type_p */ public function get_title() { - $user_data = $this->notification_manager->get_user($this->get_data('closer_id')); + $user_data = $this->user_loader->get_user($this->get_data('closer_id')); $username = get_username_string('no_profile', $user_data['user_id'], $user_data['username'], $user_data['user_colour']); diff --git a/phpBB/includes/notification/type/report_post.php b/phpBB/includes/notification/type/report_post.php index d80c7b754f..2508644b0b 100644 --- a/phpBB/includes/notification/type/report_post.php +++ b/phpBB/includes/notification/type/report_post.php @@ -127,7 +127,7 @@ class phpbb_notification_type_report_post extends phpbb_notification_type_post_i { $this->user->add_lang('mcp'); - $user_data = $this->notification_manager->get_user($this->get_data('reporter_id')); + $user_data = $this->user_loader->get_user($this->get_data('reporter_id')); $username = get_username_string('no_profile', $user_data['user_id'], $user_data['username'], $user_data['user_colour']); @@ -164,7 +164,7 @@ class phpbb_notification_type_report_post extends phpbb_notification_type_post_i */ public function get_avatar() { - return $this->get_user_avatar($this->get_data('reporter_id')); + return $this->user_loader->get_avatar($this->get_data('reporter_id')); } /** diff --git a/phpBB/includes/notification/type/report_post_closed.php b/phpBB/includes/notification/type/report_post_closed.php index cde0ff85a8..a7016a8f3d 100644 --- a/phpBB/includes/notification/type/report_post_closed.php +++ b/phpBB/includes/notification/type/report_post_closed.php @@ -106,7 +106,7 @@ class phpbb_notification_type_report_post_closed extends phpbb_notification_type */ public function get_title() { - $user_data = $this->notification_manager->get_user($this->get_data('closer_id')); + $user_data = $this->user_loader->get_user($this->get_data('closer_id')); $username = get_username_string('no_profile', $user_data['user_id'], $user_data['username'], $user_data['user_colour']); @@ -122,7 +122,7 @@ class phpbb_notification_type_report_post_closed extends phpbb_notification_type */ public function get_avatar() { - return $this->get_user_avatar($this->get_data('closer_id')); + return $this->user_loader->get_avatar($this->get_data('closer_id')); } /** diff --git a/phpBB/includes/notification/type/topic.php b/phpBB/includes/notification/type/topic.php index 4eb03194f5..6e9347d4a8 100644 --- a/phpBB/includes/notification/type/topic.php +++ b/phpBB/includes/notification/type/topic.php @@ -126,7 +126,7 @@ class phpbb_notification_type_topic extends phpbb_notification_type_base */ public function get_avatar() { - return $this->get_user_avatar($this->get_data('poster_id')); + return $this->user_loader->get_avatar($this->get_data('poster_id')); } /** @@ -142,7 +142,7 @@ class phpbb_notification_type_topic extends phpbb_notification_type_base } else { - $user_data = $this->notification_manager->get_user($this->get_data('poster_id')); + $user_data = $this->user_loader->get_user($this->get_data('poster_id')); $username = get_username_string('no_profile', $user_data['user_id'], $user_data['username'], $user_data['user_colour']); } @@ -178,7 +178,7 @@ class phpbb_notification_type_topic extends phpbb_notification_type_base } else { - $user_data = $this->notification_manager->get_user($this->get_data('poster_id')); + $user_data = $this->user_loader->get_user($this->get_data('poster_id')); $username = get_username_string('username', $user_data['user_id'], $user_data['username'], $user_data['user_colour']); } diff --git a/phpBB/includes/user_loader.php b/phpBB/includes/user_loader.php new file mode 100644 index 0000000000..a530f21f75 --- /dev/null +++ b/phpBB/includes/user_loader.php @@ -0,0 +1,118 @@ +db = $db; + + $this->phpbb_root_path = $phpbb_root_path; + $this->php_ext = $php_ext; + + $this->users_table = $users_table; + } + + /** + * Load user helper + * + * @param array $user_ids + */ + public function load_users(array $user_ids) + { + $user_ids[] = ANONYMOUS; + + // Load the users + $user_ids = array_unique($user_ids); + + // Do not load users we already have in $this->users + $user_ids = array_diff($user_ids, array_keys($this->users)); + + if (sizeof($user_ids)) + { + $sql = 'SELECT * + FROM ' . $this->users_table . ' + WHERE ' . $this->db->sql_in_set('user_id', $user_ids); + $result = $this->db->sql_query($sql); + + while ($row = $this->db->sql_fetchrow($result)) + { + $this->users[$row['user_id']] = $row; + } + $this->db->sql_freeresult($result); + } + } + + /** + * Get a user row from our users cache + * + * @param int $user_id + * @return array|bool Row from the database of the user or Anonymous if the user wasn't loaded/does not exist + * or bool False if the anonymous user was not loaded + */ + public function get_user($user_id) + { + return (isset($this->users[$user_id])) ? $this->users[$user_id] : (isset($this->users[ANONYMOUS]) ? $this->users[ANONYMOUS] : false); + } + + /** + * Get avatar + * + * @param int $user_id + * @return string + */ + public function get_avatar($user_id) + { + if (!($user = $this->get_user($user_id))) + { + return ''; + } + + if (!function_exists('get_user_avatar')) + { + include($this->phpbb_root_path . 'includes/functions_display.' . $this->php_ext); + } + + return get_user_avatar($user['user_avatar'], $user['user_avatar_type'], $user['user_avatar_width'], $user['user_avatar_height']); + } +} \ No newline at end of file diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index ab48da059d..768280ec7e 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -2814,19 +2814,19 @@ function change_database_data(&$no_updates, $version) $convert_notifications = array( array( 'check' => ($config['allow_topic_notify']), - 'item_type' => 'phpbb_notification_type_post', + 'item_type' => 'post', ), array( 'check' => ($config['allow_forum_notify']), - 'item_type' => 'phpbb_notification_type_topic', + 'item_type' => 'topic', ), array( 'check' => ($config['allow_bookmarks']), - 'item_type' => 'phpbb_notification_type_bookmark', + 'item_type' => 'bookmark', ), array( 'check' => ($config['allow_privmsg']), - 'item_type' => 'phpbb_notification_type_pm', + 'item_type' => 'pm', ), ); @@ -2853,7 +2853,7 @@ function change_database_data(&$no_updates, $version) 'item_type' => $convert_data['item_type'], 'item_id' => 0, 'user_id' => $row['user_id'], - 'method' => 'phpbb_notification_method_email', + 'method' => 'email', )), $errored, $error_ary); } @@ -2863,7 +2863,7 @@ function change_database_data(&$no_updates, $version) 'item_type' => $convert_data['item_type'], 'item_id' => 0, 'user_id' => $row['user_id'], - 'method' => 'phpbb_notification_method_jabber', + 'method' => 'jabber', )), $errored, $error_ary); } } diff --git a/phpBB/report.php b/phpBB/report.php index 95043a6978..07cec7afbc 100644 --- a/phpBB/report.php +++ b/phpBB/report.php @@ -191,7 +191,7 @@ if ($submit && $reason_id) $lang_return = $user->lang['RETURN_TOPIC']; $lang_success = $user->lang['POST_REPORTED_SUCCESS']; - $phpbb_notifications->add_notifications('phpbb_notification_type_report_post', array_merge($report_data, $row, $forum_data, array( + $phpbb_notifications->add_notifications('report_post', array_merge($report_data, $row, $forum_data, array( 'report_text' => $report_text, ))); } @@ -221,7 +221,7 @@ if ($submit && $reason_id) $lang_return = $user->lang['RETURN_PM']; $lang_success = $user->lang['PM_REPORTED_SUCCESS']; - $phpbb_notifications->add_notifications('phpbb_notification_type_report_pm', array_merge($report_data, $row, array( + $phpbb_notifications->add_notifications('report_pm', array_merge($report_data, $row, array( 'report_text' => $report_text, 'from_user_id' => $report_data['author_id'], 'report_id' => $report_id, diff --git a/tests/mock/container_builder.php b/tests/mock/container_builder.php index 8a81dd72d1..734d3e1741 100644 --- a/tests/mock/container_builder.php +++ b/tests/mock/container_builder.php @@ -11,6 +11,9 @@ use Symfony\Component\DependencyInjection\ScopeInterface; class phpbb_mock_container_builder implements ContainerInterface { + protected $services = array(); + protected $parameters = array(); + /** * Sets a service. * @@ -22,6 +25,7 @@ class phpbb_mock_container_builder implements ContainerInterface */ public function set($id, $service, $scope = self::SCOPE_CONTAINER) { + $this->services[$id] = $service; } /** @@ -42,6 +46,12 @@ class phpbb_mock_container_builder implements ContainerInterface */ public function get($id, $invalidBehavior = self::EXCEPTION_ON_INVALID_REFERENCE) { + if ($this->has($id)) + { + return $this->services[$id]; + } + + throw new Exception('Could not find service: ' . $id); } /** @@ -55,6 +65,7 @@ class phpbb_mock_container_builder implements ContainerInterface */ public function has($id) { + return isset($this->services[$id]); } /** @@ -70,6 +81,12 @@ class phpbb_mock_container_builder implements ContainerInterface */ public function getParameter($name) { + if ($this->hasParameter($name)) + { + return $this->parameters[$name]; + } + + throw new Exception('Could not find parameter: ' . $name); } /** @@ -83,6 +100,7 @@ class phpbb_mock_container_builder implements ContainerInterface */ public function hasParameter($name) { + return isset($this->parameters[$name]); } /** @@ -95,6 +113,7 @@ class phpbb_mock_container_builder implements ContainerInterface */ public function setParameter($name, $value) { + $this->parameters[$name] = $value; } /** diff --git a/tests/mock/notifications_notification_manager.php b/tests/mock/notifications_notification_manager.php new file mode 100644 index 0000000000..81f24e67c0 --- /dev/null +++ b/tests/mock/notifications_notification_manager.php @@ -0,0 +1,69 @@ +$name = $value; + } + + // Extra dependencies for get_*_class functions + protected $auth = null; + protected $cache = null; + protected $config = null; + public function setDependencies($auth, $cache, $config) + { + $this->auth = $auth; + $this->cache = $cache; + $this->config = $config; + } + + /** + * Helper to get the notifications item type class and set it up + */ + public function get_item_type_class($item_type, $data = array()) + { + $item_type = 'phpbb_notification_type_' . $item_type; + + $item = new $item_type($this->user_loader, $this->db, $this->cache, $this->user, $this->auth, $this->config, $this->phpbb_root_path, $this->php_ext, $this->notifications_table, $this->user_notifications_table); + + $item->set_notification_manager($this); + + $item->set_initial_data($data); + + return $item; + } + + /** + * Helper to get the notifications method class and set it up + */ + public function get_method_class($method_name) + { + $method_name = 'phpbb_notification_method_' . $method_name; + + $method = new $method_name($this->user_loader, $this->db, $this->cache, $this->user, $this->auth, $this->config, $this->phpbb_root_path, $this->php_ext, $this->notifications_table, $this->user_notifications_table); + + $method->set_notification_manager($this); + + return $method; + } +} diff --git a/tests/notification/ext/test/notification/type/test.php b/tests/notification/ext/test/notification/type/test.php index 34149484df..45670e1c2d 100644 --- a/tests/notification/ext/test/notification/type/test.php +++ b/tests/notification/ext/test/notification/type/test.php @@ -15,8 +15,13 @@ if (!defined('IN_PHPBB')) exit; } -class phpbb_ext_test_notification_type_test extends phpbb_notification_type_base +class phpbb_notification_type_test extends phpbb_notification_type_base { + public function get_type() + { + return 'test'; + } + public static function get_item_id($post) { return (int) $post['post_id']; diff --git a/tests/notification/notification.php b/tests/notification/notification.php index 9c88ad892e..8fa77ff651 100644 --- a/tests/notification/notification.php +++ b/tests/notification/notification.php @@ -6,10 +6,10 @@ * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 * */ - +//calls: [ [set_notification_manager, [@notification_manager]] ] class phpbb_notification_test extends phpbb_database_test_case { - protected $notifications; + protected $notifications, $db, $container, $user, $config, $auth, $cache; public function getDataSet() { @@ -30,34 +30,69 @@ class phpbb_notification_test extends phpbb_database_test_case include_once(__DIR__ . '/ext/test/notification/type/test.' . $phpEx); - $db = $this->new_dbal(); - $config = new phpbb_config(array( + $db = $this->db = $this->new_dbal(); + $this->config = new phpbb_config(array( 'allow_privmsg' => true, 'allow_bookmarks' => true, 'allow_topic_notify' => true, 'allow_forum_notify' => true, )); - $user = new phpbb_mock_user(); + $this->user = new phpbb_mock_user(); + $this->user_loader = new phpbb_user_loader($this->db, 'phpbb_users'); + $this->auth = new phpbb_mock_notifications_auth(); + $this->cache = new phpbb_mock_cache(); - $this->notifications = new phpbb_notification_manager( - $db, - new phpbb_mock_cache(), - new phpbb_template($phpbb_root_path, $phpEx, $config, $user, new phpbb_style_resource_locator()), - new phpbb_mock_extension_manager($phpbb_root_path, - array( - 'test' => array( - 'ext_name' => 'test', - 'ext_active' => '1', - 'ext_path' => 'ext/test/', - ), - ) - ), - $user, - new phpbb_mock_notifications_auth(), - $config, + $this->container = new phpbb_mock_container_builder(); + + $this->notifications = new phpbb_mock_notifications_notification_manager( + array(), + array(), + $this->container, + $this->user_loader, + $this->db, + $this->user, $phpbb_root_path, - $phpEx + $phpEx, + 'phpbb_notifications', + 'phpbb_user_notifications' ); + + $this->notifications->setDependencies($this->auth, $this->cache, $this->config); + + $types = array(); + foreach (array( + 'test', + 'approve_post', + 'approve_topic', + 'bookmark', + 'disapprove_post', + 'disapprove_topic', + 'pm', + 'post', + 'post_in_queue', + 'quote', + 'report_pm', + 'report_pm_closed', + 'report_post', + 'report_post_closed', + 'topic', + 'topic_in_queue', + ) as $type) + { + $class = $this->build_type('phpbb_notification_type_' . $type); + + $types[$type] = $class; + $this->container->set('notification.type.' . $type, $class); + } + + $this->notifications->set_var('notification_types', $types); + } + + protected function build_type($type) + { + global $phpbb_root_path, $phpEx; + + return new $type($this->user_loader, $this->db, $this->cache, $this->user, $this->auth, $this->config, $phpbb_root_path, $phpEx, 'phpbb_notifications', 'phpbb_user_notifications'); } public function test_get_subscription_types() @@ -67,12 +102,12 @@ class phpbb_notification_test extends phpbb_database_test_case $this->assertArrayHasKey('NOTIFICATION_GROUP_MISCELLANEOUS', $subscription_types); $this->assertArrayHasKey('NOTIFICATION_GROUP_POSTING', $subscription_types); - $this->assertArrayHasKey('phpbb_notification_type_bookmark', $subscription_types['NOTIFICATION_GROUP_POSTING']); - $this->assertArrayHasKey('phpbb_notification_type_post', $subscription_types['NOTIFICATION_GROUP_POSTING']); - $this->assertArrayHasKey('phpbb_notification_type_quote', $subscription_types['NOTIFICATION_GROUP_POSTING']); - $this->assertArrayHasKey('phpbb_notification_type_topic', $subscription_types['NOTIFICATION_GROUP_POSTING']); + $this->assertArrayHasKey('bookmark', $subscription_types['NOTIFICATION_GROUP_POSTING']); + $this->assertArrayHasKey('post', $subscription_types['NOTIFICATION_GROUP_POSTING']); + $this->assertArrayHasKey('quote', $subscription_types['NOTIFICATION_GROUP_POSTING']); + $this->assertArrayHasKey('topic', $subscription_types['NOTIFICATION_GROUP_POSTING']); - $this->assertArrayHasKey('phpbb_notification_type_pm', $subscription_types['NOTIFICATION_GROUP_MISCELLANEOUS']); + $this->assertArrayHasKey('pm', $subscription_types['NOTIFICATION_GROUP_MISCELLANEOUS']); //get_subscription_types //get_subscription_methods @@ -80,13 +115,13 @@ class phpbb_notification_test extends phpbb_database_test_case public function test_subscriptions() { - $this->notifications->delete_subscription('phpbb_notification_type_post', 0, '', 2); + $this->notifications->delete_subscription('post', 0, '', 2); - $this->assertArrayNotHasKey('phpbb_notification_type_post', $this->notifications->get_global_subscriptions(2)); + $this->assertArrayNotHasKey('post', $this->notifications->get_global_subscriptions(2)); - $this->notifications->add_subscription('phpbb_notification_type_post', 0, '', 2); + $this->notifications->add_subscription('post', 0, '', 2); - $this->assertArrayHasKey('phpbb_notification_type_post', $this->notifications->get_global_subscriptions(2)); + $this->assertArrayHasKey('post', $this->notifications->get_global_subscriptions(2)); } public function test_notifications() @@ -108,25 +143,25 @@ class phpbb_notification_test extends phpbb_database_test_case 'count_unread' => true, ))); - $this->notifications->add_notifications('phpbb_ext_test_notification_type_test', array( + $this->notifications->add_notifications('test', array( 'post_id' => '1', 'topic_id' => '1', 'post_time' => 1349413321, )); - $this->notifications->add_notifications('phpbb_ext_test_notification_type_test', array( + $this->notifications->add_notifications('test', array( 'post_id' => '2', 'topic_id' => '2', 'post_time' => 1349413322, )); - $this->notifications->add_notifications('phpbb_ext_test_notification_type_test', array( + $this->notifications->add_notifications('test', array( 'post_id' => '3', 'topic_id' => '2', 'post_time' => 1349413323, )); - $this->notifications->add_notifications(array('phpbb_notification_type_quote', 'phpbb_notification_type_bookmark', 'phpbb_notification_type_post', 'phpbb_ext_test_notification_type_test'), array( + $this->notifications->add_notifications(array('quote', 'bookmark', 'post', 'test'), array( 'post_id' => '4', 'topic_id' => '2', 'post_time' => 1349413324, @@ -142,7 +177,7 @@ class phpbb_notification_test extends phpbb_database_test_case 'user_id' => 0, ))); - $this->notifications->add_notifications(array('phpbb_notification_type_quote', 'phpbb_notification_type_bookmark', 'phpbb_notification_type_post', 'phpbb_ext_test_notification_type_test'), array( + $this->notifications->add_notifications(array('quote', 'bookmark', 'post', 'test'), array( 'post_id' => '5', 'topic_id' => '2', 'post_time' => 1349413325, @@ -153,9 +188,9 @@ class phpbb_notification_test extends phpbb_database_test_case 'forum_name' => 'Your first forum', )); - $this->notifications->delete_subscription('phpbb_ext_test_notification_type_test'); + $this->notifications->delete_subscription('test'); - $this->notifications->add_notifications('phpbb_ext_test_notification_type_test', array( + $this->notifications->add_notifications('test', array( 'post_id' => '6', 'topic_id' => '2', 'post_time' => 1349413326, @@ -167,7 +202,7 @@ class phpbb_notification_test extends phpbb_database_test_case $expected = array( 1 => array( - 'item_type' => 'phpbb_ext_test_notification_type_test', + 'item_type' => 'test', 'item_id' => 1, 'item_parent_id' => 1, 'user_id' => 0, @@ -176,7 +211,7 @@ class phpbb_notification_test extends phpbb_database_test_case 'data' => array(), ), 2 => array( - 'item_type' => 'phpbb_ext_test_notification_type_test', + 'item_type' => 'test', 'item_id' => 2, 'item_parent_id' => 2, 'user_id' => 0, @@ -185,7 +220,7 @@ class phpbb_notification_test extends phpbb_database_test_case 'data' => array(), ), 3 => array( - 'item_type' => 'phpbb_ext_test_notification_type_test', + 'item_type' => 'test', 'item_id' => 3, 'item_parent_id' => 2, 'user_id' => 0, @@ -194,7 +229,7 @@ class phpbb_notification_test extends phpbb_database_test_case 'data' => array(), ), 4 => array( - 'item_type' => 'phpbb_notification_type_post', + 'item_type' => 'post', 'item_id' => 4, 'item_parent_id' => 2, 'user_id' => 0, @@ -210,7 +245,7 @@ class phpbb_notification_test extends phpbb_database_test_case ), ), 5 => array( - 'item_type' => 'phpbb_notification_type_bookmark', + 'item_type' => 'bookmark', 'item_id' => 5, 'item_parent_id' => 2, 'user_id' => 0, @@ -245,19 +280,19 @@ class phpbb_notification_test extends phpbb_database_test_case // Now test updating ------------------------------- - $this->notifications->update_notifications('phpbb_ext_test_notification_type_test', array( + $this->notifications->update_notifications('test', array( 'post_id' => '1', 'topic_id' => '2', // change parent_id 'post_time' => 1349413321, )); - $this->notifications->update_notifications('phpbb_ext_test_notification_type_test', array( + $this->notifications->update_notifications('test', array( 'post_id' => '3', 'topic_id' => '2', 'post_time' => 1234, // change time )); - $this->notifications->update_notifications(array('phpbb_notification_type_quote', 'phpbb_notification_type_bookmark', 'phpbb_notification_type_post', 'phpbb_ext_test_notification_type_test'), array( + $this->notifications->update_notifications(array('quote', 'bookmark', 'post', 'test'), array( 'post_id' => '5', 'topic_id' => '2', 'poster_id' => 2, @@ -273,7 +308,7 @@ class phpbb_notification_test extends phpbb_database_test_case $expected = array( 1 => array( - 'item_type' => 'phpbb_ext_test_notification_type_test', + 'item_type' => 'test', 'item_id' => 1, 'item_parent_id' => 2, 'user_id' => 0, @@ -282,7 +317,7 @@ class phpbb_notification_test extends phpbb_database_test_case 'data' => array(), ), 2 => array( - 'item_type' => 'phpbb_ext_test_notification_type_test', + 'item_type' => 'test', 'item_id' => 2, 'item_parent_id' => 2, 'user_id' => 0, @@ -291,7 +326,7 @@ class phpbb_notification_test extends phpbb_database_test_case 'data' => array(), ), 3 => array( - 'item_type' => 'phpbb_ext_test_notification_type_test', + 'item_type' => 'test', 'item_id' => 3, 'item_parent_id' => 2, 'user_id' => 0, @@ -300,7 +335,7 @@ class phpbb_notification_test extends phpbb_database_test_case 'data' => array(), ), 4 => array( - 'item_type' => 'phpbb_notification_type_post', + 'item_type' => 'post', 'item_id' => 4, 'item_parent_id' => 2, 'user_id' => 0, @@ -316,7 +351,7 @@ class phpbb_notification_test extends phpbb_database_test_case ), ), 5 => array( - 'item_type' => 'phpbb_notification_type_bookmark', + 'item_type' => 'bookmark', 'item_id' => 5, 'item_parent_id' => 2, 'user_id' => 0, From 570c5ad3c08378f377385aaff7d3810ccb8db3ff Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Tue, 20 Nov 2012 23:12:37 -0600 Subject: [PATCH 0471/2494] [ticket/11103] Some comments PHPBB3-11103 --- phpBB/includes/notification/manager.php | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/phpBB/includes/notification/manager.php b/phpBB/includes/notification/manager.php index fbfe388c80..ea91496fb9 100644 --- a/phpBB/includes/notification/manager.php +++ b/phpBB/includes/notification/manager.php @@ -78,10 +78,15 @@ class phpbb_notification_manager * order_dir Order direction (Default: DESC) * limit Number of notifications to load (Default: 5) * start Notifications offset (Default: 0) - * all_unread Load all unread messages? If set to true, count_unread is set to true (Default: false) - * count_unread Count all unread messages? (Default: false) + * all_unread Load all unread notifications? If set to true, count_unread is set to true (Default: false) + * count_unread Count all unread notifications? (Default: false) + * count_total Count all notifications? (Default: false) + * @return array Array of information based on the request with keys: + * 'notifications' array of notification type objects + * 'unread_count' number of unread notifications the user has if count_unread is true in the options + * 'total_count' number of notifications the user has if count_total is true in the options */ - public function load_notifications($options = array()) + public function load_notifications(array $options = array()) { // Merge default options $options = array_merge(array( @@ -297,8 +302,11 @@ class phpbb_notification_manager * Note: If you send an array of types, any user who could receive multiple notifications from this single item will only receive * a single notification. If they MUST receive multiple notifications, call this function multiple times instead of sending an array * @param array $data Data specific for this type that will be inserted + * @param array $options Optional options to control what notifications are loaded + * ignore_users array of data to specify which users should not receive certain types of notifications + * @return array Information about what users were notified and how they were notified */ - public function add_notifications($item_type, $data, $options = array()) + public function add_notifications($item_type, $data, array $options = array()) { $options = array_merge(array( 'ignore_users' => array(), From b7b14f9a056190c6a01c98f6eec9e60ad73d7564 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 21 Nov 2012 16:20:14 +0100 Subject: [PATCH 0472/2494] [feature/avatars] Use constant for URL and fix usage of getimagesize We now use a constant for the gravatar URL. Additionally the usage of getimagesize() was reduced. It should only be run if the user didn't specify both the width and height of the avatar. PHPBB3-10018 --- phpBB/includes/avatar/driver/gravatar.php | 55 ++++++++++++++++------- 1 file changed, 39 insertions(+), 16 deletions(-) diff --git a/phpBB/includes/avatar/driver/gravatar.php b/phpBB/includes/avatar/driver/gravatar.php index 036800fd45..a73a28a234 100644 --- a/phpBB/includes/avatar/driver/gravatar.php +++ b/phpBB/includes/avatar/driver/gravatar.php @@ -21,6 +21,8 @@ if (!defined('IN_PHPBB')) */ class phpbb_avatar_driver_gravatar extends phpbb_avatar_driver { + const GRAVATAR_URL = 'https://secure.gravatar.com/avatar/'; + /** * @inheritdoc */ @@ -54,8 +56,7 @@ class phpbb_avatar_driver_gravatar extends phpbb_avatar_driver */ public function get_custom_html($row, $ignore_config = false, $alt = '') { - $html = 'get_gravatar_url($row) . '" ' . ($row['avatar_width'] ? ('width="' . $row['avatar_width'] . '" ') : '') . ($row['avatar_height'] ? ('height="' . $row['avatar_height'] . '" ') : '') . 'alt="' . ((!empty($user->lang[$alt])) ? $user->lang[$alt] : $alt) . '" />'; @@ -81,14 +82,14 @@ class phpbb_avatar_driver_gravatar extends phpbb_avatar_driver */ public function process_form($template, $row, &$error) { - $email = $this->request->variable('av_gravatar_email', ''); - $width = $this->request->variable('av_gravatar_width', 0); - $height = $this->request->variable('av_gravatar_height', 0); + $row['avatar'] = $this->request->variable('av_gravatar_email', ''); + $row['avatar_width'] = $this->request->variable('av_gravatar_width', 0); + $row['avatar_height'] = $this->request->variable('av_gravatar_height', 0); require_once($this->phpbb_root_path . 'includes/functions_user' . $this->phpEx); $error = array_merge($error, validate_data(array( - 'email' => $email, + 'email' => $row['avatar'], ), array( 'email' => array( array('string', false, 6, 60), @@ -101,12 +102,16 @@ class phpbb_avatar_driver_gravatar extends phpbb_avatar_driver } // Make sure getimagesize works... - if (function_exists('getimagesize')) + if (function_exists('getimagesize') && ($row['avatar_width'] <= 0 || $row['avatar_height'] <= 0)) { - // build URL - $url = 'https://secure.gravatar.com/' . md5(strtolower(trim($email))); + /** + * default to the minimum of the maximum allowed avatar size if the size + * is not or only partially entered + */ + $row['avatar_width'] = $row['avatar_height'] = min($this->config['avatar_max_width'], $this->config['avatar_max_height']); + $url = $this->get_gravatar_url($row); - if (($width <= 0 || $height <= 0) && (($image_data = @getimagesize($url)) === false)) + if (($row['avatar_width'] <= 0 || $row['avatar_height'] <= 0) && (($image_data = @getimagesize($url)) === false)) { $error[] = 'UNABLE_GET_IMAGE_SIZE'; return false; @@ -118,20 +123,38 @@ class phpbb_avatar_driver_gravatar extends phpbb_avatar_driver return false; } - $width = ($width && $height) ? $width : $image_data[0]; - $height = ($width && $height) ? $height : $image_data[1]; + $row['avatar_width'] = ($row['avatar_width'] && $row['avatar_height']) ? $row['avatar_width'] : $image_data[0]; + $row['avatar_height'] = ($row['avatar_width'] && $row['avatar_height']) ? $row['avatar_height'] : $image_data[1]; } - if ($width <= 0 || $height <= 0) + if ($row['avatar_width'] <= 0 || $row['avatar_height'] <= 0) { $error[] = 'AVATAR_NO_SIZE'; return false; } return array( - 'avatar' => $email, - 'avatar_width' => $width, - 'avatar_height' => $height, + 'avatar' => $row['avatar'], + 'avatar_width' => $row['avatar_width'], + 'avatar_height' => $row['avatar_height'], ); } + + /** + * Build gravatar URL for output on page + * + * @return string The gravatar URL + */ + protected function get_gravatar_url($row) + { + $url = self::GRAVATAR_URL; + $url .= md5(strtolower(trim($row['avatar']))); + + if ($row['avatar_width'] || $row['avatar_height']) + { + $url .= '?s=' . max($row['avatar_width'], $row['avatar_height']); + } + + return $url; + } } From 9b61204a17386742d3d3ec579ee8dcfe50cbf5a4 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 21 Nov 2012 16:27:20 +0100 Subject: [PATCH 0473/2494] [feature/avatars] Check if gravatar is within min/max width/height PHPBB3-10018 --- phpBB/includes/avatar/driver/gravatar.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/phpBB/includes/avatar/driver/gravatar.php b/phpBB/includes/avatar/driver/gravatar.php index a73a28a234..f0ab2ab548 100644 --- a/phpBB/includes/avatar/driver/gravatar.php +++ b/phpBB/includes/avatar/driver/gravatar.php @@ -132,6 +132,24 @@ class phpbb_avatar_driver_gravatar extends phpbb_avatar_driver $error[] = 'AVATAR_NO_SIZE'; return false; } + + if ($this->config['avatar_max_width'] || $this->config['avatar_max_height']) + { + if ($row['avatar_width'] > $this->config['avatar_max_width'] || $row['avatar_height'] > $this->config['avatar_max_height']) + { + $error[] = array('AVATAR_WRONG_SIZE', $this->config['avatar_min_width'], $this->config['avatar_min_height'], $this->config['avatar_max_width'], $this->config['avatar_max_height'], $row['avatar_width'], $row['avatar_height']); + return false; + } + } + + if ($this->config['avatar_min_width'] || $this->config['avatar_min_height']) + { + if ($row['avatar_width'] < $this->config['avatar_min_width'] || $row['avatar_height'] < $this->config['avatar_min_height']) + { + $error[] = array('AVATAR_WRONG_SIZE', $this->config['avatar_min_width'], $this->config['avatar_min_height'], $this->config['avatar_max_width'], $this->config['avatar_max_height'], $row['avatar_width'], $row['avatar_height']); + return false; + } + } return array( 'avatar' => $row['avatar'], From 726d1a16d704630a9a028010c7420bea837738d4 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 21 Nov 2012 17:15:35 +0100 Subject: [PATCH 0474/2494] [feature/avatars] Move avatar specific settings to drivers PHPBB3-10018 --- phpBB/includes/acp/acp_board.php | 24 ++++++++++++++-------- phpBB/includes/avatar/driver/driver.php | 8 ++++++++ phpBB/includes/avatar/driver/gravatar.php | 10 +++++++++ phpBB/includes/avatar/driver/interface.php | 7 +++++++ phpBB/includes/avatar/driver/local.php | 11 ++++++++++ phpBB/includes/avatar/driver/remote.php | 10 +++++++++ phpBB/includes/avatar/driver/upload.php | 15 ++++++++++++++ 7 files changed, 76 insertions(+), 9 deletions(-) diff --git a/phpBB/includes/acp/acp_board.php b/phpBB/includes/acp/acp_board.php index 4ad0b38708..5852f512cd 100644 --- a/phpBB/includes/acp/acp_board.php +++ b/phpBB/includes/acp/acp_board.php @@ -28,7 +28,7 @@ class acp_board { global $db, $user, $auth, $template; global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx; - global $cache; + global $cache, $phpbb_avatar_manager; $user->add_lang('acp/board'); @@ -107,6 +107,15 @@ class acp_board break; case 'avatar': + $avatar_drivers = $phpbb_avatar_manager->get_valid_drivers(); + sort($avatar_drivers); + $avatar_vars = array(); + foreach ($avatar_drivers as $driver) + { + $avatar = $phpbb_avatar_manager->get_driver($driver); + $avatar_vars += $avatar->prepare_form_acp(); + } + $display_vars = array( 'title' => 'ACP_AVATAR_SETTINGS', 'vars' => array( @@ -118,18 +127,15 @@ class acp_board 'avatar_max_height' => array('lang' => 'MAX_AVATAR_SIZE', 'validate' => 'int:0', 'type' => false, 'method' => false, 'explain' => false), 'allow_avatar' => array('lang' => 'ALLOW_AVATARS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - 'allow_avatar_gravatar' => array('lang' => 'ALLOW_GRAVATAR', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), - 'allow_avatar_local' => array('lang' => 'ALLOW_LOCAL', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), - 'allow_avatar_remote' => array('lang' => 'ALLOW_REMOTE', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - 'allow_avatar_upload' => array('lang' => 'ALLOW_UPLOAD', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), - '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' => 'text:4:10', 'explain' => true, 'append' => ' ' . $user->lang['BYTES']), 'avatar_min' => array('lang' => 'MIN_AVATAR_SIZE', 'validate' => 'int:0', 'type' => 'dimension:3:4', 'explain' => true, 'append' => ' ' . $user->lang['PIXEL']), 'avatar_max' => array('lang' => 'MAX_AVATAR_SIZE', 'validate' => 'int:0', 'type' => 'dimension:3:4', 'explain' => true, 'append' => ' ' . $user->lang['PIXEL']), - 'avatar_path' => array('lang' => 'AVATAR_STORAGE_PATH', 'validate' => 'rwpath', 'type' => 'text:20:255', 'explain' => true), - 'avatar_gallery_path' => array('lang' => 'AVATAR_GALLERY_PATH', 'validate' => 'rpath', 'type' => 'text:20:255', 'explain' => true), ) ); + + if (sizeof($avatar_vars)) + { + $display_vars['vars'] += $avatar_vars; + } break; case 'message': diff --git a/phpBB/includes/avatar/driver/driver.php b/phpBB/includes/avatar/driver/driver.php index ef0c8ce44e..710d3dfe20 100644 --- a/phpBB/includes/avatar/driver/driver.php +++ b/phpBB/includes/avatar/driver/driver.php @@ -126,6 +126,14 @@ abstract class phpbb_avatar_driver implements phpbb_avatar_driver_interface return false; } + /** + * @inheritdoc + **/ + public function prepare_form_acp() + { + return array(); + } + /** * @inheritdoc **/ diff --git a/phpBB/includes/avatar/driver/gravatar.php b/phpBB/includes/avatar/driver/gravatar.php index f0ab2ab548..58ac535e6b 100644 --- a/phpBB/includes/avatar/driver/gravatar.php +++ b/phpBB/includes/avatar/driver/gravatar.php @@ -77,6 +77,16 @@ class phpbb_avatar_driver_gravatar extends phpbb_avatar_driver return true; } + /** + * @inheritdoc + **/ + public function prepare_form_acp() + { + return array( + 'allow_avatar_gravatar' => array('lang' => 'ALLOW_GRAVATAR', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), + ); + } + /** * @inheritdoc */ diff --git a/phpBB/includes/avatar/driver/interface.php b/phpBB/includes/avatar/driver/interface.php index 11dbffa65d..28220d79f2 100644 --- a/phpBB/includes/avatar/driver/interface.php +++ b/phpBB/includes/avatar/driver/interface.php @@ -62,6 +62,13 @@ interface phpbb_avatar_driver_interface **/ public function prepare_form($template, $row, &$error); + /** + * Prepare form for changing the acp settings of this avatar + * + * @return array Return the array containing the acp settings + **/ + public function prepare_form_acp(); + /** * Process form data * diff --git a/phpBB/includes/avatar/driver/local.php b/phpBB/includes/avatar/driver/local.php index d0ad8708b0..f3c0d516af 100644 --- a/phpBB/includes/avatar/driver/local.php +++ b/phpBB/includes/avatar/driver/local.php @@ -109,6 +109,17 @@ class phpbb_avatar_driver_local extends phpbb_avatar_driver return true; } + /** + * @inheritdoc + **/ + public function prepare_form_acp() + { + return array( + 'allow_avatar_local' => array('lang' => 'ALLOW_LOCAL', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), + 'avatar_gallery_path' => array('lang' => 'AVATAR_GALLERY_PATH', 'validate' => 'rpath', 'type' => 'text:20:255', 'explain' => true), + ); + } + /** * @inheritdoc */ diff --git a/phpBB/includes/avatar/driver/remote.php b/phpBB/includes/avatar/driver/remote.php index 3c06209352..61ea0ebaf0 100644 --- a/phpBB/includes/avatar/driver/remote.php +++ b/phpBB/includes/avatar/driver/remote.php @@ -58,6 +58,16 @@ class phpbb_avatar_driver_remote extends phpbb_avatar_driver return true; } + /** + * @inheritdoc + **/ + public function prepare_form_acp() + { + return array( + 'allow_avatar_remote' => array('lang' => 'ALLOW_REMOTE', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), + ); + } + /** * @inheritdoc */ diff --git a/phpBB/includes/avatar/driver/upload.php b/phpBB/includes/avatar/driver/upload.php index 9475cad7a1..77cd81c8c9 100644 --- a/phpBB/includes/avatar/driver/upload.php +++ b/phpBB/includes/avatar/driver/upload.php @@ -122,6 +122,21 @@ class phpbb_avatar_driver_upload extends phpbb_avatar_driver ); } + /** + * @inheritdoc + **/ + public function prepare_form_acp() + { + global $user; + + return array( + 'allow_avatar_upload' => array('lang' => 'ALLOW_UPLOAD', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), + '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' => 'text:4:10', 'explain' => true, 'append' => ' ' . $user->lang['BYTES']), + 'avatar_path' => array('lang' => 'AVATAR_STORAGE_PATH', 'validate' => 'rwpath', 'type' => 'text:20:255', 'explain' => true), + ); + } + /** * @inheritdoc */ From 8c782122c1bafe6f232af6d9f395aa534c4d7dc1 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 21 Nov 2012 17:24:02 +0100 Subject: [PATCH 0475/2494] [feature/avatars] Use in_array() and fix tabbing PHPBB3-10018 --- phpBB/includes/avatar/manager.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/phpBB/includes/avatar/manager.php b/phpBB/includes/avatar/manager.php index 0d36118dbc..8255fb0759 100644 --- a/phpBB/includes/avatar/manager.php +++ b/phpBB/includes/avatar/manager.php @@ -70,16 +70,16 @@ class phpbb_avatar_manager { case AVATAR_GALLERY: $avatar_type = 'avatar.driver.local'; - break; + break; case AVATAR_UPLOAD: $avatar_type = 'avatar.driver.upload'; - break; + break; case AVATAR_REMOTE: $avatar_type = 'avatar.driver.remote'; - break; + break; } - if (false === array_search($avatar_type, self::$valid_drivers)) + if (!in_array($avatar_type, self::$valid_drivers)) { return null; } From 01b313ea262dc7c7a3399c03758ffd1ba24d1ff4 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 21 Nov 2012 19:20:39 +0100 Subject: [PATCH 0476/2494] [feature/avatars] Use isset() instead of in_array() PHPBB3-10018 --- phpBB/includes/avatar/manager.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/avatar/manager.php b/phpBB/includes/avatar/manager.php index 8255fb0759..da9d843947 100644 --- a/phpBB/includes/avatar/manager.php +++ b/phpBB/includes/avatar/manager.php @@ -79,7 +79,7 @@ class phpbb_avatar_manager break; } - if (!in_array($avatar_type, self::$valid_drivers)) + if (!isset(self::$valid_drivers[$avatar_type])) { return null; } @@ -109,7 +109,7 @@ class phpbb_avatar_manager self::$valid_drivers = array(); foreach ($this->avatar_drivers as $driver) { - self::$valid_drivers[] = $driver->get_name(); + self::$valid_drivers[$driver->get_name()] = $driver->get_name(); } } } From 24ac0393360aed07a17b7acaca0add6083cf8ddd Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 21 Nov 2012 19:51:46 +0100 Subject: [PATCH 0477/2494] [feature/avatars] Get rid of array_keys() in gallery avatar PHPBB3-10018 --- phpBB/includes/avatar/driver/local.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/phpBB/includes/avatar/driver/local.php b/phpBB/includes/avatar/driver/local.php index f3c0d516af..a206f5b1b0 100644 --- a/phpBB/includes/avatar/driver/local.php +++ b/phpBB/includes/avatar/driver/local.php @@ -52,9 +52,7 @@ class phpbb_avatar_driver_local extends phpbb_avatar_driver $avatar_list = $this->get_avatar_list(); $category = $this->request->variable('av_local_cat', ''); - $categories = array_keys($avatar_list); - - foreach ($categories as $cat) + foreach ($avatar_list as $cat => $null) { if (!empty($avatar_list[$cat])) { @@ -63,6 +61,11 @@ class phpbb_avatar_driver_local extends phpbb_avatar_driver 'SELECTED' => ($cat == $category), )); } + + if ($cat != $category) + { + unset($avatar_list[$cat]); + } } if (!empty($avatar_list[$category])) From 8a01bc171837be40818f285035ccefa5ac819213 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 21 Nov 2012 21:42:42 +0100 Subject: [PATCH 0478/2494] [feature/avatars] Use RecursiveDirectoryIterator for gallery avatar RecursiveDirectoryIterator is now used for populating the avatar list array of the gallery avatar. PHPBB3-10018 --- phpBB/includes/avatar/driver/local.php | 62 +++++++++++--------------- 1 file changed, 25 insertions(+), 37 deletions(-) diff --git a/phpBB/includes/avatar/driver/local.php b/phpBB/includes/avatar/driver/local.php index a206f5b1b0..8ac511f909 100644 --- a/phpBB/includes/avatar/driver/local.php +++ b/phpBB/includes/avatar/driver/local.php @@ -159,45 +159,33 @@ class phpbb_avatar_driver_local extends phpbb_avatar_driver $avatar_list = array(); $path = $this->phpbb_root_path . $this->config['avatar_gallery_path']; - $dh = @opendir($path); - - if ($dh) + $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path, FilesystemIterator::SKIP_DOTS | FilesystemIterator::UNIX_PATHS), RecursiveIteratorIterator::SELF_FIRST); + foreach ($iterator as $file_info) { - while (($cat = readdir($dh)) !== false) - { - if ($cat[0] != '.' && preg_match('#^[^&"\'<>]+$#i', $cat) && is_dir("$path/$cat")) - { - if ($ch = @opendir("$path/$cat")) - { - while (($image = readdir($ch)) !== false) - { - // Match all images in the gallery folder - if (preg_match('#^[^&\'"<>]+\.(?:gif|png|jpe?g)$#i', $image)) - { - if (function_exists('getimagesize')) - { - $dims = getimagesize($this->phpbb_root_path . $this->config['avatar_gallery_path'] . '/' . $cat . '/' . $image); - } - else - { - $dims = array(0, 0); - } - $avatar_list[$cat][$image] = array( - 'file' => rawurlencode($cat) . '/' . rawurlencode($image), - 'filename' => rawurlencode($image), - 'name' => ucfirst(str_replace('_', ' ', preg_replace('#^(.*)\..*$#', '\1', $image))), - 'width' => $dims[0], - 'height' => $dims[1], - ); - } - } - @closedir($ch); - } - } - } - @closedir($dh); - } + $file_path = $file_info->getPath(); + $image = $file_info->getFilename(); + // Match all images in the gallery folder + if (preg_match('#^[^&\'"<>]+\.(?:gif|png|jpe?g)$#i', $image) && is_file($file_path . '/' . $image)) + { + if (function_exists('getimagesize')) + { + $dims = getimagesize($file_path . '/' . $image); + } + else + { + $dims = array(0, 0); + } + $cat = str_replace("$path/", '', $file_path); + $avatar_list[$cat][$image] = array( + 'file' => rawurlencode($cat) . '/' . rawurlencode($image), + 'filename' => rawurlencode($image), + 'name' => ucfirst(str_replace('_', ' ', preg_replace('#^(.*)\..*$#', '\1', $image))), + 'width' => $dims[0], + 'height' => $dims[1], + ); + } + } @ksort($avatar_list); if ($this->cache != null) From c911a34b5b7541b46ee2408da366d2dc7c302090 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Wed, 21 Nov 2012 16:04:01 -0600 Subject: [PATCH 0479/2494] [ticket/11103] Do not prepend notification.(type|method) unless necessary PHPBB3-11103 --- phpBB/includes/notification/manager.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/notification/manager.php b/phpBB/includes/notification/manager.php index ea91496fb9..4c25fa72f0 100644 --- a/phpBB/includes/notification/manager.php +++ b/phpBB/includes/notification/manager.php @@ -755,7 +755,9 @@ class phpbb_notification_manager */ public function get_item_type_class($item_type, $data = array()) { - $item = $this->load_object('notification.type.' . $item_type); + $item_type = (strpos($item_type, 'notification.type.') === 0) ? $item_type : 'notification.type.' . $item_type; + + $item = $this->load_object($item_type); $item->set_initial_data($data); @@ -767,7 +769,9 @@ class phpbb_notification_manager */ public function get_method_class($method_name) { - return $this->load_object('notification.method.' . $method_name); + $method_name = (strpos($method_name, 'notification.method.') === 0) ? $method_name : 'notification.method.' . $method_name; + + return $this->load_object($method_name); } /** From 5289dc52a322f760b6a2108f5fed1b4ff365e1d4 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Thu, 22 Nov 2012 00:00:45 +0100 Subject: [PATCH 0480/2494] [feature/avatars] Add support for modularized avatars to ucp groups This seems to be the last component where the new avatars system was still missing. PHPBB3-10018 --- phpBB/includes/ucp/ucp_groups.php | 184 +++++++++--------- .../template/ucp_avatar_options.html | 2 + .../prosilver/template/ucp_groups_manage.html | 4 +- .../template/ucp_groups_manage.html | 91 +++------ .../template/ucp_profile_avatar.html | 4 +- 5 files changed, 125 insertions(+), 160 deletions(-) diff --git a/phpBB/includes/ucp/ucp_groups.php b/phpBB/includes/ucp/ucp_groups.php index 3aa6146081..1d469814b6 100644 --- a/phpBB/includes/ucp/ucp_groups.php +++ b/phpBB/includes/ucp/ucp_groups.php @@ -27,7 +27,7 @@ class ucp_groups { global $config, $phpbb_root_path, $phpEx; global $db, $user, $auth, $cache, $template; - global $request; + global $request, $phpbb_avatar_manager; $user->add_lang('groups'); @@ -438,7 +438,7 @@ class ucp_groups $group_name = $group_row['group_name']; $group_type = $group_row['group_type']; - $avatar_img = (!empty($group_row['group_avatar'])) ? get_group_avatar($group_row) : ''; + $avatar = get_group_avatar($group_row, 'GROUP_AVATAR', true); $template->assign_vars(array( 'GROUP_NAME' => ($group_type == GROUP_SPECIAL) ? $user->lang['G_' . $group_name] : $group_name, @@ -447,8 +447,8 @@ class ucp_groups 'GROUP_DESC_DISP' => generate_text_for_display($group_row['group_desc'], $group_row['group_desc_uid'], $group_row['group_desc_bitfield'], $group_row['group_desc_options']), 'GROUP_TYPE' => $group_row['group_type'], - 'AVATAR' => $avatar_img, - 'AVATAR_IMAGE' => $avatar_img, + 'AVATAR' => (empty($avatar) ? '' : $avatar), + 'AVATAR_IMAGE' => (empty($avatar) ? '' : $avatar), 'AVATAR_WIDTH' => (isset($group_row['group_avatar_width'])) ? $group_row['group_avatar_width'] : '', 'AVATAR_HEIGHT' => (isset($group_row['group_avatar_height'])) ? $group_row['group_avatar_height'] : '', )); @@ -483,10 +483,20 @@ class ucp_groups $error = array(); - $avatar_select = basename(request_var('avatar_select', '')); - $category = basename(request_var('category', '')); + // Setup avatar data for later + $avatars_enabled = false; + $avatar_drivers = null; + $avatar_data = null; + $avatar_error = array(); - $can_upload = (file_exists($phpbb_root_path . $config['avatar_path']) && phpbb_is_writable($phpbb_root_path . $config['avatar_path']) && $file_uploads) ? true : false; + if ($config['allow_avatar']) + { + $avatar_drivers = $phpbb_avatar_manager->get_valid_drivers(); + sort($avatar_drivers); + + // This is normalised data, without the group_ prefix + $avatar_data = phpbb_avatar_manager::clean_row($group_row); + } // Did we submit? if ($update) @@ -507,87 +517,41 @@ class ucp_groups 'max_recipients'=> request_var('group_max_recipients', 0), ); - $data['uploadurl'] = request_var('uploadurl', ''); - $data['remotelink'] = request_var('remotelink', ''); - $data['width'] = request_var('width', ''); - $data['height'] = request_var('height', ''); - $delete = request_var('delete', ''); - - $uploadfile = $request->file('uploadfile'); - if (!empty($uploadfile['tmp_name']) || $data['uploadurl'] || $data['remotelink']) + if ($config['allow_avatar']) { - // Avatar stuff - $var_ary = array( - 'uploadurl' => array('string', true, 5, 255), - 'remotelink' => array('string', true, 5, 255), - 'width' => array('string', true, 1, 3), - 'height' => array('string', true, 1, 3), - ); - - if (!($error = validate_data($data, $var_ary))) + // Handle avatar + $driver = str_replace('_', '.', request_var('avatar_driver', '')); + $config_name = preg_replace('#^avatar.driver.#', '', $driver); + $av_delete = $request->variable('av_delete', ''); + if (in_array($driver, $avatar_drivers) && $config["allow_avatar_$config_name"] && empty($av_delete)) { - $data['user_id'] = "g$group_id"; + $avatar = $phpbb_avatar_manager->get_driver($driver); + $result = $avatar->process_form($template, $avatar_data, $avatar_error); - if ((!empty($uploadfile['tmp_name']) || $data['uploadurl']) && $can_upload) + if ($result && empty($avatar_error)) { - list($submit_ary['avatar_type'], $submit_ary['avatar'], $submit_ary['avatar_width'], $submit_ary['avatar_height']) = avatar_upload($data, $error); - } - else if ($data['remotelink']) - { - list($submit_ary['avatar_type'], $submit_ary['avatar'], $submit_ary['avatar_width'], $submit_ary['avatar_height']) = avatar_remote($data, $error); + $result = array( + 'avatar_type' => $driver, + 'avatar' => $result['avatar'], + 'avatar_width' => $result['avatar_width'], + 'avatar_height' => $result['avatar_height'], + ); + + $submit_ary = array_merge($submit_ary, $result); } } - } - else if ($avatar_select && $config['allow_avatar_local']) - { - // check avatar gallery - if (is_dir($phpbb_root_path . $config['avatar_gallery_path'] . '/' . $category)) + else { - $submit_ary['avatar_type'] = AVATAR_GALLERY; - - list($submit_ary['avatar_width'], $submit_ary['avatar_height']) = getimagesize($phpbb_root_path . $config['avatar_gallery_path'] . '/' . $category . '/' . $avatar_select); - $submit_ary['avatar'] = $category . '/' . $avatar_select; - } - } - else if ($delete) - { - $submit_ary['avatar'] = ''; - $submit_ary['avatar_type'] = $submit_ary['avatar_width'] = $submit_ary['avatar_height'] = 0; - } - else if ($data['width'] && $data['height']) - { - // Only update the dimensions? - if ($config['avatar_max_width'] || $config['avatar_max_height']) - { - if ($data['width'] > $config['avatar_max_width'] || $data['height'] > $config['avatar_max_height']) + if ($avatar = $phpbb_avatar_manager->get_driver($user->data['user_avatar_type'])) { - $error[] = phpbb_avatar_error_wrong_size($data['width'], $data['height']); + $avatar->delete($avatar_data); } - } - if (!sizeof($error)) - { - if ($config['avatar_min_width'] || $config['avatar_min_height']) - { - if ($data['width'] < $config['avatar_min_width'] || $data['height'] < $config['avatar_min_height']) - { - $error[] = phpbb_avatar_error_wrong_size($data['width'], $data['height']); - } - } - } - - if (!sizeof($error)) - { - $submit_ary['avatar_width'] = $data['width']; - $submit_ary['avatar_height'] = $data['height']; - } - } - - if ((isset($submit_ary['avatar']) && $submit_ary['avatar'] && (!isset($group_row['group_avatar']))) || $delete) - { - if (isset($group_row['group_avatar']) && $group_row['group_avatar']) - { - avatar_delete('group', $group_row, true); + // Removing the avatar + $submit_ary['avatar_type'] = ''; + $submit_ary['avatar'] = ''; + $submit_ary['avatar_width'] = 0; + $submit_ary['avatar_height'] = 0; } } @@ -607,7 +571,7 @@ class ucp_groups 'rank' => 'int', 'colour' => 'string', 'avatar' => 'string', - 'avatar_type' => 'int', + 'avatar_type' => 'string', 'avatar_width' => 'int', 'avatar_height' => 'int', 'receive_pm' => 'int', @@ -683,28 +647,63 @@ class ucp_groups $type_closed = ($group_type == GROUP_CLOSED) ? ' checked="checked"' : ''; $type_hidden = ($group_type == GROUP_HIDDEN) ? ' checked="checked"' : ''; - $display_gallery = (isset($_POST['display_gallery'])) ? true : false; - - if ($config['allow_avatar'] && $config['allow_avatar_local'] && $display_gallery) + // Load up stuff for avatars + if ($config['allow_avatar']) { - avatar_gallery($category, $avatar_select, 4); + $avatars_enabled = false; + $focused_driver = str_replace('_', '.', request_var('avatar_driver', $avatar_data['avatar_type'])); + + foreach ($avatar_drivers as $driver) + { + $avatar = $phpbb_avatar_manager->get_driver($driver); + + if ($avatar->is_enabled()) + { + $avatars_enabled = true; + $template->set_filenames(array( + 'avatar' => $avatar->get_template_name(), + )); + + if ($avatar->prepare_form($template, $avatar_data, $avatar_error)) + { + $driver_n = str_replace('.', '_', $driver); + $driver_u = strtoupper($driver_n); + $template->assign_block_vars('avatar_drivers', array( + 'L_TITLE' => $user->lang($driver_u . '_TITLE'), + 'L_EXPLAIN' => $user->lang($driver_u . '_EXPLAIN'), + + 'DRIVER' => $driver_n, + 'SELECTED' => ($driver == $focused_driver), + 'OUTPUT' => $template->assign_display('avatar'), + )); + } + } + } } - $avatars_enabled = ($config['allow_avatar'] && (($can_upload && ($config['allow_avatar_upload'] || $config['allow_avatar_remote_upload'])) || ($config['allow_avatar_local'] || $config['allow_avatar_remote']))) ? true : false; + // Merge any avatars errors into the primary error array + // Drivers use lang constants, so we need to map to the actual strings + foreach ($avatar_error as $e) + { + if (is_array($e)) + { + $key = array_shift($e); + $error[] = vsprintf($user->lang($key), $e); + } + else + { + $error[] = $user->lang((string) $e); + } + } $template->assign_vars(array( 'S_EDIT' => true, 'S_INCLUDE_SWATCH' => true, - 'S_FORM_ENCTYPE' => ($config['allow_avatar'] && $can_upload && ($config['allow_avatar_upload'] || $config['allow_avatar_remote_upload'])) ? ' enctype="multipart/form-data"' : '', + 'S_FORM_ENCTYPE' => ' enctype="multipart/form-data"', 'S_ERROR' => (sizeof($error)) ? true : false, 'S_SPECIAL_GROUP' => ($group_type == GROUP_SPECIAL) ? true : false, - 'S_AVATARS_ENABLED' => $avatars_enabled, - 'S_DISPLAY_GALLERY' => ($config['allow_avatar'] && $config['allow_avatar_local'] && !$display_gallery) ? true : false, - 'S_IN_GALLERY' => ($config['allow_avatar_local'] && $display_gallery) ? true : false, - - 'S_UPLOAD_AVATAR_FILE' => ($config['allow_avatar'] && $config['allow_avatar_upload'] && $can_upload) ? true : false, - 'S_UPLOAD_AVATAR_URL' => ($config['allow_avatar'] && $config['allow_avatar_remote_upload'] && $can_upload) ? true : false, - 'S_LINK_AVATAR' => ($config['allow_avatar'] && $config['allow_avatar_remote']) ? true : false, + 'S_AVATARS_ENABLED' => ($config['allow_avatar'] && $avatars_enabled), + 'S_GROUP_MANAGE' => true, 'ERROR_MSG' => (sizeof($error)) ? implode('
    ', $error) : '', 'GROUP_RECEIVE_PM' => (isset($group_row['group_receive_pm']) && $group_row['group_receive_pm']) ? ' checked="checked"' : '', @@ -717,7 +716,6 @@ class ucp_groups 'S_DESC_SMILIES_CHECKED'=> $group_desc_data['allow_smilies'], 'S_RANK_OPTIONS' => $rank_options, - 'AVATAR_MAX_FILESIZE' => $config['avatar_filesize'], 'GROUP_TYPE_FREE' => GROUP_FREE, 'GROUP_TYPE_OPEN' => GROUP_OPEN, diff --git a/phpBB/styles/prosilver/template/ucp_avatar_options.html b/phpBB/styles/prosilver/template/ucp_avatar_options.html index e7300a075d..354ddcc69c 100644 --- a/phpBB/styles/prosilver/template/ucp_avatar_options.html +++ b/phpBB/styles/prosilver/template/ucp_avatar_options.html @@ -38,10 +38,12 @@ +
     
    + diff --git a/phpBB/styles/prosilver/template/ucp_groups_manage.html b/phpBB/styles/prosilver/template/ucp_groups_manage.html index 6b017ea3fa..f6fcfa043d 100644 --- a/phpBB/styles/prosilver/template/ucp_groups_manage.html +++ b/phpBB/styles/prosilver/template/ucp_groups_manage.html @@ -70,9 +70,7 @@
    {S_HIDDEN_FIELDS} -   -   -   +   {S_FORM_TOKEN}
    diff --git a/phpBB/styles/subsilver2/template/ucp_groups_manage.html b/phpBB/styles/subsilver2/template/ucp_groups_manage.html index 12319c9e4e..e15335f4e1 100644 --- a/phpBB/styles/subsilver2/template/ucp_groups_manage.html +++ b/phpBB/styles/subsilver2/template/ucp_groups_manage.html @@ -60,74 +60,43 @@
    {L_AVATAR_EXPLAIN} - {AVATAR_IMAGE}

     {L_DELETE_AVATAR} + {AVATAR_IMAGE}

     {L_DELETE_AVATAR} - - - - - - - - - -
    {L_UPLOAD_AVATAR_URL_EXPLAIN} - - - - - -
    {L_LINK_REMOTE_AVATAR_EXPLAIN} - - - -
    {L_LINK_REMOTE_SIZE_EXPLAIN} - px X px - - - - - - - - - - - - {L_AVATAR_GALLERY} - - - -   - - - - - - - - - - - - - - - - -
    {avatar_row.avatar_column.AVATAR_NAME}
    - - - - - + + + {L_AVATAR_FEATURES_DISABLED} + + + + {L_AVATAR_SELECT} + + + {L_AVATAR_TYPE}{L_COLON} + + + + + + {avatar_drivers.L_EXPLAIN} + + + {avatar_drivers.OUTPUT} + + -   + {S_HIDDEN_FIELDS}  + +

    {L_GROUP_MEMBERS}

    diff --git a/phpBB/styles/subsilver2/template/ucp_profile_avatar.html b/phpBB/styles/subsilver2/template/ucp_profile_avatar.html index f8129e60e6..4e65b37e3c 100644 --- a/phpBB/styles/subsilver2/template/ucp_profile_avatar.html +++ b/phpBB/styles/subsilver2/template/ucp_profile_avatar.html @@ -12,7 +12,7 @@ {L_CURRENT_IMAGE}{L_COLON}
    {L_AVATAR_EXPLAIN}
    - {AVATAR}

     {L_DELETE_AVATAR} + {AVATAR}

     {L_DELETE_AVATAR} @@ -43,11 +43,9 @@ - {S_HIDDEN_FIELDS}   - From 211abe2ac9722f23d2f86b6172452e9d9d1bff38 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Thu, 22 Nov 2012 00:39:02 +0100 Subject: [PATCH 0481/2494] [feature/avatars] Remove obsolete functions from functions_user.php The removed functions are no longer needed due to the new avatar system. PHPBB3-10018 --- phpBB/includes/functions_user.php | 466 ------------------------------ 1 file changed, 466 deletions(-) diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index 7cac0fb34f..3b11147a3a 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -2058,134 +2058,6 @@ function avatar_delete($mode, $row, $clean_db = false) return false; } -/** -* Remote avatar linkage -*/ -function avatar_remote($data, &$error) -{ - global $config, $db, $user, $phpbb_root_path, $phpEx; - - if (!preg_match('#^(http|https|ftp)://#i', $data['remotelink'])) - { - $data['remotelink'] = 'http://' . $data['remotelink']; - } - if (!preg_match('#^(http|https|ftp)://(?:(.*?\.)*?[a-z0-9\-]+?\.[a-z]{2,4}|(?:\d{1,3}\.){3,5}\d{1,3}):?([0-9]*?).*?\.(gif|jpg|jpeg|png)$#i', $data['remotelink'])) - { - $error[] = $user->lang['AVATAR_URL_INVALID']; - return false; - } - - // Make sure getimagesize works... - if (($image_data = @getimagesize($data['remotelink'])) === false && (empty($data['width']) || empty($data['height']))) - { - $error[] = $user->lang['UNABLE_GET_IMAGE_SIZE']; - return false; - } - - if (!empty($image_data) && ($image_data[0] < 2 || $image_data[1] < 2)) - { - $error[] = $user->lang['AVATAR_NO_SIZE']; - return false; - } - - $width = ($data['width'] && $data['height']) ? $data['width'] : $image_data[0]; - $height = ($data['width'] && $data['height']) ? $data['height'] : $image_data[1]; - - if ($width < 2 || $height < 2) - { - $error[] = $user->lang['AVATAR_NO_SIZE']; - return false; - } - - // Check image type - include_once($phpbb_root_path . 'includes/functions_upload.' . $phpEx); - $types = fileupload::image_types(); - $extension = strtolower(filespec::get_extension($data['remotelink'])); - - if (!empty($image_data) && (!isset($types[$image_data[2]]) || !in_array($extension, $types[$image_data[2]]))) - { - if (!isset($types[$image_data[2]])) - { - $error[] = $user->lang['UNABLE_GET_IMAGE_SIZE']; - } - else - { - $error[] = sprintf($user->lang['IMAGE_FILETYPE_MISMATCH'], $types[$image_data[2]][0], $extension); - } - return false; - } - - if ($config['avatar_max_width'] || $config['avatar_max_height']) - { - if ($width > $config['avatar_max_width'] || $height > $config['avatar_max_height']) - { - $error[] = phpbb_avatar_error_wrong_size($width, $height); - return false; - } - } - - if ($config['avatar_min_width'] || $config['avatar_min_height']) - { - if ($width < $config['avatar_min_width'] || $height < $config['avatar_min_height']) - { - $error[] = phpbb_avatar_error_wrong_size($width, $height); - return false; - } - } - - return array(AVATAR_REMOTE, $data['remotelink'], $width, $height); -} - -/** -* Avatar upload using the upload class -*/ -function avatar_upload($data, &$error) -{ - global $phpbb_root_path, $config, $db, $user, $phpEx, $request; - - // Init upload class - include_once($phpbb_root_path . 'includes/functions_upload.' . $phpEx); - $upload = new fileupload('AVATAR_', array('jpg', 'jpeg', 'gif', 'png'), $config['avatar_filesize'], $config['avatar_min_width'], $config['avatar_min_height'], $config['avatar_max_width'], $config['avatar_max_height'], (isset($config['mime_triggers']) ? explode('|', $config['mime_triggers']) : false)); - - $uploadfile = $request->file('uploadfile'); - if (!empty($uploadfile['name'])) - { - $file = $upload->form_upload('uploadfile'); - } - else - { - $file = $upload->remote_upload($data['uploadurl']); - } - - $prefix = $config['avatar_salt'] . '_'; - $file->clean_filename('avatar', $prefix, $data['user_id']); - - $destination = $config['avatar_path']; - - // Adjust destination path (no trailing slash) - if (substr($destination, -1, 1) == '/' || substr($destination, -1, 1) == '\\') - { - $destination = substr($destination, 0, -1); - } - - $destination = str_replace(array('../', '..\\', './', '.\\'), '', $destination); - if ($destination && ($destination[0] == '/' || $destination[0] == "\\")) - { - $destination = ''; - } - - // Move file and overwrite any existing image - $file->move_file($destination, true); - - if (sizeof($file->error)) - { - $file->remove(); - $error = array_merge($error, $file->error); - } - - return array(AVATAR_UPLOAD, $data['user_id'] . '_' . time() . '.' . $file->get('extension'), $file->get('width'), $file->get('height')); -} - /** * Generates avatar filename from the database entry */ @@ -2208,344 +2080,6 @@ function get_avatar_filename($avatar_entry) return $config['avatar_salt'] . '_' . (($avatar_group) ? 'g' : '') . $avatar_entry . '.' . $ext; } -/** -* Avatar Gallery -*/ -function avatar_gallery($category, $avatar_select, $items_per_column, $block_var = 'avatar_row') -{ - global $user, $cache, $template; - global $config, $phpbb_root_path; - - $avatar_list = array(); - - $path = $phpbb_root_path . $config['avatar_gallery_path']; - - if (!file_exists($path) || !is_dir($path)) - { - $avatar_list = array($user->lang['NO_AVATAR_CATEGORY'] => array()); - } - else - { - // Collect images - $dp = @opendir($path); - - if (!$dp) - { - return array($user->lang['NO_AVATAR_CATEGORY'] => array()); - } - - while (($file = readdir($dp)) !== false) - { - if ($file[0] != '.' && preg_match('#^[^&"\'<>]+$#i', $file) && is_dir("$path/$file")) - { - $avatar_row_count = $avatar_col_count = 0; - - if ($dp2 = @opendir("$path/$file")) - { - while (($sub_file = readdir($dp2)) !== false) - { - if (preg_match('#^[^&\'"<>]+\.(?:gif|png|jpe?g)$#i', $sub_file)) - { - $avatar_list[$file][$avatar_row_count][$avatar_col_count] = array( - 'file' => rawurlencode($file) . '/' . rawurlencode($sub_file), - 'filename' => rawurlencode($sub_file), - 'name' => ucfirst(str_replace('_', ' ', preg_replace('#^(.*)\..*$#', '\1', $sub_file))), - ); - $avatar_col_count++; - if ($avatar_col_count == $items_per_column) - { - $avatar_row_count++; - $avatar_col_count = 0; - } - } - } - closedir($dp2); - } - } - } - closedir($dp); - } - - if (!sizeof($avatar_list)) - { - $avatar_list = array($user->lang['NO_AVATAR_CATEGORY'] => array()); - } - - @ksort($avatar_list); - - $category = (!$category) ? key($avatar_list) : $category; - $avatar_categories = array_keys($avatar_list); - - $s_category_options = ''; - foreach ($avatar_categories as $cat) - { - $s_category_options .= ''; - } - - $template->assign_vars(array( - 'S_AVATARS_ENABLED' => true, - 'S_IN_AVATAR_GALLERY' => true, - 'S_CAT_OPTIONS' => $s_category_options) - ); - - $avatar_list = (isset($avatar_list[$category])) ? $avatar_list[$category] : array(); - - foreach ($avatar_list as $avatar_row_ary) - { - $template->assign_block_vars($block_var, array()); - - foreach ($avatar_row_ary as $avatar_col_ary) - { - $template->assign_block_vars($block_var . '.avatar_column', array( - 'AVATAR_IMAGE' => $phpbb_root_path . $config['avatar_gallery_path'] . '/' . $avatar_col_ary['file'], - 'AVATAR_NAME' => $avatar_col_ary['name'], - 'AVATAR_FILE' => $avatar_col_ary['filename']) - ); - - $template->assign_block_vars($block_var . '.avatar_option_column', array( - 'AVATAR_IMAGE' => $phpbb_root_path . $config['avatar_gallery_path'] . '/' . $avatar_col_ary['file'], - 'S_OPTIONS_AVATAR' => $avatar_col_ary['filename']) - ); - } - } - - return $avatar_list; -} - - -/** -* Tries to (re-)establish avatar dimensions -*/ -function avatar_get_dimensions($avatar, $avatar_type, &$error, $current_x = 0, $current_y = 0) -{ - global $config, $phpbb_root_path, $user; - - switch ($avatar_type) - { - case AVATAR_REMOTE : - break; - - case AVATAR_UPLOAD : - $avatar = $phpbb_root_path . $config['avatar_path'] . '/' . get_avatar_filename($avatar); - break; - - case AVATAR_GALLERY : - $avatar = $phpbb_root_path . $config['avatar_gallery_path'] . '/' . $avatar ; - break; - } - - // Make sure getimagesize works... - if (($image_data = @getimagesize($avatar)) === false) - { - $error[] = $user->lang['UNABLE_GET_IMAGE_SIZE']; - return false; - } - - if ($image_data[0] < 2 || $image_data[1] < 2) - { - $error[] = $user->lang['AVATAR_NO_SIZE']; - return false; - } - - // try to maintain ratio - if (!(empty($current_x) && empty($current_y))) - { - if ($current_x != 0) - { - $image_data[1] = (int) floor(($current_x / $image_data[0]) * $image_data[1]); - $image_data[1] = min($config['avatar_max_height'], $image_data[1]); - $image_data[1] = max($config['avatar_min_height'], $image_data[1]); - } - if ($current_y != 0) - { - $image_data[0] = (int) floor(($current_y / $image_data[1]) * $image_data[0]); - $image_data[0] = min($config['avatar_max_width'], $image_data[1]); - $image_data[0] = max($config['avatar_min_width'], $image_data[1]); - } - } - return array($image_data[0], $image_data[1]); -} - -/** -* Uploading/Changing user avatar -*/ -function avatar_process_user(&$error, $custom_userdata = false, $can_upload = null) -{ - global $config, $phpbb_root_path, $auth, $user, $db, $request; - - $data = array( - 'uploadurl' => request_var('uploadurl', ''), - 'remotelink' => request_var('remotelink', ''), - 'width' => request_var('width', 0), - 'height' => request_var('height', 0), - ); - - $error = validate_data($data, array( - 'uploadurl' => array('string', true, 5, 255), - 'remotelink' => array('string', true, 5, 255), - 'width' => array('string', true, 1, 3), - 'height' => array('string', true, 1, 3), - )); - - if (sizeof($error)) - { - return false; - } - - $sql_ary = array(); - - if ($custom_userdata === false) - { - $userdata = &$user->data; - } - else - { - $userdata = &$custom_userdata; - } - - $data['user_id'] = $userdata['user_id']; - $change_avatar = ($custom_userdata === false) ? $auth->acl_get('u_chgavatar') : true; - $avatar_select = basename(request_var('avatar_select', '')); - - // Can we upload? - if (is_null($can_upload)) - { - $can_upload = ($config['allow_avatar_upload'] && file_exists($phpbb_root_path . $config['avatar_path']) && phpbb_is_writable($phpbb_root_path . $config['avatar_path']) && $change_avatar && (@ini_get('file_uploads') || strtolower(@ini_get('file_uploads')) == 'on')) ? true : false; - } - - $uploadfile = $request->file('uploadfile'); - if ((!empty($uploadfile['name']) || $data['uploadurl']) && $can_upload) - { - list($sql_ary['user_avatar_type'], $sql_ary['user_avatar'], $sql_ary['user_avatar_width'], $sql_ary['user_avatar_height']) = avatar_upload($data, $error); - } - else if ($data['remotelink'] && $change_avatar && $config['allow_avatar_remote']) - { - list($sql_ary['user_avatar_type'], $sql_ary['user_avatar'], $sql_ary['user_avatar_width'], $sql_ary['user_avatar_height']) = avatar_remote($data, $error); - } - else if ($avatar_select && $change_avatar && $config['allow_avatar_local']) - { - $category = basename(request_var('category', '')); - - $sql_ary['user_avatar_type'] = AVATAR_GALLERY; - $sql_ary['user_avatar'] = $avatar_select; - - // check avatar gallery - if (!is_dir($phpbb_root_path . $config['avatar_gallery_path'] . '/' . $category)) - { - $sql_ary['user_avatar'] = ''; - $sql_ary['user_avatar_type'] = $sql_ary['user_avatar_width'] = $sql_ary['user_avatar_height'] = 0; - } - else - { - list($sql_ary['user_avatar_width'], $sql_ary['user_avatar_height']) = getimagesize($phpbb_root_path . $config['avatar_gallery_path'] . '/' . $category . '/' . urldecode($sql_ary['user_avatar'])); - $sql_ary['user_avatar'] = $category . '/' . $sql_ary['user_avatar']; - } - } - else if (isset($_POST['delete']) && $change_avatar) - { - $sql_ary['user_avatar'] = ''; - $sql_ary['user_avatar_type'] = $sql_ary['user_avatar_width'] = $sql_ary['user_avatar_height'] = 0; - } - else if (!empty($userdata['user_avatar'])) - { - // Only update the dimensions - - if (empty($data['width']) || empty($data['height'])) - { - if ($dims = avatar_get_dimensions($userdata['user_avatar'], $userdata['user_avatar_type'], $error, $data['width'], $data['height'])) - { - list($guessed_x, $guessed_y) = $dims; - if (empty($data['width'])) - { - $data['width'] = $guessed_x; - } - if (empty($data['height'])) - { - $data['height'] = $guessed_y; - } - } - } - if (($config['avatar_max_width'] || $config['avatar_max_height']) && - (($data['width'] != $userdata['user_avatar_width']) || $data['height'] != $userdata['user_avatar_height'])) - { - if ($data['width'] > $config['avatar_max_width'] || $data['height'] > $config['avatar_max_height']) - { - $error[] = phpbb_avatar_error_wrong_size($data['width'], $data['height']); - } - } - - if (!sizeof($error)) - { - if ($config['avatar_min_width'] || $config['avatar_min_height']) - { - if ($data['width'] < $config['avatar_min_width'] || $data['height'] < $config['avatar_min_height']) - { - $error[] = phpbb_avatar_error_wrong_size($data['width'], $data['height']); - } - } - } - - if (!sizeof($error)) - { - $sql_ary['user_avatar_width'] = $data['width']; - $sql_ary['user_avatar_height'] = $data['height']; - } - } - - if (!sizeof($error)) - { - // Do we actually have any data to update? - if (sizeof($sql_ary)) - { - $ext_new = $ext_old = ''; - if (isset($sql_ary['user_avatar'])) - { - $userdata = ($custom_userdata === false) ? $user->data : $custom_userdata; - $ext_new = (empty($sql_ary['user_avatar'])) ? '' : substr(strrchr($sql_ary['user_avatar'], '.'), 1); - $ext_old = (empty($userdata['user_avatar'])) ? '' : substr(strrchr($userdata['user_avatar'], '.'), 1); - - if ($userdata['user_avatar_type'] == AVATAR_UPLOAD) - { - // Delete old avatar if present - if ((!empty($userdata['user_avatar']) && empty($sql_ary['user_avatar'])) - || ( !empty($userdata['user_avatar']) && !empty($sql_ary['user_avatar']) && $ext_new !== $ext_old)) - { - avatar_delete('user', $userdata); - } - } - } - - $sql = 'UPDATE ' . USERS_TABLE . ' - SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' - WHERE user_id = ' . (($custom_userdata === false) ? $user->data['user_id'] : $custom_userdata['user_id']); - $db->sql_query($sql); - - } - } - - return (sizeof($error)) ? false : true; -} - -/** -* Returns a language string with the avatar size of the new avatar and the allowed maximum and minimum -* -* @param $width int The width of the new uploaded/selected avatar -* @param $height int The height of the new uploaded/selected avatar -* @return string -*/ -function phpbb_avatar_error_wrong_size($width, $height) -{ - global $config, $user; - - return $user->lang('AVATAR_WRONG_SIZE', - $user->lang('PIXELS', (int) $config['avatar_min_width']), - $user->lang('PIXELS', (int) $config['avatar_min_height']), - $user->lang('PIXELS', (int) $config['avatar_max_width']), - $user->lang('PIXELS', (int) $config['avatar_max_height']), - $user->lang('PIXELS', (int) $width), - $user->lang('PIXELS', (int) $height)); -} - /** * Returns an explanation string with maximum avatar settings * From 5ff343f1e6714fd88d64cb17884f88ceee681cb6 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Thu, 22 Nov 2012 11:58:45 +0100 Subject: [PATCH 0482/2494] [feature/avatars] Remove duplicate form enctype PHPBB3-10018 --- phpBB/adm/style/acp_groups.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/adm/style/acp_groups.html b/phpBB/adm/style/acp_groups.html index e96adcee90..a4699571d6 100644 --- a/phpBB/adm/style/acp_groups.html +++ b/phpBB/adm/style/acp_groups.html @@ -17,7 +17,7 @@ - enctype="multipart/form-data" enctype="multipart/form-data"> +
    {L_GROUP_DETAILS} From 2b917199066cb06aa9c6c846ce06252d6f8036e9 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Thu, 22 Nov 2012 18:38:36 +0100 Subject: [PATCH 0483/2494] [feature/avatars] Add allow_avatar_gravatar to schema_data.sql PHPBB3-10018 --- phpBB/install/schemas/schema_data.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/phpBB/install/schemas/schema_data.sql b/phpBB/install/schemas/schema_data.sql index dbb5fd7481..262221fcf3 100644 --- a/phpBB/install/schemas/schema_data.sql +++ b/phpBB/install/schemas/schema_data.sql @@ -9,6 +9,7 @@ INSERT INTO phpbb_config (config_name, config_value) VALUES ('active_sessions', INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_attachments', '1'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_autologin', '1'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_avatar', '1'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_avatar_gravatar', '0'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_avatar_local', '0'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_avatar_remote', '0'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_avatar_upload', '1'); From ce44e3908eef5166e5e3e43d2642c5372379b6a6 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 25 Nov 2012 00:54:34 +0100 Subject: [PATCH 0484/2494] [feature/avatars] Remove unnecessary abbreviations PHPBB3-10018 --- .../style/acp_avatar_options_gravatar.html | 10 +++---- phpBB/adm/style/acp_avatar_options_local.html | 28 ++++++++--------- .../adm/style/acp_avatar_options_remote.html | 10 +++---- .../adm/style/acp_avatar_options_upload.html | 8 ++--- phpBB/adm/style/acp_groups.html | 6 ++-- phpBB/adm/style/acp_users_avatar.html | 6 ++-- phpBB/adm/style/avatars.js | 4 +-- phpBB/includes/acp/acp_groups.php | 16 +++++----- phpBB/includes/acp/acp_users.php | 16 +++++----- phpBB/includes/avatar/driver/gravatar.php | 12 ++++---- phpBB/includes/avatar/driver/local.php | 30 +++++++++---------- phpBB/includes/avatar/driver/remote.php | 12 ++++---- phpBB/includes/avatar/driver/upload.php | 8 ++--- phpBB/includes/ucp/ucp_groups.php | 16 +++++----- phpBB/includes/ucp/ucp_profile.php | 16 +++++----- phpBB/styles/prosilver/template/avatars.js | 4 +-- .../template/ucp_avatar_options.html | 6 ++-- .../template/ucp_avatar_options_gravatar.html | 10 +++---- .../template/ucp_avatar_options_local.html | 22 +++++++------- .../template/ucp_avatar_options_remote.html | 10 +++---- .../template/ucp_avatar_options_upload.html | 8 ++--- phpBB/styles/subsilver2/template/avatars.js | 4 +-- .../template/ucp_avatar_options_gravatar.html | 6 ++-- .../template/ucp_avatar_options_local.html | 26 ++++++++-------- .../template/ucp_avatar_options_remote.html | 4 +-- .../template/ucp_avatar_options_upload.html | 4 +-- .../template/ucp_groups_manage.html | 6 ++-- .../template/ucp_profile_avatar.html | 6 ++-- 28 files changed, 157 insertions(+), 157 deletions(-) diff --git a/phpBB/adm/style/acp_avatar_options_gravatar.html b/phpBB/adm/style/acp_avatar_options_gravatar.html index 5629e873cf..04fd5c459d 100644 --- a/phpBB/adm/style/acp_avatar_options_gravatar.html +++ b/phpBB/adm/style/acp_avatar_options_gravatar.html @@ -1,11 +1,11 @@
    -

    {L_GRAVATAR_AVATAR_EMAIL_EXPLAIN}
    -
    +

    {L_GRAVATAR_AVATAR_EMAIL_EXPLAIN}
    +
    -

    {L_GRAVATAR_AVATAR_SIZE_EXPLAIN}
    +

    {L_GRAVATAR_AVATAR_SIZE_EXPLAIN}
    - ×  - + ×  +
    diff --git a/phpBB/adm/style/acp_avatar_options_local.html b/phpBB/adm/style/acp_avatar_options_local.html index 08ec170195..927c4821f7 100644 --- a/phpBB/adm/style/acp_avatar_options_local.html +++ b/phpBB/adm/style/acp_avatar_options_local.html @@ -1,25 +1,25 @@
    -
    - - - -  
    + + + +  
    - + - + - - - + + + - - - + + + - +
    {av_local_row.av_local_col.AVATAR_NAME}{avatar_local_row.avatar_local_col.AVATAR_NAME}
    diff --git a/phpBB/adm/style/acp_avatar_options_remote.html b/phpBB/adm/style/acp_avatar_options_remote.html index cf3eb20a39..ab91e90c27 100644 --- a/phpBB/adm/style/acp_avatar_options_remote.html +++ b/phpBB/adm/style/acp_avatar_options_remote.html @@ -1,11 +1,11 @@
    -

    {L_LINK_REMOTE_AVATAR_EXPLAIN}
    -
    +

    {L_LINK_REMOTE_AVATAR_EXPLAIN}
    +
    -

    {L_LINK_REMOTE_SIZE_EXPLAIN}
    +

    {L_LINK_REMOTE_SIZE_EXPLAIN}
    - ×  - + ×  +
    diff --git a/phpBB/adm/style/acp_avatar_options_upload.html b/phpBB/adm/style/acp_avatar_options_upload.html index d0a4f516e1..9d3efbd018 100644 --- a/phpBB/adm/style/acp_avatar_options_upload.html +++ b/phpBB/adm/style/acp_avatar_options_upload.html @@ -1,11 +1,11 @@
    -
    -
    +
    +
    -

    {L_UPLOAD_AVATAR_URL_EXPLAIN}
    -
    +

    {L_UPLOAD_AVATAR_URL_EXPLAIN}
    +
    diff --git a/phpBB/adm/style/acp_groups.html b/phpBB/adm/style/acp_groups.html index a4699571d6..bab30a7b6f 100644 --- a/phpBB/adm/style/acp_groups.html +++ b/phpBB/adm/style/acp_groups.html @@ -105,7 +105,7 @@

    {L_AVATAR_EXPLAIN}
    {AVATAR}
    -
    +
    @@ -116,9 +116,9 @@
    -
    +
    -
    +

    {avatar_drivers.L_EXPLAIN}

    {avatar_drivers.OUTPUT}
    diff --git a/phpBB/adm/style/acp_users_avatar.html b/phpBB/adm/style/acp_users_avatar.html index e32d8f379b..bc3a19a25e 100644 --- a/phpBB/adm/style/acp_users_avatar.html +++ b/phpBB/adm/style/acp_users_avatar.html @@ -6,7 +6,7 @@

    {L_AVATAR_EXPLAIN}
    {AVATAR}
    -
    +
    @@ -20,9 +20,9 @@
    -
    +
    -
    +

    {avatar_drivers.L_EXPLAIN}

    {avatar_drivers.OUTPUT}
    diff --git a/phpBB/adm/style/avatars.js b/phpBB/adm/style/avatars.js index 2068bdbbc4..882bcfe36d 100644 --- a/phpBB/adm/style/avatars.js +++ b/phpBB/adm/style/avatars.js @@ -3,10 +3,10 @@ "use strict"; function avatar_simplify() { - $('#av_options > div').hide(); + $('#avatar_options > div').hide(); var selected = $('#avatar_driver').val(); - $('#av_option_' + selected).show(); + $('#avatar_option_' + selected).show(); } avatar_simplify(); diff --git a/phpBB/includes/acp/acp_groups.php b/phpBB/includes/acp/acp_groups.php index f461555056..3a49ac8ff8 100644 --- a/phpBB/includes/acp/acp_groups.php +++ b/phpBB/includes/acp/acp_groups.php @@ -335,8 +335,8 @@ class acp_groups // Handle avatar $driver = str_replace('_', '.', request_var('avatar_driver', '')); $config_name = preg_replace('#^avatar.driver.#', '', $driver); - $av_delete = $request->variable('av_delete', ''); - if (in_array($driver, $avatar_drivers) && $config["allow_avatar_$config_name"] && empty($av_delete)) + $avatar_delete = $request->variable('avatar_delete', ''); + if (in_array($driver, $avatar_drivers) && $config["allow_avatar_$config_name"] && empty($avatar_delete)) { $avatar = $phpbb_avatar_manager->get_driver($driver); $result = $avatar->process_form($template, $avatar_data, $avatar_error); @@ -541,14 +541,14 @@ class acp_groups if ($avatar->prepare_form($template, $avatar_data, $avatar_error)) { - $driver_n = str_replace('.', '_', $driver); - $driver_u = strtoupper($driver_n); + $driver_name = str_replace('.', '_', $driver); + $driver_upper = strtoupper($driver_name); $template->assign_block_vars('avatar_drivers', array( - 'L_TITLE' => $user->lang($driver_u . '_TITLE'), - 'L_EXPLAIN' => $user->lang($driver_u . '_EXPLAIN'), + 'L_TITLE' => $user->lang($driver_upper . '_TITLE'), + 'L_EXPLAIN' => $user->lang($driver_upper . '_EXPLAIN'), - 'DRIVER' => $driver_n, - 'SELECTED' => ($driver == $focused_driver), + 'DRIVER' => $driver_name, + 'SELECTED' => $driver == $focused_driver, 'OUTPUT' => $template->assign_display('avatar'), )); } diff --git a/phpBB/includes/acp/acp_users.php b/phpBB/includes/acp/acp_users.php index fdad1df0fd..2f7662982a 100644 --- a/phpBB/includes/acp/acp_users.php +++ b/phpBB/includes/acp/acp_users.php @@ -1746,8 +1746,8 @@ class acp_users { $driver = str_replace('_', '.', request_var('avatar_driver', '')); $config_name = preg_replace('#^avatar.driver.#', '', $driver); - $av_delete = $request->variable('av_delete', ''); - if (in_array($driver, $avatar_drivers) && $config["allow_avatar_$config_name"] && empty($av_delete)) + $avatar_delete = $request->variable('avatar_delete', ''); + if (in_array($driver, $avatar_drivers) && $config["allow_avatar_$config_name"] && empty($avatar_delete)) { $avatar = $phpbb_avatar_manager->get_driver($driver); $result = $avatar->process_form($template, $avatar_data, $error); @@ -1814,15 +1814,15 @@ class acp_users if ($avatar->prepare_form($template, $avatar_data, $error)) { - $driver_n = str_replace('.', '_', $driver); - $driver_u = strtoupper($driver_n); + $driver_name = str_replace('.', '_', $driver); + $driver_upper = strtoupper($driver_name); $template->assign_block_vars('avatar_drivers', array( - 'L_TITLE' => $user->lang($driver_u . '_TITLE'), - 'L_EXPLAIN' => $user->lang($driver_u . '_EXPLAIN'), + 'L_TITLE' => $user->lang($driver_upper . '_TITLE'), + 'L_EXPLAIN' => $user->lang($driver_upper . '_EXPLAIN'), - 'DRIVER' => $driver_n, - 'SELECTED' => ($driver == $focused_driver), + 'DRIVER' => $driver_name, + 'SELECTED' => $driver == $focused_driver, 'OUTPUT' => $template->assign_display('avatar'), )); } diff --git a/phpBB/includes/avatar/driver/gravatar.php b/phpBB/includes/avatar/driver/gravatar.php index 58ac535e6b..d873f7ba41 100644 --- a/phpBB/includes/avatar/driver/gravatar.php +++ b/phpBB/includes/avatar/driver/gravatar.php @@ -69,9 +69,9 @@ class phpbb_avatar_driver_gravatar extends phpbb_avatar_driver public function prepare_form($template, $row, &$error) { $template->assign_vars(array( - 'AV_GRAVATAR_WIDTH' => (($row['avatar_type'] == $this->get_name() || $row['avatar_type'] == 'gravatar') && $row['avatar_width']) ? $row['avatar_width'] : $this->request->variable('av_gravatar_width', 0), - 'AV_GRAVATAR_HEIGHT' => (($row['avatar_type'] == $this->get_name() || $row['avatar_type'] == 'gravatar') && $row['avatar_height']) ? $row['avatar_height'] : $this->request->variable('av_gravatar_width', 0), - 'AV_GRAVATAR_EMAIL' => (($row['avatar_type'] == $this->get_name() || $row['avatar_type'] == 'gravatar') && $row['avatar']) ? $row['avatar'] : '', + 'AVATAR_GRAVATAR_WIDTH' => (($row['avatar_type'] == $this->get_name() || $row['avatar_type'] == 'gravatar') && $row['avatar_width']) ? $row['avatar_width'] : $this->request->variable('avatar_gravatar_width', 0), + 'AVATAR_GRAVATAR_HEIGHT' => (($row['avatar_type'] == $this->get_name() || $row['avatar_type'] == 'gravatar') && $row['avatar_height']) ? $row['avatar_height'] : $this->request->variable('avatar_gravatar_width', 0), + 'AVATAR_GRAVATAR_EMAIL' => (($row['avatar_type'] == $this->get_name() || $row['avatar_type'] == 'gravatar') && $row['avatar']) ? $row['avatar'] : '', )); return true; @@ -92,9 +92,9 @@ class phpbb_avatar_driver_gravatar extends phpbb_avatar_driver */ public function process_form($template, $row, &$error) { - $row['avatar'] = $this->request->variable('av_gravatar_email', ''); - $row['avatar_width'] = $this->request->variable('av_gravatar_width', 0); - $row['avatar_height'] = $this->request->variable('av_gravatar_height', 0); + $row['avatar'] = $this->request->variable('avatar_gravatar_email', ''); + $row['avatar_width'] = $this->request->variable('avatar_gravatar_width', 0); + $row['avatar_height'] = $this->request->variable('avatar_gravatar_height', 0); require_once($this->phpbb_root_path . 'includes/functions_user' . $this->phpEx); diff --git a/phpBB/includes/avatar/driver/local.php b/phpBB/includes/avatar/driver/local.php index 8ac511f909..c231206d8e 100644 --- a/phpBB/includes/avatar/driver/local.php +++ b/phpBB/includes/avatar/driver/local.php @@ -50,13 +50,13 @@ class phpbb_avatar_driver_local extends phpbb_avatar_driver public function prepare_form($template, $row, &$error) { $avatar_list = $this->get_avatar_list(); - $category = $this->request->variable('av_local_cat', ''); + $category = $this->request->variable('avatar_local_cat', ''); foreach ($avatar_list as $cat => $null) { if (!empty($avatar_list[$cat])) { - $template->assign_block_vars('av_local_cats', array( + $template->assign_block_vars('avatar_local_cats', array( 'NAME' => $cat, 'SELECTED' => ($cat == $category), )); @@ -71,16 +71,16 @@ class phpbb_avatar_driver_local extends phpbb_avatar_driver if (!empty($avatar_list[$category])) { $template->assign_vars(array( - 'AV_LOCAL_SHOW' => true, + 'AVATAR_LOCAL_SHOW' => true, )); - $table_cols = isset($row['av_gallery_cols']) ? $row['av_gallery_cols'] : 4; - $row_count = $col_count = $av_pos = 0; - $av_count = sizeof($avatar_list[$category]); + $table_cols = isset($row['avatar_gallery_cols']) ? $row['avatar_gallery_cols'] : 4; + $row_count = $col_count = $avatar_pos = 0; + $avatar_count = sizeof($avatar_list[$category]); reset($avatar_list[$category]); - while ($av_pos < $av_count) + while ($avatar_pos < $avatar_count) { $img = current($avatar_list[$category]); next($avatar_list[$category]); @@ -88,24 +88,24 @@ class phpbb_avatar_driver_local extends phpbb_avatar_driver if ($col_count == 0) { ++$row_count; - $template->assign_block_vars('av_local_row', array( + $template->assign_block_vars('avatar_local_row', array( )); } - $template->assign_block_vars('av_local_row.av_local_col', array( + $template->assign_block_vars('avatar_local_row.avatar_local_col', array( 'AVATAR_IMAGE' => $this->phpbb_root_path . $this->config['avatar_gallery_path'] . '/' . $img['file'], 'AVATAR_NAME' => $img['name'], 'AVATAR_FILE' => $img['filename'], )); - $template->assign_block_vars('av_local_row.av_local_option', array( + $template->assign_block_vars('avatar_local_row.avatar_local_option', array( 'AVATAR_FILE' => $img['filename'], 'S_OPTIONS_AVATAR' => $img['filename'] )); $col_count = ($col_count + 1) % $table_cols; - ++$av_pos; + ++$avatar_pos; } } @@ -129,9 +129,9 @@ class phpbb_avatar_driver_local extends phpbb_avatar_driver public function process_form($template, $row, &$error) { $avatar_list = $this->get_avatar_list(); - $category = $this->request->variable('av_local_cat', ''); + $category = $this->request->variable('avatar_local_cat', ''); - $file = $this->request->variable('av_local_file', ''); + $file = $this->request->variable('avatar_local_file', ''); if (!isset($avatar_list[$category][urldecode($file)])) { $error[] = 'AVATAR_URL_NOT_FOUND'; @@ -152,7 +152,7 @@ class phpbb_avatar_driver_local extends phpbb_avatar_driver */ protected function get_avatar_list() { - $avatar_list = ($this->cache == null) ? false : $this->cache->get('av_local_list'); + $avatar_list = ($this->cache == null) ? false : $this->cache->get('avatar_local_list'); if (!$avatar_list) { @@ -190,7 +190,7 @@ class phpbb_avatar_driver_local extends phpbb_avatar_driver if ($this->cache != null) { - $this->cache->put('av_local_list', $avatar_list); + $this->cache->put('avatar_local_list', $avatar_list); } } diff --git a/phpBB/includes/avatar/driver/remote.php b/phpBB/includes/avatar/driver/remote.php index 61ea0ebaf0..c2ae88cc02 100644 --- a/phpBB/includes/avatar/driver/remote.php +++ b/phpBB/includes/avatar/driver/remote.php @@ -50,9 +50,9 @@ class phpbb_avatar_driver_remote extends phpbb_avatar_driver public function prepare_form($template, $row, &$error) { $template->assign_vars(array( - 'AV_REMOTE_WIDTH' => ((in_array($row['avatar_type'], array(AVATAR_REMOTE, $this->get_name(), 'remote'))) && $row['avatar_width']) ? $row['avatar_width'] : $this->request->variable('av_remote_width', 0), - 'AV_REMOTE_HEIGHT' => ((in_array($row['avatar_type'], array(AVATAR_REMOTE, $this->get_name(), 'remote'))) && $row['avatar_height']) ? $row['avatar_height'] : $this->request->variable('av_remote_width', 0), - 'AV_REMOTE_URL' => ((in_array($row['avatar_type'], array(AVATAR_REMOTE, $this->get_name(), 'remote'))) && $row['avatar']) ? $row['avatar'] : '', + 'AVATAR_REMOTE_WIDTH' => ((in_array($row['avatar_type'], array(AVATAR_REMOTE, $this->get_name(), 'remote'))) && $row['avatar_width']) ? $row['avatar_width'] : $this->request->variable('avatar_remote_width', 0), + 'AVATAR_REMOTE_HEIGHT' => ((in_array($row['avatar_type'], array(AVATAR_REMOTE, $this->get_name(), 'remote'))) && $row['avatar_height']) ? $row['avatar_height'] : $this->request->variable('avatar_remote_width', 0), + 'AVATAR_REMOTE_URL' => ((in_array($row['avatar_type'], array(AVATAR_REMOTE, $this->get_name(), 'remote'))) && $row['avatar']) ? $row['avatar'] : '', )); return true; @@ -73,9 +73,9 @@ class phpbb_avatar_driver_remote extends phpbb_avatar_driver */ public function process_form($template, $row, &$error) { - $url = $this->request->variable('av_remote_url', ''); - $width = $this->request->variable('av_remote_width', 0); - $height = $this->request->variable('av_remote_height', 0); + $url = $this->request->variable('avatar_remote_url', ''); + $width = $this->request->variable('avatar_remote_width', 0); + $height = $this->request->variable('avatar_remote_height', 0); if (!preg_match('#^(http|https|ftp)://#i', $url)) { diff --git a/phpBB/includes/avatar/driver/upload.php b/phpBB/includes/avatar/driver/upload.php index 77cd81c8c9..9035b5364e 100644 --- a/phpBB/includes/avatar/driver/upload.php +++ b/phpBB/includes/avatar/driver/upload.php @@ -56,7 +56,7 @@ class phpbb_avatar_driver_upload extends phpbb_avatar_driver $template->assign_vars(array( 'S_UPLOAD_AVATAR_URL' => ($this->config['allow_avatar_remote_upload']) ? true : false, - 'AV_UPLOAD_SIZE' => $this->config['avatar_filesize'], + 'AVATAR_UPLOAD_SIZE' => $this->config['avatar_filesize'], )); return true; @@ -76,12 +76,12 @@ class phpbb_avatar_driver_upload extends phpbb_avatar_driver $upload = new fileupload('AVATAR_', array('jpg', 'jpeg', 'gif', 'png'), $this->config['avatar_filesize'], $this->config['avatar_min_width'], $this->config['avatar_min_height'], $this->config['avatar_max_width'], $this->config['avatar_max_height'], (isset($this->config['mime_triggers']) ? explode('|', $this->config['mime_triggers']) : false)); - $url = $this->request->variable('av_upload_url', ''); - $upload_file = $this->request->file('av_upload_file'); + $url = $this->request->variable('avatar_upload_url', ''); + $upload_file = $this->request->file('avatar_upload_file'); if (!empty($upload_file['name'])) { - $file = $upload->form_upload('av_upload_file'); + $file = $upload->form_upload('avatar_upload_file'); } else { diff --git a/phpBB/includes/ucp/ucp_groups.php b/phpBB/includes/ucp/ucp_groups.php index 1d469814b6..2a388d17f8 100644 --- a/phpBB/includes/ucp/ucp_groups.php +++ b/phpBB/includes/ucp/ucp_groups.php @@ -522,8 +522,8 @@ class ucp_groups // Handle avatar $driver = str_replace('_', '.', request_var('avatar_driver', '')); $config_name = preg_replace('#^avatar.driver.#', '', $driver); - $av_delete = $request->variable('av_delete', ''); - if (in_array($driver, $avatar_drivers) && $config["allow_avatar_$config_name"] && empty($av_delete)) + $avatar_delete = $request->variable('avatar_delete', ''); + if (in_array($driver, $avatar_drivers) && $config["allow_avatar_$config_name"] && empty($avatar_delete)) { $avatar = $phpbb_avatar_manager->get_driver($driver); $result = $avatar->process_form($template, $avatar_data, $avatar_error); @@ -666,14 +666,14 @@ class ucp_groups if ($avatar->prepare_form($template, $avatar_data, $avatar_error)) { - $driver_n = str_replace('.', '_', $driver); - $driver_u = strtoupper($driver_n); + $driver_name = str_replace('.', '_', $driver); + $driver_upper = strtoupper($driver_name); $template->assign_block_vars('avatar_drivers', array( - 'L_TITLE' => $user->lang($driver_u . '_TITLE'), - 'L_EXPLAIN' => $user->lang($driver_u . '_EXPLAIN'), + 'L_TITLE' => $user->lang($driver_upper . '_TITLE'), + 'L_EXPLAIN' => $user->lang($driver_upper . '_EXPLAIN'), - 'DRIVER' => $driver_n, - 'SELECTED' => ($driver == $focused_driver), + 'DRIVER' => $driver_name, + 'SELECTED' => $driver == $focused_driver, 'OUTPUT' => $template->assign_display('avatar'), )); } diff --git a/phpBB/includes/ucp/ucp_profile.php b/phpBB/includes/ucp/ucp_profile.php index 77b2dc7054..ab49a11f99 100644 --- a/phpBB/includes/ucp/ucp_profile.php +++ b/phpBB/includes/ucp/ucp_profile.php @@ -565,8 +565,8 @@ class ucp_profile { $driver = str_replace('_', '.', request_var('avatar_driver', '')); $config_name = preg_replace('#^avatar.driver.#', '', $driver); - $av_delete = $request->variable('av_delete', ''); - if (in_array($driver, $avatar_drivers) && $config["allow_avatar_$config_name"] && empty($av_delete)) + $avatar_delete = $request->variable('avatar_delete', ''); + if (in_array($driver, $avatar_drivers) && $config["allow_avatar_$config_name"] && empty($avatar_delete)) { $avatar = $phpbb_avatar_manager->get_driver($driver); $result = $avatar->process_form($template, $avatar_data, $error); @@ -638,15 +638,15 @@ class ucp_profile if ($avatar->prepare_form($template, $avatar_data, $error)) { - $driver_n = str_replace('.', '_', $driver); - $driver_u = strtoupper($driver_n); + $driver_name = str_replace('.', '_', $driver); + $driver_upper = strtoupper($driver_name); $template->assign_block_vars('avatar_drivers', array( - 'L_TITLE' => $user->lang($driver_u . '_TITLE'), - 'L_EXPLAIN' => $user->lang($driver_u . '_EXPLAIN'), + 'L_TITLE' => $user->lang($driver_upper . '_TITLE'), + 'L_EXPLAIN' => $user->lang($driver_upper . '_EXPLAIN'), - 'DRIVER' => $driver_n, - 'SELECTED' => ($driver == $focused_driver), + 'DRIVER' => $driver_name, + 'SELECTED' => $driver == $focused_driver, 'OUTPUT' => $template->assign_display('avatar'), )); } diff --git a/phpBB/styles/prosilver/template/avatars.js b/phpBB/styles/prosilver/template/avatars.js index 2068bdbbc4..882bcfe36d 100644 --- a/phpBB/styles/prosilver/template/avatars.js +++ b/phpBB/styles/prosilver/template/avatars.js @@ -3,10 +3,10 @@ "use strict"; function avatar_simplify() { - $('#av_options > div').hide(); + $('#avatar_options > div').hide(); var selected = $('#avatar_driver').val(); - $('#av_option_' + selected).show(); + $('#avatar_option_' + selected).show(); } avatar_simplify(); diff --git a/phpBB/styles/prosilver/template/ucp_avatar_options.html b/phpBB/styles/prosilver/template/ucp_avatar_options.html index 354ddcc69c..e7f4a48e11 100644 --- a/phpBB/styles/prosilver/template/ucp_avatar_options.html +++ b/phpBB/styles/prosilver/template/ucp_avatar_options.html @@ -9,7 +9,7 @@

    {L_AVATAR_EXPLAIN}
    {AVATAR}
    -
    +

    {L_AVATAR_SELECT}

    @@ -24,9 +24,9 @@ -
    +
    -
    +
    diff --git a/phpBB/styles/prosilver/template/ucp_avatar_options_gravatar.html b/phpBB/styles/prosilver/template/ucp_avatar_options_gravatar.html index 5629e873cf..04fd5c459d 100644 --- a/phpBB/styles/prosilver/template/ucp_avatar_options_gravatar.html +++ b/phpBB/styles/prosilver/template/ucp_avatar_options_gravatar.html @@ -1,11 +1,11 @@
    -

    {L_GRAVATAR_AVATAR_EMAIL_EXPLAIN}
    -
    +

    {L_GRAVATAR_AVATAR_EMAIL_EXPLAIN}
    +
    -

    {L_GRAVATAR_AVATAR_SIZE_EXPLAIN}
    +

    {L_GRAVATAR_AVATAR_SIZE_EXPLAIN}
    - ×  - + ×  +
    diff --git a/phpBB/styles/prosilver/template/ucp_avatar_options_local.html b/phpBB/styles/prosilver/template/ucp_avatar_options_local.html index 8b46dfa7f5..d885abcd5b 100644 --- a/phpBB/styles/prosilver/template/ucp_avatar_options_local.html +++ b/phpBB/styles/prosilver/template/ucp_avatar_options_local.html @@ -1,16 +1,16 @@ - - + diff --git a/phpBB/styles/prosilver/template/ucp_avatar_options_remote.html b/phpBB/styles/prosilver/template/ucp_avatar_options_remote.html index cf3eb20a39..ab91e90c27 100644 --- a/phpBB/styles/prosilver/template/ucp_avatar_options_remote.html +++ b/phpBB/styles/prosilver/template/ucp_avatar_options_remote.html @@ -1,11 +1,11 @@
    -

    {L_LINK_REMOTE_AVATAR_EXPLAIN}
    -
    +

    {L_LINK_REMOTE_AVATAR_EXPLAIN}
    +
    -

    {L_LINK_REMOTE_SIZE_EXPLAIN}
    +

    {L_LINK_REMOTE_SIZE_EXPLAIN}
    - ×  - + ×  +
    diff --git a/phpBB/styles/prosilver/template/ucp_avatar_options_upload.html b/phpBB/styles/prosilver/template/ucp_avatar_options_upload.html index d0a4f516e1..9d3efbd018 100644 --- a/phpBB/styles/prosilver/template/ucp_avatar_options_upload.html +++ b/phpBB/styles/prosilver/template/ucp_avatar_options_upload.html @@ -1,11 +1,11 @@
    -
    -
    +
    +
    -

    {L_UPLOAD_AVATAR_URL_EXPLAIN}
    -
    +

    {L_UPLOAD_AVATAR_URL_EXPLAIN}
    +
    diff --git a/phpBB/styles/subsilver2/template/avatars.js b/phpBB/styles/subsilver2/template/avatars.js index a9b2cc5722..df6aad178a 100644 --- a/phpBB/styles/subsilver2/template/avatars.js +++ b/phpBB/styles/subsilver2/template/avatars.js @@ -3,10 +3,10 @@ "use strict"; function avatar_simplify() { - $('.[class^="av_option_"]').hide(); + $('.[class^="avatar_option_"]').hide(); var selected = $('#avatar_driver').val(); - $('.av_option_' + selected).show(); + $('.avatar_option_' + selected).show(); } avatar_simplify(); diff --git a/phpBB/styles/subsilver2/template/ucp_avatar_options_gravatar.html b/phpBB/styles/subsilver2/template/ucp_avatar_options_gravatar.html index 9bf8a3fc39..b8840e0aab 100644 --- a/phpBB/styles/subsilver2/template/ucp_avatar_options_gravatar.html +++ b/phpBB/styles/subsilver2/template/ucp_avatar_options_gravatar.html @@ -1,13 +1,13 @@ - +
    {L_GRAVATAR_AVATAR_EMAIL}{L_COLON}
    {L_GRAVATAR_AVATAR_EMAIL_EXPLAIN}
    {L_GRAVATAR_AVATAR_SIZE}{L_COLON}
    {L_GRAVATAR_AVATAR_SIZE_EXPLAIN}
    - {L_PIXEL} ×  - {L_PIXEL} + {L_PIXEL} ×  + {L_PIXEL}
    diff --git a/phpBB/styles/subsilver2/template/ucp_avatar_options_local.html b/phpBB/styles/subsilver2/template/ucp_avatar_options_local.html index 352052f9f4..f4273192ad 100644 --- a/phpBB/styles/subsilver2/template/ucp_avatar_options_local.html +++ b/phpBB/styles/subsilver2/template/ucp_avatar_options_local.html @@ -1,32 +1,32 @@ - diff --git a/phpBB/styles/subsilver2/template/ucp_avatar_options_remote.html b/phpBB/styles/subsilver2/template/ucp_avatar_options_remote.html index 8fe7201953..50ebb9b93d 100644 --- a/phpBB/styles/subsilver2/template/ucp_avatar_options_remote.html +++ b/phpBB/styles/subsilver2/template/ucp_avatar_options_remote.html @@ -1,10 +1,10 @@
    {L_AVATAR_CATEGORY}{L_COLON} {L_AVATAR_CATEGORY}{L_COLON}   + + + +  
    - + - - - + + + - - - + + + - +
    {av_local_col.av_local_col.AVATAR_NAME}{avatar_local_col.avatar_local_col.AVATAR_NAME}
    {L_NO_AVATAR_CATEGORY}
    - + - +
    {L_LINK_REMOTE_AVATAR}{L_COLON}
    {L_LINK_REMOTE_AVATAR_EXPLAIN}
    {L_LINK_REMOTE_SIZE}{L_COLON}
    {L_LINK_REMOTE_SIZE_EXPLAIN}
    {L_PIXEL} × {L_PIXEL} {L_PIXEL} × {L_PIXEL}
    diff --git a/phpBB/styles/subsilver2/template/ucp_avatar_options_upload.html b/phpBB/styles/subsilver2/template/ucp_avatar_options_upload.html index e76abc0433..6b813baeaa 100644 --- a/phpBB/styles/subsilver2/template/ucp_avatar_options_upload.html +++ b/phpBB/styles/subsilver2/template/ucp_avatar_options_upload.html @@ -1,12 +1,12 @@ - + - +
    {L_UPLOAD_AVATAR_FILE}{L_COLON}
    {L_UPLOAD_AVATAR_URL}{L_COLON}
    {L_UPLOAD_AVATAR_URL_EXPLAIN}
    diff --git a/phpBB/styles/subsilver2/template/ucp_groups_manage.html b/phpBB/styles/subsilver2/template/ucp_groups_manage.html index e15335f4e1..8064e1e6e9 100644 --- a/phpBB/styles/subsilver2/template/ucp_groups_manage.html +++ b/phpBB/styles/subsilver2/template/ucp_groups_manage.html @@ -60,7 +60,7 @@
    {L_AVATAR_EXPLAIN} - {AVATAR_IMAGE}

     {L_DELETE_AVATAR} + {AVATAR_IMAGE}

     {L_DELETE_AVATAR} @@ -81,10 +81,10 @@ - + {avatar_drivers.L_EXPLAIN} - + {avatar_drivers.OUTPUT} diff --git a/phpBB/styles/subsilver2/template/ucp_profile_avatar.html b/phpBB/styles/subsilver2/template/ucp_profile_avatar.html index 4e65b37e3c..4c7458e940 100644 --- a/phpBB/styles/subsilver2/template/ucp_profile_avatar.html +++ b/phpBB/styles/subsilver2/template/ucp_profile_avatar.html @@ -12,7 +12,7 @@ {L_CURRENT_IMAGE}{L_COLON}
    {L_AVATAR_EXPLAIN}
    - {AVATAR}

     {L_DELETE_AVATAR} + {AVATAR}

     {L_DELETE_AVATAR} @@ -35,10 +35,10 @@ - + {avatar_drivers.L_EXPLAIN} - + {avatar_drivers.OUTPUT} From 7945ffa2a131c1539a4aa929039c4d44b8e4d336 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 25 Nov 2012 01:02:43 +0100 Subject: [PATCH 0485/2494] [feature/avatars] Use new avatar types in database updater PHPBB3-10018 --- phpBB/install/database_update.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 2015ef0475..d471833442 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -2714,9 +2714,9 @@ function change_database_data(&$no_updates, $version) // Update avatars to modular types $avatar_type_map = array( - AVATAR_UPLOAD => 'upload', - AVATAR_GALLERY => 'local', - AVATAR_REMOTE => 'remote', + AVATAR_UPLOAD => 'avatar.driver.upload', + AVATAR_GALLERY => 'avatar.driver.local', + AVATAR_REMOTE => 'avatar.driver.remote', ); foreach ($avatar_type_map as $old => $new) From ce5e2f16777ae5319fcb902ee58005a4caced7e6 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 25 Nov 2012 01:18:27 +0100 Subject: [PATCH 0486/2494] [feature/avatars] Miscellaneous fixes PHPBB3-10018 --- phpBB/includes/acp/acp_groups.php | 14 ++++++++------ phpBB/includes/acp/acp_users.php | 12 +++++++----- phpBB/includes/avatar/driver/gravatar.php | 5 ++--- phpBB/includes/avatar/driver/remote.php | 2 +- phpBB/includes/ucp/ucp_groups.php | 2 +- phpBB/includes/ucp/ucp_profile.php | 2 +- phpBB/install/database_update.php | 20 ++++++++++---------- 7 files changed, 30 insertions(+), 27 deletions(-) diff --git a/phpBB/includes/acp/acp_groups.php b/phpBB/includes/acp/acp_groups.php index 3a49ac8ff8..7a66f993b0 100644 --- a/phpBB/includes/acp/acp_groups.php +++ b/phpBB/includes/acp/acp_groups.php @@ -334,7 +334,7 @@ class acp_groups { // Handle avatar $driver = str_replace('_', '.', request_var('avatar_driver', '')); - $config_name = preg_replace('#^avatar.driver.#', '', $driver); + $config_name = preg_replace('#^avatar\.driver.#', '', $driver); $avatar_delete = $request->variable('avatar_delete', ''); if (in_array($driver, $avatar_drivers) && $config["allow_avatar_$config_name"] && empty($avatar_delete)) { @@ -534,7 +534,7 @@ class acp_groups if ($avatar->is_enabled()) { $avatars_enabled = true; - $config_name = preg_replace('#^avatar.driver.#', '', $driver); + $config_name = preg_replace('#^avatar\.driver.#', '', $driver); $template->set_filenames(array( 'avatar' => "acp_avatar_options_$config_name.html", )); @@ -558,8 +558,10 @@ class acp_groups $avatar = get_group_avatar($group_row, 'GROUP_AVATAR', true); - // Merge any avatars errors into the primary error array - // Drivers use lang constants, so we need to map to the actual strings + /* + * Merge any avatar errors into the primary error array + * Drivers use language constants, so we need to map to the actual strings + */ foreach ($avatar_error as $e) { if (is_array($e)) @@ -569,7 +571,7 @@ class acp_groups } else { - $error[] = $user->lang((string) $e); + $error[] = $user->lang("$e"); } } @@ -615,7 +617,7 @@ class acp_groups 'S_RANK_OPTIONS' => $rank_options, 'S_GROUP_OPTIONS' => group_select_options(false, false, (($user->data['user_type'] == USER_FOUNDER) ? false : 0)), - 'AVATAR' => (empty($avatar) ? '' : $avatar), + 'AVATAR' => empty($avatar) ? '' : $avatar, 'AVATAR_MAX_FILESIZE' => $config['avatar_filesize'], 'AVATAR_WIDTH' => (isset($group_row['group_avatar_width'])) ? $group_row['group_avatar_width'] : '', 'AVATAR_HEIGHT' => (isset($group_row['group_avatar_height'])) ? $group_row['group_avatar_height'] : '', diff --git a/phpBB/includes/acp/acp_users.php b/phpBB/includes/acp/acp_users.php index 2f7662982a..8e194dc91d 100644 --- a/phpBB/includes/acp/acp_users.php +++ b/phpBB/includes/acp/acp_users.php @@ -454,7 +454,7 @@ class acp_users { trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); } - + $sql_ary = array( 'user_avatar' => '', 'user_avatar_type' => '', @@ -1745,7 +1745,7 @@ class acp_users if (check_form_key($form_name)) { $driver = str_replace('_', '.', request_var('avatar_driver', '')); - $config_name = preg_replace('#^avatar.driver.#', '', $driver); + $config_name = preg_replace('#^avatar\.driver.#', '', $driver); $avatar_delete = $request->variable('avatar_delete', ''); if (in_array($driver, $avatar_drivers) && $config["allow_avatar_$config_name"] && empty($avatar_delete)) { @@ -1761,6 +1761,7 @@ class acp_users 'user_avatar_width' => $result['avatar_width'], 'user_avatar_height' => $result['avatar_height'], ); + $sql = 'UPDATE ' . USERS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $result) . ' WHERE user_id = ' . $user_id; @@ -1771,7 +1772,8 @@ class acp_users } else { - if ($avatar = $phpbb_avatar_manager->get_driver($user->data['user_avatar_type'])) + $avatar = $phpbb_avatar_manager->get_driver($user->data['user_avatar_type']); + if ($avatar) { $avatar->delete($avatar_data); } @@ -1786,7 +1788,7 @@ class acp_users $sql = 'UPDATE ' . USERS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $result) . ' - WHERE user_id = ' . $user_id; + WHERE user_id = ' . (int) $user_id; $db->sql_query($sql); trigger_error($user->lang['USER_AVATAR_UPDATED'] . adm_back_link($this->u_action . '&u=' . $user_id)); @@ -1807,7 +1809,7 @@ class acp_users if ($avatar->is_enabled()) { $avatars_enabled = true; - $config_name = preg_replace('#^avatar.driver.#', '', $driver); + $config_name = preg_replace('#^avatar\.driver.#', '', $driver); $template->set_filenames(array( 'avatar' => "acp_avatar_options_$config_name.html", )); diff --git a/phpBB/includes/avatar/driver/gravatar.php b/phpBB/includes/avatar/driver/gravatar.php index d873f7ba41..cca7289275 100644 --- a/phpBB/includes/avatar/driver/gravatar.php +++ b/phpBB/includes/avatar/driver/gravatar.php @@ -56,11 +56,10 @@ class phpbb_avatar_driver_gravatar extends phpbb_avatar_driver */ public function get_custom_html($row, $ignore_config = false, $alt = '') { - $html = ''; - return $html; } /** @@ -121,7 +120,7 @@ class phpbb_avatar_driver_gravatar extends phpbb_avatar_driver $row['avatar_width'] = $row['avatar_height'] = min($this->config['avatar_max_width'], $this->config['avatar_max_height']); $url = $this->get_gravatar_url($row); - if (($row['avatar_width'] <= 0 || $row['avatar_height'] <= 0) && (($image_data = @getimagesize($url)) === false)) + if (($row['avatar_width'] <= 0 || $row['avatar_height'] <= 0) && (($image_data = getimagesize($url)) === false)) { $error[] = 'UNABLE_GET_IMAGE_SIZE'; return false; diff --git a/phpBB/includes/avatar/driver/remote.php b/phpBB/includes/avatar/driver/remote.php index c2ae88cc02..f47b0d33f4 100644 --- a/phpBB/includes/avatar/driver/remote.php +++ b/phpBB/includes/avatar/driver/remote.php @@ -106,7 +106,7 @@ class phpbb_avatar_driver_remote extends phpbb_avatar_driver // Make sure getimagesize works... if (function_exists('getimagesize')) { - if (($width <= 0 || $height <= 0) && (($image_data = @getimagesize($url)) === false)) + if (($width <= 0 || $height <= 0) && (($image_data = getimagesize($url)) === false)) { $error[] = 'UNABLE_GET_IMAGE_SIZE'; return false; diff --git a/phpBB/includes/ucp/ucp_groups.php b/phpBB/includes/ucp/ucp_groups.php index 2a388d17f8..5289a95e6d 100644 --- a/phpBB/includes/ucp/ucp_groups.php +++ b/phpBB/includes/ucp/ucp_groups.php @@ -521,7 +521,7 @@ class ucp_groups { // Handle avatar $driver = str_replace('_', '.', request_var('avatar_driver', '')); - $config_name = preg_replace('#^avatar.driver.#', '', $driver); + $config_name = preg_replace('#^avatar\.driver.#', '', $driver); $avatar_delete = $request->variable('avatar_delete', ''); if (in_array($driver, $avatar_drivers) && $config["allow_avatar_$config_name"] && empty($avatar_delete)) { diff --git a/phpBB/includes/ucp/ucp_profile.php b/phpBB/includes/ucp/ucp_profile.php index ab49a11f99..402db86c1d 100644 --- a/phpBB/includes/ucp/ucp_profile.php +++ b/phpBB/includes/ucp/ucp_profile.php @@ -564,7 +564,7 @@ class ucp_profile if (check_form_key('ucp_avatar')) { $driver = str_replace('_', '.', request_var('avatar_driver', '')); - $config_name = preg_replace('#^avatar.driver.#', '', $driver); + $config_name = preg_replace('#^avatar\.driver.#', '', $driver); $avatar_delete = $request->variable('avatar_delete', ''); if (in_array($driver, $avatar_drivers) && $config["allow_avatar_$config_name"] && empty($avatar_delete)) { diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index d471833442..b27613168f 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -2722,27 +2722,27 @@ function change_database_data(&$no_updates, $version) foreach ($avatar_type_map as $old => $new) { $sql = 'UPDATE ' . USERS_TABLE . " - SET user_avatar_type = '" . $db->sql_escape($new) . "' - WHERE user_avatar_type = '" . $db->sql_escape($old) . "'"; + SET user_avatar_type = '" . $new . "' + WHERE user_avatar_type = '" . $old . "'"; _sql($sql, $errored, $error_ary); $sql = 'UPDATE ' . GROUPS_TABLE . " - SET group_avatar_type = '" . $db->sql_escape($new) . "' - WHERE group_avatar_type = '" . $db->sql_escape($old) . "'"; + SET group_avatar_type = '" . $new . "' + WHERE group_avatar_type = '" . $old . "'"; _sql($sql, $errored, $error_ary); } // update avatar module_auth - $sql = 'UPDATE ' . MODULES_TABLE . ' - SET module_auth = \'cfg_allow_avatar && (cfg_allow_avatar_local || cfg_allow_avatar_remote || cfg_allow_avatar_upload || cfg_allow_avatar_remote_upload || cfg_allow_avatar_gravatar)\' - WHERE module_class = \'ucp\' - AND module_basename = \'ucp_profile\' - AND module_mode = \'avatar\''; + $sql = 'UPDATE ' . MODULES_TABLE . " + SET module_auth = 'cfg_allow_avatar && (cfg_allow_avatar_local || cfg_allow_avatar_remote || cfg_allow_avatar_upload || cfg_allow_avatar_remote_upload || cfg_allow_avatar_gravatar)' + WHERE module_class = 'ucp' + AND module_basename = 'ucp_profile' + AND module_mode = 'avatar'"; _sql($sql, $errored, $error_ary); if (!isset($config['allow_avatar_gravatar'])) { - $config->set('allow_avatar_gravatar', ''); + $config->set('allow_avatar_gravatar', '0'); } $no_updates = false; From 67c2e48d15d6e4ddd244dd2e126f906ed25be1ef Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 25 Nov 2012 14:33:13 +0100 Subject: [PATCH 0487/2494] [feature/avatars] Only create avatar objects if necessary PHPBB3-10018 --- phpBB/common.php | 2 -- phpBB/includes/acp/acp_board.php | 3 ++- phpBB/includes/acp/acp_groups.php | 3 ++- phpBB/includes/acp/acp_users.php | 5 ++++- phpBB/includes/functions_display.php | 3 ++- phpBB/includes/ucp/ucp_groups.php | 3 ++- phpBB/includes/ucp/ucp_profile.php | 3 ++- 7 files changed, 14 insertions(+), 8 deletions(-) diff --git a/phpBB/common.php b/phpBB/common.php index 17e7c76465..c4237dfcf5 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -128,8 +128,6 @@ $phpbb_subscriber_loader = $phpbb_container->get('event.subscriber_loader'); $template = $phpbb_container->get('template'); $phpbb_style = $phpbb_container->get('style'); -$phpbb_avatar_manager = $phpbb_container->get('avatar.manager'); - // Add own hook handler require($phpbb_root_path . 'includes/hooks/index.' . $phpEx); $phpbb_hook = new phpbb_hook(array('exit_handler', 'phpbb_user_session_handler', 'append_sid', array('phpbb_template', 'display'))); diff --git a/phpBB/includes/acp/acp_board.php b/phpBB/includes/acp/acp_board.php index 5852f512cd..95da62dedf 100644 --- a/phpBB/includes/acp/acp_board.php +++ b/phpBB/includes/acp/acp_board.php @@ -28,7 +28,7 @@ class acp_board { global $db, $user, $auth, $template; global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx; - global $cache, $phpbb_avatar_manager; + global $cache, $phpbb_container; $user->add_lang('acp/board'); @@ -107,6 +107,7 @@ class acp_board break; case 'avatar': + $phpbb_avatar_manager = $phpbb_container->get('avatar.manager'); $avatar_drivers = $phpbb_avatar_manager->get_valid_drivers(); sort($avatar_drivers); $avatar_vars = array(); diff --git a/phpBB/includes/acp/acp_groups.php b/phpBB/includes/acp/acp_groups.php index 7a66f993b0..c09f447f76 100644 --- a/phpBB/includes/acp/acp_groups.php +++ b/phpBB/includes/acp/acp_groups.php @@ -26,7 +26,7 @@ class acp_groups { global $config, $db, $user, $auth, $template, $cache; global $phpbb_root_path, $phpbb_admin_path, $phpEx, $table_prefix, $file_uploads; - global $request, $phpbb_avatar_manager; + global $request, $phpbb_container; $user->add_lang('acp/groups'); $this->tpl_name = 'acp_groups'; @@ -282,6 +282,7 @@ class acp_groups $user->add_lang('ucp'); // Setup avatar data for later + $phpbb_avatar_manager = $phpbb_container->get('avatar.manager'); $avatars_enabled = false; $avatar_drivers = null; $avatar_data = null; diff --git a/phpBB/includes/acp/acp_users.php b/phpBB/includes/acp/acp_users.php index 8e194dc91d..885233bbd3 100644 --- a/phpBB/includes/acp/acp_users.php +++ b/phpBB/includes/acp/acp_users.php @@ -33,7 +33,7 @@ class acp_users global $config, $db, $user, $auth, $template, $cache; global $phpbb_root_path, $phpbb_admin_path, $phpEx, $table_prefix, $file_uploads; global $phpbb_dispatcher, $request; - global $phpbb_avatar_manager; + global $phpbb_container; $user->add_lang(array('posting', 'ucp', 'acp/users')); $this->tpl_name = 'acp_users'; @@ -468,6 +468,7 @@ class acp_users $db->sql_query($sql); // Delete old avatar if present + $phpbb_avatar_manager = $phpbb_container->get('avatar.manager'); $driver = $phpbb_avatar_manager->get_driver($user_row['user_avatar_type']); if ($driver) { @@ -1732,6 +1733,8 @@ class acp_users include($phpbb_root_path . 'includes/functions_display.' . $phpEx); $avatars_enabled = false; + $phpbb_avatar_manager = $phpbb_container->get('avatar.manager'); + if ($config['allow_avatar']) { $avatar_drivers = $phpbb_avatar_manager->get_valid_drivers(); diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php index bf1611a5de..669641de70 100644 --- a/phpBB/includes/functions_display.php +++ b/phpBB/includes/functions_display.php @@ -1353,7 +1353,7 @@ function get_avatar($row, $alt, $ignore_config = false) { global $user, $config, $cache, $phpbb_root_path, $phpEx; global $request; - global $phpbb_avatar_manager; + global $phpbb_container; if (!$config['allow_avatar'] && !$ignore_config) { @@ -1366,6 +1366,7 @@ function get_avatar($row, $alt, $ignore_config = false) 'height' => $row['avatar_height'], ); + $phpbb_avatar_manager = $phpbb_container->get('avatar.manager'); $avatar = $phpbb_avatar_manager->get_driver($row['avatar_type']); if ($avatar) diff --git a/phpBB/includes/ucp/ucp_groups.php b/phpBB/includes/ucp/ucp_groups.php index 5289a95e6d..33f147a47e 100644 --- a/phpBB/includes/ucp/ucp_groups.php +++ b/phpBB/includes/ucp/ucp_groups.php @@ -27,7 +27,7 @@ class ucp_groups { global $config, $phpbb_root_path, $phpEx; global $db, $user, $auth, $cache, $template; - global $request, $phpbb_avatar_manager; + global $request, $phpbb_container; $user->add_lang('groups'); @@ -484,6 +484,7 @@ class ucp_groups $error = array(); // Setup avatar data for later + $phpbb_avatar_manager = $phpbb_container->get('avatar.manager'); $avatars_enabled = false; $avatar_drivers = null; $avatar_data = null; diff --git a/phpBB/includes/ucp/ucp_profile.php b/phpBB/includes/ucp/ucp_profile.php index 402db86c1d..3945fc537a 100644 --- a/phpBB/includes/ucp/ucp_profile.php +++ b/phpBB/includes/ucp/ucp_profile.php @@ -30,7 +30,7 @@ class ucp_profile { global $cache, $config, $db, $user, $auth, $template, $phpbb_root_path, $phpEx; global $request; - global $phpbb_avatar_manager; + global $phpbb_container; $user->add_lang('posting'); @@ -549,6 +549,7 @@ class ucp_profile add_form_key('ucp_avatar'); + $phpbb_avatar_manager = $phpbb_container->get('avatar.manager'); $avatars_enabled = false; if ($config['allow_avatar'] && $auth->acl_get('u_chgavatar')) From 6d061304afaa703a5305a06a903356d1c48ff2ee Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 25 Nov 2012 15:03:35 +0100 Subject: [PATCH 0488/2494] [feature/avatars] Small fixes PHPBB3-10018 --- phpBB/includes/acp/acp_groups.php | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/phpBB/includes/acp/acp_groups.php b/phpBB/includes/acp/acp_groups.php index c09f447f76..136ceeff3c 100644 --- a/phpBB/includes/acp/acp_groups.php +++ b/phpBB/includes/acp/acp_groups.php @@ -337,6 +337,7 @@ class acp_groups $driver = str_replace('_', '.', request_var('avatar_driver', '')); $config_name = preg_replace('#^avatar\.driver.#', '', $driver); $avatar_delete = $request->variable('avatar_delete', ''); + if (in_array($driver, $avatar_drivers) && $config["allow_avatar_$config_name"] && empty($avatar_delete)) { $avatar = $phpbb_avatar_manager->get_driver($driver); @@ -344,19 +345,15 @@ class acp_groups if ($result && empty($avatar_error)) { - $result = array( - 'avatar_type' => $driver, - 'avatar' => $result['avatar'], - 'avatar_width' => $result['avatar_width'], - 'avatar_height' => $result['avatar_height'], - ); + $result['avatar_type'] = $driver; $submit_ary = array_merge($submit_ary, $result); } } else { - if ($avatar = $phpbb_avatar_manager->get_driver($user->data['user_avatar_type'])) + $avatar = $phpbb_avatar_manager->get_driver($user->data['user_avatar_type']) + if ($avatar) { $avatar->delete($avatar_data); } From 06639729ea2da6d0025da74ae7d4f3e88f211b67 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 25 Nov 2012 16:04:59 +0100 Subject: [PATCH 0489/2494] [feature/avatars] Add static methods for handling driver names PHPBB3-10018 --- phpBB/includes/acp/acp_groups.php | 6 +++--- phpBB/includes/acp/acp_users.php | 6 +++--- phpBB/includes/avatar/manager.php | 26 ++++++++++++++++++++++++++ phpBB/includes/ucp/ucp_groups.php | 6 +++--- phpBB/includes/ucp/ucp_profile.php | 6 +++--- 5 files changed, 38 insertions(+), 12 deletions(-) diff --git a/phpBB/includes/acp/acp_groups.php b/phpBB/includes/acp/acp_groups.php index 136ceeff3c..2969f34b24 100644 --- a/phpBB/includes/acp/acp_groups.php +++ b/phpBB/includes/acp/acp_groups.php @@ -334,7 +334,7 @@ class acp_groups if ($config['allow_avatar']) { // Handle avatar - $driver = str_replace('_', '.', request_var('avatar_driver', '')); + $driver = $phpbb_avatar_manager->clean_driver_name($request->variable('avatar_driver', '')); $config_name = preg_replace('#^avatar\.driver.#', '', $driver); $avatar_delete = $request->variable('avatar_delete', ''); @@ -523,7 +523,7 @@ class acp_groups if ($config['allow_avatar']) { $avatars_enabled = false; - $focused_driver = str_replace('_', '.', request_var('avatar_driver', $avatar_data['avatar_type'])); + $focused_driver = $phpbb_avatar_manager->clean_driver_name($request->variable('avatar_driver', $avatar_data['avatar_type'])); foreach ($avatar_drivers as $driver) { @@ -539,7 +539,7 @@ class acp_groups if ($avatar->prepare_form($template, $avatar_data, $avatar_error)) { - $driver_name = str_replace('.', '_', $driver); + $driver_name = $phpbb_avatar_manager->prepare_driver_name($driver); $driver_upper = strtoupper($driver_name); $template->assign_block_vars('avatar_drivers', array( 'L_TITLE' => $user->lang($driver_upper . '_TITLE'), diff --git a/phpBB/includes/acp/acp_users.php b/phpBB/includes/acp/acp_users.php index 885233bbd3..44e4f14ae2 100644 --- a/phpBB/includes/acp/acp_users.php +++ b/phpBB/includes/acp/acp_users.php @@ -1747,7 +1747,7 @@ class acp_users { if (check_form_key($form_name)) { - $driver = str_replace('_', '.', request_var('avatar_driver', '')); + $driver = $phpbb_avatar_manager->clean_driver_name($request->variable('avatar_driver', '')); $config_name = preg_replace('#^avatar\.driver.#', '', $driver); $avatar_delete = $request->variable('avatar_delete', ''); if (in_array($driver, $avatar_drivers) && $config["allow_avatar_$config_name"] && empty($avatar_delete)) @@ -1803,7 +1803,7 @@ class acp_users } } - $focused_driver = str_replace('_', '.', request_var('avatar_driver', $user_row['user_avatar_type'])); + $focused_driver = $phpbb_avatar_manager->clean_driver_name($request->variable('avatar_driver', $user_row['user_avatar_type'])); foreach ($avatar_drivers as $driver) { @@ -1819,7 +1819,7 @@ class acp_users if ($avatar->prepare_form($template, $avatar_data, $error)) { - $driver_name = str_replace('.', '_', $driver); + $driver_name = $phpbb_avatar_manager->prepare_driver_name($driver); $driver_upper = strtoupper($driver_name); $template->assign_block_vars('avatar_drivers', array( diff --git a/phpBB/includes/avatar/manager.php b/phpBB/includes/avatar/manager.php index da9d843947..51727f242a 100644 --- a/phpBB/includes/avatar/manager.php +++ b/phpBB/includes/avatar/manager.php @@ -152,4 +152,30 @@ class phpbb_avatar_manager return array_combine($keys, $values); } + + /** + * Clean driver names that are returned from template files + * Underscores are replaced with dots + * + * @param string $name Driver name + * + * @return string Cleaned driver name + */ + public static function clean_driver_name($name) + { + return str_replace('_', '.', $name); + } + + /** + * Prepare driver names for use in template files + * Dots are replaced with underscores + * + * @param string $name Clean driver name + * + * @return string Prepared driver name + */ + public static function prepare_driver_name($name) + { + return str_replace('.', '_', $name); + } } diff --git a/phpBB/includes/ucp/ucp_groups.php b/phpBB/includes/ucp/ucp_groups.php index 33f147a47e..df6915711c 100644 --- a/phpBB/includes/ucp/ucp_groups.php +++ b/phpBB/includes/ucp/ucp_groups.php @@ -521,7 +521,7 @@ class ucp_groups if ($config['allow_avatar']) { // Handle avatar - $driver = str_replace('_', '.', request_var('avatar_driver', '')); + $driver = $phpbb_avatar_manager->clean_driver_name($request->variable('avatar_driver', '')); $config_name = preg_replace('#^avatar\.driver.#', '', $driver); $avatar_delete = $request->variable('avatar_delete', ''); if (in_array($driver, $avatar_drivers) && $config["allow_avatar_$config_name"] && empty($avatar_delete)) @@ -652,7 +652,7 @@ class ucp_groups if ($config['allow_avatar']) { $avatars_enabled = false; - $focused_driver = str_replace('_', '.', request_var('avatar_driver', $avatar_data['avatar_type'])); + $focused_driver = $phpbb_avatar_manager->clean_driver_name($request->variable('avatar_driver', $avatar_data['avatar_type'])); foreach ($avatar_drivers as $driver) { @@ -667,7 +667,7 @@ class ucp_groups if ($avatar->prepare_form($template, $avatar_data, $avatar_error)) { - $driver_name = str_replace('.', '_', $driver); + $driver_name = $phpbb_avatar_manager->prepare_driver_name($driver); $driver_upper = strtoupper($driver_name); $template->assign_block_vars('avatar_drivers', array( 'L_TITLE' => $user->lang($driver_upper . '_TITLE'), diff --git a/phpBB/includes/ucp/ucp_profile.php b/phpBB/includes/ucp/ucp_profile.php index 3945fc537a..36ac227bc8 100644 --- a/phpBB/includes/ucp/ucp_profile.php +++ b/phpBB/includes/ucp/ucp_profile.php @@ -564,7 +564,7 @@ class ucp_profile { if (check_form_key('ucp_avatar')) { - $driver = str_replace('_', '.', request_var('avatar_driver', '')); + $driver = $phpbb_avatar_manager->clean_driver_name($request->variable('avatar_driver', '')); $config_name = preg_replace('#^avatar\.driver.#', '', $driver); $avatar_delete = $request->variable('avatar_delete', ''); if (in_array($driver, $avatar_drivers) && $config["allow_avatar_$config_name"] && empty($avatar_delete)) @@ -624,7 +624,7 @@ class ucp_profile } } - $focused_driver = str_replace('_', '.', request_var('avatar_driver', $user->data['user_avatar_type'])); + $focused_driver = $phpbb_avatar_manager->clean_driver_name($request->variable('avatar_driver', $user->data['user_avatar_type'])); foreach ($avatar_drivers as $driver) { @@ -639,7 +639,7 @@ class ucp_profile if ($avatar->prepare_form($template, $avatar_data, $error)) { - $driver_name = str_replace('.', '_', $driver); + $driver_name = $phpbb_avatar_manager->prepare_driver_name($driver); $driver_upper = strtoupper($driver_name); $template->assign_block_vars('avatar_drivers', array( From f8256ed00f5ecc95fbf9f69fd2e8de2a92bccec6 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 25 Nov 2012 16:18:51 +0100 Subject: [PATCH 0490/2494] [feature/avatars] Small cosmetic changes PHPBB3-10018 --- phpBB/includes/acp/acp_groups.php | 3 +-- phpBB/includes/acp/acp_users.php | 4 ++-- phpBB/includes/ucp/ucp_groups.php | 13 ++++--------- phpBB/includes/ucp/ucp_profile.php | 4 ++-- 4 files changed, 9 insertions(+), 15 deletions(-) diff --git a/phpBB/includes/acp/acp_groups.php b/phpBB/includes/acp/acp_groups.php index 2969f34b24..a55087adce 100644 --- a/phpBB/includes/acp/acp_groups.php +++ b/phpBB/includes/acp/acp_groups.php @@ -336,9 +336,8 @@ class acp_groups // Handle avatar $driver = $phpbb_avatar_manager->clean_driver_name($request->variable('avatar_driver', '')); $config_name = preg_replace('#^avatar\.driver.#', '', $driver); - $avatar_delete = $request->variable('avatar_delete', ''); - if (in_array($driver, $avatar_drivers) && $config["allow_avatar_$config_name"] && empty($avatar_delete)) + if (in_array($driver, $avatar_drivers) && $config["allow_avatar_$config_name"] && !$request->is_set_post('avatar_delete')) { $avatar = $phpbb_avatar_manager->get_driver($driver); $result = $avatar->process_form($template, $avatar_data, $avatar_error); diff --git a/phpBB/includes/acp/acp_users.php b/phpBB/includes/acp/acp_users.php index 44e4f14ae2..823f001fe0 100644 --- a/phpBB/includes/acp/acp_users.php +++ b/phpBB/includes/acp/acp_users.php @@ -1749,8 +1749,8 @@ class acp_users { $driver = $phpbb_avatar_manager->clean_driver_name($request->variable('avatar_driver', '')); $config_name = preg_replace('#^avatar\.driver.#', '', $driver); - $avatar_delete = $request->variable('avatar_delete', ''); - if (in_array($driver, $avatar_drivers) && $config["allow_avatar_$config_name"] && empty($avatar_delete)) + + if (in_array($driver, $avatar_drivers) && $config["allow_avatar_$config_name"] && !$request->is_set_post('avatar_delete')) { $avatar = $phpbb_avatar_manager->get_driver($driver); $result = $avatar->process_form($template, $avatar_data, $error); diff --git a/phpBB/includes/ucp/ucp_groups.php b/phpBB/includes/ucp/ucp_groups.php index df6915711c..dd03f332ff 100644 --- a/phpBB/includes/ucp/ucp_groups.php +++ b/phpBB/includes/ucp/ucp_groups.php @@ -523,21 +523,16 @@ class ucp_groups // Handle avatar $driver = $phpbb_avatar_manager->clean_driver_name($request->variable('avatar_driver', '')); $config_name = preg_replace('#^avatar\.driver.#', '', $driver); - $avatar_delete = $request->variable('avatar_delete', ''); - if (in_array($driver, $avatar_drivers) && $config["allow_avatar_$config_name"] && empty($avatar_delete)) + + if (in_array($driver, $avatar_drivers) && $config["allow_avatar_$config_name"] && !$request->is_set_post('avatar_delete')) { $avatar = $phpbb_avatar_manager->get_driver($driver); $result = $avatar->process_form($template, $avatar_data, $avatar_error); if ($result && empty($avatar_error)) { - $result = array( - 'avatar_type' => $driver, - 'avatar' => $result['avatar'], - 'avatar_width' => $result['avatar_width'], - 'avatar_height' => $result['avatar_height'], - ); - + $result['avatar_type'] = $driver; + $submit_ary = array_merge($submit_ary, $result); } } diff --git a/phpBB/includes/ucp/ucp_profile.php b/phpBB/includes/ucp/ucp_profile.php index 36ac227bc8..88820beac1 100644 --- a/phpBB/includes/ucp/ucp_profile.php +++ b/phpBB/includes/ucp/ucp_profile.php @@ -566,8 +566,8 @@ class ucp_profile { $driver = $phpbb_avatar_manager->clean_driver_name($request->variable('avatar_driver', '')); $config_name = preg_replace('#^avatar\.driver.#', '', $driver); - $avatar_delete = $request->variable('avatar_delete', ''); - if (in_array($driver, $avatar_drivers) && $config["allow_avatar_$config_name"] && empty($avatar_delete)) + + if (in_array($driver, $avatar_drivers) && $config["allow_avatar_$config_name"] && !$request->is_set_post('avatar_delete')) { $avatar = $phpbb_avatar_manager->get_driver($driver); $result = $avatar->process_form($template, $avatar_data, $error); From a77fcdb5f93ed291c223c445a46a5641cfdb27ea Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 25 Nov 2012 17:01:21 +0100 Subject: [PATCH 0491/2494] [feature/avatars] Implement better treatment of avatar errors PHPBB3-10018 --- phpBB/includes/acp/acp_groups.php | 10 +++++----- phpBB/includes/acp/acp_users.php | 14 ++++++-------- phpBB/includes/ucp/ucp_groups.php | 10 +++++----- phpBB/includes/ucp/ucp_profile.php | 12 +++++------- 4 files changed, 21 insertions(+), 25 deletions(-) diff --git a/phpBB/includes/acp/acp_groups.php b/phpBB/includes/acp/acp_groups.php index a55087adce..19006df306 100644 --- a/phpBB/includes/acp/acp_groups.php +++ b/phpBB/includes/acp/acp_groups.php @@ -559,16 +559,16 @@ class acp_groups * Merge any avatar errors into the primary error array * Drivers use language constants, so we need to map to the actual strings */ - foreach ($avatar_error as $e) + foreach ($avatar_error as $lang) { - if (is_array($e)) + if (is_array($lang)) { - $key = array_shift($e); - $error[] = vsprintf($user->lang($key), $e); + $key = array_shift($lang); + $error[] = vsprintf($user->lang($key), $lang); } else { - $error[] = $user->lang("$e"); + $error[] = $user->lang("$lang"); } } diff --git a/phpBB/includes/acp/acp_users.php b/phpBB/includes/acp/acp_users.php index 823f001fe0..e0dcea6d58 100644 --- a/phpBB/includes/acp/acp_users.php +++ b/phpBB/includes/acp/acp_users.php @@ -1836,21 +1836,19 @@ class acp_users } // Replace "error" strings with their real, localised form - $err = $error; - $error = array(); - foreach ($err as $e) + foreach ($error as $key => $lang) { - if (is_array($e)) + if (is_array($lang)) { - $key = array_shift($e); - $error[] = vsprintf($user->lang($key), $e); + $lang_key = array_shift($lang); + $error[$key] = vsprintf($user->lang($lang_key), $lang); } else { - $error[] = $user->lang((string) $e); + $error[$key] = $user->lang("$lang"); } } - + $avatar = get_user_avatar($user_row, 'USER_AVATAR', true); $template->assign_vars(array( diff --git a/phpBB/includes/ucp/ucp_groups.php b/phpBB/includes/ucp/ucp_groups.php index dd03f332ff..3860d22917 100644 --- a/phpBB/includes/ucp/ucp_groups.php +++ b/phpBB/includes/ucp/ucp_groups.php @@ -679,16 +679,16 @@ class ucp_groups // Merge any avatars errors into the primary error array // Drivers use lang constants, so we need to map to the actual strings - foreach ($avatar_error as $e) + foreach ($avatar_error as $lang) { - if (is_array($e)) + if (is_array($lang)) { - $key = array_shift($e); - $error[] = vsprintf($user->lang($key), $e); + $key = array_shift($lang); + $error[] = vsprintf($user->lang($key), $lang); } else { - $error[] = $user->lang((string) $e); + $error[] = $user->lang("$lang"); } } diff --git a/phpBB/includes/ucp/ucp_profile.php b/phpBB/includes/ucp/ucp_profile.php index 88820beac1..c05105eaff 100644 --- a/phpBB/includes/ucp/ucp_profile.php +++ b/phpBB/includes/ucp/ucp_profile.php @@ -656,18 +656,16 @@ class ucp_profile } // Replace "error" strings with their real, localised form - $err = $error; - $error = array(); - foreach ($err as $e) + foreach ($error as $key => $lang) { - if (is_array($e)) + if (is_array($lang)) { - $key = array_shift($e); - $error[] = vsprintf($user->lang($key), $e); + $key = array_shift($lang); + $error[$key] = vsprintf($user->lang($key), $lang); } else { - $error[] = $user->lang((string) $e); + $error[$key] = $user->lang("$lang"); } } From 6522190ff1b7a7b4384389f23c1229911c1a58d2 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 25 Nov 2012 20:50:31 +0100 Subject: [PATCH 0492/2494] [feature/avatars] Docblock fixes and small change for php_ext PHPBB3-10018 --- phpBB/includes/avatar/driver/driver.php | 60 +++++++++++------------ phpBB/includes/avatar/driver/gravatar.php | 2 +- phpBB/includes/avatar/driver/remote.php | 4 +- phpBB/includes/avatar/driver/upload.php | 4 +- 4 files changed, 34 insertions(+), 36 deletions(-) diff --git a/phpBB/includes/avatar/driver/driver.php b/phpBB/includes/avatar/driver/driver.php index 710d3dfe20..c6b864bc9f 100644 --- a/phpBB/includes/avatar/driver/driver.php +++ b/phpBB/includes/avatar/driver/driver.php @@ -23,26 +23,6 @@ abstract class phpbb_avatar_driver implements phpbb_avatar_driver_interface { protected $name; - /** - * Returns the name of the driver. - * - * @return string Name of wrapped driver. - */ - public function get_name() - { - return $this->name; - } - - /** - * Sets the name of the driver. - * - * @param string $name The driver name - */ - public function set_name($name) - { - $this->name = $name; - } - /** * Current board configuration * @type phpbb_config @@ -50,8 +30,8 @@ abstract class phpbb_avatar_driver implements phpbb_avatar_driver_interface protected $config; /** - * Current board configuration - * @type phpbb_config + * Request object + * @type phpbb_request */ protected $request; @@ -62,10 +42,10 @@ abstract class phpbb_avatar_driver implements phpbb_avatar_driver_interface protected $phpbb_root_path; /** - * Current $phpEx + * Current $php_ext * @type string */ - protected $phpEx; + protected $php_ext; /** * A cache driver @@ -83,18 +63,18 @@ abstract class phpbb_avatar_driver implements phpbb_avatar_driver_interface /** * Construct a driver object * - * @param $config The phpBB configuration - * @param $request The request object - * @param $phpbb_root_path The path to the phpBB root - * @param $phpEx The php file extension - * @param $cache A cache driver + * @param phpbb_config $config The phpBB configuration + * @param phpbb_request $request The request object + * @param string $phpbb_root_path The path to the phpBB root + * @param string $php_ext The php file extension + * @param phpbb_cache_driver_interface $cache A cache driver */ - public function __construct(phpbb_config $config, phpbb_request $request, $phpbb_root_path, $phpEx, phpbb_cache_driver_interface $cache = null) + public function __construct(phpbb_config $config, phpbb_request $request, $phpbb_root_path, $php_ext, phpbb_cache_driver_interface $cache = null) { $this->config = $config; $this->request = $request; $this->phpbb_root_path = $phpbb_root_path; - $this->phpEx = $phpEx; + $this->php_ext = $php_ext; $this->cache = $cache; } @@ -170,4 +150,22 @@ abstract class phpbb_avatar_driver implements phpbb_avatar_driver_interface return $template; } + + /** + * @inheritdoc + */ + public function get_name() + { + return $this->name; + } + + /** + * Sets the name of the driver. + * + * @param string $name The driver name + */ + public function set_name($name) + { + $this->name = $name; + } } diff --git a/phpBB/includes/avatar/driver/gravatar.php b/phpBB/includes/avatar/driver/gravatar.php index cca7289275..e21743242f 100644 --- a/phpBB/includes/avatar/driver/gravatar.php +++ b/phpBB/includes/avatar/driver/gravatar.php @@ -95,7 +95,7 @@ class phpbb_avatar_driver_gravatar extends phpbb_avatar_driver $row['avatar_width'] = $this->request->variable('avatar_gravatar_width', 0); $row['avatar_height'] = $this->request->variable('avatar_gravatar_height', 0); - require_once($this->phpbb_root_path . 'includes/functions_user' . $this->phpEx); + require_once($this->phpbb_root_path . 'includes/functions_user' . $this->php_ext); $error = array_merge($error, validate_data(array( 'email' => $row['avatar'], diff --git a/phpBB/includes/avatar/driver/remote.php b/phpBB/includes/avatar/driver/remote.php index f47b0d33f4..134bf070e5 100644 --- a/phpBB/includes/avatar/driver/remote.php +++ b/phpBB/includes/avatar/driver/remote.php @@ -82,7 +82,7 @@ class phpbb_avatar_driver_remote extends phpbb_avatar_driver $url = 'http://' . $url; } - require_once($this->phpbb_root_path . 'includes/functions_user' . $this->phpEx); + require_once($this->phpbb_root_path . 'includes/functions_user' . $this->php_ext); $error = array_merge($error, validate_data(array( 'url' => $url, @@ -128,7 +128,7 @@ class phpbb_avatar_driver_remote extends phpbb_avatar_driver return false; } - include_once($this->phpbb_root_path . 'includes/functions_upload' . $this->phpEx); + include_once($this->phpbb_root_path . 'includes/functions_upload' . $this->php_ext); $types = fileupload::image_types(); $extension = strtolower(filespec::get_extension($url)); diff --git a/phpBB/includes/avatar/driver/upload.php b/phpBB/includes/avatar/driver/upload.php index 9035b5364e..91de47e66d 100644 --- a/phpBB/includes/avatar/driver/upload.php +++ b/phpBB/includes/avatar/driver/upload.php @@ -29,7 +29,7 @@ class phpbb_avatar_driver_upload extends phpbb_avatar_driver if ($ignore_config || $this->config['allow_avatar_upload']) { return array( - 'src' => $this->phpbb_root_path . 'download/file' . $this->phpEx . '?avatar=' . $row['avatar'], + 'src' => $this->phpbb_root_path . 'download/file' . $this->php_ext . '?avatar=' . $row['avatar'], 'width' => $row['avatar_width'], 'height' => $row['avatar_height'], ); @@ -72,7 +72,7 @@ class phpbb_avatar_driver_upload extends phpbb_avatar_driver return false; } - include_once($this->phpbb_root_path . 'includes/functions_upload' . $this->phpEx); + include_once($this->phpbb_root_path . 'includes/functions_upload' . $this->php_ext); $upload = new fileupload('AVATAR_', array('jpg', 'jpeg', 'gif', 'png'), $this->config['avatar_filesize'], $this->config['avatar_min_width'], $this->config['avatar_min_height'], $this->config['avatar_max_width'], $this->config['avatar_max_height'], (isset($this->config['mime_triggers']) ? explode('|', $this->config['mime_triggers']) : false)); From f851d763f9997b896219d1068dd23f6de7dbfc36 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 25 Nov 2012 21:14:05 +0100 Subject: [PATCH 0493/2494] [feature/avatars] Even more fixes to docblocks PHPBB3-10018 --- phpBB/includes/avatar/driver/driver.php | 42 ++++++++++++---------- phpBB/includes/avatar/driver/gravatar.php | 4 +-- phpBB/includes/avatar/driver/interface.php | 38 ++++++++++---------- phpBB/includes/avatar/driver/local.php | 4 +-- phpBB/includes/avatar/driver/remote.php | 2 +- phpBB/includes/avatar/driver/upload.php | 2 +- phpBB/includes/avatar/manager.php | 34 +++++++++--------- 7 files changed, 65 insertions(+), 61 deletions(-) diff --git a/phpBB/includes/avatar/driver/driver.php b/phpBB/includes/avatar/driver/driver.php index c6b864bc9f..234186215b 100644 --- a/phpBB/includes/avatar/driver/driver.php +++ b/phpBB/includes/avatar/driver/driver.php @@ -21,53 +21,57 @@ if (!defined('IN_PHPBB')) */ abstract class phpbb_avatar_driver implements phpbb_avatar_driver_interface { + /** + * Avatar driver name + * @var string + */ protected $name; /** * Current board configuration - * @type phpbb_config + * @var phpbb_config */ protected $config; /** * Request object - * @type phpbb_request + * @var phpbb_request */ protected $request; /** * Current $phpbb_root_path - * @type string + * @var string */ protected $phpbb_root_path; /** * Current $php_ext - * @type string + * @var string */ protected $php_ext; /** - * A cache driver - * @type phpbb_cache_driver_interface + * Cache driver + * @var phpbb_cache_driver_interface */ protected $cache; /** * This flag should be set to true if the avatar requires a nonstandard image * tag, and will generate the html itself. - * @type boolean + * @var boolean */ public $custom_html = false; /** * Construct a driver object * - * @param phpbb_config $config The phpBB configuration - * @param phpbb_request $request The request object - * @param string $phpbb_root_path The path to the phpBB root - * @param string $php_ext The php file extension - * @param phpbb_cache_driver_interface $cache A cache driver + * @param phpbb_config $config phpBB configuration + * @param phpbb_request $request Request object + * @param string $phpbb_root_path Path to the phpBB root + * @param string $php_ext PHP file extension + * @param phpbb_cache_driver_interface $cache Cache driver */ public function __construct(phpbb_config $config, phpbb_request $request, $phpbb_root_path, $php_ext, phpbb_cache_driver_interface $cache = null) { @@ -100,7 +104,7 @@ abstract class phpbb_avatar_driver implements phpbb_avatar_driver_interface /** * @inheritdoc - **/ + */ public function prepare_form($template, $row, &$error) { return false; @@ -108,7 +112,7 @@ abstract class phpbb_avatar_driver implements phpbb_avatar_driver_interface /** * @inheritdoc - **/ + */ public function prepare_form_acp() { return array(); @@ -116,7 +120,7 @@ abstract class phpbb_avatar_driver implements phpbb_avatar_driver_interface /** * @inheritdoc - **/ + */ public function process_form($template, $row, &$error) { return false; @@ -124,7 +128,7 @@ abstract class phpbb_avatar_driver implements phpbb_avatar_driver_interface /** * @inheritdoc - **/ + */ public function delete($row) { return true; @@ -132,7 +136,7 @@ abstract class phpbb_avatar_driver implements phpbb_avatar_driver_interface /** * @inheritdoc - **/ + */ public function is_enabled() { $driver = preg_replace('#^phpbb_avatar_driver_#', '', get_class($this)); @@ -142,7 +146,7 @@ abstract class phpbb_avatar_driver implements phpbb_avatar_driver_interface /** * @inheritdoc - **/ + */ public function get_template_name() { $driver = preg_replace('#^phpbb_avatar_driver_#', '', get_class($this)); @@ -162,7 +166,7 @@ abstract class phpbb_avatar_driver implements phpbb_avatar_driver_interface /** * Sets the name of the driver. * - * @param string $name The driver name + * @param string $name Driver name */ public function set_name($name) { diff --git a/phpBB/includes/avatar/driver/gravatar.php b/phpBB/includes/avatar/driver/gravatar.php index e21743242f..a90c0e3ce1 100644 --- a/phpBB/includes/avatar/driver/gravatar.php +++ b/phpBB/includes/avatar/driver/gravatar.php @@ -78,7 +78,7 @@ class phpbb_avatar_driver_gravatar extends phpbb_avatar_driver /** * @inheritdoc - **/ + */ public function prepare_form_acp() { return array( @@ -170,7 +170,7 @@ class phpbb_avatar_driver_gravatar extends phpbb_avatar_driver /** * Build gravatar URL for output on page * - * @return string The gravatar URL + * @return string Gravatar URL */ protected function get_gravatar_url($row) { diff --git a/phpBB/includes/avatar/driver/interface.php b/phpBB/includes/avatar/driver/interface.php index 28220d79f2..cc6b7edd17 100644 --- a/phpBB/includes/avatar/driver/interface.php +++ b/phpBB/includes/avatar/driver/interface.php @@ -24,7 +24,7 @@ interface phpbb_avatar_driver_interface /** * Returns the name of the driver. * - * @return string Name of wrapped driver. + * @return string Name of wrapped driver. */ public function get_name(); @@ -43,7 +43,7 @@ interface phpbb_avatar_driver_interface * Returns custom html for displaying this avatar. * Only called if $custom_html is true. * - * @param $ignore_config Whether this function should respect the users prefs + * @param bool $ignore_config Whether this function should respect the users prefs * and board configuration configuration option, or should just render * the avatar anyways. Useful for the ACP. * @return string HTML @@ -53,56 +53,56 @@ interface phpbb_avatar_driver_interface /** * Prepare form for changing the settings of this avatar * - * @param object $template The template object - * @param array $row The user data or group data that has been cleaned with + * @param object $template Template object + * @param array $row User data or group data that has been cleaned with * phpbb_avatar_manager::clean_row - * @param array &$error The reference to an error array + * @param array &$error Reference to an error array * - * @return bool Returns true if form has been successfully prepared - **/ + * @return bool True if form has been successfully prepared + */ public function prepare_form($template, $row, &$error); /** * Prepare form for changing the acp settings of this avatar * - * @return array Return the array containing the acp settings - **/ + * @return array Array containing the acp settings + */ public function prepare_form_acp(); /** * Process form data * - * @param object $template The template object - * @param array $row The user data or group data that has been cleaned with + * @param object $template Template object + * @param array $row User data or group data that has been cleaned with * phpbb_avatar_manager::clean_row - * @param array &$error The reference to an error array + * @param array &$error Reference to an error array * - * @return array An array containing the avatar data as follows: + * @return array Array containing the avatar data as follows: * ['avatar'], ['avatar_width'], ['avatar_height'] - **/ + */ public function process_form($template, $row, &$error); /** * Delete avatar * - * @param array $row The user data or group data that has been cleaned with + * @param array $row User data or group data that has been cleaned with * phpbb_avatar_manager::clean_row * * @return bool True if avatar has been deleted or there is no need to delete - **/ + */ public function delete($row); /** * Check if avatar is enabled * * @return bool True if avatar is enabled, false if it's disabled - **/ + */ public function is_enabled(); /** * Get the avatars template name * - * @return string The avatars template name - **/ + * @return string Avatar's template name + */ public function get_template_name(); } diff --git a/phpBB/includes/avatar/driver/local.php b/phpBB/includes/avatar/driver/local.php index c231206d8e..d46ac79d11 100644 --- a/phpBB/includes/avatar/driver/local.php +++ b/phpBB/includes/avatar/driver/local.php @@ -114,7 +114,7 @@ class phpbb_avatar_driver_local extends phpbb_avatar_driver /** * @inheritdoc - **/ + */ public function prepare_form_acp() { return array( @@ -148,7 +148,7 @@ class phpbb_avatar_driver_local extends phpbb_avatar_driver /** * Get a list of avatars that are locally available * - * @return array An array containing the locally available avatars + * @return array Array containing the locally available avatars */ protected function get_avatar_list() { diff --git a/phpBB/includes/avatar/driver/remote.php b/phpBB/includes/avatar/driver/remote.php index 134bf070e5..b7522ac3e1 100644 --- a/phpBB/includes/avatar/driver/remote.php +++ b/phpBB/includes/avatar/driver/remote.php @@ -60,7 +60,7 @@ class phpbb_avatar_driver_remote extends phpbb_avatar_driver /** * @inheritdoc - **/ + */ public function prepare_form_acp() { return array( diff --git a/phpBB/includes/avatar/driver/upload.php b/phpBB/includes/avatar/driver/upload.php index 91de47e66d..f00033d6bd 100644 --- a/phpBB/includes/avatar/driver/upload.php +++ b/phpBB/includes/avatar/driver/upload.php @@ -124,7 +124,7 @@ class phpbb_avatar_driver_upload extends phpbb_avatar_driver /** * @inheritdoc - **/ + */ public function prepare_form_acp() { global $user; diff --git a/phpBB/includes/avatar/manager.php b/phpBB/includes/avatar/manager.php index 51727f242a..ae628f0ce2 100644 --- a/phpBB/includes/avatar/manager.php +++ b/phpBB/includes/avatar/manager.php @@ -32,14 +32,14 @@ class phpbb_avatar_manager /** * Construct an avatar manager object * - * @param $phpbb_root_path The path to the phpBB root - * @param $phpEx The php file extension - * @param $config The phpBB configuration - * @param $request The request object - * @param $cache A cache driver - * @param $avatar_drivers The avatars drivers passed via the service container - * @param $container The container object - **/ + * @param string $phpbb_root_path Path to the phpBB root + * @param string $phpEx PHP file extension + * @param phpbb_config $config phpBB configuration + * @param phpbb_request $request Request object + * @param phpbb_cache_driver_interface $cache Cache driver + * @param array $avatar_drivers Avatar drivers passed via the service container + * @param object $container Container object + */ public function __construct($phpbb_root_path, $phpEx, phpbb_config $config, phpbb_request $request, phpbb_cache_driver_interface $cache, $avatar_drivers, $container) { $this->phpbb_root_path = $phpbb_root_path; @@ -54,10 +54,10 @@ class phpbb_avatar_manager /** * Get the driver object specified by the avatar type * - * @param string The avatar type; by default an avatar's service container name + * @param string Avatar type; by default an avatar's service container name * - * @return object The avatar driver object - **/ + * @return object Avatar driver object + */ public function get_driver($avatar_type) { if (self::$valid_drivers === false) @@ -101,7 +101,7 @@ class phpbb_avatar_manager /** * Load the list of valid drivers * This is executed once and fills self::$valid_drivers - **/ + */ protected function load_valid_drivers() { if (!empty($this->avatar_drivers)) @@ -117,8 +117,8 @@ class phpbb_avatar_manager /** * Get a list of valid avatar drivers * - * @return array An array containing a list of the valid avatar drivers - **/ + * @return array Array containing a list of the valid avatar drivers + */ public function get_valid_drivers() { if (self::$valid_drivers === false) @@ -132,11 +132,11 @@ class phpbb_avatar_manager /** * Strip out user_ and group_ prefixes from keys * - * @param array $row The user data or group data + * @param array $row User data or group data * - * @return array The user data or group data with keys that have been + * @return array User data or group data with keys that have been * stripped from the preceding "user_" or "group_" - **/ + */ public static function clean_row($row) { $keys = array_keys($row); From 0abec06b09c71feb709b6101949181ff7ec4d882 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 25 Nov 2012 21:16:21 +0100 Subject: [PATCH 0494/2494] [feature/avatars] Change gravatar explain as discussed in PR PHPBB3-10018 --- phpBB/language/en/ucp.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/language/en/ucp.php b/phpBB/language/en/ucp.php index d397ca5538..7223b13b29 100644 --- a/phpBB/language/en/ucp.php +++ b/phpBB/language/en/ucp.php @@ -90,7 +90,7 @@ $lang = array_merge($lang, array( 'AUTOLOGIN_SESSION_KEYS_DELETED'=> 'The selected persistent login keys were successfully deleted.', 'AVATAR_CATEGORY' => 'Category', 'AVATAR_DRIVER_GRAVATAR_TITLE' => 'Gravatar', - 'AVATAR_DRIVER_GRAVATAR_EXPLAIN'=> 'Gravatar is a service that provides you with a globally unique avatar.', + 'AVATAR_DRIVER_GRAVATAR_EXPLAIN'=> 'Gravatar is a service that allows you to maintain the same avatar across multiple websites. Visit Gravatar for more information.', 'AVATAR_DRIVER_LOCAL_TITLE' => 'Gallery avatar', 'AVATAR_DRIVER_LOCAL_EXPLAIN' => 'You can choose your avatar from a locally available set of avatars.', 'AVATAR_DRIVER_REMOTE_TITLE' => 'Remote avatar', From cb1d98ab7f588a38fcae680aca839b805caf2a23 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 26 Nov 2012 23:06:38 +0100 Subject: [PATCH 0495/2494] [feature/avatars] Check for existing functions rather than using _once PHPBB3-10018 --- phpBB/includes/avatar/driver/gravatar.php | 5 ++++- phpBB/includes/avatar/driver/remote.php | 11 +++++++++-- phpBB/includes/avatar/driver/upload.php | 5 ++++- phpBB/includes/ucp/ucp_profile.php | 5 ++++- 4 files changed, 21 insertions(+), 5 deletions(-) diff --git a/phpBB/includes/avatar/driver/gravatar.php b/phpBB/includes/avatar/driver/gravatar.php index a90c0e3ce1..7e21a737a1 100644 --- a/phpBB/includes/avatar/driver/gravatar.php +++ b/phpBB/includes/avatar/driver/gravatar.php @@ -95,7 +95,10 @@ class phpbb_avatar_driver_gravatar extends phpbb_avatar_driver $row['avatar_width'] = $this->request->variable('avatar_gravatar_width', 0); $row['avatar_height'] = $this->request->variable('avatar_gravatar_height', 0); - require_once($this->phpbb_root_path . 'includes/functions_user' . $this->php_ext); + if (!function_exists('user_add')) + { + require($this->phpbb_root_path . 'includes/functions_user' . $this->php_ext); + } $error = array_merge($error, validate_data(array( 'email' => $row['avatar'], diff --git a/phpBB/includes/avatar/driver/remote.php b/phpBB/includes/avatar/driver/remote.php index b7522ac3e1..1da5fc16e8 100644 --- a/phpBB/includes/avatar/driver/remote.php +++ b/phpBB/includes/avatar/driver/remote.php @@ -82,7 +82,10 @@ class phpbb_avatar_driver_remote extends phpbb_avatar_driver $url = 'http://' . $url; } - require_once($this->phpbb_root_path . 'includes/functions_user' . $this->php_ext); + if (!function_exists('user_add')) + { + require($this->phpbb_root_path . 'includes/functions_user' . $this->php_ext); + } $error = array_merge($error, validate_data(array( 'url' => $url, @@ -128,7 +131,11 @@ class phpbb_avatar_driver_remote extends phpbb_avatar_driver return false; } - include_once($this->phpbb_root_path . 'includes/functions_upload' . $this->php_ext); + if (!class_exists('fileupload')) + { + include_once($this->phpbb_root_path . 'includes/functions_upload' . $this->php_ext); + } + $types = fileupload::image_types(); $extension = strtolower(filespec::get_extension($url)); diff --git a/phpBB/includes/avatar/driver/upload.php b/phpBB/includes/avatar/driver/upload.php index f00033d6bd..497dd8ad19 100644 --- a/phpBB/includes/avatar/driver/upload.php +++ b/phpBB/includes/avatar/driver/upload.php @@ -72,7 +72,10 @@ class phpbb_avatar_driver_upload extends phpbb_avatar_driver return false; } - include_once($this->phpbb_root_path . 'includes/functions_upload' . $this->php_ext); + if (!class_exists('fileupload')) + { + include_once($this->phpbb_root_path . 'includes/functions_upload' . $this->php_ext); + } $upload = new fileupload('AVATAR_', array('jpg', 'jpeg', 'gif', 'png'), $this->config['avatar_filesize'], $this->config['avatar_min_width'], $this->config['avatar_min_height'], $this->config['avatar_max_width'], $this->config['avatar_max_height'], (isset($this->config['mime_triggers']) ? explode('|', $this->config['mime_triggers']) : false)); diff --git a/phpBB/includes/ucp/ucp_profile.php b/phpBB/includes/ucp/ucp_profile.php index c05105eaff..c8547e48d8 100644 --- a/phpBB/includes/ucp/ucp_profile.php +++ b/phpBB/includes/ucp/ucp_profile.php @@ -545,7 +545,10 @@ class ucp_profile break; case 'avatar': - include_once($phpbb_root_path . 'includes/functions_display.' . $phpEx); + if (!function_exists('display_forums')) + { + include($phpbb_root_path . 'includes/functions_display.' . $phpEx); + } add_form_key('ucp_avatar'); From 29f7e729ed389f4312dbe8455d927a4bc2204f35 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Tue, 27 Nov 2012 11:11:50 -0500 Subject: [PATCH 0496/2494] [feature/template-events] Order extensions in mock extension manager. PHPBB3-9550 --- tests/mock/filesystem_extension_manager.php | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/mock/filesystem_extension_manager.php b/tests/mock/filesystem_extension_manager.php index 3332e2b82d..c5a51bbb3f 100644 --- a/tests/mock/filesystem_extension_manager.php +++ b/tests/mock/filesystem_extension_manager.php @@ -26,6 +26,7 @@ class phpbb_mock_filesystem_extension_manager extends phpbb_mock_extension_manag $extensions[$name] = $extension; } } + ksort($extensions); parent::__construct($phpbb_root_path, $extensions); } } From 83e85810aa7b04b992c8c24ec8b2eac700c4594e Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Tue, 6 Nov 2012 14:28:46 -0500 Subject: [PATCH 0497/2494] [ticket/11095] Use get method in jumpboxes. PHPBB3-11095 --- phpBB/styles/prosilver/template/jumpbox.html | 2 +- phpBB/styles/subsilver2/template/jumpbox.html | 2 +- phpBB/styles/subsilver2/template/mcp_jumpbox.html | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/phpBB/styles/prosilver/template/jumpbox.html b/phpBB/styles/prosilver/template/jumpbox.html index ff234464dc..562c115495 100644 --- a/phpBB/styles/prosilver/template/jumpbox.html +++ b/phpBB/styles/prosilver/template/jumpbox.html @@ -10,7 +10,7 @@ - +
    diff --git a/phpBB/styles/subsilver2/template/jumpbox.html b/phpBB/styles/subsilver2/template/jumpbox.html index f4153d7692..0a11524813 100644 --- a/phpBB/styles/subsilver2/template/jumpbox.html +++ b/phpBB/styles/subsilver2/template/jumpbox.html @@ -1,6 +1,6 @@ - + diff --git a/phpBB/styles/subsilver2/template/mcp_jumpbox.html b/phpBB/styles/subsilver2/template/mcp_jumpbox.html index 734222bc77..0e3433e3d6 100644 --- a/phpBB/styles/subsilver2/template/mcp_jumpbox.html +++ b/phpBB/styles/subsilver2/template/mcp_jumpbox.html @@ -1,6 +1,6 @@ - +{L_JUMP_TO}{L_COLON} "; + } + } + return $hidden; +} + /** * Generate page header */ function page_header($page_title = '', $display_online_list = true, $item_id = 0, $item = 'forum') { global $db, $config, $template, $SID, $_SID, $_EXTRA_URL, $user, $auth, $phpEx, $phpbb_root_path; - global $phpbb_dispatcher; + global $phpbb_dispatcher, $request; if (defined('HEADER_INC')) { @@ -5135,6 +5169,8 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0 $timezone_name = $user->lang['timezones'][$timezone_name]; } + $hidden_fields_for_jumpbox = phpbb_build_hidden_fields_for_query_params($request, array('f')); + // The following assigns all _common_ variables that may be used at any point in a template. $template->assign_vars(array( 'SITENAME' => $config['sitename'], @@ -5149,6 +5185,7 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0 'RECORD_USERS' => $l_online_record, 'PRIVATE_MESSAGE_INFO' => $l_privmsgs_text, 'PRIVATE_MESSAGE_INFO_UNREAD' => $l_privmsgs_text_unread, + 'HIDDEN_FIELDS_FOR_JUMPBOX' => $hidden_fields_for_jumpbox, 'S_USER_NEW_PRIVMSG' => $user->data['user_new_privmsg'], 'S_USER_UNREAD_PRIVMSG' => $user->data['user_unread_privmsg'], @@ -5507,7 +5544,8 @@ function phpbb_to_numeric($input) function phpbb_create_symfony_request(phpbb_request $request) { // This function is meant to sanitize the global input arrays - $sanitizer = function(&$value, $key) { + $sanitizer = function(&$value, $key) + { $type_cast_helper = new phpbb_request_type_cast_helper(); $type_cast_helper->set_var($value, $value, gettype($value), true); }; diff --git a/phpBB/styles/prosilver/template/jumpbox.html b/phpBB/styles/prosilver/template/jumpbox.html index 562c115495..dd793fbadc 100644 --- a/phpBB/styles/prosilver/template/jumpbox.html +++ b/phpBB/styles/prosilver/template/jumpbox.html @@ -17,6 +17,7 @@
    + {HIDDEN_FIELDS_FOR_JUMPBOX}
    -
    {L_SELECT_TOPICS_FROM}{L_MODERATE_FORUM}{L_JUMP_TO}{L_COLON} {HIDDEN_FIELDS_FOR_JUMPBOX}{L_SELECT_TOPICS_FROM}{L_MODERATE_FORUM}{L_JUMP_TO}{L_COLON}  From 3e907265d5782c535d43e503c32390cfde8dc4a8 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Thu, 29 Nov 2012 14:41:48 -0500 Subject: [PATCH 0500/2494] [ticket/11095] Docs and tests for phpbb_build_hidden_fields_for_query_params. PHPBB3-11095 --- phpBB/includes/functions.php | 14 ++++ ...ld_hidden_fields_for_query_params_test.php | 71 +++++++++++++++++++ 2 files changed, 85 insertions(+) create mode 100644 tests/functions/build_hidden_fields_for_query_params_test.php diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index ee5a1afd30..9c92adb0ec 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -4940,6 +4940,20 @@ function phpbb_quoteattr($data, $entities = null) return $data; } +/** +* Converts query string (GET) parameters in request into hidden fields. +* +* Useful for forwarding GET parameters when submitting forms with GET method. +* +* It is possible to omit some of the GET parameters, which is useful if +* they are specified in the form being submitted. +* +* sid is always omitted. +* +* @param phpbb_request $request Request object +* @param array $exclude A list of variable names that should not be forwarded +* @return string HTML with hidden fields +*/ function phpbb_build_hidden_fields_for_query_params($request, $exclude = null) { $names = $request->variable_names(phpbb_request_interface::GET); diff --git a/tests/functions/build_hidden_fields_for_query_params_test.php b/tests/functions/build_hidden_fields_for_query_params_test.php new file mode 100644 index 0000000000..ef2f5744d3 --- /dev/null +++ b/tests/functions/build_hidden_fields_for_query_params_test.php @@ -0,0 +1,71 @@ + 'bar'), + array(), + array(), + "", + ), + array( + array('foo' => 'bar', 'a' => 'b'), + array(), + array(), + "", + ), + array( + array('a' => 'quote"', 'b' => ''), + array(), + array(), + "", + ), + array( + array('a' => "quotes'\""), + array(), + array(), + "", + ), + array( + array('foo' => 'bar', 'a' => 'b'), + array('a' => 'c'), + array(), + "", + ), + // strict equality check + array( + array('foo' => 'bar', 'a' => '0'), + array('a' => ''), + array(), + "", + ), + ); + } + + /** + * @dataProvider build_hidden_fields_for_query_params_test_data + */ + public function test_build_hidden_fields_for_query_params($get, $post, $exclude, $expected) + { + $request = new phpbb_mock_request($get, $post); + $result = phpbb_build_hidden_fields_for_query_params($request, $exclude); + + $this->assertEquals($expected, $result); + } +} From 11ca272692ed1b46d4ff208705cb30636c98704f Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Thu, 29 Nov 2012 14:42:56 -0500 Subject: [PATCH 0501/2494] [ticket/11095] Restore brace on previous line. PHPBB3-11095 --- phpBB/includes/functions.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 9c92adb0ec..8df40b26f6 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -5558,8 +5558,7 @@ function phpbb_to_numeric($input) function phpbb_create_symfony_request(phpbb_request $request) { // This function is meant to sanitize the global input arrays - $sanitizer = function(&$value, $key) - { + $sanitizer = function(&$value, $key) { $type_cast_helper = new phpbb_request_type_cast_helper(); $type_cast_helper->set_var($value, $value, gettype($value), true); }; From 81a1a21185abfc230097a355216d6c6b99511b20 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Thu, 29 Nov 2012 23:08:29 +0100 Subject: [PATCH 0502/2494] [feature/avatars] Properly implement custom HTML in the interface Previously the driver class added a variable that defined wether an avatar driver would return custom HTML. The existence of this variable was implied in the interface. It's also not needed which is why it has been removed. PHPBB3-10018 --- phpBB/includes/avatar/driver/driver.php | 7 ------- phpBB/includes/avatar/driver/gravatar.php | 6 ++---- phpBB/includes/avatar/driver/interface.php | 3 +-- phpBB/includes/functions_display.php | 8 ++++---- 4 files changed, 7 insertions(+), 17 deletions(-) diff --git a/phpBB/includes/avatar/driver/driver.php b/phpBB/includes/avatar/driver/driver.php index 234186215b..6710f1f153 100644 --- a/phpBB/includes/avatar/driver/driver.php +++ b/phpBB/includes/avatar/driver/driver.php @@ -57,13 +57,6 @@ abstract class phpbb_avatar_driver implements phpbb_avatar_driver_interface */ protected $cache; - /** - * This flag should be set to true if the avatar requires a nonstandard image - * tag, and will generate the html itself. - * @var boolean - */ - public $custom_html = false; - /** * Construct a driver object * diff --git a/phpBB/includes/avatar/driver/gravatar.php b/phpBB/includes/avatar/driver/gravatar.php index 7e21a737a1..6ceac1a149 100644 --- a/phpBB/includes/avatar/driver/gravatar.php +++ b/phpBB/includes/avatar/driver/gravatar.php @@ -21,12 +21,10 @@ if (!defined('IN_PHPBB')) */ class phpbb_avatar_driver_gravatar extends phpbb_avatar_driver { - const GRAVATAR_URL = 'https://secure.gravatar.com/avatar/'; - /** - * @inheritdoc + * The URL for the gravatar service */ - public $custom_html = true; + const GRAVATAR_URL = 'https://secure.gravatar.com/avatar/'; /** * @inheritdoc diff --git a/phpBB/includes/avatar/driver/interface.php b/phpBB/includes/avatar/driver/interface.php index cc6b7edd17..d2f25a989f 100644 --- a/phpBB/includes/avatar/driver/interface.php +++ b/phpBB/includes/avatar/driver/interface.php @@ -40,8 +40,7 @@ interface phpbb_avatar_driver_interface public function get_data($row, $ignore_config = false); /** - * Returns custom html for displaying this avatar. - * Only called if $custom_html is true. + * Returns custom html if it is needed for displaying this avatar * * @param bool $ignore_config Whether this function should respect the users prefs * and board configuration configuration option, or should just render diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php index 669641de70..a7b28acac1 100644 --- a/phpBB/includes/functions_display.php +++ b/phpBB/includes/functions_display.php @@ -1368,12 +1368,14 @@ function get_avatar($row, $alt, $ignore_config = false) $phpbb_avatar_manager = $phpbb_container->get('avatar.manager'); $avatar = $phpbb_avatar_manager->get_driver($row['avatar_type']); + $html = ''; if ($avatar) { - if ($avatar->custom_html) + $html = $avatar->get_custom_html($row, $ignore_config, $alt); + if (!empty($html)) { - return $avatar->get_custom_html($row, $ignore_config, $alt); + return $html; } $avatar_data = $avatar->get_data($row, $ignore_config); @@ -1383,8 +1385,6 @@ function get_avatar($row, $alt, $ignore_config = false) $avatar_data['src'] = ''; } - $html = ''; - if (!empty($avatar_data['src'])) { $html = ' Date: Thu, 29 Nov 2012 23:50:17 +0100 Subject: [PATCH 0503/2494] [feature/avatars] Get list of enabled drivers from avatar manager This shouldn't be done in the avatar drivers. We need to force the display all avatar drivers in the ACP or it won't be possible to enable avatars after they have been disabled. PHPBB3-10018 --- phpBB/includes/acp/acp_board.php | 2 +- phpBB/includes/acp/acp_groups.php | 35 ++++++++++---------- phpBB/includes/acp/acp_users.php | 37 ++++++++++------------ phpBB/includes/avatar/driver/driver.php | 10 ------ phpBB/includes/avatar/driver/interface.php | 7 ---- phpBB/includes/avatar/manager.php | 29 ++++++++++++++--- phpBB/includes/ucp/ucp_groups.php | 33 +++++++++---------- phpBB/includes/ucp/ucp_profile.php | 35 ++++++++++---------- 8 files changed, 90 insertions(+), 98 deletions(-) diff --git a/phpBB/includes/acp/acp_board.php b/phpBB/includes/acp/acp_board.php index 95da62dedf..c3bdf89866 100644 --- a/phpBB/includes/acp/acp_board.php +++ b/phpBB/includes/acp/acp_board.php @@ -108,7 +108,7 @@ class acp_board case 'avatar': $phpbb_avatar_manager = $phpbb_container->get('avatar.manager'); - $avatar_drivers = $phpbb_avatar_manager->get_valid_drivers(); + $avatar_drivers = $phpbb_avatar_manager->get_valid_drivers(true); sort($avatar_drivers); $avatar_vars = array(); foreach ($avatar_drivers as $driver) diff --git a/phpBB/includes/acp/acp_groups.php b/phpBB/includes/acp/acp_groups.php index 19006df306..a15a1b9a78 100644 --- a/phpBB/includes/acp/acp_groups.php +++ b/phpBB/includes/acp/acp_groups.php @@ -528,27 +528,24 @@ class acp_groups { $avatar = $phpbb_avatar_manager->get_driver($driver); - if ($avatar->is_enabled()) + $avatars_enabled = true; + $config_name = preg_replace('#^avatar\.driver.#', '', $driver); + $template->set_filenames(array( + 'avatar' => "acp_avatar_options_$config_name.html", + )); + + if ($avatar->prepare_form($template, $avatar_data, $avatar_error)) { - $avatars_enabled = true; - $config_name = preg_replace('#^avatar\.driver.#', '', $driver); - $template->set_filenames(array( - 'avatar' => "acp_avatar_options_$config_name.html", + $driver_name = $phpbb_avatar_manager->prepare_driver_name($driver); + $driver_upper = strtoupper($driver_name); + $template->assign_block_vars('avatar_drivers', array( + 'L_TITLE' => $user->lang($driver_upper . '_TITLE'), + 'L_EXPLAIN' => $user->lang($driver_upper . '_EXPLAIN'), + + 'DRIVER' => $driver_name, + 'SELECTED' => $driver == $focused_driver, + 'OUTPUT' => $template->assign_display('avatar'), )); - - if ($avatar->prepare_form($template, $avatar_data, $avatar_error)) - { - $driver_name = $phpbb_avatar_manager->prepare_driver_name($driver); - $driver_upper = strtoupper($driver_name); - $template->assign_block_vars('avatar_drivers', array( - 'L_TITLE' => $user->lang($driver_upper . '_TITLE'), - 'L_EXPLAIN' => $user->lang($driver_upper . '_EXPLAIN'), - - 'DRIVER' => $driver_name, - 'SELECTED' => $driver == $focused_driver, - 'OUTPUT' => $template->assign_display('avatar'), - )); - } } } } diff --git a/phpBB/includes/acp/acp_users.php b/phpBB/includes/acp/acp_users.php index e0dcea6d58..d5532e35b6 100644 --- a/phpBB/includes/acp/acp_users.php +++ b/phpBB/includes/acp/acp_users.php @@ -1809,28 +1809,25 @@ class acp_users { $avatar = $phpbb_avatar_manager->get_driver($driver); - if ($avatar->is_enabled()) + $avatars_enabled = true; + $config_name = preg_replace('#^avatar\.driver.#', '', $driver); + $template->set_filenames(array( + 'avatar' => "acp_avatar_options_$config_name.html", + )); + + if ($avatar->prepare_form($template, $avatar_data, $error)) { - $avatars_enabled = true; - $config_name = preg_replace('#^avatar\.driver.#', '', $driver); - $template->set_filenames(array( - 'avatar' => "acp_avatar_options_$config_name.html", + $driver_name = $phpbb_avatar_manager->prepare_driver_name($driver); + $driver_upper = strtoupper($driver_name); + + $template->assign_block_vars('avatar_drivers', array( + 'L_TITLE' => $user->lang($driver_upper . '_TITLE'), + 'L_EXPLAIN' => $user->lang($driver_upper . '_EXPLAIN'), + + 'DRIVER' => $driver_name, + 'SELECTED' => $driver == $focused_driver, + 'OUTPUT' => $template->assign_display('avatar'), )); - - if ($avatar->prepare_form($template, $avatar_data, $error)) - { - $driver_name = $phpbb_avatar_manager->prepare_driver_name($driver); - $driver_upper = strtoupper($driver_name); - - $template->assign_block_vars('avatar_drivers', array( - 'L_TITLE' => $user->lang($driver_upper . '_TITLE'), - 'L_EXPLAIN' => $user->lang($driver_upper . '_EXPLAIN'), - - 'DRIVER' => $driver_name, - 'SELECTED' => $driver == $focused_driver, - 'OUTPUT' => $template->assign_display('avatar'), - )); - } } } } diff --git a/phpBB/includes/avatar/driver/driver.php b/phpBB/includes/avatar/driver/driver.php index 6710f1f153..cde4fd95a6 100644 --- a/phpBB/includes/avatar/driver/driver.php +++ b/phpBB/includes/avatar/driver/driver.php @@ -127,16 +127,6 @@ abstract class phpbb_avatar_driver implements phpbb_avatar_driver_interface return true; } - /** - * @inheritdoc - */ - public function is_enabled() - { - $driver = preg_replace('#^phpbb_avatar_driver_#', '', get_class($this)); - - return $this->config["allow_avatar_$driver"]; - } - /** * @inheritdoc */ diff --git a/phpBB/includes/avatar/driver/interface.php b/phpBB/includes/avatar/driver/interface.php index d2f25a989f..7a58a40b0c 100644 --- a/phpBB/includes/avatar/driver/interface.php +++ b/phpBB/includes/avatar/driver/interface.php @@ -91,13 +91,6 @@ interface phpbb_avatar_driver_interface */ public function delete($row); - /** - * Check if avatar is enabled - * - * @return bool True if avatar is enabled, false if it's disabled - */ - public function is_enabled(); - /** * Get the avatars template name * diff --git a/phpBB/includes/avatar/manager.php b/phpBB/includes/avatar/manager.php index ae628f0ce2..8953557acb 100644 --- a/phpBB/includes/avatar/manager.php +++ b/phpBB/includes/avatar/manager.php @@ -101,15 +101,20 @@ class phpbb_avatar_manager /** * Load the list of valid drivers * This is executed once and fills self::$valid_drivers + * + * @param bool $force_all Force showing all avatar drivers */ - protected function load_valid_drivers() + protected function load_valid_drivers($force_all = false) { if (!empty($this->avatar_drivers)) { self::$valid_drivers = array(); foreach ($this->avatar_drivers as $driver) { - self::$valid_drivers[$driver->get_name()] = $driver->get_name(); + if ($force_all || $this->is_enabled($driver)) + { + self::$valid_drivers[$driver->get_name()] = $driver->get_name(); + } } } } @@ -117,13 +122,15 @@ class phpbb_avatar_manager /** * Get a list of valid avatar drivers * + * @param bool $force_all Force showing all avatar drivers + * * @return array Array containing a list of the valid avatar drivers */ - public function get_valid_drivers() + public function get_valid_drivers($force_all = false) { if (self::$valid_drivers === false) { - $this->load_valid_drivers(); + $this->load_valid_drivers($force_all); } return self::$valid_drivers; @@ -178,4 +185,18 @@ class phpbb_avatar_manager { return str_replace('.', '_', $name); } + + /** + * Check if avatar is enabled + * + * @param object $driver Avatar driver object + * + * @return bool True if avatar is enabled, false if it's disabled + */ + public function is_enabled($driver) + { + $config_name = preg_replace('#^phpbb_avatar_driver_#', '', get_class($driver)); + + return $this->config["allow_avatar_{$config_name}"]; + } } diff --git a/phpBB/includes/ucp/ucp_groups.php b/phpBB/includes/ucp/ucp_groups.php index 3860d22917..f17e535b0c 100644 --- a/phpBB/includes/ucp/ucp_groups.php +++ b/phpBB/includes/ucp/ucp_groups.php @@ -653,26 +653,23 @@ class ucp_groups { $avatar = $phpbb_avatar_manager->get_driver($driver); - if ($avatar->is_enabled()) + $avatars_enabled = true; + $template->set_filenames(array( + 'avatar' => $avatar->get_template_name(), + )); + + if ($avatar->prepare_form($template, $avatar_data, $avatar_error)) { - $avatars_enabled = true; - $template->set_filenames(array( - 'avatar' => $avatar->get_template_name(), + $driver_name = $phpbb_avatar_manager->prepare_driver_name($driver); + $driver_upper = strtoupper($driver_name); + $template->assign_block_vars('avatar_drivers', array( + 'L_TITLE' => $user->lang($driver_upper . '_TITLE'), + 'L_EXPLAIN' => $user->lang($driver_upper . '_EXPLAIN'), + + 'DRIVER' => $driver_name, + 'SELECTED' => $driver == $focused_driver, + 'OUTPUT' => $template->assign_display('avatar'), )); - - if ($avatar->prepare_form($template, $avatar_data, $avatar_error)) - { - $driver_name = $phpbb_avatar_manager->prepare_driver_name($driver); - $driver_upper = strtoupper($driver_name); - $template->assign_block_vars('avatar_drivers', array( - 'L_TITLE' => $user->lang($driver_upper . '_TITLE'), - 'L_EXPLAIN' => $user->lang($driver_upper . '_EXPLAIN'), - - 'DRIVER' => $driver_name, - 'SELECTED' => $driver == $focused_driver, - 'OUTPUT' => $template->assign_display('avatar'), - )); - } } } } diff --git a/phpBB/includes/ucp/ucp_profile.php b/phpBB/includes/ucp/ucp_profile.php index c8547e48d8..f5c04bb432 100644 --- a/phpBB/includes/ucp/ucp_profile.php +++ b/phpBB/includes/ucp/ucp_profile.php @@ -633,27 +633,24 @@ class ucp_profile { $avatar = $phpbb_avatar_manager->get_driver($driver); - if ($avatar->is_enabled()) + $avatars_enabled = true; + $template->set_filenames(array( + 'avatar' => $avatar->get_template_name(), + )); + + if ($avatar->prepare_form($template, $avatar_data, $error)) { - $avatars_enabled = true; - $template->set_filenames(array( - 'avatar' => $avatar->get_template_name(), + $driver_name = $phpbb_avatar_manager->prepare_driver_name($driver); + $driver_upper = strtoupper($driver_name); + + $template->assign_block_vars('avatar_drivers', array( + 'L_TITLE' => $user->lang($driver_upper . '_TITLE'), + 'L_EXPLAIN' => $user->lang($driver_upper . '_EXPLAIN'), + + 'DRIVER' => $driver_name, + 'SELECTED' => $driver == $focused_driver, + 'OUTPUT' => $template->assign_display('avatar'), )); - - if ($avatar->prepare_form($template, $avatar_data, $error)) - { - $driver_name = $phpbb_avatar_manager->prepare_driver_name($driver); - $driver_upper = strtoupper($driver_name); - - $template->assign_block_vars('avatar_drivers', array( - 'L_TITLE' => $user->lang($driver_upper . '_TITLE'), - 'L_EXPLAIN' => $user->lang($driver_upper . '_EXPLAIN'), - - 'DRIVER' => $driver_name, - 'SELECTED' => $driver == $focused_driver, - 'OUTPUT' => $template->assign_display('avatar'), - )); - } } } } From 562ebe5c12b8a238b94a63ba53b694af4d061bc9 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Fri, 30 Nov 2012 14:36:18 +0100 Subject: [PATCH 0504/2494] [feature/avatars] Unify size of avatar_type Previously it was set to 255 in one file while it was 32 in other files. As the size of 32 is rather low this was increased to 255. PHPBB3-10018 --- phpBB/develop/create_schema_files.php | 4 ++-- phpBB/install/schemas/firebird_schema.sql | 4 ++-- phpBB/install/schemas/mssql_schema.sql | 4 ++-- phpBB/install/schemas/mysql_40_schema.sql | 4 ++-- phpBB/install/schemas/mysql_41_schema.sql | 4 ++-- phpBB/install/schemas/oracle_schema.sql | 4 ++-- phpBB/install/schemas/postgres_schema.sql | 4 ++-- phpBB/install/schemas/sqlite_schema.sql | 4 ++-- 8 files changed, 16 insertions(+), 16 deletions(-) diff --git a/phpBB/develop/create_schema_files.php b/phpBB/develop/create_schema_files.php index 1d03a5b06e..895a945e4e 100644 --- a/phpBB/develop/create_schema_files.php +++ b/phpBB/develop/create_schema_files.php @@ -1168,7 +1168,7 @@ function get_schema_struct() 'group_desc_uid' => array('VCHAR:8', ''), 'group_display' => array('BOOL', 0), 'group_avatar' => array('VCHAR', ''), - 'group_avatar_type' => array('VCHAR:32', ''), + 'group_avatar_type' => array('VCHAR:255', ''), 'group_avatar_width' => array('USINT', 0), 'group_avatar_height' => array('USINT', 0), 'group_rank' => array('UINT', 0), @@ -1823,7 +1823,7 @@ function get_schema_struct() 'user_allow_massemail' => array('BOOL', 1), 'user_options' => array('UINT:11', 230271), 'user_avatar' => array('VCHAR', ''), - 'user_avatar_type' => array('VCHAR:32', ''), + 'user_avatar_type' => array('VCHAR:255', ''), 'user_avatar_width' => array('USINT', 0), 'user_avatar_height' => array('USINT', 0), 'user_sig' => array('MTEXT_UNI', ''), diff --git a/phpBB/install/schemas/firebird_schema.sql b/phpBB/install/schemas/firebird_schema.sql index 45ab3af337..d830f0db77 100644 --- a/phpBB/install/schemas/firebird_schema.sql +++ b/phpBB/install/schemas/firebird_schema.sql @@ -445,7 +445,7 @@ CREATE TABLE phpbb_groups ( group_desc_uid VARCHAR(8) CHARACTER SET NONE DEFAULT '' NOT NULL, group_display INTEGER DEFAULT 0 NOT NULL, group_avatar VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL, - group_avatar_type VARCHAR(32) CHARACTER SET NONE DEFAULT '' NOT NULL, + group_avatar_type VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL, group_avatar_width INTEGER DEFAULT 0 NOT NULL, group_avatar_height INTEGER DEFAULT 0 NOT NULL, group_rank INTEGER DEFAULT 0 NOT NULL, @@ -1271,7 +1271,7 @@ CREATE TABLE phpbb_users ( user_allow_massemail INTEGER DEFAULT 1 NOT NULL, user_options INTEGER DEFAULT 230271 NOT NULL, user_avatar VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL, - user_avatar_type VARCHAR(32) CHARACTER SET NONE DEFAULT '' NOT NULL, + user_avatar_type VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL, user_avatar_width INTEGER DEFAULT 0 NOT NULL, user_avatar_height INTEGER DEFAULT 0 NOT NULL, user_sig BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL, diff --git a/phpBB/install/schemas/mssql_schema.sql b/phpBB/install/schemas/mssql_schema.sql index 1925935dc4..d2dd1c1d60 100644 --- a/phpBB/install/schemas/mssql_schema.sql +++ b/phpBB/install/schemas/mssql_schema.sql @@ -553,7 +553,7 @@ CREATE TABLE [phpbb_groups] ( [group_desc_uid] [varchar] (8) DEFAULT ('') NOT NULL , [group_display] [int] DEFAULT (0) NOT NULL , [group_avatar] [varchar] (255) DEFAULT ('') NOT NULL , - [group_avatar_type] [varchar] (32) DEFAULT ('') NOT NULL , + [group_avatar_type] [varchar] (255) DEFAULT ('') NOT NULL , [group_avatar_width] [int] DEFAULT (0) NOT NULL , [group_avatar_height] [int] DEFAULT (0) NOT NULL , [group_rank] [int] DEFAULT (0) NOT NULL , @@ -1555,7 +1555,7 @@ CREATE TABLE [phpbb_users] ( [user_allow_massemail] [int] DEFAULT (1) NOT NULL , [user_options] [int] DEFAULT (230271) NOT NULL , [user_avatar] [varchar] (255) DEFAULT ('') NOT NULL , - [user_avatar_type] [varchar] (32) DEFAULT ('') NOT NULL , + [user_avatar_type] [varchar] (255) DEFAULT ('') NOT NULL , [user_avatar_width] [int] DEFAULT (0) NOT NULL , [user_avatar_height] [int] DEFAULT (0) NOT NULL , [user_sig] [text] DEFAULT ('') NOT NULL , diff --git a/phpBB/install/schemas/mysql_40_schema.sql b/phpBB/install/schemas/mysql_40_schema.sql index 6634615e9f..dfaf3b28e2 100644 --- a/phpBB/install/schemas/mysql_40_schema.sql +++ b/phpBB/install/schemas/mysql_40_schema.sql @@ -317,7 +317,7 @@ CREATE TABLE phpbb_groups ( group_desc_uid varbinary(8) DEFAULT '' NOT NULL, group_display tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, group_avatar varbinary(255) DEFAULT '' NOT NULL, - group_avatar_type varbinary(32) DEFAULT '' NOT NULL, + group_avatar_type varbinary(255) DEFAULT '' NOT NULL, group_avatar_width smallint(4) UNSIGNED DEFAULT '0' NOT NULL, group_avatar_height smallint(4) UNSIGNED DEFAULT '0' NOT NULL, group_rank mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, @@ -919,7 +919,7 @@ CREATE TABLE phpbb_users ( user_allow_massemail tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, user_options int(11) UNSIGNED DEFAULT '230271' NOT NULL, user_avatar varbinary(255) DEFAULT '' NOT NULL, - user_avatar_type varbinary(32) DEFAULT '' NOT NULL, + user_avatar_type varbinary(255) DEFAULT '' NOT NULL, user_avatar_width smallint(4) UNSIGNED DEFAULT '0' NOT NULL, user_avatar_height smallint(4) UNSIGNED DEFAULT '0' NOT NULL, user_sig mediumblob NOT NULL, diff --git a/phpBB/install/schemas/mysql_41_schema.sql b/phpBB/install/schemas/mysql_41_schema.sql index 7823c91fb8..5c27538f86 100644 --- a/phpBB/install/schemas/mysql_41_schema.sql +++ b/phpBB/install/schemas/mysql_41_schema.sql @@ -317,7 +317,7 @@ CREATE TABLE phpbb_groups ( group_desc_uid varchar(8) DEFAULT '' NOT NULL, group_display tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, group_avatar varchar(255) DEFAULT '' NOT NULL, - group_avatar_type varchar(32) DEFAULT '' NOT NULL, + group_avatar_type varchar(255) DEFAULT '' NOT NULL, group_avatar_width smallint(4) UNSIGNED DEFAULT '0' NOT NULL, group_avatar_height smallint(4) UNSIGNED DEFAULT '0' NOT NULL, group_rank mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, @@ -919,7 +919,7 @@ CREATE TABLE phpbb_users ( user_allow_massemail tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, user_options int(11) UNSIGNED DEFAULT '230271' NOT NULL, user_avatar varchar(255) DEFAULT '' NOT NULL, - user_avatar_type varchar(32) DEFAULT '' NOT NULL, + user_avatar_type varchar(255) DEFAULT '' NOT NULL, user_avatar_width smallint(4) UNSIGNED DEFAULT '0' NOT NULL, user_avatar_height smallint(4) UNSIGNED DEFAULT '0' NOT NULL, user_sig mediumtext NOT NULL, diff --git a/phpBB/install/schemas/oracle_schema.sql b/phpBB/install/schemas/oracle_schema.sql index 78592decd5..718dd02601 100644 --- a/phpBB/install/schemas/oracle_schema.sql +++ b/phpBB/install/schemas/oracle_schema.sql @@ -610,7 +610,7 @@ CREATE TABLE phpbb_groups ( group_desc_uid varchar2(8) DEFAULT '' , group_display number(1) DEFAULT '0' NOT NULL, group_avatar varchar2(255) DEFAULT '' , - group_avatar_type varchar2(32) DEFAULT '' , + group_avatar_type varchar2(255) DEFAULT '' , group_avatar_width number(4) DEFAULT '0' NOT NULL, group_avatar_height number(4) DEFAULT '0' NOT NULL, group_rank number(8) DEFAULT '0' NOT NULL, @@ -1667,7 +1667,7 @@ CREATE TABLE phpbb_users ( user_allow_massemail number(1) DEFAULT '1' NOT NULL, user_options number(11) DEFAULT '230271' NOT NULL, user_avatar varchar2(255) DEFAULT '' , - user_avatar_type varchar2(32) DEFAULT '' , + user_avatar_type varchar2(255) DEFAULT '' , user_avatar_width number(4) DEFAULT '0' NOT NULL, user_avatar_height number(4) DEFAULT '0' NOT NULL, user_sig clob DEFAULT '' , diff --git a/phpBB/install/schemas/postgres_schema.sql b/phpBB/install/schemas/postgres_schema.sql index f85cee4277..3d4d01484e 100644 --- a/phpBB/install/schemas/postgres_schema.sql +++ b/phpBB/install/schemas/postgres_schema.sql @@ -463,7 +463,7 @@ CREATE TABLE phpbb_groups ( group_desc_uid varchar(8) DEFAULT '' NOT NULL, group_display INT2 DEFAULT '0' NOT NULL CHECK (group_display >= 0), group_avatar varchar(255) DEFAULT '' NOT NULL, - group_avatar_type varchar(32) DEFAULT '' NOT NULL, + group_avatar_type varchar(255) DEFAULT '' NOT NULL, group_avatar_width INT2 DEFAULT '0' NOT NULL CHECK (group_avatar_width >= 0), group_avatar_height INT2 DEFAULT '0' NOT NULL CHECK (group_avatar_height >= 0), group_rank INT4 DEFAULT '0' NOT NULL CHECK (group_rank >= 0), @@ -1169,7 +1169,7 @@ CREATE TABLE phpbb_users ( user_allow_massemail INT2 DEFAULT '1' NOT NULL CHECK (user_allow_massemail >= 0), user_options INT4 DEFAULT '230271' NOT NULL CHECK (user_options >= 0), user_avatar varchar(255) DEFAULT '' NOT NULL, - user_avatar_type varchar(32) DEFAULT '' NOT NULL, + user_avatar_type varchar(255) DEFAULT '' NOT NULL, user_avatar_width INT2 DEFAULT '0' NOT NULL CHECK (user_avatar_width >= 0), user_avatar_height INT2 DEFAULT '0' NOT NULL CHECK (user_avatar_height >= 0), user_sig TEXT DEFAULT '' NOT NULL, diff --git a/phpBB/install/schemas/sqlite_schema.sql b/phpBB/install/schemas/sqlite_schema.sql index 900ed06bfe..8f488416ce 100644 --- a/phpBB/install/schemas/sqlite_schema.sql +++ b/phpBB/install/schemas/sqlite_schema.sql @@ -309,7 +309,7 @@ CREATE TABLE phpbb_groups ( group_desc_uid varchar(8) NOT NULL DEFAULT '', group_display INTEGER UNSIGNED NOT NULL DEFAULT '0', group_avatar varchar(255) NOT NULL DEFAULT '', - group_avatar_type varchar(32) NOT NULL DEFAULT '', + group_avatar_type varchar(255) NOT NULL DEFAULT '', group_avatar_width INTEGER UNSIGNED NOT NULL DEFAULT '0', group_avatar_height INTEGER UNSIGNED NOT NULL DEFAULT '0', group_rank INTEGER UNSIGNED NOT NULL DEFAULT '0', @@ -893,7 +893,7 @@ CREATE TABLE phpbb_users ( user_allow_massemail INTEGER UNSIGNED NOT NULL DEFAULT '1', user_options INTEGER UNSIGNED NOT NULL DEFAULT '230271', user_avatar varchar(255) NOT NULL DEFAULT '', - user_avatar_type varchar(32) NOT NULL DEFAULT '', + user_avatar_type varchar(255) NOT NULL DEFAULT '', user_avatar_width INTEGER UNSIGNED NOT NULL DEFAULT '0', user_avatar_height INTEGER UNSIGNED NOT NULL DEFAULT '0', user_sig mediumtext(16777215) NOT NULL DEFAULT '', From d5cbedaaa28312c107ec562c78ffaa034595f336 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Fri, 30 Nov 2012 15:12:34 +0100 Subject: [PATCH 0505/2494] [feature/avatars] Let avatar manager handle $ignore_config The avatar manager already handles if avatars are enabled. It should also handle ignoring the config settings. PHPBB3-10018 --- phpBB/includes/acp/acp_groups.php | 2 +- phpBB/includes/avatar/driver/driver.php | 4 ++-- phpBB/includes/avatar/driver/gravatar.php | 25 ++++++---------------- phpBB/includes/avatar/driver/interface.php | 16 ++++++-------- phpBB/includes/avatar/driver/local.php | 23 ++++++-------------- phpBB/includes/avatar/driver/remote.php | 23 ++++++-------------- phpBB/includes/avatar/manager.php | 9 ++++---- phpBB/includes/functions_display.php | 2 +- 8 files changed, 35 insertions(+), 69 deletions(-) diff --git a/phpBB/includes/acp/acp_groups.php b/phpBB/includes/acp/acp_groups.php index a15a1b9a78..75956736f7 100644 --- a/phpBB/includes/acp/acp_groups.php +++ b/phpBB/includes/acp/acp_groups.php @@ -351,7 +351,7 @@ class acp_groups } else { - $avatar = $phpbb_avatar_manager->get_driver($user->data['user_avatar_type']) + $avatar = $phpbb_avatar_manager->get_driver($user->data['user_avatar_type']); if ($avatar) { $avatar->delete($avatar_data); diff --git a/phpBB/includes/avatar/driver/driver.php b/phpBB/includes/avatar/driver/driver.php index cde4fd95a6..317fe91b83 100644 --- a/phpBB/includes/avatar/driver/driver.php +++ b/phpBB/includes/avatar/driver/driver.php @@ -78,7 +78,7 @@ abstract class phpbb_avatar_driver implements phpbb_avatar_driver_interface /** * @inheritdoc */ - public function get_data($row, $ignore_config = false) + public function get_data($row) { return array( 'src' => '', @@ -90,7 +90,7 @@ abstract class phpbb_avatar_driver implements phpbb_avatar_driver_interface /** * @inheritdoc */ - public function get_custom_html($row, $ignore_config = false, $alt = '') + public function get_custom_html($row, $alt = '') { return ''; } diff --git a/phpBB/includes/avatar/driver/gravatar.php b/phpBB/includes/avatar/driver/gravatar.php index 6ceac1a149..001a741c3f 100644 --- a/phpBB/includes/avatar/driver/gravatar.php +++ b/phpBB/includes/avatar/driver/gravatar.php @@ -29,30 +29,19 @@ class phpbb_avatar_driver_gravatar extends phpbb_avatar_driver /** * @inheritdoc */ - public function get_data($row, $ignore_config = false) + public function get_data($row) { - if ($ignore_config || $this->config['allow_avatar_gravatar']) - { - return array( - 'src' => $row['avatar'], - 'width' => $row['avatar_width'], - 'height' => $row['avatar_height'], - ); - } - else - { - return array( - 'src' => '', - 'width' => 0, - 'height' => 0, - ); - } + return array( + 'src' => $row['avatar'], + 'width' => $row['avatar_width'], + 'height' => $row['avatar_height'], + ); } /** * @inheritdoc */ - public function get_custom_html($row, $ignore_config = false, $alt = '') + public function get_custom_html($row, $alt = '') { return ' '', 'width' => 0, 'height' => 0] + * ['src' => '', 'width' => 0, 'height' => 0] */ - public function get_data($row, $ignore_config = false); + public function get_data($row); /** * Returns custom html if it is needed for displaying this avatar * - * @param bool $ignore_config Whether this function should respect the users prefs - * and board configuration configuration option, or should just render - * the avatar anyways. Useful for the ACP. + * @param string $alt Alternate text for avatar image + * * @return string HTML */ - public function get_custom_html($row, $ignore_config = false, $alt = ''); + public function get_custom_html($row, $alt = ''); /** * Prepare form for changing the settings of this avatar diff --git a/phpBB/includes/avatar/driver/local.php b/phpBB/includes/avatar/driver/local.php index d46ac79d11..479ee3712a 100644 --- a/phpBB/includes/avatar/driver/local.php +++ b/phpBB/includes/avatar/driver/local.php @@ -24,24 +24,13 @@ class phpbb_avatar_driver_local extends phpbb_avatar_driver /** * @inheritdoc */ - public function get_data($row, $ignore_config = false) + public function get_data($row) { - if ($ignore_config || $this->config['allow_avatar_local']) - { - return array( - 'src' => $this->phpbb_root_path . $this->config['avatar_gallery_path'] . '/' . $row['avatar'], - 'width' => $row['avatar_width'], - 'height' => $row['avatar_height'], - ); - } - else - { - return array( - 'src' => '', - 'width' => 0, - 'height' => 0, - ); - } + return array( + 'src' => $this->phpbb_root_path . $this->config['avatar_gallery_path'] . '/' . $row['avatar'], + 'width' => $row['avatar_width'], + 'height' => $row['avatar_height'], + ); } /** diff --git a/phpBB/includes/avatar/driver/remote.php b/phpBB/includes/avatar/driver/remote.php index 1da5fc16e8..344275a251 100644 --- a/phpBB/includes/avatar/driver/remote.php +++ b/phpBB/includes/avatar/driver/remote.php @@ -24,24 +24,13 @@ class phpbb_avatar_driver_remote extends phpbb_avatar_driver /** * @inheritdoc */ - public function get_data($row, $ignore_config = false) + public function get_data($row) { - if ($ignore_config || $this->config['allow_avatar_remote']) - { - return array( - 'src' => $row['avatar'], - 'width' => $row['avatar_width'], - 'height' => $row['avatar_height'], - ); - } - else - { - return array( - 'src' => '', - 'width' => 0, - 'height' => 0, - ); - } + return array( + 'src' => $row['avatar'], + 'width' => $row['avatar_width'], + 'height' => $row['avatar_height'], + ); } /** diff --git a/phpBB/includes/avatar/manager.php b/phpBB/includes/avatar/manager.php index 8953557acb..a0e1070322 100644 --- a/phpBB/includes/avatar/manager.php +++ b/phpBB/includes/avatar/manager.php @@ -54,15 +54,16 @@ class phpbb_avatar_manager /** * Get the driver object specified by the avatar type * - * @param string Avatar type; by default an avatar's service container name + * @param string $avatar_type Avatar type; by default an avatar's service container name + * @param bool $force_all Grab all avatar drivers, no matter if enabled or not * * @return object Avatar driver object */ - public function get_driver($avatar_type) + public function get_driver($avatar_type, $force_all = false) { - if (self::$valid_drivers === false) + if (self::$valid_drivers === false || $force_all) { - $this->load_valid_drivers(); + $this->load_valid_drivers($force_all); } // Legacy stuff... diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php index a7b28acac1..f88d8c9054 100644 --- a/phpBB/includes/functions_display.php +++ b/phpBB/includes/functions_display.php @@ -1367,7 +1367,7 @@ function get_avatar($row, $alt, $ignore_config = false) ); $phpbb_avatar_manager = $phpbb_container->get('avatar.manager'); - $avatar = $phpbb_avatar_manager->get_driver($row['avatar_type']); + $avatar = $phpbb_avatar_manager->get_driver($row['avatar_type'], $ignore_config); $html = ''; if ($avatar) From 33b98dc5ba0b690fdae72acfd676dae5a897cb6a Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Fri, 30 Nov 2012 16:46:11 +0100 Subject: [PATCH 0506/2494] [feature/avatars] Fix variable names PHPBB3-10018 --- phpBB/includes/acp/acp_board.php | 2 +- phpBB/includes/acp/acp_groups.php | 24 +++++++++----------- phpBB/includes/acp/acp_users.php | 34 +++++++++++++--------------- phpBB/includes/avatar/manager.php | 1 + phpBB/includes/functions_display.php | 8 +++---- phpBB/includes/ucp/ucp_groups.php | 31 ++++++++++++------------- phpBB/includes/ucp/ucp_profile.php | 30 ++++++++++++------------ 7 files changed, 62 insertions(+), 68 deletions(-) diff --git a/phpBB/includes/acp/acp_board.php b/phpBB/includes/acp/acp_board.php index c3bdf89866..0467cc7c35 100644 --- a/phpBB/includes/acp/acp_board.php +++ b/phpBB/includes/acp/acp_board.php @@ -109,7 +109,7 @@ class acp_board case 'avatar': $phpbb_avatar_manager = $phpbb_container->get('avatar.manager'); $avatar_drivers = $phpbb_avatar_manager->get_valid_drivers(true); - sort($avatar_drivers); + $avatar_vars = array(); foreach ($avatar_drivers as $driver) { diff --git a/phpBB/includes/acp/acp_groups.php b/phpBB/includes/acp/acp_groups.php index 75956736f7..23f6d775ef 100644 --- a/phpBB/includes/acp/acp_groups.php +++ b/phpBB/includes/acp/acp_groups.php @@ -282,7 +282,6 @@ class acp_groups $user->add_lang('ucp'); // Setup avatar data for later - $phpbb_avatar_manager = $phpbb_container->get('avatar.manager'); $avatars_enabled = false; $avatar_drivers = null; $avatar_data = null; @@ -290,8 +289,8 @@ class acp_groups if ($config['allow_avatar']) { + $phpbb_avatar_manager = $phpbb_container->get('avatar.manager'); $avatar_drivers = $phpbb_avatar_manager->get_valid_drivers(); - sort($avatar_drivers); // This is normalised data, without the group_ prefix $avatar_data = phpbb_avatar_manager::clean_row($group_row); @@ -334,27 +333,26 @@ class acp_groups if ($config['allow_avatar']) { // Handle avatar - $driver = $phpbb_avatar_manager->clean_driver_name($request->variable('avatar_driver', '')); - $config_name = preg_replace('#^avatar\.driver.#', '', $driver); + $driver_name = $phpbb_avatar_manager->clean_driver_name($request->variable('avatar_driver', '')); - if (in_array($driver, $avatar_drivers) && $config["allow_avatar_$config_name"] && !$request->is_set_post('avatar_delete')) + if (in_array($driver_name, $avatar_drivers) && !$request->is_set_post('avatar_delete')) { - $avatar = $phpbb_avatar_manager->get_driver($driver); - $result = $avatar->process_form($template, $avatar_data, $avatar_error); + $driver = $phpbb_avatar_manager->get_driver($driver_name); + $result = $driver->process_form($template, $avatar_data, $avatar_error); if ($result && empty($avatar_error)) { - $result['avatar_type'] = $driver; + $result['avatar_type'] = $driver_name; $submit_ary = array_merge($submit_ary, $result); } } else { - $avatar = $phpbb_avatar_manager->get_driver($user->data['user_avatar_type']); - if ($avatar) + $driver = $phpbb_avatar_manager->get_driver($user->data['user_avatar_type']); + if ($driver) { - $avatar->delete($avatar_data); + $driver->delete($avatar_data); } // Removing the avatar @@ -526,7 +524,7 @@ class acp_groups foreach ($avatar_drivers as $driver) { - $avatar = $phpbb_avatar_manager->get_driver($driver); + $driver = $phpbb_avatar_manager->get_driver($driver); $avatars_enabled = true; $config_name = preg_replace('#^avatar\.driver.#', '', $driver); @@ -534,7 +532,7 @@ class acp_groups 'avatar' => "acp_avatar_options_$config_name.html", )); - if ($avatar->prepare_form($template, $avatar_data, $avatar_error)) + if ($driver->prepare_form($template, $avatar_data, $avatar_error)) { $driver_name = $phpbb_avatar_manager->prepare_driver_name($driver); $driver_upper = strtoupper($driver_name); diff --git a/phpBB/includes/acp/acp_users.php b/phpBB/includes/acp/acp_users.php index d5532e35b6..3df373a7d4 100644 --- a/phpBB/includes/acp/acp_users.php +++ b/phpBB/includes/acp/acp_users.php @@ -1733,12 +1733,11 @@ class acp_users include($phpbb_root_path . 'includes/functions_display.' . $phpEx); $avatars_enabled = false; - $phpbb_avatar_manager = $phpbb_container->get('avatar.manager'); if ($config['allow_avatar']) { + $phpbb_avatar_manager = $phpbb_container->get('avatar.manager'); $avatar_drivers = $phpbb_avatar_manager->get_valid_drivers(); - sort($avatar_drivers); // This is normalised data, without the user_ prefix $avatar_data = phpbb_avatar_manager::clean_row($user_row); @@ -1747,19 +1746,18 @@ class acp_users { if (check_form_key($form_name)) { - $driver = $phpbb_avatar_manager->clean_driver_name($request->variable('avatar_driver', '')); - $config_name = preg_replace('#^avatar\.driver.#', '', $driver); + $driver_name = $phpbb_avatar_manager->clean_driver_name($request->variable('avatar_driver', '')); - if (in_array($driver, $avatar_drivers) && $config["allow_avatar_$config_name"] && !$request->is_set_post('avatar_delete')) + if (in_array($driver_name, $avatar_drivers) && !$request->is_set_post('avatar_delete')) { - $avatar = $phpbb_avatar_manager->get_driver($driver); - $result = $avatar->process_form($template, $avatar_data, $error); + $driver = $phpbb_avatar_manager->get_driver($driver_name); + $result = $driver->process_form($template, $avatar_data, $error); if ($result && empty($error)) { // Success! Lets save the result in the database $result = array( - 'user_avatar_type' => $driver, + 'user_avatar_type' => $driver_name, 'user_avatar' => $result['avatar'], 'user_avatar_width' => $result['avatar_width'], 'user_avatar_height' => $result['avatar_height'], @@ -1775,10 +1773,10 @@ class acp_users } else { - $avatar = $phpbb_avatar_manager->get_driver($user->data['user_avatar_type']); - if ($avatar) + $driver = $phpbb_avatar_manager->get_driver($user->data['user_avatar_type']); + if ($driver) { - $avatar->delete($avatar_data); + $driver->delete($avatar_data); } // Removing the avatar @@ -1805,19 +1803,19 @@ class acp_users $focused_driver = $phpbb_avatar_manager->clean_driver_name($request->variable('avatar_driver', $user_row['user_avatar_type'])); - foreach ($avatar_drivers as $driver) + foreach ($avatar_drivers as $current_driver) { - $avatar = $phpbb_avatar_manager->get_driver($driver); + $driver = $phpbb_avatar_manager->get_driver($current_driver); $avatars_enabled = true; - $config_name = preg_replace('#^avatar\.driver.#', '', $driver); + $config_name = preg_replace('#^avatar\.driver.#', '', $current_driver); $template->set_filenames(array( 'avatar' => "acp_avatar_options_$config_name.html", )); - if ($avatar->prepare_form($template, $avatar_data, $error)) + if ($driver->prepare_form($template, $avatar_data, $error)) { - $driver_name = $phpbb_avatar_manager->prepare_driver_name($driver); + $driver_name = $phpbb_avatar_manager->prepare_driver_name($current_driver); $driver_upper = strtoupper($driver_name); $template->assign_block_vars('avatar_drivers', array( @@ -1825,7 +1823,7 @@ class acp_users 'L_EXPLAIN' => $user->lang($driver_upper . '_EXPLAIN'), 'DRIVER' => $driver_name, - 'SELECTED' => $driver == $focused_driver, + 'SELECTED' => $current_driver == $focused_driver, 'OUTPUT' => $template->assign_display('avatar'), )); } @@ -1842,7 +1840,7 @@ class acp_users } else { - $error[$key] = $user->lang("$lang"); + $error[$key] = $user->lang($lang); } } diff --git a/phpBB/includes/avatar/manager.php b/phpBB/includes/avatar/manager.php index a0e1070322..176d0d659d 100644 --- a/phpBB/includes/avatar/manager.php +++ b/phpBB/includes/avatar/manager.php @@ -117,6 +117,7 @@ class phpbb_avatar_manager self::$valid_drivers[$driver->get_name()] = $driver->get_name(); } } + asort(self::$valid_drivers); } } diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php index f88d8c9054..6b267bc901 100644 --- a/phpBB/includes/functions_display.php +++ b/phpBB/includes/functions_display.php @@ -1367,18 +1367,18 @@ function get_avatar($row, $alt, $ignore_config = false) ); $phpbb_avatar_manager = $phpbb_container->get('avatar.manager'); - $avatar = $phpbb_avatar_manager->get_driver($row['avatar_type'], $ignore_config); + $driver = $phpbb_avatar_manager->get_driver($row['avatar_type'], $ignore_config); $html = ''; - if ($avatar) + if ($driver) { - $html = $avatar->get_custom_html($row, $ignore_config, $alt); + $html = $driver->get_custom_html($row, $ignore_config, $alt); if (!empty($html)) { return $html; } - $avatar_data = $avatar->get_data($row, $ignore_config); + $avatar_data = $driver->get_data($row, $ignore_config); } else { diff --git a/phpBB/includes/ucp/ucp_groups.php b/phpBB/includes/ucp/ucp_groups.php index f17e535b0c..c1ddaccb75 100644 --- a/phpBB/includes/ucp/ucp_groups.php +++ b/phpBB/includes/ucp/ucp_groups.php @@ -484,7 +484,6 @@ class ucp_groups $error = array(); // Setup avatar data for later - $phpbb_avatar_manager = $phpbb_container->get('avatar.manager'); $avatars_enabled = false; $avatar_drivers = null; $avatar_data = null; @@ -492,8 +491,8 @@ class ucp_groups if ($config['allow_avatar']) { + $phpbb_avatar_manager = $phpbb_container->get('avatar.manager'); $avatar_drivers = $phpbb_avatar_manager->get_valid_drivers(); - sort($avatar_drivers); // This is normalised data, without the group_ prefix $avatar_data = phpbb_avatar_manager::clean_row($group_row); @@ -521,26 +520,26 @@ class ucp_groups if ($config['allow_avatar']) { // Handle avatar - $driver = $phpbb_avatar_manager->clean_driver_name($request->variable('avatar_driver', '')); - $config_name = preg_replace('#^avatar\.driver.#', '', $driver); + $driver_name = $phpbb_avatar_manager->clean_driver_name($request->variable('avatar_driver', '')); + $config_name = preg_replace('#^avatar\.driver.#', '', $driver_name); - if (in_array($driver, $avatar_drivers) && $config["allow_avatar_$config_name"] && !$request->is_set_post('avatar_delete')) + if (in_array($driver_name, $avatar_drivers) && !$request->is_set_post('avatar_delete')) { - $avatar = $phpbb_avatar_manager->get_driver($driver); - $result = $avatar->process_form($template, $avatar_data, $avatar_error); + $driver = $phpbb_avatar_manager->get_driver($driver_name); + $result = $driver->process_form($template, $avatar_data, $avatar_error); if ($result && empty($avatar_error)) { - $result['avatar_type'] = $driver; + $result['avatar_type'] = $driver_name; $submit_ary = array_merge($submit_ary, $result); } } else { - if ($avatar = $phpbb_avatar_manager->get_driver($user->data['user_avatar_type'])) + if ($driver = $phpbb_avatar_manager->get_driver($user->data['user_avatar_type'])) { - $avatar->delete($avatar_data); + $driver->delete($avatar_data); } // Removing the avatar @@ -649,25 +648,25 @@ class ucp_groups $avatars_enabled = false; $focused_driver = $phpbb_avatar_manager->clean_driver_name($request->variable('avatar_driver', $avatar_data['avatar_type'])); - foreach ($avatar_drivers as $driver) + foreach ($avatar_drivers as $current_driver) { - $avatar = $phpbb_avatar_manager->get_driver($driver); + $driver = $phpbb_avatar_manager->get_driver($current_driver); $avatars_enabled = true; $template->set_filenames(array( - 'avatar' => $avatar->get_template_name(), + 'avatar' => $driver->get_template_name(), )); - if ($avatar->prepare_form($template, $avatar_data, $avatar_error)) + if ($driver->prepare_form($template, $avatar_data, $avatar_error)) { - $driver_name = $phpbb_avatar_manager->prepare_driver_name($driver); + $driver_name = $phpbb_avatar_manager->prepare_driver_name($current_driver); $driver_upper = strtoupper($driver_name); $template->assign_block_vars('avatar_drivers', array( 'L_TITLE' => $user->lang($driver_upper . '_TITLE'), 'L_EXPLAIN' => $user->lang($driver_upper . '_EXPLAIN'), 'DRIVER' => $driver_name, - 'SELECTED' => $driver == $focused_driver, + 'SELECTED' => $current_driver == $focused_driver, 'OUTPUT' => $template->assign_display('avatar'), )); } diff --git a/phpBB/includes/ucp/ucp_profile.php b/phpBB/includes/ucp/ucp_profile.php index f5c04bb432..71a4d4e67b 100644 --- a/phpBB/includes/ucp/ucp_profile.php +++ b/phpBB/includes/ucp/ucp_profile.php @@ -552,13 +552,12 @@ class ucp_profile add_form_key('ucp_avatar'); - $phpbb_avatar_manager = $phpbb_container->get('avatar.manager'); $avatars_enabled = false; if ($config['allow_avatar'] && $auth->acl_get('u_chgavatar')) { + $phpbb_avatar_manager = $phpbb_container->get('avatar.manager'); $avatar_drivers = $phpbb_avatar_manager->get_valid_drivers(); - sort($avatar_drivers); // This is normalised data, without the user_ prefix $avatar_data = phpbb_avatar_manager::clean_row($user->data); @@ -567,19 +566,18 @@ class ucp_profile { if (check_form_key('ucp_avatar')) { - $driver = $phpbb_avatar_manager->clean_driver_name($request->variable('avatar_driver', '')); - $config_name = preg_replace('#^avatar\.driver.#', '', $driver); + $driver_name = $phpbb_avatar_manager->clean_driver_name($request->variable('avatar_driver', '')); - if (in_array($driver, $avatar_drivers) && $config["allow_avatar_$config_name"] && !$request->is_set_post('avatar_delete')) + if (in_array($driver_name, $avatar_drivers) && !$request->is_set_post('avatar_delete')) { - $avatar = $phpbb_avatar_manager->get_driver($driver); - $result = $avatar->process_form($template, $avatar_data, $error); + $driver = $phpbb_avatar_manager->get_driver($driver_name); + $result = $driver->process_form($template, $avatar_data, $error); if ($result && empty($error)) { // Success! Lets save the result in the database $result = array( - 'user_avatar_type' => $driver, + 'user_avatar_type' => $driver_name, 'user_avatar' => $result['avatar'], 'user_avatar_width' => $result['avatar_width'], 'user_avatar_height' => $result['avatar_height'], @@ -598,9 +596,9 @@ class ucp_profile } else { - if ($avatar = $phpbb_avatar_manager->get_driver($user->data['user_avatar_type'])) + if ($driver = $phpbb_avatar_manager->get_driver($user->data['user_avatar_type'])) { - $avatar->delete($avatar_data); + $driver->delete($avatar_data); } $result = array( @@ -629,18 +627,18 @@ class ucp_profile $focused_driver = $phpbb_avatar_manager->clean_driver_name($request->variable('avatar_driver', $user->data['user_avatar_type'])); - foreach ($avatar_drivers as $driver) + foreach ($avatar_drivers as $current_driver) { - $avatar = $phpbb_avatar_manager->get_driver($driver); + $driver = $phpbb_avatar_manager->get_driver($current_driver); $avatars_enabled = true; $template->set_filenames(array( - 'avatar' => $avatar->get_template_name(), + 'avatar' => $driver->get_template_name(), )); - if ($avatar->prepare_form($template, $avatar_data, $error)) + if ($driver->prepare_form($template, $avatar_data, $error)) { - $driver_name = $phpbb_avatar_manager->prepare_driver_name($driver); + $driver_name = $phpbb_avatar_manager->prepare_driver_name($current_driver); $driver_upper = strtoupper($driver_name); $template->assign_block_vars('avatar_drivers', array( @@ -648,7 +646,7 @@ class ucp_profile 'L_EXPLAIN' => $user->lang($driver_upper . '_EXPLAIN'), 'DRIVER' => $driver_name, - 'SELECTED' => $driver == $focused_driver, + 'SELECTED' => $current_driver == $focused_driver, 'OUTPUT' => $template->assign_display('avatar'), )); } From 081440f6c4bd6b7c2838dd0587ed6a4dffc87d52 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Fri, 30 Nov 2012 23:11:44 +0100 Subject: [PATCH 0507/2494] [feature/avatars] Create setting for enabling avatar in manager PHPBB3-10018 --- phpBB/includes/acp/acp_board.php | 13 ++++++++--- phpBB/includes/avatar/driver/driver.php | 28 ----------------------- phpBB/includes/avatar/driver/gravatar.php | 10 -------- phpBB/includes/avatar/driver/local.php | 1 - phpBB/includes/avatar/driver/remote.php | 10 -------- phpBB/includes/avatar/driver/upload.php | 22 ++++-------------- phpBB/includes/avatar/manager.php | 16 +++++++++++++ 7 files changed, 31 insertions(+), 69 deletions(-) diff --git a/phpBB/includes/acp/acp_board.php b/phpBB/includes/acp/acp_board.php index 0467cc7c35..bb90918a46 100644 --- a/phpBB/includes/acp/acp_board.php +++ b/phpBB/includes/acp/acp_board.php @@ -111,10 +111,17 @@ class acp_board $avatar_drivers = $phpbb_avatar_manager->get_valid_drivers(true); $avatar_vars = array(); - foreach ($avatar_drivers as $driver) + foreach ($avatar_drivers as $current_driver) { - $avatar = $phpbb_avatar_manager->get_driver($driver); - $avatar_vars += $avatar->prepare_form_acp(); + $driver = $phpbb_avatar_manager->get_driver($current_driver); + + /* + * First grab the settings for enabling/disabling the avatar + * driver and afterwards grab additional settings the driver + * might have. + */ + $avatar_vars += $phpbb_avatar_manager->get_avatar_settings($driver); + $avatar_vars += $driver->prepare_form_acp(); } $display_vars = array( diff --git a/phpBB/includes/avatar/driver/driver.php b/phpBB/includes/avatar/driver/driver.php index 317fe91b83..ab89cfbffe 100644 --- a/phpBB/includes/avatar/driver/driver.php +++ b/phpBB/includes/avatar/driver/driver.php @@ -75,18 +75,6 @@ abstract class phpbb_avatar_driver implements phpbb_avatar_driver_interface $this->cache = $cache; } - /** - * @inheritdoc - */ - public function get_data($row) - { - return array( - 'src' => '', - 'width' => 0, - 'height' => 0, - ); - } - /** * @inheritdoc */ @@ -95,14 +83,6 @@ abstract class phpbb_avatar_driver implements phpbb_avatar_driver_interface return ''; } - /** - * @inheritdoc - */ - public function prepare_form($template, $row, &$error) - { - return false; - } - /** * @inheritdoc */ @@ -111,14 +91,6 @@ abstract class phpbb_avatar_driver implements phpbb_avatar_driver_interface return array(); } - /** - * @inheritdoc - */ - public function process_form($template, $row, &$error) - { - return false; - } - /** * @inheritdoc */ diff --git a/phpBB/includes/avatar/driver/gravatar.php b/phpBB/includes/avatar/driver/gravatar.php index 001a741c3f..8fa95bf937 100644 --- a/phpBB/includes/avatar/driver/gravatar.php +++ b/phpBB/includes/avatar/driver/gravatar.php @@ -63,16 +63,6 @@ class phpbb_avatar_driver_gravatar extends phpbb_avatar_driver return true; } - /** - * @inheritdoc - */ - public function prepare_form_acp() - { - return array( - 'allow_avatar_gravatar' => array('lang' => 'ALLOW_GRAVATAR', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), - ); - } - /** * @inheritdoc */ diff --git a/phpBB/includes/avatar/driver/local.php b/phpBB/includes/avatar/driver/local.php index 479ee3712a..4593161a76 100644 --- a/phpBB/includes/avatar/driver/local.php +++ b/phpBB/includes/avatar/driver/local.php @@ -107,7 +107,6 @@ class phpbb_avatar_driver_local extends phpbb_avatar_driver public function prepare_form_acp() { return array( - 'allow_avatar_local' => array('lang' => 'ALLOW_LOCAL', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), 'avatar_gallery_path' => array('lang' => 'AVATAR_GALLERY_PATH', 'validate' => 'rpath', 'type' => 'text:20:255', 'explain' => true), ); } diff --git a/phpBB/includes/avatar/driver/remote.php b/phpBB/includes/avatar/driver/remote.php index 344275a251..e96cb35684 100644 --- a/phpBB/includes/avatar/driver/remote.php +++ b/phpBB/includes/avatar/driver/remote.php @@ -47,16 +47,6 @@ class phpbb_avatar_driver_remote extends phpbb_avatar_driver return true; } - /** - * @inheritdoc - */ - public function prepare_form_acp() - { - return array( - 'allow_avatar_remote' => array('lang' => 'ALLOW_REMOTE', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - ); - } - /** * @inheritdoc */ diff --git a/phpBB/includes/avatar/driver/upload.php b/phpBB/includes/avatar/driver/upload.php index 497dd8ad19..38627baacf 100644 --- a/phpBB/includes/avatar/driver/upload.php +++ b/phpBB/includes/avatar/driver/upload.php @@ -26,22 +26,11 @@ class phpbb_avatar_driver_upload extends phpbb_avatar_driver */ public function get_data($row, $ignore_config = false) { - if ($ignore_config || $this->config['allow_avatar_upload']) - { - return array( - 'src' => $this->phpbb_root_path . 'download/file' . $this->php_ext . '?avatar=' . $row['avatar'], - 'width' => $row['avatar_width'], - 'height' => $row['avatar_height'], - ); - } - else - { - return array( - 'src' => '', - 'width' => 0, - 'height' => 0, - ); - } + return array( + 'src' => $this->phpbb_root_path . 'download/file' . $this->php_ext . '?avatar=' . $row['avatar'], + 'width' => $row['avatar_width'], + 'height' => $row['avatar_height'], + ); } /** @@ -133,7 +122,6 @@ class phpbb_avatar_driver_upload extends phpbb_avatar_driver global $user; return array( - 'allow_avatar_upload' => array('lang' => 'ALLOW_UPLOAD', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), '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' => 'text:4:10', 'explain' => true, 'append' => ' ' . $user->lang['BYTES']), 'avatar_path' => array('lang' => 'AVATAR_STORAGE_PATH', 'validate' => 'rwpath', 'type' => 'text:20:255', 'explain' => true), diff --git a/phpBB/includes/avatar/manager.php b/phpBB/includes/avatar/manager.php index 176d0d659d..267ba24dc8 100644 --- a/phpBB/includes/avatar/manager.php +++ b/phpBB/includes/avatar/manager.php @@ -201,4 +201,20 @@ class phpbb_avatar_manager return $this->config["allow_avatar_{$config_name}"]; } + + /** + * Get the settings array for enabling/disabling an avatar driver + * + * @param string $driver Avatar driver object + * + * @return array Array of configuration options as consumed by acp_board + */ + public function get_avatar_settings($driver) + { + $config_name = preg_replace('#^phpbb_avatar_driver_#', '', get_class($driver)); + + return array( + 'allow_avatar_' . $config_name => array('lang' => 'ALLOW_' . strtoupper($config_name), 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), + ); + } } From d439f477105903ceb29652f23bcb7812d0f34d4d Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sat, 1 Dec 2012 00:27:52 +0100 Subject: [PATCH 0508/2494] [feature/avatars] Fix docblocks and minor cosmetic issues PHPBB3-10018 --- phpBB/includes/avatar/driver/gravatar.php | 2 +- phpBB/includes/avatar/driver/interface.php | 27 ++++++++++++++-------- phpBB/includes/avatar/driver/local.php | 2 +- phpBB/includes/avatar/driver/remote.php | 2 +- phpBB/includes/avatar/manager.php | 13 ++++------- phpBB/includes/ucp/ucp_profile.php | 2 +- 6 files changed, 26 insertions(+), 22 deletions(-) diff --git a/phpBB/includes/avatar/driver/gravatar.php b/phpBB/includes/avatar/driver/gravatar.php index 8fa95bf937..11996ca561 100644 --- a/phpBB/includes/avatar/driver/gravatar.php +++ b/phpBB/includes/avatar/driver/gravatar.php @@ -72,7 +72,7 @@ class phpbb_avatar_driver_gravatar extends phpbb_avatar_driver $row['avatar_width'] = $this->request->variable('avatar_gravatar_width', 0); $row['avatar_height'] = $this->request->variable('avatar_gravatar_height', 0); - if (!function_exists('user_add')) + if (!function_exists('validate_data')) { require($this->phpbb_root_path . 'includes/functions_user' . $this->php_ext); } diff --git a/phpBB/includes/avatar/driver/interface.php b/phpBB/includes/avatar/driver/interface.php index bba4bd102e..e8f529f3c4 100644 --- a/phpBB/includes/avatar/driver/interface.php +++ b/phpBB/includes/avatar/driver/interface.php @@ -24,7 +24,7 @@ interface phpbb_avatar_driver_interface /** * Returns the name of the driver. * - * @return string Name of wrapped driver. + * @return string Name of driver. */ public function get_name(); @@ -50,10 +50,13 @@ interface phpbb_avatar_driver_interface /** * Prepare form for changing the settings of this avatar * - * @param object $template Template object + * @param phpbb_template $template Template object * @param array $row User data or group data that has been cleaned with * phpbb_avatar_manager::clean_row - * @param array &$error Reference to an error array + * @param array &$error Reference to an error array that is filled by this + * function. Key values can either be a string with a language key or + * an array that will be passed to vsprintf() with the language key in + * the first array key. * * @return bool True if form has been successfully prepared */ @@ -62,17 +65,22 @@ interface phpbb_avatar_driver_interface /** * Prepare form for changing the acp settings of this avatar * - * @return array Array containing the acp settings + * @return array Array of configuration options as consumed by acp_board. + * The setting for enabling/disabling the avatar will be handled by + * the avatar manager. */ public function prepare_form_acp(); /** * Process form data * - * @param object $template Template object + * @param phpbb_template $template Template object * @param array $row User data or group data that has been cleaned with * phpbb_avatar_manager::clean_row - * @param array &$error Reference to an error array + * @param array &$error Reference to an error array that is filled by this + * function. Key values can either be a string with a language key or + * an array that will be passed to vsprintf() with the language key in + * the first array key. * * @return array Array containing the avatar data as follows: * ['avatar'], ['avatar_width'], ['avatar_height'] @@ -85,14 +93,15 @@ interface phpbb_avatar_driver_interface * @param array $row User data or group data that has been cleaned with * phpbb_avatar_manager::clean_row * - * @return bool True if avatar has been deleted or there is no need to delete + * @return bool True if avatar has been deleted or there is no need to delete, + * i.e. when the avatar is not hosted locally. */ public function delete($row); /** - * Get the avatars template name + * Get the avatar driver's template name * - * @return string Avatar's template name + * @return string Avatar driver's template name */ public function get_template_name(); } diff --git a/phpBB/includes/avatar/driver/local.php b/phpBB/includes/avatar/driver/local.php index 4593161a76..d7611b903a 100644 --- a/phpBB/includes/avatar/driver/local.php +++ b/phpBB/includes/avatar/driver/local.php @@ -174,7 +174,7 @@ class phpbb_avatar_driver_local extends phpbb_avatar_driver ); } } - @ksort($avatar_list); + ksort($avatar_list); if ($this->cache != null) { diff --git a/phpBB/includes/avatar/driver/remote.php b/phpBB/includes/avatar/driver/remote.php index e96cb35684..9135a62eac 100644 --- a/phpBB/includes/avatar/driver/remote.php +++ b/phpBB/includes/avatar/driver/remote.php @@ -61,7 +61,7 @@ class phpbb_avatar_driver_remote extends phpbb_avatar_driver $url = 'http://' . $url; } - if (!function_exists('user_add')) + if (!function_exists('validate_data')) { require($this->phpbb_root_path . 'includes/functions_user' . $this->php_ext); } diff --git a/phpBB/includes/avatar/manager.php b/phpBB/includes/avatar/manager.php index 267ba24dc8..409d0d4eea 100644 --- a/phpBB/includes/avatar/manager.php +++ b/phpBB/includes/avatar/manager.php @@ -85,16 +85,11 @@ class phpbb_avatar_manager return null; } + /* + * There is no need to handle invalid avatar types as the following code + * will cause a ServiceNotFoundException if the type does not exist + */ $driver = $this->container->get($avatar_type); - if ($driver !== false) - { - return $driver; - } - else - { - $message = "Invalid avatar driver class name '%s' provided."; - trigger_error(sprintf($message, $avatar_type)); - } return $driver; } diff --git a/phpBB/includes/ucp/ucp_profile.php b/phpBB/includes/ucp/ucp_profile.php index 71a4d4e67b..ecd828c6dc 100644 --- a/phpBB/includes/ucp/ucp_profile.php +++ b/phpBB/includes/ucp/ucp_profile.php @@ -545,7 +545,7 @@ class ucp_profile break; case 'avatar': - if (!function_exists('display_forums')) + if (!function_exists('get_user_avatar')) { include($phpbb_root_path . 'includes/functions_display.' . $phpEx); } From 215ac6a0daa51881dc6abb987baf10e682fc9972 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sat, 1 Dec 2012 21:28:44 +0100 Subject: [PATCH 0509/2494] [feature/avatars] Removed unneeded dependencies PHPBB3-10018 --- phpBB/config/services.yml | 4 ---- phpBB/includes/avatar/manager.php | 10 +--------- 2 files changed, 1 insertion(+), 13 deletions(-) diff --git a/phpBB/config/services.yml b/phpBB/config/services.yml index 3d33731eea..6649b36ae6 100644 --- a/phpBB/config/services.yml +++ b/phpBB/config/services.yml @@ -17,11 +17,7 @@ services: avatar.manager: class: phpbb_avatar_manager arguments: - - %core.root_path% - - .%core.php_ext% - @config - - @request - - @cache.driver - @avatar.driver_collection - @service_container diff --git a/phpBB/includes/avatar/manager.php b/phpBB/includes/avatar/manager.php index 409d0d4eea..e7ee323624 100644 --- a/phpBB/includes/avatar/manager.php +++ b/phpBB/includes/avatar/manager.php @@ -20,11 +20,7 @@ if (!defined('IN_PHPBB')) */ class phpbb_avatar_manager { - protected $phpbb_root_path; - protected $phpEx; protected $config; - protected $request; - protected $cache; protected static $valid_drivers = false; protected $avatar_drivers; protected $container; @@ -40,13 +36,9 @@ class phpbb_avatar_manager * @param array $avatar_drivers Avatar drivers passed via the service container * @param object $container Container object */ - public function __construct($phpbb_root_path, $phpEx, phpbb_config $config, phpbb_request $request, phpbb_cache_driver_interface $cache, $avatar_drivers, $container) + public function __construct(phpbb_config $config, $avatar_drivers, $container) { - $this->phpbb_root_path = $phpbb_root_path; - $this->phpEx = $phpEx; $this->config = $config; - $this->request = $request; - $this->cache = $cache; $this->avatar_drivers = $avatar_drivers; $this->container = $container; } From d771453b520938e21d52ad3464298a9cc0d0fa03 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sat, 1 Dec 2012 21:37:57 +0100 Subject: [PATCH 0510/2494] [feature/avatars] Add tests for avatar manager PHPBB3-10018 --- tests/avatar/manager_test.php | 82 +++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 tests/avatar/manager_test.php diff --git a/tests/avatar/manager_test.php b/tests/avatar/manager_test.php new file mode 100644 index 0000000000..12c88dd855 --- /dev/null +++ b/tests/avatar/manager_test.php @@ -0,0 +1,82 @@ + 'foobar', + 'user_avatar_width' => 50, + 'user_avatar_height' => 50, + ); + + protected $clean_user_row = array( + 'avatar' => 'foobar', + 'avatar_width' => 50, + 'avatar_height' => 50, + ); + + public function setUp() + { + global $phpbb_root_path, $phpEx; + + // Mock phpbb_container + $this->phpbb_container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface'); + $this->phpbb_container->expects($this->any()) + ->method('get') + ->with('avatar.driver.gravatar')->will($this->returnValue('avatar_foo')); + + // Prepare dependencies for avatar manager and driver + $config = new phpbb_config(array()); + $request = $this->getMock('phpbb_request'); + $cache = $this->getMock('phpbb_cache_driver_interface'); + + // Create new avatar driver object for manager + $this->avatar_gravatar = new phpbb_avatar_driver_gravatar($config, $request, $phpbb_root_path, $phpEx, $cache); + $this->avatar_gravatar->set_name('avatar.driver.gravatar'); + $avatar_drivers = array($this->avatar_gravatar); + + // Set up avatar manager + $this->manager = new phpbb_avatar_manager($config, $avatar_drivers, $this->phpbb_container); + } + + public function test_get_driver() + { + $driver = $this->manager->get_driver('avatar.driver.gravatar', true); + $this->assertEquals('avatar_foo', $driver); + + $driver = $this->manager->get_driver('avatar.driver.foo', true); + $this->assertNull($driver); + } + + public function test_get_valid_drivers() + { + $valid_drivers = $this->manager->get_valid_drivers(true); + $this->assertArrayHasKey('avatar.driver.gravatar', $valid_drivers); + $this->assertEquals('avatar.driver.gravatar', $valid_drivers['avatar.driver.gravatar']); + } + + public function test_get_avatar_settings() + { + $avatar_settings = $this->manager->get_avatar_settings($this->avatar_gravatar); + + $expected_settings = array( + 'allow_avatar_gravatar' => array('lang' => 'ALLOW_GRAVATAR', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), + ); + + $this->assertEquals($expected_settings, $avatar_settings); + } +} From 232fa5b5884d97329b2bf5c79907dfa0128b618b Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 2 Dec 2012 01:19:10 +0100 Subject: [PATCH 0511/2494] [feature/avatars] Do not use gravatar avatar in tests PHPBB3-10018 --- tests/avatar/driver/foobar.php | 19 +++++++++++++ tests/avatar/manager_test.php | 49 +++++++++++----------------------- 2 files changed, 35 insertions(+), 33 deletions(-) create mode 100644 tests/avatar/driver/foobar.php diff --git a/tests/avatar/driver/foobar.php b/tests/avatar/driver/foobar.php new file mode 100644 index 0000000000..fe4d47d923 --- /dev/null +++ b/tests/avatar/driver/foobar.php @@ -0,0 +1,19 @@ + 'foobar', - 'user_avatar_width' => 50, - 'user_avatar_height' => 50, - ); - - protected $clean_user_row = array( - 'avatar' => 'foobar', - 'avatar_width' => 50, - 'avatar_height' => 50, - ); - public function setUp() { global $phpbb_root_path, $phpEx; @@ -37,17 +20,17 @@ class phpbb_avatar_test extends PHPUnit_Framework_TestCase $this->phpbb_container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface'); $this->phpbb_container->expects($this->any()) ->method('get') - ->with('avatar.driver.gravatar')->will($this->returnValue('avatar_foo')); + ->with('avatar.driver.foobar')->will($this->returnValue('avatar.driver.foobar')); // Prepare dependencies for avatar manager and driver $config = new phpbb_config(array()); $request = $this->getMock('phpbb_request'); $cache = $this->getMock('phpbb_cache_driver_interface'); - - // Create new avatar driver object for manager - $this->avatar_gravatar = new phpbb_avatar_driver_gravatar($config, $request, $phpbb_root_path, $phpEx, $cache); - $this->avatar_gravatar->set_name('avatar.driver.gravatar'); - $avatar_drivers = array($this->avatar_gravatar); + $this->avatar_foobar = $this->getMock('phpbb_avatar_driver_foobar', array('get_name'), array($config, $request, $phpbb_root_path, $phpEx, $cache)); + $this->avatar_foobar->expects($this->any()) + ->method('get_name') + ->will($this->returnValue('avatar.driver.foobar')); + $avatar_drivers = array($this->avatar_foobar); // Set up avatar manager $this->manager = new phpbb_avatar_manager($config, $avatar_drivers, $this->phpbb_container); @@ -55,26 +38,26 @@ class phpbb_avatar_test extends PHPUnit_Framework_TestCase public function test_get_driver() { - $driver = $this->manager->get_driver('avatar.driver.gravatar', true); - $this->assertEquals('avatar_foo', $driver); + $driver = $this->manager->get_driver('avatar.driver.foobar', true); + $this->assertEquals('avatar.driver.foobar', $driver); - $driver = $this->manager->get_driver('avatar.driver.foo', true); + $driver = $this->manager->get_driver('avatar.driver.foo_wrong', true); $this->assertNull($driver); } public function test_get_valid_drivers() { $valid_drivers = $this->manager->get_valid_drivers(true); - $this->assertArrayHasKey('avatar.driver.gravatar', $valid_drivers); - $this->assertEquals('avatar.driver.gravatar', $valid_drivers['avatar.driver.gravatar']); + $this->assertArrayHasKey('avatar.driver.foobar', $valid_drivers); + $this->assertEquals('avatar.driver.foobar', $valid_drivers['avatar.driver.foobar']); } public function test_get_avatar_settings() { - $avatar_settings = $this->manager->get_avatar_settings($this->avatar_gravatar); + $avatar_settings = $this->manager->get_avatar_settings($this->avatar_foobar); $expected_settings = array( - 'allow_avatar_gravatar' => array('lang' => 'ALLOW_GRAVATAR', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), + 'allow_avatar_' . get_class($this->avatar_foobar) => array('lang' => 'ALLOW_' . strtoupper(get_class($this->avatar_foobar)), 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), ); $this->assertEquals($expected_settings, $avatar_settings); From ce653db49129f215c18c4d0dab24001d73ba94e6 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 2 Dec 2012 01:22:42 +0100 Subject: [PATCH 0512/2494] [feature/avatars] Remove unnecessary "implements" from foobar avatar PHPBB3-10018 --- tests/avatar/driver/foobar.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/avatar/driver/foobar.php b/tests/avatar/driver/foobar.php index fe4d47d923..fd4e452818 100644 --- a/tests/avatar/driver/foobar.php +++ b/tests/avatar/driver/foobar.php @@ -1,6 +1,6 @@ Date: Sat, 1 Dec 2012 20:12:31 -0500 Subject: [PATCH 0513/2494] [ticket/11162] An implementation that actually works. PHPBB3-11162 --- phpBB/includes/functions.php | 73 +++++++++++++++++++++++++++++++++--- 1 file changed, 68 insertions(+), 5 deletions(-) diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 8608c6ca4f..13690e79bb 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -1311,12 +1311,75 @@ function tz_select($default = '', $truncate = false) */ function phpbb_update_rows_avoiding_duplicates($db, $table, $column, $from_values, $to_value) { - $db->sql_return_on_error(true); - $condition = $db->sql_in_set($column, $from_values); - $db->sql_query('UPDATE ' . $table . ' SET ' . $column . ' = ' . (int) $to_value. ' WHERE ' . $condition); - $db->sql_return_on_error(false); + $sql = "SELECT $column, user_id + FROM $table + WHERE " . $db->sql_in_set($column, $from_values); + $result = $db->sql_query($sql); - $db->sql_query('DELETE FROM ' . $table . ' WHERE ' . $condition); + $old_user_ids = array(); + while ($row = $db->sql_fetchrow($result)) + { + $old_user_ids[$row[$column]][] = $row['user_id']; + } + $db->sql_freeresult($result); + + $sql = "SELECT $column, user_id + FROM $table + WHERE $column = '" . (int) $to_value . "'"; + $result = $db->sql_query($sql); + + $new_user_ids = array(); + while ($row = $db->sql_fetchrow($result)) + { + $new_user_ids[$row[$column]][] = $row['user_id']; + } + $db->sql_freeresult($result); + + $queries = array(); + $any_found = false; + foreach ($from_values as $from_value) + { + if (!isset($old_user_ids[$from_value])) + { + continue; + } + $any_found = true; + if (empty($new_user_ids)) + { + $sql = "UPDATE $table + SET $column = " . (int) $to_value. " + WHERE $column = '" . $db->sql_escape($from_value) . "'"; + $queries[] = $sql; + } + else + { + $different_user_ids = array_diff($old_user_ids[$from_value], $new_user_ids[$to_value]); + if (!empty($different_user_ids)) + { + $sql = "UPDATE $table + SET $column = " . (int) $to_value. " + WHERE $column = '" . $db->sql_escape($from_value) . "' + AND " . $db->sql_in_set('user_id', $different_user_ids); + $queries[] = $sql; + } + } + } + + if ($any_found) + { + //$db->sql_transaction('begin'); + + foreach ($queries as $sql) + { + $db->sql_query($sql); + } + + $sql = "DELETE FROM $table + WHERE " . $db->sql_in_set($column, $from_values); + $db->sql_query($sql); + + //$db->sql_transaction('commit'); + } } // Functions handling topic/post tracking/marking From 2e947334e563f122c597d7072eddd962453a84ef Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Sat, 1 Dec 2012 20:17:01 -0500 Subject: [PATCH 0514/2494] [ticket/11162] Uncomment transactions. PHPBB3-11162 --- phpBB/includes/functions.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 13690e79bb..a24dcfdf5b 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -1367,7 +1367,7 @@ function phpbb_update_rows_avoiding_duplicates($db, $table, $column, $from_value if ($any_found) { - //$db->sql_transaction('begin'); + $db->sql_transaction('begin'); foreach ($queries as $sql) { @@ -1378,7 +1378,7 @@ function phpbb_update_rows_avoiding_duplicates($db, $table, $column, $from_value WHERE " . $db->sql_in_set($column, $from_values); $db->sql_query($sql); - //$db->sql_transaction('commit'); + $db->sql_transaction('commit'); } } From c2c105df9ff1d8fd48afa1d3abdf23a39584d7ed Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Sat, 1 Dec 2012 20:21:29 -0500 Subject: [PATCH 0515/2494] [ticket/11162] Clarify that only the two tables actually work. PHPBB3-11162 --- phpBB/includes/functions.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index a24dcfdf5b..09487ce10d 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -1302,6 +1302,8 @@ function tz_select($default = '', $truncate = false) * If this results in rows violating uniqueness constraints, the duplicate * rows are eliminated. * +* The only supported tables are bookmarks and topics_watch. +* * @param dbal $db Database object * @param string $table Table on which to perform the update * @param string $column Column whose values to change From 69225bd0a6005e81b7cb58631eb5de7c3d175697 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Sat, 1 Dec 2012 20:21:51 -0500 Subject: [PATCH 0516/2494] [ticket/11162] Use phpbb_update_rows_avoiding_duplicates in mcp. PHPBB3-11162 --- phpBB/includes/mcp/mcp_forum.php | 7 +------ phpBB/includes/mcp/mcp_topic.php | 7 +------ 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/phpBB/includes/mcp/mcp_forum.php b/phpBB/includes/mcp/mcp_forum.php index b70601b479..913c55a9d1 100644 --- a/phpBB/includes/mcp/mcp_forum.php +++ b/phpBB/includes/mcp/mcp_forum.php @@ -415,12 +415,7 @@ function merge_topics($forum_id, $topic_ids, $to_topic_id) $success_msg = 'POSTS_MERGED_SUCCESS'; // If the topic no longer exist, we will update the topic watch table. - // To not let it error out on users watching both topics, we just return on an error... - $db->sql_return_on_error(true); - $db->sql_query('UPDATE ' . TOPICS_WATCH_TABLE . ' SET topic_id = ' . (int) $to_topic_id . ' WHERE ' . $db->sql_in_set('topic_id', $topic_ids)); - $db->sql_return_on_error(false); - - $db->sql_query('DELETE FROM ' . TOPICS_WATCH_TABLE . ' WHERE ' . $db->sql_in_set('topic_id', $topic_ids)); + phpbb_update_rows_avoiding_duplicates($db, TOPICS_WATCH_TABLE, 'topic_id', $topic_ids, $to_topic_id); // Link to the new topic $return_link .= (($return_link) ? '

    ' : '') . sprintf($user->lang['RETURN_NEW_TOPIC'], '', ''); diff --git a/phpBB/includes/mcp/mcp_topic.php b/phpBB/includes/mcp/mcp_topic.php index 7d4edaf362..f40a4bc044 100644 --- a/phpBB/includes/mcp/mcp_topic.php +++ b/phpBB/includes/mcp/mcp_topic.php @@ -620,12 +620,7 @@ function merge_posts($topic_id, $to_topic_id) else { // If the topic no longer exist, we will update the topic watch table. - // To not let it error out on users watching both topics, we just return on an error... - $db->sql_return_on_error(true); - $db->sql_query('UPDATE ' . TOPICS_WATCH_TABLE . ' SET topic_id = ' . (int) $to_topic_id . ' WHERE topic_id = ' . (int) $topic_id); - $db->sql_return_on_error(false); - - $db->sql_query('DELETE FROM ' . TOPICS_WATCH_TABLE . ' WHERE topic_id = ' . (int) $topic_id); + phpbb_update_rows_avoiding_duplicates($db, TOPICS_WATCH_TABLE, 'topic_id', $topic_ids, $to_topic_id); } // Link to the new topic From 05053dacd350c6bacd529df803bdc9876104a278 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Sat, 1 Dec 2012 20:24:25 -0500 Subject: [PATCH 0517/2494] [ticket/11162] Fix inaccurately copy pasted comment. PHPBB3-11162 --- phpBB/includes/mcp/mcp_forum.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/mcp/mcp_forum.php b/phpBB/includes/mcp/mcp_forum.php index 913c55a9d1..e392bef157 100644 --- a/phpBB/includes/mcp/mcp_forum.php +++ b/phpBB/includes/mcp/mcp_forum.php @@ -414,7 +414,7 @@ function merge_topics($forum_id, $topic_ids, $to_topic_id) // Message and return links $success_msg = 'POSTS_MERGED_SUCCESS'; - // If the topic no longer exist, we will update the topic watch table. + // Update the topic watch table. phpbb_update_rows_avoiding_duplicates($db, TOPICS_WATCH_TABLE, 'topic_id', $topic_ids, $to_topic_id); // Link to the new topic From 2fc43e6ed71e4b9abdb76aa179b4e64efaa47ffa Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Sat, 1 Dec 2012 23:11:14 -0500 Subject: [PATCH 0518/2494] [ticket/11162] No whitespace changes in olympus. PHPBB3-11162 --- phpBB/includes/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 09487ce10d..e3feb59d41 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -3442,7 +3442,7 @@ function parse_cfg_file($filename, $lines = false) $parsed_items[$key] = $value; } - + if (isset($parsed_items['inherit_from']) && isset($parsed_items['name']) && $parsed_items['inherit_from'] == $parsed_items['name']) { unset($parsed_items['inherit_from']); From b42ca792fd7765eb415536c49b77c53c0897367e Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Tue, 4 Dec 2012 00:49:37 +0100 Subject: [PATCH 0519/2494] [feature/avatars] Minor variable naming fixes PHPBB3-10018 --- phpBB/adm/style/acp_users_avatar.html | 2 +- phpBB/adm/style/avatars.js | 6 +++--- phpBB/includes/acp/acp_groups.php | 4 ++-- phpBB/includes/acp/acp_users.php | 4 ++-- phpBB/includes/ucp/ucp_groups.php | 4 ++-- phpBB/includes/ucp/ucp_profile.php | 4 ++-- phpBB/styles/prosilver/template/avatars.js | 6 +++--- phpBB/styles/subsilver2/template/avatars.js | 6 +++--- 8 files changed, 18 insertions(+), 18 deletions(-) diff --git a/phpBB/adm/style/acp_users_avatar.html b/phpBB/adm/style/acp_users_avatar.html index bc3a19a25e..0a72bb0b62 100644 --- a/phpBB/adm/style/acp_users_avatar.html +++ b/phpBB/adm/style/acp_users_avatar.html @@ -32,8 +32,8 @@
    -
    {S_FORM_TOKEN} + diff --git a/phpBB/adm/style/avatars.js b/phpBB/adm/style/avatars.js index 882bcfe36d..a53814c15f 100644 --- a/phpBB/adm/style/avatars.js +++ b/phpBB/adm/style/avatars.js @@ -2,14 +2,14 @@ "use strict"; -function avatar_simplify() { +function avatar_hide() { $('#avatar_options > div').hide(); var selected = $('#avatar_driver').val(); $('#avatar_option_' + selected).show(); } -avatar_simplify(); -$('#avatar_driver').bind('change', avatar_simplify); +avatar_hide(); +$('#avatar_driver').bind('change', avatar_hide); })(jQuery); // Avoid conflicts with other libraries diff --git a/phpBB/includes/acp/acp_groups.php b/phpBB/includes/acp/acp_groups.php index 23f6d775ef..b425b9d374 100644 --- a/phpBB/includes/acp/acp_groups.php +++ b/phpBB/includes/acp/acp_groups.php @@ -520,7 +520,7 @@ class acp_groups if ($config['allow_avatar']) { $avatars_enabled = false; - $focused_driver = $phpbb_avatar_manager->clean_driver_name($request->variable('avatar_driver', $avatar_data['avatar_type'])); + $selected_driver = $phpbb_avatar_manager->clean_driver_name($request->variable('avatar_driver', $avatar_data['avatar_type'])); foreach ($avatar_drivers as $driver) { @@ -541,7 +541,7 @@ class acp_groups 'L_EXPLAIN' => $user->lang($driver_upper . '_EXPLAIN'), 'DRIVER' => $driver_name, - 'SELECTED' => $driver == $focused_driver, + 'SELECTED' => $driver == $selected_driver, 'OUTPUT' => $template->assign_display('avatar'), )); } diff --git a/phpBB/includes/acp/acp_users.php b/phpBB/includes/acp/acp_users.php index 3df373a7d4..5c485b5996 100644 --- a/phpBB/includes/acp/acp_users.php +++ b/phpBB/includes/acp/acp_users.php @@ -1801,7 +1801,7 @@ class acp_users } } - $focused_driver = $phpbb_avatar_manager->clean_driver_name($request->variable('avatar_driver', $user_row['user_avatar_type'])); + $selected_driver = $phpbb_avatar_manager->clean_driver_name($request->variable('avatar_driver', $user_row['user_avatar_type'])); foreach ($avatar_drivers as $current_driver) { @@ -1823,7 +1823,7 @@ class acp_users 'L_EXPLAIN' => $user->lang($driver_upper . '_EXPLAIN'), 'DRIVER' => $driver_name, - 'SELECTED' => $current_driver == $focused_driver, + 'SELECTED' => $current_driver == $selected_driver, 'OUTPUT' => $template->assign_display('avatar'), )); } diff --git a/phpBB/includes/ucp/ucp_groups.php b/phpBB/includes/ucp/ucp_groups.php index c1ddaccb75..262e7b238f 100644 --- a/phpBB/includes/ucp/ucp_groups.php +++ b/phpBB/includes/ucp/ucp_groups.php @@ -646,7 +646,7 @@ class ucp_groups if ($config['allow_avatar']) { $avatars_enabled = false; - $focused_driver = $phpbb_avatar_manager->clean_driver_name($request->variable('avatar_driver', $avatar_data['avatar_type'])); + $selected_driver = $phpbb_avatar_manager->clean_driver_name($request->variable('avatar_driver', $avatar_data['avatar_type'])); foreach ($avatar_drivers as $current_driver) { @@ -666,7 +666,7 @@ class ucp_groups 'L_EXPLAIN' => $user->lang($driver_upper . '_EXPLAIN'), 'DRIVER' => $driver_name, - 'SELECTED' => $current_driver == $focused_driver, + 'SELECTED' => $current_driver == $selected_driver, 'OUTPUT' => $template->assign_display('avatar'), )); } diff --git a/phpBB/includes/ucp/ucp_profile.php b/phpBB/includes/ucp/ucp_profile.php index ecd828c6dc..7b4dddf12b 100644 --- a/phpBB/includes/ucp/ucp_profile.php +++ b/phpBB/includes/ucp/ucp_profile.php @@ -625,7 +625,7 @@ class ucp_profile } } - $focused_driver = $phpbb_avatar_manager->clean_driver_name($request->variable('avatar_driver', $user->data['user_avatar_type'])); + $selected_driver = $phpbb_avatar_manager->clean_driver_name($request->variable('avatar_driver', $user->data['user_avatar_type'])); foreach ($avatar_drivers as $current_driver) { @@ -646,7 +646,7 @@ class ucp_profile 'L_EXPLAIN' => $user->lang($driver_upper . '_EXPLAIN'), 'DRIVER' => $driver_name, - 'SELECTED' => $current_driver == $focused_driver, + 'SELECTED' => $current_driver == $selected_driver, 'OUTPUT' => $template->assign_display('avatar'), )); } diff --git a/phpBB/styles/prosilver/template/avatars.js b/phpBB/styles/prosilver/template/avatars.js index 882bcfe36d..a53814c15f 100644 --- a/phpBB/styles/prosilver/template/avatars.js +++ b/phpBB/styles/prosilver/template/avatars.js @@ -2,14 +2,14 @@ "use strict"; -function avatar_simplify() { +function avatar_hide() { $('#avatar_options > div').hide(); var selected = $('#avatar_driver').val(); $('#avatar_option_' + selected).show(); } -avatar_simplify(); -$('#avatar_driver').bind('change', avatar_simplify); +avatar_hide(); +$('#avatar_driver').bind('change', avatar_hide); })(jQuery); // Avoid conflicts with other libraries diff --git a/phpBB/styles/subsilver2/template/avatars.js b/phpBB/styles/subsilver2/template/avatars.js index df6aad178a..733056a32d 100644 --- a/phpBB/styles/subsilver2/template/avatars.js +++ b/phpBB/styles/subsilver2/template/avatars.js @@ -2,14 +2,14 @@ "use strict"; -function avatar_simplify() { +function avatar_hide() { $('.[class^="avatar_option_"]').hide(); var selected = $('#avatar_driver').val(); $('.avatar_option_' + selected).show(); } -avatar_simplify(); -$('#avatar_driver').bind('change', avatar_simplify); +avatar_hide(); +$('#avatar_driver').bind('change', avatar_hide); })(jQuery); // Avoid conflicts with other libraries From fc4069f81df54630a5ac8c1373c38f4834553012 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Tue, 4 Dec 2012 00:59:37 +0100 Subject: [PATCH 0520/2494] [feature/avatars] Use seperate function for retrieving all drivers PHPBB3-10018 --- phpBB/includes/acp/acp_board.php | 2 +- phpBB/includes/avatar/manager.php | 25 ++++++++++++++++++++++--- tests/avatar/manager_test.php | 2 +- 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/phpBB/includes/acp/acp_board.php b/phpBB/includes/acp/acp_board.php index bb90918a46..9e63e59403 100644 --- a/phpBB/includes/acp/acp_board.php +++ b/phpBB/includes/acp/acp_board.php @@ -108,7 +108,7 @@ class acp_board case 'avatar': $phpbb_avatar_manager = $phpbb_container->get('avatar.manager'); - $avatar_drivers = $phpbb_avatar_manager->get_valid_drivers(true); + $avatar_drivers = $phpbb_avatar_manager->get_all_drivers(); $avatar_vars = array(); foreach ($avatar_drivers as $current_driver) diff --git a/phpBB/includes/avatar/manager.php b/phpBB/includes/avatar/manager.php index e7ee323624..279278b71c 100644 --- a/phpBB/includes/avatar/manager.php +++ b/phpBB/includes/avatar/manager.php @@ -109,13 +109,32 @@ class phpbb_avatar_manager } /** - * Get a list of valid avatar drivers + * Get a list of all avatar drivers * - * @param bool $force_all Force showing all avatar drivers + * @return array Array containing a list of all avatar drivers + */ + public function get_all_drivers() + { + $drivers = array(); + + if (!empty($this->avatar_drivers)) + { + foreach ($this->avatar_drivers as $driver) + { + $drivers[$driver->get_name()] = $driver->get_name(); + } + asort($drivers); + } + + return $drivers; + } + + /** + * Get a list of valid avatar drivers * * @return array Array containing a list of the valid avatar drivers */ - public function get_valid_drivers($force_all = false) + public function get_valid_drivers() { if (self::$valid_drivers === false) { diff --git a/tests/avatar/manager_test.php b/tests/avatar/manager_test.php index 9f28e1522d..af0a2edccc 100644 --- a/tests/avatar/manager_test.php +++ b/tests/avatar/manager_test.php @@ -47,7 +47,7 @@ class phpbb_avatar_manager_test extends PHPUnit_Framework_TestCase public function test_get_valid_drivers() { - $valid_drivers = $this->manager->get_valid_drivers(true); + $valid_drivers = $this->manager->get_all_drivers(); $this->assertArrayHasKey('avatar.driver.foobar', $valid_drivers); $this->assertEquals('avatar.driver.foobar', $valid_drivers['avatar.driver.foobar']); } From e765ccd075a19be7ec9c60970677d62dc75f0845 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Tue, 4 Dec 2012 04:22:10 -0500 Subject: [PATCH 0521/2494] [ticket/11015] Include dbms name in exception message. PHPBB3-11015 --- phpBB/includes/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 57136a43ff..501257956a 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -5431,5 +5431,5 @@ function phpbb_convert_30_dbms_to_31($dbms) return 'phpbb_db_driver_' . $dbms; } - throw new \RuntimeException('You have specified an invalid dbms driver.'); + throw new \RuntimeException("You have specified an invalid dbms driver: $dbms"); } From 3687febdacc9b1629fd6f09e15305d61eacc9b78 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Tue, 4 Dec 2012 04:29:31 -0500 Subject: [PATCH 0522/2494] [ticket/11015] Change more docblocks. PHPBB3-11015 --- phpBB/includes/db/db_tools.php | 2 +- phpBB/includes/extension/manager.php | 2 +- phpBB/includes/extension/metadata_manager.php | 2 +- phpBB/includes/functions_download.php | 8 ++++---- phpBB/includes/lock/db.php | 4 ++-- phpBB/includes/search/fulltext_mysql.php | 4 ++-- phpBB/includes/search/fulltext_native.php | 4 ++-- phpBB/includes/search/fulltext_postgres.php | 4 ++-- phpBB/includes/search/fulltext_sphinx.php | 4 ++-- tests/session/testable_factory.php | 2 +- 10 files changed, 18 insertions(+), 18 deletions(-) diff --git a/phpBB/includes/db/db_tools.php b/phpBB/includes/db/db_tools.php index 6df3aac9ce..2bb016cebd 100644 --- a/phpBB/includes/db/db_tools.php +++ b/phpBB/includes/db/db_tools.php @@ -300,7 +300,7 @@ class phpbb_db_tools /** * Constructor. Set DB Object and set {@link $return_statements return_statements}. * - * @param phpbb_dbal $db DBAL object + * @param phpbb_db_driver $db Database connection * @param bool $return_statements True if only statements should be returned and no SQL being executed */ function phpbb_db_tools(&$db, $return_statements = false) diff --git a/phpBB/includes/extension/manager.php b/phpBB/includes/extension/manager.php index 862bca1855..67cc81e407 100644 --- a/phpBB/includes/extension/manager.php +++ b/phpBB/includes/extension/manager.php @@ -34,7 +34,7 @@ class phpbb_extension_manager /** * Creates a manager and loads information from database * - * @param dbal $db A database connection + * @param phpbb_db_driver $db A database connection * @param phpbb_config $config phpbb_config * @param string $extension_table The name of the table holding extensions * @param string $phpbb_root_path Path to the phpbb includes directory. diff --git a/phpBB/includes/extension/metadata_manager.php b/phpBB/includes/extension/metadata_manager.php index 813459eb67..36b0f8b184 100644 --- a/phpBB/includes/extension/metadata_manager.php +++ b/phpBB/includes/extension/metadata_manager.php @@ -34,7 +34,7 @@ class phpbb_extension_metadata_manager /** * Creates the metadata manager * - * @param dbal $db A database connection + * @param phpbb_db_driver $db A database connection * @param string $extension_manager An instance of the phpbb extension manager * @param string $phpbb_root_path Path to the phpbb includes directory. * @param string $phpEx php file extension diff --git a/phpBB/includes/functions_download.php b/phpBB/includes/functions_download.php index b6371dbecc..89bcf7c8d9 100644 --- a/phpBB/includes/functions_download.php +++ b/phpBB/includes/functions_download.php @@ -596,7 +596,7 @@ function phpbb_parse_range_request($request_array, $filesize) /** * Increments the download count of all provided attachments * -* @param dbal $db The database object +* @param phpbb_db_driver $db The database object * @param array|int $ids The attach_id of each attachment * * @return null @@ -617,7 +617,7 @@ function phpbb_increment_downloads($db, $ids) /** * Handles authentication when downloading attachments from a post or topic * -* @param dbal $db The database object +* @param phpbb_db_driver $db The database object * @param phpbb_auth $auth The authentication object * @param int $topic_id The id of the topic that we are downloading from * @@ -651,7 +651,7 @@ function phpbb_download_handle_forum_auth($db, $auth, $topic_id) /** * Handles authentication when downloading attachments from PMs * -* @param dbal $db The database object +* @param phpbb_db_driver $db The database object * @param phpbb_auth $auth The authentication object * @param int $user_id The user id * @param int $msg_id The id of the PM that we are downloading from @@ -678,7 +678,7 @@ function phpbb_download_handle_pm_auth($db, $auth, $user_id, $msg_id) /** * Checks whether a user can download from a particular PM * -* @param dbal $db The database object +* @param phpbb_db_driver $db The database object * @param int $user_id The user id * @param int $msg_id The id of the PM that we are downloading from * diff --git a/phpBB/includes/lock/db.php b/phpBB/includes/lock/db.php index 40690144b1..2bb2e25f97 100644 --- a/phpBB/includes/lock/db.php +++ b/phpBB/includes/lock/db.php @@ -48,7 +48,7 @@ class phpbb_lock_db /** * A database connection - * @var dbal + * @var phpbb_db_driver */ private $db; @@ -59,7 +59,7 @@ class phpbb_lock_db * * @param string $config_name A config variable to be used for locking * @param array $config The phpBB configuration - * @param dbal $db A database connection + * @param phpbb_db_driver $db A database connection */ public function __construct($config_name, phpbb_config $config, phpbb_db_driver $db) { diff --git a/phpBB/includes/search/fulltext_mysql.php b/phpBB/includes/search/fulltext_mysql.php index 58a4dd7d6a..693f663f23 100644 --- a/phpBB/includes/search/fulltext_mysql.php +++ b/phpBB/includes/search/fulltext_mysql.php @@ -41,8 +41,8 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base protected $config; /** - * DBAL object - * @var dbal + * Database connection + * @var phpbb_db_driver */ protected $db; diff --git a/phpBB/includes/search/fulltext_native.php b/phpBB/includes/search/fulltext_native.php index 4623326fc7..53df8348ae 100644 --- a/phpBB/includes/search/fulltext_native.php +++ b/phpBB/includes/search/fulltext_native.php @@ -85,8 +85,8 @@ class phpbb_search_fulltext_native extends phpbb_search_base protected $config; /** - * DBAL object - * @var dbal + * Database connection + * @var phpbb_db_driver */ protected $db; diff --git a/phpBB/includes/search/fulltext_postgres.php b/phpBB/includes/search/fulltext_postgres.php index 08f64735b6..cf613076d0 100644 --- a/phpBB/includes/search/fulltext_postgres.php +++ b/phpBB/includes/search/fulltext_postgres.php @@ -66,8 +66,8 @@ class phpbb_search_fulltext_postgres extends phpbb_search_base protected $config; /** - * DBAL object - * @var dbal + * Database connection + * @var phpbb_db_driver */ protected $db; diff --git a/phpBB/includes/search/fulltext_sphinx.php b/phpBB/includes/search/fulltext_sphinx.php index dd5634b623..a84a64825c 100644 --- a/phpBB/includes/search/fulltext_sphinx.php +++ b/phpBB/includes/search/fulltext_sphinx.php @@ -84,8 +84,8 @@ class phpbb_search_fulltext_sphinx protected $config; /** - * DBAL object - * @var dbal + * Database connection + * @var phpbb_db_driver */ protected $db; diff --git a/tests/session/testable_factory.php b/tests/session/testable_factory.php index 0b42255562..1e2b194ece 100644 --- a/tests/session/testable_factory.php +++ b/tests/session/testable_factory.php @@ -59,7 +59,7 @@ class phpbb_session_testable_factory /** * Retrieve the configured session class instance * - * @param dbal $dbal The database connection to use for session data + * @param phpbb_db_driver $dbal The database connection to use for session data * @return phpbb_mock_session_testable A session instance */ public function get_session(phpbb_db_driver $dbal) From 74093d0fd383619ec8b58914ebe2edd68145e070 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Tue, 4 Dec 2012 04:32:37 -0500 Subject: [PATCH 0523/2494] [ticket/11015] Fix functional test case. PHPBB3-11015 --- tests/test_framework/phpbb_functional_test_case.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index f9c1d64ff8..2a24e96a25 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -86,7 +86,7 @@ class phpbb_functional_test_case extends phpbb_test_case { global $phpbb_root_path, $phpEx; // so we don't reopen an open connection - if (!($this->db instanceof dbal)) + if (!($this->db instanceof phpbb_db_driver)) { $dbms = self::$config['dbms']; $this->db = new $dbms(); From 025a95ea909d449e14cb22564983fb005e3f8c06 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Wed, 9 Mar 2011 21:50:45 -0500 Subject: [PATCH 0524/2494] [ticket/10205] Account for potentially missing extensions in dbal. PHPBB3-10205 --- phpBB/includes/db/mssql_odbc.php | 20 +++++++++++++++++++- phpBB/includes/db/mysql.php | 20 +++++++++++++++++++- phpBB/includes/db/mysqli.php | 7 +++++++ phpBB/includes/db/oracle.php | 29 ++++++++++++++++++++++++++++- phpBB/includes/db/sqlite.php | 21 ++++++++++++++++++++- 5 files changed, 93 insertions(+), 4 deletions(-) diff --git a/phpBB/includes/db/mssql_odbc.php b/phpBB/includes/db/mssql_odbc.php index 2ecc42cadf..dabdbd1a44 100644 --- a/phpBB/includes/db/mssql_odbc.php +++ b/phpBB/includes/db/mssql_odbc.php @@ -32,6 +32,7 @@ include_once($phpbb_root_path . 'includes/db/dbal.' . $phpEx); class dbal_mssql_odbc extends dbal { var $last_query_text = ''; + var $connect_error = ''; /** * Connect to server @@ -68,7 +69,24 @@ class dbal_mssql_odbc extends dbal @ini_set('odbc.defaultlrl', $max_size); } - $this->db_connect_id = ($this->persistency) ? @odbc_pconnect($this->server, $this->user, $sqlpassword) : @odbc_connect($this->server, $this->user, $sqlpassword); + if ($this->persistency) + { + if (!function_exists('odbc_pconnect')) + { + $this->connect_error = 'odbc_pconnect function does not exist, is odbc extension installed?'; + return $this->sql_error(''); + } + $this->db_connect_id = @odbc_pconnect($this->server, $this->user, $sqlpassword); + } + else + { + if (!function_exists('odbc_connect')) + { + $this->connect_error = 'odbc_connect function does not exist, is odbc extension installed?'; + return $this->sql_error(''); + } + $this->db_connect_id = @odbc_connect($this->server, $this->user, $sqlpassword); + } return ($this->db_connect_id) ? $this->db_connect_id : $this->sql_error(''); } diff --git a/phpBB/includes/db/mysql.php b/phpBB/includes/db/mysql.php index 1ccb785150..ae36fe6425 100644 --- a/phpBB/includes/db/mysql.php +++ b/phpBB/includes/db/mysql.php @@ -30,6 +30,7 @@ include_once($phpbb_root_path . 'includes/db/dbal.' . $phpEx); class dbal_mysql extends dbal { var $multi_insert = true; + var $connect_error = ''; /** * Connect to server @@ -44,7 +45,24 @@ class dbal_mysql extends dbal $this->sql_layer = 'mysql4'; - $this->db_connect_id = ($this->persistency) ? @mysql_pconnect($this->server, $this->user, $sqlpassword) : @mysql_connect($this->server, $this->user, $sqlpassword, $new_link); + if ($this->persistency) + { + if (!function_exists('mysql_pconnect')) + { + $this->connect_error = 'mysql_pconnect function does not exist, is mysql extension installed?'; + return $this->sql_error(''); + } + $this->db_connect_id = @mysql_pconnect($this->server, $this->user, $sqlpassword); + } + else + { + if (!function_exists('mysql_connect')) + { + $this->connect_error = 'mysql_connect function does not exist, is mysql extension installed?'; + return $this->sql_error(''); + } + $this->db_connect_id = @mysql_connect($this->server, $this->user, $sqlpassword, $new_link); + } if ($this->db_connect_id && $this->dbname != '') { diff --git a/phpBB/includes/db/mysqli.php b/phpBB/includes/db/mysqli.php index a311b8cda6..98b659723f 100644 --- a/phpBB/includes/db/mysqli.php +++ b/phpBB/includes/db/mysqli.php @@ -27,12 +27,19 @@ include_once($phpbb_root_path . 'includes/db/dbal.' . $phpEx); class dbal_mysqli extends dbal { var $multi_insert = true; + var $connect_error = ''; /** * Connect to server */ function sql_connect($sqlserver, $sqluser, $sqlpassword, $database, $port = false, $persistency = false , $new_link = false) { + if (!function_exists('mysqli_connect')) + { + $this->connect_error = 'mysqli_connect function does not exist, is mysqli extension installed?'; + return $this->sql_error(''); + } + // Mysqli extension supports persistent connection since PHP 5.3.0 $this->persistency = (version_compare(PHP_VERSION, '5.3.0', '>=')) ? $persistency : false; $this->user = $sqluser; diff --git a/phpBB/includes/db/oracle.php b/phpBB/includes/db/oracle.php index 62b36aa8bf..42f5de1b24 100644 --- a/phpBB/includes/db/oracle.php +++ b/phpBB/includes/db/oracle.php @@ -25,6 +25,7 @@ include_once($phpbb_root_path . 'includes/db/dbal.' . $phpEx); class dbal_oracle extends dbal { var $last_query_text = ''; + var $connect_error = ''; /** * Connect to server @@ -48,7 +49,33 @@ class dbal_oracle extends dbal $connect = $sqlserver . (($port) ? ':' . $port : '') . '/' . $database; } - $this->db_connect_id = ($new_link) ? @ocinlogon($this->user, $sqlpassword, $connect, 'UTF8') : (($this->persistency) ? @ociplogon($this->user, $sqlpassword, $connect, 'UTF8') : @ocilogon($this->user, $sqlpassword, $connect, 'UTF8')); + if ($new_link) + { + if (!function_exists('ocinlogon')) + { + $this->connect_error = 'ocinlogon function does not exist, is oci extension installed?'; + return $this->sql_error(''); + } + $this->db_connect_id = @ocinlogon($this->user, $sqlpassword, $connect, 'UTF8'); + } + else if ($this->persistency) + { + if (!function_exists('ociplogon')) + { + $this->connect_error = 'ociplogon function does not exist, is oci extension installed?'; + return $this->sql_error(''); + } + $this->db_connect_id = @ociplogon($this->user, $sqlpassword, $connect, 'UTF8'); + } + else + { + if (!function_exists('ocilogon')) + { + $this->connect_error = 'ocilogon function does not exist, is oci extension installed?'; + return $this->sql_error(''); + } + $this->db_connect_id = @ocilogon($this->user, $sqlpassword, $connect, 'UTF8')); + } return ($this->db_connect_id) ? $this->db_connect_id : $this->sql_error(''); } diff --git a/phpBB/includes/db/sqlite.php b/phpBB/includes/db/sqlite.php index 8de72fd394..be0ad4fc8f 100644 --- a/phpBB/includes/db/sqlite.php +++ b/phpBB/includes/db/sqlite.php @@ -25,6 +25,8 @@ include_once($phpbb_root_path . 'includes/db/dbal.' . $phpEx); */ class dbal_sqlite extends dbal { + var $connect_error = ''; + /** * Connect to server */ @@ -36,7 +38,24 @@ class dbal_sqlite extends dbal $this->dbname = $database; $error = ''; - $this->db_connect_id = ($this->persistency) ? @sqlite_popen($this->server, 0666, $error) : @sqlite_open($this->server, 0666, $error); + if ($this->persistency) + { + if (!function_exists('sqlite_popen')) + { + $this->connect_error = 'sqlite_popen function does not exist, is sqlite extension installed?'; + return $this->sql_error(''); + } + $this->db_connect_id = @sqlite_popen($this->server, 0666, $error); + } + else + { + if (!function_exists('sqlite_open')) + { + $this->connect_error = 'sqlite_open function does not exist, is sqlite extension installed?'; + return $this->sql_error(''); + } + $this->db_connect_id = @sqlite_open($this->server, 0666, $error); + } if ($this->db_connect_id) { From 1a7e2211c35218094e30ddc399d4aa6b45fe75f4 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Tue, 4 Dec 2012 04:06:30 -0500 Subject: [PATCH 0525/2494] [ticket/10205] Avoid calling mysqli functions when mysqli is missing. PHPBB3-10205 --- phpBB/includes/db/mysqli.php | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/phpBB/includes/db/mysqli.php b/phpBB/includes/db/mysqli.php index 98b659723f..cd82a12b58 100644 --- a/phpBB/includes/db/mysqli.php +++ b/phpBB/includes/db/mysqli.php @@ -425,10 +425,20 @@ class dbal_mysqli extends dbal { if (!$this->db_connect_id) { - return array( - 'message' => @mysqli_connect_error(), - 'code' => @mysqli_connect_errno() - ); + if (function_exists('mysqli_connect_error')) + { + return array( + 'message' => @mysqli_connect_error(), + 'code' => @mysqli_connect_errno(), + ); + } + else + { + return array( + 'message' => $this->connect_error, + 'code' => '', + ); + } } return array( From 9f549e8249acbd82b68e961a6e0a31de47d9ca32 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Tue, 4 Dec 2012 04:50:41 -0500 Subject: [PATCH 0526/2494] [ticket/10205] Fix remaining db drivers. PHPBB3-10205 --- phpBB/includes/db/mssql.php | 58 +++++++++++++++++++------------- phpBB/includes/db/mssql_odbc.php | 18 +++++++--- phpBB/includes/db/mysql.php | 18 +++++++--- phpBB/includes/db/oracle.php | 24 +++++++++---- phpBB/includes/db/sqlite.php | 18 +++++++--- 5 files changed, 93 insertions(+), 43 deletions(-) diff --git a/phpBB/includes/db/mssql.php b/phpBB/includes/db/mssql.php index b7178593dc..bc0a870885 100644 --- a/phpBB/includes/db/mssql.php +++ b/phpBB/includes/db/mssql.php @@ -355,34 +355,44 @@ class dbal_mssql extends dbal */ function _sql_error() { - $error = array( - 'message' => @mssql_get_last_message(), - 'code' => '' - ); - - // Get error code number - $result_id = @mssql_query('SELECT @@ERROR as code', $this->db_connect_id); - if ($result_id) + if (function_exists('mssql_get_last_message')) { - $row = @mssql_fetch_assoc($result_id); - $error['code'] = $row['code']; - @mssql_free_result($result_id); - } + $error = array( + 'message' => @mssql_get_last_message(), + 'code' => '' + ); - // Get full error message if possible - $sql = 'SELECT CAST(description as varchar(255)) as message - FROM master.dbo.sysmessages - WHERE error = ' . $error['code']; - $result_id = @mssql_query($sql); - - if ($result_id) - { - $row = @mssql_fetch_assoc($result_id); - if (!empty($row['message'])) + // Get error code number + $result_id = @mssql_query('SELECT @@ERROR as code', $this->db_connect_id); + if ($result_id) { - $error['message'] .= '
    ' . $row['message']; + $row = @mssql_fetch_assoc($result_id); + $error['code'] = $row['code']; + @mssql_free_result($result_id); } - @mssql_free_result($result_id); + + // Get full error message if possible + $sql = 'SELECT CAST(description as varchar(255)) as message + FROM master.dbo.sysmessages + WHERE error = ' . $error['code']; + $result_id = @mssql_query($sql); + + if ($result_id) + { + $row = @mssql_fetch_assoc($result_id); + if (!empty($row['message'])) + { + $error['message'] .= '
    ' . $row['message']; + } + @mssql_free_result($result_id); + } + } + else + { + $error = array( + 'message' => $this->connect_error, + 'code' => '', + ); } return $error; diff --git a/phpBB/includes/db/mssql_odbc.php b/phpBB/includes/db/mssql_odbc.php index dabdbd1a44..e1234389df 100644 --- a/phpBB/includes/db/mssql_odbc.php +++ b/phpBB/includes/db/mssql_odbc.php @@ -360,10 +360,20 @@ class dbal_mssql_odbc extends dbal */ function _sql_error() { - return array( - 'message' => @odbc_errormsg(), - 'code' => @odbc_error() - ); + if (function_exists('odbc_errormsg')) + { + return array( + 'message' => @odbc_errormsg(), + 'code' => @odbc_error() + ); + } + else + { + return array( + 'message' => $this->connect_error, + 'code' => '', + ); + } } /** diff --git a/phpBB/includes/db/mysql.php b/phpBB/includes/db/mysql.php index ae36fe6425..7314e92087 100644 --- a/phpBB/includes/db/mysql.php +++ b/phpBB/includes/db/mysql.php @@ -439,10 +439,20 @@ class dbal_mysql extends dbal { if (!$this->db_connect_id) { - return array( - 'message' => @mysql_error(), - 'code' => @mysql_errno() - ); + if (function_exists('mysql_error')) + { + return array( + 'message' => @mysql_error(), + 'code' => @mysql_errno() + ); + } + else + { + return array( + 'message' => $this->connect_error, + 'code' => '', + ); + } } return array( diff --git a/phpBB/includes/db/oracle.php b/phpBB/includes/db/oracle.php index 42f5de1b24..b234d8b45e 100644 --- a/phpBB/includes/db/oracle.php +++ b/phpBB/includes/db/oracle.php @@ -674,17 +674,27 @@ class dbal_oracle extends dbal */ function _sql_error() { - $error = @ocierror(); - $error = (!$error) ? @ocierror($this->query_result) : $error; - $error = (!$error) ? @ocierror($this->db_connect_id) : $error; - - if ($error) + if (function_exists('ocierror')) { - $this->last_error_result = $error; + $error = @ocierror(); + $error = (!$error) ? @ocierror($this->query_result) : $error; + $error = (!$error) ? @ocierror($this->db_connect_id) : $error; + + if ($error) + { + $this->last_error_result = $error; + } + else + { + $error = (isset($this->last_error_result) && $this->last_error_result) ? $this->last_error_result : array(); + } } else { - $error = (isset($this->last_error_result) && $this->last_error_result) ? $this->last_error_result : array(); + $error = array( + 'message' => $this->connect_error, + 'code' => '', + ); } return $error; diff --git a/phpBB/includes/db/sqlite.php b/phpBB/includes/db/sqlite.php index be0ad4fc8f..3c9b2cce34 100644 --- a/phpBB/includes/db/sqlite.php +++ b/phpBB/includes/db/sqlite.php @@ -300,10 +300,20 @@ class dbal_sqlite extends dbal */ function _sql_error() { - return array( - 'message' => @sqlite_error_string(@sqlite_last_error($this->db_connect_id)), - 'code' => @sqlite_last_error($this->db_connect_id) - ); + if (function_exists('sqlite_error_string')) + { + return array( + 'message' => @sqlite_error_string(@sqlite_last_error($this->db_connect_id)), + 'code' => @sqlite_last_error($this->db_connect_id) + ); + } + else + { + return array( + 'message' => $this->connect_error, + 'code' => '', + ); + } } /** From 8aaa3e055fdc50faeea6f590408a7bcbb03a8d92 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Tue, 4 Dec 2012 15:11:14 +0100 Subject: [PATCH 0527/2494] [feature/avatars] Use seperate function for retrieving the config name PHPBB3-10018 --- phpBB/includes/acp/acp_users.php | 2 +- phpBB/includes/avatar/manager.php | 18 +++++++++++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/phpBB/includes/acp/acp_users.php b/phpBB/includes/acp/acp_users.php index 5c485b5996..b3cfd81949 100644 --- a/phpBB/includes/acp/acp_users.php +++ b/phpBB/includes/acp/acp_users.php @@ -1808,7 +1808,7 @@ class acp_users $driver = $phpbb_avatar_manager->get_driver($current_driver); $avatars_enabled = true; - $config_name = preg_replace('#^avatar\.driver.#', '', $current_driver); + $config_name = $phpbb_avatar_manager->get_driver_config_name($driver); $template->set_filenames(array( 'avatar' => "acp_avatar_options_$config_name.html", )); diff --git a/phpBB/includes/avatar/manager.php b/phpBB/includes/avatar/manager.php index 279278b71c..81a135b46f 100644 --- a/phpBB/includes/avatar/manager.php +++ b/phpBB/includes/avatar/manager.php @@ -203,7 +203,7 @@ class phpbb_avatar_manager */ public function is_enabled($driver) { - $config_name = preg_replace('#^phpbb_avatar_driver_#', '', get_class($driver)); + $config_name = $this->get_driver_config_name($driver); return $this->config["allow_avatar_{$config_name}"]; } @@ -211,16 +211,28 @@ class phpbb_avatar_manager /** * Get the settings array for enabling/disabling an avatar driver * - * @param string $driver Avatar driver object + * @param object $driver Avatar driver object * * @return array Array of configuration options as consumed by acp_board */ public function get_avatar_settings($driver) { - $config_name = preg_replace('#^phpbb_avatar_driver_#', '', get_class($driver)); + $config_name = $this->get_driver_config_name($driver); return array( 'allow_avatar_' . $config_name => array('lang' => 'ALLOW_' . strtoupper($config_name), 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), ); } + + /** + * Get the config name of an avatar driver + * + * @param object $driver Avatar driver object + * + * @return string Avatar driver config name + */ + public function get_driver_config_name($driver) + { + return preg_replace('#^phpbb_avatar_driver_#', '', get_class($driver)); + } } From fb139a88203fb5475712c2bc39e653996cd9103f Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Tue, 4 Dec 2012 15:12:04 +0100 Subject: [PATCH 0528/2494] [feature/avatars] Fix behavior of avatar manager and variables The $force_all variable was only partially removed and the behavior was not consistent in all files. PHPBB3-10018 --- phpBB/includes/acp/acp_board.php | 2 +- phpBB/includes/acp/acp_groups.php | 10 +++++----- phpBB/includes/avatar/manager.php | 20 ++++++++++---------- tests/avatar/manager_test.php | 7 +++++-- 4 files changed, 21 insertions(+), 18 deletions(-) diff --git a/phpBB/includes/acp/acp_board.php b/phpBB/includes/acp/acp_board.php index 9e63e59403..a48d6eda83 100644 --- a/phpBB/includes/acp/acp_board.php +++ b/phpBB/includes/acp/acp_board.php @@ -113,7 +113,7 @@ class acp_board $avatar_vars = array(); foreach ($avatar_drivers as $current_driver) { - $driver = $phpbb_avatar_manager->get_driver($current_driver); + $driver = $phpbb_avatar_manager->get_driver($current_driver, false); /* * First grab the settings for enabling/disabling the avatar diff --git a/phpBB/includes/acp/acp_groups.php b/phpBB/includes/acp/acp_groups.php index b425b9d374..ae0abdd139 100644 --- a/phpBB/includes/acp/acp_groups.php +++ b/phpBB/includes/acp/acp_groups.php @@ -522,26 +522,26 @@ class acp_groups $avatars_enabled = false; $selected_driver = $phpbb_avatar_manager->clean_driver_name($request->variable('avatar_driver', $avatar_data['avatar_type'])); - foreach ($avatar_drivers as $driver) + foreach ($avatar_drivers as $current_driver) { - $driver = $phpbb_avatar_manager->get_driver($driver); + $driver = $phpbb_avatar_manager->get_driver($current_driver); $avatars_enabled = true; - $config_name = preg_replace('#^avatar\.driver.#', '', $driver); + $config_name = $phpbb_avatar_manager->get_driver_config_name($driver); $template->set_filenames(array( 'avatar' => "acp_avatar_options_$config_name.html", )); if ($driver->prepare_form($template, $avatar_data, $avatar_error)) { - $driver_name = $phpbb_avatar_manager->prepare_driver_name($driver); + $driver_name = $phpbb_avatar_manager->prepare_driver_name($current_driver); $driver_upper = strtoupper($driver_name); $template->assign_block_vars('avatar_drivers', array( 'L_TITLE' => $user->lang($driver_upper . '_TITLE'), 'L_EXPLAIN' => $user->lang($driver_upper . '_EXPLAIN'), 'DRIVER' => $driver_name, - 'SELECTED' => $driver == $selected_driver, + 'SELECTED' => $current_driver == $selected_driver, 'OUTPUT' => $template->assign_display('avatar'), )); } diff --git a/phpBB/includes/avatar/manager.php b/phpBB/includes/avatar/manager.php index 81a135b46f..2789158de5 100644 --- a/phpBB/includes/avatar/manager.php +++ b/phpBB/includes/avatar/manager.php @@ -47,17 +47,19 @@ class phpbb_avatar_manager * Get the driver object specified by the avatar type * * @param string $avatar_type Avatar type; by default an avatar's service container name - * @param bool $force_all Grab all avatar drivers, no matter if enabled or not + * @param bool $load_valid Load only valid avatars * * @return object Avatar driver object */ - public function get_driver($avatar_type, $force_all = false) + public function get_driver($avatar_type, $load_valid = true) { - if (self::$valid_drivers === false || $force_all) + if (self::$valid_drivers === false) { - $this->load_valid_drivers($force_all); + $this->load_valid_drivers(); } + $avatar_drivers = ($load_valid) ? self::$valid_drivers : $this->get_all_drivers(); + // Legacy stuff... switch ($avatar_type) { @@ -72,7 +74,7 @@ class phpbb_avatar_manager break; } - if (!isset(self::$valid_drivers[$avatar_type])) + if (!isset($avatar_drivers[$avatar_type])) { return null; } @@ -89,17 +91,15 @@ class phpbb_avatar_manager /** * Load the list of valid drivers * This is executed once and fills self::$valid_drivers - * - * @param bool $force_all Force showing all avatar drivers */ - protected function load_valid_drivers($force_all = false) + protected function load_valid_drivers() { if (!empty($this->avatar_drivers)) { self::$valid_drivers = array(); foreach ($this->avatar_drivers as $driver) { - if ($force_all || $this->is_enabled($driver)) + if ($this->is_enabled($driver)) { self::$valid_drivers[$driver->get_name()] = $driver->get_name(); } @@ -138,7 +138,7 @@ class phpbb_avatar_manager { if (self::$valid_drivers === false) { - $this->load_valid_drivers($force_all); + $this->load_valid_drivers(); } return self::$valid_drivers; diff --git a/tests/avatar/manager_test.php b/tests/avatar/manager_test.php index af0a2edccc..cae72c982b 100644 --- a/tests/avatar/manager_test.php +++ b/tests/avatar/manager_test.php @@ -38,10 +38,13 @@ class phpbb_avatar_manager_test extends PHPUnit_Framework_TestCase public function test_get_driver() { - $driver = $this->manager->get_driver('avatar.driver.foobar', true); + $driver = $this->manager->get_driver('avatar.driver.foobar', false); $this->assertEquals('avatar.driver.foobar', $driver); - $driver = $this->manager->get_driver('avatar.driver.foo_wrong', true); + $driver = $this->manager->get_driver('avatar.driver.foo_wrong', false); + $this->assertNull($driver); + + $driver = $this->manager->get_driver('avatar.driver.foobar'); $this->assertNull($driver); } From 40db60e45f3d7af01a96f9da6b36db2606b3d147 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Tue, 4 Dec 2012 16:07:02 -0500 Subject: [PATCH 0529/2494] [ticket/10205] Fix a parse error in oracle driver. PHPBB3-10205 --- phpBB/includes/db/oracle.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/db/oracle.php b/phpBB/includes/db/oracle.php index b234d8b45e..4a7a4ecc8c 100644 --- a/phpBB/includes/db/oracle.php +++ b/phpBB/includes/db/oracle.php @@ -74,7 +74,7 @@ class dbal_oracle extends dbal $this->connect_error = 'ocilogon function does not exist, is oci extension installed?'; return $this->sql_error(''); } - $this->db_connect_id = @ocilogon($this->user, $sqlpassword, $connect, 'UTF8')); + $this->db_connect_id = @ocilogon($this->user, $sqlpassword, $connect, 'UTF8'); } return ($this->db_connect_id) ? $this->db_connect_id : $this->sql_error(''); From de2fe1a308b08af868f22d6d9c0b7007f66de676 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Tue, 4 Dec 2012 16:12:31 -0500 Subject: [PATCH 0530/2494] [ticket/10205] Convert mssqlnative driver to the same logic. PHPBB3-10205 --- phpBB/includes/db/mssqlnative.php | 52 +++++++++++++++++++------------ 1 file changed, 32 insertions(+), 20 deletions(-) diff --git a/phpBB/includes/db/mssqlnative.php b/phpBB/includes/db/mssqlnative.php index 3ad0ff3e11..e5de30faf6 100644 --- a/phpBB/includes/db/mssqlnative.php +++ b/phpBB/includes/db/mssqlnative.php @@ -199,16 +199,18 @@ class dbal_mssqlnative extends dbal var $m_insert_id = NULL; var $last_query_text = ''; var $query_options = array(); + var $connect_error = ''; /** * Connect to server */ function sql_connect($sqlserver, $sqluser, $sqlpassword, $database, $port = false, $persistency = false, $new_link = false) { - # Test for driver support, to avoid suppressed fatal error + // Test for driver support, to avoid suppressed fatal error if (!function_exists('sqlsrv_connect')) { - trigger_error('Native MS SQL Server driver for PHP is missing or needs to be updated. Version 1.1 or later is required to install phpBB3. You can download the driver from: http://www.microsoft.com/sqlserver/2005/en/us/PHP-Driver.aspx\n', E_USER_ERROR); + $this->connect_error = 'Native MS SQL Server driver for PHP is missing or needs to be updated. Version 1.1 or later is required to install phpBB3. You can download the driver from: http://www.microsoft.com/sqlserver/2005/en/us/PHP-Driver.aspx'; + return $this->sql_error(''); } //set up connection variables @@ -514,31 +516,41 @@ class dbal_mssqlnative extends dbal */ function _sql_error() { - $errors = @sqlsrv_errors(SQLSRV_ERR_ERRORS); - $error_message = ''; - $code = 0; - - if ($errors != null) + if (function_exists('sqlsrv_errors')) { - foreach ($errors as $error) + $errors = @sqlsrv_errors(SQLSRV_ERR_ERRORS); + $error_message = ''; + $code = 0; + + if ($errors != null) { - $error_message .= "SQLSTATE: ".$error[ 'SQLSTATE']."\n"; - $error_message .= "code: ".$error[ 'code']."\n"; - $code = $error['code']; - $error_message .= "message: ".$error[ 'message']."\n"; + foreach ($errors as $error) + { + $error_message .= "SQLSTATE: ".$error[ 'SQLSTATE']."\n"; + $error_message .= "code: ".$error[ 'code']."\n"; + $code = $error['code']; + $error_message .= "message: ".$error[ 'message']."\n"; + } + $this->last_error_result = $error_message; + $error = $this->last_error_result; } - $this->last_error_result = $error_message; - $error = $this->last_error_result; + else + { + $error = (isset($this->last_error_result) && $this->last_error_result) ? $this->last_error_result : array(); + } + + return array( + 'message' => $error, + 'code' => $code, + ); } else { - $error = (isset($this->last_error_result) && $this->last_error_result) ? $this->last_error_result : array(); + return array( + 'message' => $this->connect_error, + 'code' => '', + ); } - - return array( - 'message' => $error, - 'code' => $code, - ); } /** From dc521692f3c6d65b842a42f68bc727c8a36c9042 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Tue, 4 Dec 2012 16:14:39 -0500 Subject: [PATCH 0531/2494] [ticket/10205] Check for function existence in mssql connect method. PHPBB3-10205 --- phpBB/includes/db/mssql.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/phpBB/includes/db/mssql.php b/phpBB/includes/db/mssql.php index bc0a870885..3792e82aa0 100644 --- a/phpBB/includes/db/mssql.php +++ b/phpBB/includes/db/mssql.php @@ -25,11 +25,19 @@ include_once($phpbb_root_path . 'includes/db/dbal.' . $phpEx); */ class dbal_mssql extends dbal { + var $connect_error = ''; + /** * Connect to server */ function sql_connect($sqlserver, $sqluser, $sqlpassword, $database, $port = false, $persistency = false, $new_link = false) { + if (!function_exists('mssql_connect')) + { + $this->connect_error = 'mssql_connect function does not exist, is mssql extension installed?'; + return $this->sql_error(''); + } + $this->persistency = $persistency; $this->user = $sqluser; $this->dbname = $database; From f3c043a5696610ed1312a734b3f3ed1b613fc4f4 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Tue, 4 Dec 2012 16:29:37 -0500 Subject: [PATCH 0532/2494] [ticket/10205] Test failed connection attempts. PHPBB3-10205 --- tests/dbal/connect_test.php | 44 +++++++++++++++++++++++++++++++++++++ tests/fixtures/empty.xml | 5 +++++ 2 files changed, 49 insertions(+) create mode 100644 tests/dbal/connect_test.php create mode 100644 tests/fixtures/empty.xml diff --git a/tests/dbal/connect_test.php b/tests/dbal/connect_test.php new file mode 100644 index 0000000000..4964f24ba2 --- /dev/null +++ b/tests/dbal/connect_test.php @@ -0,0 +1,44 @@ +createXMLDataSet(dirname(__FILE__) . '/../fixtures/empty.xml'); + } + + public function test_failing_connect() + { + global $phpbb_root_path, $phpEx; + + $config = $this->get_database_config(); + + require_once dirname(__FILE__) . '/../../phpBB/includes/db/' . $config['dbms'] . '.php'; + $dbal = 'dbal_' . $config['dbms']; + $db = new $dbal(); + + // Failure to connect results in a trigger_error call in dbal. + // phpunit converts triggered errors to exceptions. + // In particular there should be no fatals here. + try + { + $db->sql_connect($config['dbhost'], 'phpbbogus', 'phpbbogus', 'phpbbogus', $config['dbport']); + $this->assertFalse(true); + } catch (Exception $e) + { + // should have a legitimate message + $this->assertNotEmpty($e->getMessage()); + } + + return $db; + } +} diff --git a/tests/fixtures/empty.xml b/tests/fixtures/empty.xml new file mode 100644 index 0000000000..96eb1ab483 --- /dev/null +++ b/tests/fixtures/empty.xml @@ -0,0 +1,5 @@ + + + +
    +
    From 2d3882c4124e928dccd050da3d3ccafa54b9ff20 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Tue, 4 Dec 2012 16:32:57 -0500 Subject: [PATCH 0533/2494] [ticket/10205] Delete stray return. PHPBB3-10205 --- tests/dbal/connect_test.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/dbal/connect_test.php b/tests/dbal/connect_test.php index 4964f24ba2..cefd76aa16 100644 --- a/tests/dbal/connect_test.php +++ b/tests/dbal/connect_test.php @@ -38,7 +38,5 @@ class phpbb_dbal_connect_test extends phpbb_database_test_case // should have a legitimate message $this->assertNotEmpty($e->getMessage()); } - - return $db; } } From bdc3ddf2bcec3caa9047d03e954c9de82f4916aa Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Tue, 4 Dec 2012 17:19:25 -0500 Subject: [PATCH 0534/2494] [ticket/10491] Set up functional tests sensibly. PHPBB_FUNCTIONAL_URL goes into setup before class. Drop PHPBB_FUNCTIONAL_URL check in board installation and silent return if it is not set. Take board installation out of constructor. Install board in setup method. PHPBB3-10491 --- .../phpbb_functional_test_case.php | 35 ++++++++++--------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index 7c03f874e9..85019a5e31 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -33,11 +33,27 @@ class phpbb_functional_test_case extends phpbb_test_case static protected $config = array(); static protected $already_installed = false; - public function setUp() + static public function setUpBeforeClass() { + parent::setUpBeforeClass(); + + self::$config = phpbb_test_case_helpers::get_test_config(); + if (!isset(self::$config['phpbb_functional_url'])) { - $this->markTestSkipped('phpbb_functional_url was not set in test_config and wasn\'t set as PHPBB_FUNCTIONAL_URL environment variable either.'); + self::markTestSkipped('phpbb_functional_url was not set in test_config and wasn\'t set as PHPBB_FUNCTIONAL_URL environment variable either.'); + } + } + + public function setUp() + { + parent::setUp(); + + if (!static::$already_installed) + { + $this->install_board(); + $this->bootstrap(); + static::$already_installed = true; } $this->cookieJar = new CookieJar; @@ -91,26 +107,12 @@ class phpbb_functional_test_case extends phpbb_test_case $this->backupStaticAttributesBlacklist += array( 'phpbb_functional_test_case' => array('config', 'already_installed'), ); - - if (!static::$already_installed) - { - $this->install_board(); - $this->bootstrap(); - static::$already_installed = true; - } } protected function install_board() { global $phpbb_root_path, $phpEx; - self::$config = phpbb_test_case_helpers::get_test_config(); - - if (!isset(self::$config['phpbb_functional_url'])) - { - return; - } - self::$config['table_prefix'] = 'phpbb_'; $this->recreate_database(self::$config); @@ -158,6 +160,7 @@ class phpbb_functional_test_case extends phpbb_test_case // end data $content = $this->do_request('install'); + $this->assertNotSame(false, $content); $this->assertContains('Welcome to Installation', $content); $this->do_request('create_table', $data); From 38d2868ba8db0f6e24fdfb7bbdfef4925a97770c Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Tue, 4 Dec 2012 17:37:46 -0500 Subject: [PATCH 0535/2494] [ticket/10491] Move board installation into setup before class. Functional posting test already assumed that board is installed once per test case and not once per test. PHPBB3-10491 --- .../phpbb_functional_test_case.php | 28 ++++++++----------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index 85019a5e31..66f4b6db65 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -31,7 +31,6 @@ class phpbb_functional_test_case extends phpbb_test_case protected $lang = array(); static protected $config = array(); - static protected $already_installed = false; static public function setUpBeforeClass() { @@ -43,18 +42,15 @@ class phpbb_functional_test_case extends phpbb_test_case { self::markTestSkipped('phpbb_functional_url was not set in test_config and wasn\'t set as PHPBB_FUNCTIONAL_URL environment variable either.'); } + + self::install_board(); } public function setUp() { parent::setUp(); - if (!static::$already_installed) - { - $this->install_board(); - $this->bootstrap(); - static::$already_installed = true; - } + $this->bootstrap(); $this->cookieJar = new CookieJar; $this->client = new Goutte\Client(array(), null, $this->cookieJar); @@ -109,12 +105,12 @@ class phpbb_functional_test_case extends phpbb_test_case ); } - protected function install_board() + static protected function install_board() { global $phpbb_root_path, $phpEx; self::$config['table_prefix'] = 'phpbb_'; - $this->recreate_database(self::$config); + self::recreate_database(self::$config); if (file_exists($phpbb_root_path . "config.$phpEx")) { @@ -159,20 +155,20 @@ class phpbb_functional_test_case extends phpbb_test_case )); // end data - $content = $this->do_request('install'); - $this->assertNotSame(false, $content); - $this->assertContains('Welcome to Installation', $content); + $content = self::do_request('install'); + self::assertNotSame(false, $content); + self::assertContains('Welcome to Installation', $content); - $this->do_request('create_table', $data); + self::do_request('create_table', $data); - $this->do_request('config_file', $data); + self::do_request('config_file', $data); file_put_contents($phpbb_root_path . "config.$phpEx", phpbb_create_config_file_data($data, self::$config['dbms'], array(), true, true)); - $this->do_request('final', $data); + self::do_request('final', $data); copy($phpbb_root_path . "config.$phpEx", $phpbb_root_path . "config_test.$phpEx"); } - private function do_request($sub, $post_data = null) + static private function do_request($sub, $post_data = null) { $context = null; From 29c4da6162902d3c0d766a8acb17e5a2cf02f901 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Tue, 4 Dec 2012 19:00:42 -0500 Subject: [PATCH 0536/2494] [ticket/10205] Add some columns to the empty fixture file for mssqlnative. Supposedly it choked on the version without any columns thusly: phpbb_dbal_connect_test::test_failing_connect PDOException: SQLSTATE[HY090]: [Microsoft][ODBC Driver Manager] Invalid string or buffer length PHPBB3-10205 --- tests/fixtures/empty.xml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/fixtures/empty.xml b/tests/fixtures/empty.xml index 96eb1ab483..195e30e38d 100644 --- a/tests/fixtures/empty.xml +++ b/tests/fixtures/empty.xml @@ -1,5 +1,9 @@ - +
    + session_id + session_user_id + session_ip + session_browser
    From 89c9c9d4b0daa7308fd015e8a6fca6386a8b8016 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Tue, 4 Dec 2012 21:22:33 -0500 Subject: [PATCH 0537/2494] [ticket/10205] Cosmetic changes. PHPBB3-10205 --- phpBB/includes/db/mssql.php | 2 +- phpBB/includes/db/mssql_odbc.php | 2 +- phpBB/includes/db/mssqlnative.php | 6 +++--- phpBB/includes/db/mysql.php | 4 ++-- phpBB/includes/db/sqlite.php | 2 +- tests/dbal/connect_test.php | 3 ++- 6 files changed, 10 insertions(+), 9 deletions(-) diff --git a/phpBB/includes/db/mssql.php b/phpBB/includes/db/mssql.php index 3792e82aa0..2dd95c2508 100644 --- a/phpBB/includes/db/mssql.php +++ b/phpBB/includes/db/mssql.php @@ -367,7 +367,7 @@ class dbal_mssql extends dbal { $error = array( 'message' => @mssql_get_last_message(), - 'code' => '' + 'code' => '', ); // Get error code number diff --git a/phpBB/includes/db/mssql_odbc.php b/phpBB/includes/db/mssql_odbc.php index e1234389df..47792d74ab 100644 --- a/phpBB/includes/db/mssql_odbc.php +++ b/phpBB/includes/db/mssql_odbc.php @@ -364,7 +364,7 @@ class dbal_mssql_odbc extends dbal { return array( 'message' => @odbc_errormsg(), - 'code' => @odbc_error() + 'code' => @odbc_error(), ); } else diff --git a/phpBB/includes/db/mssqlnative.php b/phpBB/includes/db/mssqlnative.php index e5de30faf6..41ac0a1784 100644 --- a/phpBB/includes/db/mssqlnative.php +++ b/phpBB/includes/db/mssqlnative.php @@ -526,10 +526,10 @@ class dbal_mssqlnative extends dbal { foreach ($errors as $error) { - $error_message .= "SQLSTATE: ".$error[ 'SQLSTATE']."\n"; - $error_message .= "code: ".$error[ 'code']."\n"; + $error_message .= "SQLSTATE: " . $error[ 'SQLSTATE'] . "\n"; + $error_message .= "code: " . $error[ 'code'] . "\n"; $code = $error['code']; - $error_message .= "message: ".$error[ 'message']."\n"; + $error_message .= "message: " . $error[ 'message'] . "\n"; } $this->last_error_result = $error_message; $error = $this->last_error_result; diff --git a/phpBB/includes/db/mysql.php b/phpBB/includes/db/mysql.php index 7314e92087..0125be0917 100644 --- a/phpBB/includes/db/mysql.php +++ b/phpBB/includes/db/mysql.php @@ -443,7 +443,7 @@ class dbal_mysql extends dbal { return array( 'message' => @mysql_error(), - 'code' => @mysql_errno() + 'code' => @mysql_errno(), ); } else @@ -457,7 +457,7 @@ class dbal_mysql extends dbal return array( 'message' => @mysql_error($this->db_connect_id), - 'code' => @mysql_errno($this->db_connect_id) + 'code' => @mysql_errno($this->db_connect_id), ); } diff --git a/phpBB/includes/db/sqlite.php b/phpBB/includes/db/sqlite.php index 3c9b2cce34..199b4eed23 100644 --- a/phpBB/includes/db/sqlite.php +++ b/phpBB/includes/db/sqlite.php @@ -304,7 +304,7 @@ class dbal_sqlite extends dbal { return array( 'message' => @sqlite_error_string(@sqlite_last_error($this->db_connect_id)), - 'code' => @sqlite_last_error($this->db_connect_id) + 'code' => @sqlite_last_error($this->db_connect_id), ); } else diff --git a/tests/dbal/connect_test.php b/tests/dbal/connect_test.php index cefd76aa16..505ce28fa1 100644 --- a/tests/dbal/connect_test.php +++ b/tests/dbal/connect_test.php @@ -33,7 +33,8 @@ class phpbb_dbal_connect_test extends phpbb_database_test_case { $db->sql_connect($config['dbhost'], 'phpbbogus', 'phpbbogus', 'phpbbogus', $config['dbport']); $this->assertFalse(true); - } catch (Exception $e) + } + catch (Exception $e) { // should have a legitimate message $this->assertNotEmpty($e->getMessage()); From 597dea1e047b94f0a862f7f6e650771ffc780141 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Tue, 4 Dec 2012 21:32:02 -0500 Subject: [PATCH 0538/2494] [ticket/10205] Rewrite _sql_error implementations to have a single return. PHPBB3-10205 --- phpBB/includes/db/mssql_odbc.php | 6 ++++-- phpBB/includes/db/mssqlnative.php | 6 ++++-- phpBB/includes/db/mysql.php | 18 +++++++++++------- phpBB/includes/db/mysqli.php | 18 +++++++++++------- phpBB/includes/db/sqlite.php | 6 ++++-- 5 files changed, 34 insertions(+), 20 deletions(-) diff --git a/phpBB/includes/db/mssql_odbc.php b/phpBB/includes/db/mssql_odbc.php index 47792d74ab..04501cce8b 100644 --- a/phpBB/includes/db/mssql_odbc.php +++ b/phpBB/includes/db/mssql_odbc.php @@ -362,18 +362,20 @@ class dbal_mssql_odbc extends dbal { if (function_exists('odbc_errormsg')) { - return array( + $error = array( 'message' => @odbc_errormsg(), 'code' => @odbc_error(), ); } else { - return array( + $error = array( 'message' => $this->connect_error, 'code' => '', ); } + + return $error; } /** diff --git a/phpBB/includes/db/mssqlnative.php b/phpBB/includes/db/mssqlnative.php index 41ac0a1784..b91372ac61 100644 --- a/phpBB/includes/db/mssqlnative.php +++ b/phpBB/includes/db/mssqlnative.php @@ -539,18 +539,20 @@ class dbal_mssqlnative extends dbal $error = (isset($this->last_error_result) && $this->last_error_result) ? $this->last_error_result : array(); } - return array( + $error = array( 'message' => $error, 'code' => $code, ); } else { - return array( + $error = array( 'message' => $this->connect_error, 'code' => '', ); } + + return $error; } /** diff --git a/phpBB/includes/db/mysql.php b/phpBB/includes/db/mysql.php index 0125be0917..e638531f51 100644 --- a/phpBB/includes/db/mysql.php +++ b/phpBB/includes/db/mysql.php @@ -437,28 +437,32 @@ class dbal_mysql extends dbal */ function _sql_error() { - if (!$this->db_connect_id) + if ($this->db_connect_id) + { + $error = array( + 'message' => @mysql_error($this->db_connect_id), + 'code' => @mysql_errno($this->db_connect_id), + ); + } + else { if (function_exists('mysql_error')) { - return array( + $error = array( 'message' => @mysql_error(), 'code' => @mysql_errno(), ); } else { - return array( + $error = array( 'message' => $this->connect_error, 'code' => '', ); } } - return array( - 'message' => @mysql_error($this->db_connect_id), - 'code' => @mysql_errno($this->db_connect_id), - ); + return $error; } /** diff --git a/phpBB/includes/db/mysqli.php b/phpBB/includes/db/mysqli.php index cd82a12b58..b2a43d35f9 100644 --- a/phpBB/includes/db/mysqli.php +++ b/phpBB/includes/db/mysqli.php @@ -423,28 +423,32 @@ class dbal_mysqli extends dbal */ function _sql_error() { - if (!$this->db_connect_id) + if ($this->db_connect_id) + { + $error = array( + 'message' => @mysqli_error($this->db_connect_id), + 'code' => @mysqli_errno($this->db_connect_id) + ); + } + else { if (function_exists('mysqli_connect_error')) { - return array( + $error = array( 'message' => @mysqli_connect_error(), 'code' => @mysqli_connect_errno(), ); } else { - return array( + $error = array( 'message' => $this->connect_error, 'code' => '', ); } } - return array( - 'message' => @mysqli_error($this->db_connect_id), - 'code' => @mysqli_errno($this->db_connect_id) - ); + return $error; } /** diff --git a/phpBB/includes/db/sqlite.php b/phpBB/includes/db/sqlite.php index 199b4eed23..557b057cce 100644 --- a/phpBB/includes/db/sqlite.php +++ b/phpBB/includes/db/sqlite.php @@ -302,18 +302,20 @@ class dbal_sqlite extends dbal { if (function_exists('sqlite_error_string')) { - return array( + $error = array( 'message' => @sqlite_error_string(@sqlite_last_error($this->db_connect_id)), 'code' => @sqlite_last_error($this->db_connect_id), ); } else { - return array( + $error = array( 'message' => $this->connect_error, 'code' => '', ); } + + return $error; } /** From 5120f36a258ffcbffd5c10e9a1056d64ea794a16 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Tue, 4 Dec 2012 21:33:13 -0500 Subject: [PATCH 0539/2494] [ticket/10205] Reduce nesting in mysql drivers. PHPBB3-10205 --- phpBB/includes/db/mysql.php | 25 +++++++++++-------------- phpBB/includes/db/mysqli.php | 25 +++++++++++-------------- 2 files changed, 22 insertions(+), 28 deletions(-) diff --git a/phpBB/includes/db/mysql.php b/phpBB/includes/db/mysql.php index e638531f51..252cb20bd4 100644 --- a/phpBB/includes/db/mysql.php +++ b/phpBB/includes/db/mysql.php @@ -444,22 +444,19 @@ class dbal_mysql extends dbal 'code' => @mysql_errno($this->db_connect_id), ); } + else if (function_exists('mysql_error')) + { + $error = array( + 'message' => @mysql_error(), + 'code' => @mysql_errno(), + ); + } else { - if (function_exists('mysql_error')) - { - $error = array( - 'message' => @mysql_error(), - 'code' => @mysql_errno(), - ); - } - else - { - $error = array( - 'message' => $this->connect_error, - 'code' => '', - ); - } + $error = array( + 'message' => $this->connect_error, + 'code' => '', + ); } return $error; diff --git a/phpBB/includes/db/mysqli.php b/phpBB/includes/db/mysqli.php index b2a43d35f9..69f1d26a40 100644 --- a/phpBB/includes/db/mysqli.php +++ b/phpBB/includes/db/mysqli.php @@ -430,22 +430,19 @@ class dbal_mysqli extends dbal 'code' => @mysqli_errno($this->db_connect_id) ); } + else if (function_exists('mysqli_connect_error')) + { + $error = array( + 'message' => @mysqli_connect_error(), + 'code' => @mysqli_connect_errno(), + ); + } else { - if (function_exists('mysqli_connect_error')) - { - $error = array( - 'message' => @mysqli_connect_error(), - 'code' => @mysqli_connect_errno(), - ); - } - else - { - $error = array( - 'message' => $this->connect_error, - 'code' => '', - ); - } + $error = array( + 'message' => $this->connect_error, + 'code' => '', + ); } return $error; From 0f96b1aad378b1fc40620ea57df5ee89224fd5eb Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Tue, 4 Dec 2012 23:35:34 -0500 Subject: [PATCH 0540/2494] [ticket/11162] Move to a separate file to avoid blowing out functions.php. PHPBB3-11162 --- phpBB/includes/functions.php | 87 --------------- phpBB/includes/functions_tricky_update.php | 103 ++++++++++++++++++ .../fixtures/duplicates.xml | 0 .../update_rows_avoiding_duplicates_test.php | 2 +- 4 files changed, 104 insertions(+), 88 deletions(-) create mode 100644 phpBB/includes/functions_tricky_update.php rename tests/{functions => functions_tricky_update}/fixtures/duplicates.xml (100%) rename tests/{functions => functions_tricky_update}/update_rows_avoiding_duplicates_test.php (98%) diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index e3feb59d41..65d8be32ad 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -1297,93 +1297,6 @@ function tz_select($default = '', $truncate = false) return $tz_select; } -/** -* Updates rows in given table from a set of values to a new value. -* If this results in rows violating uniqueness constraints, the duplicate -* rows are eliminated. -* -* The only supported tables are bookmarks and topics_watch. -* -* @param dbal $db Database object -* @param string $table Table on which to perform the update -* @param string $column Column whose values to change -* @param array $from_values An array of values that should be changed -* @param int $to_value The new value -* @return null -*/ -function phpbb_update_rows_avoiding_duplicates($db, $table, $column, $from_values, $to_value) -{ - $sql = "SELECT $column, user_id - FROM $table - WHERE " . $db->sql_in_set($column, $from_values); - $result = $db->sql_query($sql); - - $old_user_ids = array(); - while ($row = $db->sql_fetchrow($result)) - { - $old_user_ids[$row[$column]][] = $row['user_id']; - } - $db->sql_freeresult($result); - - $sql = "SELECT $column, user_id - FROM $table - WHERE $column = '" . (int) $to_value . "'"; - $result = $db->sql_query($sql); - - $new_user_ids = array(); - while ($row = $db->sql_fetchrow($result)) - { - $new_user_ids[$row[$column]][] = $row['user_id']; - } - $db->sql_freeresult($result); - - $queries = array(); - $any_found = false; - foreach ($from_values as $from_value) - { - if (!isset($old_user_ids[$from_value])) - { - continue; - } - $any_found = true; - if (empty($new_user_ids)) - { - $sql = "UPDATE $table - SET $column = " . (int) $to_value. " - WHERE $column = '" . $db->sql_escape($from_value) . "'"; - $queries[] = $sql; - } - else - { - $different_user_ids = array_diff($old_user_ids[$from_value], $new_user_ids[$to_value]); - if (!empty($different_user_ids)) - { - $sql = "UPDATE $table - SET $column = " . (int) $to_value. " - WHERE $column = '" . $db->sql_escape($from_value) . "' - AND " . $db->sql_in_set('user_id', $different_user_ids); - $queries[] = $sql; - } - } - } - - if ($any_found) - { - $db->sql_transaction('begin'); - - foreach ($queries as $sql) - { - $db->sql_query($sql); - } - - $sql = "DELETE FROM $table - WHERE " . $db->sql_in_set($column, $from_values); - $db->sql_query($sql); - - $db->sql_transaction('commit'); - } -} - // Functions handling topic/post tracking/marking /** diff --git a/phpBB/includes/functions_tricky_update.php b/phpBB/includes/functions_tricky_update.php new file mode 100644 index 0000000000..a5b9fdacd0 --- /dev/null +++ b/phpBB/includes/functions_tricky_update.php @@ -0,0 +1,103 @@ +sql_in_set($column, $from_values); + $result = $db->sql_query($sql); + + $old_user_ids = array(); + while ($row = $db->sql_fetchrow($result)) + { + $old_user_ids[$row[$column]][] = $row['user_id']; + } + $db->sql_freeresult($result); + + $sql = "SELECT $column, user_id + FROM $table + WHERE $column = '" . (int) $to_value . "'"; + $result = $db->sql_query($sql); + + $new_user_ids = array(); + while ($row = $db->sql_fetchrow($result)) + { + $new_user_ids[$row[$column]][] = $row['user_id']; + } + $db->sql_freeresult($result); + + $queries = array(); + $any_found = false; + foreach ($from_values as $from_value) + { + if (!isset($old_user_ids[$from_value])) + { + continue; + } + $any_found = true; + if (empty($new_user_ids)) + { + $sql = "UPDATE $table + SET $column = " . (int) $to_value. " + WHERE $column = '" . $db->sql_escape($from_value) . "'"; + $queries[] = $sql; + } + else + { + $different_user_ids = array_diff($old_user_ids[$from_value], $new_user_ids[$to_value]); + if (!empty($different_user_ids)) + { + $sql = "UPDATE $table + SET $column = " . (int) $to_value. " + WHERE $column = '" . $db->sql_escape($from_value) . "' + AND " . $db->sql_in_set('user_id', $different_user_ids); + $queries[] = $sql; + } + } + } + + if ($any_found) + { + $db->sql_transaction('begin'); + + foreach ($queries as $sql) + { + $db->sql_query($sql); + } + + $sql = "DELETE FROM $table + WHERE " . $db->sql_in_set($column, $from_values); + $db->sql_query($sql); + + $db->sql_transaction('commit'); + } +} diff --git a/tests/functions/fixtures/duplicates.xml b/tests/functions_tricky_update/fixtures/duplicates.xml similarity index 100% rename from tests/functions/fixtures/duplicates.xml rename to tests/functions_tricky_update/fixtures/duplicates.xml diff --git a/tests/functions/update_rows_avoiding_duplicates_test.php b/tests/functions_tricky_update/update_rows_avoiding_duplicates_test.php similarity index 98% rename from tests/functions/update_rows_avoiding_duplicates_test.php rename to tests/functions_tricky_update/update_rows_avoiding_duplicates_test.php index 0d68e22d4a..6940122393 100644 --- a/tests/functions/update_rows_avoiding_duplicates_test.php +++ b/tests/functions_tricky_update/update_rows_avoiding_duplicates_test.php @@ -7,7 +7,7 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; +require_once dirname(__FILE__) . '/../../phpBB/includes/functions_tricky_update.php'; class phpbb_update_rows_avoiding_duplicates_test extends phpbb_database_test_case { From abca64b1dfbe11f73675a3e5457fb9f0038f1cb6 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Tue, 4 Dec 2012 23:37:14 -0500 Subject: [PATCH 0541/2494] [ticket/11162] Add includes. PHPBB3-11162 --- phpBB/includes/mcp/mcp_forum.php | 4 ++++ phpBB/includes/mcp/mcp_topic.php | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/phpBB/includes/mcp/mcp_forum.php b/phpBB/includes/mcp/mcp_forum.php index e392bef157..3603224735 100644 --- a/phpBB/includes/mcp/mcp_forum.php +++ b/phpBB/includes/mcp/mcp_forum.php @@ -415,6 +415,10 @@ function merge_topics($forum_id, $topic_ids, $to_topic_id) $success_msg = 'POSTS_MERGED_SUCCESS'; // Update the topic watch table. + if (!function_exists('phpbb_update_rows_avoiding_duplicates')) + { + include($phpbb_root_path . 'includes/functions_tricky_update.' . $phpEx); + } phpbb_update_rows_avoiding_duplicates($db, TOPICS_WATCH_TABLE, 'topic_id', $topic_ids, $to_topic_id); // Link to the new topic diff --git a/phpBB/includes/mcp/mcp_topic.php b/phpBB/includes/mcp/mcp_topic.php index f40a4bc044..1fb3cb9d73 100644 --- a/phpBB/includes/mcp/mcp_topic.php +++ b/phpBB/includes/mcp/mcp_topic.php @@ -620,6 +620,10 @@ function merge_posts($topic_id, $to_topic_id) else { // If the topic no longer exist, we will update the topic watch table. + if (!function_exists('phpbb_update_rows_avoiding_duplicates')) + { + include($phpbb_root_path . 'includes/functions_tricky_update.' . $phpEx); + } phpbb_update_rows_avoiding_duplicates($db, TOPICS_WATCH_TABLE, 'topic_id', $topic_ids, $to_topic_id); } From 58951ef1057bd5f0d1098f9536eb8a84c532833c Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Tue, 4 Dec 2012 23:37:57 -0500 Subject: [PATCH 0542/2494] [ticket/11162] The test is not at all trivial. PHPBB3-11162 --- .../update_rows_avoiding_duplicates_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/functions_tricky_update/update_rows_avoiding_duplicates_test.php b/tests/functions_tricky_update/update_rows_avoiding_duplicates_test.php index 6940122393..4849605e9c 100644 --- a/tests/functions_tricky_update/update_rows_avoiding_duplicates_test.php +++ b/tests/functions_tricky_update/update_rows_avoiding_duplicates_test.php @@ -53,7 +53,7 @@ class phpbb_update_rows_avoiding_duplicates_test extends phpbb_database_test_cas /** * @dataProvider fixture_data */ - public function test_trivial_update($description, $from, $to, $expected_result_count) + public function test_update($description, $from, $to, $expected_result_count) { $db = $this->new_dbal(); From efe122b03200155479920890defc2a3dc689bdd7 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Tue, 4 Dec 2012 23:40:30 -0500 Subject: [PATCH 0543/2494] [ticket/11162] This test really only works for bookmarks. PHPBB3-11162 --- .../fixtures/bookmarks_duplicates.xml | 47 +++++++++++++++++++ ...icates.xml => topics_watch_duplicates.xml} | 0 .../update_rows_avoiding_duplicates_test.php | 6 +-- 3 files changed, 50 insertions(+), 3 deletions(-) create mode 100644 tests/functions_tricky_update/fixtures/bookmarks_duplicates.xml rename tests/functions_tricky_update/fixtures/{duplicates.xml => topics_watch_duplicates.xml} (100%) diff --git a/tests/functions_tricky_update/fixtures/bookmarks_duplicates.xml b/tests/functions_tricky_update/fixtures/bookmarks_duplicates.xml new file mode 100644 index 0000000000..d49f76b073 --- /dev/null +++ b/tests/functions_tricky_update/fixtures/bookmarks_duplicates.xml @@ -0,0 +1,47 @@ + + + + user_id + topic_id + + + + 1 + 1 + + + + + 2 + 2 + + + 3 + 3 + + + + + 1 + 4 + + + 1 + 5 + + + + + 1 + 6 + + + 1 + 7 + + + 2 + 6 + +
    +
    diff --git a/tests/functions_tricky_update/fixtures/duplicates.xml b/tests/functions_tricky_update/fixtures/topics_watch_duplicates.xml similarity index 100% rename from tests/functions_tricky_update/fixtures/duplicates.xml rename to tests/functions_tricky_update/fixtures/topics_watch_duplicates.xml diff --git a/tests/functions_tricky_update/update_rows_avoiding_duplicates_test.php b/tests/functions_tricky_update/update_rows_avoiding_duplicates_test.php index 4849605e9c..6142997408 100644 --- a/tests/functions_tricky_update/update_rows_avoiding_duplicates_test.php +++ b/tests/functions_tricky_update/update_rows_avoiding_duplicates_test.php @@ -13,7 +13,7 @@ class phpbb_update_rows_avoiding_duplicates_test extends phpbb_database_test_cas { public function getDataSet() { - return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/duplicates.xml'); + return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/bookmarks_duplicates.xml'); } public static function fixture_data() @@ -57,10 +57,10 @@ class phpbb_update_rows_avoiding_duplicates_test extends phpbb_database_test_cas { $db = $this->new_dbal(); - phpbb_update_rows_avoiding_duplicates($db, TOPICS_WATCH_TABLE, 'topic_id', $from, $to); + phpbb_update_rows_avoiding_duplicates($db, BOOKMARKS_TABLE, 'topic_id', $from, $to); $sql = 'SELECT COUNT(*) AS remaining_rows - FROM ' . TOPICS_WATCH_TABLE . ' + FROM ' . BOOKMARKS_TABLE . ' WHERE topic_id = ' . (int) $to; $result = $db->sql_query($sql); $result_count = $db->sql_fetchfield('remaining_rows'); From 6872104aa95a9f2aad565189e25bbf54abc3ca2c Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Wed, 5 Dec 2012 00:07:01 -0500 Subject: [PATCH 0544/2494] [ticket/11162] Account for notify_status. PHPBB3-11162 --- phpBB/includes/functions_tricky_update.php | 111 +++++++++++++++++- .../fixtures/topics_watch_duplicates.xml | 38 ++++-- ...avoiding_duplicates_notify_status_test.php | 100 ++++++++++++++++ 3 files changed, 239 insertions(+), 10 deletions(-) create mode 100644 tests/functions_tricky_update/update_rows_avoiding_duplicates_notify_status_test.php diff --git a/phpBB/includes/functions_tricky_update.php b/phpBB/includes/functions_tricky_update.php index a5b9fdacd0..cf922d7014 100644 --- a/phpBB/includes/functions_tricky_update.php +++ b/phpBB/includes/functions_tricky_update.php @@ -20,7 +20,7 @@ if (!defined('IN_PHPBB')) * If this results in rows violating uniqueness constraints, the duplicate * rows are eliminated. * -* The only supported tables are bookmarks and topics_watch. +* The only supported table is bookmarks. * * @param dbal $db Database object * @param string $table Table on which to perform the update @@ -67,7 +67,7 @@ function phpbb_update_rows_avoiding_duplicates($db, $table, $column, $from_value if (empty($new_user_ids)) { $sql = "UPDATE $table - SET $column = " . (int) $to_value. " + SET $column = " . (int) $to_value . " WHERE $column = '" . $db->sql_escape($from_value) . "'"; $queries[] = $sql; } @@ -77,7 +77,7 @@ function phpbb_update_rows_avoiding_duplicates($db, $table, $column, $from_value if (!empty($different_user_ids)) { $sql = "UPDATE $table - SET $column = " . (int) $to_value. " + SET $column = " . (int) $to_value . " WHERE $column = '" . $db->sql_escape($from_value) . "' AND " . $db->sql_in_set('user_id', $different_user_ids); $queries[] = $sql; @@ -101,3 +101,108 @@ function phpbb_update_rows_avoiding_duplicates($db, $table, $column, $from_value $db->sql_transaction('commit'); } } + +/** +* Updates rows in given table from a set of values to a new value. +* If this results in rows violating uniqueness constraints, the duplicate +* rows are merged respecting notify_status (0 takes precedence over 1). +* +* The only supported table is topics_watch. +* +* @param dbal $db Database object +* @param string $table Table on which to perform the update +* @param string $column Column whose values to change +* @param array $from_values An array of values that should be changed +* @param int $to_value The new value +* @return null +*/ +function phpbb_update_rows_avoiding_duplicates_notify_status($db, $table, $column, $from_values, $to_value) +{ + $sql = "SELECT $column, user_id, notify_status + FROM $table + WHERE " . $db->sql_in_set($column, $from_values); + $result = $db->sql_query($sql); + + $old_user_ids = array(); + while ($row = $db->sql_fetchrow($result)) + { + $old_user_ids[(int) $row['notify_status']][$row[$column]][] = $row['user_id']; + } + $db->sql_freeresult($result); + + $sql = "SELECT $column, user_id + FROM $table + WHERE $column = '" . (int) $to_value . "'"; + $result = $db->sql_query($sql); + + $new_user_ids = array(); + while ($row = $db->sql_fetchrow($result)) + { + $new_user_ids[$row[$column]][] = $row['user_id']; + } + $db->sql_freeresult($result); + + $queries = array(); + $any_found = false; + $extra_updates = array( + 0 => 'notify_status = 0', + 1 => '', + ); + foreach ($from_values as $from_value) + { + foreach ($extra_updates as $notify_status => $extra_update) { + if (!isset($old_user_ids[$notify_status][$from_value])) + { + continue; + } + $any_found = true; + if (empty($new_user_ids)) + { + $sql = "UPDATE $table + SET $column = " . (int) $to_value . " + WHERE $column = '" . $db->sql_escape($from_value) . "'"; + $queries[] = $sql; + } + else + { + $different_user_ids = array_diff($old_user_ids[$notify_status][$from_value], $new_user_ids[$to_value]); + if (!empty($different_user_ids)) + { + $sql = "UPDATE $table + SET $column = " . (int) $to_value . " + WHERE $column = '" . $db->sql_escape($from_value) . "' + AND " . $db->sql_in_set('user_id', $different_user_ids); + $queries[] = $sql; + } + + if ($extra_update) { + $same_user_ids = array_diff($old_user_ids[$notify_status][$from_value], $different_user_ids); + if (!empty($same_user_ids)) + { + $sql = "UPDATE $table + SET $extra_update + WHERE $column = '" . (int) $to_value . "' + AND " . $db->sql_in_set('user_id', $same_user_ids); + $queries[] = $sql; + } + } + } + } + } + + if ($any_found) + { + $db->sql_transaction('begin'); + + foreach ($queries as $sql) + { + $db->sql_query($sql); + } + + $sql = "DELETE FROM $table + WHERE " . $db->sql_in_set($column, $from_values); + $db->sql_query($sql); + + $db->sql_transaction('commit'); + } +} diff --git a/tests/functions_tricky_update/fixtures/topics_watch_duplicates.xml b/tests/functions_tricky_update/fixtures/topics_watch_duplicates.xml index bc08016a8f..c387bb737a 100644 --- a/tests/functions_tricky_update/fixtures/topics_watch_duplicates.xml +++ b/tests/functions_tricky_update/fixtures/topics_watch_duplicates.xml @@ -14,17 +14,17 @@ - 2 + 1 2 1 + 2 3 - 3 - 1 + 0 - + 1 4 @@ -36,20 +36,44 @@ 1 - + 1 6 - 1 + 0 1 7 1 + + + + 1 + 8 + 1 + + + 1 + 9 + 0 + + + + + 1 + 10 + 0 + + + 1 + 11 + 1 + 2 - 6 + 10 1
    diff --git a/tests/functions_tricky_update/update_rows_avoiding_duplicates_notify_status_test.php b/tests/functions_tricky_update/update_rows_avoiding_duplicates_notify_status_test.php new file mode 100644 index 0000000000..aa739c5f04 --- /dev/null +++ b/tests/functions_tricky_update/update_rows_avoiding_duplicates_notify_status_test.php @@ -0,0 +1,100 @@ +createXMLDataSet(dirname(__FILE__).'/fixtures/topics_watch_duplicates.xml'); + } + + public static function fixture_data() + { + return array( + // description + // from array + // to value + // expected count with to value post update + // expected notify_status values + array( + 'trivial', + array(1), + 1000, + 1, + 1, + ), + array( + 'no conflict', + array(2), + 3, + 2, + 1, + ), + array( + 'conflict, same notify status', + array(4), + 5, + 1, + 1, + ), + array( + 'conflict, notify status 0 into 1', + array(6), + 7, + 1, + 0, + ), + array( + 'conflict, notify status 1 into 0', + array(8), + 9, + 1, + 0, + ), + array( + 'conflict and no conflict', + array(10), + 11, + 2, + 0, + ), + ); + } + + /** + * @dataProvider fixture_data + */ + public function test_update($description, $from, $to, $expected_result_count, $expected_notify_status) + { + $db = $this->new_dbal(); + + phpbb_update_rows_avoiding_duplicates_notify_status($db, TOPICS_WATCH_TABLE, 'topic_id', $from, $to); + + $sql = 'SELECT COUNT(*) AS remaining_rows + FROM ' . TOPICS_WATCH_TABLE . ' + WHERE topic_id = ' . (int) $to; + $result = $db->sql_query($sql); + $result_count = $db->sql_fetchfield('remaining_rows'); + $db->sql_freeresult($result); + + $this->assertEquals($expected_result_count, $result_count); + + // user id of 1 is the user being updated + $sql = 'SELECT notify_status + FROM ' . TOPICS_WATCH_TABLE . ' + WHERE topic_id = ' . (int) $to . ' AND user_id = 1'; + $result = $db->sql_query($sql); + $notify_status = $db->sql_fetchfield('notify_status'); + $db->sql_freeresult($result); + + $this->assertEquals($expected_notify_status, $notify_status); + } +} From 1a411c5658da769e28b03332ed618d5e701dab79 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Wed, 5 Dec 2012 00:10:02 -0500 Subject: [PATCH 0545/2494] [ticket/11162] Use correct functions. PHPBB3-11162 --- phpBB/includes/mcp/mcp_forum.php | 4 ++-- phpBB/includes/mcp/mcp_topic.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/phpBB/includes/mcp/mcp_forum.php b/phpBB/includes/mcp/mcp_forum.php index 3603224735..cd938e83a0 100644 --- a/phpBB/includes/mcp/mcp_forum.php +++ b/phpBB/includes/mcp/mcp_forum.php @@ -415,11 +415,11 @@ function merge_topics($forum_id, $topic_ids, $to_topic_id) $success_msg = 'POSTS_MERGED_SUCCESS'; // Update the topic watch table. - if (!function_exists('phpbb_update_rows_avoiding_duplicates')) + if (!function_exists('phpbb_update_rows_avoiding_duplicates_notify_status')) { include($phpbb_root_path . 'includes/functions_tricky_update.' . $phpEx); } - phpbb_update_rows_avoiding_duplicates($db, TOPICS_WATCH_TABLE, 'topic_id', $topic_ids, $to_topic_id); + phpbb_update_rows_avoiding_duplicates_notify_status($db, TOPICS_WATCH_TABLE, 'topic_id', $topic_ids, $to_topic_id); // Link to the new topic $return_link .= (($return_link) ? '

    ' : '') . sprintf($user->lang['RETURN_NEW_TOPIC'], '', ''); diff --git a/phpBB/includes/mcp/mcp_topic.php b/phpBB/includes/mcp/mcp_topic.php index 1fb3cb9d73..29dabdd2a2 100644 --- a/phpBB/includes/mcp/mcp_topic.php +++ b/phpBB/includes/mcp/mcp_topic.php @@ -620,11 +620,11 @@ function merge_posts($topic_id, $to_topic_id) else { // If the topic no longer exist, we will update the topic watch table. - if (!function_exists('phpbb_update_rows_avoiding_duplicates')) + if (!function_exists('phpbb_update_rows_avoiding_duplicates_notify_status')) { include($phpbb_root_path . 'includes/functions_tricky_update.' . $phpEx); } - phpbb_update_rows_avoiding_duplicates($db, TOPICS_WATCH_TABLE, 'topic_id', $topic_ids, $to_topic_id); + phpbb_update_rows_avoiding_duplicates_notify_status($db, TOPICS_WATCH_TABLE, 'topic_id', $topic_ids, $to_topic_id); } // Link to the new topic From 94ebc5707836d931e24e77f5ce1b3a16d0410fb8 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Wed, 5 Dec 2012 10:40:42 -0500 Subject: [PATCH 0546/2494] [ticket/11162] Newlines to LF. PHPBB3-11162 --- phpBB/includes/functions_tricky_update.php | 416 ++++++++++----------- 1 file changed, 208 insertions(+), 208 deletions(-) diff --git a/phpBB/includes/functions_tricky_update.php b/phpBB/includes/functions_tricky_update.php index cf922d7014..c8fcb9b6f0 100644 --- a/phpBB/includes/functions_tricky_update.php +++ b/phpBB/includes/functions_tricky_update.php @@ -1,208 +1,208 @@ -sql_in_set($column, $from_values); - $result = $db->sql_query($sql); - - $old_user_ids = array(); - while ($row = $db->sql_fetchrow($result)) - { - $old_user_ids[$row[$column]][] = $row['user_id']; - } - $db->sql_freeresult($result); - - $sql = "SELECT $column, user_id - FROM $table - WHERE $column = '" . (int) $to_value . "'"; - $result = $db->sql_query($sql); - - $new_user_ids = array(); - while ($row = $db->sql_fetchrow($result)) - { - $new_user_ids[$row[$column]][] = $row['user_id']; - } - $db->sql_freeresult($result); - - $queries = array(); - $any_found = false; - foreach ($from_values as $from_value) - { - if (!isset($old_user_ids[$from_value])) - { - continue; - } - $any_found = true; - if (empty($new_user_ids)) - { - $sql = "UPDATE $table - SET $column = " . (int) $to_value . " - WHERE $column = '" . $db->sql_escape($from_value) . "'"; - $queries[] = $sql; - } - else - { - $different_user_ids = array_diff($old_user_ids[$from_value], $new_user_ids[$to_value]); - if (!empty($different_user_ids)) - { - $sql = "UPDATE $table - SET $column = " . (int) $to_value . " - WHERE $column = '" . $db->sql_escape($from_value) . "' - AND " . $db->sql_in_set('user_id', $different_user_ids); - $queries[] = $sql; - } - } - } - - if ($any_found) - { - $db->sql_transaction('begin'); - - foreach ($queries as $sql) - { - $db->sql_query($sql); - } - - $sql = "DELETE FROM $table - WHERE " . $db->sql_in_set($column, $from_values); - $db->sql_query($sql); - - $db->sql_transaction('commit'); - } -} - -/** -* Updates rows in given table from a set of values to a new value. -* If this results in rows violating uniqueness constraints, the duplicate -* rows are merged respecting notify_status (0 takes precedence over 1). -* -* The only supported table is topics_watch. -* -* @param dbal $db Database object -* @param string $table Table on which to perform the update -* @param string $column Column whose values to change -* @param array $from_values An array of values that should be changed -* @param int $to_value The new value -* @return null -*/ -function phpbb_update_rows_avoiding_duplicates_notify_status($db, $table, $column, $from_values, $to_value) -{ - $sql = "SELECT $column, user_id, notify_status - FROM $table - WHERE " . $db->sql_in_set($column, $from_values); - $result = $db->sql_query($sql); - - $old_user_ids = array(); - while ($row = $db->sql_fetchrow($result)) - { - $old_user_ids[(int) $row['notify_status']][$row[$column]][] = $row['user_id']; - } - $db->sql_freeresult($result); - - $sql = "SELECT $column, user_id - FROM $table - WHERE $column = '" . (int) $to_value . "'"; - $result = $db->sql_query($sql); - - $new_user_ids = array(); - while ($row = $db->sql_fetchrow($result)) - { - $new_user_ids[$row[$column]][] = $row['user_id']; - } - $db->sql_freeresult($result); - - $queries = array(); - $any_found = false; - $extra_updates = array( - 0 => 'notify_status = 0', - 1 => '', - ); - foreach ($from_values as $from_value) - { - foreach ($extra_updates as $notify_status => $extra_update) { - if (!isset($old_user_ids[$notify_status][$from_value])) - { - continue; - } - $any_found = true; - if (empty($new_user_ids)) - { - $sql = "UPDATE $table - SET $column = " . (int) $to_value . " - WHERE $column = '" . $db->sql_escape($from_value) . "'"; - $queries[] = $sql; - } - else - { - $different_user_ids = array_diff($old_user_ids[$notify_status][$from_value], $new_user_ids[$to_value]); - if (!empty($different_user_ids)) - { - $sql = "UPDATE $table - SET $column = " . (int) $to_value . " - WHERE $column = '" . $db->sql_escape($from_value) . "' - AND " . $db->sql_in_set('user_id', $different_user_ids); - $queries[] = $sql; - } - - if ($extra_update) { - $same_user_ids = array_diff($old_user_ids[$notify_status][$from_value], $different_user_ids); - if (!empty($same_user_ids)) - { - $sql = "UPDATE $table - SET $extra_update - WHERE $column = '" . (int) $to_value . "' - AND " . $db->sql_in_set('user_id', $same_user_ids); - $queries[] = $sql; - } - } - } - } - } - - if ($any_found) - { - $db->sql_transaction('begin'); - - foreach ($queries as $sql) - { - $db->sql_query($sql); - } - - $sql = "DELETE FROM $table - WHERE " . $db->sql_in_set($column, $from_values); - $db->sql_query($sql); - - $db->sql_transaction('commit'); - } -} +sql_in_set($column, $from_values); + $result = $db->sql_query($sql); + + $old_user_ids = array(); + while ($row = $db->sql_fetchrow($result)) + { + $old_user_ids[$row[$column]][] = $row['user_id']; + } + $db->sql_freeresult($result); + + $sql = "SELECT $column, user_id + FROM $table + WHERE $column = '" . (int) $to_value . "'"; + $result = $db->sql_query($sql); + + $new_user_ids = array(); + while ($row = $db->sql_fetchrow($result)) + { + $new_user_ids[$row[$column]][] = $row['user_id']; + } + $db->sql_freeresult($result); + + $queries = array(); + $any_found = false; + foreach ($from_values as $from_value) + { + if (!isset($old_user_ids[$from_value])) + { + continue; + } + $any_found = true; + if (empty($new_user_ids)) + { + $sql = "UPDATE $table + SET $column = " . (int) $to_value . " + WHERE $column = '" . $db->sql_escape($from_value) . "'"; + $queries[] = $sql; + } + else + { + $different_user_ids = array_diff($old_user_ids[$from_value], $new_user_ids[$to_value]); + if (!empty($different_user_ids)) + { + $sql = "UPDATE $table + SET $column = " . (int) $to_value . " + WHERE $column = '" . $db->sql_escape($from_value) . "' + AND " . $db->sql_in_set('user_id', $different_user_ids); + $queries[] = $sql; + } + } + } + + if ($any_found) + { + $db->sql_transaction('begin'); + + foreach ($queries as $sql) + { + $db->sql_query($sql); + } + + $sql = "DELETE FROM $table + WHERE " . $db->sql_in_set($column, $from_values); + $db->sql_query($sql); + + $db->sql_transaction('commit'); + } +} + +/** +* Updates rows in given table from a set of values to a new value. +* If this results in rows violating uniqueness constraints, the duplicate +* rows are merged respecting notify_status (0 takes precedence over 1). +* +* The only supported table is topics_watch. +* +* @param dbal $db Database object +* @param string $table Table on which to perform the update +* @param string $column Column whose values to change +* @param array $from_values An array of values that should be changed +* @param int $to_value The new value +* @return null +*/ +function phpbb_update_rows_avoiding_duplicates_notify_status($db, $table, $column, $from_values, $to_value) +{ + $sql = "SELECT $column, user_id, notify_status + FROM $table + WHERE " . $db->sql_in_set($column, $from_values); + $result = $db->sql_query($sql); + + $old_user_ids = array(); + while ($row = $db->sql_fetchrow($result)) + { + $old_user_ids[(int) $row['notify_status']][$row[$column]][] = $row['user_id']; + } + $db->sql_freeresult($result); + + $sql = "SELECT $column, user_id + FROM $table + WHERE $column = '" . (int) $to_value . "'"; + $result = $db->sql_query($sql); + + $new_user_ids = array(); + while ($row = $db->sql_fetchrow($result)) + { + $new_user_ids[$row[$column]][] = $row['user_id']; + } + $db->sql_freeresult($result); + + $queries = array(); + $any_found = false; + $extra_updates = array( + 0 => 'notify_status = 0', + 1 => '', + ); + foreach ($from_values as $from_value) + { + foreach ($extra_updates as $notify_status => $extra_update) { + if (!isset($old_user_ids[$notify_status][$from_value])) + { + continue; + } + $any_found = true; + if (empty($new_user_ids)) + { + $sql = "UPDATE $table + SET $column = " . (int) $to_value . " + WHERE $column = '" . $db->sql_escape($from_value) . "'"; + $queries[] = $sql; + } + else + { + $different_user_ids = array_diff($old_user_ids[$notify_status][$from_value], $new_user_ids[$to_value]); + if (!empty($different_user_ids)) + { + $sql = "UPDATE $table + SET $column = " . (int) $to_value . " + WHERE $column = '" . $db->sql_escape($from_value) . "' + AND " . $db->sql_in_set('user_id', $different_user_ids); + $queries[] = $sql; + } + + if ($extra_update) { + $same_user_ids = array_diff($old_user_ids[$notify_status][$from_value], $different_user_ids); + if (!empty($same_user_ids)) + { + $sql = "UPDATE $table + SET $extra_update + WHERE $column = '" . (int) $to_value . "' + AND " . $db->sql_in_set('user_id', $same_user_ids); + $queries[] = $sql; + } + } + } + } + } + + if ($any_found) + { + $db->sql_transaction('begin'); + + foreach ($queries as $sql) + { + $db->sql_query($sql); + } + + $sql = "DELETE FROM $table + WHERE " . $db->sql_in_set($column, $from_values); + $db->sql_query($sql); + + $db->sql_transaction('commit'); + } +} From 16966f52d37e4ebdca4f3846c81dfa85b193501e Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Wed, 5 Dec 2012 10:41:08 -0500 Subject: [PATCH 0547/2494] [ticket/11162] Reformat. PHPBB3-11162 --- phpBB/includes/functions_tricky_update.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/phpBB/includes/functions_tricky_update.php b/phpBB/includes/functions_tricky_update.php index c8fcb9b6f0..10321618b2 100644 --- a/phpBB/includes/functions_tricky_update.php +++ b/phpBB/includes/functions_tricky_update.php @@ -150,7 +150,8 @@ function phpbb_update_rows_avoiding_duplicates_notify_status($db, $table, $colum ); foreach ($from_values as $from_value) { - foreach ($extra_updates as $notify_status => $extra_update) { + foreach ($extra_updates as $notify_status => $extra_update) + { if (!isset($old_user_ids[$notify_status][$from_value])) { continue; @@ -174,8 +175,9 @@ function phpbb_update_rows_avoiding_duplicates_notify_status($db, $table, $colum AND " . $db->sql_in_set('user_id', $different_user_ids); $queries[] = $sql; } - - if ($extra_update) { + + if ($extra_update) + { $same_user_ids = array_diff($old_user_ids[$notify_status][$from_value], $different_user_ids); if (!empty($same_user_ids)) { From fe87d441eeb54bf5efb56a0f69f42848d9ef53d5 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Wed, 5 Dec 2012 10:44:36 -0500 Subject: [PATCH 0548/2494] [ticket/11162] Review comments fixed. PHPBB3-11162 --- phpBB/includes/functions_tricky_update.php | 12 ++++++------ ...e_rows_avoiding_duplicates_notify_status_test.php | 3 ++- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/phpBB/includes/functions_tricky_update.php b/phpBB/includes/functions_tricky_update.php index 10321618b2..05cb65e68d 100644 --- a/phpBB/includes/functions_tricky_update.php +++ b/phpBB/includes/functions_tricky_update.php @@ -39,19 +39,19 @@ function phpbb_update_rows_avoiding_duplicates($db, $table, $column, $from_value $old_user_ids = array(); while ($row = $db->sql_fetchrow($result)) { - $old_user_ids[$row[$column]][] = $row['user_id']; + $old_user_ids[$row[$column]][] = (int) $row['user_id']; } $db->sql_freeresult($result); $sql = "SELECT $column, user_id FROM $table - WHERE $column = '" . (int) $to_value . "'"; + WHERE $column = " . (int) $to_value; $result = $db->sql_query($sql); $new_user_ids = array(); while ($row = $db->sql_fetchrow($result)) { - $new_user_ids[$row[$column]][] = $row['user_id']; + $new_user_ids[$row[$column]][] = (int) $row['user_id']; } $db->sql_freeresult($result); @@ -126,19 +126,19 @@ function phpbb_update_rows_avoiding_duplicates_notify_status($db, $table, $colum $old_user_ids = array(); while ($row = $db->sql_fetchrow($result)) { - $old_user_ids[(int) $row['notify_status']][$row[$column]][] = $row['user_id']; + $old_user_ids[(int) $row['notify_status']][$row[$column]][] = (int) $row['user_id']; } $db->sql_freeresult($result); $sql = "SELECT $column, user_id FROM $table - WHERE $column = '" . (int) $to_value . "'"; + WHERE $column = " . (int) $to_value; $result = $db->sql_query($sql); $new_user_ids = array(); while ($row = $db->sql_fetchrow($result)) { - $new_user_ids[$row[$column]][] = $row['user_id']; + $new_user_ids[$row[$column]][] = (int) $row['user_id']; } $db->sql_freeresult($result); diff --git a/tests/functions_tricky_update/update_rows_avoiding_duplicates_notify_status_test.php b/tests/functions_tricky_update/update_rows_avoiding_duplicates_notify_status_test.php index aa739c5f04..9052585552 100644 --- a/tests/functions_tricky_update/update_rows_avoiding_duplicates_notify_status_test.php +++ b/tests/functions_tricky_update/update_rows_avoiding_duplicates_notify_status_test.php @@ -90,7 +90,8 @@ class phpbb_update_rows_avoiding_duplicates_notify_status_test extends phpbb_dat // user id of 1 is the user being updated $sql = 'SELECT notify_status FROM ' . TOPICS_WATCH_TABLE . ' - WHERE topic_id = ' . (int) $to . ' AND user_id = 1'; + WHERE topic_id = ' . (int) $to . ' + AND user_id = 1'; $result = $db->sql_query($sql); $notify_status = $db->sql_fetchfield('notify_status'); $db->sql_freeresult($result); From f5de11438c471a76fc5c5f3a4b8c4c29d07ed734 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Wed, 5 Dec 2012 10:47:26 -0500 Subject: [PATCH 0549/2494] [ticket/11162] Use empty($queries). PHPBB3-11162 --- phpBB/includes/functions_tricky_update.php | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/phpBB/includes/functions_tricky_update.php b/phpBB/includes/functions_tricky_update.php index 05cb65e68d..664c246888 100644 --- a/phpBB/includes/functions_tricky_update.php +++ b/phpBB/includes/functions_tricky_update.php @@ -56,14 +56,12 @@ function phpbb_update_rows_avoiding_duplicates($db, $table, $column, $from_value $db->sql_freeresult($result); $queries = array(); - $any_found = false; foreach ($from_values as $from_value) { if (!isset($old_user_ids[$from_value])) { continue; } - $any_found = true; if (empty($new_user_ids)) { $sql = "UPDATE $table @@ -85,7 +83,7 @@ function phpbb_update_rows_avoiding_duplicates($db, $table, $column, $from_value } } - if ($any_found) + if (!empty($queries)) { $db->sql_transaction('begin'); @@ -143,7 +141,6 @@ function phpbb_update_rows_avoiding_duplicates_notify_status($db, $table, $colum $db->sql_freeresult($result); $queries = array(); - $any_found = false; $extra_updates = array( 0 => 'notify_status = 0', 1 => '', @@ -156,7 +153,6 @@ function phpbb_update_rows_avoiding_duplicates_notify_status($db, $table, $colum { continue; } - $any_found = true; if (empty($new_user_ids)) { $sql = "UPDATE $table @@ -192,7 +188,7 @@ function phpbb_update_rows_avoiding_duplicates_notify_status($db, $table, $colum } } - if ($any_found) + if (!empty($queries)) { $db->sql_transaction('begin'); From 9b018bd460376abce3f4fe9d8c11feef0c547b0d Mon Sep 17 00:00:00 2001 From: Bruno Ais Date: Sun, 2 Dec 2012 21:47:18 +0000 Subject: [PATCH 0550/2494] [ticket/11171] DB additions for these changes Made the required changes to develop/create_schema_files.php and this is what resulted of that. PHPBB3-11171 --- phpBB/develop/create_schema_files.php | 27 +++++++++++++---------- phpBB/install/schemas/firebird_schema.sql | 5 ++++- phpBB/install/schemas/mssql_schema.sql | 5 ++++- phpBB/install/schemas/mysql_40_schema.sql | 5 ++++- phpBB/install/schemas/mysql_41_schema.sql | 5 ++++- phpBB/install/schemas/oracle_schema.sql | 5 ++++- phpBB/install/schemas/postgres_schema.sql | 5 ++++- phpBB/install/schemas/sqlite_schema.sql | 5 ++++- 8 files changed, 43 insertions(+), 19 deletions(-) diff --git a/phpBB/develop/create_schema_files.php b/phpBB/develop/create_schema_files.php index 3d3e478032..0ae75c2681 100644 --- a/phpBB/develop/create_schema_files.php +++ b/phpBB/develop/create_schema_files.php @@ -1520,18 +1520,21 @@ function get_schema_struct() $schema_data['phpbb_reports'] = array( 'COLUMNS' => array( - 'report_id' => array('UINT', NULL, 'auto_increment'), - 'reason_id' => array('USINT', 0), - 'post_id' => array('UINT', 0), - 'pm_id' => array('UINT', 0), - 'user_id' => array('UINT', 0), - 'user_notify' => array('BOOL', 0), - 'report_closed' => array('BOOL', 0), - 'report_time' => array('TIMESTAMP', 0), - 'report_text' => array('MTEXT_UNI', ''), - 'reported_post_text' => array('MTEXT_UNI', ''), - 'reported_post_uid' => array('VCHAR:8', ''), - 'reported_post_bitfield' => array('VCHAR:255', ''), + 'report_id' => array('UINT', NULL, 'auto_increment'), + 'reason_id' => array('USINT', 0), + 'post_id' => array('UINT', 0), + 'pm_id' => array('UINT', 0), + 'user_id' => array('UINT', 0), + 'user_notify' => array('BOOL', 0), + 'report_closed' => array('BOOL', 0), + 'report_time' => array('TIMESTAMP', 0), + 'report_text' => array('MTEXT_UNI', ''), + 'reported_post_text' => array('MTEXT_UNI', ''), + 'reported_post_uid' => array('VCHAR:8', ''), + 'reported_post_bitfield' => array('VCHAR:255', ''), + 'reported_post_enable_magic_url' => array('BOOL', 1), + 'reported_post_enable_smilies' => array('BOOL', 1), + 'reported_post_enable_bbcode' => array('BOOL', 1) ), 'PRIMARY_KEY' => 'report_id', 'KEYS' => array( diff --git a/phpBB/install/schemas/firebird_schema.sql b/phpBB/install/schemas/firebird_schema.sql index 767ce68b4a..bd97fefb36 100644 --- a/phpBB/install/schemas/firebird_schema.sql +++ b/phpBB/install/schemas/firebird_schema.sql @@ -912,8 +912,11 @@ CREATE TABLE phpbb_reports ( report_time INTEGER DEFAULT 0 NOT NULL, report_text BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL, reported_post_text BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL, + reported_post_uid VARCHAR(8) CHARACTER SET NONE DEFAULT '' NOT NULL, reported_post_bitfield VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL, - reported_post_uid VARCHAR(8) CHARACTER SET NONE DEFAULT '' NOT NULL + reported_post_enable_magic_url INTEGER DEFAULT 1 NOT NULL, + reported_post_enable_smilies INTEGER DEFAULT 1 NOT NULL, + reported_post_enable_bbcode INTEGER DEFAULT 1 NOT NULL );; ALTER TABLE phpbb_reports ADD PRIMARY KEY (report_id);; diff --git a/phpBB/install/schemas/mssql_schema.sql b/phpBB/install/schemas/mssql_schema.sql index 84c975942f..bb0890e439 100644 --- a/phpBB/install/schemas/mssql_schema.sql +++ b/phpBB/install/schemas/mssql_schema.sql @@ -1111,8 +1111,11 @@ CREATE TABLE [phpbb_reports] ( [report_time] [int] DEFAULT (0) NOT NULL , [report_text] [text] DEFAULT ('') NOT NULL , [reported_post_text] [text] DEFAULT ('') NOT NULL , + [reported_post_uid] [varchar] (8) DEFAULT ('') NOT NULL , [reported_post_bitfield] [varchar] (255) DEFAULT ('') NOT NULL , - [reported_post_uid] [varchar] (8) DEFAULT ('') NOT NULL + [reported_post_enable_magic_url] [int] DEFAULT (1) NOT NULL , + [reported_post_enable_smilies] [int] DEFAULT (1) NOT NULL , + [reported_post_enable_bbcode] [int] DEFAULT (1) NOT NULL ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY] GO diff --git a/phpBB/install/schemas/mysql_40_schema.sql b/phpBB/install/schemas/mysql_40_schema.sql index 8aab949103..bf3d7fecfa 100644 --- a/phpBB/install/schemas/mysql_40_schema.sql +++ b/phpBB/install/schemas/mysql_40_schema.sql @@ -649,8 +649,11 @@ CREATE TABLE phpbb_reports ( report_time int(11) UNSIGNED DEFAULT '0' NOT NULL, report_text mediumblob NOT NULL, reported_post_text mediumblob NOT NULL, - reported_post_bitfield varbinary(255) DEFAULT '' NOT NULL, reported_post_uid varbinary(8) DEFAULT '' NOT NULL, + reported_post_bitfield varbinary(255) DEFAULT '' NOT NULL, + reported_post_enable_magic_url tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, + reported_post_enable_smilies tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, + reported_post_enable_bbcode tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, PRIMARY KEY (report_id), KEY post_id (post_id), KEY pm_id (pm_id) diff --git a/phpBB/install/schemas/mysql_41_schema.sql b/phpBB/install/schemas/mysql_41_schema.sql index 04aef2844a..372b63d83c 100644 --- a/phpBB/install/schemas/mysql_41_schema.sql +++ b/phpBB/install/schemas/mysql_41_schema.sql @@ -649,8 +649,11 @@ CREATE TABLE phpbb_reports ( report_time int(11) UNSIGNED DEFAULT '0' NOT NULL, report_text mediumtext NOT NULL, reported_post_text mediumtext NOT NULL, - reported_post_bitfield varchar(255) DEFAULT '' NOT NULL, reported_post_uid varchar(8) DEFAULT '' NOT NULL, + reported_post_bitfield varchar(255) DEFAULT '' NOT NULL, + reported_post_enable_magic_url tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, + reported_post_enable_smilies tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, + reported_post_enable_bbcode tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, PRIMARY KEY (report_id), KEY post_id (post_id), KEY pm_id (pm_id) diff --git a/phpBB/install/schemas/oracle_schema.sql b/phpBB/install/schemas/oracle_schema.sql index 91f906bc8b..671347ebe1 100644 --- a/phpBB/install/schemas/oracle_schema.sql +++ b/phpBB/install/schemas/oracle_schema.sql @@ -1216,8 +1216,11 @@ CREATE TABLE phpbb_reports ( report_time number(11) DEFAULT '0' NOT NULL, report_text clob DEFAULT '' , reported_post_text clob DEFAULT '' , - reported_post_bitfield varchar2(255) DEFAULT '' , reported_post_uid varchar2(8) DEFAULT '' , + reported_post_bitfield varchar2(255) DEFAULT '' , + reported_post_enable_magic_url number(1) DEFAULT '1' NOT NULL, + reported_post_enable_smilies number(1) DEFAULT '1' NOT NULL, + reported_post_enable_bbcode number(1) DEFAULT '1' NOT NULL, CONSTRAINT pk_phpbb_reports PRIMARY KEY (report_id) ) / diff --git a/phpBB/install/schemas/postgres_schema.sql b/phpBB/install/schemas/postgres_schema.sql index 619985e0d6..4c13bf0ba9 100644 --- a/phpBB/install/schemas/postgres_schema.sql +++ b/phpBB/install/schemas/postgres_schema.sql @@ -855,8 +855,11 @@ CREATE TABLE phpbb_reports ( report_time INT4 DEFAULT '0' NOT NULL CHECK (report_time >= 0), report_text TEXT DEFAULT '' NOT NULL, reported_post_text TEXT DEFAULT '' NOT NULL, - reported_post_bitfield varchar(255) DEFAULT '' NOT NULL, reported_post_uid varchar(8) DEFAULT '' NOT NULL, + reported_post_bitfield varchar(255) DEFAULT '' NOT NULL, + reported_post_enable_magic_url INT2 DEFAULT '1' NOT NULL CHECK (reported_post_enable_magic_url >= 0), + reported_post_enable_smilies INT2 DEFAULT '1' NOT NULL CHECK (reported_post_enable_smilies >= 0), + reported_post_enable_bbcode INT2 DEFAULT '1' NOT NULL CHECK (reported_post_enable_bbcode >= 0), PRIMARY KEY (report_id) ); diff --git a/phpBB/install/schemas/sqlite_schema.sql b/phpBB/install/schemas/sqlite_schema.sql index 1690a7dcab..46a96a1edd 100644 --- a/phpBB/install/schemas/sqlite_schema.sql +++ b/phpBB/install/schemas/sqlite_schema.sql @@ -630,8 +630,11 @@ CREATE TABLE phpbb_reports ( report_time INTEGER UNSIGNED NOT NULL DEFAULT '0', report_text mediumtext(16777215) NOT NULL DEFAULT '', reported_post_text mediumtext(16777215) NOT NULL DEFAULT '', + reported_post_uid varchar(8) NOT NULL DEFAULT '', reported_post_bitfield varchar(255) NOT NULL DEFAULT '', - reported_post_uid varchar(8) NOT NULL DEFAULT '' + reported_post_enable_magic_url INTEGER UNSIGNED NOT NULL DEFAULT '1', + reported_post_enable_smilies INTEGER UNSIGNED NOT NULL DEFAULT '1', + reported_post_enable_bbcode INTEGER UNSIGNED NOT NULL DEFAULT '1' ); CREATE INDEX phpbb_reports_post_id ON phpbb_reports (post_id); From 780a8c98aca5dc54e1b85a79f8ff0f04ce49c5e4 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 6 Dec 2012 14:28:52 +0100 Subject: [PATCH 0551/2494] [ticket/10411] Rename template variable CUR_ to CURRENT_ PHPBB3-10411 --- phpBB/adm/style/acp_groups_position.html | 2 +- phpBB/includes/acp/acp_groups.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/phpBB/adm/style/acp_groups_position.html b/phpBB/adm/style/acp_groups_position.html index 99864f75ce..eb4c3d8819 100644 --- a/phpBB/adm/style/acp_groups_position.html +++ b/phpBB/adm/style/acp_groups_position.html @@ -108,7 +108,7 @@

    {L_TEAMPAGE_EXPLAIN}

    -

    {L_TEAMPAGE} » {CUR_CATEGORY_NAME}

    +

    {L_TEAMPAGE} » {CURRENT_CATEGORY_NAME}

    diff --git a/phpBB/includes/acp/acp_groups.php b/phpBB/includes/acp/acp_groups.php index 3784e5c169..81ae567a8c 100644 --- a/phpBB/includes/acp/acp_groups.php +++ b/phpBB/includes/acp/acp_groups.php @@ -948,7 +948,7 @@ class acp_groups if ($row['teampage_id'] == $category_id) { $template->assign_vars(array( - 'CUR_CATEGORY_NAME' => $row['teampage_name'], + 'CURRENT_CATEGORY_NAME' => $row['teampage_name'], )); continue; } From 70050020699d9eab9b97bda342e0e928d1591de8 Mon Sep 17 00:00:00 2001 From: Fyorl Date: Sun, 8 Jul 2012 20:22:19 +0100 Subject: [PATCH 0552/2494] [ticket/10972] Added methods for creating and deleting basic users Modified the login method to allow logging in of an arbitrary user. Also added tests for the new functionality. PHPBB3-10972 --- tests/functional/new_user_test.php | 45 +++++++++++++++++++ .../phpbb_functional_test_case.php | 45 ++++++++++++++++++- 2 files changed, 88 insertions(+), 2 deletions(-) create mode 100644 tests/functional/new_user_test.php diff --git a/tests/functional/new_user_test.php b/tests/functional/new_user_test.php new file mode 100644 index 0000000000..db2f31f450 --- /dev/null +++ b/tests/functional/new_user_test.php @@ -0,0 +1,45 @@ +create_user('user'); + $this->login(); + $crawler = $this->request('GET', 'memberlist.php?sid=' . $this->sid); + $this->assertContains('user', $crawler->filter('#memberlist tr')->eq(1)->text()); + } + + /** + * @depends test_create_user + */ + public function test_delete_user() + { + $this->delete_user('user'); + $this->login(); + $crawler = $this->request('GET', 'memberlist.php?sid=' . $this->sid); + $this->assertEquals(2, $crawler->filter('#memberlist tr')->count()); + } + + /** + * @depends test_delete_user + */ + public function test_login_other() + { + $this->create_user('user'); + $this->login('user'); + $crawler = $this->request('GET', 'index.php'); + $this->assertContains('user', $crawler->filter('.icon-logout')->text()); + $this->delete_user('user'); + } +} diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index 7c03f874e9..dfbfe2565e 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -194,7 +194,48 @@ class phpbb_functional_test_case extends phpbb_test_case $db_conn_mgr->recreate_db(); } - protected function login() + /** + * Creates a new user with limited permissions + * + * @param string $username Also doubles up as the user's password + */ + protected function create_user($username) + { + // Required by unique_id + global $config; + + if (!is_array($config)) + { + $config = array(); + } + + $config['rand_seed'] = ''; + $config['rand_seed_last_update'] = time() + 600; + + $db = $this->get_db(); + $query = " + INSERT INTO " . self::$config['table_prefix'] . "users + (user_type, group_id, username, username_clean, user_regdate, user_password, user_email, user_lang, user_style, user_rank, user_colour, user_posts, user_permissions, user_ip, user_birthday, user_lastpage, user_last_confirm_key, user_post_sortby_type, user_post_sortby_dir, user_topic_sortby_type, user_topic_sortby_dir, user_avatar, user_sig, user_sig_bbcode_uid, user_from, user_icq, user_aim, user_yim, user_msnm, user_jabber, user_website, user_occ, user_interests, user_actkey, user_newpasswd) + VALUES + (0, 2, 'user', 'user', 0, '" . phpbb_hash($username) . "', 'nobody@example.com', 'en', 1, 0, '', 1, '', '', '', '', '', 't', 'a', 't', 'd', '', '', '', '', '', '', '', '', '', '', '', '', '', '') + "; + + $db->sql_query($query); + } + + /** + * Deletes a user + * + * @param string $username The username of the user to delete + */ + protected function delete_user($username) + { + $db = $this->get_db(); + $query = "DELETE FROM " . self::$config['table_prefix'] . "users WHERE username = '" . $db->sql_escape($username) . "'"; + $db->sql_query($query); + } + + protected function login($username = 'admin') { $this->add_lang('ucp'); @@ -202,7 +243,7 @@ class phpbb_functional_test_case extends phpbb_test_case $this->assertContains($this->lang('LOGIN_EXPLAIN_UCP'), $crawler->filter('html')->text()); $form = $crawler->selectButton($this->lang('LOGIN'))->form(); - $login = $this->client->submit($form, array('username' => 'admin', 'password' => 'admin')); + $login = $this->client->submit($form, array('username' => $username, 'password' => $username)); $cookies = $this->cookieJar->all(); From cafc7feca12730fce59091bd7a18fb5c3f7ecdc0 Mon Sep 17 00:00:00 2001 From: Fyorl Date: Mon, 9 Jul 2012 00:24:28 +0100 Subject: [PATCH 0553/2494] [ticket/10972] Moved tests into appropriate places and added comments PHPBB3-10972 --- tests/functional/auth_test.php | 9 ++++ tests/functional/new_user_test.php | 45 ------------------- .../phpbb_functional_test_case.php | 4 ++ 3 files changed, 13 insertions(+), 45 deletions(-) delete mode 100644 tests/functional/new_user_test.php diff --git a/tests/functional/auth_test.php b/tests/functional/auth_test.php index e955dcb4df..e67118d8f9 100644 --- a/tests/functional/auth_test.php +++ b/tests/functional/auth_test.php @@ -21,6 +21,15 @@ class phpbb_functional_auth_test extends phpbb_functional_test_case $this->assertContains($this->lang('LOGOUT_USER', 'admin'), $crawler->filter('.navbar')->text()); } + public function test_login_other() + { + $this->create_user('user'); + $this->login('user'); + $crawler = $this->request('GET', 'index.php'); + $this->assertContains('user', $crawler->filter('.icon-logout')->text()); + $this->delete_user('user'); + } + /** * @depends test_login */ diff --git a/tests/functional/new_user_test.php b/tests/functional/new_user_test.php deleted file mode 100644 index db2f31f450..0000000000 --- a/tests/functional/new_user_test.php +++ /dev/null @@ -1,45 +0,0 @@ -create_user('user'); - $this->login(); - $crawler = $this->request('GET', 'memberlist.php?sid=' . $this->sid); - $this->assertContains('user', $crawler->filter('#memberlist tr')->eq(1)->text()); - } - - /** - * @depends test_create_user - */ - public function test_delete_user() - { - $this->delete_user('user'); - $this->login(); - $crawler = $this->request('GET', 'memberlist.php?sid=' . $this->sid); - $this->assertEquals(2, $crawler->filter('#memberlist tr')->count()); - } - - /** - * @depends test_delete_user - */ - public function test_login_other() - { - $this->create_user('user'); - $this->login('user'); - $crawler = $this->request('GET', 'index.php'); - $this->assertContains('user', $crawler->filter('.icon-logout')->text()); - $this->delete_user('user'); - } -} diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index dfbfe2565e..a72c0940ab 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -197,6 +197,10 @@ class phpbb_functional_test_case extends phpbb_test_case /** * Creates a new user with limited permissions * + * Note that creating two users with the same name results in undefined + * login behaviour. Always call delete_user after running a test that + * requires create_user. + * * @param string $username Also doubles up as the user's password */ protected function create_user($username) From d33accb687ab4266559c12a356e121f3634d780b Mon Sep 17 00:00:00 2001 From: Fyorl Date: Fri, 10 Aug 2012 12:31:53 +0100 Subject: [PATCH 0554/2494] [ticket/10972] Added explicit checks for creating duplicate users. PHPBB3-10972 --- .../phpbb_functional_test_case.php | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index a72c0940ab..9bc2c96753 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -30,6 +30,11 @@ class phpbb_functional_test_case extends phpbb_test_case */ protected $lang = array(); + /** + * @var array + */ + protected $created_users = array(); + static protected $config = array(); static protected $already_installed = false; @@ -197,14 +202,18 @@ class phpbb_functional_test_case extends phpbb_test_case /** * Creates a new user with limited permissions * - * Note that creating two users with the same name results in undefined - * login behaviour. Always call delete_user after running a test that + * Always call delete_user after running a test that * requires create_user. * * @param string $username Also doubles up as the user's password */ protected function create_user($username) { + if (isset($this->created_users[$username])) + { + return; + } + // Required by unique_id global $config; @@ -225,6 +234,7 @@ class phpbb_functional_test_case extends phpbb_test_case "; $db->sql_query($query); + $this->created_users[$username] = 1; } /** @@ -234,6 +244,11 @@ class phpbb_functional_test_case extends phpbb_test_case */ protected function delete_user($username) { + if (isset($this->created_users[$username])) + { + unset($this->created_users[$username]); + } + $db = $this->get_db(); $query = "DELETE FROM " . self::$config['table_prefix'] . "users WHERE username = '" . $db->sql_escape($username) . "'"; $db->sql_query($query); From ebdd96592a100139c48204ef133e706c0ac465d1 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Thu, 6 Dec 2012 22:45:12 -0500 Subject: [PATCH 0555/2494] [ticket/10972] Backport get_db from develop. PHPBB3-10972 --- .../phpbb_functional_test_case.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index 9bc2c96753..3b6232d091 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -16,7 +16,9 @@ class phpbb_functional_test_case extends phpbb_test_case { protected $client; protected $root_url; + protected $cache = null; + protected $db = null; /** * Session ID for current test's session (each test makes its own) @@ -70,6 +72,23 @@ class phpbb_functional_test_case extends phpbb_test_case { } + protected function get_db() + { + global $phpbb_root_path, $phpEx; + // so we don't reopen an open connection + if (!($this->db instanceof dbal)) + { + if (!class_exists('dbal_' . self::$config['dbms'])) + { + include($phpbb_root_path . 'includes/db/' . self::$config['dbms'] . ".$phpEx"); + } + $sql_db = 'dbal_' . self::$config['dbms']; + $this->db = new $sql_db(); + $this->db->sql_connect(self::$config['dbhost'], self::$config['dbuser'], self::$config['dbpasswd'], self::$config['dbname'], self::$config['dbport']); + } + return $this->db; + } + protected function get_cache_driver() { if (!$this->cache) From 771bb957ab4dee865ce1678eb675c37874d04e98 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Thu, 6 Dec 2012 23:41:02 -0500 Subject: [PATCH 0556/2494] [ticket/10972] Add mock null cache. The mock cache has instrumentation methods and therefore is non-trivial to implement. For those times when we don't care that the cache caches, null cache is a simpler implementation. PHPBB3-10972 --- tests/mock/null_cache.php | 42 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 tests/mock/null_cache.php diff --git a/tests/mock/null_cache.php b/tests/mock/null_cache.php new file mode 100644 index 0000000000..aca20ca77b --- /dev/null +++ b/tests/mock/null_cache.php @@ -0,0 +1,42 @@ + Date: Thu, 6 Dec 2012 23:42:13 -0500 Subject: [PATCH 0557/2494] [ticket/10972] Add destroy method to mock cache. I actually needed the version that destroys tables, therefore I ended up writing a mock null cache. This code is currently unused but will probably be handy at some point. PHPBB3-10972 --- tests/mock/cache.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/tests/mock/cache.php b/tests/mock/cache.php index 650545c3d6..aa0db5ab20 100644 --- a/tests/mock/cache.php +++ b/tests/mock/cache.php @@ -34,6 +34,16 @@ class phpbb_mock_cache $this->data[$var_name] = $var; } + public function destroy($var_name, $table = '') + { + if ($table) + { + throw new Exception('Destroying tables is not implemented yet'); + } + + unset($this->data[$var_name]); + } + /** * Obtain active bots */ @@ -41,7 +51,7 @@ class phpbb_mock_cache { return $this->data['_bots']; } - + /** * Obtain list of word censors. We don't need to parse them here, * that is tested elsewhere. From fb5c4440e598f2a775a52299a06e903d3cee5398 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Thu, 6 Dec 2012 23:43:22 -0500 Subject: [PATCH 0558/2494] [ticket/10972] Tweak user addition. Always add users, do not keep track of which users have been added. The tests should know whether users they want exist or not. Use more unique user names in tests for robustness. Added some more assertions here and there. PHPBB3-10972 --- tests/functional/auth_test.php | 12 ++-- .../phpbb_functional_test_case.php | 59 +++++++++++-------- 2 files changed, 41 insertions(+), 30 deletions(-) diff --git a/tests/functional/auth_test.php b/tests/functional/auth_test.php index e67118d8f9..3e218ebd77 100644 --- a/tests/functional/auth_test.php +++ b/tests/functional/auth_test.php @@ -18,16 +18,18 @@ class phpbb_functional_auth_test extends phpbb_functional_test_case // check for logout link $crawler = $this->request('GET', 'index.php'); + $this->assert_response_success(); $this->assertContains($this->lang('LOGOUT_USER', 'admin'), $crawler->filter('.navbar')->text()); } public function test_login_other() { - $this->create_user('user'); - $this->login('user'); + $this->create_user('anothertestuser'); + $this->login('anothertestuser'); $crawler = $this->request('GET', 'index.php'); - $this->assertContains('user', $crawler->filter('.icon-logout')->text()); - $this->delete_user('user'); + $this->assert_response_success(); + $this->assertContains('anothertestuser', $crawler->filter('.icon-logout')->text()); + $this->delete_user('anothertestuser'); } /** @@ -40,10 +42,12 @@ class phpbb_functional_auth_test extends phpbb_functional_test_case // logout $crawler = $this->request('GET', 'ucp.php?sid=' . $this->sid . '&mode=logout'); + $this->assert_response_success(); $this->assertContains($this->lang('LOGOUT_REDIRECT'), $crawler->filter('#message')->text()); // look for a register link, which should be visible only when logged out $crawler = $this->request('GET', 'index.php'); + $this->assert_response_success(); $this->assertContains($this->lang('REGISTER'), $crawler->filter('.navbar')->text()); } } diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index 3b6232d091..b17b2dcd5f 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -32,11 +32,6 @@ class phpbb_functional_test_case extends phpbb_test_case */ protected $lang = array(); - /** - * @var array - */ - protected $created_users = array(); - static protected $config = array(); static protected $already_installed = false; @@ -225,14 +220,10 @@ class phpbb_functional_test_case extends phpbb_test_case * requires create_user. * * @param string $username Also doubles up as the user's password + * @return int ID of created user */ protected function create_user($username) { - if (isset($this->created_users[$username])) - { - return; - } - // Required by unique_id global $config; @@ -243,17 +234,36 @@ class phpbb_functional_test_case extends phpbb_test_case $config['rand_seed'] = ''; $config['rand_seed_last_update'] = time() + 600; - - $db = $this->get_db(); - $query = " - INSERT INTO " . self::$config['table_prefix'] . "users - (user_type, group_id, username, username_clean, user_regdate, user_password, user_email, user_lang, user_style, user_rank, user_colour, user_posts, user_permissions, user_ip, user_birthday, user_lastpage, user_last_confirm_key, user_post_sortby_type, user_post_sortby_dir, user_topic_sortby_type, user_topic_sortby_dir, user_avatar, user_sig, user_sig_bbcode_uid, user_from, user_icq, user_aim, user_yim, user_msnm, user_jabber, user_website, user_occ, user_interests, user_actkey, user_newpasswd) - VALUES - (0, 2, 'user', 'user', 0, '" . phpbb_hash($username) . "', 'nobody@example.com', 'en', 1, 0, '', 1, '', '', '', '', '', 't', 'a', 't', 'd', '', '', '', '', '', '', '', '', '', '', '', '', '', '') - "; - $db->sql_query($query); - $this->created_users[$username] = 1; + // Required by user_add + global $db, $cache; + $db = $this->get_db(); + if (!function_exists('phpbb_mock_null_cache')) + { + require_once(__DIR__ . '/../mock/null_cache.php'); + } + $cache = new phpbb_mock_null_cache; + + if (!function_exists('utf_clean_string')) + { + require_once(__DIR__ . '/../../phpBB/includes/utf/utf_tools.php'); + } + if (!function_exists('user_add')) + { + require_once(__DIR__ . '/../../phpBB/includes/functions_user.php'); + } + + $user_row = array( + 'username' => $username, + 'group_id' => 2, + 'user_email' => 'nobody@example.com', + 'user_type' => 0, + 'user_lang' => 'en', + 'user_timezone' => 0, + 'user_dateformat' => '', + 'user_password' => phpbb_hash($username), + ); + return user_add($user_row); } /** @@ -263,11 +273,6 @@ class phpbb_functional_test_case extends phpbb_test_case */ protected function delete_user($username) { - if (isset($this->created_users[$username])) - { - unset($this->created_users[$username]); - } - $db = $this->get_db(); $query = "DELETE FROM " . self::$config['table_prefix'] . "users WHERE username = '" . $db->sql_escape($username) . "'"; $db->sql_query($query); @@ -281,7 +286,9 @@ class phpbb_functional_test_case extends phpbb_test_case $this->assertContains($this->lang('LOGIN_EXPLAIN_UCP'), $crawler->filter('html')->text()); $form = $crawler->selectButton($this->lang('LOGIN'))->form(); - $login = $this->client->submit($form, array('username' => $username, 'password' => $username)); + $crawler = $this->client->submit($form, array('username' => $username, 'password' => $username)); + $this->assert_response_success(); + $this->assertContains($this->lang('LOGIN_REDIRECT'), $crawler->filter('html')->text()); $cookies = $this->cookieJar->all(); From ff993ba9d30f5de49e5231647c5bb76d95c357f8 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Thu, 6 Dec 2012 23:47:19 -0500 Subject: [PATCH 0559/2494] [ticket/10972] Drop user deletion. Users should not be deleted in tests that test user creation. Tests should use unique user names to avoid collisions. User deletion should use user_remove anyway. PHPBB3-10972 --- tests/functional/auth_test.php | 1 - .../test_framework/phpbb_functional_test_case.php | 15 --------------- 2 files changed, 16 deletions(-) diff --git a/tests/functional/auth_test.php b/tests/functional/auth_test.php index 3e218ebd77..662b1bd38b 100644 --- a/tests/functional/auth_test.php +++ b/tests/functional/auth_test.php @@ -29,7 +29,6 @@ class phpbb_functional_auth_test extends phpbb_functional_test_case $crawler = $this->request('GET', 'index.php'); $this->assert_response_success(); $this->assertContains('anothertestuser', $crawler->filter('.icon-logout')->text()); - $this->delete_user('anothertestuser'); } /** diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index b17b2dcd5f..71e88fbcf6 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -216,9 +216,6 @@ class phpbb_functional_test_case extends phpbb_test_case /** * Creates a new user with limited permissions * - * Always call delete_user after running a test that - * requires create_user. - * * @param string $username Also doubles up as the user's password * @return int ID of created user */ @@ -266,18 +263,6 @@ class phpbb_functional_test_case extends phpbb_test_case return user_add($user_row); } - /** - * Deletes a user - * - * @param string $username The username of the user to delete - */ - protected function delete_user($username) - { - $db = $this->get_db(); - $query = "DELETE FROM " . self::$config['table_prefix'] . "users WHERE username = '" . $db->sql_escape($username) . "'"; - $db->sql_query($query); - } - protected function login($username = 'admin') { $this->add_lang('ucp'); From 25780c17a4e9c1e96e8f1648bd9bd16ff06afb7f Mon Sep 17 00:00:00 2001 From: Bruno Ais Date: Sun, 2 Dec 2012 22:59:11 +0000 Subject: [PATCH 0560/2494] [ticket/11171] DB changes for the update These are the changes to database_update.php required for this ticket. PHPBB3-11171 --- phpBB/install/database_update.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index e966756337..060d749b92 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -2792,6 +2792,23 @@ function change_database_data(&$no_updates, $version) } $db->sql_freeresult($result); + // PHPBB3-11171: Copy bbcode fields, etc. for reported posts. Add 5 columns to the reports table + + // Add the columns used by these changes + $changes['add_columns'] = array( + REPORTS_TABLE => array( + 'reported_post_enable_bbcode' => array('BOOL', 1), + 'reported_post_enable_smilies' => array('BOOL', 1), + 'reported_post_enable_magic_url' => array('BOOL', 1) + ) + ); + $statements = $db_tools->perform_schema_changes($changes); + + foreach ($statements as $sql) + { + _sql($sql, $errored, $error_ary); + } + break; } } From 83a71a2e777dcc9d1c717b6bf438b9aaf41dffba Mon Sep 17 00:00:00 2001 From: Bruno Ais Date: Sun, 2 Dec 2012 23:01:29 +0000 Subject: [PATCH 0561/2494] [ticket/11171] Use the options stored to decide how to show it Added what's needed so that the post in the report is parsed the same way as it was being parsed when the post was reported PHPBB3-11171 --- phpBB/includes/mcp/mcp_reports.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/mcp/mcp_reports.php b/phpBB/includes/mcp/mcp_reports.php index 3426d62cdb..ca730f7728 100644 --- a/phpBB/includes/mcp/mcp_reports.php +++ b/phpBB/includes/mcp/mcp_reports.php @@ -71,7 +71,7 @@ class mcp_reports // closed reports are accessed by report id $report_id = request_var('r', 0); - $sql = 'SELECT r.post_id, r.user_id, r.report_id, r.report_closed, report_time, r.report_text, r.reported_post_text, r.reported_post_uid, r.reported_post_bitfield, rr.reason_title, rr.reason_description, u.username, u.username_clean, u.user_colour + $sql = 'SELECT r.post_id, r.user_id, r.report_id, r.report_closed, report_time, r.report_text, r.reported_post_text, r.reported_post_uid, r.reported_post_bitfield, r.reported_post_enable_magic_url, r.reported_post_enable_smilies, r.reported_post_enable_bbcode, rr.reason_title, rr.reason_description, u.username, u.username_clean, u.user_colour FROM ' . REPORTS_TABLE . ' r, ' . REPORTS_REASONS_TABLE . ' rr, ' . USERS_TABLE . ' u WHERE ' . (($report_id) ? 'r.report_id = ' . $report_id : "r.post_id = $post_id") . ' AND rr.reason_id = r.reason_id @@ -94,6 +94,10 @@ class mcp_reports $post_id = $report['post_id']; $report_id = $report['report_id']; + + $parse_post_flags = $report['reported_post_enable_bbcode'] ? OPTION_FLAG_BBCODE : 0; + $parse_post_flags += $report['reported_post_enable_smilies'] ? OPTION_FLAG_SMILIES : 0; + $parse_post_flags += $report['reported_post_enable_magic_url'] ? OPTION_FLAG_LINKS : 0; $post_info = get_post_data(array($post_id), 'm_report', true); @@ -227,7 +231,7 @@ class mcp_reports 'REPORTER_NAME' => get_username_string('username', $report['user_id'], $report['username'], $report['user_colour']), 'U_VIEW_REPORTER_PROFILE' => get_username_string('profile', $report['user_id'], $report['username'], $report['user_colour']), - 'POST_PREVIEW' => generate_text_for_display($report['reported_post_text'], $report['reported_post_uid'], $report['reported_post_bitfield'], OPTION_FLAG_BBCODE | OPTION_FLAG_SMILIES, false), + 'POST_PREVIEW' => generate_text_for_display($report['reported_post_text'], $report['reported_post_uid'], $report['reported_post_bitfield'], $parse_post_flags, false), 'POST_SUBJECT' => ($post_info['post_subject']) ? $post_info['post_subject'] : $user->lang['NO_SUBJECT'], 'POST_DATE' => $user->format_date($post_info['post_time']), 'POST_IP' => $post_info['poster_ip'], From 91246c20fa8b9218fe0ddc8b52236d4b878346dd Mon Sep 17 00:00:00 2001 From: Bruno Ais Date: Sun, 2 Dec 2012 23:07:40 +0000 Subject: [PATCH 0562/2494] [ticket/11171] Adapted the code in report.php Added the variable aliases needed (to look and feel the same as it was before) Added the variables into the table insert. PHPBB3-11171 --- phpBB/report.php | 46 +++++++++++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 19 deletions(-) diff --git a/phpBB/report.php b/phpBB/report.php index d792b8df6a..be38bad2f3 100644 --- a/phpBB/report.php +++ b/phpBB/report.php @@ -71,11 +71,14 @@ if ($post_id) trigger_error('POST_NOT_EXIST'); } - $forum_id = (int) $report_data['forum_id']; - $topic_id = (int) $report_data['topic_id']; - $reported_post_text = $report_data['post_text']; - $reported_post_bitfield = $report_data['bbcode_bitfield']; - $reported_post_uid = $report_data['bbcode_uid']; + $forum_id = (int) $report_data['forum_id']; + $topic_id = (int) $report_data['topic_id']; + $reported_post_text = $report_data['post_text']; + $reported_post_bitfield = $report_data['bbcode_bitfield']; + $reported_post_uid = $report_data['bbcode_uid']; + $reported_post_enable_bbcode = $report_data['enable_bbcode']; + $reported_post_enable_smilies = $report_data['enable_smilies']; + $reported_post_enable_magic_url = $report_data['enable_magic_url']; $sql = 'SELECT * FROM ' . FORUMS_TABLE . ' @@ -134,9 +137,11 @@ else trigger_error($message); } - $reported_post_text = $report_data['message_text']; - $reported_post_bitfield = $report_data['bbcode_bitfield']; - $reported_post_uid = $report_data['bbcode_uid']; + $reported_post_text = $report_data['message_text']; + $reported_post_bitfield = $report_data['bbcode_bitfield']; + $reported_post_enable_bbcode = $report_data['reported_post_enable_bbcode']; + $reported_post_enable_smilies = $report_data['reported_post_enable_smilies']; + $reported_post_enable_magic_url = $report_data['reported_post_enable_magic_url']; } // Submit report? @@ -155,17 +160,20 @@ if ($submit && $reason_id) } $sql_ary = array( - 'reason_id' => (int) $reason_id, - 'post_id' => $post_id, - 'pm_id' => $pm_id, - 'user_id' => (int) $user->data['user_id'], - 'user_notify' => (int) $user_notify, - 'report_closed' => 0, - 'report_time' => (int) time(), - 'report_text' => (string) $report_text, - 'reported_post_text' => $reported_post_text, - 'reported_post_uid' => $reported_post_uid, - 'reported_post_bitfield'=> $reported_post_bitfield, + 'reason_id' => (int) $reason_id, + 'post_id' => $post_id, + 'pm_id' => $pm_id, + 'user_id' => (int) $user->data['user_id'], + 'user_notify' => (int) $user_notify, + 'report_closed' => 0, + 'report_time' => (int) time(), + 'report_text' => (string) $report_text, + 'reported_post_text' => $reported_post_text, + 'reported_post_uid' => $reported_post_uid, + 'reported_post_bitfield' => $reported_post_bitfield, + 'reported_post_enable_bbcode' => $reported_post_enable_bbcode, + 'reported_post_enable_smilies' => $reported_post_enable_smilies, + 'reported_post_enable_magic_url' => $reported_post_enable_magic_url, ); $sql = 'INSERT INTO ' . REPORTS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary); From 73971ef0fa2a53b056847a524bb84f8b2d3e5a4b Mon Sep 17 00:00:00 2001 From: Bruno Ais Date: Sun, 2 Dec 2012 23:19:59 +0000 Subject: [PATCH 0563/2494] [ticket/11171] Cleanup of leftovers I didn't notice that there were actually leftovers from the other PR. Anyway, this will remove all the leftovers I noticed from the other PR. PHPBB3-11171 --- phpBB/includes/mcp/mcp_reports.php | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/phpBB/includes/mcp/mcp_reports.php b/phpBB/includes/mcp/mcp_reports.php index ca730f7728..8da303f6e3 100644 --- a/phpBB/includes/mcp/mcp_reports.php +++ b/phpBB/includes/mcp/mcp_reports.php @@ -140,18 +140,7 @@ class mcp_reports $post_unread = (isset($topic_tracking_info[$post_info['topic_id']]) && $post_info['post_time'] > $topic_tracking_info[$post_info['topic_id']]) ? true : false; - // Process message, leave it uncensored - $message = $post_info['post_text']; - if ($post_info['bbcode_bitfield']) - { - include_once($phpbb_root_path . 'includes/bbcode.' . $phpEx); - $bbcode = new bbcode($post_info['bbcode_bitfield']); - $bbcode->bbcode_second_pass($message, $post_info['bbcode_uid'], $post_info['bbcode_bitfield']); - } - - $message = bbcode_nl2br($message); - $message = smiley_text($message); $report['report_text'] = make_clickable(bbcode_nl2br($report['report_text'])); if ($post_info['post_attachment'] && $auth->acl_get('u_download') && $auth->acl_get('f_download', $post_info['forum_id'])) @@ -172,7 +161,7 @@ class mcp_reports if (sizeof($attachments)) { $update_count = array(); - parse_attachments($post_info['forum_id'], $message, $attachments, $update_count); + parse_attachments($post_info['forum_id'], $report['reported_post_text'], $attachments, $update_count); } // Display not already displayed Attachments for this post, we already parsed them. ;) From 5213ee1829c0ca4689d6137ac011cc759a727c59 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 7 Dec 2012 14:39:57 +0100 Subject: [PATCH 0564/2494] [ticket/10714] Make attributed protected rather then private PHPBB3-10714 --- phpBB/includes/log/log.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/phpBB/includes/log/log.php b/phpBB/includes/log/log.php index eff084bbd2..b6f275835c 100644 --- a/phpBB/includes/log/log.php +++ b/phpBB/includes/log/log.php @@ -25,22 +25,22 @@ class phpbb_log implements phpbb_log_interface /** * Keeps the status of the log system. Is the log enabled or disabled? */ - private $disabled_logs; + protected $disabled_logs; /** * Keeps the total log count of the last call to get_logs() */ - private $logs_total; + protected $logs_total; /** * Keeps the offset of the last valid page of the last call to get_logs() */ - private $logs_offset; + protected $logs_offset; /** * The table we use to store our logs. */ - private $log_table; + protected $log_table; /** * Constructor From 70d23380aa55c2aab33c1c2e5cea57f186314584 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 7 Dec 2012 15:11:56 +0100 Subject: [PATCH 0565/2494] [ticket/10714] Rely on global instead of creating an instance PHPBB3-10714 --- phpBB/includes/functions.php | 6 ------ phpBB/includes/functions_admin.php | 6 ------ 2 files changed, 12 deletions(-) diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 93dfb4cd7f..7c1a48f913 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -3367,12 +3367,6 @@ function add_log() return false; } - // no log class set, create a temporary one ourselves to keep backwards compatibility - if ($phpbb_log === null) - { - $phpbb_log = new phpbb_log(LOG_TABLE); - } - $mode = array_shift($args); // This looks kind of dirty, but add_log has some additional data before the log_operation diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index 2a87feed51..8a1f34e76d 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -2490,12 +2490,6 @@ function view_log($mode, &$log, &$log_count, $limit = 0, $offset = 0, $forum_id { global $phpbb_log; - // no log class set, create a temporary one ourselves to keep backwards compatability - if ($phpbb_log === null) - { - $phpbb_log = new phpbb_log(LOG_TABLE); - } - $count_logs = ($log_count !== false); $log = $phpbb_log->get_logs($mode, $count_logs, $limit, $offset, $forum_id, $topic_id, $user_id, $limit_days, $sort_by, $keywords); From 9eecaa21e3fe23c0c1afc7f8d057754fca68e9a6 Mon Sep 17 00:00:00 2001 From: Bruno Ais Date: Thu, 6 Dec 2012 11:22:56 +0000 Subject: [PATCH 0566/2494] [ticket/11171] Moved the DB schema changes to its place Moved the db changes schema to the place where all the other schema changes are. PHPBB3-11171 --- phpBB/install/database_update.php | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 060d749b92..91365d4a72 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -1123,9 +1123,12 @@ function database_update_info() 'style_parent_tree' => array('TEXT', ''), ), REPORTS_TABLE => array( - 'reported_post_text' => array('MTEXT_UNI', ''), - 'reported_post_uid' => array('VCHAR:8', ''), - 'reported_post_bitfield' => array('VCHAR:255', ''), + 'reported_post_text' => array('MTEXT_UNI', ''), + 'reported_post_uid' => array('VCHAR:8', ''), + 'reported_post_bitfield' => array('VCHAR:255', ''), + 'reported_post_enable_bbcode' => array('BOOL', 1), + 'reported_post_enable_smilies' => array('BOOL', 1), + 'reported_post_enable_magic_url' => array('BOOL', 1), ), ), 'change_columns' => array( @@ -2791,23 +2794,7 @@ function change_database_data(&$no_updates, $version) _sql($sql, $errored, $error_ary); } $db->sql_freeresult($result); - - // PHPBB3-11171: Copy bbcode fields, etc. for reported posts. Add 5 columns to the reports table - // Add the columns used by these changes - $changes['add_columns'] = array( - REPORTS_TABLE => array( - 'reported_post_enable_bbcode' => array('BOOL', 1), - 'reported_post_enable_smilies' => array('BOOL', 1), - 'reported_post_enable_magic_url' => array('BOOL', 1) - ) - ); - $statements = $db_tools->perform_schema_changes($changes); - - foreach ($statements as $sql) - { - _sql($sql, $errored, $error_ary); - } break; } From 0f94ff91383ee0ed533048db96a34164ba94b0a4 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 7 Dec 2012 16:05:57 +0100 Subject: [PATCH 0567/2494] [ticket/10714] Add global variables for the unit tests PHPBB3-10714 --- tests/log/function_add_log_test.php | 4 +++- tests/log/function_view_log_test.php | 6 ++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/tests/log/function_add_log_test.php b/tests/log/function_add_log_test.php index 77c4578baa..7ed862c523 100644 --- a/tests/log/function_add_log_test.php +++ b/tests/log/function_add_log_test.php @@ -142,7 +142,7 @@ class phpbb_log_function_add_log_test extends phpbb_database_test_case */ public function test_add_log_function($expected, $user_id, $mode, $required1, $additional1 = null, $additional2 = null, $additional3 = null) { - global $db, $user, $phpbb_dispatcher; + global $db, $cache, $user, $phpbb_log, $phpbb_dispatcher; if ($expected) { @@ -155,7 +155,9 @@ class phpbb_log_function_add_log_test extends phpbb_database_test_case } $db = $this->new_dbal(); + $cache = new phpbb_mock_cache; $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); + $phpbb_log = new phpbb_log(LOG_TABLE); $user->ip = 'user_ip'; if ($user_id) diff --git a/tests/log/function_view_log_test.php b/tests/log/function_view_log_test.php index 790597e9c8..f7e2c51c32 100644 --- a/tests/log/function_view_log_test.php +++ b/tests/log/function_view_log_test.php @@ -24,7 +24,8 @@ class phpbb_log_function_view_log_test extends phpbb_database_test_case public static function test_view_log_function_data() { - global $phpEx; + global $phpEx, $phpbb_dispatcher; + $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); $expected_data_sets = array( 1 => array( @@ -299,11 +300,12 @@ class phpbb_log_function_view_log_test extends phpbb_database_test_case */ public function test_view_log_function($expected, $expected_returned, $mode, $log_count, $limit = 5, $offset = 0, $forum_id = 0, $topic_id = 0, $user_id = 0, $limit_days = 0, $sort_by = 'l.log_id ASC', $keywords = '') { - global $cache, $db, $user, $auth, $phpbb_dispatcher; + global $cache, $db, $user, $auth, $phpbb_log, $phpbb_dispatcher; $db = $this->new_dbal(); $cache = new phpbb_mock_cache; $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); + $phpbb_log = new phpbb_log(LOGS_TABLE); // Create auth mock $auth = $this->getMock('phpbb_auth'); From 7f1b0eeb711c57de82235d7893d793969ed0cfdd Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 7 Dec 2012 16:28:46 +0100 Subject: [PATCH 0568/2494] [ticket/10714] Compare log_type to false, rather then null PHPBB3-10714 --- phpBB/includes/log/log.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/phpBB/includes/log/log.php b/phpBB/includes/log/log.php index b6f275835c..c2ebedd6f2 100644 --- a/phpBB/includes/log/log.php +++ b/phpBB/includes/log/log.php @@ -278,14 +278,14 @@ class phpbb_log implements phpbb_log_interface break; default: - $log_type = null; + $log_type = false; $sql_additional = ''; } /** * Overwrite log type and limitations before we count and get the logs * - * NOTE: if log_type is not set, no entries will be returned. + * NOTE: if log_type is false, no entries will be returned. * * @event core.get_logs_modify_type * @var string mode Mode of the entries we display @@ -302,7 +302,7 @@ class phpbb_log implements phpbb_log_interface * keywords in log_operation or log_data * @var string profile_url URL to the users profile * @var int log_type Limit logs to a certain type. If log_type - * is not set, no entries will be returned. + * is false, no entries will be returned. * @var string sql_additional Additional conditions for the entries, * e.g.: 'AND l.forum_id = 1' * @since 3.1-A1 @@ -310,7 +310,7 @@ class phpbb_log implements phpbb_log_interface $vars = array('mode', 'count_logs', 'limit', 'offset', 'forum_id', 'topic_id', 'user_id', 'log_time', 'sort_by', 'keywords', 'profile_url', 'log_type', 'sql_additional'); extract($phpbb_dispatcher->trigger_event('core.get_logs_modify_type', $vars)); - if (!isset($log_type)) + if ($log_type === false) { $this->logs_offset = 0; return array(); From 5b368dd53a2da6ab481bc608176f442dc067c4a7 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Fri, 7 Dec 2012 15:32:06 -0500 Subject: [PATCH 0569/2494] [ticket/11255] Fix dbal write sequence test to run standalone. PHPBB3-11255 --- tests/dbal/write_sequence_test.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/dbal/write_sequence_test.php b/tests/dbal/write_sequence_test.php index 8975cfbfb1..f382a971a5 100644 --- a/tests/dbal/write_sequence_test.php +++ b/tests/dbal/write_sequence_test.php @@ -33,6 +33,10 @@ class phpbb_dbal_write_sequence_test extends phpbb_database_test_case { $db = $this->new_dbal(); + // dbal uses cache + global $cache; + $cache = new phpbb_mock_cache(); + $sql = 'INSERT INTO phpbb_users ' . $db->sql_build_array('INSERT', array( 'username' => $username, 'username_clean' => $username, From 5af3d14af3c35e99c0eba75c43a411ead6191c79 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Fri, 7 Dec 2012 15:32:26 -0500 Subject: [PATCH 0570/2494] [ticket/11255] Change search tests to use mock cache. PHPBB3-11255 --- tests/search/mysql_test.php | 2 +- tests/search/native_test.php | 2 +- tests/search/postgres_test.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/search/mysql_test.php b/tests/search/mysql_test.php index 3ba3915714..3ad15bd806 100644 --- a/tests/search/mysql_test.php +++ b/tests/search/mysql_test.php @@ -26,7 +26,7 @@ class phpbb_search_mysql_test extends phpbb_search_common_test_case parent::setUp(); // dbal uses cache - $cache = new phpbb_cache_service(new phpbb_cache_driver_null); + $cache = new phpbb_mock_cache(); // set config values $config['fulltext_mysql_min_word_len'] = 4; diff --git a/tests/search/native_test.php b/tests/search/native_test.php index eeee3a44f3..4a2c210013 100644 --- a/tests/search/native_test.php +++ b/tests/search/native_test.php @@ -26,7 +26,7 @@ class phpbb_search_native_test extends phpbb_search_test_case parent::setUp(); // dbal uses cache - $cache = new phpbb_cache_service(new phpbb_cache_driver_null); + $cache = new phpbb_mock_cache(); $this->db = $this->new_dbal(); $error = null; diff --git a/tests/search/postgres_test.php b/tests/search/postgres_test.php index 9c77e0c09e..923af6f854 100644 --- a/tests/search/postgres_test.php +++ b/tests/search/postgres_test.php @@ -26,7 +26,7 @@ class phpbb_search_postgres_test extends phpbb_search_common_test_case parent::setUp(); // dbal uses cache - $cache = new phpbb_cache_service(new phpbb_cache_driver_null); + $cache = new phpbb_mock_cache(); // set config values $config['fulltext_postgres_min_word_len'] = 4; From cf956e8f53cadbbe647651b9fd87f9feba23f7e2 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Fri, 7 Dec 2012 23:14:07 +0100 Subject: [PATCH 0571/2494] [ticket/11256] Remove unused service with non-existent class PHPBB3-11256 --- phpBB/config/services.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/phpBB/config/services.yml b/phpBB/config/services.yml index 37e6c0b5df..fb1df6f508 100644 --- a/phpBB/config/services.yml +++ b/phpBB/config/services.yml @@ -59,12 +59,6 @@ services: - @service_container - @ext.finder - controller.route_collection: - class: phpbb_controller_route_collection - arguments: - - @ext.finder - - @controller.provider - controller.provider: class: phpbb_controller_provider From 2973539760beebc1bb60dc91382c2b628d4276c6 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Fri, 7 Dec 2012 23:18:38 +0100 Subject: [PATCH 0572/2494] [ticket/11256] Remove unused controller.provider service PHPBB3-11256 --- phpBB/config/services.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/phpBB/config/services.yml b/phpBB/config/services.yml index fb1df6f508..242fe7f1d2 100644 --- a/phpBB/config/services.yml +++ b/phpBB/config/services.yml @@ -59,9 +59,6 @@ services: - @service_container - @ext.finder - controller.provider: - class: phpbb_controller_provider - cron.task_collection: class: phpbb_di_service_collection arguments: From 03d2c6413c25b1faf7f37ff20625ce986b19eb88 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Fri, 7 Dec 2012 21:57:33 -0500 Subject: [PATCH 0573/2494] [ticket/11248] Convert line endings to LF - develop edition. PHPBB3-11248 --- phpBB/docs/sphinx.sample.conf | 90 +- phpBB/includes/sphinxapi.php | 3424 ++++++++++++++--------------- tests/session/append_sid_test.php | 108 +- 3 files changed, 1826 insertions(+), 1796 deletions(-) diff --git a/phpBB/docs/sphinx.sample.conf b/phpBB/docs/sphinx.sample.conf index aa0e8d905d..fcaba6dcf3 100644 --- a/phpBB/docs/sphinx.sample.conf +++ b/phpBB/docs/sphinx.sample.conf @@ -10,21 +10,36 @@ source source_phpbb_{SPHINX_ID}_main sql_query_pre = UPDATE phpbb_sphinx SET max_doc_id = MAX(post_id) WHERE counter_id = 1 sql_query_range = SELECT MIN(post_id), MAX(post_id) FROM phpbb_posts sql_range_step = 5000 - sql_query = SELECT \ - p.post_id AS id, \ - p.forum_id, \ - p.topic_id, \ - p.poster_id, \ - CASE WHEN p.post_id = t.topic_first_post_id THEN 1 ELSE 0 END as topic_first_post, \ - p.post_time, \ - p.post_subject, \ - p.post_subject as title, \ - p.post_text as data, \ - t.topic_last_post_time, \ - 0 as deleted \ - FROM phpbb_posts p, phpbb_topics t \ - WHERE \ - p.topic_id = t.topic_id \ + sql_query = SELECT +\ + p.post_id AS id, +\ + p.forum_id, +\ + p.topic_id, +\ + p.poster_id, +\ + CASE WHEN p.post_id = t.topic_first_post_id THEN 1 ELSE 0 END as topic_first_post, +\ + p.post_time, +\ + p.post_subject, +\ + p.post_subject as title, +\ + p.post_text as data, +\ + t.topic_last_post_time, +\ + 0 as deleted +\ + FROM phpbb_posts p, phpbb_topics t +\ + WHERE +\ + p.topic_id = t.topic_id +\ AND p.post_id >= $start AND p.post_id <= $end sql_query_post = sql_query_post_index = UPDATE phpbb_sphinx SET max_doc_id = $maxid WHERE counter_id = 1 @@ -42,21 +57,36 @@ source source_phpbb_{SPHINX_ID}_delta : source_phpbb_{SPHINX_ID}_main { sql_query_range = sql_range_step = - sql_query = SELECT \ - p.post_id AS id, \ - p.forum_id, \ - p.topic_id, \ - p.poster_id, \ - CASE WHEN p.post_id = t.topic_first_post_id THEN 1 ELSE 0 END as topic_first_post, \ - p.post_time, \ - p.post_subject, \ - p.post_subject as title, \ - p.post_text as data, \ - t.topic_last_post_time, \ - 0 as deleted \ - FROM phpbb_posts p, phpbb_topics t \ - WHERE \ - p.topic_id = t.topic_id \ + sql_query = SELECT +\ + p.post_id AS id, +\ + p.forum_id, +\ + p.topic_id, +\ + p.poster_id, +\ + CASE WHEN p.post_id = t.topic_first_post_id THEN 1 ELSE 0 END as topic_first_post, +\ + p.post_time, +\ + p.post_subject, +\ + p.post_subject as title, +\ + p.post_text as data, +\ + t.topic_last_post_time, +\ + 0 as deleted +\ + FROM phpbb_posts p, phpbb_topics t +\ + WHERE +\ + p.topic_id = t.topic_id +\ AND p.post_id >= ( SELECT max_doc_id FROM phpbb_sphinx WHERE counter_id=1 ) sql_query_pre = } diff --git a/phpBB/includes/sphinxapi.php b/phpBB/includes/sphinxapi.php index bd83b1d2e0..6c3b66710c 100644 --- a/phpBB/includes/sphinxapi.php +++ b/phpBB/includes/sphinxapi.php @@ -1,1712 +1,1712 @@ -=8 ) - { - $v = (int)$v; - return pack ( "NN", $v>>32, $v&0xFFFFFFFF ); - } - - // x32, int - if ( is_int($v) ) - return pack ( "NN", $v < 0 ? -1 : 0, $v ); - - // x32, bcmath - if ( function_exists("bcmul") ) - { - if ( bccomp ( $v, 0 ) == -1 ) - $v = bcadd ( "18446744073709551616", $v ); - $h = bcdiv ( $v, "4294967296", 0 ); - $l = bcmod ( $v, "4294967296" ); - return pack ( "NN", (float)$h, (float)$l ); // conversion to float is intentional; int would lose 31st bit - } - - // x32, no-bcmath - $p = max(0, strlen($v) - 13); - $lo = abs((float)substr($v, $p)); - $hi = abs((float)substr($v, 0, $p)); - - $m = $lo + $hi*1316134912.0; // (10 ^ 13) % (1 << 32) = 1316134912 - $q = floor($m/4294967296.0); - $l = $m - ($q*4294967296.0); - $h = $hi*2328.0 + $q; // (10 ^ 13) / (1 << 32) = 2328 - - if ( $v<0 ) - { - if ( $l==0 ) - $h = 4294967296.0 - $h; - else - { - $h = 4294967295.0 - $h; - $l = 4294967296.0 - $l; - } - } - return pack ( "NN", $h, $l ); -} - -/// pack 64-bit unsigned -function sphPackU64 ( $v ) -{ - assert ( is_numeric($v) ); - - // x64 - if ( PHP_INT_SIZE>=8 ) - { - assert ( $v>=0 ); - - // x64, int - if ( is_int($v) ) - return pack ( "NN", $v>>32, $v&0xFFFFFFFF ); - - // x64, bcmath - if ( function_exists("bcmul") ) - { - $h = bcdiv ( $v, 4294967296, 0 ); - $l = bcmod ( $v, 4294967296 ); - return pack ( "NN", $h, $l ); - } - - // x64, no-bcmath - $p = max ( 0, strlen($v) - 13 ); - $lo = (int)substr ( $v, $p ); - $hi = (int)substr ( $v, 0, $p ); - - $m = $lo + $hi*1316134912; - $l = $m % 4294967296; - $h = $hi*2328 + (int)($m/4294967296); - - return pack ( "NN", $h, $l ); - } - - // x32, int - if ( is_int($v) ) - return pack ( "NN", 0, $v ); - - // x32, bcmath - if ( function_exists("bcmul") ) - { - $h = bcdiv ( $v, "4294967296", 0 ); - $l = bcmod ( $v, "4294967296" ); - return pack ( "NN", (float)$h, (float)$l ); // conversion to float is intentional; int would lose 31st bit - } - - // x32, no-bcmath - $p = max(0, strlen($v) - 13); - $lo = (float)substr($v, $p); - $hi = (float)substr($v, 0, $p); - - $m = $lo + $hi*1316134912.0; - $q = floor($m / 4294967296.0); - $l = $m - ($q * 4294967296.0); - $h = $hi*2328.0 + $q; - - return pack ( "NN", $h, $l ); -} - -// unpack 64-bit unsigned -function sphUnpackU64 ( $v ) -{ - list ( $hi, $lo ) = array_values ( unpack ( "N*N*", $v ) ); - - if ( PHP_INT_SIZE>=8 ) - { - if ( $hi<0 ) $hi += (1<<32); // because php 5.2.2 to 5.2.5 is totally fucked up again - if ( $lo<0 ) $lo += (1<<32); - - // x64, int - if ( $hi<=2147483647 ) - return ($hi<<32) + $lo; - - // x64, bcmath - if ( function_exists("bcmul") ) - return bcadd ( $lo, bcmul ( $hi, "4294967296" ) ); - - // x64, no-bcmath - $C = 100000; - $h = ((int)($hi / $C) << 32) + (int)($lo / $C); - $l = (($hi % $C) << 32) + ($lo % $C); - if ( $l>$C ) - { - $h += (int)($l / $C); - $l = $l % $C; - } - - if ( $h==0 ) - return $l; - return sprintf ( "%d%05d", $h, $l ); - } - - // x32, int - if ( $hi==0 ) - { - if ( $lo>0 ) - return $lo; - return sprintf ( "%u", $lo ); - } - - $hi = sprintf ( "%u", $hi ); - $lo = sprintf ( "%u", $lo ); - - // x32, bcmath - if ( function_exists("bcmul") ) - return bcadd ( $lo, bcmul ( $hi, "4294967296" ) ); - - // x32, no-bcmath - $hi = (float)$hi; - $lo = (float)$lo; - - $q = floor($hi/10000000.0); - $r = $hi - $q*10000000.0; - $m = $lo + $r*4967296.0; - $mq = floor($m/10000000.0); - $l = $m - $mq*10000000.0; - $h = $q*4294967296.0 + $r*429.0 + $mq; - - $h = sprintf ( "%.0f", $h ); - $l = sprintf ( "%07.0f", $l ); - if ( $h=="0" ) - return sprintf( "%.0f", (float)$l ); - return $h . $l; -} - -// unpack 64-bit signed -function sphUnpackI64 ( $v ) -{ - list ( $hi, $lo ) = array_values ( unpack ( "N*N*", $v ) ); - - // x64 - if ( PHP_INT_SIZE>=8 ) - { - if ( $hi<0 ) $hi += (1<<32); // because php 5.2.2 to 5.2.5 is totally fucked up again - if ( $lo<0 ) $lo += (1<<32); - - return ($hi<<32) + $lo; - } - - // x32, int - if ( $hi==0 ) - { - if ( $lo>0 ) - return $lo; - return sprintf ( "%u", $lo ); - } - // x32, int - elseif ( $hi==-1 ) - { - if ( $lo<0 ) - return $lo; - return sprintf ( "%.0f", $lo - 4294967296.0 ); - } - - $neg = ""; - $c = 0; - if ( $hi<0 ) - { - $hi = ~$hi; - $lo = ~$lo; - $c = 1; - $neg = "-"; - } - - $hi = sprintf ( "%u", $hi ); - $lo = sprintf ( "%u", $lo ); - - // x32, bcmath - if ( function_exists("bcmul") ) - return $neg . bcadd ( bcadd ( $lo, bcmul ( $hi, "4294967296" ) ), $c ); - - // x32, no-bcmath - $hi = (float)$hi; - $lo = (float)$lo; - - $q = floor($hi/10000000.0); - $r = $hi - $q*10000000.0; - $m = $lo + $r*4967296.0; - $mq = floor($m/10000000.0); - $l = $m - $mq*10000000.0 + $c; - $h = $q*4294967296.0 + $r*429.0 + $mq; - if ( $l==10000000 ) - { - $l = 0; - $h += 1; - } - - $h = sprintf ( "%.0f", $h ); - $l = sprintf ( "%07.0f", $l ); - if ( $h=="0" ) - return $neg . sprintf( "%.0f", (float)$l ); - return $neg . $h . $l; -} - - -function sphFixUint ( $value ) -{ - if ( PHP_INT_SIZE>=8 ) - { - // x64 route, workaround broken unpack() in 5.2.2+ - if ( $value<0 ) $value += (1<<32); - return $value; - } - else - { - // x32 route, workaround php signed/unsigned braindamage - return sprintf ( "%u", $value ); - } -} - - -/// sphinx searchd client class -class SphinxClient -{ - var $_host; ///< searchd host (default is "localhost") - var $_port; ///< searchd port (default is 9312) - var $_offset; ///< how many records to seek from result-set start (default is 0) - var $_limit; ///< how many records to return from result-set starting at offset (default is 20) - var $_mode; ///< query matching mode (default is SPH_MATCH_ALL) - var $_weights; ///< per-field weights (default is 1 for all fields) - var $_sort; ///< match sorting mode (default is SPH_SORT_RELEVANCE) - var $_sortby; ///< attribute to sort by (defualt is "") - var $_min_id; ///< min ID to match (default is 0, which means no limit) - var $_max_id; ///< max ID to match (default is 0, which means no limit) - var $_filters; ///< search filters - var $_groupby; ///< group-by attribute name - var $_groupfunc; ///< group-by function (to pre-process group-by attribute value with) - var $_groupsort; ///< group-by sorting clause (to sort groups in result set with) - var $_groupdistinct;///< group-by count-distinct attribute - var $_maxmatches; ///< max matches to retrieve - var $_cutoff; ///< cutoff to stop searching at (default is 0) - var $_retrycount; ///< distributed retries count - var $_retrydelay; ///< distributed retries delay - var $_anchor; ///< geographical anchor point - var $_indexweights; ///< per-index weights - var $_ranker; ///< ranking mode (default is SPH_RANK_PROXIMITY_BM25) - var $_rankexpr; ///< ranking mode expression (for SPH_RANK_EXPR) - var $_maxquerytime; ///< max query time, milliseconds (default is 0, do not limit) - var $_fieldweights; ///< per-field-name weights - var $_overrides; ///< per-query attribute values overrides - var $_select; ///< select-list (attributes or expressions, with optional aliases) - - var $_error; ///< last error message - var $_warning; ///< last warning message - var $_connerror; ///< connection error vs remote error flag - - var $_reqs; ///< requests array for multi-query - var $_mbenc; ///< stored mbstring encoding - var $_arrayresult; ///< whether $result["matches"] should be a hash or an array - var $_timeout; ///< connect timeout - - ///////////////////////////////////////////////////////////////////////////// - // common stuff - ///////////////////////////////////////////////////////////////////////////// - - /// create a new client object and fill defaults - function SphinxClient () - { - // per-client-object settings - $this->_host = "localhost"; - $this->_port = 9312; - $this->_path = false; - $this->_socket = false; - - // per-query settings - $this->_offset = 0; - $this->_limit = 20; - $this->_mode = SPH_MATCH_ALL; - $this->_weights = array (); - $this->_sort = SPH_SORT_RELEVANCE; - $this->_sortby = ""; - $this->_min_id = 0; - $this->_max_id = 0; - $this->_filters = array (); - $this->_groupby = ""; - $this->_groupfunc = SPH_GROUPBY_DAY; - $this->_groupsort = "@group desc"; - $this->_groupdistinct= ""; - $this->_maxmatches = 1000; - $this->_cutoff = 0; - $this->_retrycount = 0; - $this->_retrydelay = 0; - $this->_anchor = array (); - $this->_indexweights= array (); - $this->_ranker = SPH_RANK_PROXIMITY_BM25; - $this->_rankexpr = ""; - $this->_maxquerytime= 0; - $this->_fieldweights= array(); - $this->_overrides = array(); - $this->_select = "*"; - - $this->_error = ""; // per-reply fields (for single-query case) - $this->_warning = ""; - $this->_connerror = false; - - $this->_reqs = array (); // requests storage (for multi-query case) - $this->_mbenc = ""; - $this->_arrayresult = false; - $this->_timeout = 0; - } - - function __destruct() - { - if ( $this->_socket !== false ) - fclose ( $this->_socket ); - } - - /// get last error message (string) - function GetLastError () - { - return $this->_error; - } - - /// get last warning message (string) - function GetLastWarning () - { - return $this->_warning; - } - - /// get last error flag (to tell network connection errors from searchd errors or broken responses) - function IsConnectError() - { - return $this->_connerror; - } - - /// set searchd host name (string) and port (integer) - function SetServer ( $host, $port = 0 ) - { - assert ( is_string($host) ); - if ( $host[0] == '/') - { - $this->_path = 'unix://' . $host; - return; - } - if ( substr ( $host, 0, 7 )=="unix://" ) - { - $this->_path = $host; - return; - } - - assert ( is_int($port) ); - $this->_host = $host; - $this->_port = $port; - $this->_path = ''; - - } - - /// set server connection timeout (0 to remove) - function SetConnectTimeout ( $timeout ) - { - assert ( is_numeric($timeout) ); - $this->_timeout = $timeout; - } - - - function _Send ( $handle, $data, $length ) - { - if ( feof($handle) || fwrite ( $handle, $data, $length ) !== $length ) - { - $this->_error = 'connection unexpectedly closed (timed out?)'; - $this->_connerror = true; - return false; - } - return true; - } - - ///////////////////////////////////////////////////////////////////////////// - - /// enter mbstring workaround mode - function _MBPush () - { - $this->_mbenc = ""; - if ( ini_get ( "mbstring.func_overload" ) & 2 ) - { - $this->_mbenc = mb_internal_encoding(); - mb_internal_encoding ( "latin1" ); - } - } - - /// leave mbstring workaround mode - function _MBPop () - { - if ( $this->_mbenc ) - mb_internal_encoding ( $this->_mbenc ); - } - - /// connect to searchd server - function _Connect () - { - if ( $this->_socket!==false ) - { - // we are in persistent connection mode, so we have a socket - // however, need to check whether it's still alive - if ( !@feof ( $this->_socket ) ) - return $this->_socket; - - // force reopen - $this->_socket = false; - } - - $errno = 0; - $errstr = ""; - $this->_connerror = false; - - if ( $this->_path ) - { - $host = $this->_path; - $port = 0; - } - else - { - $host = $this->_host; - $port = $this->_port; - } - - if ( $this->_timeout<=0 ) - $fp = @fsockopen ( $host, $port, $errno, $errstr ); - else - $fp = @fsockopen ( $host, $port, $errno, $errstr, $this->_timeout ); - - if ( !$fp ) - { - if ( $this->_path ) - $location = $this->_path; - else - $location = "{$this->_host}:{$this->_port}"; - - $errstr = trim ( $errstr ); - $this->_error = "connection to $location failed (errno=$errno, msg=$errstr)"; - $this->_connerror = true; - return false; - } - - // send my version - // this is a subtle part. we must do it before (!) reading back from searchd. - // because otherwise under some conditions (reported on FreeBSD for instance) - // TCP stack could throttle write-write-read pattern because of Nagle. - if ( !$this->_Send ( $fp, pack ( "N", 1 ), 4 ) ) - { - fclose ( $fp ); - $this->_error = "failed to send client protocol version"; - return false; - } - - // check version - list(,$v) = unpack ( "N*", fread ( $fp, 4 ) ); - $v = (int)$v; - if ( $v<1 ) - { - fclose ( $fp ); - $this->_error = "expected searchd protocol version 1+, got version '$v'"; - return false; - } - - return $fp; - } - - /// get and check response packet from searchd server - function _GetResponse ( $fp, $client_ver ) - { - $response = ""; - $len = 0; - - $header = fread ( $fp, 8 ); - if ( strlen($header)==8 ) - { - list ( $status, $ver, $len ) = array_values ( unpack ( "n2a/Nb", $header ) ); - $left = $len; - while ( $left>0 && !feof($fp) ) - { - $chunk = fread ( $fp, min ( 8192, $left ) ); - if ( $chunk ) - { - $response .= $chunk; - $left -= strlen($chunk); - } - } - } - if ( $this->_socket === false ) - fclose ( $fp ); - - // check response - $read = strlen ( $response ); - if ( !$response || $read!=$len ) - { - $this->_error = $len - ? "failed to read searchd response (status=$status, ver=$ver, len=$len, read=$read)" - : "received zero-sized searchd response"; - return false; - } - - // check status - if ( $status==SEARCHD_WARNING ) - { - list(,$wlen) = unpack ( "N*", substr ( $response, 0, 4 ) ); - $this->_warning = substr ( $response, 4, $wlen ); - return substr ( $response, 4+$wlen ); - } - if ( $status==SEARCHD_ERROR ) - { - $this->_error = "searchd error: " . substr ( $response, 4 ); - return false; - } - if ( $status==SEARCHD_RETRY ) - { - $this->_error = "temporary searchd error: " . substr ( $response, 4 ); - return false; - } - if ( $status!=SEARCHD_OK ) - { - $this->_error = "unknown status code '$status'"; - return false; - } - - // check version - if ( $ver<$client_ver ) - { - $this->_warning = sprintf ( "searchd command v.%d.%d older than client's v.%d.%d, some options might not work", - $ver>>8, $ver&0xff, $client_ver>>8, $client_ver&0xff ); - } - - return $response; - } - - ///////////////////////////////////////////////////////////////////////////// - // searching - ///////////////////////////////////////////////////////////////////////////// - - /// set offset and count into result set, - /// and optionally set max-matches and cutoff limits - function SetLimits ( $offset, $limit, $max=0, $cutoff=0 ) - { - assert ( is_int($offset) ); - assert ( is_int($limit) ); - assert ( $offset>=0 ); - assert ( $limit>0 ); - assert ( $max>=0 ); - $this->_offset = $offset; - $this->_limit = $limit; - if ( $max>0 ) - $this->_maxmatches = $max; - if ( $cutoff>0 ) - $this->_cutoff = $cutoff; - } - - /// set maximum query time, in milliseconds, per-index - /// integer, 0 means "do not limit" - function SetMaxQueryTime ( $max ) - { - assert ( is_int($max) ); - assert ( $max>=0 ); - $this->_maxquerytime = $max; - } - - /// set matching mode - function SetMatchMode ( $mode ) - { - assert ( $mode==SPH_MATCH_ALL - || $mode==SPH_MATCH_ANY - || $mode==SPH_MATCH_PHRASE - || $mode==SPH_MATCH_BOOLEAN - || $mode==SPH_MATCH_EXTENDED - || $mode==SPH_MATCH_FULLSCAN - || $mode==SPH_MATCH_EXTENDED2 ); - $this->_mode = $mode; - } - - /// set ranking mode - function SetRankingMode ( $ranker, $rankexpr="" ) - { - assert ( $ranker>=0 && $ranker_ranker = $ranker; - $this->_rankexpr = $rankexpr; - } - - /// set matches sorting mode - function SetSortMode ( $mode, $sortby="" ) - { - assert ( - $mode==SPH_SORT_RELEVANCE || - $mode==SPH_SORT_ATTR_DESC || - $mode==SPH_SORT_ATTR_ASC || - $mode==SPH_SORT_TIME_SEGMENTS || - $mode==SPH_SORT_EXTENDED || - $mode==SPH_SORT_EXPR ); - assert ( is_string($sortby) ); - assert ( $mode==SPH_SORT_RELEVANCE || strlen($sortby)>0 ); - - $this->_sort = $mode; - $this->_sortby = $sortby; - } - - /// bind per-field weights by order - /// DEPRECATED; use SetFieldWeights() instead - function SetWeights ( $weights ) - { - assert ( is_array($weights) ); - foreach ( $weights as $weight ) - assert ( is_int($weight) ); - - $this->_weights = $weights; - } - - /// bind per-field weights by name - function SetFieldWeights ( $weights ) - { - assert ( is_array($weights) ); - foreach ( $weights as $name=>$weight ) - { - assert ( is_string($name) ); - assert ( is_int($weight) ); - } - $this->_fieldweights = $weights; - } - - /// bind per-index weights by name - function SetIndexWeights ( $weights ) - { - assert ( is_array($weights) ); - foreach ( $weights as $index=>$weight ) - { - assert ( is_string($index) ); - assert ( is_int($weight) ); - } - $this->_indexweights = $weights; - } - - /// set IDs range to match - /// only match records if document ID is beetwen $min and $max (inclusive) - function SetIDRange ( $min, $max ) - { - assert ( is_numeric($min) ); - assert ( is_numeric($max) ); - assert ( $min<=$max ); - $this->_min_id = $min; - $this->_max_id = $max; - } - - /// set values set filter - /// only match records where $attribute value is in given set - function SetFilter ( $attribute, $values, $exclude=false ) - { - assert ( is_string($attribute) ); - assert ( is_array($values) ); - assert ( count($values) ); - - if ( is_array($values) && count($values) ) - { - foreach ( $values as $value ) - assert ( is_numeric($value) ); - - $this->_filters[] = array ( "type"=>SPH_FILTER_VALUES, "attr"=>$attribute, "exclude"=>$exclude, "values"=>$values ); - } - } - - /// set range filter - /// only match records if $attribute value is beetwen $min and $max (inclusive) - function SetFilterRange ( $attribute, $min, $max, $exclude=false ) - { - assert ( is_string($attribute) ); - assert ( is_numeric($min) ); - assert ( is_numeric($max) ); - assert ( $min<=$max ); - - $this->_filters[] = array ( "type"=>SPH_FILTER_RANGE, "attr"=>$attribute, "exclude"=>$exclude, "min"=>$min, "max"=>$max ); - } - - /// set float range filter - /// only match records if $attribute value is beetwen $min and $max (inclusive) - function SetFilterFloatRange ( $attribute, $min, $max, $exclude=false ) - { - assert ( is_string($attribute) ); - assert ( is_float($min) ); - assert ( is_float($max) ); - assert ( $min<=$max ); - - $this->_filters[] = array ( "type"=>SPH_FILTER_FLOATRANGE, "attr"=>$attribute, "exclude"=>$exclude, "min"=>$min, "max"=>$max ); - } - - /// setup anchor point for geosphere distance calculations - /// required to use @geodist in filters and sorting - /// latitude and longitude must be in radians - function SetGeoAnchor ( $attrlat, $attrlong, $lat, $long ) - { - assert ( is_string($attrlat) ); - assert ( is_string($attrlong) ); - assert ( is_float($lat) ); - assert ( is_float($long) ); - - $this->_anchor = array ( "attrlat"=>$attrlat, "attrlong"=>$attrlong, "lat"=>$lat, "long"=>$long ); - } - - /// set grouping attribute and function - function SetGroupBy ( $attribute, $func, $groupsort="@group desc" ) - { - assert ( is_string($attribute) ); - assert ( is_string($groupsort) ); - assert ( $func==SPH_GROUPBY_DAY - || $func==SPH_GROUPBY_WEEK - || $func==SPH_GROUPBY_MONTH - || $func==SPH_GROUPBY_YEAR - || $func==SPH_GROUPBY_ATTR - || $func==SPH_GROUPBY_ATTRPAIR ); - - $this->_groupby = $attribute; - $this->_groupfunc = $func; - $this->_groupsort = $groupsort; - } - - /// set count-distinct attribute for group-by queries - function SetGroupDistinct ( $attribute ) - { - assert ( is_string($attribute) ); - $this->_groupdistinct = $attribute; - } - - /// set distributed retries count and delay - function SetRetries ( $count, $delay=0 ) - { - assert ( is_int($count) && $count>=0 ); - assert ( is_int($delay) && $delay>=0 ); - $this->_retrycount = $count; - $this->_retrydelay = $delay; - } - - /// set result set format (hash or array; hash by default) - /// PHP specific; needed for group-by-MVA result sets that may contain duplicate IDs - function SetArrayResult ( $arrayresult ) - { - assert ( is_bool($arrayresult) ); - $this->_arrayresult = $arrayresult; - } - - /// set attribute values override - /// there can be only one override per attribute - /// $values must be a hash that maps document IDs to attribute values - function SetOverride ( $attrname, $attrtype, $values ) - { - assert ( is_string ( $attrname ) ); - assert ( in_array ( $attrtype, array ( SPH_ATTR_INTEGER, SPH_ATTR_TIMESTAMP, SPH_ATTR_BOOL, SPH_ATTR_FLOAT, SPH_ATTR_BIGINT ) ) ); - assert ( is_array ( $values ) ); - - $this->_overrides[$attrname] = array ( "attr"=>$attrname, "type"=>$attrtype, "values"=>$values ); - } - - /// set select-list (attributes or expressions), SQL-like syntax - function SetSelect ( $select ) - { - assert ( is_string ( $select ) ); - $this->_select = $select; - } - - ////////////////////////////////////////////////////////////////////////////// - - /// clear all filters (for multi-queries) - function ResetFilters () - { - $this->_filters = array(); - $this->_anchor = array(); - } - - /// clear groupby settings (for multi-queries) - function ResetGroupBy () - { - $this->_groupby = ""; - $this->_groupfunc = SPH_GROUPBY_DAY; - $this->_groupsort = "@group desc"; - $this->_groupdistinct= ""; - } - - /// clear all attribute value overrides (for multi-queries) - function ResetOverrides () - { - $this->_overrides = array (); - } - - ////////////////////////////////////////////////////////////////////////////// - - /// connect to searchd server, run given search query through given indexes, - /// and return the search results - function Query ( $query, $index="*", $comment="" ) - { - assert ( empty($this->_reqs) ); - - $this->AddQuery ( $query, $index, $comment ); - $results = $this->RunQueries (); - $this->_reqs = array (); // just in case it failed too early - - if ( !is_array($results) ) - return false; // probably network error; error message should be already filled - - $this->_error = $results[0]["error"]; - $this->_warning = $results[0]["warning"]; - if ( $results[0]["status"]==SEARCHD_ERROR ) - return false; - else - return $results[0]; - } - - /// helper to pack floats in network byte order - function _PackFloat ( $f ) - { - $t1 = pack ( "f", $f ); // machine order - list(,$t2) = unpack ( "L*", $t1 ); // int in machine order - return pack ( "N", $t2 ); - } - - /// add query to multi-query batch - /// returns index into results array from RunQueries() call - function AddQuery ( $query, $index="*", $comment="" ) - { - // mbstring workaround - $this->_MBPush (); - - // build request - $req = pack ( "NNNN", $this->_offset, $this->_limit, $this->_mode, $this->_ranker ); - if ( $this->_ranker==SPH_RANK_EXPR ) - $req .= pack ( "N", strlen($this->_rankexpr) ) . $this->_rankexpr; - $req .= pack ( "N", $this->_sort ); // (deprecated) sort mode - $req .= pack ( "N", strlen($this->_sortby) ) . $this->_sortby; - $req .= pack ( "N", strlen($query) ) . $query; // query itself - $req .= pack ( "N", count($this->_weights) ); // weights - foreach ( $this->_weights as $weight ) - $req .= pack ( "N", (int)$weight ); - $req .= pack ( "N", strlen($index) ) . $index; // indexes - $req .= pack ( "N", 1 ); // id64 range marker - $req .= sphPackU64 ( $this->_min_id ) . sphPackU64 ( $this->_max_id ); // id64 range - - // filters - $req .= pack ( "N", count($this->_filters) ); - foreach ( $this->_filters as $filter ) - { - $req .= pack ( "N", strlen($filter["attr"]) ) . $filter["attr"]; - $req .= pack ( "N", $filter["type"] ); - switch ( $filter["type"] ) - { - case SPH_FILTER_VALUES: - $req .= pack ( "N", count($filter["values"]) ); - foreach ( $filter["values"] as $value ) - $req .= sphPackI64 ( $value ); - break; - - case SPH_FILTER_RANGE: - $req .= sphPackI64 ( $filter["min"] ) . sphPackI64 ( $filter["max"] ); - break; - - case SPH_FILTER_FLOATRANGE: - $req .= $this->_PackFloat ( $filter["min"] ) . $this->_PackFloat ( $filter["max"] ); - break; - - default: - assert ( 0 && "internal error: unhandled filter type" ); - } - $req .= pack ( "N", $filter["exclude"] ); - } - - // group-by clause, max-matches count, group-sort clause, cutoff count - $req .= pack ( "NN", $this->_groupfunc, strlen($this->_groupby) ) . $this->_groupby; - $req .= pack ( "N", $this->_maxmatches ); - $req .= pack ( "N", strlen($this->_groupsort) ) . $this->_groupsort; - $req .= pack ( "NNN", $this->_cutoff, $this->_retrycount, $this->_retrydelay ); - $req .= pack ( "N", strlen($this->_groupdistinct) ) . $this->_groupdistinct; - - // anchor point - if ( empty($this->_anchor) ) - { - $req .= pack ( "N", 0 ); - } else - { - $a =& $this->_anchor; - $req .= pack ( "N", 1 ); - $req .= pack ( "N", strlen($a["attrlat"]) ) . $a["attrlat"]; - $req .= pack ( "N", strlen($a["attrlong"]) ) . $a["attrlong"]; - $req .= $this->_PackFloat ( $a["lat"] ) . $this->_PackFloat ( $a["long"] ); - } - - // per-index weights - $req .= pack ( "N", count($this->_indexweights) ); - foreach ( $this->_indexweights as $idx=>$weight ) - $req .= pack ( "N", strlen($idx) ) . $idx . pack ( "N", $weight ); - - // max query time - $req .= pack ( "N", $this->_maxquerytime ); - - // per-field weights - $req .= pack ( "N", count($this->_fieldweights) ); - foreach ( $this->_fieldweights as $field=>$weight ) - $req .= pack ( "N", strlen($field) ) . $field . pack ( "N", $weight ); - - // comment - $req .= pack ( "N", strlen($comment) ) . $comment; - - // attribute overrides - $req .= pack ( "N", count($this->_overrides) ); - foreach ( $this->_overrides as $key => $entry ) - { - $req .= pack ( "N", strlen($entry["attr"]) ) . $entry["attr"]; - $req .= pack ( "NN", $entry["type"], count($entry["values"]) ); - foreach ( $entry["values"] as $id=>$val ) - { - assert ( is_numeric($id) ); - assert ( is_numeric($val) ); - - $req .= sphPackU64 ( $id ); - switch ( $entry["type"] ) - { - case SPH_ATTR_FLOAT: $req .= $this->_PackFloat ( $val ); break; - case SPH_ATTR_BIGINT: $req .= sphPackI64 ( $val ); break; - default: $req .= pack ( "N", $val ); break; - } - } - } - - // select-list - $req .= pack ( "N", strlen($this->_select) ) . $this->_select; - - // mbstring workaround - $this->_MBPop (); - - // store request to requests array - $this->_reqs[] = $req; - return count($this->_reqs)-1; - } - - /// connect to searchd, run queries batch, and return an array of result sets - function RunQueries () - { - if ( empty($this->_reqs) ) - { - $this->_error = "no queries defined, issue AddQuery() first"; - return false; - } - - // mbstring workaround - $this->_MBPush (); - - if (!( $fp = $this->_Connect() )) - { - $this->_MBPop (); - return false; - } - - // send query, get response - $nreqs = count($this->_reqs); - $req = join ( "", $this->_reqs ); - $len = 8+strlen($req); - $req = pack ( "nnNNN", SEARCHD_COMMAND_SEARCH, VER_COMMAND_SEARCH, $len, 0, $nreqs ) . $req; // add header - - if ( !( $this->_Send ( $fp, $req, $len+8 ) ) || - !( $response = $this->_GetResponse ( $fp, VER_COMMAND_SEARCH ) ) ) - { - $this->_MBPop (); - return false; - } - - // query sent ok; we can reset reqs now - $this->_reqs = array (); - - // parse and return response - return $this->_ParseSearchResponse ( $response, $nreqs ); - } - - /// parse and return search query (or queries) response - function _ParseSearchResponse ( $response, $nreqs ) - { - $p = 0; // current position - $max = strlen($response); // max position for checks, to protect against broken responses - - $results = array (); - for ( $ires=0; $ires<$nreqs && $p<$max; $ires++ ) - { - $results[] = array(); - $result =& $results[$ires]; - - $result["error"] = ""; - $result["warning"] = ""; - - // extract status - list(,$status) = unpack ( "N*", substr ( $response, $p, 4 ) ); $p += 4; - $result["status"] = $status; - if ( $status!=SEARCHD_OK ) - { - list(,$len) = unpack ( "N*", substr ( $response, $p, 4 ) ); $p += 4; - $message = substr ( $response, $p, $len ); $p += $len; - - if ( $status==SEARCHD_WARNING ) - { - $result["warning"] = $message; - } else - { - $result["error"] = $message; - continue; - } - } - - // read schema - $fields = array (); - $attrs = array (); - - list(,$nfields) = unpack ( "N*", substr ( $response, $p, 4 ) ); $p += 4; - while ( $nfields-->0 && $p<$max ) - { - list(,$len) = unpack ( "N*", substr ( $response, $p, 4 ) ); $p += 4; - $fields[] = substr ( $response, $p, $len ); $p += $len; - } - $result["fields"] = $fields; - - list(,$nattrs) = unpack ( "N*", substr ( $response, $p, 4 ) ); $p += 4; - while ( $nattrs-->0 && $p<$max ) - { - list(,$len) = unpack ( "N*", substr ( $response, $p, 4 ) ); $p += 4; - $attr = substr ( $response, $p, $len ); $p += $len; - list(,$type) = unpack ( "N*", substr ( $response, $p, 4 ) ); $p += 4; - $attrs[$attr] = $type; - } - $result["attrs"] = $attrs; - - // read match count - list(,$count) = unpack ( "N*", substr ( $response, $p, 4 ) ); $p += 4; - list(,$id64) = unpack ( "N*", substr ( $response, $p, 4 ) ); $p += 4; - - // read matches - $idx = -1; - while ( $count-->0 && $p<$max ) - { - // index into result array - $idx++; - - // parse document id and weight - if ( $id64 ) - { - $doc = sphUnpackU64 ( substr ( $response, $p, 8 ) ); $p += 8; - list(,$weight) = unpack ( "N*", substr ( $response, $p, 4 ) ); $p += 4; - } - else - { - list ( $doc, $weight ) = array_values ( unpack ( "N*N*", - substr ( $response, $p, 8 ) ) ); - $p += 8; - $doc = sphFixUint($doc); - } - $weight = sprintf ( "%u", $weight ); - - // create match entry - if ( $this->_arrayresult ) - $result["matches"][$idx] = array ( "id"=>$doc, "weight"=>$weight ); - else - $result["matches"][$doc]["weight"] = $weight; - - // parse and create attributes - $attrvals = array (); - foreach ( $attrs as $attr=>$type ) - { - // handle 64bit ints - if ( $type==SPH_ATTR_BIGINT ) - { - $attrvals[$attr] = sphUnpackI64 ( substr ( $response, $p, 8 ) ); $p += 8; - continue; - } - - // handle floats - if ( $type==SPH_ATTR_FLOAT ) - { - list(,$uval) = unpack ( "N*", substr ( $response, $p, 4 ) ); $p += 4; - list(,$fval) = unpack ( "f*", pack ( "L", $uval ) ); - $attrvals[$attr] = $fval; - continue; - } - - // handle everything else as unsigned ints - list(,$val) = unpack ( "N*", substr ( $response, $p, 4 ) ); $p += 4; - if ( $type==SPH_ATTR_MULTI ) - { - $attrvals[$attr] = array (); - $nvalues = $val; - while ( $nvalues-->0 && $p<$max ) - { - list(,$val) = unpack ( "N*", substr ( $response, $p, 4 ) ); $p += 4; - $attrvals[$attr][] = sphFixUint($val); - } - } else if ( $type==SPH_ATTR_MULTI64 ) - { - $attrvals[$attr] = array (); - $nvalues = $val; - while ( $nvalues>0 && $p<$max ) - { - $attrvals[$attr][] = sphUnpackU64 ( substr ( $response, $p, 8 ) ); $p += 8; - $nvalues -= 2; - } - } else if ( $type==SPH_ATTR_STRING ) - { - $attrvals[$attr] = substr ( $response, $p, $val ); - $p += $val; - } else - { - $attrvals[$attr] = sphFixUint($val); - } - } - - if ( $this->_arrayresult ) - $result["matches"][$idx]["attrs"] = $attrvals; - else - $result["matches"][$doc]["attrs"] = $attrvals; - } - - list ( $total, $total_found, $msecs, $words ) = - array_values ( unpack ( "N*N*N*N*", substr ( $response, $p, 16 ) ) ); - $result["total"] = sprintf ( "%u", $total ); - $result["total_found"] = sprintf ( "%u", $total_found ); - $result["time"] = sprintf ( "%.3f", $msecs/1000 ); - $p += 16; - - while ( $words-->0 && $p<$max ) - { - list(,$len) = unpack ( "N*", substr ( $response, $p, 4 ) ); $p += 4; - $word = substr ( $response, $p, $len ); $p += $len; - list ( $docs, $hits ) = array_values ( unpack ( "N*N*", substr ( $response, $p, 8 ) ) ); $p += 8; - $result["words"][$word] = array ( - "docs"=>sprintf ( "%u", $docs ), - "hits"=>sprintf ( "%u", $hits ) ); - } - } - - $this->_MBPop (); - return $results; - } - - ///////////////////////////////////////////////////////////////////////////// - // excerpts generation - ///////////////////////////////////////////////////////////////////////////// - - /// connect to searchd server, and generate exceprts (snippets) - /// of given documents for given query. returns false on failure, - /// an array of snippets on success - function BuildExcerpts ( $docs, $index, $words, $opts=array() ) - { - assert ( is_array($docs) ); - assert ( is_string($index) ); - assert ( is_string($words) ); - assert ( is_array($opts) ); - - $this->_MBPush (); - - if (!( $fp = $this->_Connect() )) - { - $this->_MBPop(); - return false; - } - - ///////////////// - // fixup options - ///////////////// - - if ( !isset($opts["before_match"]) ) $opts["before_match"] = ""; - if ( !isset($opts["after_match"]) ) $opts["after_match"] = ""; - if ( !isset($opts["chunk_separator"]) ) $opts["chunk_separator"] = " ... "; - if ( !isset($opts["limit"]) ) $opts["limit"] = 256; - if ( !isset($opts["limit_passages"]) ) $opts["limit_passages"] = 0; - if ( !isset($opts["limit_words"]) ) $opts["limit_words"] = 0; - if ( !isset($opts["around"]) ) $opts["around"] = 5; - if ( !isset($opts["exact_phrase"]) ) $opts["exact_phrase"] = false; - if ( !isset($opts["single_passage"]) ) $opts["single_passage"] = false; - if ( !isset($opts["use_boundaries"]) ) $opts["use_boundaries"] = false; - if ( !isset($opts["weight_order"]) ) $opts["weight_order"] = false; - if ( !isset($opts["query_mode"]) ) $opts["query_mode"] = false; - if ( !isset($opts["force_all_words"]) ) $opts["force_all_words"] = false; - if ( !isset($opts["start_passage_id"]) ) $opts["start_passage_id"] = 1; - if ( !isset($opts["load_files"]) ) $opts["load_files"] = false; - if ( !isset($opts["html_strip_mode"]) ) $opts["html_strip_mode"] = "index"; - if ( !isset($opts["allow_empty"]) ) $opts["allow_empty"] = false; - if ( !isset($opts["passage_boundary"]) ) $opts["passage_boundary"] = "none"; - if ( !isset($opts["emit_zones"]) ) $opts["emit_zones"] = false; - if ( !isset($opts["load_files_scattered"]) ) $opts["load_files_scattered"] = false; - - - ///////////////// - // build request - ///////////////// - - // v.1.2 req - $flags = 1; // remove spaces - if ( $opts["exact_phrase"] ) $flags |= 2; - if ( $opts["single_passage"] ) $flags |= 4; - if ( $opts["use_boundaries"] ) $flags |= 8; - if ( $opts["weight_order"] ) $flags |= 16; - if ( $opts["query_mode"] ) $flags |= 32; - if ( $opts["force_all_words"] ) $flags |= 64; - if ( $opts["load_files"] ) $flags |= 128; - if ( $opts["allow_empty"] ) $flags |= 256; - if ( $opts["emit_zones"] ) $flags |= 512; - if ( $opts["load_files_scattered"] ) $flags |= 1024; - $req = pack ( "NN", 0, $flags ); // mode=0, flags=$flags - $req .= pack ( "N", strlen($index) ) . $index; // req index - $req .= pack ( "N", strlen($words) ) . $words; // req words - - // options - $req .= pack ( "N", strlen($opts["before_match"]) ) . $opts["before_match"]; - $req .= pack ( "N", strlen($opts["after_match"]) ) . $opts["after_match"]; - $req .= pack ( "N", strlen($opts["chunk_separator"]) ) . $opts["chunk_separator"]; - $req .= pack ( "NN", (int)$opts["limit"], (int)$opts["around"] ); - $req .= pack ( "NNN", (int)$opts["limit_passages"], (int)$opts["limit_words"], (int)$opts["start_passage_id"] ); // v.1.2 - $req .= pack ( "N", strlen($opts["html_strip_mode"]) ) . $opts["html_strip_mode"]; - $req .= pack ( "N", strlen($opts["passage_boundary"]) ) . $opts["passage_boundary"]; - - // documents - $req .= pack ( "N", count($docs) ); - foreach ( $docs as $doc ) - { - assert ( is_string($doc) ); - $req .= pack ( "N", strlen($doc) ) . $doc; - } - - //////////////////////////// - // send query, get response - //////////////////////////// - - $len = strlen($req); - $req = pack ( "nnN", SEARCHD_COMMAND_EXCERPT, VER_COMMAND_EXCERPT, $len ) . $req; // add header - if ( !( $this->_Send ( $fp, $req, $len+8 ) ) || - !( $response = $this->_GetResponse ( $fp, VER_COMMAND_EXCERPT ) ) ) - { - $this->_MBPop (); - return false; - } - - ////////////////// - // parse response - ////////////////// - - $pos = 0; - $res = array (); - $rlen = strlen($response); - for ( $i=0; $i $rlen ) - { - $this->_error = "incomplete reply"; - $this->_MBPop (); - return false; - } - $res[] = $len ? substr ( $response, $pos, $len ) : ""; - $pos += $len; - } - - $this->_MBPop (); - return $res; - } - - - ///////////////////////////////////////////////////////////////////////////// - // keyword generation - ///////////////////////////////////////////////////////////////////////////// - - /// connect to searchd server, and generate keyword list for a given query - /// returns false on failure, - /// an array of words on success - function BuildKeywords ( $query, $index, $hits ) - { - assert ( is_string($query) ); - assert ( is_string($index) ); - assert ( is_bool($hits) ); - - $this->_MBPush (); - - if (!( $fp = $this->_Connect() )) - { - $this->_MBPop(); - return false; - } - - ///////////////// - // build request - ///////////////// - - // v.1.0 req - $req = pack ( "N", strlen($query) ) . $query; // req query - $req .= pack ( "N", strlen($index) ) . $index; // req index - $req .= pack ( "N", (int)$hits ); - - //////////////////////////// - // send query, get response - //////////////////////////// - - $len = strlen($req); - $req = pack ( "nnN", SEARCHD_COMMAND_KEYWORDS, VER_COMMAND_KEYWORDS, $len ) . $req; // add header - if ( !( $this->_Send ( $fp, $req, $len+8 ) ) || - !( $response = $this->_GetResponse ( $fp, VER_COMMAND_KEYWORDS ) ) ) - { - $this->_MBPop (); - return false; - } - - ////////////////// - // parse response - ////////////////// - - $pos = 0; - $res = array (); - $rlen = strlen($response); - list(,$nwords) = unpack ( "N*", substr ( $response, $pos, 4 ) ); - $pos += 4; - for ( $i=0; $i<$nwords; $i++ ) - { - list(,$len) = unpack ( "N*", substr ( $response, $pos, 4 ) ); $pos += 4; - $tokenized = $len ? substr ( $response, $pos, $len ) : ""; - $pos += $len; - - list(,$len) = unpack ( "N*", substr ( $response, $pos, 4 ) ); $pos += 4; - $normalized = $len ? substr ( $response, $pos, $len ) : ""; - $pos += $len; - - $res[] = array ( "tokenized"=>$tokenized, "normalized"=>$normalized ); - - if ( $hits ) - { - list($ndocs,$nhits) = array_values ( unpack ( "N*N*", substr ( $response, $pos, 8 ) ) ); - $pos += 8; - $res [$i]["docs"] = $ndocs; - $res [$i]["hits"] = $nhits; - } - - if ( $pos > $rlen ) - { - $this->_error = "incomplete reply"; - $this->_MBPop (); - return false; - } - } - - $this->_MBPop (); - return $res; - } - - function EscapeString ( $string ) - { - $from = array ( '\\', '(',')','|','-','!','@','~','"','&', '/', '^', '$', '=' ); - $to = array ( '\\\\', '\(','\)','\|','\-','\!','\@','\~','\"', '\&', '\/', '\^', '\$', '\=' ); - - return str_replace ( $from, $to, $string ); - } - - ///////////////////////////////////////////////////////////////////////////// - // attribute updates - ///////////////////////////////////////////////////////////////////////////// - - /// batch update given attributes in given rows in given indexes - /// returns amount of updated documents (0 or more) on success, or -1 on failure - function UpdateAttributes ( $index, $attrs, $values, $mva=false ) - { - // verify everything - assert ( is_string($index) ); - assert ( is_bool($mva) ); - - assert ( is_array($attrs) ); - foreach ( $attrs as $attr ) - assert ( is_string($attr) ); - - assert ( is_array($values) ); - foreach ( $values as $id=>$entry ) - { - assert ( is_numeric($id) ); - assert ( is_array($entry) ); - assert ( count($entry)==count($attrs) ); - foreach ( $entry as $v ) - { - if ( $mva ) - { - assert ( is_array($v) ); - foreach ( $v as $vv ) - assert ( is_int($vv) ); - } else - assert ( is_int($v) ); - } - } - - // build request - $this->_MBPush (); - $req = pack ( "N", strlen($index) ) . $index; - - $req .= pack ( "N", count($attrs) ); - foreach ( $attrs as $attr ) - { - $req .= pack ( "N", strlen($attr) ) . $attr; - $req .= pack ( "N", $mva ? 1 : 0 ); - } - - $req .= pack ( "N", count($values) ); - foreach ( $values as $id=>$entry ) - { - $req .= sphPackU64 ( $id ); - foreach ( $entry as $v ) - { - $req .= pack ( "N", $mva ? count($v) : $v ); - if ( $mva ) - foreach ( $v as $vv ) - $req .= pack ( "N", $vv ); - } - } - - // connect, send query, get response - if (!( $fp = $this->_Connect() )) - { - $this->_MBPop (); - return -1; - } - - $len = strlen($req); - $req = pack ( "nnN", SEARCHD_COMMAND_UPDATE, VER_COMMAND_UPDATE, $len ) . $req; // add header - if ( !$this->_Send ( $fp, $req, $len+8 ) ) - { - $this->_MBPop (); - return -1; - } - - if (!( $response = $this->_GetResponse ( $fp, VER_COMMAND_UPDATE ) )) - { - $this->_MBPop (); - return -1; - } - - // parse response - list(,$updated) = unpack ( "N*", substr ( $response, 0, 4 ) ); - $this->_MBPop (); - return $updated; - } - - ///////////////////////////////////////////////////////////////////////////// - // persistent connections - ///////////////////////////////////////////////////////////////////////////// - - function Open() - { - if ( $this->_socket !== false ) - { - $this->_error = 'already connected'; - return false; - } - if ( !$fp = $this->_Connect() ) - return false; - - // command, command version = 0, body length = 4, body = 1 - $req = pack ( "nnNN", SEARCHD_COMMAND_PERSIST, 0, 4, 1 ); - if ( !$this->_Send ( $fp, $req, 12 ) ) - return false; - - $this->_socket = $fp; - return true; - } - - function Close() - { - if ( $this->_socket === false ) - { - $this->_error = 'not connected'; - return false; - } - - fclose ( $this->_socket ); - $this->_socket = false; - - return true; - } - - ////////////////////////////////////////////////////////////////////////// - // status - ////////////////////////////////////////////////////////////////////////// - - function Status () - { - $this->_MBPush (); - if (!( $fp = $this->_Connect() )) - { - $this->_MBPop(); - return false; - } - - $req = pack ( "nnNN", SEARCHD_COMMAND_STATUS, VER_COMMAND_STATUS, 4, 1 ); // len=4, body=1 - if ( !( $this->_Send ( $fp, $req, 12 ) ) || - !( $response = $this->_GetResponse ( $fp, VER_COMMAND_STATUS ) ) ) - { - $this->_MBPop (); - return false; - } - - $res = substr ( $response, 4 ); // just ignore length, error handling, etc - $p = 0; - list ( $rows, $cols ) = array_values ( unpack ( "N*N*", substr ( $response, $p, 8 ) ) ); $p += 8; - - $res = array(); - for ( $i=0; $i<$rows; $i++ ) - for ( $j=0; $j<$cols; $j++ ) - { - list(,$len) = unpack ( "N*", substr ( $response, $p, 4 ) ); $p += 4; - $res[$i][] = substr ( $response, $p, $len ); $p += $len; - } - - $this->_MBPop (); - return $res; - } - - ////////////////////////////////////////////////////////////////////////// - // flush - ////////////////////////////////////////////////////////////////////////// - - function FlushAttributes () - { - $this->_MBPush (); - if (!( $fp = $this->_Connect() )) - { - $this->_MBPop(); - return -1; - } - - $req = pack ( "nnN", SEARCHD_COMMAND_FLUSHATTRS, VER_COMMAND_FLUSHATTRS, 0 ); // len=0 - if ( !( $this->_Send ( $fp, $req, 8 ) ) || - !( $response = $this->_GetResponse ( $fp, VER_COMMAND_FLUSHATTRS ) ) ) - { - $this->_MBPop (); - return -1; - } - - $tag = -1; - if ( strlen($response)==4 ) - list(,$tag) = unpack ( "N*", $response ); - else - $this->_error = "unexpected response length"; - - $this->_MBPop (); - return $tag; - } -} - -// -// $Id: sphinxapi.php 3087 2012-01-30 23:07:35Z shodan $ -// +=8 ) + { + $v = (int)$v; + return pack ( "NN", $v>>32, $v&0xFFFFFFFF ); + } + + // x32, int + if ( is_int($v) ) + return pack ( "NN", $v < 0 ? -1 : 0, $v ); + + // x32, bcmath + if ( function_exists("bcmul") ) + { + if ( bccomp ( $v, 0 ) == -1 ) + $v = bcadd ( "18446744073709551616", $v ); + $h = bcdiv ( $v, "4294967296", 0 ); + $l = bcmod ( $v, "4294967296" ); + return pack ( "NN", (float)$h, (float)$l ); // conversion to float is intentional; int would lose 31st bit + } + + // x32, no-bcmath + $p = max(0, strlen($v) - 13); + $lo = abs((float)substr($v, $p)); + $hi = abs((float)substr($v, 0, $p)); + + $m = $lo + $hi*1316134912.0; // (10 ^ 13) % (1 << 32) = 1316134912 + $q = floor($m/4294967296.0); + $l = $m - ($q*4294967296.0); + $h = $hi*2328.0 + $q; // (10 ^ 13) / (1 << 32) = 2328 + + if ( $v<0 ) + { + if ( $l==0 ) + $h = 4294967296.0 - $h; + else + { + $h = 4294967295.0 - $h; + $l = 4294967296.0 - $l; + } + } + return pack ( "NN", $h, $l ); +} + +/// pack 64-bit unsigned +function sphPackU64 ( $v ) +{ + assert ( is_numeric($v) ); + + // x64 + if ( PHP_INT_SIZE>=8 ) + { + assert ( $v>=0 ); + + // x64, int + if ( is_int($v) ) + return pack ( "NN", $v>>32, $v&0xFFFFFFFF ); + + // x64, bcmath + if ( function_exists("bcmul") ) + { + $h = bcdiv ( $v, 4294967296, 0 ); + $l = bcmod ( $v, 4294967296 ); + return pack ( "NN", $h, $l ); + } + + // x64, no-bcmath + $p = max ( 0, strlen($v) - 13 ); + $lo = (int)substr ( $v, $p ); + $hi = (int)substr ( $v, 0, $p ); + + $m = $lo + $hi*1316134912; + $l = $m % 4294967296; + $h = $hi*2328 + (int)($m/4294967296); + + return pack ( "NN", $h, $l ); + } + + // x32, int + if ( is_int($v) ) + return pack ( "NN", 0, $v ); + + // x32, bcmath + if ( function_exists("bcmul") ) + { + $h = bcdiv ( $v, "4294967296", 0 ); + $l = bcmod ( $v, "4294967296" ); + return pack ( "NN", (float)$h, (float)$l ); // conversion to float is intentional; int would lose 31st bit + } + + // x32, no-bcmath + $p = max(0, strlen($v) - 13); + $lo = (float)substr($v, $p); + $hi = (float)substr($v, 0, $p); + + $m = $lo + $hi*1316134912.0; + $q = floor($m / 4294967296.0); + $l = $m - ($q * 4294967296.0); + $h = $hi*2328.0 + $q; + + return pack ( "NN", $h, $l ); +} + +// unpack 64-bit unsigned +function sphUnpackU64 ( $v ) +{ + list ( $hi, $lo ) = array_values ( unpack ( "N*N*", $v ) ); + + if ( PHP_INT_SIZE>=8 ) + { + if ( $hi<0 ) $hi += (1<<32); // because php 5.2.2 to 5.2.5 is totally fucked up again + if ( $lo<0 ) $lo += (1<<32); + + // x64, int + if ( $hi<=2147483647 ) + return ($hi<<32) + $lo; + + // x64, bcmath + if ( function_exists("bcmul") ) + return bcadd ( $lo, bcmul ( $hi, "4294967296" ) ); + + // x64, no-bcmath + $C = 100000; + $h = ((int)($hi / $C) << 32) + (int)($lo / $C); + $l = (($hi % $C) << 32) + ($lo % $C); + if ( $l>$C ) + { + $h += (int)($l / $C); + $l = $l % $C; + } + + if ( $h==0 ) + return $l; + return sprintf ( "%d%05d", $h, $l ); + } + + // x32, int + if ( $hi==0 ) + { + if ( $lo>0 ) + return $lo; + return sprintf ( "%u", $lo ); + } + + $hi = sprintf ( "%u", $hi ); + $lo = sprintf ( "%u", $lo ); + + // x32, bcmath + if ( function_exists("bcmul") ) + return bcadd ( $lo, bcmul ( $hi, "4294967296" ) ); + + // x32, no-bcmath + $hi = (float)$hi; + $lo = (float)$lo; + + $q = floor($hi/10000000.0); + $r = $hi - $q*10000000.0; + $m = $lo + $r*4967296.0; + $mq = floor($m/10000000.0); + $l = $m - $mq*10000000.0; + $h = $q*4294967296.0 + $r*429.0 + $mq; + + $h = sprintf ( "%.0f", $h ); + $l = sprintf ( "%07.0f", $l ); + if ( $h=="0" ) + return sprintf( "%.0f", (float)$l ); + return $h . $l; +} + +// unpack 64-bit signed +function sphUnpackI64 ( $v ) +{ + list ( $hi, $lo ) = array_values ( unpack ( "N*N*", $v ) ); + + // x64 + if ( PHP_INT_SIZE>=8 ) + { + if ( $hi<0 ) $hi += (1<<32); // because php 5.2.2 to 5.2.5 is totally fucked up again + if ( $lo<0 ) $lo += (1<<32); + + return ($hi<<32) + $lo; + } + + // x32, int + if ( $hi==0 ) + { + if ( $lo>0 ) + return $lo; + return sprintf ( "%u", $lo ); + } + // x32, int + elseif ( $hi==-1 ) + { + if ( $lo<0 ) + return $lo; + return sprintf ( "%.0f", $lo - 4294967296.0 ); + } + + $neg = ""; + $c = 0; + if ( $hi<0 ) + { + $hi = ~$hi; + $lo = ~$lo; + $c = 1; + $neg = "-"; + } + + $hi = sprintf ( "%u", $hi ); + $lo = sprintf ( "%u", $lo ); + + // x32, bcmath + if ( function_exists("bcmul") ) + return $neg . bcadd ( bcadd ( $lo, bcmul ( $hi, "4294967296" ) ), $c ); + + // x32, no-bcmath + $hi = (float)$hi; + $lo = (float)$lo; + + $q = floor($hi/10000000.0); + $r = $hi - $q*10000000.0; + $m = $lo + $r*4967296.0; + $mq = floor($m/10000000.0); + $l = $m - $mq*10000000.0 + $c; + $h = $q*4294967296.0 + $r*429.0 + $mq; + if ( $l==10000000 ) + { + $l = 0; + $h += 1; + } + + $h = sprintf ( "%.0f", $h ); + $l = sprintf ( "%07.0f", $l ); + if ( $h=="0" ) + return $neg . sprintf( "%.0f", (float)$l ); + return $neg . $h . $l; +} + + +function sphFixUint ( $value ) +{ + if ( PHP_INT_SIZE>=8 ) + { + // x64 route, workaround broken unpack() in 5.2.2+ + if ( $value<0 ) $value += (1<<32); + return $value; + } + else + { + // x32 route, workaround php signed/unsigned braindamage + return sprintf ( "%u", $value ); + } +} + + +/// sphinx searchd client class +class SphinxClient +{ + var $_host; ///< searchd host (default is "localhost") + var $_port; ///< searchd port (default is 9312) + var $_offset; ///< how many records to seek from result-set start (default is 0) + var $_limit; ///< how many records to return from result-set starting at offset (default is 20) + var $_mode; ///< query matching mode (default is SPH_MATCH_ALL) + var $_weights; ///< per-field weights (default is 1 for all fields) + var $_sort; ///< match sorting mode (default is SPH_SORT_RELEVANCE) + var $_sortby; ///< attribute to sort by (defualt is "") + var $_min_id; ///< min ID to match (default is 0, which means no limit) + var $_max_id; ///< max ID to match (default is 0, which means no limit) + var $_filters; ///< search filters + var $_groupby; ///< group-by attribute name + var $_groupfunc; ///< group-by function (to pre-process group-by attribute value with) + var $_groupsort; ///< group-by sorting clause (to sort groups in result set with) + var $_groupdistinct;///< group-by count-distinct attribute + var $_maxmatches; ///< max matches to retrieve + var $_cutoff; ///< cutoff to stop searching at (default is 0) + var $_retrycount; ///< distributed retries count + var $_retrydelay; ///< distributed retries delay + var $_anchor; ///< geographical anchor point + var $_indexweights; ///< per-index weights + var $_ranker; ///< ranking mode (default is SPH_RANK_PROXIMITY_BM25) + var $_rankexpr; ///< ranking mode expression (for SPH_RANK_EXPR) + var $_maxquerytime; ///< max query time, milliseconds (default is 0, do not limit) + var $_fieldweights; ///< per-field-name weights + var $_overrides; ///< per-query attribute values overrides + var $_select; ///< select-list (attributes or expressions, with optional aliases) + + var $_error; ///< last error message + var $_warning; ///< last warning message + var $_connerror; ///< connection error vs remote error flag + + var $_reqs; ///< requests array for multi-query + var $_mbenc; ///< stored mbstring encoding + var $_arrayresult; ///< whether $result["matches"] should be a hash or an array + var $_timeout; ///< connect timeout + + ///////////////////////////////////////////////////////////////////////////// + // common stuff + ///////////////////////////////////////////////////////////////////////////// + + /// create a new client object and fill defaults + function SphinxClient () + { + // per-client-object settings + $this->_host = "localhost"; + $this->_port = 9312; + $this->_path = false; + $this->_socket = false; + + // per-query settings + $this->_offset = 0; + $this->_limit = 20; + $this->_mode = SPH_MATCH_ALL; + $this->_weights = array (); + $this->_sort = SPH_SORT_RELEVANCE; + $this->_sortby = ""; + $this->_min_id = 0; + $this->_max_id = 0; + $this->_filters = array (); + $this->_groupby = ""; + $this->_groupfunc = SPH_GROUPBY_DAY; + $this->_groupsort = "@group desc"; + $this->_groupdistinct= ""; + $this->_maxmatches = 1000; + $this->_cutoff = 0; + $this->_retrycount = 0; + $this->_retrydelay = 0; + $this->_anchor = array (); + $this->_indexweights= array (); + $this->_ranker = SPH_RANK_PROXIMITY_BM25; + $this->_rankexpr = ""; + $this->_maxquerytime= 0; + $this->_fieldweights= array(); + $this->_overrides = array(); + $this->_select = "*"; + + $this->_error = ""; // per-reply fields (for single-query case) + $this->_warning = ""; + $this->_connerror = false; + + $this->_reqs = array (); // requests storage (for multi-query case) + $this->_mbenc = ""; + $this->_arrayresult = false; + $this->_timeout = 0; + } + + function __destruct() + { + if ( $this->_socket !== false ) + fclose ( $this->_socket ); + } + + /// get last error message (string) + function GetLastError () + { + return $this->_error; + } + + /// get last warning message (string) + function GetLastWarning () + { + return $this->_warning; + } + + /// get last error flag (to tell network connection errors from searchd errors or broken responses) + function IsConnectError() + { + return $this->_connerror; + } + + /// set searchd host name (string) and port (integer) + function SetServer ( $host, $port = 0 ) + { + assert ( is_string($host) ); + if ( $host[0] == '/') + { + $this->_path = 'unix://' . $host; + return; + } + if ( substr ( $host, 0, 7 )=="unix://" ) + { + $this->_path = $host; + return; + } + + assert ( is_int($port) ); + $this->_host = $host; + $this->_port = $port; + $this->_path = ''; + + } + + /// set server connection timeout (0 to remove) + function SetConnectTimeout ( $timeout ) + { + assert ( is_numeric($timeout) ); + $this->_timeout = $timeout; + } + + + function _Send ( $handle, $data, $length ) + { + if ( feof($handle) || fwrite ( $handle, $data, $length ) !== $length ) + { + $this->_error = 'connection unexpectedly closed (timed out?)'; + $this->_connerror = true; + return false; + } + return true; + } + + ///////////////////////////////////////////////////////////////////////////// + + /// enter mbstring workaround mode + function _MBPush () + { + $this->_mbenc = ""; + if ( ini_get ( "mbstring.func_overload" ) & 2 ) + { + $this->_mbenc = mb_internal_encoding(); + mb_internal_encoding ( "latin1" ); + } + } + + /// leave mbstring workaround mode + function _MBPop () + { + if ( $this->_mbenc ) + mb_internal_encoding ( $this->_mbenc ); + } + + /// connect to searchd server + function _Connect () + { + if ( $this->_socket!==false ) + { + // we are in persistent connection mode, so we have a socket + // however, need to check whether it's still alive + if ( !@feof ( $this->_socket ) ) + return $this->_socket; + + // force reopen + $this->_socket = false; + } + + $errno = 0; + $errstr = ""; + $this->_connerror = false; + + if ( $this->_path ) + { + $host = $this->_path; + $port = 0; + } + else + { + $host = $this->_host; + $port = $this->_port; + } + + if ( $this->_timeout<=0 ) + $fp = @fsockopen ( $host, $port, $errno, $errstr ); + else + $fp = @fsockopen ( $host, $port, $errno, $errstr, $this->_timeout ); + + if ( !$fp ) + { + if ( $this->_path ) + $location = $this->_path; + else + $location = "{$this->_host}:{$this->_port}"; + + $errstr = trim ( $errstr ); + $this->_error = "connection to $location failed (errno=$errno, msg=$errstr)"; + $this->_connerror = true; + return false; + } + + // send my version + // this is a subtle part. we must do it before (!) reading back from searchd. + // because otherwise under some conditions (reported on FreeBSD for instance) + // TCP stack could throttle write-write-read pattern because of Nagle. + if ( !$this->_Send ( $fp, pack ( "N", 1 ), 4 ) ) + { + fclose ( $fp ); + $this->_error = "failed to send client protocol version"; + return false; + } + + // check version + list(,$v) = unpack ( "N*", fread ( $fp, 4 ) ); + $v = (int)$v; + if ( $v<1 ) + { + fclose ( $fp ); + $this->_error = "expected searchd protocol version 1+, got version '$v'"; + return false; + } + + return $fp; + } + + /// get and check response packet from searchd server + function _GetResponse ( $fp, $client_ver ) + { + $response = ""; + $len = 0; + + $header = fread ( $fp, 8 ); + if ( strlen($header)==8 ) + { + list ( $status, $ver, $len ) = array_values ( unpack ( "n2a/Nb", $header ) ); + $left = $len; + while ( $left>0 && !feof($fp) ) + { + $chunk = fread ( $fp, min ( 8192, $left ) ); + if ( $chunk ) + { + $response .= $chunk; + $left -= strlen($chunk); + } + } + } + if ( $this->_socket === false ) + fclose ( $fp ); + + // check response + $read = strlen ( $response ); + if ( !$response || $read!=$len ) + { + $this->_error = $len + ? "failed to read searchd response (status=$status, ver=$ver, len=$len, read=$read)" + : "received zero-sized searchd response"; + return false; + } + + // check status + if ( $status==SEARCHD_WARNING ) + { + list(,$wlen) = unpack ( "N*", substr ( $response, 0, 4 ) ); + $this->_warning = substr ( $response, 4, $wlen ); + return substr ( $response, 4+$wlen ); + } + if ( $status==SEARCHD_ERROR ) + { + $this->_error = "searchd error: " . substr ( $response, 4 ); + return false; + } + if ( $status==SEARCHD_RETRY ) + { + $this->_error = "temporary searchd error: " . substr ( $response, 4 ); + return false; + } + if ( $status!=SEARCHD_OK ) + { + $this->_error = "unknown status code '$status'"; + return false; + } + + // check version + if ( $ver<$client_ver ) + { + $this->_warning = sprintf ( "searchd command v.%d.%d older than client's v.%d.%d, some options might not work", + $ver>>8, $ver&0xff, $client_ver>>8, $client_ver&0xff ); + } + + return $response; + } + + ///////////////////////////////////////////////////////////////////////////// + // searching + ///////////////////////////////////////////////////////////////////////////// + + /// set offset and count into result set, + /// and optionally set max-matches and cutoff limits + function SetLimits ( $offset, $limit, $max=0, $cutoff=0 ) + { + assert ( is_int($offset) ); + assert ( is_int($limit) ); + assert ( $offset>=0 ); + assert ( $limit>0 ); + assert ( $max>=0 ); + $this->_offset = $offset; + $this->_limit = $limit; + if ( $max>0 ) + $this->_maxmatches = $max; + if ( $cutoff>0 ) + $this->_cutoff = $cutoff; + } + + /// set maximum query time, in milliseconds, per-index + /// integer, 0 means "do not limit" + function SetMaxQueryTime ( $max ) + { + assert ( is_int($max) ); + assert ( $max>=0 ); + $this->_maxquerytime = $max; + } + + /// set matching mode + function SetMatchMode ( $mode ) + { + assert ( $mode==SPH_MATCH_ALL + || $mode==SPH_MATCH_ANY + || $mode==SPH_MATCH_PHRASE + || $mode==SPH_MATCH_BOOLEAN + || $mode==SPH_MATCH_EXTENDED + || $mode==SPH_MATCH_FULLSCAN + || $mode==SPH_MATCH_EXTENDED2 ); + $this->_mode = $mode; + } + + /// set ranking mode + function SetRankingMode ( $ranker, $rankexpr="" ) + { + assert ( $ranker>=0 && $ranker_ranker = $ranker; + $this->_rankexpr = $rankexpr; + } + + /// set matches sorting mode + function SetSortMode ( $mode, $sortby="" ) + { + assert ( + $mode==SPH_SORT_RELEVANCE || + $mode==SPH_SORT_ATTR_DESC || + $mode==SPH_SORT_ATTR_ASC || + $mode==SPH_SORT_TIME_SEGMENTS || + $mode==SPH_SORT_EXTENDED || + $mode==SPH_SORT_EXPR ); + assert ( is_string($sortby) ); + assert ( $mode==SPH_SORT_RELEVANCE || strlen($sortby)>0 ); + + $this->_sort = $mode; + $this->_sortby = $sortby; + } + + /// bind per-field weights by order + /// DEPRECATED; use SetFieldWeights() instead + function SetWeights ( $weights ) + { + assert ( is_array($weights) ); + foreach ( $weights as $weight ) + assert ( is_int($weight) ); + + $this->_weights = $weights; + } + + /// bind per-field weights by name + function SetFieldWeights ( $weights ) + { + assert ( is_array($weights) ); + foreach ( $weights as $name=>$weight ) + { + assert ( is_string($name) ); + assert ( is_int($weight) ); + } + $this->_fieldweights = $weights; + } + + /// bind per-index weights by name + function SetIndexWeights ( $weights ) + { + assert ( is_array($weights) ); + foreach ( $weights as $index=>$weight ) + { + assert ( is_string($index) ); + assert ( is_int($weight) ); + } + $this->_indexweights = $weights; + } + + /// set IDs range to match + /// only match records if document ID is beetwen $min and $max (inclusive) + function SetIDRange ( $min, $max ) + { + assert ( is_numeric($min) ); + assert ( is_numeric($max) ); + assert ( $min<=$max ); + $this->_min_id = $min; + $this->_max_id = $max; + } + + /// set values set filter + /// only match records where $attribute value is in given set + function SetFilter ( $attribute, $values, $exclude=false ) + { + assert ( is_string($attribute) ); + assert ( is_array($values) ); + assert ( count($values) ); + + if ( is_array($values) && count($values) ) + { + foreach ( $values as $value ) + assert ( is_numeric($value) ); + + $this->_filters[] = array ( "type"=>SPH_FILTER_VALUES, "attr"=>$attribute, "exclude"=>$exclude, "values"=>$values ); + } + } + + /// set range filter + /// only match records if $attribute value is beetwen $min and $max (inclusive) + function SetFilterRange ( $attribute, $min, $max, $exclude=false ) + { + assert ( is_string($attribute) ); + assert ( is_numeric($min) ); + assert ( is_numeric($max) ); + assert ( $min<=$max ); + + $this->_filters[] = array ( "type"=>SPH_FILTER_RANGE, "attr"=>$attribute, "exclude"=>$exclude, "min"=>$min, "max"=>$max ); + } + + /// set float range filter + /// only match records if $attribute value is beetwen $min and $max (inclusive) + function SetFilterFloatRange ( $attribute, $min, $max, $exclude=false ) + { + assert ( is_string($attribute) ); + assert ( is_float($min) ); + assert ( is_float($max) ); + assert ( $min<=$max ); + + $this->_filters[] = array ( "type"=>SPH_FILTER_FLOATRANGE, "attr"=>$attribute, "exclude"=>$exclude, "min"=>$min, "max"=>$max ); + } + + /// setup anchor point for geosphere distance calculations + /// required to use @geodist in filters and sorting + /// latitude and longitude must be in radians + function SetGeoAnchor ( $attrlat, $attrlong, $lat, $long ) + { + assert ( is_string($attrlat) ); + assert ( is_string($attrlong) ); + assert ( is_float($lat) ); + assert ( is_float($long) ); + + $this->_anchor = array ( "attrlat"=>$attrlat, "attrlong"=>$attrlong, "lat"=>$lat, "long"=>$long ); + } + + /// set grouping attribute and function + function SetGroupBy ( $attribute, $func, $groupsort="@group desc" ) + { + assert ( is_string($attribute) ); + assert ( is_string($groupsort) ); + assert ( $func==SPH_GROUPBY_DAY + || $func==SPH_GROUPBY_WEEK + || $func==SPH_GROUPBY_MONTH + || $func==SPH_GROUPBY_YEAR + || $func==SPH_GROUPBY_ATTR + || $func==SPH_GROUPBY_ATTRPAIR ); + + $this->_groupby = $attribute; + $this->_groupfunc = $func; + $this->_groupsort = $groupsort; + } + + /// set count-distinct attribute for group-by queries + function SetGroupDistinct ( $attribute ) + { + assert ( is_string($attribute) ); + $this->_groupdistinct = $attribute; + } + + /// set distributed retries count and delay + function SetRetries ( $count, $delay=0 ) + { + assert ( is_int($count) && $count>=0 ); + assert ( is_int($delay) && $delay>=0 ); + $this->_retrycount = $count; + $this->_retrydelay = $delay; + } + + /// set result set format (hash or array; hash by default) + /// PHP specific; needed for group-by-MVA result sets that may contain duplicate IDs + function SetArrayResult ( $arrayresult ) + { + assert ( is_bool($arrayresult) ); + $this->_arrayresult = $arrayresult; + } + + /// set attribute values override + /// there can be only one override per attribute + /// $values must be a hash that maps document IDs to attribute values + function SetOverride ( $attrname, $attrtype, $values ) + { + assert ( is_string ( $attrname ) ); + assert ( in_array ( $attrtype, array ( SPH_ATTR_INTEGER, SPH_ATTR_TIMESTAMP, SPH_ATTR_BOOL, SPH_ATTR_FLOAT, SPH_ATTR_BIGINT ) ) ); + assert ( is_array ( $values ) ); + + $this->_overrides[$attrname] = array ( "attr"=>$attrname, "type"=>$attrtype, "values"=>$values ); + } + + /// set select-list (attributes or expressions), SQL-like syntax + function SetSelect ( $select ) + { + assert ( is_string ( $select ) ); + $this->_select = $select; + } + + ////////////////////////////////////////////////////////////////////////////// + + /// clear all filters (for multi-queries) + function ResetFilters () + { + $this->_filters = array(); + $this->_anchor = array(); + } + + /// clear groupby settings (for multi-queries) + function ResetGroupBy () + { + $this->_groupby = ""; + $this->_groupfunc = SPH_GROUPBY_DAY; + $this->_groupsort = "@group desc"; + $this->_groupdistinct= ""; + } + + /// clear all attribute value overrides (for multi-queries) + function ResetOverrides () + { + $this->_overrides = array (); + } + + ////////////////////////////////////////////////////////////////////////////// + + /// connect to searchd server, run given search query through given indexes, + /// and return the search results + function Query ( $query, $index="*", $comment="" ) + { + assert ( empty($this->_reqs) ); + + $this->AddQuery ( $query, $index, $comment ); + $results = $this->RunQueries (); + $this->_reqs = array (); // just in case it failed too early + + if ( !is_array($results) ) + return false; // probably network error; error message should be already filled + + $this->_error = $results[0]["error"]; + $this->_warning = $results[0]["warning"]; + if ( $results[0]["status"]==SEARCHD_ERROR ) + return false; + else + return $results[0]; + } + + /// helper to pack floats in network byte order + function _PackFloat ( $f ) + { + $t1 = pack ( "f", $f ); // machine order + list(,$t2) = unpack ( "L*", $t1 ); // int in machine order + return pack ( "N", $t2 ); + } + + /// add query to multi-query batch + /// returns index into results array from RunQueries() call + function AddQuery ( $query, $index="*", $comment="" ) + { + // mbstring workaround + $this->_MBPush (); + + // build request + $req = pack ( "NNNN", $this->_offset, $this->_limit, $this->_mode, $this->_ranker ); + if ( $this->_ranker==SPH_RANK_EXPR ) + $req .= pack ( "N", strlen($this->_rankexpr) ) . $this->_rankexpr; + $req .= pack ( "N", $this->_sort ); // (deprecated) sort mode + $req .= pack ( "N", strlen($this->_sortby) ) . $this->_sortby; + $req .= pack ( "N", strlen($query) ) . $query; // query itself + $req .= pack ( "N", count($this->_weights) ); // weights + foreach ( $this->_weights as $weight ) + $req .= pack ( "N", (int)$weight ); + $req .= pack ( "N", strlen($index) ) . $index; // indexes + $req .= pack ( "N", 1 ); // id64 range marker + $req .= sphPackU64 ( $this->_min_id ) . sphPackU64 ( $this->_max_id ); // id64 range + + // filters + $req .= pack ( "N", count($this->_filters) ); + foreach ( $this->_filters as $filter ) + { + $req .= pack ( "N", strlen($filter["attr"]) ) . $filter["attr"]; + $req .= pack ( "N", $filter["type"] ); + switch ( $filter["type"] ) + { + case SPH_FILTER_VALUES: + $req .= pack ( "N", count($filter["values"]) ); + foreach ( $filter["values"] as $value ) + $req .= sphPackI64 ( $value ); + break; + + case SPH_FILTER_RANGE: + $req .= sphPackI64 ( $filter["min"] ) . sphPackI64 ( $filter["max"] ); + break; + + case SPH_FILTER_FLOATRANGE: + $req .= $this->_PackFloat ( $filter["min"] ) . $this->_PackFloat ( $filter["max"] ); + break; + + default: + assert ( 0 && "internal error: unhandled filter type" ); + } + $req .= pack ( "N", $filter["exclude"] ); + } + + // group-by clause, max-matches count, group-sort clause, cutoff count + $req .= pack ( "NN", $this->_groupfunc, strlen($this->_groupby) ) . $this->_groupby; + $req .= pack ( "N", $this->_maxmatches ); + $req .= pack ( "N", strlen($this->_groupsort) ) . $this->_groupsort; + $req .= pack ( "NNN", $this->_cutoff, $this->_retrycount, $this->_retrydelay ); + $req .= pack ( "N", strlen($this->_groupdistinct) ) . $this->_groupdistinct; + + // anchor point + if ( empty($this->_anchor) ) + { + $req .= pack ( "N", 0 ); + } else + { + $a =& $this->_anchor; + $req .= pack ( "N", 1 ); + $req .= pack ( "N", strlen($a["attrlat"]) ) . $a["attrlat"]; + $req .= pack ( "N", strlen($a["attrlong"]) ) . $a["attrlong"]; + $req .= $this->_PackFloat ( $a["lat"] ) . $this->_PackFloat ( $a["long"] ); + } + + // per-index weights + $req .= pack ( "N", count($this->_indexweights) ); + foreach ( $this->_indexweights as $idx=>$weight ) + $req .= pack ( "N", strlen($idx) ) . $idx . pack ( "N", $weight ); + + // max query time + $req .= pack ( "N", $this->_maxquerytime ); + + // per-field weights + $req .= pack ( "N", count($this->_fieldweights) ); + foreach ( $this->_fieldweights as $field=>$weight ) + $req .= pack ( "N", strlen($field) ) . $field . pack ( "N", $weight ); + + // comment + $req .= pack ( "N", strlen($comment) ) . $comment; + + // attribute overrides + $req .= pack ( "N", count($this->_overrides) ); + foreach ( $this->_overrides as $key => $entry ) + { + $req .= pack ( "N", strlen($entry["attr"]) ) . $entry["attr"]; + $req .= pack ( "NN", $entry["type"], count($entry["values"]) ); + foreach ( $entry["values"] as $id=>$val ) + { + assert ( is_numeric($id) ); + assert ( is_numeric($val) ); + + $req .= sphPackU64 ( $id ); + switch ( $entry["type"] ) + { + case SPH_ATTR_FLOAT: $req .= $this->_PackFloat ( $val ); break; + case SPH_ATTR_BIGINT: $req .= sphPackI64 ( $val ); break; + default: $req .= pack ( "N", $val ); break; + } + } + } + + // select-list + $req .= pack ( "N", strlen($this->_select) ) . $this->_select; + + // mbstring workaround + $this->_MBPop (); + + // store request to requests array + $this->_reqs[] = $req; + return count($this->_reqs)-1; + } + + /// connect to searchd, run queries batch, and return an array of result sets + function RunQueries () + { + if ( empty($this->_reqs) ) + { + $this->_error = "no queries defined, issue AddQuery() first"; + return false; + } + + // mbstring workaround + $this->_MBPush (); + + if (!( $fp = $this->_Connect() )) + { + $this->_MBPop (); + return false; + } + + // send query, get response + $nreqs = count($this->_reqs); + $req = join ( "", $this->_reqs ); + $len = 8+strlen($req); + $req = pack ( "nnNNN", SEARCHD_COMMAND_SEARCH, VER_COMMAND_SEARCH, $len, 0, $nreqs ) . $req; // add header + + if ( !( $this->_Send ( $fp, $req, $len+8 ) ) || + !( $response = $this->_GetResponse ( $fp, VER_COMMAND_SEARCH ) ) ) + { + $this->_MBPop (); + return false; + } + + // query sent ok; we can reset reqs now + $this->_reqs = array (); + + // parse and return response + return $this->_ParseSearchResponse ( $response, $nreqs ); + } + + /// parse and return search query (or queries) response + function _ParseSearchResponse ( $response, $nreqs ) + { + $p = 0; // current position + $max = strlen($response); // max position for checks, to protect against broken responses + + $results = array (); + for ( $ires=0; $ires<$nreqs && $p<$max; $ires++ ) + { + $results[] = array(); + $result =& $results[$ires]; + + $result["error"] = ""; + $result["warning"] = ""; + + // extract status + list(,$status) = unpack ( "N*", substr ( $response, $p, 4 ) ); $p += 4; + $result["status"] = $status; + if ( $status!=SEARCHD_OK ) + { + list(,$len) = unpack ( "N*", substr ( $response, $p, 4 ) ); $p += 4; + $message = substr ( $response, $p, $len ); $p += $len; + + if ( $status==SEARCHD_WARNING ) + { + $result["warning"] = $message; + } else + { + $result["error"] = $message; + continue; + } + } + + // read schema + $fields = array (); + $attrs = array (); + + list(,$nfields) = unpack ( "N*", substr ( $response, $p, 4 ) ); $p += 4; + while ( $nfields-->0 && $p<$max ) + { + list(,$len) = unpack ( "N*", substr ( $response, $p, 4 ) ); $p += 4; + $fields[] = substr ( $response, $p, $len ); $p += $len; + } + $result["fields"] = $fields; + + list(,$nattrs) = unpack ( "N*", substr ( $response, $p, 4 ) ); $p += 4; + while ( $nattrs-->0 && $p<$max ) + { + list(,$len) = unpack ( "N*", substr ( $response, $p, 4 ) ); $p += 4; + $attr = substr ( $response, $p, $len ); $p += $len; + list(,$type) = unpack ( "N*", substr ( $response, $p, 4 ) ); $p += 4; + $attrs[$attr] = $type; + } + $result["attrs"] = $attrs; + + // read match count + list(,$count) = unpack ( "N*", substr ( $response, $p, 4 ) ); $p += 4; + list(,$id64) = unpack ( "N*", substr ( $response, $p, 4 ) ); $p += 4; + + // read matches + $idx = -1; + while ( $count-->0 && $p<$max ) + { + // index into result array + $idx++; + + // parse document id and weight + if ( $id64 ) + { + $doc = sphUnpackU64 ( substr ( $response, $p, 8 ) ); $p += 8; + list(,$weight) = unpack ( "N*", substr ( $response, $p, 4 ) ); $p += 4; + } + else + { + list ( $doc, $weight ) = array_values ( unpack ( "N*N*", + substr ( $response, $p, 8 ) ) ); + $p += 8; + $doc = sphFixUint($doc); + } + $weight = sprintf ( "%u", $weight ); + + // create match entry + if ( $this->_arrayresult ) + $result["matches"][$idx] = array ( "id"=>$doc, "weight"=>$weight ); + else + $result["matches"][$doc]["weight"] = $weight; + + // parse and create attributes + $attrvals = array (); + foreach ( $attrs as $attr=>$type ) + { + // handle 64bit ints + if ( $type==SPH_ATTR_BIGINT ) + { + $attrvals[$attr] = sphUnpackI64 ( substr ( $response, $p, 8 ) ); $p += 8; + continue; + } + + // handle floats + if ( $type==SPH_ATTR_FLOAT ) + { + list(,$uval) = unpack ( "N*", substr ( $response, $p, 4 ) ); $p += 4; + list(,$fval) = unpack ( "f*", pack ( "L", $uval ) ); + $attrvals[$attr] = $fval; + continue; + } + + // handle everything else as unsigned ints + list(,$val) = unpack ( "N*", substr ( $response, $p, 4 ) ); $p += 4; + if ( $type==SPH_ATTR_MULTI ) + { + $attrvals[$attr] = array (); + $nvalues = $val; + while ( $nvalues-->0 && $p<$max ) + { + list(,$val) = unpack ( "N*", substr ( $response, $p, 4 ) ); $p += 4; + $attrvals[$attr][] = sphFixUint($val); + } + } else if ( $type==SPH_ATTR_MULTI64 ) + { + $attrvals[$attr] = array (); + $nvalues = $val; + while ( $nvalues>0 && $p<$max ) + { + $attrvals[$attr][] = sphUnpackU64 ( substr ( $response, $p, 8 ) ); $p += 8; + $nvalues -= 2; + } + } else if ( $type==SPH_ATTR_STRING ) + { + $attrvals[$attr] = substr ( $response, $p, $val ); + $p += $val; + } else + { + $attrvals[$attr] = sphFixUint($val); + } + } + + if ( $this->_arrayresult ) + $result["matches"][$idx]["attrs"] = $attrvals; + else + $result["matches"][$doc]["attrs"] = $attrvals; + } + + list ( $total, $total_found, $msecs, $words ) = + array_values ( unpack ( "N*N*N*N*", substr ( $response, $p, 16 ) ) ); + $result["total"] = sprintf ( "%u", $total ); + $result["total_found"] = sprintf ( "%u", $total_found ); + $result["time"] = sprintf ( "%.3f", $msecs/1000 ); + $p += 16; + + while ( $words-->0 && $p<$max ) + { + list(,$len) = unpack ( "N*", substr ( $response, $p, 4 ) ); $p += 4; + $word = substr ( $response, $p, $len ); $p += $len; + list ( $docs, $hits ) = array_values ( unpack ( "N*N*", substr ( $response, $p, 8 ) ) ); $p += 8; + $result["words"][$word] = array ( + "docs"=>sprintf ( "%u", $docs ), + "hits"=>sprintf ( "%u", $hits ) ); + } + } + + $this->_MBPop (); + return $results; + } + + ///////////////////////////////////////////////////////////////////////////// + // excerpts generation + ///////////////////////////////////////////////////////////////////////////// + + /// connect to searchd server, and generate exceprts (snippets) + /// of given documents for given query. returns false on failure, + /// an array of snippets on success + function BuildExcerpts ( $docs, $index, $words, $opts=array() ) + { + assert ( is_array($docs) ); + assert ( is_string($index) ); + assert ( is_string($words) ); + assert ( is_array($opts) ); + + $this->_MBPush (); + + if (!( $fp = $this->_Connect() )) + { + $this->_MBPop(); + return false; + } + + ///////////////// + // fixup options + ///////////////// + + if ( !isset($opts["before_match"]) ) $opts["before_match"] = ""; + if ( !isset($opts["after_match"]) ) $opts["after_match"] = ""; + if ( !isset($opts["chunk_separator"]) ) $opts["chunk_separator"] = " ... "; + if ( !isset($opts["limit"]) ) $opts["limit"] = 256; + if ( !isset($opts["limit_passages"]) ) $opts["limit_passages"] = 0; + if ( !isset($opts["limit_words"]) ) $opts["limit_words"] = 0; + if ( !isset($opts["around"]) ) $opts["around"] = 5; + if ( !isset($opts["exact_phrase"]) ) $opts["exact_phrase"] = false; + if ( !isset($opts["single_passage"]) ) $opts["single_passage"] = false; + if ( !isset($opts["use_boundaries"]) ) $opts["use_boundaries"] = false; + if ( !isset($opts["weight_order"]) ) $opts["weight_order"] = false; + if ( !isset($opts["query_mode"]) ) $opts["query_mode"] = false; + if ( !isset($opts["force_all_words"]) ) $opts["force_all_words"] = false; + if ( !isset($opts["start_passage_id"]) ) $opts["start_passage_id"] = 1; + if ( !isset($opts["load_files"]) ) $opts["load_files"] = false; + if ( !isset($opts["html_strip_mode"]) ) $opts["html_strip_mode"] = "index"; + if ( !isset($opts["allow_empty"]) ) $opts["allow_empty"] = false; + if ( !isset($opts["passage_boundary"]) ) $opts["passage_boundary"] = "none"; + if ( !isset($opts["emit_zones"]) ) $opts["emit_zones"] = false; + if ( !isset($opts["load_files_scattered"]) ) $opts["load_files_scattered"] = false; + + + ///////////////// + // build request + ///////////////// + + // v.1.2 req + $flags = 1; // remove spaces + if ( $opts["exact_phrase"] ) $flags |= 2; + if ( $opts["single_passage"] ) $flags |= 4; + if ( $opts["use_boundaries"] ) $flags |= 8; + if ( $opts["weight_order"] ) $flags |= 16; + if ( $opts["query_mode"] ) $flags |= 32; + if ( $opts["force_all_words"] ) $flags |= 64; + if ( $opts["load_files"] ) $flags |= 128; + if ( $opts["allow_empty"] ) $flags |= 256; + if ( $opts["emit_zones"] ) $flags |= 512; + if ( $opts["load_files_scattered"] ) $flags |= 1024; + $req = pack ( "NN", 0, $flags ); // mode=0, flags=$flags + $req .= pack ( "N", strlen($index) ) . $index; // req index + $req .= pack ( "N", strlen($words) ) . $words; // req words + + // options + $req .= pack ( "N", strlen($opts["before_match"]) ) . $opts["before_match"]; + $req .= pack ( "N", strlen($opts["after_match"]) ) . $opts["after_match"]; + $req .= pack ( "N", strlen($opts["chunk_separator"]) ) . $opts["chunk_separator"]; + $req .= pack ( "NN", (int)$opts["limit"], (int)$opts["around"] ); + $req .= pack ( "NNN", (int)$opts["limit_passages"], (int)$opts["limit_words"], (int)$opts["start_passage_id"] ); // v.1.2 + $req .= pack ( "N", strlen($opts["html_strip_mode"]) ) . $opts["html_strip_mode"]; + $req .= pack ( "N", strlen($opts["passage_boundary"]) ) . $opts["passage_boundary"]; + + // documents + $req .= pack ( "N", count($docs) ); + foreach ( $docs as $doc ) + { + assert ( is_string($doc) ); + $req .= pack ( "N", strlen($doc) ) . $doc; + } + + //////////////////////////// + // send query, get response + //////////////////////////// + + $len = strlen($req); + $req = pack ( "nnN", SEARCHD_COMMAND_EXCERPT, VER_COMMAND_EXCERPT, $len ) . $req; // add header + if ( !( $this->_Send ( $fp, $req, $len+8 ) ) || + !( $response = $this->_GetResponse ( $fp, VER_COMMAND_EXCERPT ) ) ) + { + $this->_MBPop (); + return false; + } + + ////////////////// + // parse response + ////////////////// + + $pos = 0; + $res = array (); + $rlen = strlen($response); + for ( $i=0; $i $rlen ) + { + $this->_error = "incomplete reply"; + $this->_MBPop (); + return false; + } + $res[] = $len ? substr ( $response, $pos, $len ) : ""; + $pos += $len; + } + + $this->_MBPop (); + return $res; + } + + + ///////////////////////////////////////////////////////////////////////////// + // keyword generation + ///////////////////////////////////////////////////////////////////////////// + + /// connect to searchd server, and generate keyword list for a given query + /// returns false on failure, + /// an array of words on success + function BuildKeywords ( $query, $index, $hits ) + { + assert ( is_string($query) ); + assert ( is_string($index) ); + assert ( is_bool($hits) ); + + $this->_MBPush (); + + if (!( $fp = $this->_Connect() )) + { + $this->_MBPop(); + return false; + } + + ///////////////// + // build request + ///////////////// + + // v.1.0 req + $req = pack ( "N", strlen($query) ) . $query; // req query + $req .= pack ( "N", strlen($index) ) . $index; // req index + $req .= pack ( "N", (int)$hits ); + + //////////////////////////// + // send query, get response + //////////////////////////// + + $len = strlen($req); + $req = pack ( "nnN", SEARCHD_COMMAND_KEYWORDS, VER_COMMAND_KEYWORDS, $len ) . $req; // add header + if ( !( $this->_Send ( $fp, $req, $len+8 ) ) || + !( $response = $this->_GetResponse ( $fp, VER_COMMAND_KEYWORDS ) ) ) + { + $this->_MBPop (); + return false; + } + + ////////////////// + // parse response + ////////////////// + + $pos = 0; + $res = array (); + $rlen = strlen($response); + list(,$nwords) = unpack ( "N*", substr ( $response, $pos, 4 ) ); + $pos += 4; + for ( $i=0; $i<$nwords; $i++ ) + { + list(,$len) = unpack ( "N*", substr ( $response, $pos, 4 ) ); $pos += 4; + $tokenized = $len ? substr ( $response, $pos, $len ) : ""; + $pos += $len; + + list(,$len) = unpack ( "N*", substr ( $response, $pos, 4 ) ); $pos += 4; + $normalized = $len ? substr ( $response, $pos, $len ) : ""; + $pos += $len; + + $res[] = array ( "tokenized"=>$tokenized, "normalized"=>$normalized ); + + if ( $hits ) + { + list($ndocs,$nhits) = array_values ( unpack ( "N*N*", substr ( $response, $pos, 8 ) ) ); + $pos += 8; + $res [$i]["docs"] = $ndocs; + $res [$i]["hits"] = $nhits; + } + + if ( $pos > $rlen ) + { + $this->_error = "incomplete reply"; + $this->_MBPop (); + return false; + } + } + + $this->_MBPop (); + return $res; + } + + function EscapeString ( $string ) + { + $from = array ( '\\', '(',')','|','-','!','@','~','"','&', '/', '^', '$', '=' ); + $to = array ( '\\\\', '\(','\)','\|','\-','\!','\@','\~','\"', '\&', '\/', '\^', '\$', '\=' ); + + return str_replace ( $from, $to, $string ); + } + + ///////////////////////////////////////////////////////////////////////////// + // attribute updates + ///////////////////////////////////////////////////////////////////////////// + + /// batch update given attributes in given rows in given indexes + /// returns amount of updated documents (0 or more) on success, or -1 on failure + function UpdateAttributes ( $index, $attrs, $values, $mva=false ) + { + // verify everything + assert ( is_string($index) ); + assert ( is_bool($mva) ); + + assert ( is_array($attrs) ); + foreach ( $attrs as $attr ) + assert ( is_string($attr) ); + + assert ( is_array($values) ); + foreach ( $values as $id=>$entry ) + { + assert ( is_numeric($id) ); + assert ( is_array($entry) ); + assert ( count($entry)==count($attrs) ); + foreach ( $entry as $v ) + { + if ( $mva ) + { + assert ( is_array($v) ); + foreach ( $v as $vv ) + assert ( is_int($vv) ); + } else + assert ( is_int($v) ); + } + } + + // build request + $this->_MBPush (); + $req = pack ( "N", strlen($index) ) . $index; + + $req .= pack ( "N", count($attrs) ); + foreach ( $attrs as $attr ) + { + $req .= pack ( "N", strlen($attr) ) . $attr; + $req .= pack ( "N", $mva ? 1 : 0 ); + } + + $req .= pack ( "N", count($values) ); + foreach ( $values as $id=>$entry ) + { + $req .= sphPackU64 ( $id ); + foreach ( $entry as $v ) + { + $req .= pack ( "N", $mva ? count($v) : $v ); + if ( $mva ) + foreach ( $v as $vv ) + $req .= pack ( "N", $vv ); + } + } + + // connect, send query, get response + if (!( $fp = $this->_Connect() )) + { + $this->_MBPop (); + return -1; + } + + $len = strlen($req); + $req = pack ( "nnN", SEARCHD_COMMAND_UPDATE, VER_COMMAND_UPDATE, $len ) . $req; // add header + if ( !$this->_Send ( $fp, $req, $len+8 ) ) + { + $this->_MBPop (); + return -1; + } + + if (!( $response = $this->_GetResponse ( $fp, VER_COMMAND_UPDATE ) )) + { + $this->_MBPop (); + return -1; + } + + // parse response + list(,$updated) = unpack ( "N*", substr ( $response, 0, 4 ) ); + $this->_MBPop (); + return $updated; + } + + ///////////////////////////////////////////////////////////////////////////// + // persistent connections + ///////////////////////////////////////////////////////////////////////////// + + function Open() + { + if ( $this->_socket !== false ) + { + $this->_error = 'already connected'; + return false; + } + if ( !$fp = $this->_Connect() ) + return false; + + // command, command version = 0, body length = 4, body = 1 + $req = pack ( "nnNN", SEARCHD_COMMAND_PERSIST, 0, 4, 1 ); + if ( !$this->_Send ( $fp, $req, 12 ) ) + return false; + + $this->_socket = $fp; + return true; + } + + function Close() + { + if ( $this->_socket === false ) + { + $this->_error = 'not connected'; + return false; + } + + fclose ( $this->_socket ); + $this->_socket = false; + + return true; + } + + ////////////////////////////////////////////////////////////////////////// + // status + ////////////////////////////////////////////////////////////////////////// + + function Status () + { + $this->_MBPush (); + if (!( $fp = $this->_Connect() )) + { + $this->_MBPop(); + return false; + } + + $req = pack ( "nnNN", SEARCHD_COMMAND_STATUS, VER_COMMAND_STATUS, 4, 1 ); // len=4, body=1 + if ( !( $this->_Send ( $fp, $req, 12 ) ) || + !( $response = $this->_GetResponse ( $fp, VER_COMMAND_STATUS ) ) ) + { + $this->_MBPop (); + return false; + } + + $res = substr ( $response, 4 ); // just ignore length, error handling, etc + $p = 0; + list ( $rows, $cols ) = array_values ( unpack ( "N*N*", substr ( $response, $p, 8 ) ) ); $p += 8; + + $res = array(); + for ( $i=0; $i<$rows; $i++ ) + for ( $j=0; $j<$cols; $j++ ) + { + list(,$len) = unpack ( "N*", substr ( $response, $p, 4 ) ); $p += 4; + $res[$i][] = substr ( $response, $p, $len ); $p += $len; + } + + $this->_MBPop (); + return $res; + } + + ////////////////////////////////////////////////////////////////////////// + // flush + ////////////////////////////////////////////////////////////////////////// + + function FlushAttributes () + { + $this->_MBPush (); + if (!( $fp = $this->_Connect() )) + { + $this->_MBPop(); + return -1; + } + + $req = pack ( "nnN", SEARCHD_COMMAND_FLUSHATTRS, VER_COMMAND_FLUSHATTRS, 0 ); // len=0 + if ( !( $this->_Send ( $fp, $req, 8 ) ) || + !( $response = $this->_GetResponse ( $fp, VER_COMMAND_FLUSHATTRS ) ) ) + { + $this->_MBPop (); + return -1; + } + + $tag = -1; + if ( strlen($response)==4 ) + list(,$tag) = unpack ( "N*", $response ); + else + $this->_error = "unexpected response length"; + + $this->_MBPop (); + return $tag; + } +} + +// +// $Id: sphinxapi.php 3087 2012-01-30 23:07:35Z shodan $ +// diff --git a/tests/session/append_sid_test.php b/tests/session/append_sid_test.php index 34f6dea8ca..b9e9ac1aa9 100644 --- a/tests/session/append_sid_test.php +++ b/tests/session/append_sid_test.php @@ -1,54 +1,54 @@ - 1, 'f' => 2), true, false, 'viewtopic.php?t=1&f=2', 'parameters in params-argument as array'), - - // Custom sid parameter - array('viewtopic.php', 't=1&f=2', true, 'custom-sid', 'viewtopic.php?t=1&f=2&sid=custom-sid', 'using session_id'), - - // Testing anchors - array('viewtopic.php?t=1&f=2#anchor', false, true, false, 'viewtopic.php?t=1&f=2#anchor', 'anchor in url-argument'), - array('viewtopic.php', 't=1&f=2#anchor', true, false, 'viewtopic.php?t=1&f=2#anchor', 'anchor in params-argument'), - array('viewtopic.php', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, false, 'viewtopic.php?t=1&f=2#anchor', 'anchor in params-argument (array)'), - - // Anchors and custom sid - array('viewtopic.php?t=1&f=2#anchor', false, true, 'custom-sid', 'viewtopic.php?t=1&f=2&sid=custom-sid#anchor', 'anchor in url-argument using session_id'), - array('viewtopic.php', 't=1&f=2#anchor', true, 'custom-sid', 'viewtopic.php?t=1&f=2&sid=custom-sid#anchor', 'anchor in params-argument using session_id'), - array('viewtopic.php', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, 'custom-sid', 'viewtopic.php?t=1&f=2&sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'), - - // Empty parameters should not append the ? - array('viewtopic.php', false, true, false, 'viewtopic.php', 'no params using bool false'), - array('viewtopic.php', '', true, false, 'viewtopic.php', 'no params using empty string'), - array('viewtopic.php', array(), true, false, 'viewtopic.php', 'no params using empty array'), - ); - } - - /** - * @dataProvider append_sid_data - */ - public function test_append_sid($url, $params, $is_amp, $session_id, $expected, $description) - { - global $phpbb_dispatcher; - - $phpbb_dispatcher = new phpbb_mock_event_dispatcher; - $this->assertEquals($expected, append_sid($url, $params, $is_amp, $session_id)); - } -} - + 1, 'f' => 2), true, false, 'viewtopic.php?t=1&f=2', 'parameters in params-argument as array'), + + // Custom sid parameter + array('viewtopic.php', 't=1&f=2', true, 'custom-sid', 'viewtopic.php?t=1&f=2&sid=custom-sid', 'using session_id'), + + // Testing anchors + array('viewtopic.php?t=1&f=2#anchor', false, true, false, 'viewtopic.php?t=1&f=2#anchor', 'anchor in url-argument'), + array('viewtopic.php', 't=1&f=2#anchor', true, false, 'viewtopic.php?t=1&f=2#anchor', 'anchor in params-argument'), + array('viewtopic.php', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, false, 'viewtopic.php?t=1&f=2#anchor', 'anchor in params-argument (array)'), + + // Anchors and custom sid + array('viewtopic.php?t=1&f=2#anchor', false, true, 'custom-sid', 'viewtopic.php?t=1&f=2&sid=custom-sid#anchor', 'anchor in url-argument using session_id'), + array('viewtopic.php', 't=1&f=2#anchor', true, 'custom-sid', 'viewtopic.php?t=1&f=2&sid=custom-sid#anchor', 'anchor in params-argument using session_id'), + array('viewtopic.php', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, 'custom-sid', 'viewtopic.php?t=1&f=2&sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'), + + // Empty parameters should not append the ? + array('viewtopic.php', false, true, false, 'viewtopic.php', 'no params using bool false'), + array('viewtopic.php', '', true, false, 'viewtopic.php', 'no params using empty string'), + array('viewtopic.php', array(), true, false, 'viewtopic.php', 'no params using empty array'), + ); + } + + /** + * @dataProvider append_sid_data + */ + public function test_append_sid($url, $params, $is_amp, $session_id, $expected, $description) + { + global $phpbb_dispatcher; + + $phpbb_dispatcher = new phpbb_mock_event_dispatcher; + $this->assertEquals($expected, append_sid($url, $params, $is_amp, $session_id)); + } +} + From 8a28271dd500b3623e1402339252504468e567f6 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Fri, 7 Dec 2012 21:23:20 -0600 Subject: [PATCH 0574/2494] [ticket/11257] Do not require set_name() method to exist To use Service Collection PHPBB3-11257 --- phpBB/config/cron_tasks.yml | 16 ++++++++++++++++ phpBB/includes/di/service_collection.php | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/phpBB/config/cron_tasks.yml b/phpBB/config/cron_tasks.yml index 74f57e449d..d1954b1877 100644 --- a/phpBB/config/cron_tasks.yml +++ b/phpBB/config/cron_tasks.yml @@ -6,6 +6,8 @@ services: - %core.php_ext% - @config - @dbal.conn + calls: + - [set_name, [cron.task.core.prune_all_forums]] tags: - { name: cron.task } @@ -16,6 +18,8 @@ services: - %core.php_ext% - @config - @dbal.conn + calls: + - [set_name, [cron.task.core.prune_forum]] tags: - { name: cron.task } @@ -25,6 +29,8 @@ services: - %core.root_path% - %core.php_ext% - @config + calls: + - [set_name, [cron.task.core.queue]] tags: - { name: cron.task } @@ -33,6 +39,8 @@ services: arguments: - @config - @cache.driver + calls: + - [set_name, [cron.task.core.tidy_cache]] tags: - { name: cron.task } @@ -42,6 +50,8 @@ services: - %core.root_path% - %core.php_ext% - @config + calls: + - [set_name, [cron.task.core.tidy_database]] tags: - { name: cron.task } @@ -54,6 +64,8 @@ services: - @config - @dbal.conn - @user + calls: + - [set_name, [cron.task.core.tidy_search]] tags: - { name: cron.task } @@ -62,6 +74,8 @@ services: arguments: - @config - @user + calls: + - [set_name, [cron.task.core.tidy_sessions]] tags: - { name: cron.task } @@ -71,5 +85,7 @@ services: - %core.root_path% - %core.php_ext% - @config + calls: + - [set_name, [cron.task.core.tidy_warnings]] tags: - { name: cron.task } diff --git a/phpBB/includes/di/service_collection.php b/phpBB/includes/di/service_collection.php index 60323c8dba..880cb46d4d 100644 --- a/phpBB/includes/di/service_collection.php +++ b/phpBB/includes/di/service_collection.php @@ -43,7 +43,7 @@ class phpbb_di_service_collection extends ArrayObject public function add($name) { $task = $this->container->get($name); - $task->set_name($name); + $this->offsetSet($name, $task); } } From b91ba8d5f1c05bc285e3f3b24fc5ffd50f6ee3ed Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Sat, 8 Dec 2012 13:18:11 -0600 Subject: [PATCH 0575/2494] [ticket/11103] Newlines at end of files PHPBB3-11103 --- phpBB/config/notifications.yml | 2 +- phpBB/includes/user_loader.php | 2 +- phpBB/language/en/email/newtopic_notify.txt | 2 +- phpBB/language/en/email/post_disapproved.txt | 2 +- phpBB/language/en/email/privmsg_notify.txt | 2 +- phpBB/language/en/email/short/newtopic_notify.txt | 2 +- phpBB/language/en/email/short/post_disapproved.txt | 2 +- phpBB/language/en/email/short/privmsg_notify.txt | 2 +- phpBB/language/en/email/short/topic_approved.txt | 2 +- phpBB/language/en/email/short/topic_disapproved.txt | 2 +- phpBB/language/en/email/short/topic_notify.txt | 2 +- phpBB/language/en/email/topic_approved.txt | 2 +- phpBB/language/en/email/topic_disapproved.txt | 2 +- phpBB/language/en/email/topic_notify.txt | 2 +- 14 files changed, 14 insertions(+), 14 deletions(-) diff --git a/phpBB/config/notifications.yml b/phpBB/config/notifications.yml index f8a5b5f9fa..5a593c44d6 100644 --- a/phpBB/config/notifications.yml +++ b/phpBB/config/notifications.yml @@ -279,4 +279,4 @@ services: - %core.root_path% - %core.php_ext% tags: - - { name: notification.method } \ No newline at end of file + - { name: notification.method } diff --git a/phpBB/includes/user_loader.php b/phpBB/includes/user_loader.php index a530f21f75..c7a6a103f8 100644 --- a/phpBB/includes/user_loader.php +++ b/phpBB/includes/user_loader.php @@ -115,4 +115,4 @@ class phpbb_user_loader return get_user_avatar($user['user_avatar'], $user['user_avatar_type'], $user['user_avatar_width'], $user['user_avatar_height']); } -} \ No newline at end of file +} diff --git a/phpBB/language/en/email/newtopic_notify.txt b/phpBB/language/en/email/newtopic_notify.txt index d4f5cae620..bf6799e5be 100644 --- a/phpBB/language/en/email/newtopic_notify.txt +++ b/phpBB/language/en/email/newtopic_notify.txt @@ -10,4 +10,4 @@ If you no longer wish to watch this forum you can either click the "Unsubscribe {U_STOP_WATCHING_FORUM} -{EMAIL_SIG} \ No newline at end of file +{EMAIL_SIG} diff --git a/phpBB/language/en/email/post_disapproved.txt b/phpBB/language/en/email/post_disapproved.txt index 3bc64bb611..2f8a8381cb 100644 --- a/phpBB/language/en/email/post_disapproved.txt +++ b/phpBB/language/en/email/post_disapproved.txt @@ -9,4 +9,4 @@ The following reason was given for the disapproval: {REASON} -{EMAIL_SIG} \ No newline at end of file +{EMAIL_SIG} diff --git a/phpBB/language/en/email/privmsg_notify.txt b/phpBB/language/en/email/privmsg_notify.txt index d3a86cc73c..41fdbb782c 100644 --- a/phpBB/language/en/email/privmsg_notify.txt +++ b/phpBB/language/en/email/privmsg_notify.txt @@ -12,4 +12,4 @@ You can view your new message by clicking on the following link: You have requested that you be notified on this event, remember that you can always choose not to be notified of new messages by changing the appropriate setting in your profile. -{EMAIL_SIG} \ No newline at end of file +{EMAIL_SIG} diff --git a/phpBB/language/en/email/short/newtopic_notify.txt b/phpBB/language/en/email/short/newtopic_notify.txt index d4f5cae620..bf6799e5be 100644 --- a/phpBB/language/en/email/short/newtopic_notify.txt +++ b/phpBB/language/en/email/short/newtopic_notify.txt @@ -10,4 +10,4 @@ If you no longer wish to watch this forum you can either click the "Unsubscribe {U_STOP_WATCHING_FORUM} -{EMAIL_SIG} \ No newline at end of file +{EMAIL_SIG} diff --git a/phpBB/language/en/email/short/post_disapproved.txt b/phpBB/language/en/email/short/post_disapproved.txt index 3bc64bb611..2f8a8381cb 100644 --- a/phpBB/language/en/email/short/post_disapproved.txt +++ b/phpBB/language/en/email/short/post_disapproved.txt @@ -9,4 +9,4 @@ The following reason was given for the disapproval: {REASON} -{EMAIL_SIG} \ No newline at end of file +{EMAIL_SIG} diff --git a/phpBB/language/en/email/short/privmsg_notify.txt b/phpBB/language/en/email/short/privmsg_notify.txt index d3a86cc73c..41fdbb782c 100644 --- a/phpBB/language/en/email/short/privmsg_notify.txt +++ b/phpBB/language/en/email/short/privmsg_notify.txt @@ -12,4 +12,4 @@ You can view your new message by clicking on the following link: You have requested that you be notified on this event, remember that you can always choose not to be notified of new messages by changing the appropriate setting in your profile. -{EMAIL_SIG} \ No newline at end of file +{EMAIL_SIG} diff --git a/phpBB/language/en/email/short/topic_approved.txt b/phpBB/language/en/email/short/topic_approved.txt index ffda378d30..0b09918b89 100644 --- a/phpBB/language/en/email/short/topic_approved.txt +++ b/phpBB/language/en/email/short/topic_approved.txt @@ -8,4 +8,4 @@ If you want to view the topic, click the following link: {U_VIEW_TOPIC} -{EMAIL_SIG} \ No newline at end of file +{EMAIL_SIG} diff --git a/phpBB/language/en/email/short/topic_disapproved.txt b/phpBB/language/en/email/short/topic_disapproved.txt index 49ef58bf39..a4bd9c151e 100644 --- a/phpBB/language/en/email/short/topic_disapproved.txt +++ b/phpBB/language/en/email/short/topic_disapproved.txt @@ -9,4 +9,4 @@ The following reason was given for the disapproval: {REASON} -{EMAIL_SIG} \ No newline at end of file +{EMAIL_SIG} diff --git a/phpBB/language/en/email/short/topic_notify.txt b/phpBB/language/en/email/short/topic_notify.txt index fa2481dd9a..472375fb22 100644 --- a/phpBB/language/en/email/short/topic_notify.txt +++ b/phpBB/language/en/email/short/topic_notify.txt @@ -17,4 +17,4 @@ If you no longer wish to watch this topic you can either click the "Unsubscribe {U_STOP_WATCHING_TOPIC} -{EMAIL_SIG} \ No newline at end of file +{EMAIL_SIG} diff --git a/phpBB/language/en/email/topic_approved.txt b/phpBB/language/en/email/topic_approved.txt index ffda378d30..0b09918b89 100644 --- a/phpBB/language/en/email/topic_approved.txt +++ b/phpBB/language/en/email/topic_approved.txt @@ -8,4 +8,4 @@ If you want to view the topic, click the following link: {U_VIEW_TOPIC} -{EMAIL_SIG} \ No newline at end of file +{EMAIL_SIG} diff --git a/phpBB/language/en/email/topic_disapproved.txt b/phpBB/language/en/email/topic_disapproved.txt index 49ef58bf39..a4bd9c151e 100644 --- a/phpBB/language/en/email/topic_disapproved.txt +++ b/phpBB/language/en/email/topic_disapproved.txt @@ -9,4 +9,4 @@ The following reason was given for the disapproval: {REASON} -{EMAIL_SIG} \ No newline at end of file +{EMAIL_SIG} diff --git a/phpBB/language/en/email/topic_notify.txt b/phpBB/language/en/email/topic_notify.txt index fa2481dd9a..472375fb22 100644 --- a/phpBB/language/en/email/topic_notify.txt +++ b/phpBB/language/en/email/topic_notify.txt @@ -17,4 +17,4 @@ If you no longer wish to watch this topic you can either click the "Unsubscribe {U_STOP_WATCHING_TOPIC} -{EMAIL_SIG} \ No newline at end of file +{EMAIL_SIG} From 6b7443adacfa8e79304e4c91ca02000d25259633 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Sat, 8 Dec 2012 13:41:44 -0600 Subject: [PATCH 0576/2494] [ticket/11103] User loader test.bat PHPBB3-11103 --- tests/notification/notification.php | 1 - tests/user/fixtures/user_loader.xml | 23 ++++++++++++++ tests/user/user_loader.php | 48 +++++++++++++++++++++++++++++ 3 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 tests/user/fixtures/user_loader.xml create mode 100644 tests/user/user_loader.php diff --git a/tests/notification/notification.php b/tests/notification/notification.php index 8fa77ff651..e4522c2cdc 100644 --- a/tests/notification/notification.php +++ b/tests/notification/notification.php @@ -16,7 +16,6 @@ class phpbb_notification_test extends phpbb_database_test_case return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/notification.xml'); } - protected function setUp() { parent::setUp(); diff --git a/tests/user/fixtures/user_loader.xml b/tests/user/fixtures/user_loader.xml new file mode 100644 index 0000000000..737376f326 --- /dev/null +++ b/tests/user/fixtures/user_loader.xml @@ -0,0 +1,23 @@ + + +
    + user_id + username + username_clean + + 1 + Guest + guest + + + 2 + Admin + admin + + + 3 + Test + test + +
    + diff --git a/tests/user/user_loader.php b/tests/user/user_loader.php new file mode 100644 index 0000000000..145bfc9549 --- /dev/null +++ b/tests/user/user_loader.php @@ -0,0 +1,48 @@ +createXMLDataSet(dirname(__FILE__) . '/fixtures/user_loader.xml'); + } + + public function test_user_loader() + { + $db = $this->new_dbal(); + + $user_loader = new phpbb_user_loader($db, __DIR__ . '../../phpBB', 'php', 'phpbb_users'); + + $user_loader->load_users(array(2)); + + $user = $user_loader->get_user(1); + $this->assertEquals(1, $user['user_id']); + $this->assertEquals('Guest', $user['username']); + + $user = $user_loader->get_user(2); + $this->assertEquals(2, $user['user_id']); + $this->assertEquals('Admin', $user['username']); + + // Not loaded + $user = $user_loader->get_user(3); + $this->assertEquals(1, $user['user_id']); + $this->assertEquals('Guest', $user['username']); + + $user_loader->load_users(array(3)); + + $user = $user_loader->get_user(2); + $this->assertEquals(2, $user['user_id']); + $this->assertEquals('Admin', $user['username']); + + $user = $user_loader->get_user(3); + $this->assertEquals(3, $user['user_id']); + $this->assertEquals('Test', $user['username']); + } +} From 2227ceab8bf0cccf95598f4e2a59cc7134adf7f0 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Sat, 8 Dec 2012 13:56:39 -0600 Subject: [PATCH 0577/2494] [ticket/11103] Use $request->variable rather than request_var PHPBB3-11103 --- phpBB/includes/ucp/ucp_notifications.php | 8 ++++---- phpBB/index.php | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/phpBB/includes/ucp/ucp_notifications.php b/phpBB/includes/ucp/ucp_notifications.php index e8ceac3f59..76fc411584 100644 --- a/phpBB/includes/ucp/ucp_notifications.php +++ b/phpBB/includes/ucp/ucp_notifications.php @@ -26,8 +26,8 @@ class ucp_notifications add_form_key('ucp_notification'); - $start = request_var('start', 0); - $form_time = min(request_var('form_time', 0), time()); + $start = $request->variable('start', 0); + $form_time = min($request->variable('form_time', 0), time()); switch ($mode) { @@ -87,7 +87,7 @@ class ucp_notifications case 'notification_list': default: // Mark all items read - if (request_var('mark', '') == 'all' && (confirm_box(true) || check_link_hash(request_var('token', ''), 'mark_all_notifications_read'))) + if ($request->variable('mark', '') == 'all' && (confirm_box(true) || check_link_hash($request->variable('token', ''), 'mark_all_notifications_read'))) { if (confirm_box(true)) { @@ -114,7 +114,7 @@ class ucp_notifications trigger_error('FORM_INVALID'); } - $mark_read = request_var('mark', array(0)); + $mark_read = $request->variable('mark', array(0)); if (!empty($mark_read)) { diff --git a/phpBB/index.php b/phpBB/index.php index 94b2b17084..5e76d653eb 100644 --- a/phpBB/index.php +++ b/phpBB/index.php @@ -25,7 +25,7 @@ $auth->acl($user->data); $user->setup('viewforum'); // Mark notifications read -if (($mark_notification = request_var('mark_notification', 0))) +if (($mark_notification = $request->variable('mark_notification', 0))) { $notification = $phpbb_notifications->load_notifications(array( 'notification_id' => $mark_notification @@ -37,7 +37,7 @@ if (($mark_notification = request_var('mark_notification', 0))) $notification->mark_read(); - if (($redirect = request_var('redirect', ''))) + if (($redirect = $request->variable('redirect', ''))) { redirect(append_sid($phpbb_root_path . $redirect)); } From 0d6c8f46ffa1206e9d8d71fd30ef04e52f7cb2a8 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Sat, 8 Dec 2012 14:12:25 -0600 Subject: [PATCH 0578/2494] [ticket/11103] Update indexes on notifications/user notifications tables PHPBB3-11103 --- phpBB/develop/create_schema_files.php | 14 ++------------ phpBB/install/database_update.php | 14 ++------------ phpBB/install/schemas/firebird_schema.sql | 9 ++------- phpBB/install/schemas/mssql_schema.sql | 19 ++----------------- phpBB/install/schemas/mysql_40_schema.sql | 9 ++------- phpBB/install/schemas/mysql_41_schema.sql | 9 ++------- phpBB/install/schemas/oracle_schema.sql | 14 ++------------ phpBB/install/schemas/postgres_schema.sql | 9 ++------- phpBB/install/schemas/sqlite_schema.sql | 9 ++------- 9 files changed, 18 insertions(+), 88 deletions(-) diff --git a/phpBB/develop/create_schema_files.php b/phpBB/develop/create_schema_files.php index 3548bc5f05..87204f9e26 100644 --- a/phpBB/develop/create_schema_files.php +++ b/phpBB/develop/create_schema_files.php @@ -1309,13 +1309,8 @@ function get_schema_struct() ), 'PRIMARY_KEY' => 'notification_id', 'KEYS' => array( - 'item_type' => array('INDEX', 'item_type'), - 'item_id' => array('INDEX', 'item_id'), - 'item_pid' => array('INDEX', 'item_parent_id'), - 'user_id' => array('INDEX', 'user_id'), - 'time' => array('INDEX', 'time'), - 'unread' => array('INDEX', 'unread'), - 'is_enabled' => array('INDEX', 'is_enabled'), + 'item_ident' => array('INDEX', array('item_type', 'item_id')), + 'user' => array('INDEX', array('user_id', 'unread')), ), ); @@ -1791,11 +1786,6 @@ function get_schema_struct() 'user_id', 'method', ), - 'KEYS' => array( - 'it' => array('INDEX', 'item_type'), - 'uid' => array('INDEX', 'user_id'), - 'no' => array('INDEX', 'notify'), - ), ); $schema_data['phpbb_user_group'] = array( diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 33e8795327..a4739b7212 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -1122,13 +1122,8 @@ function database_update_info() ), 'PRIMARY_KEY' => 'notification_id', 'KEYS' => array( - 'item_type' => array('INDEX', 'item_type'), - 'item_id' => array('INDEX', 'item_id'), - 'item_pid' => array('INDEX', 'item_parent_id'), - 'user_id' => array('INDEX', 'user_id'), - 'time' => array('INDEX', 'time'), - 'unread' => array('INDEX', 'unread'), - 'is_enabled' => array('INDEX', 'is_enabled'), + 'item_ident' => array('INDEX', array('item_type', 'item_id')), + 'user' => array('INDEX', array('user_id', 'unread')), ), ), $table_prefix . 'user_notifications' => array( @@ -1145,11 +1140,6 @@ function database_update_info() 'user_id', 'method', ), - 'KEYS' => array( - 'it' => array('INDEX', 'item_type'), - 'uid' => array('INDEX', 'user_id'), - 'no' => array('INDEX', 'notify'), - ), ), ), 'add_columns' => array( diff --git a/phpBB/install/schemas/firebird_schema.sql b/phpBB/install/schemas/firebird_schema.sql index 8456958800..d3058fb0dd 100644 --- a/phpBB/install/schemas/firebird_schema.sql +++ b/phpBB/install/schemas/firebird_schema.sql @@ -633,13 +633,8 @@ CREATE TABLE phpbb_notifications ( ALTER TABLE phpbb_notifications ADD PRIMARY KEY (notification_id);; -CREATE INDEX phpbb_notifications_item_type ON phpbb_notifications(item_type);; -CREATE INDEX phpbb_notifications_item_id ON phpbb_notifications(item_id);; -CREATE INDEX phpbb_notifications_item_pid ON phpbb_notifications(item_parent_id);; -CREATE INDEX phpbb_notifications_user_id ON phpbb_notifications(user_id);; -CREATE INDEX phpbb_notifications_time ON phpbb_notifications(time);; -CREATE INDEX phpbb_notifications_unread ON phpbb_notifications(unread);; -CREATE INDEX phpbb_notifications_is_enabled ON phpbb_notifications(is_enabled);; +CREATE INDEX phpbb_notifications_item_ident ON phpbb_notifications(item_type, item_id);; +CREATE INDEX phpbb_notifications_user ON phpbb_notifications(user_id, unread);; CREATE GENERATOR phpbb_notifications_gen;; SET GENERATOR phpbb_notifications_gen TO 0;; diff --git a/phpBB/install/schemas/mssql_schema.sql b/phpBB/install/schemas/mssql_schema.sql index d0023aa411..377ff92620 100644 --- a/phpBB/install/schemas/mssql_schema.sql +++ b/phpBB/install/schemas/mssql_schema.sql @@ -774,25 +774,10 @@ ALTER TABLE [phpbb_notifications] WITH NOCHECK ADD ) ON [PRIMARY] GO -CREATE INDEX [item_type] ON [phpbb_notifications]([item_type]) ON [PRIMARY] +CREATE INDEX [item_ident] ON [phpbb_notifications]([item_type], [item_id]) ON [PRIMARY] GO -CREATE INDEX [item_id] ON [phpbb_notifications]([item_id]) ON [PRIMARY] -GO - -CREATE INDEX [item_pid] ON [phpbb_notifications]([item_parent_id]) ON [PRIMARY] -GO - -CREATE INDEX [user_id] ON [phpbb_notifications]([user_id]) ON [PRIMARY] -GO - -CREATE INDEX [time] ON [phpbb_notifications]([time]) ON [PRIMARY] -GO - -CREATE INDEX [unread] ON [phpbb_notifications]([unread]) ON [PRIMARY] -GO - -CREATE INDEX [is_enabled] ON [phpbb_notifications]([is_enabled]) ON [PRIMARY] +CREATE INDEX [user] ON [phpbb_notifications]([user_id], [unread]) ON [PRIMARY] GO diff --git a/phpBB/install/schemas/mysql_40_schema.sql b/phpBB/install/schemas/mysql_40_schema.sql index 07e529e833..4ceb664cd3 100644 --- a/phpBB/install/schemas/mysql_40_schema.sql +++ b/phpBB/install/schemas/mysql_40_schema.sql @@ -442,13 +442,8 @@ CREATE TABLE phpbb_notifications ( time int(11) UNSIGNED DEFAULT '1' NOT NULL, data blob NOT NULL, PRIMARY KEY (notification_id), - KEY item_type (item_type), - KEY item_id (item_id), - KEY item_pid (item_parent_id), - KEY user_id (user_id), - KEY time (time), - KEY unread (unread), - KEY is_enabled (is_enabled) + KEY item_ident (item_type, item_id), + KEY user (user_id, unread) ); diff --git a/phpBB/install/schemas/mysql_41_schema.sql b/phpBB/install/schemas/mysql_41_schema.sql index 361f53c313..423b97567a 100644 --- a/phpBB/install/schemas/mysql_41_schema.sql +++ b/phpBB/install/schemas/mysql_41_schema.sql @@ -442,13 +442,8 @@ CREATE TABLE phpbb_notifications ( time int(11) UNSIGNED DEFAULT '1' NOT NULL, data text NOT NULL, PRIMARY KEY (notification_id), - KEY item_type (item_type), - KEY item_id (item_id), - KEY item_pid (item_parent_id), - KEY user_id (user_id), - KEY time (time), - KEY unread (unread), - KEY is_enabled (is_enabled) + KEY item_ident (item_type, item_id), + KEY user (user_id, unread) ) CHARACTER SET `utf8` COLLATE `utf8_bin`; diff --git a/phpBB/install/schemas/oracle_schema.sql b/phpBB/install/schemas/oracle_schema.sql index a2bb016dae..b3ea3c7d5e 100644 --- a/phpBB/install/schemas/oracle_schema.sql +++ b/phpBB/install/schemas/oracle_schema.sql @@ -857,19 +857,9 @@ CREATE TABLE phpbb_notifications ( ) / -CREATE INDEX phpbb_notifications_item_type ON phpbb_notifications (item_type) +CREATE INDEX phpbb_notifications_item_ident ON phpbb_notifications (item_type, item_id) / -CREATE INDEX phpbb_notifications_item_id ON phpbb_notifications (item_id) -/ -CREATE INDEX phpbb_notifications_item_pid ON phpbb_notifications (item_parent_id) -/ -CREATE INDEX phpbb_notifications_user_id ON phpbb_notifications (user_id) -/ -CREATE INDEX phpbb_notifications_time ON phpbb_notifications (time) -/ -CREATE INDEX phpbb_notifications_unread ON phpbb_notifications (unread) -/ -CREATE INDEX phpbb_notifications_is_enabled ON phpbb_notifications (is_enabled) +CREATE INDEX phpbb_notifications_user ON phpbb_notifications (user_id, unread) / CREATE SEQUENCE phpbb_notifications_seq diff --git a/phpBB/install/schemas/postgres_schema.sql b/phpBB/install/schemas/postgres_schema.sql index 94926d0b7a..e43b64468d 100644 --- a/phpBB/install/schemas/postgres_schema.sql +++ b/phpBB/install/schemas/postgres_schema.sql @@ -614,13 +614,8 @@ CREATE TABLE phpbb_notifications ( PRIMARY KEY (notification_id) ); -CREATE INDEX phpbb_notifications_item_type ON phpbb_notifications (item_type); -CREATE INDEX phpbb_notifications_item_id ON phpbb_notifications (item_id); -CREATE INDEX phpbb_notifications_item_pid ON phpbb_notifications (item_parent_id); -CREATE INDEX phpbb_notifications_user_id ON phpbb_notifications (user_id); -CREATE INDEX phpbb_notifications_time ON phpbb_notifications (time); -CREATE INDEX phpbb_notifications_unread ON phpbb_notifications (unread); -CREATE INDEX phpbb_notifications_is_enabled ON phpbb_notifications (is_enabled); +CREATE INDEX phpbb_notifications_item_ident ON phpbb_notifications (item_type, item_id); +CREATE INDEX phpbb_notifications_user ON phpbb_notifications (user_id, unread); /* Table: 'phpbb_poll_options' diff --git a/phpBB/install/schemas/sqlite_schema.sql b/phpBB/install/schemas/sqlite_schema.sql index 43611ef70b..e3b556668d 100644 --- a/phpBB/install/schemas/sqlite_schema.sql +++ b/phpBB/install/schemas/sqlite_schema.sql @@ -430,13 +430,8 @@ CREATE TABLE phpbb_notifications ( data text(65535) NOT NULL DEFAULT '' ); -CREATE INDEX phpbb_notifications_item_type ON phpbb_notifications (item_type); -CREATE INDEX phpbb_notifications_item_id ON phpbb_notifications (item_id); -CREATE INDEX phpbb_notifications_item_pid ON phpbb_notifications (item_parent_id); -CREATE INDEX phpbb_notifications_user_id ON phpbb_notifications (user_id); -CREATE INDEX phpbb_notifications_time ON phpbb_notifications (time); -CREATE INDEX phpbb_notifications_unread ON phpbb_notifications (unread); -CREATE INDEX phpbb_notifications_is_enabled ON phpbb_notifications (is_enabled); +CREATE INDEX phpbb_notifications_item_ident ON phpbb_notifications (item_type, item_id); +CREATE INDEX phpbb_notifications_user ON phpbb_notifications (user_id, unread); # Table: 'phpbb_poll_options' CREATE TABLE phpbb_poll_options ( From c0534f9e5d1527426f5a80276cf8a08323334ef1 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Sat, 8 Dec 2012 14:28:38 -0600 Subject: [PATCH 0579/2494] [ticket/11103] User Loader constructor docs PHPBB3-11103 --- phpBB/includes/user_loader.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/phpBB/includes/user_loader.php b/phpBB/includes/user_loader.php index c7a6a103f8..914770e335 100644 --- a/phpBB/includes/user_loader.php +++ b/phpBB/includes/user_loader.php @@ -43,6 +43,14 @@ class phpbb_user_loader */ protected $users = array(); + /** + * User loader constructor + * + * @param dbal $db A database connection + * @param string $phpbb_root_path Path to the phpbb includes directory. + * @param string $php_ext php file extension + * @param string $users_table The name of the database table (phpbb_users) + */ public function __construct(dbal $db, $phpbb_root_path, $php_ext, $users_table) { $this->db = $db; From 37565f37e4363f257a160145bc7973a2d5738a86 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Sat, 8 Dec 2012 18:40:41 -0600 Subject: [PATCH 0580/2494] [ticket/11103] Some improvements to the user loader PHPBB3-11103 --- phpBB/includes/notification/type/pm.php | 4 +- phpBB/includes/notification/type/post.php | 8 +- .../includes/notification/type/report_pm.php | 6 +- .../notification/type/report_pm_closed.php | 4 +- .../notification/type/report_post.php | 4 +- .../notification/type/report_post_closed.php | 4 +- phpBB/includes/notification/type/topic.php | 8 +- phpBB/includes/user_loader.php | 117 +++++++++++++++++- tests/user/user_loader.php | 15 +-- 9 files changed, 129 insertions(+), 41 deletions(-) diff --git a/phpBB/includes/notification/type/pm.php b/phpBB/includes/notification/type/pm.php index 1eaeb1a250..8d31c87817 100644 --- a/phpBB/includes/notification/type/pm.php +++ b/phpBB/includes/notification/type/pm.php @@ -112,9 +112,7 @@ class phpbb_notification_type_pm extends phpbb_notification_type_base */ public function get_title() { - $user_data = $this->user_loader->get_user($this->get_data('from_user_id')); - - $username = get_username_string('no_profile', $user_data['user_id'], $user_data['username'], $user_data['user_colour']); + $username = $this->user_loader->get_username($this->get_data('from_user_id'), 'no_profile'); return $this->user->lang('NOTIFICATION_PM', $username, $this->get_data('message_subject')); } diff --git a/phpBB/includes/notification/type/post.php b/phpBB/includes/notification/type/post.php index 7e06779982..0646282c94 100644 --- a/phpBB/includes/notification/type/post.php +++ b/phpBB/includes/notification/type/post.php @@ -181,9 +181,7 @@ class phpbb_notification_type_post extends phpbb_notification_type_base } else { - $user_data = $this->user_loader->get_user($responder['poster_id']); - - $usernames[] = get_username_string('no_profile', $user_data['user_id'], $user_data['username'], $user_data['user_colour']); + $usernames[] = $this->user_loader->get_username($responder['poster_id'], 'no_profile'); } } @@ -217,9 +215,7 @@ class phpbb_notification_type_post extends phpbb_notification_type_base } else { - $user_data = $this->user_loader->get_user($this->get_data('poster_id')); - - $username = get_username_string('username', $user_data['user_id'], $user_data['username'], $user_data['user_colour']); + $username = $this->user_loader->get_username($this->get_data('poster_id'), 'no_profile'); } return array( diff --git a/phpBB/includes/notification/type/report_pm.php b/phpBB/includes/notification/type/report_pm.php index 73e22dc83b..877e8209e3 100644 --- a/phpBB/includes/notification/type/report_pm.php +++ b/phpBB/includes/notification/type/report_pm.php @@ -160,9 +160,7 @@ class phpbb_notification_type_report_pm extends phpbb_notification_type_pm { $this->user->add_lang('mcp'); - $user_data = $this->user_loader->get_user($this->get_data('reporter_id')); - - $username = get_username_string('no_profile', $user_data['user_id'], $user_data['username'], $user_data['user_colour']); + $username = $this->user_loader->get_username($this->get_data('reporter_id'), 'no_profile'); if ($this->get_data('report_text')) { @@ -186,7 +184,7 @@ class phpbb_notification_type_report_pm extends phpbb_notification_type_pm return $this->user->lang( $this->language_key, - $username, + $username, censor_text($this->get_data('message_subject')), $this->get_data('reason_description') ); diff --git a/phpBB/includes/notification/type/report_pm_closed.php b/phpBB/includes/notification/type/report_pm_closed.php index 51e5204304..2d60ae21d4 100644 --- a/phpBB/includes/notification/type/report_pm_closed.php +++ b/phpBB/includes/notification/type/report_pm_closed.php @@ -106,9 +106,7 @@ class phpbb_notification_type_report_pm_closed extends phpbb_notification_type_p */ public function get_title() { - $user_data = $this->user_loader->get_user($this->get_data('closer_id')); - - $username = get_username_string('no_profile', $user_data['user_id'], $user_data['username'], $user_data['user_colour']); + $username = $this->user_loader->get_username($this->get_data('closer_id'), 'no_profile'); return $this->user->lang( $this->language_key, diff --git a/phpBB/includes/notification/type/report_post.php b/phpBB/includes/notification/type/report_post.php index 2508644b0b..0334fdb109 100644 --- a/phpBB/includes/notification/type/report_post.php +++ b/phpBB/includes/notification/type/report_post.php @@ -127,9 +127,7 @@ class phpbb_notification_type_report_post extends phpbb_notification_type_post_i { $this->user->add_lang('mcp'); - $user_data = $this->user_loader->get_user($this->get_data('reporter_id')); - - $username = get_username_string('no_profile', $user_data['user_id'], $user_data['username'], $user_data['user_colour']); + $username = $this->user_loader->get_username($this->get_data('reporter_id'), 'no_profile'); if ($this->get_data('report_text')) { diff --git a/phpBB/includes/notification/type/report_post_closed.php b/phpBB/includes/notification/type/report_post_closed.php index a7016a8f3d..3282ba7d8c 100644 --- a/phpBB/includes/notification/type/report_post_closed.php +++ b/phpBB/includes/notification/type/report_post_closed.php @@ -106,9 +106,7 @@ class phpbb_notification_type_report_post_closed extends phpbb_notification_type */ public function get_title() { - $user_data = $this->user_loader->get_user($this->get_data('closer_id')); - - $username = get_username_string('no_profile', $user_data['user_id'], $user_data['username'], $user_data['user_colour']); + $username = $this->user_loader->get_username($this->get_data('closer_id'), 'no_profile'); return $this->user->lang( $this->language_key, diff --git a/phpBB/includes/notification/type/topic.php b/phpBB/includes/notification/type/topic.php index 6e9347d4a8..614d644501 100644 --- a/phpBB/includes/notification/type/topic.php +++ b/phpBB/includes/notification/type/topic.php @@ -142,9 +142,7 @@ class phpbb_notification_type_topic extends phpbb_notification_type_base } else { - $user_data = $this->user_loader->get_user($this->get_data('poster_id')); - - $username = get_username_string('no_profile', $user_data['user_id'], $user_data['username'], $user_data['user_colour']); + $username = $this->user_loader->get_username($this->get_data('poster_id'), 'no_profile'); } return $this->user->lang( @@ -178,9 +176,7 @@ class phpbb_notification_type_topic extends phpbb_notification_type_base } else { - $user_data = $this->user_loader->get_user($this->get_data('poster_id')); - - $username = get_username_string('username', $user_data['user_id'], $user_data['username'], $user_data['user_colour']); + $username = $this->user_loader->get_username($this->get_data('poster_id'), 'no_profile'); } return array( diff --git a/phpBB/includes/user_loader.php b/phpBB/includes/user_loader.php index 914770e335..db12854a60 100644 --- a/phpBB/includes/user_loader.php +++ b/phpBB/includes/user_loader.php @@ -91,27 +91,100 @@ class phpbb_user_loader } } + /** + * Load a user by username + * + * Stores the full data in the user cache so they do not need to be loaded again + * Returns the user id so you may use get_user() from the returned value + * + * @param string $username Raw username to load (will be cleaned) + * @return int User ID for the username + */ + public function load_user_by_username($username) + { + $sql = 'SELECT * + FROM ' . $this->users_table . " + WHERE username_clean = '" . $this->db->sql_escape(utf8_clean_string($username)) . "'"; + $result = $this->db->sql_query($sql); + $row = $this->db->sql_fetchrow($result); + $this->db->sql_freeresult($result); + + if ($row) + { + $this->users[$row['user_id']] = $row; + + return $row['user_id']; + } + + return ANONYMOUS; + } + /** * Get a user row from our users cache * - * @param int $user_id + * @param int $user_id User ID of the user you want to retreive + * @param bool $query Should we query the database if this user has not yet been loaded? + * Typically this should be left as false and you should make sure + * you load users ahead of time with load_users() * @return array|bool Row from the database of the user or Anonymous if the user wasn't loaded/does not exist * or bool False if the anonymous user was not loaded */ - public function get_user($user_id) + public function get_user($user_id, $query = false) { - return (isset($this->users[$user_id])) ? $this->users[$user_id] : (isset($this->users[ANONYMOUS]) ? $this->users[ANONYMOUS] : false); + if (isset($this->users[$user_id])) + { + return $this->users[$user_id]; + } + // Query them if we must (if ANONYMOUS is sent as the user_id and we have not loaded Anonymous yet, we must load Anonymous as a last resort) + else if ($query || $user_id == ANONYMOUS) + { + $this->load_users(array($user_id)); + + return $this->get_user($user_id); + } + + return $this->get_user(ANONYMOUS); + } + + /** + * Get username + * + * @param int $user_id User ID of the user you want to retreive the username for + * @param string $mode The mode to load (same as get_username_string). One of the following: + * profile (for getting an url to the profile) + * username (for obtaining the username) + * colour (for obtaining the user colour) + * full (for obtaining a html string representing a coloured link to the users profile) + * no_profile (the same as full but forcing no profile link) + * @param string $guest_username Optional parameter to specify the guest username. It will be used in favor of the GUEST language variable then. + * @param string $custom_profile_url Optional parameter to specify a profile url. The user id get appended to this url as &u={user_id} + * @param bool $query Should we query the database if this user has not yet been loaded? + * Typically this should be left as false and you should make sure + * you load users ahead of time with load_users() + * @return string + */ + public function get_username($user_id, $mode, $guest_username = false, $custom_profile_url = false, $query = false) + { + if (!($user = $this->get_user($user_id, $query))) + { + return ''; + } + + return get_username_string($mode, $user['user_id'], $user['username'], $user['user_colour'], $guest_username, $custom_profile_url); } /** * Get avatar * - * @param int $user_id + * @param int $user_id User ID of the user you want to retreive the avatar for + * @param bool $query Should we query the database if this user has not yet been loaded? + * Typically this should be left as false and you should make sure + * you load users ahead of time with load_users() * @return string */ - public function get_avatar($user_id) + public function get_avatar($user_id, $query = false) { - if (!($user = $this->get_user($user_id))) + if (!($user = $this->get_user($user_id, $query))) { return ''; } @@ -123,4 +196,36 @@ class phpbb_user_loader return get_user_avatar($user['user_avatar'], $user['user_avatar_type'], $user['user_avatar_width'], $user['user_avatar_height']); } + + /** + * Get rank + * + * @param int $user_id User ID of the user you want to retreive the rank for + * @param bool $query Should we query the database if this user has not yet been loaded? + * Typically this should be left as false and you should make sure + * you load users ahead of time with load_users() + * @return array Array with keys 'rank_title', 'rank_img', and 'rank_img_src' + */ + public function get_rank($user_id, $query = false) + { + if (!($user = $this->get_user($user_id, $query))) + { + return ''; + } + + if (!function_exists('get_user_rank')) + { + include($this->phpbb_root_path . 'includes/functions_display.' . $this->php_ext); + } + + $rank = array( + 'rank_title', + 'rank_img', + 'rank_img_src', + ); + + get_user_rank($user['user_rank'], (($user['user_id'] == ANONYMOUS) ? false : $user['user_posts']), $rank['rank_title'], $rank['rank_img'], $rank['rank_img_src']); + + return $rank; + } } diff --git a/tests/user/user_loader.php b/tests/user/user_loader.php index 145bfc9549..0beb804729 100644 --- a/tests/user/user_loader.php +++ b/tests/user/user_loader.php @@ -7,6 +7,8 @@ * */ +include_once(__DIR__ . '/../../phpBB/includes/utf/utf_tools.php'); + class phpbb_user_lang_test extends phpbb_database_test_case { public function getDataSet() @@ -18,7 +20,7 @@ class phpbb_user_lang_test extends phpbb_database_test_case { $db = $this->new_dbal(); - $user_loader = new phpbb_user_loader($db, __DIR__ . '../../phpBB', 'php', 'phpbb_users'); + $user_loader = new phpbb_user_loader($db, __DIR__ . '/../../phpBB/', 'php', 'phpbb_users'); $user_loader->load_users(array(2)); @@ -35,13 +37,12 @@ class phpbb_user_lang_test extends phpbb_database_test_case $this->assertEquals(1, $user['user_id']); $this->assertEquals('Guest', $user['username']); - $user_loader->load_users(array(3)); + $user = $user_loader->get_user(3, true); + $this->assertEquals(3, $user['user_id']); + $this->assertEquals('Test', $user['username']); - $user = $user_loader->get_user(2); - $this->assertEquals(2, $user['user_id']); - $this->assertEquals('Admin', $user['username']); - - $user = $user_loader->get_user(3); + $user_id = $user_loader->load_user_by_username('Test'); + $user = $user_loader->get_user($user_id); $this->assertEquals(3, $user['user_id']); $this->assertEquals('Test', $user['username']); } From 26bde05a30c7111b57621a37d86425aa69d74263 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 9 Dec 2012 19:42:50 +0100 Subject: [PATCH 0581/2494] [feature/avatars] Call set_name() method in avatars.yml This is needed after 8a28271d was merged. PHPBB3-10018 --- phpBB/config/avatars.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/phpBB/config/avatars.yml b/phpBB/config/avatars.yml index cc9ed05836..e6106038f5 100644 --- a/phpBB/config/avatars.yml +++ b/phpBB/config/avatars.yml @@ -7,6 +7,8 @@ services: - %core.root_path% - .%core.php_ext% - @cache.driver + calls: + - [set_name, [avatar.driver.gravatar]] tags: - { name: avatar.driver } @@ -18,6 +20,8 @@ services: - %core.root_path% - .%core.php_ext% - @cache.driver + calls: + - [set_name, [avatar.driver.local]] tags: - { name: avatar.driver } @@ -29,6 +33,8 @@ services: - %core.root_path% - .%core.php_ext% - @cache.driver + calls: + - [set_name, [avatar.driver.remote]] tags: - { name: avatar.driver } @@ -40,5 +46,7 @@ services: - %core.root_path% - .%core.php_ext% - @cache.driver + calls: + - [set_name, [avatar.driver.upload]] tags: - { name: avatar.driver } From 84284a9ccee7d5ccc658c3d1f751a5254b3b9175 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Sun, 9 Dec 2012 13:43:06 -0600 Subject: [PATCH 0582/2494] [ticket/11103] Use scope: prototype This lets us clean up the mess that was in load_object(), but requires scope: prototype to be added to the service definitions for all types or methods! PHPBB3-11103 --- phpBB/config/notifications.yml | 17 +++++++++++++++++ phpBB/includes/notification/manager.php | 20 +------------------- tests/notification/notification.php | 2 +- 3 files changed, 19 insertions(+), 20 deletions(-) diff --git a/phpBB/config/notifications.yml b/phpBB/config/notifications.yml index 5a593c44d6..550fbdfd0c 100644 --- a/phpBB/config/notifications.yml +++ b/phpBB/config/notifications.yml @@ -15,6 +15,7 @@ services: notification.type.approve_post: class: phpbb_notification_type_approve_post + scope: prototype # scope MUST be prototype for this to work! # scope MUST be prototype for this to work! arguments: - @user_loader - @dbal.conn @@ -31,6 +32,7 @@ services: notification.type.approve_topic: class: phpbb_notification_type_approve_topic + scope: prototype # scope MUST be prototype for this to work! arguments: - @user_loader - @dbal.conn @@ -47,6 +49,7 @@ services: notification.type.bookmark: class: phpbb_notification_type_bookmark + scope: prototype # scope MUST be prototype for this to work! arguments: - @user_loader - @dbal.conn @@ -63,6 +66,7 @@ services: notification.type.disapprove_post: class: phpbb_notification_type_disapprove_post + scope: prototype # scope MUST be prototype for this to work! arguments: - @user_loader - @dbal.conn @@ -79,6 +83,7 @@ services: notification.type.disapprove_topic: class: phpbb_notification_type_disapprove_topic + scope: prototype # scope MUST be prototype for this to work! arguments: - @user_loader - @dbal.conn @@ -95,6 +100,7 @@ services: notification.type.pm: class: phpbb_notification_type_pm + scope: prototype # scope MUST be prototype for this to work! arguments: - @user_loader - @dbal.conn @@ -111,6 +117,7 @@ services: notification.type.post: class: phpbb_notification_type_post + scope: prototype # scope MUST be prototype for this to work! arguments: - @user_loader - @dbal.conn @@ -127,6 +134,7 @@ services: notification.type.post_in_queue: class: phpbb_notification_type_post_in_queue + scope: prototype # scope MUST be prototype for this to work! arguments: - @user_loader - @dbal.conn @@ -143,6 +151,7 @@ services: notification.type.quote: class: phpbb_notification_type_quote + scope: prototype # scope MUST be prototype for this to work! arguments: - @user_loader - @dbal.conn @@ -159,6 +168,7 @@ services: notification.type.report_pm: class: phpbb_notification_type_report_pm + scope: prototype # scope MUST be prototype for this to work! arguments: - @user_loader - @dbal.conn @@ -175,6 +185,7 @@ services: notification.type.report_pm_closed: class: phpbb_notification_type_report_pm_closed + scope: prototype # scope MUST be prototype for this to work! arguments: - @user_loader - @dbal.conn @@ -191,6 +202,7 @@ services: notification.type.report_post: class: phpbb_notification_type_report_post + scope: prototype # scope MUST be prototype for this to work! arguments: - @user_loader - @dbal.conn @@ -207,6 +219,7 @@ services: notification.type.report_post_closed: class: phpbb_notification_type_report_post + scope: prototype # scope MUST be prototype for this to work! arguments: - @user_loader - @dbal.conn @@ -223,6 +236,7 @@ services: notification.type.topic: class: phpbb_notification_type_topic + scope: prototype # scope MUST be prototype for this to work! arguments: - @user_loader - @dbal.conn @@ -239,6 +253,7 @@ services: notification.type.topic_in_queue: class: phpbb_notification_type_topic_in_queue + scope: prototype # scope MUST be prototype for this to work! arguments: - @user_loader - @dbal.conn @@ -255,6 +270,7 @@ services: notification.method.email: class: phpbb_notification_method_email + scope: prototype # scope MUST be prototype for this to work! arguments: - @user_loader - @dbal.conn @@ -269,6 +285,7 @@ services: notification.method.jabber: class: phpbb_notification_method_jabber + scope: prototype # scope MUST be prototype for this to work! arguments: - @user_loader - @dbal.conn diff --git a/phpBB/includes/notification/manager.php b/phpBB/includes/notification/manager.php index 4c25fa72f0..22f8f58783 100644 --- a/phpBB/includes/notification/manager.php +++ b/phpBB/includes/notification/manager.php @@ -779,24 +779,6 @@ class phpbb_notification_manager */ protected function load_object($object_name) { - // Here we cannot just use ContainerBuilder->get(name) - // The reason for this is because get handles services - // which are initialized once and shared. Here we need - // separate new objects because we pass around objects - // that store row data in each object, which would lead - // to over-writing of data if we used get() - - $parameterBag = $this->phpbb_container->getParameterBag(); - $definition = $this->phpbb_container->getDefinition($object_name); - $arguments = $this->phpbb_container->resolveServices( - $parameterBag->unescapeValue($parameterBag->resolveValue($definition->getArguments())) - ); - $r = new \ReflectionClass($parameterBag->resolveValue($definition->getClass())); - - $object = null === $r->getConstructor() ? $r->newInstance() : $r->newInstanceArgs($arguments); - - $object->set_notification_manager($this); - - return $object; + return $this->phpbb_container->get($object_name); } } diff --git a/tests/notification/notification.php b/tests/notification/notification.php index e4522c2cdc..2f2a404216 100644 --- a/tests/notification/notification.php +++ b/tests/notification/notification.php @@ -37,7 +37,7 @@ class phpbb_notification_test extends phpbb_database_test_case 'allow_forum_notify' => true, )); $this->user = new phpbb_mock_user(); - $this->user_loader = new phpbb_user_loader($this->db, 'phpbb_users'); + $this->user_loader = new phpbb_user_loader($this->db, $phpbb_root_path, $phpEx, 'phpbb_users'); $this->auth = new phpbb_mock_notifications_auth(); $this->cache = new phpbb_mock_cache(); From 83b8b65016f172baa65cbbb463015602c97e9e45 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sun, 9 Dec 2012 23:47:46 +0100 Subject: [PATCH 0583/2494] [ticket/10714] Use dependencies instead of globals We use a setter for the admin root path, as it is not defined all the time. Aswell as we added a setter for the table name, so it can still be used for custom tables. PHPBB3-10714 --- phpBB/config/services.yml | 11 +++ phpBB/config/tables.yml | 1 + phpBB/includes/log/log.php | 163 ++++++++++++++++++++++++++----------- 3 files changed, 129 insertions(+), 46 deletions(-) diff --git a/phpBB/config/services.yml b/phpBB/config/services.yml index 37e6c0b5df..73d8680803 100644 --- a/phpBB/config/services.yml +++ b/phpBB/config/services.yml @@ -154,6 +154,17 @@ services: tags: - { name: kernel.event_subscriber } + log: + class: phpbb_log + arguments: + - @dbal.conn + - @user + - @auth + - @dispatcher + - %core.root_path% + - %core.php_ext% + - %tables.log% + request: class: phpbb_request diff --git a/phpBB/config/tables.yml b/phpBB/config/tables.yml index cfc6dbcfed..b506e6c6b3 100644 --- a/phpBB/config/tables.yml +++ b/phpBB/config/tables.yml @@ -1,3 +1,4 @@ parameters: tables.config: %core.table_prefix%config tables.ext: %core.table_prefix%ext + tables.log: %core.table_prefix%log diff --git a/phpBB/includes/log/log.php b/phpBB/includes/log/log.php index c2ebedd6f2..3d9620a2ee 100644 --- a/phpBB/includes/log/log.php +++ b/phpBB/includes/log/log.php @@ -42,15 +42,96 @@ class phpbb_log implements phpbb_log_interface */ protected $log_table; + /** + * Database object + * @var dbal + */ + protected $db; + + /** + * User object + * @var phpbb_user + */ + protected $user; + + /** + * Auth object + * @var phpbb_auth + */ + protected $auth; + + /** + * Event dispatcher object + * @var phpbb_dispatcher + */ + protected $dispatcher; + + /** + * phpBB root path + * @var string + */ + protected $phpbb_root_path; + + /** + * Admin root path + * @var string + */ + protected $phpbb_admin_path; + + /** + * PHP Extension + * @var string + */ + protected $php_ext; + /** * Constructor * - * @param string $log_table The table we use to store our logs + * @param dbal $db Database object + * @param phpbb_user $user User object + * @param phpbb_auth $auth Auth object + * @param phpbb_dispatcher $phpbb_dispatcher Event dispatcher + * @param string $phpbb_root_path Root path + * @param string $php_ext PHP Extension + * @param string $log_table Name of the table we use to store our logs + * @return null */ - public function __construct($log_table) + public function __construct(dbal $db, phpbb_user $user, phpbb_auth $auth, phpbb_dispatcher $phpbb_dispatcher, $phpbb_root_path, $php_ext, $log_table) + { + $this->db = $db; + $this->user = $user; + $this->auth = $auth; + $this->dispatcher = $phpbb_dispatcher; + $this->phpbb_root_path = $phpbb_root_path; + $this->php_ext = $php_ext; + $this->log_table = $log_table; + + $this->enable(); + $this->set_admin_path('', false); + } + + /** + * Set phpbb_admin_path and is_in_admin in order to return administrative user profile links in get_logs() + * + * @param string $phpbb_admin_path Full path from current file to admin root + * @param bool $is_in_admin Are we called from within the acp? + * @return null + */ + public function set_admin_path($phpbb_admin_path, $is_in_admin) + { + $this->phpbb_admin_path = $phpbb_admin_path; + $this->is_in_admin = (bool) $is_in_admin; + } + + /** + * Set table name + * + * @param string $log_table Can overwrite the table to use for the logs + * @return null + */ + public function set_log_table($log_table) { $this->log_table = $log_table; - $this->enable(); } /** @@ -134,8 +215,6 @@ class phpbb_log implements phpbb_log_interface return false; } - global $db, $phpbb_dispatcher; - if ($log_time == false) { $log_time = time(); @@ -208,7 +287,7 @@ class phpbb_log implements phpbb_log_interface * @since 3.1-A1 */ $vars = array('mode', 'user_id', 'log_ip', 'log_operation', 'log_time', 'additional_data', 'sql_ary'); - extract($phpbb_dispatcher->trigger_event('core.add_log', $vars)); + extract($this->dispatcher->trigger_event('core.add_log', $vars)); // We didn't find a log_type, so we don't save it in the database. if (!isset($sql_ary['log_type'])) @@ -216,9 +295,9 @@ class phpbb_log implements phpbb_log_interface return false; } - $db->sql_query('INSERT INTO ' . $this->log_table . ' ' . $db->sql_build_array('INSERT', $sql_ary)); + $this->db->sql_query('INSERT INTO ' . $this->log_table . ' ' . $this->db->sql_build_array('INSERT', $sql_ary)); - return $db->sql_nextid(); + return $this->db->sql_nextid(); } /** @@ -228,14 +307,12 @@ class phpbb_log implements phpbb_log_interface */ public function get_logs($mode, $count_logs = true, $limit = 0, $offset = 0, $forum_id = 0, $topic_id = 0, $user_id = 0, $log_time = 0, $sort_by = 'l.log_time DESC', $keywords = '') { - global $db, $user, $auth, $phpEx, $phpbb_root_path, $phpbb_admin_path, $phpbb_dispatcher; - $this->logs_total = 0; $this->logs_offset = $offset; $topic_id_list = $reportee_id_list = array(); - $profile_url = (defined('IN_ADMIN')) ? append_sid("{$phpbb_admin_path}index.$phpEx", 'i=users&mode=overview') : append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=viewprofile'); + $profile_url = ($this->is_in_admin && $this->phpbb_admin_path) ? append_sid("{$this->phpbb_admin_path}index.{$this->php_ext}", 'i=users&mode=overview') : append_sid("{$this->phpbb_root_path}memberlist.{$this->php_ext}", 'mode=viewprofile'); switch ($mode) { @@ -254,7 +331,7 @@ class phpbb_log implements phpbb_log_interface } else if (is_array($forum_id)) { - $sql_additional = 'AND ' . $db->sql_in_set('l.forum_id', array_map('intval', $forum_id)); + $sql_additional = 'AND ' . $this->db->sql_in_set('l.forum_id', array_map('intval', $forum_id)); } else if ($forum_id) { @@ -308,7 +385,7 @@ class phpbb_log implements phpbb_log_interface * @since 3.1-A1 */ $vars = array('mode', 'count_logs', 'limit', 'offset', 'forum_id', 'topic_id', 'user_id', 'log_time', 'sort_by', 'keywords', 'profile_url', 'log_type', 'sql_additional'); - extract($phpbb_dispatcher->trigger_event('core.get_logs_modify_type', $vars)); + extract($this->dispatcher->trigger_event('core.get_logs_modify_type', $vars)); if ($log_type === false) { @@ -332,9 +409,9 @@ class phpbb_log implements phpbb_log_interface AND l.log_time >= $log_time $sql_keywords $sql_additional"; - $result = $db->sql_query($sql); - $this->logs_total = (int) $db->sql_fetchfield('total_entries'); - $db->sql_freeresult($result); + $result = $this->db->sql_query($sql); + $this->logs_total = (int) $this->db->sql_fetchfield('total_entries'); + $this->db->sql_freeresult($result); if ($this->logs_total == 0) { @@ -358,11 +435,11 @@ class phpbb_log implements phpbb_log_interface $sql_keywords $sql_additional ORDER BY $sort_by"; - $result = $db->sql_query_limit($sql, $limit, $this->logs_offset); + $result = $this->db->sql_query_limit($sql, $limit, $this->logs_offset); $i = 0; $log = array(); - while ($row = $db->sql_fetchrow($result)) + while ($row = $this->db->sql_fetchrow($result)) { $row['forum_id'] = (int) $row['forum_id']; if ($row['topic_id']) @@ -391,8 +468,8 @@ class phpbb_log implements phpbb_log_interface 'forum_id' => (int) $row['forum_id'], 'topic_id' => (int) $row['topic_id'], - 'viewforum' => ($row['forum_id'] && $auth->acl_get('f_read', $row['forum_id'])) ? append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $row['forum_id']) : false, - 'action' => (isset($user->lang[$row['log_operation']])) ? $user->lang[$row['log_operation']] : '{' . ucfirst(str_replace('_', ' ', $row['log_operation'])) . '}', + 'viewforum' => ($row['forum_id'] && $this->auth->acl_get('f_read', $row['forum_id'])) ? append_sid("{$this->phpbb_root_path}viewforum.{$this->php_ext}", 'f=' . $row['forum_id']) : false, + 'action' => (isset($this->user->lang[$row['log_operation']])) ? $this->user->lang[$row['log_operation']] : '{' . ucfirst(str_replace('_', ' ', $row['log_operation'])) . '}', ); /** @@ -404,7 +481,7 @@ class phpbb_log implements phpbb_log_interface * @since 3.1-A1 */ $vars = array('row', 'log_entry_data'); - extract($phpbb_dispatcher->trigger_event('core.get_logs_modify_entry_data', $vars)); + extract($this->dispatcher->trigger_event('core.get_logs_modify_entry_data', $vars)); $log[$i] = $log_entry_data; @@ -413,7 +490,7 @@ class phpbb_log implements phpbb_log_interface $log_data_ary = @unserialize($row['log_data']); $log_data_ary = ($log_data_ary !== false) ? $log_data_ary : array(); - if (isset($user->lang[$row['log_operation']])) + if (isset($this->user->lang[$row['log_operation']])) { // Check if there are more occurrences of % than arguments, if there are we fill out the arguments array // It doesn't matter if we add more arguments than placeholders @@ -447,7 +524,7 @@ class phpbb_log implements phpbb_log_interface $i++; } - $db->sql_freeresult($result); + $this->db->sql_freeresult($result); /** * Get some additional data after we got all log entries @@ -461,7 +538,7 @@ class phpbb_log implements phpbb_log_interface * @since 3.1-A1 */ $vars = array('log', 'topic_id_list', 'reportee_id_list'); - extract($phpbb_dispatcher->trigger_event('core.get_logs_get_additional_data', $vars)); + extract($this->dispatcher->trigger_event('core.get_logs_get_additional_data', $vars)); if (sizeof($topic_id_list)) { @@ -469,8 +546,8 @@ class phpbb_log implements phpbb_log_interface foreach ($log as $key => $row) { - $log[$key]['viewtopic'] = (isset($topic_auth['f_read'][$row['topic_id']])) ? append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $topic_auth['f_read'][$row['topic_id']] . '&t=' . $row['topic_id']) : false; - $log[$key]['viewlogs'] = (isset($topic_auth['m_'][$row['topic_id']])) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=logs&mode=topic_logs&t=' . $row['topic_id'], true, $user->session_id) : false; + $log[$key]['viewtopic'] = (isset($topic_auth['f_read'][$row['topic_id']])) ? append_sid("{$this->phpbb_root_path}viewtopic.{$this->php_ext}", 'f=' . $topic_auth['f_read'][$row['topic_id']] . '&t=' . $row['topic_id']) : false; + $log[$key]['viewlogs'] = (isset($topic_auth['m_'][$row['topic_id']])) ? append_sid("{$this->phpbb_root_path}mcp.{$this->php_ext}", 'i=logs&mode=topic_logs&t=' . $row['topic_id'], true, $this->user->session_id) : false; } } @@ -502,8 +579,6 @@ class phpbb_log implements phpbb_log_interface */ private function generate_sql_keyword($keywords) { - global $db, $user; - // Use no preg_quote for $keywords because this would lead to sole backslashes being added // We also use an OR connection here for spaces and the | string. Currently, regex is not supported for searching (but may come later). $keywords = preg_split('#[\s|]+#u', utf8_strtolower($keywords), 0, PREG_SPLIT_NO_EMPTY); @@ -517,13 +592,13 @@ class phpbb_log implements phpbb_log_interface for ($i = 0, $num_keywords = sizeof($keywords); $i < $num_keywords; $i++) { $keywords_pattern[] = preg_quote($keywords[$i], '#'); - $keywords[$i] = $db->sql_like_expression($db->any_char . $keywords[$i] . $db->any_char); + $keywords[$i] = $this->db->sql_like_expression($this->db->any_char . $keywords[$i] . $this->db->any_char); } $keywords_pattern = '#' . implode('|', $keywords_pattern) . '#ui'; $operations = array(); - foreach ($user->lang as $key => $value) + foreach ($this->user->lang as $key => $value) { if (substr($key, 0, 4) == 'LOG_' && preg_match($keywords_pattern, $value)) { @@ -534,9 +609,9 @@ class phpbb_log implements phpbb_log_interface $sql_keywords = 'AND ('; if (!empty($operations)) { - $sql_keywords .= $db->sql_in_set('l.log_operation', $operations) . ' OR '; + $sql_keywords .= $this->db->sql_in_set('l.log_operation', $operations) . ' OR '; } - $sql_lower = $db->sql_lower_text('l.log_data'); + $sql_lower = $this->db->sql_lower_text('l.log_data'); $sql_keywords .= " $sql_lower " . implode(" OR $sql_lower ", $keywords) . ')'; } @@ -557,32 +632,30 @@ class phpbb_log implements phpbb_log_interface */ private function get_topic_auth($topic_ids) { - global $auth, $db; - $forum_auth = array('f_read' => array(), 'm_' => array()); $topic_ids = array_unique($topic_ids); $sql = 'SELECT topic_id, forum_id FROM ' . TOPICS_TABLE . ' - WHERE ' . $db->sql_in_set('topic_id', array_map('intval', $topic_ids)); - $result = $db->sql_query($sql); + WHERE ' . $this->db->sql_in_set('topic_id', array_map('intval', $topic_ids)); + $result = $this->db->sql_query($sql); - while ($row = $db->sql_fetchrow($result)) + while ($row = $this->db->sql_fetchrow($result)) { $row['topic_id'] = (int) $row['topic_id']; $row['forum_id'] = (int) $row['forum_id']; - if ($auth->acl_get('f_read', $row['forum_id'])) + if ($this->auth->acl_get('f_read', $row['forum_id'])) { $forum_auth['f_read'][$row['topic_id']] = $row['forum_id']; } - if ($auth->acl_gets('a_', 'm_', $row['forum_id'])) + if ($this->auth->acl_gets('a_', 'm_', $row['forum_id'])) { $forum_auth['m_'][$row['topic_id']] = $row['forum_id']; } } - $db->sql_freeresult($result); + $this->db->sql_freeresult($result); return $forum_auth; } @@ -596,21 +669,19 @@ class phpbb_log implements phpbb_log_interface */ private function get_reportee_data($reportee_ids) { - global $db; - $reportee_ids = array_unique($reportee_ids); $reportee_data_list = array(); $sql = 'SELECT user_id, username, user_colour FROM ' . USERS_TABLE . ' - WHERE ' . $db->sql_in_set('user_id', $reportee_ids); - $result = $db->sql_query($sql); + WHERE ' . $this->db->sql_in_set('user_id', $reportee_ids); + $result = $this->db->sql_query($sql); - while ($row = $db->sql_fetchrow($result)) + while ($row = $this->db->sql_fetchrow($result)) { $reportee_data_list[$row['user_id']] = $row; } - $db->sql_freeresult($result); + $this->db->sql_freeresult($result); return $reportee_data_list; } From 6dee2539419ba2c050830b7677294603a63b559a Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Sun, 9 Dec 2012 17:01:08 -0600 Subject: [PATCH 0584/2494] [ticket/11259] Make phpbb_admin_path available everywhere PHPBB3-11259 --- phpBB/adm/index.php | 1 - phpBB/adm/style/install_header.html | 6 +++--- phpBB/adm/style/install_update_diff.html | 2 +- phpBB/adm/swatch.php | 2 -- phpBB/common.php | 4 ++++ phpBB/includes/db/dbal.php | 4 ++-- phpBB/includes/functions.php | 4 ++-- phpBB/includes/functions_install.php | 3 +++ phpBB/includes/ucp/ucp_groups.php | 6 +++--- phpBB/install/database_update.php | 8 ++++++-- phpBB/install/index.php | 16 ++++++++++------ phpBB/install/install_install.php | 4 ++-- phpBB/install/install_update.php | 11 ++++++----- phpBB/language/en/install.php | 2 +- phpBB/memberlist.php | 2 +- phpBB/viewonline.php | 2 +- 16 files changed, 45 insertions(+), 32 deletions(-) diff --git a/phpBB/adm/index.php b/phpBB/adm/index.php index e20bbe4bec..2591fa9d24 100644 --- a/phpBB/adm/index.php +++ b/phpBB/adm/index.php @@ -42,7 +42,6 @@ if (!$auth->acl_get('a_')) // We define the admin variables now, because the user is now able to use the admin related features... define('IN_ADMIN', true); -$phpbb_admin_path = (defined('PHPBB_ADMIN_PATH')) ? PHPBB_ADMIN_PATH : './'; // Some oft used variables $safe_mode = (@ini_get('safe_mode') == '1' || strtolower(@ini_get('safe_mode')) === 'on') ? true : false; diff --git a/phpBB/adm/style/install_header.html b/phpBB/adm/style/install_header.html index 6826654ded..5631b83e17 100644 --- a/phpBB/adm/style/install_header.html +++ b/phpBB/adm/style/install_header.html @@ -5,7 +5,7 @@ {META} {PAGE_TITLE} - + + + + From c83c5c7f473b8b7211560a826b84800831167f0b Mon Sep 17 00:00:00 2001 From: Michael Cullum Date: Tue, 13 Mar 2012 13:22:58 +0000 Subject: [PATCH 0691/2494] [feature/events] Add overall_header_nav template ledge Adds a ledge next to the FAQ button for extensions to put links on the navigation bar PHPBB3-9550 --- phpBB/styles/prosilver/template/overall_header.html | 1 + 1 file changed, 1 insertion(+) diff --git a/phpBB/styles/prosilver/template/overall_header.html b/phpBB/styles/prosilver/template/overall_header.html index c7aac764a5..aa931293d6 100644 --- a/phpBB/styles/prosilver/template/overall_header.html +++ b/phpBB/styles/prosilver/template/overall_header.html @@ -147,6 +147,7 @@
    - From 46c4ff46e00e4f050a5c987027a4b05e72456162 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sun, 3 Mar 2013 20:30:17 +0100 Subject: [PATCH 1129/2494] [ticket/10714] Logs are disabled for this page call only PHPBB3-10714 --- phpBB/includes/log/interface.php | 9 +++++++-- phpBB/includes/log/log.php | 9 +++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/phpBB/includes/log/interface.php b/phpBB/includes/log/interface.php index 24bf412ce0..3b459c9bdf 100644 --- a/phpBB/includes/log/interface.php +++ b/phpBB/includes/log/interface.php @@ -33,8 +33,11 @@ interface phpbb_log_interface public function is_enabled($type = ''); /** - * This function allows disabling the log system. When add_log is called - * and the type is disabled, the log will not be added to the database. + * Disable log + * + * This function allows disabling the log system or parts of it, for this + * page call. When add_log is called and the type is disabled, + * the log will not be added to the database. * * @param mixed $type The log type we want to disable. Empty to * disable all logs. Can also be an array of types. @@ -44,6 +47,8 @@ interface phpbb_log_interface public function disable($type = ''); /** + * Enable log + * * This function allows re-enabling the log system. * * @param mixed $type The log type we want to enable. Empty to diff --git a/phpBB/includes/log/log.php b/phpBB/includes/log/log.php index 8da8b63391..7a26858348 100644 --- a/phpBB/includes/log/log.php +++ b/phpBB/includes/log/log.php @@ -177,8 +177,11 @@ class phpbb_log implements phpbb_log_interface } /** - * This function allows disabling the log system. When add_log is called - * and the type is disabled, the log will not be added to the database. + * Disable log + * + * This function allows disabling the log system or parts of it, for this + * page call. When add_log is called and the type is disabled, + * the log will not be added to the database. * * {@inheritDoc} */ @@ -202,6 +205,8 @@ class phpbb_log implements phpbb_log_interface } /** + * Enable log + * * This function allows re-enabling the log system. * * {@inheritDoc} From e0328814f30d51bfac45e9c66d17b29478addd79 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sun, 3 Mar 2013 20:30:54 +0100 Subject: [PATCH 1130/2494] [ticket/10714] Use $phpbb_adm_relative_path instead of hardcoded adm/ PHPBB3-10714 --- phpBB/includes/functions_container.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/functions_container.php b/phpBB/includes/functions_container.php index 36c5ad507e..106b7d75cc 100644 --- a/phpBB/includes/functions_container.php +++ b/phpBB/includes/functions_container.php @@ -57,7 +57,7 @@ function phpbb_create_install_container($phpbb_root_path, $php_ext) $container = phpbb_create_container(array($core), $phpbb_root_path, $php_ext); $container->setParameter('core.root_path', $phpbb_root_path); - $container->setParameter('core.adm_relative_path', 'adm/'); + $container->setParameter('core.adm_relative_path', $phpbb_adm_relative_path); $container->setParameter('core.php_ext', $php_ext); $container->setParameter('core.table_prefix', ''); From e1bb76eb096673af9e106f4cbd6e328c2b4bfdb6 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 4 Mar 2013 00:25:38 +0100 Subject: [PATCH 1131/2494] [feature/avatars] Reduce module auth of ucp avatar settings Previously the avatar types that need to be enabled were hardcoded into the module auth. This is no longer needed in the new avatar system. PHPBB3-10018 --- phpBB/includes/ucp/info/ucp_profile.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/ucp/info/ucp_profile.php b/phpBB/includes/ucp/info/ucp_profile.php index 98ab0597ff..e974cea713 100644 --- a/phpBB/includes/ucp/info/ucp_profile.php +++ b/phpBB/includes/ucp/info/ucp_profile.php @@ -21,7 +21,7 @@ class ucp_profile_info 'modes' => array( 'profile_info' => array('title' => 'UCP_PROFILE_PROFILE_INFO', 'auth' => 'acl_u_chgprofileinfo', 'cat' => array('UCP_PROFILE')), 'signature' => array('title' => 'UCP_PROFILE_SIGNATURE', 'auth' => 'acl_u_sig', 'cat' => array('UCP_PROFILE')), - 'avatar' => array('title' => 'UCP_PROFILE_AVATAR', 'auth' => 'cfg_allow_avatar && (cfg_allow_avatar_local || cfg_allow_avatar_remote || cfg_allow_avatar_upload || cfg_allow_avatar_remote_upload || cfg_allow_avatar_gravatar)', 'cat' => array('UCP_PROFILE')), + 'avatar' => array('title' => 'UCP_PROFILE_AVATAR', 'auth' => 'cfg_allow_avatar', 'cat' => array('UCP_PROFILE')), 'reg_details' => array('title' => 'UCP_PROFILE_REG_DETAILS', 'auth' => '', 'cat' => array('UCP_PROFILE')), 'autologin_keys'=> array('title' => 'UCP_PROFILE_AUTOLOGIN_KEYS', 'auth' => '', 'cat' => array('UCP_PROFILE')), ), From c7ca4e445c7dc6c775e27597cd7b0968fa5fd904 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 4 Mar 2013 01:04:36 +0100 Subject: [PATCH 1132/2494] [feature/avatars] Add migrations data file for avatars The module_auth of the ucp avatar settings are used for checking if the migration has already been installed. PHPBB3-10018 --- .../db/migration/data/310/avatars.php | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 phpBB/includes/db/migration/data/310/avatars.php diff --git a/phpBB/includes/db/migration/data/310/avatars.php b/phpBB/includes/db/migration/data/310/avatars.php new file mode 100644 index 0000000000..de11a64556 --- /dev/null +++ b/phpBB/includes/db/migration/data/310/avatars.php @@ -0,0 +1,64 @@ +db->sql_query($sql); + $module_auth = $this->db->sql_fetchfield('module_auth'); + $this->db->sql_freeresult($result); + return ($module_auth == 'cfg_allow_avatar'); + } + + static public function depends_on() + { + return array('phpbb_db_migration_data_30x_3_0_11'); + } + + public function update_schema() + { + return array( + 'change_columns' => array( + $this->table_prefix . 'users' => array( + 'user_avatar_type' => array('VCHAR:255', ''), + ), + $this->table_prefix . 'groups' => array( + 'group_avatar_type' => array('VCHAR:255', ''), + ), + ), + ); + } + + public function revert_schema() + { + return array( + 'change_columns' => array( + $this->table_prefix . 'users' => array( + 'user_avatar_type' => array('TINT:2', ''), + ), + $this->table_prefix . 'groups' => array( + 'group_avatar_type' => array('TINT:2', ''), + ), + ), + ); + } + + public function update_data() + { + return array( + array('config.add', array('allow_avatar_gravatar', 0)), + ); + } +} From e4f782819968ec44f1dd207dc9de7ec703826d29 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Sun, 3 Mar 2013 19:54:22 -0600 Subject: [PATCH 1133/2494] [ticket/11386] Send list of migrations instead of using load_migrations Remove dependency of extension manager for migrator. Keeping load_migrations function for others to use if they desire but requiring the finder be sent to it in order to use it. PHPBB3-11386 --- phpBB/config/migrator.yml | 2 - phpBB/config/services.yml | 3 +- phpBB/includes/db/migrator.php | 188 ++++++++---------- phpBB/includes/extension/manager.php | 32 +-- phpBB/install/database_update.php | 8 +- phpBB/install/install_install.php | 13 +- tests/dbal/migrator_test.php | 20 +- tests/extension/manager_test.php | 23 +-- tests/extension/metadata_manager_test.php | 11 + .../phpbb_functional_test_case.php | 21 +- 10 files changed, 160 insertions(+), 161 deletions(-) diff --git a/phpBB/config/migrator.yml b/phpBB/config/migrator.yml index 42445ef9bf..999a2d41a3 100644 --- a/phpBB/config/migrator.yml +++ b/phpBB/config/migrator.yml @@ -10,8 +10,6 @@ services: - %core.php_ext% - %core.table_prefix% - @migrator.tool_collection - calls: - - [set_extension_manager, [@ext.manager]] migrator.tool_collection: class: phpbb_di_service_collection diff --git a/phpBB/config/services.yml b/phpBB/config/services.yml index 250e4a782b..3e4ae8d129 100644 --- a/phpBB/config/services.yml +++ b/phpBB/config/services.yml @@ -116,12 +116,11 @@ services: - @service_container - @dbal.conn - @config + - @migrator - %tables.ext% - %core.root_path% - .%core.php_ext% - @cache.driver - calls: - - [set_migrator, [@migrator]] ext.finder: class: phpbb_extension_finder diff --git a/phpBB/includes/db/migrator.php b/phpBB/includes/db/migrator.php index de9c06948c..b925ca5297 100644 --- a/phpBB/includes/db/migrator.php +++ b/phpBB/includes/db/migrator.php @@ -29,10 +29,7 @@ class phpbb_db_migrator protected $db; /** @var phpbb_db_tools */ - protected $db_tools; - - /** @var phpbb_extension_manager */ - protected $extension_manager; + protected $db_tools /** @var string */ protected $table_prefix; @@ -93,16 +90,6 @@ class phpbb_db_migrator $this->load_migration_state(); } - /** - * Set Extension Manager (required) - * - * Not in constructor to prevent circular reference error - */ - public function set_extension_manager(phpbb_extension_manager $extension_manager) - { - $this->extension_manager = $extension_manager; - } - /** * Loads all migrations and their application state from the database. * @@ -145,98 +132,6 @@ class phpbb_db_migrator $this->migrations = $class_names; } - /** - * This function adds all migrations in a specified directory to the migrations table - * - * THIS SHOULD NOT GENERALLY BE USED! THIS IS FOR THE PHPBB INSTALLER. - * THIS WILL THROW ERRORS IF MIGRATIONS ALREADY EXIST IN THE TABLE, DO NOT CALL MORE THAN ONCE! - * - * @param string $path Path to migration data files - * @param bool $recursive Set to true to also load data files from subdirectories - * @return null - */ - public function populate_migrations_from_directory($path, $recursive = true) - { - $existing_migrations = $this->migrations; - - $this->migrations = array(); - $this->load_migrations($path, true, $recursive); - - foreach ($this->migrations as $name) - { - if ($this->migration_state($name) === false) - { - $state = array( - 'migration_depends_on' => $name::depends_on(), - 'migration_schema_done' => true, - 'migration_data_done' => true, - 'migration_data_state' => '', - 'migration_start_time' => time(), - 'migration_end_time' => time(), - ); - $this->insert_migration($name, $state); - } - } - - $this->migrations = $existing_migrations; - } - - /** - * Load migration data files from a directory - * - * Migration data files loaded with this function MUST contain - * ONLY ONE class in them (or an exception will be thrown). - * - * @param string $path Path to migration data files - * @param bool $check_fulfillable If TRUE (default), we will check - * if all of the migrations are fulfillable after loading them. - * If FALSE, we will not check. You SHOULD check at least once - * to prevent errors (if including multiple directories, check - * with the last call to prevent throwing errors unnecessarily). - * @return array Array of migration names - */ - public function load_migrations($path, $check_fulfillable = true) - { - if (!is_dir($path)) - { - throw new phpbb_db_migration_exception('DIRECTORY INVALID', $path); - } - - $migrations = array(); - - $finder = $this->extension_manager->get_finder(); - $files = $finder - ->extension_directory("/") - ->find_from_paths(array('/' => $path)); - foreach ($files as $file) - { - $migrations[$file['path'] . $file['filename']] = ''; - } - $migrations = $finder->get_classes_from_files($migrations); - - foreach ($migrations as $migration) - { - if (!in_array($migration, $this->migrations)) - { - $this->migrations[] = $migration; - } - } - - if ($check_fulfillable) - { - foreach ($this->migrations as $name) - { - $unfulfillable = $this->unfulfillable($name); - if ($unfulfillable !== false) - { - throw new phpbb_db_migration_exception('MIGRATION_NOT_FULFILLABLE', $name, $unfulfillable); - } - } - } - - return $this->migrations; - } - /** * Runs a single update step from the next migration to be applied. * @@ -754,4 +649,85 @@ class phpbb_db_migrator { return new $name($this->config, $this->db, $this->db_tools, $this->phpbb_root_path, $this->php_ext, $this->table_prefix); } + + /** + * This function adds all migrations sent to it to the migrations table + * + * THIS SHOULD NOT GENERALLY BE USED! THIS IS FOR THE PHPBB INSTALLER. + * THIS WILL THROW ERRORS IF MIGRATIONS ALREADY EXIST IN THE TABLE, DO NOT CALL MORE THAN ONCE! + * + * @param array $migrations Array of migrations (names) to add to the migrations table + * @return null + */ + public function populate_migrations($migrations) + { + foreach ($migrations as $name) + { + if ($this->migration_state($name) === false) + { + $state = array( + 'migration_depends_on' => $name::depends_on(), + 'migration_schema_done' => true, + 'migration_data_done' => true, + 'migration_data_state' => '', + 'migration_start_time' => time(), + 'migration_end_time' => time(), + ); + $this->insert_migration($name, $state); + } + } + } + + /** + * Load migration data files from a directory + * + * @param phpbb_extension_finder $finder + * @param string $path Path to migration data files + * @param bool $check_fulfillable If TRUE (default), we will check + * if all of the migrations are fulfillable after loading them. + * If FALSE, we will not check. You SHOULD check at least once + * to prevent errors (if including multiple directories, check + * with the last call to prevent throwing errors unnecessarily). + * @return array Array of migration names + */ + public function load_migrations(phpbb_extension_finder $finder, $path, $check_fulfillable = true) + { + if (!is_dir($path)) + { + throw new phpbb_db_migration_exception('DIRECTORY INVALID', $path); + } + + $migrations = array(); + + $files = $finder + ->extension_directory("/") + ->find_from_paths(array('/' => $path)); + foreach ($files as $file) + { + $migrations[$file['path'] . $file['filename']] = ''; + } + $migrations = $finder->get_classes_from_files($migrations); + + foreach ($migrations as $migration) + { + if (!in_array($migration, $this->migrations)) + { + $this->migrations[] = $migration; + } + } + + if ($check_fulfillable) + { + foreach ($this->migrations as $name) + { + $unfulfillable = $this->unfulfillable($name); + if ($unfulfillable !== false) + { + throw new phpbb_db_migration_exception('MIGRATION_NOT_FULFILLABLE', $name, $unfulfillable); + } + } + } + + return $this->migrations; + } } diff --git a/phpBB/includes/extension/manager.php b/phpBB/includes/extension/manager.php index 0d760681b9..44a30c6280 100644 --- a/phpBB/includes/extension/manager.php +++ b/phpBB/includes/extension/manager.php @@ -43,18 +43,20 @@ class phpbb_extension_manager * @param ContainerInterface $container A container * @param phpbb_db_driver $db A database connection * @param phpbb_config $config phpbb_config + * @param phpbb_db_migrator $migrator * @param string $extension_table The name of the table holding extensions * @param string $phpbb_root_path Path to the phpbb includes directory. * @param string $php_ext php file extension * @param phpbb_cache_driver_interface $cache A cache instance or null * @param string $cache_name The name of the cache variable, defaults to _ext */ - public function __construct(ContainerInterface $container, phpbb_db_driver $db, phpbb_config $config, $extension_table, $phpbb_root_path, $php_ext = '.php', phpbb_cache_driver_interface $cache = null, $cache_name = '_ext') + public function __construct(ContainerInterface $container, phpbb_db_driver $db, phpbb_config $config, phpbb_db_migrator $migrator, $extension_table, $phpbb_root_path, $php_ext = '.php', phpbb_cache_driver_interface $cache = null, $cache_name = '_ext') { $this->container = $container; $this->phpbb_root_path = $phpbb_root_path; $this->db = $db; $this->config = $config; + $this->migrator = $migrator; $this->cache = $cache; $this->php_ext = $php_ext; $this->extension_table = $extension_table; @@ -68,14 +70,6 @@ class phpbb_extension_manager } } - /** - * Set migrator (get around circular reference) - */ - public function set_migrator(phpbb_db_migrator $migrator) - { - $this->migrator = $migrator; - } - /** * Loads all extension information from the database * @@ -528,13 +522,27 @@ class phpbb_extension_manager */ protected function handle_migrations($extension_name, $mode) { - $migrations_path = $this->phpbb_root_path . $this->get_extension_path($extension_name) . 'migrations/'; - if (!file_exists($migrations_path) || !is_dir($migrations_path)) + $extensions = array( + $extension_name => $this->phpbb_root_path . $this->get_extension_path($extension_name), + ); + + $finder = $this->get_finder(); + $migrations = array(); + $file_list = $finder + ->extension_directory('/migrations') + ->find_from_paths($extensions); + + if (empty($file_list)) { return true; } - $migrations = $this->migrator->load_migrations($migrations_path); + foreach ($file_list as $file) + { + $migrations[$file['named_path']] = $file['ext_name']; + } + $migrations = $finder->get_classes_from_files($migrations); + $this->migrator->set_migrations($migrations); // What is a safe limit of execution time? Half the max execution time should be safe. $safe_time_limit = (ini_get('max_execution_time') / 2); diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 4938ef0f87..b84f00659c 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -210,7 +210,13 @@ if (!$db_tools->sql_table_exists($table_prefix . 'migrations')) } $migrator = $phpbb_container->get('migrator'); -$migrator->load_migrations($phpbb_root_path . 'includes/db/migration/data/'); +$extension_manager = $phpbb_container->get('ext.manager'); +$finder = $extension_manager->get_finder(); + +$migrations = $finder + ->core_path('includes/db/migration/data/') + ->get_classes(); +$migrator->set_migrations($migrations); // What is a safe limit of execution time? Half the max execution time should be safe. $safe_time_limit = (ini_get('max_execution_time') / 2); diff --git a/phpBB/install/install_install.php b/phpBB/install/install_install.php index f0280acc40..4cc154509c 100644 --- a/phpBB/install/install_install.php +++ b/phpBB/install/install_install.php @@ -114,7 +114,7 @@ class install_install extends module $this->add_bots($mode, $sub); $this->email_admin($mode, $sub); $this->disable_avatars_if_unwritable(); - $this->populate_migrations($phpbb_container->get('migrator'), $phpbb_root_path); + $this->populate_migrations($phpbb_container->get('ext.manager'), $phpbb_container->get('migrator')); // Remove the lock file @unlink($phpbb_root_path . 'cache/install_lock'); @@ -1888,12 +1888,17 @@ class install_install extends module * "installs" means it adds all migrations to the migrations table, but does not * perform any of the actions in the migrations. * + * @param phpbb_extension_manager $extension_manager * @param phpbb_db_migrator $migrator - * @param string $phpbb_root_path */ - function populate_migrations($migrator, $phpbb_root_path) + function populate_migrations($extension_manager, $migrator) { - $migrator->populate_migrations_from_directory($phpbb_root_path . 'includes/db/migration/data/'); + $finder = $extension_manager->get_finder(); + + $migrations = $finder + ->core_path('includes/db/migration/data/') + ->get_classes(); + $migrator->populate_migrations($migrations); } /** diff --git a/tests/dbal/migrator_test.php b/tests/dbal/migrator_test.php index b447a81cda..89669b85ec 100644 --- a/tests/dbal/migrator_test.php +++ b/tests/dbal/migrator_test.php @@ -45,15 +45,6 @@ class phpbb_dbal_migrator_test extends phpbb_database_test_case new phpbb_db_migration_tool_config($this->config), ); - $this->extension_manager = new phpbb_extension_manager( - new phpbb_mock_container_builder(), - $this->db, - $this->config, - 'phpbb_ext', - dirname(__FILE__) . '/../../phpBB/', - '.php', - null - ); $this->migrator = new phpbb_db_migrator( $this->config, $this->db, @@ -64,7 +55,16 @@ class phpbb_dbal_migrator_test extends phpbb_database_test_case 'phpbb_', $tools ); - $this->migrator->set_extension_manager($this->extension_manager); + $this->extension_manager = new phpbb_extension_manager( + new phpbb_mock_container_builder(), + $this->db, + $this->config, + $this->migrator, + 'phpbb_ext', + dirname(__FILE__) . '/../../phpBB/', + '.php', + null + ); } public function test_update() diff --git a/tests/extension/manager_test.php b/tests/extension/manager_test.php index 3b81afc456..1f311116f4 100644 --- a/tests/extension/manager_test.php +++ b/tests/extension/manager_test.php @@ -97,15 +97,6 @@ class phpbb_extension_manager_test extends phpbb_database_test_case $php_ext = 'php'; $table_prefix = 'phpbb_'; - $manager = new phpbb_extension_manager( - new phpbb_mock_container_builder(), - $db, - $config, - 'phpbb_ext', - dirname(__FILE__) . '/', - '.' . $php_ext, - ($with_cache) ? new phpbb_mock_cache() : null - ); $migrator = new phpbb_db_migrator( $config, $db, @@ -116,9 +107,15 @@ class phpbb_extension_manager_test extends phpbb_database_test_case $table_prefix, array() ); - $manager->set_migrator($migrator); - $migrator->set_extension_manager($manager); - - return $manager; + return new phpbb_extension_manager( + new phpbb_mock_container_builder(), + $db, + $config, + $migrator, + 'phpbb_ext', + dirname(__FILE__) . '/', + '.' . $php_ext, + ($with_cache) ? new phpbb_mock_cache() : null + ); } } diff --git a/tests/extension/metadata_manager_test.php b/tests/extension/metadata_manager_test.php index 7fb19b67e3..081a32e277 100644 --- a/tests/extension/metadata_manager_test.php +++ b/tests/extension/metadata_manager_test.php @@ -49,10 +49,21 @@ class metadata_manager_test extends phpbb_database_test_case new phpbb_template_context() ); + $this->migrator = new phpbb_db_migrator( + $this->config, + $this->db, + $this->db_tools, + 'phpbb_migrations', + $this->phpbb_root_path, + 'php', + $this->table_prefix, + array() + ); $this->extension_manager = new phpbb_extension_manager( new phpbb_mock_container_builder(), $this->db, $this->config, + $this->migrator, 'phpbb_ext', $this->phpbb_root_path, $this->phpEx, diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index 3b9629b9f8..887dfea3b5 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -138,15 +138,6 @@ class phpbb_functional_test_case extends phpbb_test_case $db = $this->get_db(); $db_tools = new phpbb_db_tools($db); - $extension_manager = new phpbb_extension_manager( - new phpbb_mock_container_builder(), - $db, - $config, - self::$config['table_prefix'] . 'ext', - dirname(__FILE__) . '/', - '.' . $php_ext, - $this->get_cache_driver() - ); $migrator = new phpbb_db_migrator( $config, $db, @@ -157,8 +148,16 @@ class phpbb_functional_test_case extends phpbb_test_case self::$config['table_prefix'], array() ); - $extension_manager->set_migrator($migrator); - $migrator->set_extension_manager($extension_manager); + $extension_manager = new phpbb_extension_manager( + new phpbb_mock_container_builder(), + $db, + $config, + $migrator, + self::$config['table_prefix'] . 'ext', + dirname(__FILE__) . '/', + '.' . $php_ext, + $this->get_cache_driver() + ); return $extension_manager; } From 6cad032fbb2ceba892c861f8a2abab82574b12ae Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Sun, 3 Mar 2013 20:18:05 -0600 Subject: [PATCH 1134/2494] [ticket/11393] Give more information on database updater PHPBB3-11393 --- phpBB/includes/db/migrator.php | 9 ++++++++- phpBB/install/database_update.php | 23 ++++++++++++++++++++++- phpBB/language/en/migrator.php | 3 +++ 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/db/migrator.php b/phpBB/includes/db/migrator.php index de9c06948c..81beb14b76 100644 --- a/phpBB/includes/db/migrator.php +++ b/phpBB/includes/db/migrator.php @@ -63,7 +63,9 @@ class phpbb_db_migrator protected $migrations = array(); /** - * 'name' and 'class' of the last migration run + * 'name,' 'class,' and 'state' of the last migration run + * + * 'effectively_installed' set and set to true if the migration was effectively_installed * * @var array */ @@ -304,6 +306,7 @@ class phpbb_db_migrator $this->last_run_migration = array( 'name' => $name, 'class' => $migration, + 'state' => $state, ); if (!isset($this->migration_state[$name])) @@ -318,6 +321,8 @@ class phpbb_db_migrator 'migration_start_time' => 0, 'migration_end_time' => 0, ); + + $this->last_run_migration['effectively_installed'] = true; } else { @@ -662,6 +667,8 @@ class phpbb_db_migrator } $this->migration_state[$name] = $state; + + $this->last_run_migration['state'] = $state; } /** diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 4938ef0f87..6c8a95a413 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -228,7 +228,28 @@ while (!$migrator->finished()) phpbb_end_update($cache); } - echo $migrator->last_run_migration['name'] . '
    '; + $state = array_merge(array( + 'migration_schema_done' => false, + 'migration_data_done' => false, + ), + $migrator->last_run_migration['state'] + ); + + if (isset($migrator->last_run_migration['effectively_installed']) && $migrator->last_run_migration['effectively_installed']) + { + echo $user->lang('MIGRATION_EFFECTIVELY_INSTALLED', $migrator->last_run_migration['name']) . '
    '; + } + else + { + if ($state['migration_data_done']) + { + echo $user->lang('MIGRATION_DATA_DONE', $migrator->last_run_migration['name']) . '
    '; + } + else if ($state['migration_schema_done']) + { + echo $user->lang('MIGRATION_SCHEMA_DONE', $migrator->last_run_migration['name']) . '
    '; + } + } // Are we approaching the time limit? If so we want to pause the update and continue after refreshing if ((time() - $update_start_time) >= $safe_time_limit) diff --git a/phpBB/language/en/migrator.php b/phpBB/language/en/migrator.php index 84074c391c..a62da483cf 100644 --- a/phpBB/language/en/migrator.php +++ b/phpBB/language/en/migrator.php @@ -40,8 +40,11 @@ $lang = array_merge($lang, array( 'GROUP_NOT_EXIST' => 'The group "%s" unexpectedly does not exist.', + 'MIGRATION_DATA_DONE' => 'Installed Data: %s', + 'MIGRATION_EFFECTIVELY_INSTALLED' => 'Migration already effectively installed (skipped): %s', 'MIGRATION_EXCEPTION_ERROR' => 'Something went wrong during the request and an exception was thrown. The changes made before the error occurred were reversed to the best of our abilities, but you should check the board for errors.', 'MIGRATION_NOT_FULFILLABLE' => 'The migration "%1$s" is not fulfillable, missing migration "%2$s".', + 'MIGRATION_SCHEMA_DONE' => 'Installed Schema: %s', 'MODULE_ALREADY_EXIST' => 'The module "%s" unexpectedly already exists.', 'MODULE_ERROR' => 'An error occured while creating a module: %s', From 9dfc5fbf9a8b866bea38efa5217417e6ef341bf1 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Sun, 3 Mar 2013 20:47:14 -0600 Subject: [PATCH 1135/2494] [ticket/11395] Prevent acp_modules::get_modules_info from reincluding files PHPBB3-11395 --- phpBB/includes/acp/acp_modules.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/acp/acp_modules.php b/phpBB/includes/acp/acp_modules.php index fce26bf45f..7c2ea86122 100644 --- a/phpBB/includes/acp/acp_modules.php +++ b/phpBB/includes/acp/acp_modules.php @@ -600,11 +600,11 @@ class acp_modules if (!class_exists($info_class)) { - if (file_exists($directory . $module . '.' . $phpEx)) + $info_class = $module . '_info'; + if (!class_exists($info_class) && file_exists($directory . $module . '.' . $phpEx)) { include($directory . $module . '.' . $phpEx); } - $info_class = $module . '_info'; } // Get module title tag From ae15fabb323c8f76ad2c8c994c2d205aabeafcbe Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Sun, 3 Mar 2013 20:59:21 -0600 Subject: [PATCH 1136/2494] [ticket/11396] Rename insert_migration to set_migration_state PHPBB3-11396 --- phpBB/includes/db/migrator.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/phpBB/includes/db/migrator.php b/phpBB/includes/db/migrator.php index de9c06948c..7b5e8cb2de 100644 --- a/phpBB/includes/db/migrator.php +++ b/phpBB/includes/db/migrator.php @@ -174,7 +174,7 @@ class phpbb_db_migrator 'migration_start_time' => time(), 'migration_end_time' => time(), ); - $this->insert_migration($name, $state); + $this->set_migration_state($name, $state); } } @@ -350,7 +350,7 @@ class phpbb_db_migrator } } - $this->insert_migration($name, $state); + $this->set_migration_state($name, $state); return true; } @@ -422,7 +422,7 @@ class phpbb_db_migrator $state['migration_data_done'] = ($result === true) ? false : true; } - $this->insert_migration($name, $state); + $this->set_migration_state($name, $state); } else { @@ -641,7 +641,7 @@ class phpbb_db_migrator * @param array $state * @return null */ - protected function insert_migration($name, $state) + protected function set_migration_state($name, $state) { $migration_row = $state; $migration_row['migration_depends_on'] = serialize($state['migration_depends_on']); From 2e2ddd7e85034f747d5dd312803aadfc47ac80e2 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 4 Mar 2013 10:30:49 +0100 Subject: [PATCH 1137/2494] [feature/avatars] Update module_auth of ucp module and fix small issues Reduced the check effectively_installed() to just checking for the config entry "allow_avatar_gravatar". Also added the missing update of the module_auth of the ucp_profile avatar mode. PHPBB3-10018 --- .../db/migration/data/310/avatars.php | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/phpBB/includes/db/migration/data/310/avatars.php b/phpBB/includes/db/migration/data/310/avatars.php index de11a64556..79547337f7 100644 --- a/phpBB/includes/db/migration/data/310/avatars.php +++ b/phpBB/includes/db/migration/data/310/avatars.php @@ -11,15 +11,7 @@ class phpbb_db_migration_data_310_avatars extends phpbb_db_migration { public function effectively_installed() { - $sql = 'SELECT module_auth - FROM ' . MODULES_TABLE . " - WHERE module_class = 'ucp' - AND module_basename = 'ucp_profile' - AND module_mode = 'avatar'"; - $result = $this->db->sql_query($sql); - $module_auth = $this->db->sql_fetchfield('module_auth'); - $this->db->sql_freeresult($result); - return ($module_auth == 'cfg_allow_avatar'); + return isset($this->config['allow_avatar_gravatar']); } static public function depends_on() @@ -59,6 +51,17 @@ class phpbb_db_migration_data_310_avatars extends phpbb_db_migration { return array( array('config.add', array('allow_avatar_gravatar', 0)), + array('custom', array(array($this, 'update_module_auth'))), ); } + + public function update_module_auth() + { + $sql = 'UPDATE ' . $this->table_prefix . "modules + SET module_auth = 'cfg_allow_avatar' + WHERE module_class = 'ucp' + AND module_basename = 'ucp_profile' + AND module_mode = 'avatar'"; + $this->db->sql_query($sql); + } } From 7423d48757bec0a81c8d439e911ed32d5af3a775 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 4 Mar 2013 11:25:27 +0100 Subject: [PATCH 1138/2494] [ticket/10714] Get log from container in install, update and download/file PHPBB3-10714 --- phpBB/download/file.php | 1 + phpBB/install/database_update.php | 1 + phpBB/install/install_install.php | 5 +++-- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/phpBB/download/file.php b/phpBB/download/file.php index 4a392b002d..855813d0d2 100644 --- a/phpBB/download/file.php +++ b/phpBB/download/file.php @@ -67,6 +67,7 @@ if (isset($_GET['avatar'])) $phpbb_dispatcher = $phpbb_container->get('dispatcher'); $request = $phpbb_container->get('request'); $db = $phpbb_container->get('dbal.conn'); + $phpbb_log = $phpbb_container->get('log'); // Connect to DB if (!@$db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, false)) diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 4938ef0f87..23048df9fa 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -123,6 +123,7 @@ $request = $phpbb_container->get('request'); $user = $phpbb_container->get('user'); $auth = $phpbb_container->get('auth'); $db = $phpbb_container->get('dbal.conn'); +$phpbb_log = $phpbb_container->get('log'); // make sure request_var uses this request instance request_var('', 0, false, false, $request); // "dependency injection" for a function diff --git a/phpBB/install/install_install.php b/phpBB/install/install_install.php index f0280acc40..d95a500929 100644 --- a/phpBB/install/install_install.php +++ b/phpBB/install/install_install.php @@ -53,7 +53,7 @@ class install_install extends module function main($mode, $sub) { global $lang, $template, $language, $phpbb_root_path, $phpEx; - global $phpbb_container, $cache; + global $phpbb_container, $cache, $phpbb_log; switch ($sub) { @@ -105,8 +105,9 @@ class install_install extends module // Create a normal container now $phpbb_container = phpbb_create_default_container($phpbb_root_path, $phpEx); - // Sets the global $cache variable + // Sets the global variables $cache = $phpbb_container->get('cache'); + $phpbb_log = $phpbb_container->get('log'); $this->build_search_index($mode, $sub); $this->add_modules($mode, $sub); From 071defded6f0e4d2a805b336f56f0a2524d5b1b6 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Mon, 4 Mar 2013 09:55:23 -0600 Subject: [PATCH 1139/2494] [ticket/11386] Fix missing ; PHPBB3-11386 --- phpBB/includes/db/migrator.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/db/migrator.php b/phpBB/includes/db/migrator.php index b925ca5297..9fe4f40df2 100644 --- a/phpBB/includes/db/migrator.php +++ b/phpBB/includes/db/migrator.php @@ -29,7 +29,7 @@ class phpbb_db_migrator protected $db; /** @var phpbb_db_tools */ - protected $db_tools + protected $db_tools; /** @var string */ protected $table_prefix; From 2aadc5a22c4ad58cab73bb8b56ca0109a95fab0f Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Sun, 3 Mar 2013 20:25:31 -0600 Subject: [PATCH 1140/2494] [ticket/11394] Relax Migration Tools Do not throw as many exceptions in the migration tools (when something unexpected occurs but can be safely ignored). PHPBB3-11394 --- phpBB/includes/db/migration/tool/config.php | 4 ++-- phpBB/includes/db/migration/tool/module.php | 6 +++--- phpBB/includes/db/migration/tool/permission.php | 6 +++--- phpBB/language/en/migrator.php | 4 ---- 4 files changed, 8 insertions(+), 12 deletions(-) diff --git a/phpBB/includes/db/migration/tool/config.php b/phpBB/includes/db/migration/tool/config.php index 458a25fb66..0b626bf455 100644 --- a/phpBB/includes/db/migration/tool/config.php +++ b/phpBB/includes/db/migration/tool/config.php @@ -49,7 +49,7 @@ class phpbb_db_migration_tool_config implements phpbb_db_migration_tool_interfac { if (isset($this->config[$config_name])) { - throw new phpbb_db_migration_exception('CONFIG_ALREADY_EXIST', $config_name); + return; } $this->config->set($config_name, $config_value, !$is_dynamic); @@ -105,7 +105,7 @@ class phpbb_db_migration_tool_config implements phpbb_db_migration_tool_interfac { if (!isset($this->config[$config_name])) { - throw new phpbb_db_migration_exception('CONFIG_NOT_EXIST', $config_name); + return; } $this->config->delete($config_name); diff --git a/phpBB/includes/db/migration/tool/module.php b/phpBB/includes/db/migration/tool/module.php index ad94c5aadb..ec683d36af 100644 --- a/phpBB/includes/db/migration/tool/module.php +++ b/phpBB/includes/db/migration/tool/module.php @@ -236,7 +236,7 @@ class phpbb_db_migration_tool_module implements phpbb_db_migration_tool_interfac if ($this->exists($class, $parent, $data['module_langname'])) { - throw new phpbb_db_migration_exception('MODULE_ALREADY_EXIST', $data['module_langname']); + return; } if (!class_exists('acp_modules')) @@ -369,7 +369,7 @@ class phpbb_db_migration_tool_module implements phpbb_db_migration_tool_interfac { if (!$this->exists($class, $parent, $module)) { - throw new phpbb_db_migration_exception('MODULE_NOT_EXIST', ((isset($this->user->lang[$module])) ? $this->user->lang[$module] : $module)); + return; } $parent_sql = ''; @@ -442,7 +442,7 @@ class phpbb_db_migration_tool_module implements phpbb_db_migration_tool_interfac $result = $acp_modules->delete_module($module_id); if (!empty($result)) { - throw new phpbb_db_migration_exception('MODULE_NOT_REMOVABLE', $module_id, $result); + return; } } diff --git a/phpBB/includes/db/migration/tool/permission.php b/phpBB/includes/db/migration/tool/permission.php index 4231fbe1dd..3b196fdbc2 100644 --- a/phpBB/includes/db/migration/tool/permission.php +++ b/phpBB/includes/db/migration/tool/permission.php @@ -107,7 +107,7 @@ class phpbb_db_migration_tool_permission implements phpbb_db_migration_tool_inte { if ($this->exists($auth_option, $global)) { - throw new phpbb_db_migration_exception('PERMISSION_ALREADY_EXIST', $auth_option); + return; } // We've added permissions, so set to true to notify the user. @@ -190,7 +190,7 @@ class phpbb_db_migration_tool_permission implements phpbb_db_migration_tool_inte { if (!$this->exists($auth_option, $global)) { - throw new phpbb_db_migration_exception('PERMISSION_NOT_EXIST', $auth_option); + return; } if ($global) @@ -315,7 +315,7 @@ class phpbb_db_migration_tool_permission implements phpbb_db_migration_tool_inte if (!$role_id) { - throw new phpbb_db_migration_exception('ROLE_NOT_EXIST', $role_name); + return; } $sql = 'DELETE FROM ' . ACL_ROLES_DATA_TABLE . ' diff --git a/phpBB/language/en/migrator.php b/phpBB/language/en/migrator.php index 84074c391c..59e6f06884 100644 --- a/phpBB/language/en/migrator.php +++ b/phpBB/language/en/migrator.php @@ -35,7 +35,6 @@ if (empty($lang) || !is_array($lang)) // in a url you again do not need to specify an order e.g., 'Click %sHERE%s' is fine $lang = array_merge($lang, array( - 'CONFIG_ALREADY_EXIST' => 'The config setting "%s" unexpectedly already exists.', 'CONFIG_NOT_EXIST' => 'The config setting "%s" unexpectedly does not exist.', 'GROUP_NOT_EXIST' => 'The group "%s" unexpectedly does not exist.', @@ -43,13 +42,10 @@ $lang = array_merge($lang, array( 'MIGRATION_EXCEPTION_ERROR' => 'Something went wrong during the request and an exception was thrown. The changes made before the error occurred were reversed to the best of our abilities, but you should check the board for errors.', 'MIGRATION_NOT_FULFILLABLE' => 'The migration "%1$s" is not fulfillable, missing migration "%2$s".', - 'MODULE_ALREADY_EXIST' => 'The module "%s" unexpectedly already exists.', 'MODULE_ERROR' => 'An error occured while creating a module: %s', 'MODULE_INFO_FILE_NOT_EXIST' => 'A required module info file is missing: %2$s', 'MODULE_NOT_EXIST' => 'A required module does not exist: %s', - 'MODULE_NOT_REMOVABLE' => 'Module %1$s was unable to be removed: %2$s', - 'PERMISSION_ALREADY_EXIST' => 'The permission setting "%s" unexpectedly already exists.', 'PERMISSION_NOT_EXIST' => 'The permission setting "%s" unexpectedly does not exist.', 'ROLE_NOT_EXIST' => 'The permission role "%s" unexpectedly does not exist.', From e7d9cfa009ba8e22b0e75f1401ea2caa70c89c5b Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Tue, 5 Mar 2013 01:06:22 +0100 Subject: [PATCH 1141/2494] [ticket/11398] Correctly call permission_set method in permission tool The permission_set method calls itself inside the permission tool. Probably due to an oversight, it is called as $this->set(), which causes a fatal error. This patch will get rid of this issue. PHPBB3-11398 --- phpBB/includes/db/migration/tool/permission.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/db/migration/tool/permission.php b/phpBB/includes/db/migration/tool/permission.php index 3b196fdbc2..2f09c0ac72 100644 --- a/phpBB/includes/db/migration/tool/permission.php +++ b/phpBB/includes/db/migration/tool/permission.php @@ -422,7 +422,7 @@ class phpbb_db_migration_tool_permission implements phpbb_db_migration_tool_inte $this->db->sql_query($sql); $role_name = $this->db->sql_fetchfield('role_name'); - return $this->set($role_name, $auth_option, 'role', $has_permission); + return $this->permission_set($role_name, $auth_option, 'role', $has_permission); } $sql = 'SELECT auth_option_id, auth_setting From a21de6e3f845f56026757e370b0bae8a02997bad Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 5 Mar 2013 17:09:33 +0100 Subject: [PATCH 1142/2494] [ticket/9657] Rebuild notifications in mcp_queue.php PHPBB3-9657 --- phpBB/includes/mcp/mcp_queue.php | 157 ++++++++++++++----------------- 1 file changed, 72 insertions(+), 85 deletions(-) diff --git a/phpBB/includes/mcp/mcp_queue.php b/phpBB/includes/mcp/mcp_queue.php index 6f9f16bde4..01abdc82d8 100644 --- a/phpBB/includes/mcp/mcp_queue.php +++ b/phpBB/includes/mcp/mcp_queue.php @@ -650,46 +650,39 @@ class mcp_queue // Only send out the mails, when the posts are being approved if ($action == 'approve') { - $messenger = new messenger(); + $phpbb_notifications = $phpbb_container->get('notification_manager'); - // Notify Poster? - if ($notify_poster) + // Send out normal user notifications + $email_sig = str_replace('
    ', "\n", "-- \n" . $config['board_email_sig']); + + // Handle notifications + foreach ($post_info as $post_id => $post_data) { - foreach ($post_info as $post_id => $post_data) + $phpbb_notifications->delete_notifications('post_in_queue', $post_id); + + $phpbb_notifications->add_notifications(array( + 'quote', + 'bookmark', + 'post', + ), $post_data); + + $phpbb_notifications->mark_notifications_read(array( + 'quote', + 'bookmark', + 'post', + ), $post_data['post_id'], $user->data['user_id']); + + // Notify Poster? + if ($notify_poster) { if ($post_data['poster_id'] == ANONYMOUS) { continue; } - $messenger->template('post_approved', $post_data['user_lang']); - - $messenger->to($post_data['user_email'], $post_data['username']); - $messenger->im($post_data['user_jabber'], $post_data['username']); - - $messenger->assign_vars(array( - 'USERNAME' => htmlspecialchars_decode($post_data['username']), - 'POST_SUBJECT' => htmlspecialchars_decode(censor_text($post_data['post_subject'])), - 'TOPIC_TITLE' => htmlspecialchars_decode(censor_text($post_data['topic_title'])), - - 'U_VIEW_TOPIC' => generate_board_url() . "/viewtopic.$phpEx?f={$post_data['forum_id']}&t={$post_data['topic_id']}&e=0", - 'U_VIEW_POST' => generate_board_url() . "/viewtopic.$phpEx?f={$post_data['forum_id']}&t={$post_data['topic_id']}&p=$post_id&e=$post_id") - ); - - $messenger->send($post_data['user_notify_type']); + $phpbb_notifications->add_notifications('approve_post', $post_data); } } - - $messenger->save_queue(); - - // Send out normal user notifications - $email_sig = str_replace('
    ', "\n", "-- \n" . $config['board_email_sig']); - - foreach ($post_info as $post_id => $post_data) - { - // Topic Notifications - user_notification('reply', $post_data['post_subject'], $post_data['topic_title'], $post_data['forum_name'], $post_data['forum_id'], $post_data['topic_id'], $post_id); - } } } else @@ -818,41 +811,27 @@ class mcp_queue // Only send out the mails, when the posts are being approved if ($action == 'approve') { - $messenger = new messenger(); - - // Notify Poster? - if ($notify_poster) - { - foreach ($topic_info as $topic_id => $topic_data) - { - if ($topic_data['topic_poster'] == ANONYMOUS) - { - continue; - } - - $messenger->template('topic_approved', $topic_data['user_lang']); - $messenger->to($topic_data['user_email'], $topic_data['username']); - $messenger->im($topic_data['user_jabber'], $topic_data['username']); - - $messenger->assign_vars(array( - 'USERNAME' => htmlspecialchars_decode($topic_data['username']), - 'TOPIC_TITLE' => htmlspecialchars_decode(censor_text($topic_data['topic_title'])), - 'U_VIEW_TOPIC' => generate_board_url() . "/viewtopic.$phpEx?f={$topic_data['forum_id']}&t={$topic_data['topic_id']}&e=0", - )); - - $messenger->send($topic_data['user_notify_type']); - } - } - - $messenger->save_queue(); - // Send out normal user notifications $email_sig = str_replace('
    ', "\n", "-- \n" . $config['board_email_sig']); + // Handle notifications + $phpbb_notifications = $phpbb_container->get('notification_manager'); + foreach ($topic_info as $topic_id => $topic_data) { - // Forum Notifications - user_notification('post', $topic_data['topic_title'], $topic_data['topic_title'], $topic_data['forum_name'], $topic_data['forum_id'], $topic_data['topic_id'], 0); + $phpbb_notifications->delete_notifications('topic_in_queue', $post_data['topic_id']); + $phpbb_notifications->add_notifications(array( + 'quote', + 'topic', + ), $post_data); + + $phpbb_notifications->mark_notifications_read('quote', $post_data['post_id'], $user->data['user_id']); + $phpbb_notifications->mark_notifications_read('topic', $post_data['topic_id'], $user->data['user_id']); + + if ($notify_poster) + { + $phpbb_notifications->add_notifications('approve_topic', $post_data); + } } } } @@ -1068,20 +1047,33 @@ class mcp_queue } } - $messenger = new messenger(); + $phpbb_notifications = $phpbb_container->get('notification_manager'); - // Notify Poster? - if ($notify_poster) + $lang_reasons = array(); + + foreach ($post_info as $post_id => $post_data) { - $lang_reasons = array(); + $disapprove_all_posts_in_topic = $topic_information[$topic_id]['topic_posts_approved'] == 0 && + $topic_information[$topic_id]['topic_posts_softdeleted'] == 0 && + $topic_information[$topic_id]['topic_posts_unapproved'] == $topic_posts_unapproved[$topic_id]; - foreach ($post_info as $post_id => $post_data) + $phpbb_notifications->delete_notifications('post_in_queue', $post_id); + + // Do we disapprove the whole topic? Remove potential notifications + if ($disapprove_all_posts_in_topic) + { + $phpbb_notifications->delete_notifications('topic_in_queue', $post_data['topic_id']); + } + + // Notify Poster? + if ($notify_poster) { if ($post_data['poster_id'] == ANONYMOUS) { continue; } + $post_data['disapprove_reason'] = ''; if (isset($disapprove_reason_lang)) { // Okay we need to get the reason from the posters language @@ -1107,32 +1099,27 @@ class mcp_queue } } - $email_disapprove_reason = $lang_reasons[$post_data['user_lang']]; - $email_disapprove_reason .= ($reason) ? "\n\n" . $reason : ''; + $post_data['disapprove_reason'] = $lang_reasons[$post_data['user_lang']]; + $post_data['disapprove_reason'] .= ($reason) ? "\n\n" . $reason : ''; } - $email_template = ($post_data['post_id'] == $post_data['topic_first_post_id'] && $post_data['post_id'] == $post_data['topic_last_post_id']) ? 'topic_disapproved' : 'post_disapproved'; - $messenger->template($email_template, $post_data['user_lang']); - - $messenger->to($post_data['user_email'], $post_data['username']); - $messenger->im($post_data['user_jabber'], $post_data['username']); - - $messenger->assign_vars(array( - 'USERNAME' => htmlspecialchars_decode($post_data['username']), - 'REASON' => htmlspecialchars_decode($email_disapprove_reason), - 'POST_SUBJECT' => htmlspecialchars_decode(censor_text($post_data['post_subject'])), - 'TOPIC_TITLE' => htmlspecialchars_decode(censor_text($post_data['topic_title']))) - ); - - $messenger->send($post_data['user_notify_type']); + if ($disapprove_all_posts_in_topic && $topic_information[$topic_id]['topic_posts_unapproved'] == 1) + { + // If there is only 1 post when disapproving the topic, + // we send the user a "disapprove topic" notification... + $phpbb_notifications->add_notifications('disapprove_topic', $post_data); + } + else + { + // ... otherwise there are multiple unapproved posts and + // all of them are disapproved as posts. + $phpbb_notifications->add_notifications('disapprove_post', $post_data); + } } - - unset($lang_reasons); } - unset($post_info, $disapprove_reason, $email_disapprove_reason, $disapprove_reason_lang); - $messenger->save_queue(); + unset($lang_reasons,$post_info, $disapprove_reason, $email_disapprove_reason, $disapprove_reason_lang); if ($num_disapproved_topics) { From ab4c1b5d0c07dcf60e4dc41a4b6b4abfec64cd1e Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Tue, 5 Mar 2013 10:28:52 -0600 Subject: [PATCH 1143/2494] [ticket/11400] If email is disabled, disable it for notifications PHPBB3-11400 --- phpBB/includes/notification/method/email.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/phpBB/includes/notification/method/email.php b/phpBB/includes/notification/method/email.php index 429dfda2ba..4a7fea6df3 100644 --- a/phpBB/includes/notification/method/email.php +++ b/phpBB/includes/notification/method/email.php @@ -53,8 +53,7 @@ class phpbb_notification_method_email extends phpbb_notification_method_base */ public function is_available() { - // Email is always available - return true; + return (bool) $this->config['email_enable']; } /** From 6c6912f9e65f0683a806548bdc1a3526ed9ae107 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 5 Mar 2013 18:23:13 +0100 Subject: [PATCH 1144/2494] [ticket/9657] FIx merge conflict from merging develop PHPBB3-9657 --- phpBB/includes/search/fulltext_native.php | 6 +----- phpBB/includes/search/fulltext_postgres.php | 6 +----- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/phpBB/includes/search/fulltext_native.php b/phpBB/includes/search/fulltext_native.php index 90ea553ddc..2a9b552928 100644 --- a/phpBB/includes/search/fulltext_native.php +++ b/phpBB/includes/search/fulltext_native.php @@ -913,11 +913,7 @@ class phpbb_search_fulltext_native extends phpbb_search_base * @param int $per_page number of ids each page is supposed to contain * @return boolean|int total number of results */ -<<<<<<< HEAD - public function author_search($type, $firstpost_only, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $post_visibility, $topic_id, $author_ary, $author_name, &$id_ary, $start, $per_page) -======= - public function author_search($type, $firstpost_only, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_fid_ary, $topic_id, $author_ary, $author_name, &$id_ary, &$start, $per_page) ->>>>>>> bee4f8d8185d4ff5278be758db4ea4a814f09b4f + public function author_search($type, $firstpost_only, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $post_visibility, $topic_id, $author_ary, $author_name, &$id_ary, &$start, $per_page) { // No author? No posts if (!sizeof($author_ary)) diff --git a/phpBB/includes/search/fulltext_postgres.php b/phpBB/includes/search/fulltext_postgres.php index d5deb47222..8ccd27f43a 100644 --- a/phpBB/includes/search/fulltext_postgres.php +++ b/phpBB/includes/search/fulltext_postgres.php @@ -546,11 +546,7 @@ class phpbb_search_fulltext_postgres extends phpbb_search_base * @param int $per_page number of ids each page is supposed to contain * @return boolean|int total number of results */ -<<<<<<< HEAD - public function author_search($type, $firstpost_only, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $post_visibility, $topic_id, $author_ary, $author_name, &$id_ary, $start, $per_page) -======= - public function author_search($type, $firstpost_only, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_fid_ary, $topic_id, $author_ary, $author_name, &$id_ary, &$start, $per_page) ->>>>>>> bee4f8d8185d4ff5278be758db4ea4a814f09b4f + public function author_search($type, $firstpost_only, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $post_visibility, $topic_id, $author_ary, $author_name, &$id_ary, &$start, $per_page) { // No author? No posts if (!sizeof($author_ary)) From 0eb6f56a9ae6af541e4c12dec0235da0b508d65d Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Tue, 5 Mar 2013 11:46:58 -0600 Subject: [PATCH 1145/2494] [ticket/11402] Fix undefined index in post/topic_in_queue PHPBB3-11402 --- .../notification/type/post_in_queue.php | 18 ++++++++++--- .../notification/type/topic_in_queue.php | 25 ++++++++++++++++--- 2 files changed, 35 insertions(+), 8 deletions(-) diff --git a/phpBB/includes/notification/type/post_in_queue.php b/phpBB/includes/notification/type/post_in_queue.php index 1c29bee3cd..9c719205e6 100644 --- a/phpBB/includes/notification/type/post_in_queue.php +++ b/phpBB/includes/notification/type/post_in_queue.php @@ -64,9 +64,9 @@ class phpbb_notification_type_post_in_queue extends phpbb_notification_type_post */ public function is_available() { - $m_approve = $this->auth->acl_getf($this->permission, true); + $has_permission = $this->auth->acl_getf($this->permission, true); - return (!empty($m_approve)); + return (!empty($has_permission)); } /** @@ -90,9 +90,19 @@ class phpbb_notification_type_post_in_queue extends phpbb_notification_type_post return array(); } - $auth_approve[$post['forum_id']] = array_unique(array_merge($auth_approve[$post['forum_id']], $auth_approve[0])); + $has_permission = array(); - return $this->check_user_notification_options($auth_approve[$post['forum_id']][$this->permission], array_merge($options, array( + if (isset($auth_approve[$post['forum_id']][$this->permission])) + { + $has_permission = $auth_approve[$post['forum_id']][$this->permission]; + } + + if (isset($auth_approve[0][$this->permission])) + { + $has_permission = array_unique(array_merge($has_permission, $auth_approve[0][$this->permission])); + } + + return $this->check_user_notification_options($has_permission, array_merge($options, array( 'item_type' => self::$notification_option['id'], ))); } diff --git a/phpBB/includes/notification/type/topic_in_queue.php b/phpBB/includes/notification/type/topic_in_queue.php index dc0b9f9869..c501434c43 100644 --- a/phpBB/includes/notification/type/topic_in_queue.php +++ b/phpBB/includes/notification/type/topic_in_queue.php @@ -52,14 +52,21 @@ class phpbb_notification_type_topic_in_queue extends phpbb_notification_type_top 'group' => 'NOTIFICATION_GROUP_MODERATION', ); + /** + * Permission to check for (in find_users_for_notification) + * + * @var string Permission name + */ + protected $permission = 'm_approve'; + /** * Is available */ public function is_available() { - $m_approve = $this->auth->acl_getf('m_approve', true); + $has_permission = $this->auth->acl_getf($this->permission, true); - return (!empty($m_approve)); + return (!empty($has_permission)); } /** @@ -83,9 +90,19 @@ class phpbb_notification_type_topic_in_queue extends phpbb_notification_type_top return array(); } - $auth_approve[$topic['forum_id']] = array_unique(array_merge($auth_approve[$topic['forum_id']], $auth_approve[0])); + $has_permission = array(); - return $this->check_user_notification_options($auth_approve[$topic['forum_id']]['m_approve'], array_merge($options, array( + if (isset($auth_approve[$topic['forum_id']][$this->permission])) + { + $has_permission = $auth_approve[$topic['forum_id']][$this->permission]; + } + + if (isset($auth_approve[0][$this->permission])) + { + $has_permission = array_unique(array_merge($has_permission, $auth_approve[0][$this->permission])); + } + + return $this->check_user_notification_options($has_permission, array_merge($options, array( 'item_type' => self::$notification_option['id'], ))); } From 50b557ca4e0a80b3f153bc43f261e6b59e197371 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Mon, 4 Mar 2013 22:00:37 +0100 Subject: [PATCH 1146/2494] [ticket/10202] Implementation of config options with arbitrary length values. PHPBB3-10202 --- phpBB/includes/config/db_text.php | 157 ++++++++++++++++++++++++++++++ 1 file changed, 157 insertions(+) create mode 100644 phpBB/includes/config/db_text.php diff --git a/phpBB/includes/config/db_text.php b/phpBB/includes/config/db_text.php new file mode 100644 index 0000000000..79f83391f8 --- /dev/null +++ b/phpBB/includes/config/db_text.php @@ -0,0 +1,157 @@ +db = $db; + $this->table = $table; + } + + /** + * Sets the configuration option with the name $key to $value. + * + * @param string $key The configuration option's name + * @param string $value New configuration value + * + * @return null + */ + public function set($key, $value) + { + $this->setAll(array($key => $value)); + } + + /** + * Gets the configuration value for the name $key. + * + * @param string $key The configuration option's name + * + * @return string|null String result on success + * null if there is no such option + */ + public function get($key) + { + $map = $this->getAll(array($key)); + + return isset($map[$key]) ? $map[$key] : null; + } + + /** + * Removes a configuration option + * + * @param string $key The configuration option's name + * + * @return null + */ + public function delete($key) + { + $this->deleteAll(array($key)); + } + + /** + * Sets a configuration option's value + * + * @param array $map Map from configuration names to values + * + * @return null + */ + public function setAll(array $map) + { + $this->db->sql_transaction('begin'); + + foreach ($map as $key => $value) + { + $sql = 'UPDATE ' . $this->table . " + SET config_value = '" . $this->db->sql_escape($value) . "' + WHERE config_name = '" . $this->db->sql_escape($key) . "'"; + $result = $this->db->sql_query($sql); + + if (!$this->db->sql_affectedrows($result)) + { + $sql = 'INSERT INTO ' . $this->table . ' ' . $this->db->sql_build_array('INSERT', array( + 'config_name' => $key, + 'config_value' => $value, + )); + $this->db->sql_query($sql); + } + } + + $this->db->sql_transaction('commit'); + } + + /** + * Gets a set of configuration options as a key => value map. + * + * @param array $keys Set of configuration option names + * + * @return array Map from configuration names to values + */ + public function getAll(array $keys) + { + $sql = 'SELECT * + FROM ' . $this->table . ' + WHERE ' . $this->db->sql_in_set('config_name', $keys, false, true); + $result = $this->db->sql_query($sql); + + $map = array(); + while ($row = $this->db->sql_fetchrow($result)) + { + $map[$row['config_name']] = $row['config_value']; + } + + return $map; + } + + /** + * Removes multiple configuration options + * + * @param array $keys Set of configuration option names + * + * @return null + */ + public function deleteAll(array $keys) + { + $sql = 'DELETE + FROM ' . $this->table . ' + WHERE ' . $this->db->sql_in_set('config_name', $keys, false, true); + $result = $this->db->sql_query($sql); + } +} From 3a5d3bdd686e93539d51d8f1a78a5489192f73ef Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Tue, 5 Mar 2013 02:22:09 +0100 Subject: [PATCH 1147/2494] [ticket/10202] Add database schema for phpbb_config_db_text. PHPBB3-10202 --- phpBB/develop/create_schema_files.php | 8 ++++++++ phpBB/install/schemas/firebird_schema.sql | 9 +++++++++ phpBB/install/schemas/mssql_schema.sql | 17 +++++++++++++++++ phpBB/install/schemas/mysql_40_schema.sql | 8 ++++++++ phpBB/install/schemas/mysql_41_schema.sql | 8 ++++++++ phpBB/install/schemas/oracle_schema.sql | 11 +++++++++++ phpBB/install/schemas/postgres_schema.sql | 10 ++++++++++ phpBB/install/schemas/sqlite_schema.sql | 8 ++++++++ 8 files changed, 79 insertions(+) diff --git a/phpBB/develop/create_schema_files.php b/phpBB/develop/create_schema_files.php index a9caee2e25..907d177678 100644 --- a/phpBB/develop/create_schema_files.php +++ b/phpBB/develop/create_schema_files.php @@ -998,6 +998,14 @@ function get_schema_struct() ), ); + $schema_data['phpbb_config_text'] = array( + 'COLUMNS' => array( + 'config_name' => array('VCHAR', ''), + 'config_value' => array('TEXT', ''), + ), + 'PRIMARY_KEY' => 'config_name', + ); + $schema_data['phpbb_confirm'] = array( 'COLUMNS' => array( 'confirm_id' => array('CHAR:32', ''), diff --git a/phpBB/install/schemas/firebird_schema.sql b/phpBB/install/schemas/firebird_schema.sql index 3f813ef9b9..18ca184c65 100644 --- a/phpBB/install/schemas/firebird_schema.sql +++ b/phpBB/install/schemas/firebird_schema.sql @@ -222,6 +222,15 @@ ALTER TABLE phpbb_config ADD PRIMARY KEY (config_name);; CREATE INDEX phpbb_config_is_dynamic ON phpbb_config(is_dynamic);; +# Table: 'phpbb_config_text' +CREATE TABLE phpbb_config_text ( + config_name VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL, + config_value BLOB SUB_TYPE TEXT CHARACTER SET NONE DEFAULT '' NOT NULL +);; + +ALTER TABLE phpbb_config_text ADD PRIMARY KEY (config_name);; + + # Table: 'phpbb_confirm' CREATE TABLE phpbb_confirm ( confirm_id CHAR(32) CHARACTER SET NONE DEFAULT '' NOT NULL, diff --git a/phpBB/install/schemas/mssql_schema.sql b/phpBB/install/schemas/mssql_schema.sql index 30e95954d4..07c269ea3f 100644 --- a/phpBB/install/schemas/mssql_schema.sql +++ b/phpBB/install/schemas/mssql_schema.sql @@ -293,6 +293,23 @@ CREATE INDEX [is_dynamic] ON [phpbb_config]([is_dynamic]) ON [PRIMARY] GO +/* + Table: 'phpbb_config_text' +*/ +CREATE TABLE [phpbb_config_text] ( + [config_name] [varchar] (255) DEFAULT ('') NOT NULL , + [config_value] [varchar] (8000) DEFAULT ('') NOT NULL +) ON [PRIMARY] +GO + +ALTER TABLE [phpbb_config_text] WITH NOCHECK ADD + CONSTRAINT [PK_phpbb_config_text] PRIMARY KEY CLUSTERED + ( + [config_name] + ) ON [PRIMARY] +GO + + /* Table: 'phpbb_confirm' */ diff --git a/phpBB/install/schemas/mysql_40_schema.sql b/phpBB/install/schemas/mysql_40_schema.sql index 3bf8c22488..b432cd4aa2 100644 --- a/phpBB/install/schemas/mysql_40_schema.sql +++ b/phpBB/install/schemas/mysql_40_schema.sql @@ -157,6 +157,14 @@ CREATE TABLE phpbb_config ( ); +# Table: 'phpbb_config_text' +CREATE TABLE phpbb_config_text ( + config_name varbinary(255) DEFAULT '' NOT NULL, + config_value blob NOT NULL, + PRIMARY KEY (config_name) +); + + # Table: 'phpbb_confirm' CREATE TABLE phpbb_confirm ( confirm_id binary(32) DEFAULT '' NOT NULL, diff --git a/phpBB/install/schemas/mysql_41_schema.sql b/phpBB/install/schemas/mysql_41_schema.sql index 93348b2015..5842d35fc7 100644 --- a/phpBB/install/schemas/mysql_41_schema.sql +++ b/phpBB/install/schemas/mysql_41_schema.sql @@ -157,6 +157,14 @@ CREATE TABLE phpbb_config ( ) CHARACTER SET `utf8` COLLATE `utf8_bin`; +# Table: 'phpbb_config_text' +CREATE TABLE phpbb_config_text ( + config_name varchar(255) DEFAULT '' NOT NULL, + config_value text NOT NULL, + PRIMARY KEY (config_name) +) CHARACTER SET `utf8` COLLATE `utf8_bin`; + + # Table: 'phpbb_confirm' CREATE TABLE phpbb_confirm ( confirm_id char(32) DEFAULT '' NOT NULL, diff --git a/phpBB/install/schemas/oracle_schema.sql b/phpBB/install/schemas/oracle_schema.sql index 4dd151e54b..35f05e34cd 100644 --- a/phpBB/install/schemas/oracle_schema.sql +++ b/phpBB/install/schemas/oracle_schema.sql @@ -331,6 +331,17 @@ CREATE TABLE phpbb_config ( CREATE INDEX phpbb_config_is_dynamic ON phpbb_config (is_dynamic) / +/* + Table: 'phpbb_config_text' +*/ +CREATE TABLE phpbb_config_text ( + config_name varchar2(255) DEFAULT '' , + config_value clob DEFAULT '' , + CONSTRAINT pk_phpbb_config_text PRIMARY KEY (config_name) +) +/ + + /* Table: 'phpbb_confirm' */ diff --git a/phpBB/install/schemas/postgres_schema.sql b/phpBB/install/schemas/postgres_schema.sql index 77481add59..c0df97bd8f 100644 --- a/phpBB/install/schemas/postgres_schema.sql +++ b/phpBB/install/schemas/postgres_schema.sql @@ -269,6 +269,16 @@ CREATE TABLE phpbb_config ( CREATE INDEX phpbb_config_is_dynamic ON phpbb_config (is_dynamic); +/* + Table: 'phpbb_config_text' +*/ +CREATE TABLE phpbb_config_text ( + config_name varchar(255) DEFAULT '' NOT NULL, + config_value varchar(8000) DEFAULT '' NOT NULL, + PRIMARY KEY (config_name) +); + + /* Table: 'phpbb_confirm' */ diff --git a/phpBB/install/schemas/sqlite_schema.sql b/phpBB/install/schemas/sqlite_schema.sql index 7dd1fe70f6..d14f6797d0 100644 --- a/phpBB/install/schemas/sqlite_schema.sql +++ b/phpBB/install/schemas/sqlite_schema.sql @@ -154,6 +154,14 @@ CREATE TABLE phpbb_config ( CREATE INDEX phpbb_config_is_dynamic ON phpbb_config (is_dynamic); +# Table: 'phpbb_config_text' +CREATE TABLE phpbb_config_text ( + config_name varchar(255) NOT NULL DEFAULT '', + config_value text(65535) NOT NULL DEFAULT '', + PRIMARY KEY (config_name) +); + + # Table: 'phpbb_confirm' CREATE TABLE phpbb_confirm ( confirm_id char(32) NOT NULL DEFAULT '', From a73b76cb24bcbde96735d343d2a22e6723de8390 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Tue, 5 Mar 2013 02:26:46 +0100 Subject: [PATCH 1148/2494] [ticket/10202] Adjust method names to guidelines. PHPBB3-10202 --- phpBB/includes/config/db_text.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/phpBB/includes/config/db_text.php b/phpBB/includes/config/db_text.php index 79f83391f8..05ba4ddabf 100644 --- a/phpBB/includes/config/db_text.php +++ b/phpBB/includes/config/db_text.php @@ -56,7 +56,7 @@ class phpbb_config_db_text */ public function set($key, $value) { - $this->setAll(array($key => $value)); + $this->set_all(array($key => $value)); } /** @@ -69,7 +69,7 @@ class phpbb_config_db_text */ public function get($key) { - $map = $this->getAll(array($key)); + $map = $this->get_all(array($key)); return isset($map[$key]) ? $map[$key] : null; } @@ -83,7 +83,7 @@ class phpbb_config_db_text */ public function delete($key) { - $this->deleteAll(array($key)); + $this->delete_all(array($key)); } /** @@ -93,7 +93,7 @@ class phpbb_config_db_text * * @return null */ - public function setAll(array $map) + public function set_all(array $map) { $this->db->sql_transaction('begin'); @@ -124,7 +124,7 @@ class phpbb_config_db_text * * @return array Map from configuration names to values */ - public function getAll(array $keys) + public function get_all(array $keys) { $sql = 'SELECT * FROM ' . $this->table . ' @@ -147,7 +147,7 @@ class phpbb_config_db_text * * @return null */ - public function deleteAll(array $keys) + public function delete_all(array $keys) { $sql = 'DELETE FROM ' . $this->table . ' From 828c6c01bb3ffff4d58f1bea1aad82663d656f2c Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Tue, 5 Mar 2013 03:10:57 +0100 Subject: [PATCH 1149/2494] [ticket/10202] Add tests for phpbb_config_db_text. PHPBB3-10202 --- tests/config/db_text_test.php | 115 ++++++++++++++++++++++++++ tests/config/fixtures/config_text.xml | 19 +++++ 2 files changed, 134 insertions(+) create mode 100644 tests/config/db_text_test.php create mode 100644 tests/config/fixtures/config_text.xml diff --git a/tests/config/db_text_test.php b/tests/config/db_text_test.php new file mode 100644 index 0000000000..03e581fead --- /dev/null +++ b/tests/config/db_text_test.php @@ -0,0 +1,115 @@ +createXMLDataSet(dirname(__FILE__) . '/fixtures/config_text.xml'); + } + + public function setUp() + { + parent::setUp(); + + $this->db = $this->new_dbal(); + $this->config_text = new phpbb_config_db_text($this->db, 'phpbb_config_text'); + } + + public function test_get() + { + $this->assertSame('23', $this->config_text->get('foo')); + $this->assertSame('string-de-ding', $this->config_text->get('meh')); + } + + public function test_get_nonexisting() + { + $this->assertNull($this->config_text->get('noooooo')); + } + + public function test_set_new_get() + { + $this->config_text->set('barz', 'phpbb'); + $this->assertSame('phpbb', $this->config_text->get('barz')); + } + + public function test_set_replace_get() + { + $this->config_text->set('foo', '24'); + $this->assertSame('24', $this->config_text->get('foo')); + } + + public function test_set_get_long_string() + { + $expected = str_repeat('ABC', 10000); + $this->config_text->set('long', $expected); + $this->assertSame($expected, $this->config_text->get('long')); + } + + public function test_delete_get() + { + $this->config_text->delete('foo'); + $this->assertNull($this->config_text->get('foo')); + + $this->assertSame('42', $this->config_text->get('bar')); + $this->assertSame('string-de-ding', $this->config_text->get('meh')); + } + + public function test_get_all_empty() + { + $this->assertEmpty($this->config_text->get_all(array('key1', 'key2'))); + } + + public function test_get_all_subset() + { + $expected = array( + 'bar' => '42', + 'foo' => '23', + ); + + $actual = $this->config_text->get_all(array_keys($expected)); + ksort($actual); + + $this->assertSame($expected, $actual); + } + + public function test_set_all_get_all_subset() + { + $set_all_param = array( + // New entry + 'baby' => 'phpBB', + // Entry update + 'bar' => '64', + ); + + $this->config_text->set_all($set_all_param); + + $expected = array_merge($set_all_param, array( + 'foo' => '23', + )); + + $actual = $this->config_text->get_all(array_keys($expected)); + ksort($actual); + + $this->assertSame($expected, $actual); + } + + public function test_delete_all_get_remaining() + { + $this->config_text->delete_all(array('foo', 'bar')); + + $this->assertNull($this->config_text->get('bar')); + $this->assertNull($this->config_text->get('foo')); + + $this->assertSame('string-de-ding', $this->config_text->get('meh')); + } +} diff --git a/tests/config/fixtures/config_text.xml b/tests/config/fixtures/config_text.xml new file mode 100644 index 0000000000..5acac13ea3 --- /dev/null +++ b/tests/config/fixtures/config_text.xml @@ -0,0 +1,19 @@ + + + + config_name + config_value + + foo + 23 + + + bar + 42 + + + meh + string-de-ding + +
    +
    From 722092fe546025deeba487f18a34db0e60ca6f1c Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Tue, 5 Mar 2013 03:13:27 +0100 Subject: [PATCH 1150/2494] [ticket/10202] Define phpbb_config_db_text as a service. PHPBB3-10202 --- phpBB/config/services.yml | 6 ++++++ phpBB/config/tables.yml | 1 + 2 files changed, 7 insertions(+) diff --git a/phpBB/config/services.yml b/phpBB/config/services.yml index 7b2a24b2b3..b9c71844dc 100644 --- a/phpBB/config/services.yml +++ b/phpBB/config/services.yml @@ -58,6 +58,12 @@ services: - @cache.driver - %tables.config% + config_text: + class: phpbb_config_db_text + arguments: + - @dbal.conn + - %tables.config_text% + controller.helper: class: phpbb_controller_helper arguments: diff --git a/phpBB/config/tables.yml b/phpBB/config/tables.yml index b3093abf0c..1191fd0ae1 100644 --- a/phpBB/config/tables.yml +++ b/phpBB/config/tables.yml @@ -1,5 +1,6 @@ parameters: tables.config: %core.table_prefix%config + tables.config_text: %core.table_prefix%config_text tables.ext: %core.table_prefix%ext tables.log: %core.table_prefix%log tables.notification_types: %core.table_prefix%notification_types From 95764c4f0e6b1ceef7b14e2394637891482ade43 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Tue, 5 Mar 2013 03:41:26 +0100 Subject: [PATCH 1151/2494] [ticket/10202] Add $this->db->sql_freeresult($result) to SELECT queries. PHPBB3-10202 --- phpBB/includes/config/db_text.php | 1 + 1 file changed, 1 insertion(+) diff --git a/phpBB/includes/config/db_text.php b/phpBB/includes/config/db_text.php index 05ba4ddabf..0c18675ffc 100644 --- a/phpBB/includes/config/db_text.php +++ b/phpBB/includes/config/db_text.php @@ -136,6 +136,7 @@ class phpbb_config_db_text { $map[$row['config_name']] = $row['config_value']; } + $this->db->sql_freeresult($result); return $map; } From af02681960257a1df344275b2a1eb2893bc470df Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Tue, 5 Mar 2013 03:43:51 +0100 Subject: [PATCH 1152/2494] [ticket/10202] SQL escape the table name. PHPBB3-10202 --- phpBB/includes/config/db_text.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/config/db_text.php b/phpBB/includes/config/db_text.php index 0c18675ffc..7563a228f5 100644 --- a/phpBB/includes/config/db_text.php +++ b/phpBB/includes/config/db_text.php @@ -43,7 +43,7 @@ class phpbb_config_db_text public function __construct(phpbb_db_driver $db, $table) { $this->db = $db; - $this->table = $table; + $this->table = $this->db->sql_escape($table); } /** From 0071ad3bfd88780af24ebf9cb4d02eac76369994 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Tue, 5 Mar 2013 04:02:05 +0100 Subject: [PATCH 1153/2494] [ticket/10202] Improve method documentation. PHPBB3-10202 --- phpBB/includes/config/db_text.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/phpBB/includes/config/db_text.php b/phpBB/includes/config/db_text.php index 7563a228f5..6449a2e02b 100644 --- a/phpBB/includes/config/db_text.php +++ b/phpBB/includes/config/db_text.php @@ -75,7 +75,7 @@ class phpbb_config_db_text } /** - * Removes a configuration option + * Removes the configuration option with the name $key. * * @param string $key The configuration option's name * @@ -87,7 +87,9 @@ class phpbb_config_db_text } /** - * Sets a configuration option's value + * Mass set configuration options: Receives an associative array, + * treats array keys as configuration option names and associated + * array values as their configuration option values. * * @param array $map Map from configuration names to values * @@ -118,7 +120,10 @@ class phpbb_config_db_text } /** - * Gets a set of configuration options as a key => value map. + * Mass get configuration options: Receives a set of configuration + * option names and returns the result as a key => value map where + * array keys are configuration option names and array values are + * associated config option values. * * @param array $keys Set of configuration option names * @@ -142,7 +147,7 @@ class phpbb_config_db_text } /** - * Removes multiple configuration options + * Mass delete configuration options. * * @param array $keys Set of configuration option names * From 5158224845d4d21fc3d4bbb62ff3e0d798285071 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Tue, 5 Mar 2013 22:39:41 +0100 Subject: [PATCH 1154/2494] [ticket/10202] Upgrade TEXT to the bigger MTEXT. PHPBB3-10202 --- phpBB/develop/create_schema_files.php | 2 +- phpBB/install/schemas/mssql_schema.sql | 4 ++-- phpBB/install/schemas/mysql_40_schema.sql | 2 +- phpBB/install/schemas/mysql_41_schema.sql | 2 +- phpBB/install/schemas/postgres_schema.sql | 2 +- phpBB/install/schemas/sqlite_schema.sql | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/phpBB/develop/create_schema_files.php b/phpBB/develop/create_schema_files.php index 907d177678..b454fb2c16 100644 --- a/phpBB/develop/create_schema_files.php +++ b/phpBB/develop/create_schema_files.php @@ -1001,7 +1001,7 @@ function get_schema_struct() $schema_data['phpbb_config_text'] = array( 'COLUMNS' => array( 'config_name' => array('VCHAR', ''), - 'config_value' => array('TEXT', ''), + 'config_value' => array('MTEXT', ''), ), 'PRIMARY_KEY' => 'config_name', ); diff --git a/phpBB/install/schemas/mssql_schema.sql b/phpBB/install/schemas/mssql_schema.sql index 07c269ea3f..3530f9cd25 100644 --- a/phpBB/install/schemas/mssql_schema.sql +++ b/phpBB/install/schemas/mssql_schema.sql @@ -298,8 +298,8 @@ GO */ CREATE TABLE [phpbb_config_text] ( [config_name] [varchar] (255) DEFAULT ('') NOT NULL , - [config_value] [varchar] (8000) DEFAULT ('') NOT NULL -) ON [PRIMARY] + [config_value] [text] DEFAULT ('') NOT NULL +) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY] GO ALTER TABLE [phpbb_config_text] WITH NOCHECK ADD diff --git a/phpBB/install/schemas/mysql_40_schema.sql b/phpBB/install/schemas/mysql_40_schema.sql index b432cd4aa2..8c405677a8 100644 --- a/phpBB/install/schemas/mysql_40_schema.sql +++ b/phpBB/install/schemas/mysql_40_schema.sql @@ -160,7 +160,7 @@ CREATE TABLE phpbb_config ( # Table: 'phpbb_config_text' CREATE TABLE phpbb_config_text ( config_name varbinary(255) DEFAULT '' NOT NULL, - config_value blob NOT NULL, + config_value mediumblob NOT NULL, PRIMARY KEY (config_name) ); diff --git a/phpBB/install/schemas/mysql_41_schema.sql b/phpBB/install/schemas/mysql_41_schema.sql index 5842d35fc7..cb259aa57d 100644 --- a/phpBB/install/schemas/mysql_41_schema.sql +++ b/phpBB/install/schemas/mysql_41_schema.sql @@ -160,7 +160,7 @@ CREATE TABLE phpbb_config ( # Table: 'phpbb_config_text' CREATE TABLE phpbb_config_text ( config_name varchar(255) DEFAULT '' NOT NULL, - config_value text NOT NULL, + config_value mediumtext NOT NULL, PRIMARY KEY (config_name) ) CHARACTER SET `utf8` COLLATE `utf8_bin`; diff --git a/phpBB/install/schemas/postgres_schema.sql b/phpBB/install/schemas/postgres_schema.sql index c0df97bd8f..6dc507b46d 100644 --- a/phpBB/install/schemas/postgres_schema.sql +++ b/phpBB/install/schemas/postgres_schema.sql @@ -274,7 +274,7 @@ CREATE INDEX phpbb_config_is_dynamic ON phpbb_config (is_dynamic); */ CREATE TABLE phpbb_config_text ( config_name varchar(255) DEFAULT '' NOT NULL, - config_value varchar(8000) DEFAULT '' NOT NULL, + config_value TEXT DEFAULT '' NOT NULL, PRIMARY KEY (config_name) ); diff --git a/phpBB/install/schemas/sqlite_schema.sql b/phpBB/install/schemas/sqlite_schema.sql index d14f6797d0..ccb67ad46f 100644 --- a/phpBB/install/schemas/sqlite_schema.sql +++ b/phpBB/install/schemas/sqlite_schema.sql @@ -157,7 +157,7 @@ CREATE INDEX phpbb_config_is_dynamic ON phpbb_config (is_dynamic); # Table: 'phpbb_config_text' CREATE TABLE phpbb_config_text ( config_name varchar(255) NOT NULL DEFAULT '', - config_value text(65535) NOT NULL DEFAULT '', + config_value mediumtext(16777215) NOT NULL DEFAULT '', PRIMARY KEY (config_name) ); From 3a4b34ca3240c5f66faae8faa1c50baea1d6e108 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Tue, 5 Mar 2013 22:58:19 +0100 Subject: [PATCH 1155/2494] [ticket/10202] Add migration file for config_db_text. PHPBB3-10202 --- .../db/migration/data/310/config_db_text.php | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 phpBB/includes/db/migration/data/310/config_db_text.php diff --git a/phpBB/includes/db/migration/data/310/config_db_text.php b/phpBB/includes/db/migration/data/310/config_db_text.php new file mode 100644 index 0000000000..89f211adda --- /dev/null +++ b/phpBB/includes/db/migration/data/310/config_db_text.php @@ -0,0 +1,45 @@ +db_tools->sql_table_exists($this->table_prefix . 'config_text'); + } + + static public function depends_on() + { + return array('phpbb_db_migration_data_30x_3_0_11'); + } + + public function update_schema() + { + return array( + 'add_tables' => array( + $this->table_prefix . 'config_text' => array( + 'COLUMNS' => array( + 'config_name' => array('VCHAR', ''), + 'config_value' => array('MTEXT', ''), + ), + 'PRIMARY_KEY' => 'config_name', + ), + ), + ); + } + + public function revert_schema() + { + return array( + 'drop_tables' => array( + $this->table_prefix . 'config_text', + ), + ); + } +} From 32ff2348f10aed1aad3b78e7677dca34335b7adb Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Tue, 5 Mar 2013 23:15:46 +0100 Subject: [PATCH 1156/2494] [ticket/10202] Rename method names _all() to _array(). PHPBB3-10202 --- phpBB/includes/config/db_text.php | 12 ++++++------ tests/config/db_text_test.php | 22 +++++++++++----------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/phpBB/includes/config/db_text.php b/phpBB/includes/config/db_text.php index 6449a2e02b..b365cb5c77 100644 --- a/phpBB/includes/config/db_text.php +++ b/phpBB/includes/config/db_text.php @@ -56,7 +56,7 @@ class phpbb_config_db_text */ public function set($key, $value) { - $this->set_all(array($key => $value)); + $this->set_array(array($key => $value)); } /** @@ -69,7 +69,7 @@ class phpbb_config_db_text */ public function get($key) { - $map = $this->get_all(array($key)); + $map = $this->get_array(array($key)); return isset($map[$key]) ? $map[$key] : null; } @@ -83,7 +83,7 @@ class phpbb_config_db_text */ public function delete($key) { - $this->delete_all(array($key)); + $this->delete_array(array($key)); } /** @@ -95,7 +95,7 @@ class phpbb_config_db_text * * @return null */ - public function set_all(array $map) + public function set_array(array $map) { $this->db->sql_transaction('begin'); @@ -129,7 +129,7 @@ class phpbb_config_db_text * * @return array Map from configuration names to values */ - public function get_all(array $keys) + public function get_array(array $keys) { $sql = 'SELECT * FROM ' . $this->table . ' @@ -153,7 +153,7 @@ class phpbb_config_db_text * * @return null */ - public function delete_all(array $keys) + public function delete_array(array $keys) { $sql = 'DELETE FROM ' . $this->table . ' diff --git a/tests/config/db_text_test.php b/tests/config/db_text_test.php index 03e581fead..4818bba8c9 100644 --- a/tests/config/db_text_test.php +++ b/tests/config/db_text_test.php @@ -64,48 +64,48 @@ class phpbb_config_db_text_test extends phpbb_database_test_case $this->assertSame('string-de-ding', $this->config_text->get('meh')); } - public function test_get_all_empty() + public function test_get_array_empty() { - $this->assertEmpty($this->config_text->get_all(array('key1', 'key2'))); + $this->assertEmpty($this->config_text->get_array(array('key1', 'key2'))); } - public function test_get_all_subset() + public function test_get_array_subset() { $expected = array( 'bar' => '42', 'foo' => '23', ); - $actual = $this->config_text->get_all(array_keys($expected)); + $actual = $this->config_text->get_array(array_keys($expected)); ksort($actual); $this->assertSame($expected, $actual); } - public function test_set_all_get_all_subset() + public function test_set_array_get_array_subset() { - $set_all_param = array( + $set_array_param = array( // New entry 'baby' => 'phpBB', // Entry update 'bar' => '64', ); - $this->config_text->set_all($set_all_param); + $this->config_text->set_array($set_array_param); - $expected = array_merge($set_all_param, array( + $expected = array_merge($set_array_param, array( 'foo' => '23', )); - $actual = $this->config_text->get_all(array_keys($expected)); + $actual = $this->config_text->get_array(array_keys($expected)); ksort($actual); $this->assertSame($expected, $actual); } - public function test_delete_all_get_remaining() + public function test_delete_array_get_remaining() { - $this->config_text->delete_all(array('foo', 'bar')); + $this->config_text->delete_array(array('foo', 'bar')); $this->assertNull($this->config_text->get('bar')); $this->assertNull($this->config_text->get('foo')); From 5963905825ed65a522fe94e380c6c179a461e437 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 6 Mar 2013 11:32:23 +0100 Subject: [PATCH 1157/2494] [ticket/11404] Return empty array of avatar data if $row is empty While creating a group in the acp, the group data ($group_row) is empty. Due to that array_combine in phpbb_avatar_manager::clean_row() will cause PHP Warnings. In addition to that the required indexes 'avatar', 'avatar_width', 'avatar_height', and 'avatar_type' won't be defined. This patch will solve that issue. PHPBB3-11404 --- phpBB/includes/avatar/manager.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/phpBB/includes/avatar/manager.php b/phpBB/includes/avatar/manager.php index 9c60436de8..f126d69300 100644 --- a/phpBB/includes/avatar/manager.php +++ b/phpBB/includes/avatar/manager.php @@ -177,6 +177,17 @@ class phpbb_avatar_manager $keys = array_keys($row); $values = array_values($row); + // Upon creation of a user/group $row might be empty + if (empty($keys)) + { + return array( + 'avatar' => '', + 'avatar_type' => '', + 'avatar_width' => '', + 'avatar_height' => '', + ); + } + $keys = array_map(array('phpbb_avatar_manager', 'strip_prefix'), $keys); return array_combine($keys, $values); From e1f5e98fbca5c3f989a829fa763a471e04082e64 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 6 Mar 2013 12:26:43 +0100 Subject: [PATCH 1158/2494] [ticket/9657] Correctly state when to refresh last/first post info on approving PHPBB3-9657 --- phpBB/includes/mcp/mcp_queue.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/mcp/mcp_queue.php b/phpBB/includes/mcp/mcp_queue.php index 01abdc82d8..0e835b0aa9 100644 --- a/phpBB/includes/mcp/mcp_queue.php +++ b/phpBB/includes/mcp/mcp_queue.php @@ -613,12 +613,14 @@ class mcp_queue $topic_info[$topic_id]['posts'][] = (int) $post_id; $topic_info[$topic_id]['forum_id'] = (int) $post_data['forum_id']; - if ($post_id == $post_data['topic_first_post_id']) + // Refresh the first post, if the time or id is older then the current one + if ($post_id <= $post_data['topic_first_post_id'] || $post_data['post_time'] <= $post_data['topic_time']) { $topic_info[$topic_id]['first_post'] = true; } - if ($post_id == $post_data['topic_last_post_id']) + // Refresh the last post, if the time or id is newer then the current one + if ($post_id >= $post_data['topic_last_post_id'] || $post_data['post_time'] >= $post_data['topic_last_post_time']) { $topic_info[$topic_id]['last_post'] = true; } From d4aae49aa0d2a0ab67b5815c682e330e255b6879 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 6 Mar 2013 12:31:01 +0100 Subject: [PATCH 1159/2494] [ticket/9657] Move softdelete permission to new post-tab PHPBB3-9657 --- phpBB/language/en/acp/permissions_phpbb.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/language/en/acp/permissions_phpbb.php b/phpBB/language/en/acp/permissions_phpbb.php index 616dd46332..cf3a80e811 100644 --- a/phpBB/language/en/acp/permissions_phpbb.php +++ b/phpBB/language/en/acp/permissions_phpbb.php @@ -153,7 +153,7 @@ $lang = array_merge($lang, array( 'acl_f_reply' => array('lang' => 'Can reply to topics', 'cat' => 'post'), 'acl_f_edit' => array('lang' => 'Can edit own posts', 'cat' => 'post'), 'acl_f_delete' => array('lang' => 'Can permanently delete own posts', 'cat' => 'post'), - 'acl_f_softdelete' => array('lang' => 'Can delete own posts', 'cat' => 'actions'), + 'acl_f_softdelete' => array('lang' => 'Can delete own posts', 'cat' => 'post'), 'acl_f_ignoreflood' => array('lang' => 'Can ignore flood limit', 'cat' => 'post'), 'acl_f_postcount' => array('lang' => 'Increment post counter
    Please note that this setting only affects new posts.', 'cat' => 'post'), 'acl_f_noapprove' => array('lang' => 'Can post without approval', 'cat' => 'post'), From 164a06c0665e0f5cbbfb3314b323ffe9a05648d7 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 6 Mar 2013 12:43:03 +0100 Subject: [PATCH 1160/2494] [ticket/9657] Fix "Display this post" link if javascript is disabled PHPBB3-9657 --- phpBB/viewtopic.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index 49967d4c25..6cfbef6dc7 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -1688,9 +1688,9 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i) 'S_TOPIC_POSTER' => ($topic_data['topic_poster'] == $poster_id) ? true : false, 'S_IGNORE_POST' => ($row['foe']) ? true : false, - 'L_IGNORE_POST' => ($row['foe']) ? sprintf($user->lang['POST_BY_FOE'], get_username_string('full', $poster_id, $row['username'], $row['user_colour'], $row['post_username']), '', '') : '', + 'L_IGNORE_POST' => ($row['foe']) ? sprintf($user->lang['POST_BY_FOE'], get_username_string('full', $poster_id, $row['username'], $row['user_colour'], $row['post_username'])) : '', 'S_POST_HIDDEN' => $row['hide_post'], - 'L_POST_DISPLAY' => ($row['hide_post']) ? $user->lang('POST_DISPLAY', '', '') : '', + 'L_POST_DISPLAY' => ($row['hide_post']) ? $user->lang('POST_DISPLAY', '', '') : '', ); $user_poster_data = $user_cache[$poster_id]; From f5482e73fddc1a00f2c9df5f6428da70e2777547 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 6 Mar 2013 12:52:15 +0100 Subject: [PATCH 1161/2494] [ticket/9657] Correctly return to viewtopic page when handling posts While managing posts from viewtopic.php we should return to that page, rather then the MCP PHPBB3-9657 --- phpBB/viewtopic.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index 6cfbef6dc7..c192bb28d9 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -1659,7 +1659,7 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i) 'U_YIM' => $user_cache[$poster_id]['yim'], 'U_JABBER' => $user_cache[$poster_id]['jabber'], - 'U_APPROVE_ACTION' => append_sid("{$phpbb_root_path}mcp.$phpEx", "i=queue&p={$row['post_id']}&f=$forum_id"), + 'U_APPROVE_ACTION' => append_sid("{$phpbb_root_path}mcp.$phpEx", "i=queue&p={$row['post_id']}&f=$forum_id&redirect=" . urlencode(str_replace('&', '&', $viewtopic_url . '&p=' . $row['post_id'] . '#p' . $row['post_id']))), 'U_REPORT' => ($auth->acl_get('f_report', $forum_id)) ? append_sid("{$phpbb_root_path}report.$phpEx", 'f=' . $forum_id . '&p=' . $row['post_id']) : '', 'U_MCP_REPORT' => ($auth->acl_get('m_report', $forum_id)) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=reports&mode=report_details&f=' . $forum_id . '&p=' . $row['post_id'], true, $user->session_id) : '', 'U_MCP_APPROVE' => ($auth->acl_get('m_approve', $forum_id)) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&mode=approve_details&f=' . $forum_id . '&p=' . $row['post_id'], true, $user->session_id) : '', From 9bddf73d315de89fc65b74bcc81aca8dfe57a796 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 6 Mar 2013 13:52:11 +0100 Subject: [PATCH 1162/2494] [ticket/9657] Add migration files for updating the database PHPBB3-9657 --- .../db/migration/data/310/softdelete_p1.php | 171 ++++++++++++++++++ .../db/migration/data/310/softdelete_p2.php | 74 ++++++++ 2 files changed, 245 insertions(+) create mode 100644 phpBB/includes/db/migration/data/310/softdelete_p1.php create mode 100644 phpBB/includes/db/migration/data/310/softdelete_p2.php diff --git a/phpBB/includes/db/migration/data/310/softdelete_p1.php b/phpBB/includes/db/migration/data/310/softdelete_p1.php new file mode 100644 index 0000000000..35f6138ef6 --- /dev/null +++ b/phpBB/includes/db/migration/data/310/softdelete_p1.php @@ -0,0 +1,171 @@ +db_tools->sql_column_exists($this->table_prefix . 'posts', 'post_visibility'); + } + + static public function depends_on() + { + return array('phpbb_db_migration_data_310_dev'); + } + + public function update_schema() + { + return array( + 'add_columns' => array( + $this->table_prefix . 'forums' => array( + 'forum_posts_approved' => array('UINT', 0), + 'forum_posts_unapproved' => array('UINT', 0), + 'forum_posts_softdeleted' => array('UINT', 0), + 'forum_topics_approved' => array('UINT', 0), + 'forum_topics_unapproved' => array('UINT', 0), + 'forum_topics_softdeleted' => array('UINT', 0), + ), + $this->table_prefix . 'posts' => array( + 'post_visibility' => array('TINT:3', 0), + 'post_delete_time' => array('TIMESTAMP', 0), + 'post_delete_reason' => array('STEXT_UNI', ''), + 'post_delete_user' => array('UINT', 0), + ), + $this->table_prefix . 'topics' => array( + 'topic_visibility' => array('TINT:3', 0), + 'topic_delete_time' => array('TIMESTAMP', 0), + 'topic_delete_reason' => array('STEXT_UNI', ''), + 'topic_delete_user' => array('UINT', 0), + 'topic_posts_approved' => array('UINT', 0), + 'topic_posts_unapproved' => array('UINT', 0), + 'topic_posts_softdeleted' => array('UINT', 0), + ), + ), + 'add_index' => array( + $this->table_prefix . 'posts' => array( + 'post_visibility' => array('post_visibility'), + ), + $this->table_prefix . 'topics' => array( + 'topic_visibility' => array('topic_visibility'), + 'forum_vis_last' => array('forum_id', 'topic_visibility', 'topic_last_post_id'), + ), + ), + ); + } + + public function revert_schema() + { + return array( + 'drop_columns' => array( + $this->table_prefix . 'forums' => array( + 'forum_posts_approved', + 'forum_posts_unapproved', + 'forum_posts_softdeleted', + 'forum_topics_approved', + 'forum_topics_unapproved', + 'forum_topics_softdeleted', + ), + $this->table_prefix . 'posts' => array( + 'post_visibility', + 'post_delete_time', + 'post_delete_reason', + 'post_delete_user', + ), + $this->table_prefix . 'topics' => array( + 'topic_visibility', + 'topic_delete_time', + 'topic_delete_reason', + 'topic_delete_user', + 'topic_posts_approved', + 'topic_posts_unapproved', + 'topic_posts_softdeleted', + ), + ), + 'drop_keys' => array( + $this->table_prefix . 'posts' => array('post_visibility'), + $this->table_prefix . 'topics' => array('topic_visibility', 'forum_vis_last'), + ), + ); + } + + public function update_data() + { + return array( + array('custom', array(array($this, 'update_post_visibility'))), + array('custom', array(array($this, 'update_topic_visibility'))), + array('custom', array(array($this, 'update_topic_forum_counts'))), + + array('permission.add', array('f_softdelete', false)), + array('permission.add', array('m_softdelete', false)), + ); + } + + public function update_post_visibility() + { + $sql = 'UPDATE ' . $this->table_prefix . 'posts + SET post_visibility = post_approved'; + $this->sql_query($sql); + } + + public function update_topic_visibility() + { + $sql = 'UPDATE ' . $this->table_prefix . 'topics + SET topic_visibility = topic_approved'; + $this->sql_query($sql); + } + + public function update_topic_forum_counts() + { + $sql = 'UPDATE ' . $this->table_prefix . 'topics + SET topic_posts_approved = topic_replies + 1, + topic_posts_unapproved = topic_replies_real - topic_replies + WHERE topic_visibility = ' . ITEM_APPROVED; + $this->sql_query($sql); + + $sql = 'UPDATE ' . $this->table_prefix . 'topics + SET topic_posts_approved = 0, + topic_posts_unapproved = (topic_replies_real - topic_replies) + 1 + WHERE topic_visibility = ' . ITEM_UNAPPROVED; + $this->sql_query($sql); + + $sql = 'SELECT forum_id, topic_visibility, COUNT(topic_id) AS sum_topics, SUM(topic_posts) AS sum_posts, SUM(topic_posts_unapproved) AS sum_posts_unapproved + FROM ' . $this->table_prefix . 'topics + GROUP BY forum_id, topic_visibility'; + $result = $this->db->sql_query($sql); + + $update_forums = array(); + while ($row = $this->db->sql_fetchrow($result)) + { + $forum_id = (int) $row['forum_id']; + if (!isset($update_forums[$forum_id])) + { + $update_forums[$forum_id] = array( + 'forum_posts_approved' => 0, + 'forum_posts_unapproved' => 0, + 'forum_topics_approved' => 0, + 'forum_topics_unapproved' => 0, + ); + } + + $update_forums[$forum_id]['forum_posts_approved'] += (int) $row['sum_posts']; + $update_forums[$forum_id]['forum_posts_unapproved'] += (int) $row['sum_posts_unapproved']; + + $update_forums[$forum_id][(($row['topic_visibility'] == ITEM_APPROVED) ? 'forum_topics_approved' : 'forum_topics_unapproved')] += (int) $row['sum_topics']; + } + $this->db->sql_freeresult($result); + + foreach ($update_forums as $forum_id => $forum_data) + { + $sql = 'UPDATE ' . FORUMS_TABLE . ' + SET ' . $this->db->sql_build_array('UPDATE', $forum_data) . ' + WHERE forum_id = ' . $forum_id; + $this->sql_query($sql); + } + } +} diff --git a/phpBB/includes/db/migration/data/310/softdelete_p2.php b/phpBB/includes/db/migration/data/310/softdelete_p2.php new file mode 100644 index 0000000000..15de8e7185 --- /dev/null +++ b/phpBB/includes/db/migration/data/310/softdelete_p2.php @@ -0,0 +1,74 @@ +db_tools->sql_column_exists($this->table_prefix . 'posts', 'post_approved'); + } + + static public function depends_on() + { + return array( + 'phpbb_db_migration_data_310_dev', + 'phpbb_db_migration_data_310_softdelete_p1', + ); + } + + public function update_schema() + { + return array( + 'drop_columns' => array( + $this->table_prefix . 'forums' => array('forum_posts', 'forum_topics', 'forum_topics_real'), + $this->table_prefix . 'posts' => array('post_approved'), + $this->table_prefix . 'topics' => array('topic_approved', 'topic_replies', 'topic_replies_real'), + ), + 'drop_keys' => array( + $this->table_prefix . 'posts' => array('post_approved'), + $this->table_prefix . 'topics' => array('forum_appr_last'), + ), + ); + } + + public function revert_schema() + { + return array( + 'add_columns' => array( + $this->table_prefix . 'forums' => array( + 'forum_posts' => array('UINT', 0), + 'forum_topics' => array('UINT', 0), + 'forum_topics_real' => array('UINT', 0), + ), + $this->table_prefix . 'posts' => array( + 'post_approved' => array('BOOL', 1), + ), + $this->table_prefix . 'topics' => array( + 'topic_approved' => array('BOOL', 1), + 'topic_replies' => array('UINT', 0), + 'topic_replies_real' => array('UINT', 0), + ), + ), + 'add_index' => array( + $this->table_prefix . 'posts' => array( + 'post_approved' => array('post_approved'), + ), + $this->table_prefix . 'topics' => array( + 'forum_appr_last' => array('forum_id', 'topic_approved', 'topic_last_post_id'), + ), + ), + ); + } + + public function update_data() + { + return array( + ); + } +} From 1a17a3854fa62e0fcdb018e1dcb53253b67ea8f1 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 6 Mar 2013 16:13:34 +0100 Subject: [PATCH 1163/2494] [ticket/9657] Fix unit tests missing global container. PHPBB3-9657 --- tests/content_visibility/delete_post_test.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/content_visibility/delete_post_test.php b/tests/content_visibility/delete_post_test.php index 3f15d5a158..e7ab3e3879 100644 --- a/tests/content_visibility/delete_post_test.php +++ b/tests/content_visibility/delete_post_test.php @@ -262,13 +262,16 @@ class phpbb_content_visibility_delete_post_test extends phpbb_database_test_case */ public function test_delete_post($forum_id, $topic_id, $post_id, $data, $is_soft, $reason, $expected_posts, $expected_topic, $expected_forum) { - global $auth, $cache, $config, $db; + global $auth, $cache, $config, $db, $phpbb_container; $config['search_type'] = 'phpbb_mock_search'; $cache = new phpbb_mock_cache; $db = $this->new_dbal(); set_config_count(null, null, null, new phpbb_config(array('num_posts' => 3, 'num_topics' => 1))); + $phpbb_container = new phpbb_mock_container_builder(); + $phpbb_container->set('notification_manager', new phpbb_mock_notification_manager()); + // Create auth mock $auth = $this->getMock('phpbb_auth'); $auth->expects($this->any()) From 74a9ecfd24e745a0c0ad394bac915d121ea72278 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 6 Mar 2013 16:29:50 +0100 Subject: [PATCH 1164/2494] [ticket/9657] Fix wrongly added notifications when post is posted softdeleted The post/topic should not trigger "*_in_queue" notifications if it is softdeleted, as it is not in the queue then. PHPBB3-9657 --- phpBB/includes/functions_posting.php | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index f9dacae655..d2ff095e25 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -2214,7 +2214,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u break; } } - else + else if ($post_visibility == ITEM_UNAPPROVED) { switch ($mode) { @@ -2231,6 +2231,32 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u case 'edit_first_post': case 'edit': case 'edit_last_post': + // @todo: Check whether these notification deletions are correct + $phpbb_notifications->delete_notifications('topic', $data['topic_id']); + + $phpbb_notifications->delete_notifications(array( + 'quote', + 'bookmark', + 'post', + ), $data['post_id']); + break; + } + } + else if ($post_visibility == ITEM_DELETED) + { + switch ($mode) + { + case 'post': + case 'reply': + case 'quote': + // Nothing to do here + break; + + case 'edit_topic': + case 'edit_first_post': + case 'edit': + case 'edit_last_post': + // @todo: Check whether these notification deletions are correct $phpbb_notifications->delete_notifications('topic', $data['topic_id']); $phpbb_notifications->delete_notifications(array( From 3aab72d79bdad45933e87ebce39483a7664ffd68 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Wed, 6 Mar 2013 09:53:41 -0600 Subject: [PATCH 1165/2494] [ticket/11408] user_jabber instead of jabber PHPBB3-11408 --- phpBB/includes/notification/method/jabber.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/notification/method/jabber.php b/phpBB/includes/notification/method/jabber.php index e3eb571fbc..863846b8a5 100644 --- a/phpBB/includes/notification/method/jabber.php +++ b/phpBB/includes/notification/method/jabber.php @@ -53,7 +53,7 @@ class phpbb_notification_method_jabber extends phpbb_notification_method_email */ public function is_available() { - return ($this->global_available() && $this->user->data['jabber']); + return ($this->global_available() && $this->user->data['user_jabber']); } /** From 300a42f5b840384eef87abfd1b415102b3367f16 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 7 Mar 2013 11:14:01 +0100 Subject: [PATCH 1166/2494] [ticket/11421] Correctly display submit button when needed PHPBB3-11421 --- phpBB/styles/prosilver/template/ucp_notifications.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/styles/prosilver/template/ucp_notifications.html b/phpBB/styles/prosilver/template/ucp_notifications.html index a2d558d0ca..b06d6bb759 100644 --- a/phpBB/styles/prosilver/template/ucp_notifications.html +++ b/phpBB/styles/prosilver/template/ucp_notifications.html @@ -118,7 +118,7 @@
    - +
    {S_HIDDEN_FIELDS} From 2caf7fbf121d969948a4384517f17986306db6ad Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 7 Mar 2013 11:30:02 +0100 Subject: [PATCH 1167/2494] [ticket/11417] FIx submit button description on notifications options page PHPBB3-11417 --- phpBB/styles/prosilver/template/ucp_notifications.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/styles/prosilver/template/ucp_notifications.html b/phpBB/styles/prosilver/template/ucp_notifications.html index a2d558d0ca..e59e674ba2 100644 --- a/phpBB/styles/prosilver/template/ucp_notifications.html +++ b/phpBB/styles/prosilver/template/ucp_notifications.html @@ -122,7 +122,7 @@
    {S_HIDDEN_FIELDS} - + {S_FORM_TOKEN}
    From 899d85792914c6095996fa47b389b1b945501757 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 7 Mar 2013 11:39:33 +0100 Subject: [PATCH 1168/2494] [ticket/11390] Hide pagination when there are no notifications PHPBB3-11390 --- .../styles/prosilver/template/ucp_notifications.html | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/phpBB/styles/prosilver/template/ucp_notifications.html b/phpBB/styles/prosilver/template/ucp_notifications.html index a2d558d0ca..e407e47fea 100644 --- a/phpBB/styles/prosilver/template/ucp_notifications.html +++ b/phpBB/styles/prosilver/template/ucp_notifications.html @@ -48,6 +48,7 @@ +
    + +

    {L_NO_NOTIFICATIONS}

    + +
    From 7ac945358ed5aefa947f29b359210a076c181a0a Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 7 Mar 2013 11:39:55 +0100 Subject: [PATCH 1169/2494] [ticket/11390] Correctly separate list of notifications from header PHPBB3-11390 --- phpBB/styles/prosilver/template/ucp_notifications.html | 2 ++ 1 file changed, 2 insertions(+) diff --git a/phpBB/styles/prosilver/template/ucp_notifications.html b/phpBB/styles/prosilver/template/ucp_notifications.html index e407e47fea..ac36809985 100644 --- a/phpBB/styles/prosilver/template/ucp_notifications.html +++ b/phpBB/styles/prosilver/template/ucp_notifications.html @@ -71,6 +71,8 @@
    {L_MARK_READ}
    + +
    • From d219eafa16449bba1adb286fa01f7c0355745905 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 7 Mar 2013 12:18:53 +0100 Subject: [PATCH 1170/2494] [ticket/11407] Fix description of "notification" option. PHPBB3-11407 --- phpBB/styles/prosilver/template/ucp_notifications.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/styles/prosilver/template/ucp_notifications.html b/phpBB/styles/prosilver/template/ucp_notifications.html index a2d558d0ca..9004d235b4 100644 --- a/phpBB/styles/prosilver/template/ucp_notifications.html +++ b/phpBB/styles/prosilver/template/ucp_notifications.html @@ -41,7 +41,7 @@
      checked="checked" /> {notification_methods.NAME}
      -
      checked="checked" /> {notification_methods.NAME}
      +
      checked="checked" /> {L_NOTIFICATIONS}
    • From bb584627248cc95443ebda511fca51effea6d0af Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Thu, 7 Mar 2013 13:03:27 +0100 Subject: [PATCH 1171/2494] [ticket/11404] Use a default data row if $row is empty in clean_row() A statically defined $default_row will be used inside the phpbb_avatar_manager::clean_row() method if the $row passed to it is empty. PHPBB3-11404 --- phpBB/includes/avatar/manager.php | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/phpBB/includes/avatar/manager.php b/phpBB/includes/avatar/manager.php index f126d69300..58d994c3c0 100644 --- a/phpBB/includes/avatar/manager.php +++ b/phpBB/includes/avatar/manager.php @@ -45,6 +45,17 @@ class phpbb_avatar_manager */ protected $container; + /** + * Default avatar data row + * @var array + */ + static protected $default_row = array( + 'avatar' => '', + 'avatar_type' => '', + 'avatar_width' => '', + 'avatar_height' => '', + ); + /** * Construct an avatar manager object * @@ -174,20 +185,15 @@ class phpbb_avatar_manager */ static public function clean_row($row) { + // Upon creation of a user/group $row might be empty + if (empty($row)) + { + return self::$default_row; + } + $keys = array_keys($row); $values = array_values($row); - // Upon creation of a user/group $row might be empty - if (empty($keys)) - { - return array( - 'avatar' => '', - 'avatar_type' => '', - 'avatar_width' => '', - 'avatar_height' => '', - ); - } - $keys = array_map(array('phpbb_avatar_manager', 'strip_prefix'), $keys); return array_combine($keys, $values); From 60c0da8b54e5347e472d2ce97e756623717fd011 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 7 Mar 2013 13:15:55 +0100 Subject: [PATCH 1172/2494] [ticket/9657] Remove empty update_data() method from p2 migration PHPBB3-9657 --- phpBB/includes/db/migration/data/310/softdelete_p2.php | 6 ------ 1 file changed, 6 deletions(-) diff --git a/phpBB/includes/db/migration/data/310/softdelete_p2.php b/phpBB/includes/db/migration/data/310/softdelete_p2.php index 15de8e7185..7320a2c2bf 100644 --- a/phpBB/includes/db/migration/data/310/softdelete_p2.php +++ b/phpBB/includes/db/migration/data/310/softdelete_p2.php @@ -65,10 +65,4 @@ class phpbb_db_migration_data_310_softdelete_p2 extends phpbb_db_migration ), ); } - - public function update_data() - { - return array( - ); - } } From bff6cf40ba03320247c777d651d47673b3d36d2b Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 7 Mar 2013 14:02:11 +0100 Subject: [PATCH 1173/2494] [ticket/9657] Fix colum name in migration file PHPBB3-9657 --- phpBB/includes/db/migration/data/310/softdelete_p1.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/db/migration/data/310/softdelete_p1.php b/phpBB/includes/db/migration/data/310/softdelete_p1.php index 35f6138ef6..84f8eebd4a 100644 --- a/phpBB/includes/db/migration/data/310/softdelete_p1.php +++ b/phpBB/includes/db/migration/data/310/softdelete_p1.php @@ -134,7 +134,7 @@ class phpbb_db_migration_data_310_softdelete_p1 extends phpbb_db_migration WHERE topic_visibility = ' . ITEM_UNAPPROVED; $this->sql_query($sql); - $sql = 'SELECT forum_id, topic_visibility, COUNT(topic_id) AS sum_topics, SUM(topic_posts) AS sum_posts, SUM(topic_posts_unapproved) AS sum_posts_unapproved + $sql = 'SELECT forum_id, topic_visibility, COUNT(topic_id) AS sum_topics, SUM(topic_posts_approved) AS sum_posts_approved, SUM(topic_posts_unapproved) AS sum_posts_unapproved FROM ' . $this->table_prefix . 'topics GROUP BY forum_id, topic_visibility'; $result = $this->db->sql_query($sql); @@ -153,7 +153,7 @@ class phpbb_db_migration_data_310_softdelete_p1 extends phpbb_db_migration ); } - $update_forums[$forum_id]['forum_posts_approved'] += (int) $row['sum_posts']; + $update_forums[$forum_id]['forum_posts_approved'] += (int) $row['sum_posts_approved']; $update_forums[$forum_id]['forum_posts_unapproved'] += (int) $row['sum_posts_unapproved']; $update_forums[$forum_id][(($row['topic_visibility'] == ITEM_APPROVED) ? 'forum_topics_approved' : 'forum_topics_unapproved')] += (int) $row['sum_topics']; From 0f7303627550da228e18251256ce180e309cda11 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 7 Mar 2013 14:10:16 +0100 Subject: [PATCH 1174/2494] [ticket/9657] Explain soft delete permission in ACP PHPBB3-9657 --- phpBB/language/en/acp/permissions_phpbb.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpBB/language/en/acp/permissions_phpbb.php b/phpBB/language/en/acp/permissions_phpbb.php index cf3a80e811..87e316383c 100644 --- a/phpBB/language/en/acp/permissions_phpbb.php +++ b/phpBB/language/en/acp/permissions_phpbb.php @@ -153,7 +153,7 @@ $lang = array_merge($lang, array( 'acl_f_reply' => array('lang' => 'Can reply to topics', 'cat' => 'post'), 'acl_f_edit' => array('lang' => 'Can edit own posts', 'cat' => 'post'), 'acl_f_delete' => array('lang' => 'Can permanently delete own posts', 'cat' => 'post'), - 'acl_f_softdelete' => array('lang' => 'Can delete own posts', 'cat' => 'post'), + 'acl_f_softdelete' => array('lang' => 'Can soft delete own posts
      Soft deleted posts can be restored by moderators, having the approve posts permission.', 'cat' => 'post'), 'acl_f_ignoreflood' => array('lang' => 'Can ignore flood limit', 'cat' => 'post'), 'acl_f_postcount' => array('lang' => 'Increment post counter
      Please note that this setting only affects new posts.', 'cat' => 'post'), 'acl_f_noapprove' => array('lang' => 'Can post without approval', 'cat' => 'post'), @@ -178,7 +178,7 @@ $lang = array_merge($lang, array( 'acl_m_approve' => array('lang' => 'Can approve posts', 'cat' => 'post_actions'), 'acl_m_report' => array('lang' => 'Can close and delete reports', 'cat' => 'post_actions'), 'acl_m_chgposter' => array('lang' => 'Can change post author', 'cat' => 'post_actions'), - 'acl_m_softdelete' => array('lang' => 'Can delete posts', 'cat' => 'post_actions'), + 'acl_m_softdelete' => array('lang' => 'Can soft delete posts
      Soft deleted posts can be restored by moderators, having the approve posts permission.', 'cat' => 'post_actions'), 'acl_m_restore' => array('lang' => 'Can restore deleted posts', 'cat' => 'post_actions'), 'acl_m_move' => array('lang' => 'Can move topics', 'cat' => 'topic_actions'), From 1a498524138a7a3192ad14ad10f714b34488321f Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 7 Mar 2013 14:15:14 +0100 Subject: [PATCH 1175/2494] [ticket/9657] Remove unused email variables PHPBB3-9657 --- phpBB/includes/mcp/mcp_queue.php | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/phpBB/includes/mcp/mcp_queue.php b/phpBB/includes/mcp/mcp_queue.php index 0e835b0aa9..4383c5d571 100644 --- a/phpBB/includes/mcp/mcp_queue.php +++ b/phpBB/includes/mcp/mcp_queue.php @@ -654,9 +654,6 @@ class mcp_queue { $phpbb_notifications = $phpbb_container->get('notification_manager'); - // Send out normal user notifications - $email_sig = str_replace('
      ', "\n", "-- \n" . $config['board_email_sig']); - // Handle notifications foreach ($post_info as $post_id => $post_data) { @@ -813,9 +810,6 @@ class mcp_queue // Only send out the mails, when the posts are being approved if ($action == 'approve') { - // Send out normal user notifications - $email_sig = str_replace('
      ', "\n", "-- \n" . $config['board_email_sig']); - // Handle notifications $phpbb_notifications = $phpbb_container->get('notification_manager'); @@ -961,8 +955,6 @@ class mcp_queue { $disapprove_reason_lang = strtoupper($row['reason_title']); } - - $email_disapprove_reason = $disapprove_reason; } } @@ -1121,7 +1113,7 @@ class mcp_queue } } - unset($lang_reasons,$post_info, $disapprove_reason, $email_disapprove_reason, $disapprove_reason_lang); + unset($lang_reasons, $post_info, $disapprove_reason, $disapprove_reason_lang); if ($num_disapproved_topics) { From 692e0f1e33e72062d9bddd0a47df18d230575600 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 7 Mar 2013 16:17:04 +0100 Subject: [PATCH 1176/2494] [ticket/9657] Adapt confirm box templates to new layout PHPBB3-9657 --- .../template/confirm_delete_body.html | 37 +++++++++---------- .../prosilver/template/mcp_approve.html | 2 +- 2 files changed, 19 insertions(+), 20 deletions(-) diff --git a/phpBB/styles/prosilver/template/confirm_delete_body.html b/phpBB/styles/prosilver/template/confirm_delete_body.html index 9b5b9906d0..9f36d2d824 100644 --- a/phpBB/styles/prosilver/template/confirm_delete_body.html +++ b/phpBB/styles/prosilver/template/confirm_delete_body.html @@ -2,28 +2,27 @@

      {MESSAGE_TEXT}

      -
      - -
      -
      -
      - -
      -
      - + + + - -
      -

      {L_DELETE_REASON_EXPLAIN}
      -
      -
      - -
      + + + +
      +   + +
      + diff --git a/phpBB/styles/prosilver/template/mcp_approve.html b/phpBB/styles/prosilver/template/mcp_approve.html index baa660f8f7..f0978df518 100644 --- a/phpBB/styles/prosilver/template/mcp_approve.html +++ b/phpBB/styles/prosilver/template/mcp_approve.html @@ -7,7 +7,7 @@ - + - +
    - + diff --git a/phpBB/styles/subsilver2/template/timezone_option.html b/phpBB/styles/subsilver2/template/timezone_option.html index 9b68f81557..0f27719f86 100644 --- a/phpBB/styles/subsilver2/template/timezone_option.html +++ b/phpBB/styles/subsilver2/template/timezone_option.html @@ -15,6 +15,6 @@ {S_TZ_OPTIONS} - + diff --git a/phpBB/styles/subsilver2/template/ucp_groups_manage.html b/phpBB/styles/subsilver2/template/ucp_groups_manage.html index 13b8b8c6b7..b8e7e29481 100644 --- a/phpBB/styles/subsilver2/template/ucp_groups_manage.html +++ b/phpBB/styles/subsilver2/template/ucp_groups_manage.html @@ -95,7 +95,7 @@ - + diff --git a/phpBB/styles/subsilver2/template/ucp_profile_avatar.html b/phpBB/styles/subsilver2/template/ucp_profile_avatar.html index 885d46ef0b..60a816d00a 100644 --- a/phpBB/styles/subsilver2/template/ucp_profile_avatar.html +++ b/phpBB/styles/subsilver2/template/ucp_profile_avatar.html @@ -48,6 +48,6 @@ - + From 02a8150bb615b6319bcdfd170e3febe34117f16c Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Tue, 2 Jul 2013 11:08:52 -0500 Subject: [PATCH 1988/2494] [feature/twig] INCLUDEPHP behavior now supports local relative paths As a last resort, now we use the Twig Loader to find the correct file to include to (most specific file first, then parent styles). Also allows using @namespace convention. This is ONLY done if the specified path is not an absolute path AND the file does not exist relative to the phpBB root path. PHPBB3-11598 --- phpBB/includes/template/twig/node/includephp.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/phpBB/includes/template/twig/node/includephp.php b/phpBB/includes/template/twig/node/includephp.php index 33142bf05a..a19ce43653 100644 --- a/phpBB/includes/template/twig/node/includephp.php +++ b/phpBB/includes/template/twig/node/includephp.php @@ -52,11 +52,18 @@ class phpbb_template_twig_node_includephp extends Twig_Node ->raw(";\n") ->write("if (phpbb_is_absolute(\$location)) {\n") ->indent() + // Absolute path specified ->write("require(\$location);\n") ->outdent() + ->write("} else if (file_exists(\$this->getEnvironment()->get_phpbb_root_path() . \$location)) {\n") + ->indent() + // PHP file relative to phpbb_root_path + ->write("require(\$this->getEnvironment()->get_phpbb_root_path() . \$location);\n") + ->outdent() ->write("} else {\n") ->indent() - ->write("require(\$this->getEnvironment()->get_phpbb_root_path() . \$location);\n") + // Local path (behaves like INCLUDE) + ->write("require(\$this->getEnvironment()->getLoader()->getCacheKey(\$location));\n") ->outdent() ->write("}\n") ; From 9dce2b28af639d74a0e7eb15b7e1d4c29a5396a3 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Tue, 2 Jul 2013 11:21:05 -0500 Subject: [PATCH 1989/2494] [feature/twig] Fix template test case PHPBB3-11598 --- tests/template/template_test_case.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/template/template_test_case.php b/tests/template/template_test_case.php index 63f0c873b0..3e2cd5a387 100644 --- a/tests/template/template_test_case.php +++ b/tests/template/template_test_case.php @@ -29,7 +29,7 @@ class phpbb_template_template_test_case extends phpbb_test_case try { - $this->assertTrue($this->template->display($handle, false)); + $this->template->display($handle, false); } catch (Exception $exception) { From c6c064a1360cf6ef488adbe516cea5c4d7138f0c Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Tue, 2 Jul 2013 11:21:31 -0500 Subject: [PATCH 1990/2494] [feature/twig] Fix includejs test PHPBB3-11598 --- tests/template/template_includejs_test.php | 12 ++++++------ tests/template/templates/includejs.html | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/template/template_includejs_test.php b/tests/template/template_includejs_test.php index c0169bd385..67381b1fd4 100644 --- a/tests/template/template_includejs_test.php +++ b/tests/template/template_includejs_test.php @@ -18,12 +18,12 @@ class phpbb_template_template_includejs_test extends phpbb_template_template_tes // Prepare correct result $scripts = array( - '', - '', - '', - '', - '', - '', + '', + '', + '', + '', + '', + '', ); // Run test diff --git a/tests/template/templates/includejs.html b/tests/template/templates/includejs.html index ef73700eeb..229f1ccc19 100644 --- a/tests/template/templates/includejs.html +++ b/tests/template/templates/includejs.html @@ -5,4 +5,4 @@ -{SCRIPTS} +{$SCRIPTS} From 709b3e98034e537fb3cbe5cbcb1511002c2d372d Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Tue, 2 Jul 2013 11:29:32 -0500 Subject: [PATCH 1991/2494] [feature/twig] Fix BBCode parser PHPBB3-11598 --- phpBB/includes/bbcode.php | 2 +- phpBB/includes/template/template.php | 7 +++++++ phpBB/includes/template/twig/twig.php | 10 ++++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/phpBB/includes/bbcode.php b/phpBB/includes/bbcode.php index ecbb056045..fd00728510 100644 --- a/phpBB/includes/bbcode.php +++ b/phpBB/includes/bbcode.php @@ -138,7 +138,7 @@ class bbcode $style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $style_resource_locator, $style_path_provider, $template); $style->set_style(); $template->set_filenames(array('bbcode.html' => 'bbcode.html')); - $this->template_filename = $style_resource_locator->get_source_file_for_handle('bbcode.html'); + $this->template_filename = $template->get_source_file_for_handle('bbcode.html'); } $bbcode_ids = $rowset = $sql = array(); diff --git a/phpBB/includes/template/template.php b/phpBB/includes/template/template.php index e506c2c278..2b7c36ea7d 100644 --- a/phpBB/includes/template/template.php +++ b/phpBB/includes/template/template.php @@ -147,4 +147,11 @@ interface phpbb_template * @return bool false on error, true on success */ public function alter_block_array($blockname, array $vararray, $key = false, $mode = 'insert'); + + /** + * Get path to template for handle (required for BBCode parser) + * + * @return string + */ + public function get_source_file_for_handle($handle); } diff --git a/phpBB/includes/template/twig/twig.php b/phpBB/includes/template/twig/twig.php index dbc36ecddf..9d69136e0c 100644 --- a/phpBB/includes/template/twig/twig.php +++ b/phpBB/includes/template/twig/twig.php @@ -444,4 +444,14 @@ class phpbb_template_twig implements phpbb_template { return (isset($this->filenames[$handle])) ? $this->filenames[$handle] : $handle; } + + /** + * Get path to template for handle (required for BBCode parser) + * + * @return string + */ + public function get_source_file_for_handle($handle) + { + return $this->twig->getLoader()->getCacheKey($this->get_filename_from_handle($handle)); + } } From f39edcea3fb12c4f3ce9606772887c93d629f2d4 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Tue, 2 Jul 2013 12:17:56 -0500 Subject: [PATCH 1992/2494] [feature/twig] Check the template context for language vars We output some language vars to the context (e.g. L_TITLE in the ACP). These do not exist in user->lang, so we must check the context vars first, if not in context, we output the result of user->lang. PHPBB3-11598 --- phpBB/includes/template/twig/extension.php | 37 ++++++++++++++++++++-- phpBB/includes/template/twig/twig.php | 1 + 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/template/twig/extension.php b/phpBB/includes/template/twig/extension.php index 1ea5f7b662..a54c2b2509 100644 --- a/phpBB/includes/template/twig/extension.php +++ b/phpBB/includes/template/twig/extension.php @@ -17,11 +17,15 @@ if (!defined('IN_PHPBB')) class phpbb_template_twig_extension extends Twig_Extension { + /** @var phpbb_template_context */ + protected $context; + /** @var phpbb_user */ protected $user; - public function __construct($user) + public function __construct(phpbb_template_context $context, $user) { + $this->context = $context; $this->user = $user; } @@ -69,7 +73,7 @@ class phpbb_template_twig_extension extends Twig_Extension public function getFunctions() { return array( - new Twig_SimpleFunction('lang', array($this->user, 'lang')), + new Twig_SimpleFunction('lang', array($this, 'lang')), ); } @@ -140,4 +144,33 @@ class phpbb_template_twig_extension extends Twig_Extension return twig_slice($env, $item, $start, $end, $preserveKeys); } + + /** + * Get output for a language variable (L_FOO, LA_FOO) + * + * This function checks to see if the language var was outputted to $context + * (e.g. in the ACP, L_TITLE) + * If not, we return the result of $user->lang() + * + * @param string $lang name + * @return string + */ + function lang() + { + $args = func_get_args(); + $key = $args[0]; + + $context = $this->context->get_data_ref(); + $context_vars = $context['.'][0]; + + if (isset($context_vars['L_' . $key])) + { + return $context_vars['L_' . $key]; + } + + // LA_ is transformed into lang(\'$1\')|addslashes, so we should not + // need to check for it + + return call_user_func_array(array($this->user, 'lang'), $args); + } } diff --git a/phpBB/includes/template/twig/twig.php b/phpBB/includes/template/twig/twig.php index 9d69136e0c..347db0b94c 100644 --- a/phpBB/includes/template/twig/twig.php +++ b/phpBB/includes/template/twig/twig.php @@ -134,6 +134,7 @@ class phpbb_template_twig implements phpbb_template $this->twig->addExtension( new phpbb_template_twig_extension( + $this->context, $this->user ) ); From 985a233a78af7350387dfb9b8a924d09df767f05 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Tue, 2 Jul 2013 12:22:42 -0500 Subject: [PATCH 1993/2494] [feature/twig] Remove reference to cachepath, it is not used publicly anymore PHPBB3-11598 --- phpBB/includes/style/style.php | 2 -- phpBB/includes/template/twig/twig.php | 5 ++++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/phpBB/includes/style/style.php b/phpBB/includes/style/style.php index 493c4512a6..29cdcf0f7f 100644 --- a/phpBB/includes/style/style.php +++ b/phpBB/includes/style/style.php @@ -160,8 +160,6 @@ class phpbb_style $this->template->set_style_names($names, $appended_paths); } - //$this->template->cachepath = $this->phpbb_root_path . 'cache/tpl_' . str_replace('_', '-', $name) . '_'; - return true; } diff --git a/phpBB/includes/template/twig/twig.php b/phpBB/includes/template/twig/twig.php index 347db0b94c..98bd1ab89c 100644 --- a/phpBB/includes/template/twig/twig.php +++ b/phpBB/includes/template/twig/twig.php @@ -30,9 +30,12 @@ class phpbb_template_twig implements phpbb_template /** * Path of the cache directory for the template + * + * Cannot be changed during runtime. + * * @var string */ - public $cachepath = ''; + private $cachepath = ''; /** * phpBB root path From f102f609f5f0e424374aab55b8141c4e4a48b0fc Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Tue, 2 Jul 2013 12:23:42 -0500 Subject: [PATCH 1994/2494] [feature/twig] Remove getCacheFilename function I was working on This can be addressed later if we decide we want to have more nicely named cache files. It does not need to be addressed now PHPBB3-11598 --- phpBB/includes/template/twig/environment.php | 30 -------------------- 1 file changed, 30 deletions(-) diff --git a/phpBB/includes/template/twig/environment.php b/phpBB/includes/template/twig/environment.php index 73375444da..190d43f513 100644 --- a/phpBB/includes/template/twig/environment.php +++ b/phpBB/includes/template/twig/environment.php @@ -38,36 +38,6 @@ class phpbb_template_twig_environment extends Twig_Environment return parent::__construct($loader, $options); } - /** - * Gets the cache filename for a given template. - * - * @param string $name The template name - * @return string The cache file name - */ - public function ignoregetCacheFilename($name) - { - if (false === $this->cache) - { - return false; - } - // @todo - $file_path = $this->getLoader()->getCacheKey($name); - foreach ($this->getLoader()->getNamespaces() as $namespace) - { - foreach ($this->getLoader()->getPaths($namespace) as $path) - { - if (strpos($file_path, $path) === 0) - { - //return $this->getCache() . '/' . preg_replace('#[^a-zA-Z0-9_/]#', '_', $namespace . '/' . $name) . '.php'; - } - } - } - - // We probably should never get here under normal circumstances - return $this->getCache() . '/' . preg_replace('#[^a-zA-Z0-9_/]#', '_', $name) . '.php'; - return $this->getCache() . '/' . preg_replace('#[^a-zA-Z0-9_/]#', '_', $name) . '_' . md5($this->getLoader()->getCacheKey($name)) . '.php'; - } - /** * Get the list of enabled phpBB extensions * From 57c2d99e65ce107208db10721cff5b815ee3403c Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Tue, 2 Jul 2013 12:34:16 -0500 Subject: [PATCH 1995/2494] [feature/twig] Fix indentation PHPBB3-11598 --- phpBB/includes/template/twig/environment.php | 11 ++ phpBB/includes/template/twig/node/define.php | 26 ++-- phpBB/includes/template/twig/node/event.php | 54 ++++----- .../node/expression/binary/equalequal.php | 8 +- .../node/expression/binary/notequalequal.php | 8 +- phpBB/includes/template/twig/node/include.php | 28 ++--- .../includes/template/twig/node/includejs.php | 36 +++--- .../template/twig/node/includephp.php | 60 ++++----- phpBB/includes/template/twig/node/php.php | 28 ++--- .../template/twig/tokenparser/define.php | 76 ++++++------ .../template/twig/tokenparser/event.php | 46 +++---- .../includes/template/twig/tokenparser/if.php | 114 +++++++++--------- .../template/twig/tokenparser/include.php | 44 +++---- .../template/twig/tokenparser/includejs.php | 46 +++---- .../template/twig/tokenparser/includephp.php | 58 ++++----- .../template/twig/tokenparser/php.php | 52 ++++---- 16 files changed, 353 insertions(+), 342 deletions(-) diff --git a/phpBB/includes/template/twig/environment.php b/phpBB/includes/template/twig/environment.php index 190d43f513..acb97cfad2 100644 --- a/phpBB/includes/template/twig/environment.php +++ b/phpBB/includes/template/twig/environment.php @@ -29,6 +29,15 @@ class phpbb_template_twig_environment extends Twig_Environment /** @var array **/ protected $namespace_look_up_order = array('__main__'); + /** + * Constructor + * + * @param phpbb_config $phpbb_config + * @param array $phpbb_extensions Array of enabled extensions (name => path) + * @param string $phpbb_root_path + * @param Twig_LoaderInterface $loader + * @param array $options Array of options to pass to Twig + */ public function __construct($phpbb_config, $phpbb_extensions, $phpbb_root_path, Twig_LoaderInterface $loader = null, $options = array()) { $this->phpbb_config = $phpbb_config; @@ -41,6 +50,8 @@ class phpbb_template_twig_environment extends Twig_Environment /** * Get the list of enabled phpBB extensions * + * Used in EVENT node + * * @return array */ public function get_phpbb_extensions() diff --git a/phpBB/includes/template/twig/node/define.php b/phpBB/includes/template/twig/node/define.php index 0c4d400767..499bbdc518 100644 --- a/phpBB/includes/template/twig/node/define.php +++ b/phpBB/includes/template/twig/node/define.php @@ -9,19 +9,19 @@ class phpbb_template_twig_node_define extends Twig_Node { - public function __construct($capture, Twig_NodeInterface $name, Twig_NodeInterface $value, $lineno, $tag = null) - { - parent::__construct(array('name' => $name, 'value' => $value), array('capture' => $capture, 'safe' => false), $lineno, $tag); - } + public function __construct($capture, Twig_NodeInterface $name, Twig_NodeInterface $value, $lineno, $tag = null) + { + parent::__construct(array('name' => $name, 'value' => $value), array('capture' => $capture, 'safe' => false), $lineno, $tag); + } - /** - * Compiles the node to PHP. - * - * @param Twig_Compiler A Twig_Compiler instance - */ - public function compile(Twig_Compiler $compiler) - { - $compiler->addDebugInfo($this); + /** + * Compiles the node to PHP. + * + * @param Twig_Compiler A Twig_Compiler instance + */ + public function compile(Twig_Compiler $compiler) + { + $compiler->addDebugInfo($this); if ($this->getAttribute('capture')) { $compiler @@ -45,5 +45,5 @@ class phpbb_template_twig_node_define extends Twig_Node ->raw($this->getNode('name')->getAttribute('name')) ->raw("', \$value);\n") ; - } + } } diff --git a/phpBB/includes/template/twig/node/event.php b/phpBB/includes/template/twig/node/event.php index 358c68dae5..6de270e19c 100644 --- a/phpBB/includes/template/twig/node/event.php +++ b/phpBB/includes/template/twig/node/event.php @@ -12,39 +12,39 @@ class phpbb_template_twig_node_event extends Twig_Node /** @var Twig_Environment */ protected $environment; - public function __construct(Twig_Node_Expression $expr, phpbb_template_twig_environment $environment, $lineno, $tag = null) - { - $this->environment = $environment; + public function __construct(Twig_Node_Expression $expr, phpbb_template_twig_environment $environment, $lineno, $tag = null) + { + $this->environment = $environment; - parent::__construct(array('expr' => $expr), array(), $lineno, $tag); - } + parent::__construct(array('expr' => $expr), array(), $lineno, $tag); + } - /** - * Compiles the node to PHP. - * - * @param Twig_Compiler A Twig_Compiler instance - */ - public function compile(Twig_Compiler $compiler) - { - $compiler->addDebugInfo($this); + /** + * Compiles the node to PHP. + * + * @param Twig_Compiler A Twig_Compiler instance + */ + public function compile(Twig_Compiler $compiler) + { + $compiler->addDebugInfo($this); - $location = $this->getNode('expr')->getAttribute('name'); + $location = $this->getNode('expr')->getAttribute('name'); - foreach ($this->environment->get_phpbb_extensions() as $ext_namespace => $ext_path) - { - $ext_namespace = str_replace('/', '_', $ext_namespace); + foreach ($this->environment->get_phpbb_extensions() as $ext_namespace => $ext_path) + { + $ext_namespace = str_replace('/', '_', $ext_namespace); - if ($this->environment->getLoader()->exists('@' . $ext_namespace . '/' . $location . '.html')) - { - $compiler - ->write("\$previous_look_up_order = \$this->env->getNamespaceLookUpOrder();\n") + if ($this->environment->getLoader()->exists('@' . $ext_namespace . '/' . $location . '.html')) + { + $compiler + ->write("\$previous_look_up_order = \$this->env->getNamespaceLookUpOrder();\n") - // We set the namespace lookup order to be this extension first, then the main path - ->write("\$this->env->setNamespaceLookUpOrder(array('" . $ext_namespace . "', '__main__'));\n") - ->write("\$this->env->loadTemplate('@" . $ext_namespace . "/" . $location . ".html')->display(\$context);\n") - ->write("\$this->env->setNamespaceLookUpOrder(\$previous_look_up_order);\n") - ; + // We set the namespace lookup order to be this extension first, then the main path + ->write("\$this->env->setNamespaceLookUpOrder(array('" . $ext_namespace . "', '__main__'));\n") + ->write("\$this->env->loadTemplate('@" . $ext_namespace . "/" . $location . ".html')->display(\$context);\n") + ->write("\$this->env->setNamespaceLookUpOrder(\$previous_look_up_order);\n") + ; } } - } + } } diff --git a/phpBB/includes/template/twig/node/expression/binary/equalequal.php b/phpBB/includes/template/twig/node/expression/binary/equalequal.php index 3a0c79c839..054f63ecf9 100644 --- a/phpBB/includes/template/twig/node/expression/binary/equalequal.php +++ b/phpBB/includes/template/twig/node/expression/binary/equalequal.php @@ -9,8 +9,8 @@ class phpbb_template_twig_node_expression_binary_equalequal extends Twig_Node_Expression_Binary { - public function operator(Twig_Compiler $compiler) - { - return $compiler->raw('==='); - } + public function operator(Twig_Compiler $compiler) + { + return $compiler->raw('==='); + } } diff --git a/phpBB/includes/template/twig/node/expression/binary/notequalequal.php b/phpBB/includes/template/twig/node/expression/binary/notequalequal.php index b53bc56b2d..d8a1c411cf 100644 --- a/phpBB/includes/template/twig/node/expression/binary/notequalequal.php +++ b/phpBB/includes/template/twig/node/expression/binary/notequalequal.php @@ -9,8 +9,8 @@ class phpbb_template_twig_node_expression_binary_notequalequal extends Twig_Node_Expression_Binary { - public function operator(Twig_Compiler $compiler) - { - return $compiler->raw('!=='); - } + public function operator(Twig_Compiler $compiler) + { + return $compiler->raw('!=='); + } } diff --git a/phpBB/includes/template/twig/node/include.php b/phpBB/includes/template/twig/node/include.php index 2a90dc19e4..a614cbe20f 100644 --- a/phpBB/includes/template/twig/node/include.php +++ b/phpBB/includes/template/twig/node/include.php @@ -9,14 +9,14 @@ class phpbb_template_twig_node_include extends Twig_Node_Include { - /** - * Compiles the node to PHP. - * - * @param Twig_Compiler A Twig_Compiler instance - */ - public function compile(Twig_Compiler $compiler) - { - $compiler->addDebugInfo($this); + /** + * Compiles the node to PHP. + * + * @param Twig_Compiler A Twig_Compiler instance + */ + public function compile(Twig_Compiler $compiler) + { + $compiler->addDebugInfo($this); $compiler ->write("\$location = ") @@ -26,15 +26,15 @@ class phpbb_template_twig_node_include extends Twig_Node_Include ->write("if (strpos(\$location, '@') === 0) {\n") ->indent() ->write("\$namespace = substr(\$location, 1, strpos(\$location, '/') - 1);\n") - ->write("\$previous_look_up_order = \$this->env->getNamespaceLookUpOrder();\n") + ->write("\$previous_look_up_order = \$this->env->getNamespaceLookUpOrder();\n") - // We set the namespace lookup order to be this namespace first, then the main path - ->write("\$this->env->setNamespaceLookUpOrder(array(\$namespace, '__main__'));\n") + // We set the namespace lookup order to be this namespace first, then the main path + ->write("\$this->env->setNamespaceLookUpOrder(array(\$namespace, '__main__'));\n") ->outdent() ->write("}\n") ; - parent::compile($compiler); + parent::compile($compiler); $compiler ->write("if (\$namespace) {\n") @@ -42,6 +42,6 @@ class phpbb_template_twig_node_include extends Twig_Node_Include ->write("\$this->env->setNamespaceLookUpOrder(\$previous_look_up_order);\n") ->outdent() ->write("}\n") - ; - } + ; + } } diff --git a/phpBB/includes/template/twig/node/includejs.php b/phpBB/includes/template/twig/node/includejs.php index 91b24e8068..6d0d67c6c9 100644 --- a/phpBB/includes/template/twig/node/includejs.php +++ b/phpBB/includes/template/twig/node/includejs.php @@ -12,27 +12,27 @@ class phpbb_template_twig_node_includejs extends Twig_Node /** @var Twig_Environment */ protected $environment; - public function __construct(Twig_Node_Expression $expr, phpbb_template_twig_environment $environment, $lineno, $tag = null) - { - $this->environment = $environment; + public function __construct(Twig_Node_Expression $expr, phpbb_template_twig_environment $environment, $lineno, $tag = null) + { + $this->environment = $environment; - parent::__construct(array('expr' => $expr), array(), $lineno, $tag); - } + parent::__construct(array('expr' => $expr), array(), $lineno, $tag); + } - /** - * Compiles the node to PHP. - * - * @param Twig_Compiler A Twig_Compiler instance - */ - public function compile(Twig_Compiler $compiler) - { - $compiler->addDebugInfo($this); + /** + * Compiles the node to PHP. + * + * @param Twig_Compiler A Twig_Compiler instance + */ + public function compile(Twig_Compiler $compiler) + { + $compiler->addDebugInfo($this); $config = $this->environment->get_phpbb_config(); - $compiler + $compiler ->write("\$js_file = ") - ->subcompile($this->getNode('expr')) + ->subcompile($this->getNode('expr')) ->raw(";\n") ->write("if (!file_exists(\$js_file)) {\n") ->indent() @@ -41,7 +41,7 @@ class phpbb_template_twig_node_includejs extends Twig_Node ->write("}\n") ->write("\$context['definition']->append('SCRIPTS', '\n');\n") - ; - } + ->raw(" . '?assets_version=" . $config['assets_version'] . "\">\n');\n") + ; + } } diff --git a/phpBB/includes/template/twig/node/includephp.php b/phpBB/includes/template/twig/node/includephp.php index a19ce43653..b5bb2ee9c9 100644 --- a/phpBB/includes/template/twig/node/includephp.php +++ b/phpBB/includes/template/twig/node/includephp.php @@ -12,21 +12,21 @@ class phpbb_template_twig_node_includephp extends Twig_Node /** @var Twig_Environment */ protected $environment; - public function __construct(Twig_Node_Expression $expr, phpbb_template_twig_environment $environment, $ignoreMissing = false, $lineno, $tag = null) - { - $this->environment = $environment; + public function __construct(Twig_Node_Expression $expr, phpbb_template_twig_environment $environment, $ignoreMissing = false, $lineno, $tag = null) + { + $this->environment = $environment; - parent::__construct(array('expr' => $expr), array('ignore_missing' => (Boolean) $ignoreMissing), $lineno, $tag); - } + parent::__construct(array('expr' => $expr), array('ignore_missing' => (Boolean) $ignoreMissing), $lineno, $tag); + } - /** - * Compiles the node to PHP. - * - * @param Twig_Compiler A Twig_Compiler instance - */ - public function compile(Twig_Compiler $compiler) - { - $compiler->addDebugInfo($this); + /** + * Compiles the node to PHP. + * + * @param Twig_Compiler A Twig_Compiler instance + */ + public function compile(Twig_Compiler $compiler) + { + $compiler->addDebugInfo($this); $config = $this->environment->get_phpbb_config(); @@ -39,12 +39,12 @@ class phpbb_template_twig_node_includephp extends Twig_Node return; } - if ($this->getAttribute('ignore_missing')) { - $compiler - ->write("try {\n") - ->indent() - ; - } + if ($this->getAttribute('ignore_missing')) { + $compiler + ->write("try {\n") + ->indent() + ; + } $compiler ->write("\$location = ") @@ -68,15 +68,15 @@ class phpbb_template_twig_node_includephp extends Twig_Node ->write("}\n") ; - if ($this->getAttribute('ignore_missing')) { - $compiler - ->outdent() - ->write("} catch (Twig_Error_Loader \$e) {\n") - ->indent() - ->write("// ignore missing template\n") - ->outdent() - ->write("}\n\n") - ; - } - } + if ($this->getAttribute('ignore_missing')) { + $compiler + ->outdent() + ->write("} catch (Twig_Error_Loader \$e) {\n") + ->indent() + ->write("// ignore missing template\n") + ->outdent() + ->write("}\n\n") + ; + } + } } diff --git a/phpBB/includes/template/twig/node/php.php b/phpBB/includes/template/twig/node/php.php index 953cd184a7..ebf4947e48 100644 --- a/phpBB/includes/template/twig/node/php.php +++ b/phpBB/includes/template/twig/node/php.php @@ -12,21 +12,21 @@ class phpbb_template_twig_node_php extends Twig_Node /** @var Twig_Environment */ protected $environment; - public function __construct(Twig_Node_Text $text, phpbb_template_twig_environment $environment, $lineno, $tag = null) - { - $this->environment = $environment; + public function __construct(Twig_Node_Text $text, phpbb_template_twig_environment $environment, $lineno, $tag = null) + { + $this->environment = $environment; - parent::__construct(array('text' => $text), array(), $lineno, $tag); - } + parent::__construct(array('text' => $text), array(), $lineno, $tag); + } - /** - * Compiles the node to PHP. - * - * @param Twig_Compiler A Twig_Compiler instance - */ - public function compile(Twig_Compiler $compiler) - { - $compiler->addDebugInfo($this); + /** + * Compiles the node to PHP. + * + * @param Twig_Compiler A Twig_Compiler instance + */ + public function compile(Twig_Compiler $compiler) + { + $compiler->addDebugInfo($this); $config = $this->environment->get_phpbb_config(); @@ -42,5 +42,5 @@ class phpbb_template_twig_node_php extends Twig_Node $compiler ->raw($this->getNode('text')->getAttribute('data')) ; - } + } } diff --git a/phpBB/includes/template/twig/tokenparser/define.php b/phpBB/includes/template/twig/tokenparser/define.php index ebf7cb4c4a..ed77699b77 100644 --- a/phpBB/includes/template/twig/tokenparser/define.php +++ b/phpBB/includes/template/twig/tokenparser/define.php @@ -9,49 +9,49 @@ class phpbb_template_twig_tokenparser_define extends Twig_TokenParser { - /** - * Parses a token and returns a node. - * - * @param Twig_Token $token A Twig_Token instance - * - * @return Twig_NodeInterface A Twig_NodeInterface instance - */ - public function parse(Twig_Token $token) - { - $lineno = $token->getLine(); - $stream = $this->parser->getStream(); - $name = $this->parser->getExpressionParser()->parseExpression(); + /** + * Parses a token and returns a node. + * + * @param Twig_Token $token A Twig_Token instance + * + * @return Twig_NodeInterface A Twig_NodeInterface instance + */ + public function parse(Twig_Token $token) + { + $lineno = $token->getLine(); + $stream = $this->parser->getStream(); + $name = $this->parser->getExpressionParser()->parseExpression(); - $capture = false; - if ($stream->test(Twig_Token::OPERATOR_TYPE, '=')) { - $stream->next(); - $value = $this->parser->getExpressionParser()->parseExpression(); + $capture = false; + if ($stream->test(Twig_Token::OPERATOR_TYPE, '=')) { + $stream->next(); + $value = $this->parser->getExpressionParser()->parseExpression(); - $stream->expect(Twig_Token::BLOCK_END_TYPE); - } else { - $capture = true; + $stream->expect(Twig_Token::BLOCK_END_TYPE); + } else { + $capture = true; - $stream->expect(Twig_Token::BLOCK_END_TYPE); + $stream->expect(Twig_Token::BLOCK_END_TYPE); - $value = $this->parser->subparse(array($this, 'decideBlockEnd'), true); - $stream->expect(Twig_Token::BLOCK_END_TYPE); - } + $value = $this->parser->subparse(array($this, 'decideBlockEnd'), true); + $stream->expect(Twig_Token::BLOCK_END_TYPE); + } - return new phpbb_template_twig_node_define($capture, $name, $value, $lineno, $this->getTag()); - } + return new phpbb_template_twig_node_define($capture, $name, $value, $lineno, $this->getTag()); + } - public function decideBlockEnd(Twig_Token $token) - { - return $token->test('ENDDEFINE'); - } + public function decideBlockEnd(Twig_Token $token) + { + return $token->test('ENDDEFINE'); + } - /** - * Gets the tag name associated with this token parser. - * - * @return string The tag name - */ - public function getTag() - { - return 'DEFINE'; - } + /** + * Gets the tag name associated with this token parser. + * + * @return string The tag name + */ + public function getTag() + { + return 'DEFINE'; + } } diff --git a/phpBB/includes/template/twig/tokenparser/event.php b/phpBB/includes/template/twig/tokenparser/event.php index 03810454ed..2a6d6b6457 100644 --- a/phpBB/includes/template/twig/tokenparser/event.php +++ b/phpBB/includes/template/twig/tokenparser/event.php @@ -9,30 +9,30 @@ class phpbb_template_twig_tokenparser_event extends Twig_TokenParser { - /** - * Parses a token and returns a node. - * - * @param Twig_Token $token A Twig_Token instance - * - * @return Twig_NodeInterface A Twig_NodeInterface instance - */ - public function parse(Twig_Token $token) - { - $expr = $this->parser->getExpressionParser()->parseExpression(); + /** + * Parses a token and returns a node. + * + * @param Twig_Token $token A Twig_Token instance + * + * @return Twig_NodeInterface A Twig_NodeInterface instance + */ + public function parse(Twig_Token $token) + { + $expr = $this->parser->getExpressionParser()->parseExpression(); - $stream = $this->parser->getStream(); - $stream->expect(Twig_Token::BLOCK_END_TYPE); + $stream = $this->parser->getStream(); + $stream->expect(Twig_Token::BLOCK_END_TYPE); - return new phpbb_template_twig_node_event($expr, $this->parser->getEnvironment(), $token->getLine(), $this->getTag()); - } + return new phpbb_template_twig_node_event($expr, $this->parser->getEnvironment(), $token->getLine(), $this->getTag()); + } - /** - * Gets the tag name associated with this token parser. - * - * @return string The tag name - */ - public function getTag() - { - return 'EVENT'; - } + /** + * Gets the tag name associated with this token parser. + * + * @return string The tag name + */ + public function getTag() + { + return 'EVENT'; + } } diff --git a/phpBB/includes/template/twig/tokenparser/if.php b/phpBB/includes/template/twig/tokenparser/if.php index 04ee048f94..939d679030 100644 --- a/phpBB/includes/template/twig/tokenparser/if.php +++ b/phpBB/includes/template/twig/tokenparser/if.php @@ -9,70 +9,70 @@ class phpbb_template_twig_tokenparser_if extends Twig_TokenParser_If { - /** - * Parses a token and returns a node. - * - * @param Twig_Token $token A Twig_Token instance - * - * @return Twig_NodeInterface A Twig_NodeInterface instance - */ - public function parse(Twig_Token $token) - { - $lineno = $token->getLine(); - $expr = $this->parser->getExpressionParser()->parseExpression(); - $stream = $this->parser->getStream(); - $stream->expect(Twig_Token::BLOCK_END_TYPE); - $body = $this->parser->subparse(array($this, 'decideIfFork')); - $tests = array($expr, $body); - $else = null; + /** + * Parses a token and returns a node. + * + * @param Twig_Token $token A Twig_Token instance + * + * @return Twig_NodeInterface A Twig_NodeInterface instance + */ + public function parse(Twig_Token $token) + { + $lineno = $token->getLine(); + $expr = $this->parser->getExpressionParser()->parseExpression(); + $stream = $this->parser->getStream(); + $stream->expect(Twig_Token::BLOCK_END_TYPE); + $body = $this->parser->subparse(array($this, 'decideIfFork')); + $tests = array($expr, $body); + $else = null; - $end = false; - while (!$end) { - switch ($stream->next()->getValue()) { - case 'ELSE': - $stream->expect(Twig_Token::BLOCK_END_TYPE); - $else = $this->parser->subparse(array($this, 'decideIfEnd')); - break; + $end = false; + while (!$end) { + switch ($stream->next()->getValue()) { + case 'ELSE': + $stream->expect(Twig_Token::BLOCK_END_TYPE); + $else = $this->parser->subparse(array($this, 'decideIfEnd')); + break; - case 'ELSEIF': - $expr = $this->parser->getExpressionParser()->parseExpression(); - $stream->expect(Twig_Token::BLOCK_END_TYPE); - $body = $this->parser->subparse(array($this, 'decideIfFork')); - $tests[] = $expr; - $tests[] = $body; - break; + case 'ELSEIF': + $expr = $this->parser->getExpressionParser()->parseExpression(); + $stream->expect(Twig_Token::BLOCK_END_TYPE); + $body = $this->parser->subparse(array($this, 'decideIfFork')); + $tests[] = $expr; + $tests[] = $body; + break; - case 'ENDIF': - $end = true; - break; + case 'ENDIF': + $end = true; + break; - default: - throw new Twig_Error_Syntax(sprintf('Unexpected end of template. Twig was looking for the following tags "ELSE", "ELSEIF", or "ENDIF" to close the "IF" block started at line %d)', $lineno), $stream->getCurrent()->getLine(), $stream->getFilename()); - } - } + default: + throw new Twig_Error_Syntax(sprintf('Unexpected end of template. Twig was looking for the following tags "ELSE", "ELSEIF", or "ENDIF" to close the "IF" block started at line %d)', $lineno), $stream->getCurrent()->getLine(), $stream->getFilename()); + } + } - $stream->expect(Twig_Token::BLOCK_END_TYPE); + $stream->expect(Twig_Token::BLOCK_END_TYPE); - return new Twig_Node_If(new Twig_Node($tests), $else, $lineno, $this->getTag()); - } + return new Twig_Node_If(new Twig_Node($tests), $else, $lineno, $this->getTag()); + } - public function decideIfFork(Twig_Token $token) - { - return $token->test(array('ELSEIF', 'ELSE', 'ENDIF')); - } + public function decideIfFork(Twig_Token $token) + { + return $token->test(array('ELSEIF', 'ELSE', 'ENDIF')); + } - public function decideIfEnd(Twig_Token $token) - { - return $token->test(array('ENDIF')); - } + public function decideIfEnd(Twig_Token $token) + { + return $token->test(array('ENDIF')); + } - /** - * Gets the tag name associated with this token parser. - * - * @return string The tag name - */ - public function getTag() - { - return 'IF'; - } + /** + * Gets the tag name associated with this token parser. + * + * @return string The tag name + */ + public function getTag() + { + return 'IF'; + } } diff --git a/phpBB/includes/template/twig/tokenparser/include.php b/phpBB/includes/template/twig/tokenparser/include.php index 0f7e4faf8f..5b5105d23e 100644 --- a/phpBB/includes/template/twig/tokenparser/include.php +++ b/phpBB/includes/template/twig/tokenparser/include.php @@ -9,29 +9,29 @@ class phpbb_template_twig_tokenparser_include extends Twig_TokenParser_Include { - /** - * Parses a token and returns a node. - * - * @param Twig_Token $token A Twig_Token instance - * - * @return Twig_NodeInterface A Twig_NodeInterface instance - */ - public function parse(Twig_Token $token) - { - $expr = $this->parser->getExpressionParser()->parseExpression(); + /** + * Parses a token and returns a node. + * + * @param Twig_Token $token A Twig_Token instance + * + * @return Twig_NodeInterface A Twig_NodeInterface instance + */ + public function parse(Twig_Token $token) + { + $expr = $this->parser->getExpressionParser()->parseExpression(); - list($variables, $only, $ignoreMissing) = $this->parseArguments(); + list($variables, $only, $ignoreMissing) = $this->parseArguments(); - return new phpbb_template_twig_node_include($expr, $variables, $only, $ignoreMissing, $token->getLine(), $this->getTag()); - } + return new phpbb_template_twig_node_include($expr, $variables, $only, $ignoreMissing, $token->getLine(), $this->getTag()); + } - /** - * Gets the tag name associated with this token parser. - * - * @return string The tag name - */ - public function getTag() - { - return 'INCLUDE'; - } + /** + * Gets the tag name associated with this token parser. + * + * @return string The tag name + */ + public function getTag() + { + return 'INCLUDE'; + } } diff --git a/phpBB/includes/template/twig/tokenparser/includejs.php b/phpBB/includes/template/twig/tokenparser/includejs.php index 0b46f315d2..962d01ac45 100644 --- a/phpBB/includes/template/twig/tokenparser/includejs.php +++ b/phpBB/includes/template/twig/tokenparser/includejs.php @@ -9,30 +9,30 @@ class phpbb_template_twig_tokenparser_includejs extends Twig_TokenParser { - /** - * Parses a token and returns a node. - * - * @param Twig_Token $token A Twig_Token instance - * - * @return Twig_NodeInterface A Twig_NodeInterface instance - */ - public function parse(Twig_Token $token) - { - $expr = $this->parser->getExpressionParser()->parseExpression(); + /** + * Parses a token and returns a node. + * + * @param Twig_Token $token A Twig_Token instance + * + * @return Twig_NodeInterface A Twig_NodeInterface instance + */ + public function parse(Twig_Token $token) + { + $expr = $this->parser->getExpressionParser()->parseExpression(); - $stream = $this->parser->getStream(); - $stream->expect(Twig_Token::BLOCK_END_TYPE); + $stream = $this->parser->getStream(); + $stream->expect(Twig_Token::BLOCK_END_TYPE); - return new phpbb_template_twig_node_includejs($expr, $this->parser->getEnvironment(), $token->getLine(), $this->getTag()); - } + return new phpbb_template_twig_node_includejs($expr, $this->parser->getEnvironment(), $token->getLine(), $this->getTag()); + } - /** - * Gets the tag name associated with this token parser. - * - * @return string The tag name - */ - public function getTag() - { - return 'INCLUDEJS'; - } + /** + * Gets the tag name associated with this token parser. + * + * @return string The tag name + */ + public function getTag() + { + return 'INCLUDEJS'; + } } diff --git a/phpBB/includes/template/twig/tokenparser/includephp.php b/phpBB/includes/template/twig/tokenparser/includephp.php index a81d663c09..57d804183b 100644 --- a/phpBB/includes/template/twig/tokenparser/includephp.php +++ b/phpBB/includes/template/twig/tokenparser/includephp.php @@ -9,39 +9,39 @@ class phpbb_template_twig_tokenparser_includephp extends Twig_TokenParser { - /** - * Parses a token and returns a node. - * - * @param Twig_Token $token A Twig_Token instance - * - * @return Twig_NodeInterface A Twig_NodeInterface instance - */ - public function parse(Twig_Token $token) - { - $expr = $this->parser->getExpressionParser()->parseExpression(); + /** + * Parses a token and returns a node. + * + * @param Twig_Token $token A Twig_Token instance + * + * @return Twig_NodeInterface A Twig_NodeInterface instance + */ + public function parse(Twig_Token $token) + { + $expr = $this->parser->getExpressionParser()->parseExpression(); - $stream = $this->parser->getStream(); + $stream = $this->parser->getStream(); - $ignoreMissing = false; - if ($stream->test(Twig_Token::NAME_TYPE, 'ignore')) { - $stream->next(); - $stream->expect(Twig_Token::NAME_TYPE, 'missing'); + $ignoreMissing = false; + if ($stream->test(Twig_Token::NAME_TYPE, 'ignore')) { + $stream->next(); + $stream->expect(Twig_Token::NAME_TYPE, 'missing'); - $ignoreMissing = true; - } + $ignoreMissing = true; + } - $stream->expect(Twig_Token::BLOCK_END_TYPE); + $stream->expect(Twig_Token::BLOCK_END_TYPE); - return new phpbb_template_twig_node_includephp($expr, $this->parser->getEnvironment(), $ignoreMissing, $token->getLine(), $this->getTag()); - } + return new phpbb_template_twig_node_includephp($expr, $this->parser->getEnvironment(), $ignoreMissing, $token->getLine(), $this->getTag()); + } - /** - * Gets the tag name associated with this token parser. - * - * @return string The tag name - */ - public function getTag() - { - return 'INCLUDEPHP'; - } + /** + * Gets the tag name associated with this token parser. + * + * @return string The tag name + */ + public function getTag() + { + return 'INCLUDEPHP'; + } } diff --git a/phpBB/includes/template/twig/tokenparser/php.php b/phpBB/includes/template/twig/tokenparser/php.php index 7db57081e2..62e1c4fdcd 100644 --- a/phpBB/includes/template/twig/tokenparser/php.php +++ b/phpBB/includes/template/twig/tokenparser/php.php @@ -9,38 +9,38 @@ class phpbb_template_twig_tokenparser_php extends Twig_TokenParser { - /** - * Parses a token and returns a node. - * - * @param Twig_Token $token A Twig_Token instance - * - * @return Twig_NodeInterface A Twig_NodeInterface instance - */ - public function parse(Twig_Token $token) - { - $stream = $this->parser->getStream(); + /** + * Parses a token and returns a node. + * + * @param Twig_Token $token A Twig_Token instance + * + * @return Twig_NodeInterface A Twig_NodeInterface instance + */ + public function parse(Twig_Token $token) + { + $stream = $this->parser->getStream(); - $stream->expect(Twig_Token::BLOCK_END_TYPE); + $stream->expect(Twig_Token::BLOCK_END_TYPE); $body = $this->parser->subparse(array($this, 'decideEnd'), true); - $stream->expect(Twig_Token::BLOCK_END_TYPE); + $stream->expect(Twig_Token::BLOCK_END_TYPE); - return new phpbb_template_twig_node_php($body, $this->parser->getEnvironment(), $token->getLine(), $this->getTag()); - } + return new phpbb_template_twig_node_php($body, $this->parser->getEnvironment(), $token->getLine(), $this->getTag()); + } - public function decideEnd(Twig_Token $token) - { - return $token->test('ENDPHP'); - } + public function decideEnd(Twig_Token $token) + { + return $token->test('ENDPHP'); + } - /** - * Gets the tag name associated with this token parser. - * - * @return string The tag name - */ - public function getTag() - { - return 'PHP'; + /** + * Gets the tag name associated with this token parser. + * + * @return string The tag name + */ + public function getTag() + { + return 'PHP'; } } From b4947f94ed23270d4dbb498afb31555da2c8af0d Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Tue, 2 Jul 2013 12:43:26 -0500 Subject: [PATCH 1996/2494] [feature/twig] Should compare to $this->test_path rather than hardcoded path PHPBB3-11598 --- tests/template/template_includejs_test.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/template/template_includejs_test.php b/tests/template/template_includejs_test.php index 67381b1fd4..a57b219150 100644 --- a/tests/template/template_includejs_test.php +++ b/tests/template/template_includejs_test.php @@ -18,12 +18,12 @@ class phpbb_template_template_includejs_test extends phpbb_template_template_tes // Prepare correct result $scripts = array( - '', - '', - '', - '', - '', - '', + '', + '', + '', + '', + '', + '', ); // Run test From 6bbe92a8d020f1fcfa8de0da50714acf88837295 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Tue, 2 Jul 2013 12:50:55 -0500 Subject: [PATCH 1997/2494] [feature/twig] Move test_php back to template_test Was originally moved because I thought that a new test file might mean a new instance and the memory would be cleared, fixing the original problem, but that isn't true and it was fixed another way. PHPBB3-11598 --- tests/template/template_php_test.php | 30 ---------------------------- tests/template/template_test.php | 16 +++++++++++++++ 2 files changed, 16 insertions(+), 30 deletions(-) delete mode 100644 tests/template/template_php_test.php diff --git a/tests/template/template_php_test.php b/tests/template/template_php_test.php deleted file mode 100644 index fd4174953c..0000000000 --- a/tests/template/template_php_test.php +++ /dev/null @@ -1,30 +0,0 @@ -echo "test";'; - - $cache_dir = dirname($this->template->cachepath) . '/'; - $fp = fopen($cache_dir . 'php.html', 'w'); - fputs($fp, $template_text); - fclose($fp); - - $this->setup_engine(array('tpl_allow_php' => true)); - - $this->style->set_custom_style('tests', $cache_dir, array(), ''); - - $this->run_template('php.html', array(), array(), array(), 'test'); - } -} diff --git a/tests/template/template_test.php b/tests/template/template_test.php index ad4c8fbd17..26cfb3a8e4 100644 --- a/tests/template/template_test.php +++ b/tests/template/template_test.php @@ -369,6 +369,22 @@ class phpbb_template_template_test extends phpbb_template_template_test_case $this->assertEquals($expecting, $this->display('append_var')); } + public function test_php() + { + $template_text = 'echo "test";'; + + $cache_dir = dirname($this->template->cachepath) . '/'; + $fp = fopen($cache_dir . 'php.html', 'w'); + fputs($fp, $template_text); + fclose($fp); + + $this->setup_engine(array('tpl_allow_php' => true)); + + $this->style->set_custom_style('tests', $cache_dir, array(), ''); + + $this->run_template('php.html', array(), array(), array(), 'test'); + } + public function alter_block_array_data() { return array( From 2507c648fe92de5363bd443839d1bb52f55795b4 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Tue, 2 Jul 2013 12:59:23 -0500 Subject: [PATCH 1998/2494] [feature/twig] template->cachepath is now private, missed checking tests PHPBB3-11598 --- tests/template/includephp_test.php | 4 +++- tests/template/template_test.php | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/template/includephp_test.php b/tests/template/includephp_test.php index edf1e40bb8..a3dc9bd5c5 100644 --- a/tests/template/includephp_test.php +++ b/tests/template/includephp_test.php @@ -33,11 +33,13 @@ class phpbb_template_includephp_test extends phpbb_template_template_test_case public function test_includephp_absolute() { + global $phpbb_root_path; + $path_to_php = str_replace('\\', '/', dirname(__FILE__)) . '/templates/_dummy_include.php.inc'; $this->assertTrue(phpbb_is_absolute($path_to_php)); $template_text = "Path is absolute.\n"; - $cache_dir = dirname($this->template->cachepath) . '/'; + $cache_dir = dirname($phpbb_root_path . 'cache') . '/'; $fp = fopen($cache_dir . 'includephp_absolute.html', 'w'); fputs($fp, $template_text); fclose($fp); diff --git a/tests/template/template_test.php b/tests/template/template_test.php index 26cfb3a8e4..1b3dda9b2a 100644 --- a/tests/template/template_test.php +++ b/tests/template/template_test.php @@ -371,9 +371,11 @@ class phpbb_template_template_test extends phpbb_template_template_test_case public function test_php() { + global $phpbb_root_path; + $template_text = 'echo "test";'; - $cache_dir = dirname($this->template->cachepath) . '/'; + $cache_dir = dirname($phpbb_root_path . 'cache') . '/'; $fp = fopen($cache_dir . 'php.html', 'w'); fputs($fp, $template_text); fclose($fp); From f9672e9b45a0f0d26702ca0f55a884a24e21bf77 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Tue, 2 Jul 2013 14:03:22 -0400 Subject: [PATCH 1999/2494] [feature/auth-refactor] Fix code style issue PHPBB3-9734 --- phpBB/includes/acp/acp_board.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/acp/acp_board.php b/phpBB/includes/acp/acp_board.php index 4d07f96c6f..24b913260b 100644 --- a/phpBB/includes/acp/acp_board.php +++ b/phpBB/includes/acp/acp_board.php @@ -660,8 +660,8 @@ class acp_board if ($fields['tpl']) { $template->assign_block_vars('auth_tpl', array( - 'TPL' => $fields['tpl']) - ); + 'TPL' => $fields['tpl'], + )); } unset($fields); } From 52bce2ce11013477f763d0e9fe4f6f724a970f29 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Tue, 2 Jul 2013 13:43:02 -0500 Subject: [PATCH 2000/2494] [feature/twig] Prevent errors from mkdir if the dir already exists PHPBB3-11598 --- tests/test_framework/phpbb_test_case_helpers.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/test_framework/phpbb_test_case_helpers.php b/tests/test_framework/phpbb_test_case_helpers.php index 50b2bf03ec..c4907d5ecf 100644 --- a/tests/test_framework/phpbb_test_case_helpers.php +++ b/tests/test_framework/phpbb_test_case_helpers.php @@ -94,7 +94,10 @@ class phpbb_test_case_helpers public function makedirs($path) { - mkdir($path, 0777, true); + if (!is_dir($path)) + { + mkdir($path, 0777, true); + } } static public function get_test_config() From 9652483ef49295379b28bdd842c846c0160fa1a1 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Tue, 2 Jul 2013 14:24:48 -0500 Subject: [PATCH 2001/2494] [feature/twig] Fix begin loop var regex PHPBB3-11598 --- phpBB/includes/template/twig/lexer.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/template/twig/lexer.php b/phpBB/includes/template/twig/lexer.php index b32a9e4ffa..c7ab1590f5 100644 --- a/phpBB/includes/template/twig/lexer.php +++ b/phpBB/includes/template/twig/lexer.php @@ -134,10 +134,10 @@ class phpbb_template_twig_lexer extends Twig_Lexer } } - // Remove all parent nodes, e.g. foo, bar from foo.bar.foobar + // Remove all parent nodes, e.g. foo, bar from foo.bar.foobar.VAR foreach ($parent_nodes as $node) { - $body = preg_replace('#([^a-zA-Z0-9])' . $node . '\.#', '$1', $body); + $body = preg_replace('#([^a-zA-Z0-9_])' . $node . '\.([a-zA-Z0-9_]+)\.#', '$1$2.', $body); } // Add current node to list of parent nodes for child nodes From fba3a9d600e9b79c8530b026fa781c99ea9ba833 Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Tue, 2 Jul 2013 16:52:15 -0700 Subject: [PATCH 2002/2494] [ticket/11617] Missing U_ACTION in acp_captcha.php http://tracker.phpbb.com/browse/PHPBB3-11617 PHPBB3-11617 --- phpBB/includes/acp/acp_captcha.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/phpBB/includes/acp/acp_captcha.php b/phpBB/includes/acp/acp_captcha.php index 469a367bba..5b553d6a0d 100644 --- a/phpBB/includes/acp/acp_captcha.php +++ b/phpBB/includes/acp/acp_captcha.php @@ -124,6 +124,8 @@ class acp_captcha 'CAPTCHA_PREVIEW_TPL' => $demo_captcha->get_demo_template($id), 'S_CAPTCHA_HAS_CONFIG' => $demo_captcha->has_config(), 'CAPTCHA_SELECT' => $captcha_select, + + 'U_ACTION' => $this->u_action, )); } } From 5ef4987ffe15fe1fbafc9d9eae005f29a028dd3e Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Tue, 2 Jul 2013 18:47:56 -0700 Subject: [PATCH 2003/2494] [ticket/11617] Remove spaces and tabs from empty lines PHPBB3-11617 --- phpBB/includes/acp/acp_captcha.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/acp/acp_captcha.php b/phpBB/includes/acp/acp_captcha.php index 5b553d6a0d..bfec7c27d8 100644 --- a/phpBB/includes/acp/acp_captcha.php +++ b/phpBB/includes/acp/acp_captcha.php @@ -124,7 +124,7 @@ class acp_captcha 'CAPTCHA_PREVIEW_TPL' => $demo_captcha->get_demo_template($id), 'S_CAPTCHA_HAS_CONFIG' => $demo_captcha->has_config(), 'CAPTCHA_SELECT' => $captcha_select, - + 'U_ACTION' => $this->u_action, )); } From 950a3a7d952cd361c9dc3c3ff8138b0becea6f74 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Wed, 3 Jul 2013 15:31:24 +0200 Subject: [PATCH 2004/2494] [ticket/11619] Some tests for get_remote_file(). PHPBB3-11619 --- tests/functions/get_remote_file_test.php | 75 ++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 tests/functions/get_remote_file_test.php diff --git a/tests/functions/get_remote_file_test.php b/tests/functions/get_remote_file_test.php new file mode 100644 index 0000000000..4032ca5b58 --- /dev/null +++ b/tests/functions/get_remote_file_test.php @@ -0,0 +1,75 @@ +markTestSkipped(sprintf( + 'Could not find a DNS record for hostname %s. ' . + 'Assuming network is down.', + $hostname + )); + } + + $errstr = $errno = null; + $file = get_remote_file($hostname, '/phpbb', '30x.txt', $errstr, $errno); + + $this->assertNotEquals( + 0, + strlen($file), + 'Failed asserting that the response is not empty.' + ); + + $this->assertSame( + '', + $errstr, + 'Failed asserting that the error string is empty.' + ); + + $this->assertSame( + 0, + $errno, + 'Failed asserting that the error number is 0 (i.e. no error occurred).' + ); + + $lines = explode("\n", $file); + + $this->assertGreaterThanOrEqual( + 2, + sizeof($lines), + 'Failed asserting that the version file has at least two lines.' + ); + + $this->assertStringStartsWith( + '3.', + $lines[0], + "Failed asserting that the first line of the version file starts with '3.'" + ); + + $this->assertNotSame( + false, + filter_var($lines[1], FILTER_VALIDATE_URL), + 'Failed asserting that the second line of the version file is a valid URL.' + ); + + $this->assertContains('http', $lines[1]); + $this->assertContains('phpbb.com', $lines[1], '', true); + } +} From 9e845d4641aa7f71ab713434a7a2e1edfd2876b4 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Wed, 3 Jul 2013 15:31:40 +0200 Subject: [PATCH 2005/2494] [ticket/11619] Use HTTP/1.0 because of lack of chunked-encoding handling. PHPBB3-11619 --- phpBB/includes/functions_admin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index a9d1db24a5..2f73858ea2 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -3121,7 +3121,7 @@ function get_remote_file($host, $directory, $filename, &$errstr, &$errno, $port if ($fsock = @fsockopen($host, $port, $errno, $errstr, $timeout)) { - @fputs($fsock, "GET $directory/$filename HTTP/1.1\r\n"); + @fputs($fsock, "GET $directory/$filename HTTP/1.0\r\n"); @fputs($fsock, "HOST: $host\r\n"); @fputs($fsock, "Connection: close\r\n\r\n"); From f1717412f3c222af5c3cfc0b248842ea9ec88c9f Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Wed, 3 Jul 2013 09:31:35 -0500 Subject: [PATCH 2006/2494] [feature/twig] Debugging test failures PHPBB3-11598 --- tests/test_framework/phpbb_test_case_helpers.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/test_framework/phpbb_test_case_helpers.php b/tests/test_framework/phpbb_test_case_helpers.php index c4907d5ecf..b83b1ca5ca 100644 --- a/tests/test_framework/phpbb_test_case_helpers.php +++ b/tests/test_framework/phpbb_test_case_helpers.php @@ -96,6 +96,12 @@ class phpbb_test_case_helpers { if (!is_dir($path)) { + // Testing + if (file_exists($path)) + { + echo $path; + } + mkdir($path, 0777, true); } } From 36f25ea09bd42de7bc705332edc5ce3c402bd844 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Thu, 4 Jul 2013 10:12:09 -0500 Subject: [PATCH 2007/2494] [feature/twig] Change style->set_style to accept a list of base directories set_style now accepts an array containing a list of paths, e.g. array( 'ext/foo/bar/styles', 'styles'). Default: array('styles') Using this option allows us to set the style based on the user's preferred style (including the full tree), but use one or more base directories to add the paths from. The main use for this ability is so that extensions can call set_style, including their path and the phpBB styles path (or any others) and have their template files loaded from those directories (in the order given). PHPBB3-11598 --- phpBB/includes/style/style.php | 87 ++++++++++++++++----------- phpBB/includes/template/template.php | 2 +- phpBB/includes/template/twig/twig.php | 6 +- 3 files changed, 58 insertions(+), 37 deletions(-) diff --git a/phpBB/includes/style/style.php b/phpBB/includes/style/style.php index 29cdcf0f7f..b0bf3c1019 100644 --- a/phpBB/includes/style/style.php +++ b/phpBB/includes/style/style.php @@ -85,28 +85,56 @@ class phpbb_style } /** - * Set style location based on (current) user's chosen style. + * Get the style tree of the style preferred by the current user + * + * @return array Style tree, most specific first */ - public function set_style() + public function get_user_style() { - $style_path = $this->user->style['style_path']; - $style_dirs = ($this->user->style['style_parent_id']) ? array_reverse(explode('/', $this->user->style['style_parent_tree'])) : array(); + return array_merge(array( + $this->user->style['style_path'], + ), + ($this->user->style['style_parent_id']) ? array_reverse(explode('/', $this->user->style['style_parent_tree'])) : array() + ); + } - $names = array($style_path); - foreach ($style_dirs as $dir) - { - $names[] = $dir; - } - // Add 'all' path, used as last fallback path by events and extensions - //$names[] = 'all'; + /** + * Set style location based on (current) user's chosen style. + * + * @param array $style_directories The directories to add style paths for + * E.g. array('ext/foo/bar/styles', 'styles') + * Default: array('styles') (phpBB's style directory) + * @return bool true + */ + public function set_style($style_directories = array('styles')) + { + $this->names = $this->get_user_style(); $paths = array(); - foreach ($names as $name) + foreach ($style_directories as $directory) { - $paths[] = $this->get_style_path($name); + foreach ($this->names as $name) + { + $path = $this->get_style_path($name, $directory); + + if (is_dir($path)) + { + $paths[] = $path; + } + } } - return $this->set_custom_style($style_path, $paths, $names); + $this->provider->set_styles($paths); + $this->locator->set_paths($this->provider); + + foreach ($paths as &$path) + { + $path .= '/template/'; + } + + $this->template->set_style_names($this->names, $paths, ($style_directories === array('styles'))); + + return true; } /** @@ -118,6 +146,7 @@ class phpbb_style * @param array or string $paths Array of style paths, relative to current root directory * @param array $names Array of names of templates in inheritance tree order, used by extensions. If empty, $name will be used. * @param string $template_path Path to templates, relative to style directory. False if path should be set to default (templates/). + * @return bool true */ public function set_custom_style($name, $paths, $names = array(), $template_path = false) { @@ -138,28 +167,15 @@ class phpbb_style if ($template_path !== false) { $this->locator->set_template_path($template_path); - - $appended_paths = array(); - foreach ($paths as $path) - { - $appended_paths[] = $path . '/' . $template_path; - } - - $this->template->set_style_names($names, $appended_paths); } - else + + foreach ($paths as &$path) { - $this->locator->set_default_template_path(); - - $appended_paths = array(); - foreach ($paths as $path) - { - $appended_paths[] = $path . '/template/'; - } - - $this->template->set_style_names($names, $appended_paths); + $path .= '/' . (($template_path !== false) ? $template_path : 'template/'); } + $this->template->set_style_names($names, $paths); + return true; } @@ -167,11 +183,14 @@ class phpbb_style * Get location of style directory for specific style_path * * @param string $path Style path, such as "prosilver" + * @param string $style_base_directory The base directory the style is in + * E.g. 'styles', 'ext/foo/bar/styles' + * Default: 'styles' * @return string Path to style directory, relative to current path */ - public function get_style_path($path) + public function get_style_path($path, $style_base_directory = 'styles') { - return $this->phpbb_root_path . 'styles/' . $path; + return $this->phpbb_root_path . trim($style_base_directory, '/') . '/' . $path; } /** diff --git a/phpBB/includes/template/template.php b/phpBB/includes/template/template.php index 2b7c36ea7d..89a01e924d 100644 --- a/phpBB/includes/template/template.php +++ b/phpBB/includes/template/template.php @@ -41,7 +41,7 @@ interface phpbb_template * @param array $style_paths List of style paths in inheritance tree order * @return phpbb_template $this */ - public function set_style_names(array $style_names, array $style_paths = array()); + public function set_style_names(array $style_names, array $style_paths); /** * Clears all variables and blocks assigned to this template. diff --git a/phpBB/includes/template/twig/twig.php b/phpBB/includes/template/twig/twig.php index 98bd1ab89c..dd2c1a4023 100644 --- a/phpBB/includes/template/twig/twig.php +++ b/phpBB/includes/template/twig/twig.php @@ -181,9 +181,11 @@ class phpbb_template_twig implements phpbb_template * * @param array $style_names List of style names in inheritance tree order * @param array $style_paths List of style paths in inheritance tree order + * @param bool $is_core True if the style names are the "core" styles for this page load + * Core means the main phpBB template files * @return phpbb_template $this */ - public function set_style_names(array $style_names, array $style_paths = array()) + public function set_style_names(array $style_names, array $style_paths, $is_core = false) { $this->style_names = $style_names; @@ -191,7 +193,7 @@ class phpbb_template_twig implements phpbb_template $this->twig->getLoader()->setPaths($style_paths); // Core style namespace from phpbb_style::set_style() - if (isset($this->user->style['style_path']) && ($style_names === array($this->user->style['style_path']) || $style_names[0] == $this->user->style['style_path'])) + if ($is_core) { $this->twig->getLoader()->setPaths($style_paths, 'core'); } From 884a5b06fa2e300285a67885d0652d201c7a330a Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Thu, 4 Jul 2013 10:13:05 -0500 Subject: [PATCH 2008/2494] [feature/twig] Add set_style function to controller helper PHPBB3-11598 --- phpBB/config/services.yml | 1 + phpBB/includes/controller/helper.php | 25 ++++++++++++++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/phpBB/config/services.yml b/phpBB/config/services.yml index 23205169b9..f364bf5574 100644 --- a/phpBB/config/services.yml +++ b/phpBB/config/services.yml @@ -68,6 +68,7 @@ services: controller.helper: class: phpbb_controller_helper arguments: + - @style - @template - @user - %core.root_path% diff --git a/phpBB/includes/controller/helper.php b/phpBB/includes/controller/helper.php index 74410ddfd1..ec09757a5d 100644 --- a/phpBB/includes/controller/helper.php +++ b/phpBB/includes/controller/helper.php @@ -23,6 +23,12 @@ use Symfony\Component\HttpFoundation\Response; */ class phpbb_controller_helper { + /** + * Style object + * @var phpbb_style + */ + protected $style; + /** * Template object * @var phpbb_template @@ -50,19 +56,36 @@ class phpbb_controller_helper /** * Constructor * + * @param phpbb_style $style Style object * @param phpbb_template $template Template object * @param phpbb_user $user User object * @param string $phpbb_root_path phpBB root path * @param string $php_ext PHP extension */ - public function __construct(phpbb_template $template, phpbb_user $user, $phpbb_root_path, $php_ext) + public function __construct(phpbb_style $style, phpbb_template $template, phpbb_user $user, $phpbb_root_path, $php_ext) { + $this->style = $style; $this->template = $template; $this->user = $user; $this->phpbb_root_path = $phpbb_root_path; $this->php_ext = $php_ext; } + /** + * Set style location based on (current) user's chosen style. + * + * @param array $style_directories The directories to add style paths for + * E.g. array('ext/foo/bar/styles', 'styles') + * Default: array('styles') (phpBB's style directory) + * @return phpbb_controller_helper $this + */ + public function set_style($style_base_directory = array('styles')) + { + $this->style->set_style($style_base_directory); + + return $this; + } + /** * Automate setting up the page and creating the response object. * From 5c39f26cd27d5e4a1debfa24407825906f42d346 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Thu, 4 Jul 2013 10:13:46 -0500 Subject: [PATCH 2009/2494] [feature/twig] Call set_style in the foo/bar controller for functional tests PHPBB3-11598 --- tests/functional/fixtures/ext/foo/bar/controller/controller.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/functional/fixtures/ext/foo/bar/controller/controller.php b/tests/functional/fixtures/ext/foo/bar/controller/controller.php index 5a91b5f681..331f6addfb 100644 --- a/tests/functional/fixtures/ext/foo/bar/controller/controller.php +++ b/tests/functional/fixtures/ext/foo/bar/controller/controller.php @@ -9,6 +9,8 @@ class phpbb_ext_foo_bar_controller { $this->template = $template; $this->helper = $helper; + + $this->helper->set_style(array('ext/foo/bar/styles', 'styles')); } public function handle() From 84e0943c7bee5061bc53aed2a14f82751d238bf8 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Thu, 4 Jul 2013 10:22:12 -0500 Subject: [PATCH 2010/2494] [feature/twig] Indentation and comments PHPBB3-11598 --- phpBB/includes/template/twig/extension.php | 18 +++++++++--------- phpBB/includes/template/twig/twig.php | 4 +++- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/phpBB/includes/template/twig/extension.php b/phpBB/includes/template/twig/extension.php index a54c2b2509..f73b99a4c1 100644 --- a/phpBB/includes/template/twig/extension.php +++ b/phpBB/includes/template/twig/extension.php @@ -59,9 +59,9 @@ class phpbb_template_twig_extension extends Twig_Extension */ public function getFilters() { - return array( - new Twig_SimpleFilter('subset', array($this, 'loop_subset'), array('needs_environment' => true)), - new Twig_SimpleFilter('addslashes', 'addslashes'), + return array( + new Twig_SimpleFilter('subset', array($this, 'loop_subset'), array('needs_environment' => true)), + new Twig_SimpleFilter('addslashes', 'addslashes'), ); } @@ -72,8 +72,8 @@ class phpbb_template_twig_extension extends Twig_Extension */ public function getFunctions() { - return array( - new Twig_SimpleFunction('lang', array($this, 'lang')), + return array( + new Twig_SimpleFunction('lang', array($this, 'lang')), ); } @@ -86,7 +86,7 @@ class phpbb_template_twig_extension extends Twig_Extension { return array( array( - '!' => array('precedence' => 50, 'class' => 'Twig_Node_Expression_Unary_Not'), + '!' => array('precedence' => 50, 'class' => 'Twig_Node_Expression_Unary_Not'), ), array( // precedence settings are copied from similar operators in Twig core extension @@ -109,9 +109,9 @@ class phpbb_template_twig_extension extends Twig_Extension 'lte' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_LessEqual', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), 'le' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_LessEqual', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), - 'mod' => array('precedence' => 60, 'class' => 'Twig_Node_Expression_Binary_Mod', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), - ), - ); + 'mod' => array('precedence' => 60, 'class' => 'Twig_Node_Expression_Binary_Mod', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), + ), + ); } /** diff --git a/phpBB/includes/template/twig/twig.php b/phpBB/includes/template/twig/twig.php index dd2c1a4023..621bfe0f4f 100644 --- a/phpBB/includes/template/twig/twig.php +++ b/phpBB/includes/template/twig/twig.php @@ -102,7 +102,9 @@ class phpbb_template_twig implements phpbb_template * Constructor. * * @param string $phpbb_root_path phpBB root path - * @param user $user current user + * @param string $php_ext php extension (typically 'php') + * @param phpbb_config $config + * @param phpbb_user $user * @param phpbb_template_context $context template context * @param phpbb_extension_manager $extension_manager extension manager, if null then template events will not be invoked * @param string $adm_relative_path relative path to adm directory From 81f27fd87ee2e8ffc1ad1ad06c5b255c5436e86c Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Thu, 4 Jul 2013 10:40:14 -0500 Subject: [PATCH 2011/2494] [feature/twig] Add test to make sure nested loops get the correct S_ROW_COUNT PHPBB3-11598 --- tests/template/template_test.php | 7 +++++++ tests/template/templates/loop_nested2.html | 6 ++++++ 2 files changed, 13 insertions(+) create mode 100644 tests/template/templates/loop_nested2.html diff --git a/tests/template/template_test.php b/tests/template/template_test.php index 1b3dda9b2a..4970ce0363 100644 --- a/tests/template/template_test.php +++ b/tests/template/template_test.php @@ -125,6 +125,13 @@ class phpbb_template_template_test extends phpbb_template_template_test_case array(), "101234561\nx\n101234561\nx\n101234561\nx\n1234561\nx\n1\nx\n101\nx\n234\nx\n10\nx\n561\nx\n561", ), + array( + 'loop_nested2.html', + array(), + array('outer' => array(array(), array()), 'outer.middle' => array(array(), array())), + array(), + "o0o1m01m11", + ), array( 'define.html', array(), diff --git a/tests/template/templates/loop_nested2.html b/tests/template/templates/loop_nested2.html new file mode 100644 index 0000000000..3eeeb5e36a --- /dev/null +++ b/tests/template/templates/loop_nested2.html @@ -0,0 +1,6 @@ + +o{outer.S_ROW_COUNT} + +m{outer.middle.S_ROW_COUNT}{outer.S_ROW_COUNT} + + From 2fb48d60f1b8ea111c766d6d9e7a3dde2b8a4e74 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Thu, 4 Jul 2013 11:08:36 -0500 Subject: [PATCH 2012/2494] [feature/twig] Attempt to automatically set style dir for ext controllers Extension authors can change it themselves if necessary PHPBB3-11598 --- phpBB/config/services.yml | 2 +- phpBB/includes/controller/resolver.php | 28 +++++++++++++++++++++++++- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/phpBB/config/services.yml b/phpBB/config/services.yml index f364bf5574..bb9879601c 100644 --- a/phpBB/config/services.yml +++ b/phpBB/config/services.yml @@ -79,7 +79,7 @@ services: arguments: - @user - @service_container - - @ext.finder + - @style cron.task_collection: class: phpbb_di_service_collection diff --git a/phpBB/includes/controller/resolver.php b/phpBB/includes/controller/resolver.php index ee469aa9c8..2c7d112748 100644 --- a/phpBB/includes/controller/resolver.php +++ b/phpBB/includes/controller/resolver.php @@ -37,16 +37,24 @@ class phpbb_controller_resolver implements ControllerResolverInterface */ protected $container; + /** + * phpbb_style object + * @var phpbb_style + */ + protected $style; + /** * Construct method * * @param phpbb_user $user User Object * @param ContainerInterface $container ContainerInterface object + * @param phpbb_style $style */ - public function __construct(phpbb_user $user, ContainerInterface $container) + public function __construct(phpbb_user $user, ContainerInterface $container, phpbb_style $style) { $this->user = $user; $this->container = $container; + $this->style = $style; } /** @@ -80,6 +88,24 @@ class phpbb_controller_resolver implements ControllerResolverInterface $controller_object = $this->container->get($service); + /* + * If this is an extension controller, we'll try to automatically set + * the style paths for the extension (the ext author can change them + * if necessary). + */ + $controller_dir = explode('_', get_class($controller_object)); + + // 0 phpbb, 1 ext, 2 vendor, 3 extension name, ... + if ($controller_dir[1] === 'ext') + { + $controller_style_dir = 'ext/' . $controller_dir[2] . '/' . $controller_dir[3] . '/styles'; + + if (is_dir($controller_style_dir)) + { + $this->style->set_style(array($controller_style_dir, 'styles')); + } + } + return array($controller_object, $method); } From bb56c1a391feff9c54d05f64e49c6d1f93ac2bce Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Thu, 4 Jul 2013 11:09:33 -0500 Subject: [PATCH 2013/2494] Revert "[feature/twig] Call set_style in the foo/bar controller for functional tests" This reverts commit 5c39f26cd27d5e4a1debfa24407825906f42d346. --- tests/functional/fixtures/ext/foo/bar/controller/controller.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/functional/fixtures/ext/foo/bar/controller/controller.php b/tests/functional/fixtures/ext/foo/bar/controller/controller.php index 331f6addfb..5a91b5f681 100644 --- a/tests/functional/fixtures/ext/foo/bar/controller/controller.php +++ b/tests/functional/fixtures/ext/foo/bar/controller/controller.php @@ -9,8 +9,6 @@ class phpbb_ext_foo_bar_controller { $this->template = $template; $this->helper = $helper; - - $this->helper->set_style(array('ext/foo/bar/styles', 'styles')); } public function handle() From 1ce33c1ff62426d030731cca100c4119bcd5265d Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Thu, 4 Jul 2013 11:12:26 -0500 Subject: [PATCH 2014/2494] [feature/twig] Safety check for 2fb48d6 PHPBB3-11598 --- phpBB/includes/controller/resolver.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/controller/resolver.php b/phpBB/includes/controller/resolver.php index 2c7d112748..e44aa14b55 100644 --- a/phpBB/includes/controller/resolver.php +++ b/phpBB/includes/controller/resolver.php @@ -96,7 +96,7 @@ class phpbb_controller_resolver implements ControllerResolverInterface $controller_dir = explode('_', get_class($controller_object)); // 0 phpbb, 1 ext, 2 vendor, 3 extension name, ... - if ($controller_dir[1] === 'ext') + if (isset($controller_dir[3]) && $controller_dir[1] === 'ext') { $controller_style_dir = 'ext/' . $controller_dir[2] . '/' . $controller_dir[3] . '/styles'; From b7ede06835ba784b81365946f057adf75ae7592b Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Thu, 4 Jul 2013 11:16:44 -0500 Subject: [PATCH 2015/2494] [feature/twig] Make style dependency optional for resolver PHPBB3-11598 --- phpBB/includes/controller/resolver.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/controller/resolver.php b/phpBB/includes/controller/resolver.php index e44aa14b55..95dfc8da8e 100644 --- a/phpBB/includes/controller/resolver.php +++ b/phpBB/includes/controller/resolver.php @@ -50,7 +50,7 @@ class phpbb_controller_resolver implements ControllerResolverInterface * @param ContainerInterface $container ContainerInterface object * @param phpbb_style $style */ - public function __construct(phpbb_user $user, ContainerInterface $container, phpbb_style $style) + public function __construct(phpbb_user $user, ContainerInterface $container, phpbb_style $style = null) { $this->user = $user; $this->container = $container; @@ -96,7 +96,7 @@ class phpbb_controller_resolver implements ControllerResolverInterface $controller_dir = explode('_', get_class($controller_object)); // 0 phpbb, 1 ext, 2 vendor, 3 extension name, ... - if (isset($controller_dir[3]) && $controller_dir[1] === 'ext') + if (!is_null($this->style) && isset($controller_dir[3]) && $controller_dir[1] === 'ext') { $controller_style_dir = 'ext/' . $controller_dir[2] . '/' . $controller_dir[3] . '/styles'; From 5f03321fac6ce888cb870e158c685bf839c25f07 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Thu, 4 Jul 2013 12:44:12 -0500 Subject: [PATCH 2016/2494] [feature/twig] Support using Twig filters on {VAR}, add masks for Twig tags Now we can do {L_TITLE|upper}, {SITENAME|lower}, etc We can also use all the Twig tags in our own syntax. E.g. = {% block foo %]. All tags are the same as the Twig tag names, but are in uppercase. PHPBB3-11598 --- phpBB/includes/template/twig/lexer.php | 76 ++++++++++++++++++++++++-- phpBB/includes/template/twig/twig.php | 2 +- 2 files changed, 71 insertions(+), 7 deletions(-) diff --git a/phpBB/includes/template/twig/lexer.php b/phpBB/includes/template/twig/lexer.php index c7ab1590f5..50ef403231 100644 --- a/phpBB/includes/template/twig/lexer.php +++ b/phpBB/includes/template/twig/lexer.php @@ -19,8 +19,9 @@ class phpbb_template_twig_lexer extends Twig_Lexer { public function tokenize($code, $filename = null) { - $valid_starting_tokens = array( - // Commented out tokens are handled separately from the main replace + // Our phpBB tags + // Commented out tokens are handled separately from the main replace + $phpbb_tags = array( /*'BEGIN', 'BEGINELSE', 'END',*/ @@ -39,6 +40,34 @@ class phpbb_template_twig_lexer extends Twig_Lexer 'EVENT', ); + // Twig tag masks + $twig_tags = array( + 'autoescape', + 'endautoescape', + 'block', + 'endblock', + 'use', + 'extends', + 'embed', + 'filter', + 'endfilter', + 'flush', + 'for', + 'endfor', + 'macro', + 'endmacro', + 'import', + 'from', + 'sandbox', + 'endsandbox', + 'set', + 'endset', + 'spaceless', + 'endspaceless', + 'verbatim', + 'endverbatim', + ); + // Fix tokens that may have inline variables (e.g. with Twig style, {% TOKEN %} // This also strips outer parenthesis, becomes - $code = preg_replace('##', '{% $1 $2 %}', $code); + $code = preg_replace('##', '{% $1 $2 %}', $code); + + // Replace all of our twig masks with Twig code (e.g. with {% block $1 %}) + $code = $this->replace_twig_tag_masks($code, $twig_tags); // Replace all of our language variables, {L_VARNAME}, with Twig style, {{ lang('NAME') }} - $code = preg_replace('#{L_([a-zA-Z0-9_\.]+)}#', '{{ lang(\'$1\') }}', $code); + // Appends any filters after lang() + $code = preg_replace('#{L_([a-zA-Z0-9_\.]+)(\|[^}]+)?}#', '{{ lang(\'$1\')$2 }}', $code); // Replace all of our escaped language variables, {LA_VARNAME}, with Twig style, {{ lang('NAME')|addslashes }} - $code = preg_replace('#{LA_([a-zA-Z0-9_\.]+)}#', '{{ lang(\'$1\')|addslashes }}', $code); + // Appends any filters after lang(), but before addslashes + $code = preg_replace('#{LA_([a-zA-Z0-9_\.]+)(\|[^}]+)?}}#', '{{ lang(\'$1\')$2|addslashes }}', $code); // Replace all of our variables, {VARNAME}, with Twig style, {{ VARNAME }} - $code = preg_replace('#{([a-zA-Z0-9_\.]+)}#', '{{ $1 }}', $code); + // Appends any filters + $code = preg_replace('#{([a-zA-Z0-9_\.]+)(\|[^}]+)?}#', '{{ $1$2 }}', $code); return parent::tokenize($code, $filename); } @@ -227,4 +262,33 @@ class phpbb_template_twig_lexer extends Twig_Lexer return $code; } + + /** + * Replace Twig tag masks with Twig tag calls + * + * E.g. with {% block foo %} + * + * @param string $code + * @param array $twig_tags All tags we want to create a mask for + * @return string + */ + protected function replace_twig_tag_masks($code, $twig_tags) + { + $callback = function ($matches) + { + $matches[1] = strtolower($matches[1]); + + return "{% {$matches[1]}{$matches[2]}%}"; + }; + + foreach ($twig_tags as &$tag) + { + $tag = strtoupper($tag); + } + + // twig_tags is an array of the twig tags, which are all lowercase, but we use all uppercase tags + $code = preg_replace_callback('##',$callback, $code); + + return $code; + } } diff --git a/phpBB/includes/template/twig/twig.php b/phpBB/includes/template/twig/twig.php index 621bfe0f4f..47e346ad1e 100644 --- a/phpBB/includes/template/twig/twig.php +++ b/phpBB/includes/template/twig/twig.php @@ -132,7 +132,7 @@ class phpbb_template_twig implements phpbb_template array( 'cache' => $this->cachepath, 'debug' => defined('DEBUG'), - 'auto_reload' => (bool) $this->config['load_tplcompile'], + 'auto_reload' => true,//(bool) $this->config['load_tplcompile'], 'autoescape' => false, ) ); From 864465761f45fec2732381849ee9959d7ad9b45d Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Thu, 4 Jul 2013 13:19:03 -0500 Subject: [PATCH 2017/2494] [feature/twig] Fix debug code PHPBB3-11598 --- phpBB/includes/template/twig/twig.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/template/twig/twig.php b/phpBB/includes/template/twig/twig.php index 47e346ad1e..621bfe0f4f 100644 --- a/phpBB/includes/template/twig/twig.php +++ b/phpBB/includes/template/twig/twig.php @@ -132,7 +132,7 @@ class phpbb_template_twig implements phpbb_template array( 'cache' => $this->cachepath, 'debug' => defined('DEBUG'), - 'auto_reload' => true,//(bool) $this->config['load_tplcompile'], + 'auto_reload' => (bool) $this->config['load_tplcompile'], 'autoescape' => false, ) ); From 4f6cb9acbdc8b3564fa30e8e291e5fa669a409b9 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Thu, 4 Jul 2013 13:19:21 -0500 Subject: [PATCH 2018/2494] [feature/twig] Fix helper URL test PHPBB3-11598 --- tests/controller/helper_url_test.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/controller/helper_url_test.php b/tests/controller/helper_url_test.php index e376efde66..3206460caf 100644 --- a/tests/controller/helper_url_test.php +++ b/tests/controller/helper_url_test.php @@ -51,8 +51,11 @@ class phpbb_controller_helper_url_test extends phpbb_test_case $this->style_resource_locator = new phpbb_style_resource_locator(); $this->user = $this->getMock('phpbb_user'); $this->template = new phpbb_template_twig($phpbb_root_path, $phpEx, $config, $this->user, new phpbb_template_context()); + $this->style_resource_locator = new phpbb_style_resource_locator(); + $this->style_provider = new phpbb_style_path_provider(); + $this->style = new phpbb_style($phpbb_root_path, $phpEx, new phpbb_config(array()), $this->user, $this->style_resource_locator, $this->style_provider, $this->template); - $helper = new phpbb_controller_helper($this->template, $this->user, '', 'php'); + $helper = new phpbb_controller_helper($this->style, $this->template, $this->user, '', 'php'); $this->assertEquals($helper->url($route, $params, $is_amp, $session_id), $expected); } } From fdbdd8bfd92795098b4f9a704a677972e611f455 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Thu, 4 Jul 2013 13:22:41 -0500 Subject: [PATCH 2019/2494] [feature/twig] Fix a regular expression PHPBB3-11598 --- phpBB/includes/template/twig/lexer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/template/twig/lexer.php b/phpBB/includes/template/twig/lexer.php index 50ef403231..394c3077a6 100644 --- a/phpBB/includes/template/twig/lexer.php +++ b/phpBB/includes/template/twig/lexer.php @@ -98,7 +98,7 @@ class phpbb_template_twig_lexer extends Twig_Lexer // Replace all of our escaped language variables, {LA_VARNAME}, with Twig style, {{ lang('NAME')|addslashes }} // Appends any filters after lang(), but before addslashes - $code = preg_replace('#{LA_([a-zA-Z0-9_\.]+)(\|[^}]+)?}}#', '{{ lang(\'$1\')$2|addslashes }}', $code); + $code = preg_replace('#{LA_([a-zA-Z0-9_\.]+)(\|[^}]+)?}#', '{{ lang(\'$1\')$2|addslashes }}', $code); // Replace all of our variables, {VARNAME}, with Twig style, {{ VARNAME }} // Appends any filters From 8cf6dbd95035f71ea8cff0f2f8d834b91b243429 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Thu, 4 Jul 2013 13:25:50 -0500 Subject: [PATCH 2020/2494] [feature/twig] Trying some new debug code for this mkdir error PHPBB3-11598 --- tests/test_framework/phpbb_test_case_helpers.php | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/tests/test_framework/phpbb_test_case_helpers.php b/tests/test_framework/phpbb_test_case_helpers.php index b83b1ca5ca..fdc09fbeec 100644 --- a/tests/test_framework/phpbb_test_case_helpers.php +++ b/tests/test_framework/phpbb_test_case_helpers.php @@ -94,16 +94,12 @@ class phpbb_test_case_helpers public function makedirs($path) { - if (!is_dir($path)) + if (is_dir($path) || file_exists($path)) { - // Testing - if (file_exists($path)) - { - echo $path; - } - - mkdir($path, 0777, true); + var_dump($path); + exit; } + mkdir($path, 0777, true); } static public function get_test_config() From 24be21636656bf636738449488da3810e489b4a7 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Thu, 4 Jul 2013 13:49:56 -0500 Subject: [PATCH 2021/2494] [feature/twig] Attempt to automatically set style dir for ext modules Extension authors can change it themselves if necessary PHPBB3-11598 --- phpBB/includes/functions_module.php | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/phpBB/includes/functions_module.php b/phpBB/includes/functions_module.php index 0d387ace6d..5a8ac276cd 100644 --- a/phpBB/includes/functions_module.php +++ b/phpBB/includes/functions_module.php @@ -455,7 +455,7 @@ class p_master */ function load_active($mode = false, $module_url = false, $execute_module = true) { - global $phpbb_root_path, $phpbb_admin_path, $phpEx, $user; + global $phpbb_root_path, $phpbb_admin_path, $phpEx, $user, $style; $module_path = $this->include_path . $this->p_class; $icat = request_var('icat', ''); @@ -491,6 +491,24 @@ class p_master $this->module = new $class_name($this); + /* + * If this is an extension module, we'll try to automatically set + * the style paths for the extension (the ext author can change them + * if necessary). + */ + $module_dir = explode('_', get_class($this->module)); + + // 0 phpbb, 1 ext, 2 vendor, 3 extension name, ... + if (!is_null($this->style) && isset($module_dir[3]) && $module_dir[1] === 'ext') + { + $module_style_dir = 'ext/' . $module_dir[2] . '/' . $module_dir[3] . '/styles'; + + if (is_dir($module_style_dir)) + { + $style->set_style(array($module_style_dir, 'styles')); + } + } + // We pre-define the action parameter we are using all over the place if (defined('IN_ADMIN')) { From 38700a80f805ae32632d88254e714699b8435f61 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Thu, 4 Jul 2013 14:09:50 -0500 Subject: [PATCH 2022/2494] [feature/twig] Fix copy/pasted code PHPBB3-11598 --- phpBB/includes/functions_module.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/functions_module.php b/phpBB/includes/functions_module.php index 5a8ac276cd..85ff41500f 100644 --- a/phpBB/includes/functions_module.php +++ b/phpBB/includes/functions_module.php @@ -499,7 +499,7 @@ class p_master $module_dir = explode('_', get_class($this->module)); // 0 phpbb, 1 ext, 2 vendor, 3 extension name, ... - if (!is_null($this->style) && isset($module_dir[3]) && $module_dir[1] === 'ext') + if (isset($module_dir[3]) && $module_dir[1] === 'ext') { $module_style_dir = 'ext/' . $module_dir[2] . '/' . $module_dir[3] . '/styles'; From 5afcb1d5f4f642d3ad6d8c1a98295e6b115d9a77 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Thu, 4 Jul 2013 21:15:02 +0200 Subject: [PATCH 2023/2494] [ticket/11600] Remove duplicate test case PHPBB3-11600 --- tests/avatar/manager_test.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/avatar/manager_test.php b/tests/avatar/manager_test.php index ec2cba3f53..4ebe79c9cd 100644 --- a/tests/avatar/manager_test.php +++ b/tests/avatar/manager_test.php @@ -95,7 +95,6 @@ class phpbb_avatar_manager_test extends PHPUnit_Framework_TestCase array(AVATAR_GALLERY, null), array(AVATAR_UPLOAD, null), array(AVATAR_REMOTE, null), - array(AVATAR_GALLERY, null), ); } @@ -117,7 +116,6 @@ class phpbb_avatar_manager_test extends PHPUnit_Framework_TestCase array(AVATAR_GALLERY, 'avatar.driver.local'), array(AVATAR_UPLOAD, 'avatar.driver.upload'), array(AVATAR_REMOTE, 'avatar.driver.remote'), - array(AVATAR_GALLERY, 'avatar.driver.local'), ); } From 53496e6a473f1e5563f733365cbeaf275c2fd0af Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Thu, 4 Jul 2013 15:21:57 -0500 Subject: [PATCH 2024/2494] [feature/twig] acp module tpls are in ext/adm, ucp/mcp in styles/ PHPBB3-11598 --- phpBB/includes/functions_module.php | 56 +++++++++++++++++++---------- 1 file changed, 37 insertions(+), 19 deletions(-) diff --git a/phpBB/includes/functions_module.php b/phpBB/includes/functions_module.php index 85ff41500f..df0327db0f 100644 --- a/phpBB/includes/functions_module.php +++ b/phpBB/includes/functions_module.php @@ -455,7 +455,7 @@ class p_master */ function load_active($mode = false, $module_url = false, $execute_module = true) { - global $phpbb_root_path, $phpbb_admin_path, $phpEx, $user, $style; + global $phpbb_root_path, $phpbb_admin_path, $phpEx, $user, $phpbb_style; $module_path = $this->include_path . $this->p_class; $icat = request_var('icat', ''); @@ -491,27 +491,27 @@ class p_master $this->module = new $class_name($this); - /* - * If this is an extension module, we'll try to automatically set - * the style paths for the extension (the ext author can change them - * if necessary). - */ - $module_dir = explode('_', get_class($this->module)); - - // 0 phpbb, 1 ext, 2 vendor, 3 extension name, ... - if (isset($module_dir[3]) && $module_dir[1] === 'ext') - { - $module_style_dir = 'ext/' . $module_dir[2] . '/' . $module_dir[3] . '/styles'; - - if (is_dir($module_style_dir)) - { - $style->set_style(array($module_style_dir, 'styles')); - } - } - // We pre-define the action parameter we are using all over the place if (defined('IN_ADMIN')) { + /* + * If this is an extension module, we'll try to automatically set + * the style paths for the extension (the ext author can change them + * if necessary). + */ + $module_dir = explode('_', get_class($this->module)); + + // 0 phpbb, 1 ext, 2 vendor, 3 extension name, ... + if (isset($module_dir[3]) && $module_dir[1] === 'ext') + { + $module_style_dir = $phpbb_root_path .'ext/' . $module_dir[2] . '/' . $module_dir[3] . '/adm/style'; + + if (is_dir($module_style_dir)) + { + $phpbb_style->set_custom_style('admin', array($module_style_dir, $phpbb_admin_path . 'style'), array(), ''); + } + } + // Is first module automatically enabled a duplicate and the category not passed yet? if (!$icat && $this->module_ary[$this->active_module_row_id]['is_duplicate']) { @@ -523,6 +523,24 @@ class p_master } else { + /* + * If this is an extension module, we'll try to automatically set + * the style paths for the extension (the ext author can change them + * if necessary). + */ + $module_dir = explode('_', get_class($this->module)); + + // 0 phpbb, 1 ext, 2 vendor, 3 extension name, ... + if (isset($module_dir[3]) && $module_dir[1] === 'ext') + { + $module_style_dir = 'ext/' . $module_dir[2] . '/' . $module_dir[3] . '/styles'; + + if (is_dir($phpbb_root_path . $module_style_dir)) + { + $phpbb_style->set_style(array($module_style_dir, 'styles')); + } + } + // If user specified the module url we will use it... if ($module_url !== false) { From 0f3086a54bf2a9c83876a135738bdf130e0f0844 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Thu, 4 Jul 2013 15:24:42 -0500 Subject: [PATCH 2025/2494] [feature/twig] Spacing PHPBB3-11598 --- phpBB/includes/functions_module.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/functions_module.php b/phpBB/includes/functions_module.php index df0327db0f..99c24fcb19 100644 --- a/phpBB/includes/functions_module.php +++ b/phpBB/includes/functions_module.php @@ -504,7 +504,7 @@ class p_master // 0 phpbb, 1 ext, 2 vendor, 3 extension name, ... if (isset($module_dir[3]) && $module_dir[1] === 'ext') { - $module_style_dir = $phpbb_root_path .'ext/' . $module_dir[2] . '/' . $module_dir[3] . '/adm/style'; + $module_style_dir = $phpbb_root_path . 'ext/' . $module_dir[2] . '/' . $module_dir[3] . '/adm/style'; if (is_dir($module_style_dir)) { From 25b4732845941c488f3667ef7ec4afdc0e69d274 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Thu, 4 Jul 2013 15:32:04 -0500 Subject: [PATCH 2026/2494] [feature/twig] Remove debug code PHPBB3-11598 --- tests/test_framework/phpbb_test_case_helpers.php | 5 ----- 1 file changed, 5 deletions(-) diff --git a/tests/test_framework/phpbb_test_case_helpers.php b/tests/test_framework/phpbb_test_case_helpers.php index fdc09fbeec..50b2bf03ec 100644 --- a/tests/test_framework/phpbb_test_case_helpers.php +++ b/tests/test_framework/phpbb_test_case_helpers.php @@ -94,11 +94,6 @@ class phpbb_test_case_helpers public function makedirs($path) { - if (is_dir($path) || file_exists($path)) - { - var_dump($path); - exit; - } mkdir($path, 0777, true); } From 5746c8d96ff50b7c520e3070270311992685fcce Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Thu, 4 Jul 2013 17:12:55 -0400 Subject: [PATCH 2027/2494] [feature/auth-refactor] Move auth providers to separate directory Moves the provider files to their own directory per bantu's suggestion. PHPBB3-9734 --- .../auth/{provider_apache.php => provider/apache.php} | 0 .../includes/auth/{provider_db.php => provider/db.php} | 0 phpBB/includes/auth/provider/index.htm | 10 ++++++++++ .../{provider_interface.php => provider/interface.php} | 0 .../auth/{provider_ldap.php => provider/ldap.php} | 0 5 files changed, 10 insertions(+) rename phpBB/includes/auth/{provider_apache.php => provider/apache.php} (100%) rename phpBB/includes/auth/{provider_db.php => provider/db.php} (100%) create mode 100644 phpBB/includes/auth/provider/index.htm rename phpBB/includes/auth/{provider_interface.php => provider/interface.php} (100%) rename phpBB/includes/auth/{provider_ldap.php => provider/ldap.php} (100%) diff --git a/phpBB/includes/auth/provider_apache.php b/phpBB/includes/auth/provider/apache.php similarity index 100% rename from phpBB/includes/auth/provider_apache.php rename to phpBB/includes/auth/provider/apache.php diff --git a/phpBB/includes/auth/provider_db.php b/phpBB/includes/auth/provider/db.php similarity index 100% rename from phpBB/includes/auth/provider_db.php rename to phpBB/includes/auth/provider/db.php diff --git a/phpBB/includes/auth/provider/index.htm b/phpBB/includes/auth/provider/index.htm new file mode 100644 index 0000000000..ee1f723a7d --- /dev/null +++ b/phpBB/includes/auth/provider/index.htm @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/phpBB/includes/auth/provider_interface.php b/phpBB/includes/auth/provider/interface.php similarity index 100% rename from phpBB/includes/auth/provider_interface.php rename to phpBB/includes/auth/provider/interface.php diff --git a/phpBB/includes/auth/provider_ldap.php b/phpBB/includes/auth/provider/ldap.php similarity index 100% rename from phpBB/includes/auth/provider_ldap.php rename to phpBB/includes/auth/provider/ldap.php From 192c9d8f867a0c7d1a81d23bc4fb11c63fe1ec40 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Fri, 5 Jul 2013 09:37:40 -0500 Subject: [PATCH 2028/2494] [feature/twig] Removing template/renderer.php (no longer used) PHPBB3-11598 --- phpBB/includes/template/renderer.php | 35 ---------------------------- 1 file changed, 35 deletions(-) delete mode 100644 phpBB/includes/template/renderer.php diff --git a/phpBB/includes/template/renderer.php b/phpBB/includes/template/renderer.php deleted file mode 100644 index 30e234a733..0000000000 --- a/phpBB/includes/template/renderer.php +++ /dev/null @@ -1,35 +0,0 @@ - Date: Fri, 5 Jul 2013 09:56:25 -0500 Subject: [PATCH 2029/2494] [feature/twig] Docs/typehinting for Twig extension PHPBB3-11598 --- phpBB/includes/template/twig/extension.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/phpBB/includes/template/twig/extension.php b/phpBB/includes/template/twig/extension.php index f73b99a4c1..5704468013 100644 --- a/phpBB/includes/template/twig/extension.php +++ b/phpBB/includes/template/twig/extension.php @@ -23,12 +23,24 @@ class phpbb_template_twig_extension extends Twig_Extension /** @var phpbb_user */ protected $user; - public function __construct(phpbb_template_context $context, $user) + /** + * Constructor + * + * @param phpbb_template_context $context + * @param phpbb_user $user + * @return phpbb_template_twig_extension + */ + public function __construct(phpbb_template_context $context, phpbb_user $user) { $this->context = $context; $this->user = $user; } + /** + * Get the name of this extension + * + * @return string + */ public function getName() { return 'phpbb'; From c1a600277d07c2dbb3ebd410f87acb22627a9d60 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Fri, 5 Jul 2013 09:57:55 -0500 Subject: [PATCH 2030/2494] [feature/twig] Nicer code for get_user_style.php() PHPBB3-11598 --- phpBB/includes/style/style.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/phpBB/includes/style/style.php b/phpBB/includes/style/style.php index b0bf3c1019..06c16fdef4 100644 --- a/phpBB/includes/style/style.php +++ b/phpBB/includes/style/style.php @@ -91,11 +91,16 @@ class phpbb_style */ public function get_user_style() { - return array_merge(array( - $this->user->style['style_path'], - ), - ($this->user->style['style_parent_id']) ? array_reverse(explode('/', $this->user->style['style_parent_tree'])) : array() + $style_list = array( + $this->user->style['style_path'], ); + + if ($this->user->style['style_parent_id']) + { + $style_list = array_merge($style_list, array_reverse(explode('/', $this->user->style['style_parent_tree']))); + } + + return $style_list; } /** From 2674740573a226dae36dc81faf8eb5453e01a31d Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Fri, 5 Jul 2013 10:03:48 -0500 Subject: [PATCH 2031/2494] [feature/twig] Spacing PHPBB3-11598 --- phpBB/includes/template/twig/extension.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/template/twig/extension.php b/phpBB/includes/template/twig/extension.php index 5704468013..e23dd4f119 100644 --- a/phpBB/includes/template/twig/extension.php +++ b/phpBB/includes/template/twig/extension.php @@ -144,7 +144,7 @@ class phpbb_template_twig_extension extends Twig_Extension { // When end is > 1, subset will end on the last item in an array with the specified $end // This is different from slice in that it is the number we end on rather than the number - // of items to grab (length) + // of items to grab (length) // Start must always be the actual starting number for this calculation (not negative) $start = ($start < 0) ? sizeof($item) + $start : $start; From 81f0715b8ef89e3a03a285a0c0f4639351449e9a Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Fri, 5 Jul 2013 10:05:20 -0500 Subject: [PATCH 2032/2494] [feature/twig] Clarify comment PHPBB3-11598 --- phpBB/includes/template/twig/extension.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/template/twig/extension.php b/phpBB/includes/template/twig/extension.php index e23dd4f119..6b066f1bd3 100644 --- a/phpBB/includes/template/twig/extension.php +++ b/phpBB/includes/template/twig/extension.php @@ -139,7 +139,7 @@ class phpbb_template_twig_extension extends Twig_Extension */ function loop_subset(Twig_Environment $env, $item, $start, $end = null, $preserveKeys = false) { - // We do almost the same thing as array_slice, except when $end is positive + // We do almost the same thing as Twig's slice (array_slice), except when $end is positive if ($end >= 1) { // When end is > 1, subset will end on the last item in an array with the specified $end From 1f4a717f9ec925d84b589547ce6c93a17ae863e9 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Fri, 5 Jul 2013 10:29:24 -0500 Subject: [PATCH 2033/2494] [feature/twig] Add template test for ===, !== PHPBB3-11598 --- tests/template/template_test.php | 22 ++++++++++++++++++---- tests/template/templates/if.html | 8 ++++++++ 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/tests/template/template_test.php b/tests/template/template_test.php index 4970ce0363..b7c3a08512 100644 --- a/tests/template/template_test.php +++ b/tests/template/template_test.php @@ -46,28 +46,42 @@ class phpbb_template_template_test extends phpbb_template_template_test_case array(), array(), array(), - '03', + '03!false', ), array( 'if.html', array('S_VALUE' => true), array(), array(), - '1', + '1!false', ), array( 'if.html', array('S_VALUE' => true, 'S_OTHER_VALUE' => true), array(), array(), - '1', + '1!false', ), array( 'if.html', array('S_VALUE' => false, 'S_OTHER_VALUE' => true), array(), array(), - '2', + '2!false', + ), + array( + 'if.html', + array('S_TEST' => false), + array(), + array(), + '03false', + ), + array( + 'if.html', + array('S_TEST' => 0), + array(), + array(), + '03!false', ), array( 'loop.html', diff --git a/tests/template/templates/if.html b/tests/template/templates/if.html index eed431019e..c010aff7fa 100644 --- a/tests/template/templates/if.html +++ b/tests/template/templates/if.html @@ -9,3 +9,11 @@ 04 + + +false + + + +!false + From 13c356545465a457b8c55dd9638f89165bab6271 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Fri, 5 Jul 2013 12:11:59 -0500 Subject: [PATCH 2034/2494] [feature/twig] Remove style dependency for controller helper If a controller wants to use set_style, it can just use phpbb_style PHPBB3-11598 --- phpBB/config/services.yml | 1 - phpBB/includes/controller/helper.php | 25 +------------------------ tests/controller/helper_url_test.php | 2 +- 3 files changed, 2 insertions(+), 26 deletions(-) diff --git a/phpBB/config/services.yml b/phpBB/config/services.yml index 3d951e2a45..e228b3d83f 100644 --- a/phpBB/config/services.yml +++ b/phpBB/config/services.yml @@ -69,7 +69,6 @@ services: controller.helper: class: phpbb_controller_helper arguments: - - @style - @template - @user - %core.root_path% diff --git a/phpBB/includes/controller/helper.php b/phpBB/includes/controller/helper.php index ec09757a5d..74410ddfd1 100644 --- a/phpBB/includes/controller/helper.php +++ b/phpBB/includes/controller/helper.php @@ -23,12 +23,6 @@ use Symfony\Component\HttpFoundation\Response; */ class phpbb_controller_helper { - /** - * Style object - * @var phpbb_style - */ - protected $style; - /** * Template object * @var phpbb_template @@ -56,36 +50,19 @@ class phpbb_controller_helper /** * Constructor * - * @param phpbb_style $style Style object * @param phpbb_template $template Template object * @param phpbb_user $user User object * @param string $phpbb_root_path phpBB root path * @param string $php_ext PHP extension */ - public function __construct(phpbb_style $style, phpbb_template $template, phpbb_user $user, $phpbb_root_path, $php_ext) + public function __construct(phpbb_template $template, phpbb_user $user, $phpbb_root_path, $php_ext) { - $this->style = $style; $this->template = $template; $this->user = $user; $this->phpbb_root_path = $phpbb_root_path; $this->php_ext = $php_ext; } - /** - * Set style location based on (current) user's chosen style. - * - * @param array $style_directories The directories to add style paths for - * E.g. array('ext/foo/bar/styles', 'styles') - * Default: array('styles') (phpBB's style directory) - * @return phpbb_controller_helper $this - */ - public function set_style($style_base_directory = array('styles')) - { - $this->style->set_style($style_base_directory); - - return $this; - } - /** * Automate setting up the page and creating the response object. * diff --git a/tests/controller/helper_url_test.php b/tests/controller/helper_url_test.php index 3206460caf..6686b77e8f 100644 --- a/tests/controller/helper_url_test.php +++ b/tests/controller/helper_url_test.php @@ -55,7 +55,7 @@ class phpbb_controller_helper_url_test extends phpbb_test_case $this->style_provider = new phpbb_style_path_provider(); $this->style = new phpbb_style($phpbb_root_path, $phpEx, new phpbb_config(array()), $this->user, $this->style_resource_locator, $this->style_provider, $this->template); - $helper = new phpbb_controller_helper($this->style, $this->template, $this->user, '', 'php'); + $helper = new phpbb_controller_helper($this->template, $this->user, '', 'php'); $this->assertEquals($helper->url($route, $params, $is_amp, $session_id), $expected); } } From 05984be2c002133d1dd7f546e4238749b275f9f6 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Fri, 5 Jul 2013 12:47:50 -0500 Subject: [PATCH 2035/2494] [feature/twig] Fix S_NUM_ROWS assignment PHPBB3-11598 --- phpBB/includes/template/context.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/template/context.php b/phpBB/includes/template/context.php index e3ad6be46c..c5ce7422b9 100644 --- a/phpBB/includes/template/context.php +++ b/phpBB/includes/template/context.php @@ -165,7 +165,7 @@ class phpbb_template_context // Set S_NUM_ROWS foreach ($str[$blocks[$blockcount]] as &$mod_block) { - $mod_block['S_NUM_ROWS'] = $blockcount; + $mod_block['S_NUM_ROWS'] = sizeof($str[$blocks[$blockcount]]); } } else From 9ac61565fdb0fd3464b9c974b506f084f24e0bbd Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Fri, 5 Jul 2013 12:48:02 -0500 Subject: [PATCH 2036/2494] [feature/twig] Add template tests for S_NUM_ROWS and S_BLOCK_NAME PHPBB3-11598 --- tests/template/template_test.php | 33 ++++++++++++++++++++++- tests/template/templates/loop_nested.html | 4 +-- 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/tests/template/template_test.php b/tests/template/template_test.php index b7c3a08512..d99e91bae4 100644 --- a/tests/template/template_test.php +++ b/tests/template/template_test.php @@ -516,4 +516,35 @@ EOT $this->template->alter_block_array($alter_block, $vararray, $key, $mode); $this->assertEquals(str_replace(array("\n", "\r", "\t"), '', $expect), str_replace(array("\n", "\r", "\t"), '', $this->display('test')), $description); } -} \ No newline at end of file + + public function test_more_alter_block_array() + { + $this->template->set_filenames(array('test' => 'loop_nested.html')); + + $this->template->assign_var('TEST_MORE', true); + + // @todo Change this + $this->template->assign_block_vars('outer', array()); + $this->template->assign_block_vars('outer.middle', array()); + $this->template->assign_block_vars('outer', array()); + $this->template->assign_block_vars('outer.middle', array()); + $this->template->assign_block_vars('outer.middle', array()); + $this->template->assign_block_vars('outer', array()); + $this->template->assign_block_vars('outer.middle', array()); + $this->template->assign_block_vars('outer.middle', array()); + $this->template->assign_block_vars('outer.middle', array()); + + $expect = 'outer - 0[outer|3]middle - 0[middle|1]outer - 1[outer|3]middle - 0[middle|2]middle - 1[middle|2]outer - 2[outer|3]middle - 0[middle|3]middle - 1[middle|3]middle - 2[middle|3]'; + $this->assertEquals($expect, str_replace(array("\n", "\r", "\t"), '', $this->display('test')), 'Ensuring template is built correctly before modification'); + + $this->template->alter_block_array('outer', array()); + + $expect = 'outer - 0[outer|4]outer - 1[outer|4]middle - 0[middle|1]outer - 2[outer|4]middle - 0[middle|2]middle - 1[middle|2]outer - 3[outer|4]middle - 0[middle|3]middle - 1[middle|3]middle - 2[middle|3]'; + $this->assertEquals($expect, str_replace(array("\n", "\r", "\t"), '', $this->display('test')), 'Ensuring S_NUM_ROWS is correct after insertion'); + + $this->template->alter_block_array('outer', array('VARIABLE' => 'test'), 2, 'change'); + + $expect = 'outer - 0[outer|4]outer - 1[outer|4]middle - 0[middle|1]outer - 2 - test[outer|4]middle - 0[middle|2]middle - 1[middle|2]outer - 3[outer|4]middle - 0[middle|3]middle - 1[middle|3]middle - 2[middle|3]'; + $this->assertEquals($expect, str_replace(array("\n", "\r", "\t"), '', $this->display('test')), 'Ensuring S_NUM_ROWS is correct after modification'); + } +} diff --git a/tests/template/templates/loop_nested.html b/tests/template/templates/loop_nested.html index 3b5ffa5cac..cf099ecc15 100644 --- a/tests/template/templates/loop_nested.html +++ b/tests/template/templates/loop_nested.html @@ -1,6 +1,6 @@ -outer - {outer.S_ROW_COUNT} - {outer.VARIABLE} +outer - {outer.S_ROW_COUNT} - {outer.VARIABLE}[{outer.S_BLOCK_NAME}|{outer.S_NUM_ROWS}] -middle - {outer.middle.S_ROW_COUNT} - {outer.middle.VARIABLE} +middle - {outer.middle.S_ROW_COUNT} - {outer.middle.VARIABLE}[{outer.middle.S_BLOCK_NAME}|{outer.middle.S_NUM_ROWS}] From 99ddbe1adc8dad125fa996f1f568bdcfa2b80d95 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Fri, 5 Jul 2013 12:55:32 -0500 Subject: [PATCH 2037/2494] [feature/twig] Can't use typehint here, causes tests to fail PHPBB3-11598 --- phpBB/includes/template/twig/extension.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/template/twig/extension.php b/phpBB/includes/template/twig/extension.php index 6b066f1bd3..c4d36050f9 100644 --- a/phpBB/includes/template/twig/extension.php +++ b/phpBB/includes/template/twig/extension.php @@ -30,7 +30,7 @@ class phpbb_template_twig_extension extends Twig_Extension * @param phpbb_user $user * @return phpbb_template_twig_extension */ - public function __construct(phpbb_template_context $context, phpbb_user $user) + public function __construct(phpbb_template_context $context, $user) { $this->context = $context; $this->user = $user; From c5c34ff831faf96368d34012dc65bdb9451227aa Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Fri, 5 Jul 2013 13:10:35 -0500 Subject: [PATCH 2038/2494] [feature/twig] Add check for defined IN_PHPBB in all new Twig related files PHPBB3-11598 --- phpBB/includes/template/twig/node/define.php | 9 +++++++++ phpBB/includes/template/twig/node/event.php | 9 +++++++++ .../template/twig/node/expression/binary/equalequal.php | 9 +++++++++ .../twig/node/expression/binary/notequalequal.php | 9 +++++++++ phpBB/includes/template/twig/node/include.php | 9 +++++++++ phpBB/includes/template/twig/node/includejs.php | 9 +++++++++ phpBB/includes/template/twig/node/includephp.php | 9 +++++++++ phpBB/includes/template/twig/node/php.php | 9 +++++++++ phpBB/includes/template/twig/tokenparser/define.php | 9 +++++++++ phpBB/includes/template/twig/tokenparser/event.php | 9 +++++++++ phpBB/includes/template/twig/tokenparser/if.php | 9 +++++++++ phpBB/includes/template/twig/tokenparser/include.php | 9 +++++++++ phpBB/includes/template/twig/tokenparser/includejs.php | 9 +++++++++ phpBB/includes/template/twig/tokenparser/includephp.php | 9 +++++++++ phpBB/includes/template/twig/tokenparser/php.php | 9 +++++++++ 15 files changed, 135 insertions(+) diff --git a/phpBB/includes/template/twig/node/define.php b/phpBB/includes/template/twig/node/define.php index 499bbdc518..fcb19cc773 100644 --- a/phpBB/includes/template/twig/node/define.php +++ b/phpBB/includes/template/twig/node/define.php @@ -7,6 +7,15 @@ * */ +/** +* @ignore +*/ +if (!defined('IN_PHPBB')) +{ + exit; +} + + class phpbb_template_twig_node_define extends Twig_Node { public function __construct($capture, Twig_NodeInterface $name, Twig_NodeInterface $value, $lineno, $tag = null) diff --git a/phpBB/includes/template/twig/node/event.php b/phpBB/includes/template/twig/node/event.php index 6de270e19c..984ba35244 100644 --- a/phpBB/includes/template/twig/node/event.php +++ b/phpBB/includes/template/twig/node/event.php @@ -7,6 +7,15 @@ * */ +/** +* @ignore +*/ +if (!defined('IN_PHPBB')) +{ + exit; +} + + class phpbb_template_twig_node_event extends Twig_Node { /** @var Twig_Environment */ diff --git a/phpBB/includes/template/twig/node/expression/binary/equalequal.php b/phpBB/includes/template/twig/node/expression/binary/equalequal.php index 054f63ecf9..8ec2069114 100644 --- a/phpBB/includes/template/twig/node/expression/binary/equalequal.php +++ b/phpBB/includes/template/twig/node/expression/binary/equalequal.php @@ -7,6 +7,15 @@ * */ +/** +* @ignore +*/ +if (!defined('IN_PHPBB')) +{ + exit; +} + + class phpbb_template_twig_node_expression_binary_equalequal extends Twig_Node_Expression_Binary { public function operator(Twig_Compiler $compiler) diff --git a/phpBB/includes/template/twig/node/expression/binary/notequalequal.php b/phpBB/includes/template/twig/node/expression/binary/notequalequal.php index d8a1c411cf..96f32c502e 100644 --- a/phpBB/includes/template/twig/node/expression/binary/notequalequal.php +++ b/phpBB/includes/template/twig/node/expression/binary/notequalequal.php @@ -7,6 +7,15 @@ * */ +/** +* @ignore +*/ +if (!defined('IN_PHPBB')) +{ + exit; +} + + class phpbb_template_twig_node_expression_binary_notequalequal extends Twig_Node_Expression_Binary { public function operator(Twig_Compiler $compiler) diff --git a/phpBB/includes/template/twig/node/include.php b/phpBB/includes/template/twig/node/include.php index a614cbe20f..5c6ae1bbcf 100644 --- a/phpBB/includes/template/twig/node/include.php +++ b/phpBB/includes/template/twig/node/include.php @@ -7,6 +7,15 @@ * */ +/** +* @ignore +*/ +if (!defined('IN_PHPBB')) +{ + exit; +} + + class phpbb_template_twig_node_include extends Twig_Node_Include { /** diff --git a/phpBB/includes/template/twig/node/includejs.php b/phpBB/includes/template/twig/node/includejs.php index 6d0d67c6c9..943eb89ace 100644 --- a/phpBB/includes/template/twig/node/includejs.php +++ b/phpBB/includes/template/twig/node/includejs.php @@ -7,6 +7,15 @@ * */ +/** +* @ignore +*/ +if (!defined('IN_PHPBB')) +{ + exit; +} + + class phpbb_template_twig_node_includejs extends Twig_Node { /** @var Twig_Environment */ diff --git a/phpBB/includes/template/twig/node/includephp.php b/phpBB/includes/template/twig/node/includephp.php index b5bb2ee9c9..dbe54f0e1a 100644 --- a/phpBB/includes/template/twig/node/includephp.php +++ b/phpBB/includes/template/twig/node/includephp.php @@ -7,6 +7,15 @@ * */ +/** +* @ignore +*/ +if (!defined('IN_PHPBB')) +{ + exit; +} + + class phpbb_template_twig_node_includephp extends Twig_Node { /** @var Twig_Environment */ diff --git a/phpBB/includes/template/twig/node/php.php b/phpBB/includes/template/twig/node/php.php index ebf4947e48..c11539ea7f 100644 --- a/phpBB/includes/template/twig/node/php.php +++ b/phpBB/includes/template/twig/node/php.php @@ -7,6 +7,15 @@ * */ +/** +* @ignore +*/ +if (!defined('IN_PHPBB')) +{ + exit; +} + + class phpbb_template_twig_node_php extends Twig_Node { /** @var Twig_Environment */ diff --git a/phpBB/includes/template/twig/tokenparser/define.php b/phpBB/includes/template/twig/tokenparser/define.php index ed77699b77..4ea15388c4 100644 --- a/phpBB/includes/template/twig/tokenparser/define.php +++ b/phpBB/includes/template/twig/tokenparser/define.php @@ -7,6 +7,15 @@ * */ +/** +* @ignore +*/ +if (!defined('IN_PHPBB')) +{ + exit; +} + + class phpbb_template_twig_tokenparser_define extends Twig_TokenParser { /** diff --git a/phpBB/includes/template/twig/tokenparser/event.php b/phpBB/includes/template/twig/tokenparser/event.php index 2a6d6b6457..e4dddd6dcc 100644 --- a/phpBB/includes/template/twig/tokenparser/event.php +++ b/phpBB/includes/template/twig/tokenparser/event.php @@ -7,6 +7,15 @@ * */ +/** +* @ignore +*/ +if (!defined('IN_PHPBB')) +{ + exit; +} + + class phpbb_template_twig_tokenparser_event extends Twig_TokenParser { /** diff --git a/phpBB/includes/template/twig/tokenparser/if.php b/phpBB/includes/template/twig/tokenparser/if.php index 939d679030..77881ad5f0 100644 --- a/phpBB/includes/template/twig/tokenparser/if.php +++ b/phpBB/includes/template/twig/tokenparser/if.php @@ -7,6 +7,15 @@ * */ +/** +* @ignore +*/ +if (!defined('IN_PHPBB')) +{ + exit; +} + + class phpbb_template_twig_tokenparser_if extends Twig_TokenParser_If { /** diff --git a/phpBB/includes/template/twig/tokenparser/include.php b/phpBB/includes/template/twig/tokenparser/include.php index 5b5105d23e..520f9fd1a0 100644 --- a/phpBB/includes/template/twig/tokenparser/include.php +++ b/phpBB/includes/template/twig/tokenparser/include.php @@ -7,6 +7,15 @@ * */ +/** +* @ignore +*/ +if (!defined('IN_PHPBB')) +{ + exit; +} + + class phpbb_template_twig_tokenparser_include extends Twig_TokenParser_Include { /** diff --git a/phpBB/includes/template/twig/tokenparser/includejs.php b/phpBB/includes/template/twig/tokenparser/includejs.php index 962d01ac45..b02b2f89ba 100644 --- a/phpBB/includes/template/twig/tokenparser/includejs.php +++ b/phpBB/includes/template/twig/tokenparser/includejs.php @@ -7,6 +7,15 @@ * */ +/** +* @ignore +*/ +if (!defined('IN_PHPBB')) +{ + exit; +} + + class phpbb_template_twig_tokenparser_includejs extends Twig_TokenParser { /** diff --git a/phpBB/includes/template/twig/tokenparser/includephp.php b/phpBB/includes/template/twig/tokenparser/includephp.php index 57d804183b..13fe6de8a6 100644 --- a/phpBB/includes/template/twig/tokenparser/includephp.php +++ b/phpBB/includes/template/twig/tokenparser/includephp.php @@ -7,6 +7,15 @@ * */ +/** +* @ignore +*/ +if (!defined('IN_PHPBB')) +{ + exit; +} + + class phpbb_template_twig_tokenparser_includephp extends Twig_TokenParser { /** diff --git a/phpBB/includes/template/twig/tokenparser/php.php b/phpBB/includes/template/twig/tokenparser/php.php index 62e1c4fdcd..197980a59a 100644 --- a/phpBB/includes/template/twig/tokenparser/php.php +++ b/phpBB/includes/template/twig/tokenparser/php.php @@ -7,6 +7,15 @@ * */ +/** +* @ignore +*/ +if (!defined('IN_PHPBB')) +{ + exit; +} + + class phpbb_template_twig_tokenparser_php extends Twig_TokenParser { /** From 0ffbdc80d1eafdcbdc6e2aa4c82fa7e081c0a502 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Fri, 5 Jul 2013 13:15:10 -0500 Subject: [PATCH 2039/2494] [feature/twig] context_recursive_loop_builder isn't used anymore, removing it PHPBB3-11598 --- phpBB/includes/template/twig/environment.php | 22 -------------------- 1 file changed, 22 deletions(-) diff --git a/phpBB/includes/template/twig/environment.php b/phpBB/includes/template/twig/environment.php index acb97cfad2..b60cd72325 100644 --- a/phpBB/includes/template/twig/environment.php +++ b/phpBB/includes/template/twig/environment.php @@ -137,26 +137,4 @@ class phpbb_template_twig_environment extends Twig_Environment return parent::loadTemplate($name, $index); } } - - /** - * Recursive helper to set variables into $context so that Twig can properly fetch them for display - * - * @param array $data Data to set at the end of the chain - * @param array $blocks Array of blocks to loop into still - * @param mixed $current_location Current location in $context (recursive!) - * @return null - */ - public function context_recursive_loop_builder($data, $blocks, &$current_location) - { - $block = array_shift($blocks); - - if (empty($blocks)) - { - $current_location[$block] = $data; - } - else - { - $this->context_recursive_loop_builder($data, $blocks, $current_location[$block]); - } - } } From 8d11a147f5ab05443b243559f248e7e52e2e9faf Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Fri, 5 Jul 2013 14:10:57 -0500 Subject: [PATCH 2040/2494] [feature/twig] Use Twig mask for IF statements instead of our own tokenparser PHPBB3-11598 --- phpBB/includes/template/twig/extension.php | 1 - phpBB/includes/template/twig/lexer.php | 8 +- .../includes/template/twig/tokenparser/if.php | 87 ------------------- 3 files changed, 6 insertions(+), 90 deletions(-) delete mode 100644 phpBB/includes/template/twig/tokenparser/if.php diff --git a/phpBB/includes/template/twig/extension.php b/phpBB/includes/template/twig/extension.php index c4d36050f9..5ffc45e75a 100644 --- a/phpBB/includes/template/twig/extension.php +++ b/phpBB/includes/template/twig/extension.php @@ -54,7 +54,6 @@ class phpbb_template_twig_extension extends Twig_Extension public function getTokenParsers() { return array( - new phpbb_template_twig_tokenparser_if, new phpbb_template_twig_tokenparser_define, new phpbb_template_twig_tokenparser_include, new phpbb_template_twig_tokenparser_includejs, diff --git a/phpBB/includes/template/twig/lexer.php b/phpBB/includes/template/twig/lexer.php index 394c3077a6..5f76c44481 100644 --- a/phpBB/includes/template/twig/lexer.php +++ b/phpBB/includes/template/twig/lexer.php @@ -24,12 +24,12 @@ class phpbb_template_twig_lexer extends Twig_Lexer $phpbb_tags = array( /*'BEGIN', 'BEGINELSE', - 'END',*/ + 'END', 'IF', 'ELSE', 'ELSEIF', 'ENDIF', - /*'DEFINE', + 'DEFINE', 'UNDEFINE',*/ 'ENDDEFINE', 'INCLUDE', @@ -44,6 +44,10 @@ class phpbb_template_twig_lexer extends Twig_Lexer $twig_tags = array( 'autoescape', 'endautoescape', + 'if', + 'elseif', + 'else', + 'endif', 'block', 'endblock', 'use', diff --git a/phpBB/includes/template/twig/tokenparser/if.php b/phpBB/includes/template/twig/tokenparser/if.php deleted file mode 100644 index 77881ad5f0..0000000000 --- a/phpBB/includes/template/twig/tokenparser/if.php +++ /dev/null @@ -1,87 +0,0 @@ -getLine(); - $expr = $this->parser->getExpressionParser()->parseExpression(); - $stream = $this->parser->getStream(); - $stream->expect(Twig_Token::BLOCK_END_TYPE); - $body = $this->parser->subparse(array($this, 'decideIfFork')); - $tests = array($expr, $body); - $else = null; - - $end = false; - while (!$end) { - switch ($stream->next()->getValue()) { - case 'ELSE': - $stream->expect(Twig_Token::BLOCK_END_TYPE); - $else = $this->parser->subparse(array($this, 'decideIfEnd')); - break; - - case 'ELSEIF': - $expr = $this->parser->getExpressionParser()->parseExpression(); - $stream->expect(Twig_Token::BLOCK_END_TYPE); - $body = $this->parser->subparse(array($this, 'decideIfFork')); - $tests[] = $expr; - $tests[] = $body; - break; - - case 'ENDIF': - $end = true; - break; - - default: - throw new Twig_Error_Syntax(sprintf('Unexpected end of template. Twig was looking for the following tags "ELSE", "ELSEIF", or "ENDIF" to close the "IF" block started at line %d)', $lineno), $stream->getCurrent()->getLine(), $stream->getFilename()); - } - } - - $stream->expect(Twig_Token::BLOCK_END_TYPE); - - return new Twig_Node_If(new Twig_Node($tests), $else, $lineno, $this->getTag()); - } - - public function decideIfFork(Twig_Token $token) - { - return $token->test(array('ELSEIF', 'ELSE', 'ENDIF')); - } - - public function decideIfEnd(Twig_Token $token) - { - return $token->test(array('ENDIF')); - } - - /** - * Gets the tag name associated with this token parser. - * - * @return string The tag name - */ - public function getTag() - { - return 'IF'; - } -} From 921d44aa4dfa307eb3b7e4f24befabb07e727812 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Fri, 5 Jul 2013 14:17:46 -0500 Subject: [PATCH 2041/2494] [feature/twig] Put $SCRIPTS below overall_footer_after, use includejs for core Moved below overall_footer_after so events can add JS files in that event. PHPBB3-11598 --- phpBB/styles/prosilver/template/overall_footer.html | 4 +++- phpBB/styles/subsilver2/template/overall_footer.html | 6 ++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/phpBB/styles/prosilver/template/overall_footer.html b/phpBB/styles/prosilver/template/overall_footer.html index 5c88209ad8..eef9f53409 100644 --- a/phpBB/styles/prosilver/template/overall_footer.html +++ b/phpBB/styles/prosilver/template/overall_footer.html @@ -56,8 +56,10 @@ -{$SCRIPTS} + +{$SCRIPTS} + diff --git a/phpBB/styles/subsilver2/template/overall_footer.html b/phpBB/styles/subsilver2/template/overall_footer.html index 2d794d9f71..d2b30c22a0 100644 --- a/phpBB/styles/subsilver2/template/overall_footer.html +++ b/phpBB/styles/subsilver2/template/overall_footer.html @@ -13,9 +13,11 @@ - -{$SCRIPTS} + + +{$SCRIPTS} + From 1d9d22cc7676fac14bfe4a5b67537ccfb4f1849d Mon Sep 17 00:00:00 2001 From: Andy Chase Date: Wed, 26 Jun 2013 12:43:37 -0700 Subject: [PATCH 2042/2494] [ticket/11620] Add testable facade for sessions.php Since many functions in session.php have global variables inside the function, this exposes those functions through a testable facade that uses testable_factory's mock global variables to modify global variables used in the functions. This is using the facade pattern to provide a testable "front" to the functions in sessions.php. PHPBB3-11620 --- tests/session/testable_facade.php | 49 +++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 tests/session/testable_facade.php diff --git a/tests/session/testable_facade.php b/tests/session/testable_facade.php new file mode 100644 index 0000000000..d4c03ec8d5 --- /dev/null +++ b/tests/session/testable_facade.php @@ -0,0 +1,49 @@ +get_session($db); + global $request; + $request->overwrite('PHP_SELF', $php_self, phpbb_request_interface::SERVER); + $request->overwrite('QUERY_STRING', $query_string, phpbb_request_interface::SERVER); + $request->overwrite('REQUEST_URI', $request_uri, phpbb_request_interface::SERVER); + return phpbb_session::extract_current_page($root_path, phpbb_request_interface::SERVER); + } + + // [To be completed] + // public static function extract_current_hostname() {} + // public static function session_begin($update_session_page = true) {} + // public static function session_create($user_id = false, $set_admin = false, $persist_login = false, $viewonline = true) {} + // public static function session_kill($new_session = true) {} + // public static function session_gc() {} + // public static function set_cookie($name, $cookiedata, $cookietime) {} + // public static function check_ban($user_id = false, $user_ips = false, $user_email = false, $return = false) {} + // public static function check_dnsbl($mode, $ip = false) {} + // public static function set_login_key($user_id = false, $key = false, $user_ip = false) {} + // public static function reset_login_keys($user_id = false) {} + // public static function validate_referer($check_script_path = false) {} + // public static function update_session($session_data, $session_id = null) {} + // public static function unset_admin() {} +} + From 19a348e35990511186fc8e987b28b5f8b34c6650 Mon Sep 17 00:00:00 2001 From: Andy Chase Date: Wed, 26 Jun 2013 12:44:14 -0700 Subject: [PATCH 2043/2494] [ticket/11620] Add test for test_extract_current_page PHPBB3-11620 --- tests/session/class_functions_test.php | 49 ++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 tests/session/class_functions_test.php diff --git a/tests/session/class_functions_test.php b/tests/session/class_functions_test.php new file mode 100644 index 0000000000..c4ae5628f1 --- /dev/null +++ b/tests/session/class_functions_test.php @@ -0,0 +1,49 @@ +createXMLDataSet(dirname(__FILE__).'/fixtures/sessions_empty.xml'); + } + + public function setUp() + { + $this->session_factory = new phpbb_session_testable_factory; + $this->db = $this->new_dbal(); + } + + function test_extract_current_page() + { + $expected_fields = array( + 'page_name' => "index.php", + 'script_path' => "/phpBB/" + ); + + $output = phpbb_session_testable_facade::extract_current_page( + $this->db, + $this->session_factory, + /* Root Path */ "./", + /* PHP Self */ "/phpBB/index.php", + /* Query String*/ "", + /* Request URI */ "/phpBB/" + ); + + foreach($expected_fields as $field => $expected_value) + { + $this->assertSame($expected_value, $output[$field]); + } + } +} From e1d957c3eed77ffb02eaf2c9422f09e71b12f938 Mon Sep 17 00:00:00 2001 From: Andy Chase Date: Wed, 26 Jun 2013 12:49:05 -0700 Subject: [PATCH 2044/2494] [ticket/11620] Remove accidental argument from testable_facade. PHPBB3-11620 --- tests/session/testable_facade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/session/testable_facade.php b/tests/session/testable_facade.php index d4c03ec8d5..f85332c94a 100644 --- a/tests/session/testable_facade.php +++ b/tests/session/testable_facade.php @@ -28,7 +28,7 @@ class phpbb_session_testable_facade $request->overwrite('PHP_SELF', $php_self, phpbb_request_interface::SERVER); $request->overwrite('QUERY_STRING', $query_string, phpbb_request_interface::SERVER); $request->overwrite('REQUEST_URI', $request_uri, phpbb_request_interface::SERVER); - return phpbb_session::extract_current_page($root_path, phpbb_request_interface::SERVER); + return phpbb_session::extract_current_page($root_path); } // [To be completed] From 9f156e995468d322a9b90f188cb31df059b03d82 Mon Sep 17 00:00:00 2001 From: Andy Chase Date: Thu, 27 Jun 2013 15:56:19 -0700 Subject: [PATCH 2045/2494] [ticket/11620] Rename class_functions_test -> extract_page_test Renaming this file because it is going to contain a large data provider, so I'd rather split this test out. PHPBB3-11620 --- .../session/{class_functions_test.php => extract_page_test.php} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename tests/session/{class_functions_test.php => extract_page_test.php} (93%) diff --git a/tests/session/class_functions_test.php b/tests/session/extract_page_test.php similarity index 93% rename from tests/session/class_functions_test.php rename to tests/session/extract_page_test.php index c4ae5628f1..fca7763bc3 100644 --- a/tests/session/class_functions_test.php +++ b/tests/session/extract_page_test.php @@ -9,7 +9,7 @@ require_once dirname(__FILE__) . '/testable_facade.php'; -class phpbb_session_class_functions_test extends phpbb_database_test_case +class phpbb_session_extract_page_test extends phpbb_database_test_case { public $session_factory; public $db; From 7fd03abcab531d3e989753492ab0cce78549c1a3 Mon Sep 17 00:00:00 2001 From: Andy Chase Date: Thu, 27 Jun 2013 15:57:58 -0700 Subject: [PATCH 2046/2494] [ticket/11620] Add data provider to extract_page These test cases were taken from a live session, more test cases should be added to test specific functionality in this function. PHPBB3-11620 --- tests/session/extract_page_test.php | 105 ++++++++++++++++++++++++---- 1 file changed, 91 insertions(+), 14 deletions(-) diff --git a/tests/session/extract_page_test.php b/tests/session/extract_page_test.php index fca7763bc3..24fcb98164 100644 --- a/tests/session/extract_page_test.php +++ b/tests/session/extract_page_test.php @@ -14,6 +14,88 @@ class phpbb_session_extract_page_test extends phpbb_database_test_case public $session_factory; public $db; + static public function extract_current_page_data() + { + return array( + array( + './', + '/phpBB/index.php', + '', + '/phpBB/', + array( + 'page_name' => 'index.php', + 'page_dir' => '', + 'query_string' => '', + 'script_path' => '/phpBB/', + 'root_script_path' => '/phpBB/', + 'page' => 'index.php', + 'forum' => 0 + ) + ) , + array( + './', + '/phpBB/ucp.php', + 'mode=login', + '/phpBB/ucp.php?mode=login', + array( + 'page_name' => 'ucp.php', + 'page_dir' => '', + 'query_string' => 'mode=login', + 'script_path' => '/phpBB/', + 'root_script_path' => '/phpBB/', + 'page' => 'ucp.php?mode=login', + 'forum' => 0 + ) + ) , + array( + './', + '/phpBB/ucp.php', + 'mode=register', + '/phpBB/ucp.php?mode=register', + array( + 'page_name' => 'ucp.php', + 'page_dir' => '', + 'query_string' => 'mode=register', + 'script_path' => '/phpBB/', + 'root_script_path' => '/phpBB/', + 'page' => 'ucp.php?mode=register', + 'forum' => 0 + ) + ) , + array( + './', + '/phpBB/ucp.php', + 'mode=register', + '/phpBB/ucp.php?mode=register', + array( + 'page_name' => 'ucp.php', + 'page_dir' => '', + 'query_string' => 'mode=register', + 'script_path' => '/phpBB/', + 'root_script_path' => '/phpBB/', + 'page' => 'ucp.php?mode=register', + 'forum' => 0 + ) + ) , + array( + './../', + '/phpBB/adm/index.php', + 'sid=e7215d958cdd41a6fc13509bebe53e42', + '/phpBB/adm/index.php?sid=e7215d958cdd41a6fc13509bebe53e42', + array( + 'page_name' => 'index.php', + //'page_dir' => 'adm', + // ^-- Ignored because .. returns different directory in live vs testing + 'query_string' => '', + 'script_path' => '/phpBB/adm/', + 'root_script_path' => '/phpBB/', + //'page' => 'adm/index.php', + 'forum' => 0 + ) + ) + ); + } + public function getDataSet() { return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/sessions_empty.xml'); @@ -25,25 +107,20 @@ class phpbb_session_extract_page_test extends phpbb_database_test_case $this->db = $this->new_dbal(); } - function test_extract_current_page() + /** @dataProvider extract_current_page_data */ + function test_extract_current_page($root_path, $php_self, $query_string, $request_uri, $expected) { - $expected_fields = array( - 'page_name' => "index.php", - 'script_path' => "/phpBB/" - ); - $output = phpbb_session_testable_facade::extract_current_page( $this->db, $this->session_factory, - /* Root Path */ "./", - /* PHP Self */ "/phpBB/index.php", - /* Query String*/ "", - /* Request URI */ "/phpBB/" + $root_path, + $php_self, + $query_string, + $request_uri ); - foreach($expected_fields as $field => $expected_value) - { - $this->assertSame($expected_value, $output[$field]); - } + // This compares the result of the output. + // Any keys that are not in the expected array are overwritten by the output (aka not checked). + $this->assert_array_content_equals(array_merge($output, $expected), $output); } } From b8d9d7b79f98093a5870db2e3b60663ed5069d39 Mon Sep 17 00:00:00 2001 From: Andy Chase Date: Mon, 1 Jul 2013 00:11:44 -0700 Subject: [PATCH 2047/2494] [ticket/11620] Add extract_current_hostname Add a tests for extracting the current hostname from session. PHPBB3-11620 --- tests/session/extract_hostname_test.php | 58 +++++++++++++++++++++++++ tests/session/testable_facade.php | 11 ++++- 2 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 tests/session/extract_hostname_test.php diff --git a/tests/session/extract_hostname_test.php b/tests/session/extract_hostname_test.php new file mode 100644 index 0000000000..a126626ae3 --- /dev/null +++ b/tests/session/extract_hostname_test.php @@ -0,0 +1,58 @@ +createXMLDataSet(dirname(__FILE__).'/fixtures/sessions_empty.xml'); + } + + public function setUp() + { + $this->session_factory = new phpbb_session_testable_factory; + $this->db = $this->new_dbal(); + } + + static public function extract_current_hostname_data() + { + return array ( + // [Input] $host, $server_name_config, $cookie_domain_config, [Expected] $output + // If host is ip use that ipv4 + array("127.0.0.1", "skipped.org", "skipped.org", "127.0.0.1"), + // If no host but server name matches cookie_domain use that + array("", "example.org", "example.org", "example.org"), + // If there is a host uri use that + array("example.org", False, False, "example.org"), + // "best approach" guessing + array("", "example.org", False, "example.org"), + array("", False, "127.0.0.1", "127.0.0.1"), + array("", False, False, php_uname('n')), + ); + } + + /** @dataProvider extract_current_hostname_data */ + function test_extract_current_hostname($host, $server_name_config, $cookie_domain_config, $expected) + { + $output = phpbb_session_testable_facade::extract_current_hostname( + $this->db, + $this->session_factory, + $host, + $server_name_config, + $cookie_domain_config + ); + + $this->assertEquals($expected, $output); + } +} diff --git a/tests/session/testable_facade.php b/tests/session/testable_facade.php index f85332c94a..a4a3d63ed4 100644 --- a/tests/session/testable_facade.php +++ b/tests/session/testable_facade.php @@ -31,8 +31,17 @@ class phpbb_session_testable_facade return phpbb_session::extract_current_page($root_path); } + public static function extract_current_hostname($db, $session_factory, $host, $server_name_config, $cookie_domain_config) { + $session = $session_factory->get_session($db); + global $config, $request; + $config['server_name'] = $server_name_config; + $config['cookie_domain'] = $cookie_domain_config; + $request->overwrite('SERVER_NAME', $host, phpbb_request_interface::SERVER); + $request->overwrite('Host', $host, phpbb_request_interface::SERVER); + // Note: There is a php_uname fallthrough in this method that this function doesn't override + return $session->extract_current_hostname(); + } // [To be completed] - // public static function extract_current_hostname() {} // public static function session_begin($update_session_page = true) {} // public static function session_create($user_id = false, $set_admin = false, $persist_login = false, $viewonline = true) {} // public static function session_kill($new_session = true) {} From 71fbe74edea4ad2618fbd9161e83ccaabafea9ac Mon Sep 17 00:00:00 2001 From: Andy Chase Date: Mon, 1 Jul 2013 15:07:06 -0700 Subject: [PATCH 2048/2494] [ticket/11620] Fix quotes in extract_hostname_test PHPBB3-11620 --- tests/session/extract_hostname_test.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/session/extract_hostname_test.php b/tests/session/extract_hostname_test.php index a126626ae3..ae12a027f7 100644 --- a/tests/session/extract_hostname_test.php +++ b/tests/session/extract_hostname_test.php @@ -30,15 +30,15 @@ class phpbb_session_extract_hostname_test extends phpbb_database_test_case return array ( // [Input] $host, $server_name_config, $cookie_domain_config, [Expected] $output // If host is ip use that ipv4 - array("127.0.0.1", "skipped.org", "skipped.org", "127.0.0.1"), + array('127.0.0.1', 'skipped.org', 'skipped.org', '127.0.0.1'), // If no host but server name matches cookie_domain use that - array("", "example.org", "example.org", "example.org"), + array('', 'example.org', 'example.org', 'example.org'), // If there is a host uri use that - array("example.org", False, False, "example.org"), - // "best approach" guessing - array("", "example.org", False, "example.org"), - array("", False, "127.0.0.1", "127.0.0.1"), - array("", False, False, php_uname('n')), + array('example.org', false, false, 'example.org'), + // 'best approach' guessing + array('', 'example.org', false, 'example.org'), + array('', false, '127.0.0.1', '127.0.0.1'), + array('', false, false, php_uname('n')), ); } From e8facfc735ccc10fd106a169e2508b4c335a0e9e Mon Sep 17 00:00:00 2001 From: Andy Chase Date: Mon, 1 Jul 2013 15:09:13 -0700 Subject: [PATCH 2049/2494] [ticket/11620] Add commas in extract_page_test PHPBB3-11620 --- tests/session/extract_page_test.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/session/extract_page_test.php b/tests/session/extract_page_test.php index 24fcb98164..94ed96c6d2 100644 --- a/tests/session/extract_page_test.php +++ b/tests/session/extract_page_test.php @@ -29,7 +29,7 @@ class phpbb_session_extract_page_test extends phpbb_database_test_case 'script_path' => '/phpBB/', 'root_script_path' => '/phpBB/', 'page' => 'index.php', - 'forum' => 0 + 'forum' => 0, ) ) , array( @@ -44,7 +44,7 @@ class phpbb_session_extract_page_test extends phpbb_database_test_case 'script_path' => '/phpBB/', 'root_script_path' => '/phpBB/', 'page' => 'ucp.php?mode=login', - 'forum' => 0 + 'forum' => 0, ) ) , array( @@ -59,7 +59,7 @@ class phpbb_session_extract_page_test extends phpbb_database_test_case 'script_path' => '/phpBB/', 'root_script_path' => '/phpBB/', 'page' => 'ucp.php?mode=register', - 'forum' => 0 + 'forum' => 0, ) ) , array( @@ -74,7 +74,7 @@ class phpbb_session_extract_page_test extends phpbb_database_test_case 'script_path' => '/phpBB/', 'root_script_path' => '/phpBB/', 'page' => 'ucp.php?mode=register', - 'forum' => 0 + 'forum' => 0, ) ) , array( @@ -90,7 +90,7 @@ class phpbb_session_extract_page_test extends phpbb_database_test_case 'script_path' => '/phpBB/adm/', 'root_script_path' => '/phpBB/', //'page' => 'adm/index.php', - 'forum' => 0 + 'forum' => 0, ) ) ); From 2f92c903e7f42978e01d09287e93d572f5e302c9 Mon Sep 17 00:00:00 2001 From: Andy Chase Date: Mon, 1 Jul 2013 15:16:22 -0700 Subject: [PATCH 2050/2494] [ticket/11620] Make testable_facade non-static, expand. Make the class functions of testable_facade no longer static methods, but a class based one and expand the methods to be filled in, in later commits. PHPBB3-11620 --- tests/session/extract_hostname_test.php | 5 +- tests/session/extract_page_test.php | 7 +- tests/session/testable_facade.php | 145 ++++++++++++++++++++---- 3 files changed, 132 insertions(+), 25 deletions(-) diff --git a/tests/session/extract_hostname_test.php b/tests/session/extract_hostname_test.php index ae12a027f7..6978b5286f 100644 --- a/tests/session/extract_hostname_test.php +++ b/tests/session/extract_hostname_test.php @@ -13,6 +13,7 @@ class phpbb_session_extract_hostname_test extends phpbb_database_test_case { public $session_factory; public $db; + public $session_facade; public function getDataSet() { @@ -23,6 +24,8 @@ class phpbb_session_extract_hostname_test extends phpbb_database_test_case { $this->session_factory = new phpbb_session_testable_factory; $this->db = $this->new_dbal(); + $this->session_facade = + new phpbb_session_testable_facade($this->db, $this->session_factory); } static public function extract_current_hostname_data() @@ -45,7 +48,7 @@ class phpbb_session_extract_hostname_test extends phpbb_database_test_case /** @dataProvider extract_current_hostname_data */ function test_extract_current_hostname($host, $server_name_config, $cookie_domain_config, $expected) { - $output = phpbb_session_testable_facade::extract_current_hostname( + $output = $this->session_facade->extract_current_hostname( $this->db, $this->session_factory, $host, diff --git a/tests/session/extract_page_test.php b/tests/session/extract_page_test.php index 94ed96c6d2..f8883dc8c9 100644 --- a/tests/session/extract_page_test.php +++ b/tests/session/extract_page_test.php @@ -13,6 +13,7 @@ class phpbb_session_extract_page_test extends phpbb_database_test_case { public $session_factory; public $db; + public $session_facade; static public function extract_current_page_data() { @@ -105,14 +106,14 @@ class phpbb_session_extract_page_test extends phpbb_database_test_case { $this->session_factory = new phpbb_session_testable_factory; $this->db = $this->new_dbal(); + $this->session_facade = + new phpbb_session_testable_facade($this->db, $this->session_factory); } /** @dataProvider extract_current_page_data */ function test_extract_current_page($root_path, $php_self, $query_string, $request_uri, $expected) { - $output = phpbb_session_testable_facade::extract_current_page( - $this->db, - $this->session_factory, + $output = $this->session_facade->extract_current_page( $root_path, $php_self, $query_string, diff --git a/tests/session/testable_facade.php b/tests/session/testable_facade.php index a4a3d63ed4..6d2c1408c9 100644 --- a/tests/session/testable_facade.php +++ b/tests/session/testable_facade.php @@ -14,16 +14,32 @@ require_once dirname(__FILE__) . '/../../phpBB/includes/session.php'; * This class exists to expose session.php's functions in a more testable way. * * Since many functions in session.php have global variables inside the function, - * this exposes those functions through a testable facade that uses testable_factory's - * mock global variables to modify global variables used in the functions. + * this exposes those functions through a testable facade that uses + * testable_factory's mock global variables to modify global variables used in + * the functions. * - * This is using the facade pattern to provide a testable "front" to the functions in sessions.php. + * This is using the facade pattern to provide a testable "front" to the + * functions in sessions.php. * */ class phpbb_session_testable_facade { - public static function extract_current_page($db, $session_factory, $root_path, $php_self, $query_string, $request_uri) { - $session_factory->get_session($db); + var $db; + var $session_factory; + + function __construct($db, $session_factory) { + $this->db = $db; + $this->session_factory = $session_factory; + } + + function extract_current_page ( + $root_path, + $php_self, + $query_string, + $request_uri + ) + { + $this->session_factory->get_session($this->db); global $request; $request->overwrite('PHP_SELF', $php_self, phpbb_request_interface::SERVER); $request->overwrite('QUERY_STRING', $query_string, phpbb_request_interface::SERVER); @@ -31,28 +47,115 @@ class phpbb_session_testable_facade return phpbb_session::extract_current_page($root_path); } - public static function extract_current_hostname($db, $session_factory, $host, $server_name_config, $cookie_domain_config) { - $session = $session_factory->get_session($db); + function extract_current_hostname ( + $host, + $server_name_config, + $cookie_domain_config + ) + { + $session = $this->session_factory->get_session($this->db); global $config, $request; $config['server_name'] = $server_name_config; $config['cookie_domain'] = $cookie_domain_config; $request->overwrite('SERVER_NAME', $host, phpbb_request_interface::SERVER); $request->overwrite('Host', $host, phpbb_request_interface::SERVER); - // Note: There is a php_uname fallthrough in this method that this function doesn't override + // Note: There is a php_uname fallthrough in this method + // that this function doesn't override return $session->extract_current_hostname(); } - // [To be completed] - // public static function session_begin($update_session_page = true) {} - // public static function session_create($user_id = false, $set_admin = false, $persist_login = false, $viewonline = true) {} - // public static function session_kill($new_session = true) {} - // public static function session_gc() {} - // public static function set_cookie($name, $cookiedata, $cookietime) {} - // public static function check_ban($user_id = false, $user_ips = false, $user_email = false, $return = false) {} - // public static function check_dnsbl($mode, $ip = false) {} - // public static function set_login_key($user_id = false, $key = false, $user_ip = false) {} - // public static function reset_login_keys($user_id = false) {} - // public static function validate_referer($check_script_path = false) {} - // public static function update_session($session_data, $session_id = null) {} - // public static function unset_admin() {} + + + /** This function has a *lot* of dependencies, so instead of naming them all, + * just ask for overrides */ + function session_begin ( + $update_session_page = true, + $config_overrides = array(), + $request_overrides = array() + ) + { + $session = $this->session_factory->get_session($this->db); + global $config, $request; + $request->merge(phpbb_request_interface::SERVER, $request_overrides); + $config = array_merge($config, $config_overrides); + return $session->session_begin($update_session_page); + } + + function session_create ( + $user_id = false, + $set_admin = false, + $persist_login = false, + $viewonline = true, + $config_overrides = array(), + $request_overrides = array(), + $bot_overrides = array(), + $uri_sid = "" + ) + { + $session = $this->session_factory->get_session($this->db); + global $config, $request, $cache; + $request->merge(phpbb_request_interface::SERVER, $request_overrides); + $config = array_merge($config, $config_overrides); + // Bots + $cache->merge_cache_data(array('_bots' => $bot_overrides)); + // Uri sid + $_GET['sid'] = $uri_sid; + return $session->session_create($user_id, $set_admin, $persist_login, $viewonline); + } + + function session_kill($new_session = true) + { + $session = $this->session_factory->get_session($this->db); + global $config, $request; + + } + + function session_gc() + { + $session = $this->session_factory->get_session($this->db); + global $config, $request; + + } + + function set_cookie($name, $cookiedata, $cookietime) + { + $session = $this->session_factory->get_session($this->db); + global $config, $request; + + } + + function check_ban($user_id = false, $user_ips = false, $user_email = false, $return = false) + { + $session = $this->session_factory->get_session($this->db); + global $config, $request; + + } + + function check_dnsbl($mode, $ip = false) + { + $session = $this->session_factory->get_session($this->db); + global $config, $request; + + } + + function set_login_key($user_id = false, $key = false, $user_ip = false) + { + $session = $this->session_factory->get_session($this->db); + global $config, $request; + + } + + function reset_login_keys($user_id = false) + { + $session = $this->session_factory->get_session($this->db); + global $config, $request; + + } + + function validate_referer($check_script_path = false) + { + $session = $this->session_factory->get_session($this->db); + global $config, $request; + return $session->validate_referer($check_script_path); + } } From 17890a308bbecd295c6ebb92d55fc39e68aae34e Mon Sep 17 00:00:00 2001 From: Andy Chase Date: Mon, 1 Jul 2013 16:44:22 -0700 Subject: [PATCH 2051/2494] [ticket/11620] Add ipv6 test cases and remove extra arguments. PHPBB3-11620 --- tests/session/extract_hostname_test.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/session/extract_hostname_test.php b/tests/session/extract_hostname_test.php index 6978b5286f..cd71f82b17 100644 --- a/tests/session/extract_hostname_test.php +++ b/tests/session/extract_hostname_test.php @@ -32,8 +32,12 @@ class phpbb_session_extract_hostname_test extends phpbb_database_test_case { return array ( // [Input] $host, $server_name_config, $cookie_domain_config, [Expected] $output - // If host is ip use that ipv4 + // If host is ip use that + // ipv4 array('127.0.0.1', 'skipped.org', 'skipped.org', '127.0.0.1'), + // ipv6 + array('::1', 'skipped.org', 'skipped.org', ':'), + array('2002::3235:51f9', 'skipped.org', 'skipped.org', '2002::3235'), // If no host but server name matches cookie_domain use that array('', 'example.org', 'example.org', 'example.org'), // If there is a host uri use that @@ -49,8 +53,6 @@ class phpbb_session_extract_hostname_test extends phpbb_database_test_case function test_extract_current_hostname($host, $server_name_config, $cookie_domain_config, $expected) { $output = $this->session_facade->extract_current_hostname( - $this->db, - $this->session_factory, $host, $server_name_config, $cookie_domain_config From 30ebc03d143aaa7e3708b84b93b2e112351e70e5 Mon Sep 17 00:00:00 2001 From: Andy Chase Date: Wed, 3 Jul 2013 12:26:25 -0700 Subject: [PATCH 2052/2494] [ticket/11620] Remove unneeded functions from testable facade There are functions listed in testable facade that don't have a lot of dependencies, instead mostly just take the input and perform database functions on them. These can be tested without a testable facade function and so will be removed. PHPBB3-11620 --- tests/session/testable_facade.php | 49 ------------------------------- 1 file changed, 49 deletions(-) diff --git a/tests/session/testable_facade.php b/tests/session/testable_facade.php index 6d2c1408c9..02af73174f 100644 --- a/tests/session/testable_facade.php +++ b/tests/session/testable_facade.php @@ -102,55 +102,6 @@ class phpbb_session_testable_facade return $session->session_create($user_id, $set_admin, $persist_login, $viewonline); } - function session_kill($new_session = true) - { - $session = $this->session_factory->get_session($this->db); - global $config, $request; - - } - - function session_gc() - { - $session = $this->session_factory->get_session($this->db); - global $config, $request; - - } - - function set_cookie($name, $cookiedata, $cookietime) - { - $session = $this->session_factory->get_session($this->db); - global $config, $request; - - } - - function check_ban($user_id = false, $user_ips = false, $user_email = false, $return = false) - { - $session = $this->session_factory->get_session($this->db); - global $config, $request; - - } - - function check_dnsbl($mode, $ip = false) - { - $session = $this->session_factory->get_session($this->db); - global $config, $request; - - } - - function set_login_key($user_id = false, $key = false, $user_ip = false) - { - $session = $this->session_factory->get_session($this->db); - global $config, $request; - - } - - function reset_login_keys($user_id = false) - { - $session = $this->session_factory->get_session($this->db); - global $config, $request; - - } - function validate_referer($check_script_path = false) { $session = $this->session_factory->get_session($this->db); From 290533a14fbcf09caf40c88c30fc39b227f110f0 Mon Sep 17 00:00:00 2001 From: Andy Chase Date: Wed, 3 Jul 2013 12:28:37 -0700 Subject: [PATCH 2053/2494] [ticket/11620] Add validate_referrer test Add a test for the validate_referrer function. PHPBB3-11620 --- tests/session/testable_facade.php | 16 ++++- tests/session/validate_referrer_test.php | 80 ++++++++++++++++++++++++ 2 files changed, 95 insertions(+), 1 deletion(-) create mode 100644 tests/session/validate_referrer_test.php diff --git a/tests/session/testable_facade.php b/tests/session/testable_facade.php index 02af73174f..886c9b328a 100644 --- a/tests/session/testable_facade.php +++ b/tests/session/testable_facade.php @@ -102,10 +102,24 @@ class phpbb_session_testable_facade return $session->session_create($user_id, $set_admin, $persist_login, $viewonline); } - function validate_referer($check_script_path = false) + function validate_referer( + $check_script_path, + $referer, + $host, + $force_server_vars, + $server_port, + $server_name, + $root_script_path + ) { $session = $this->session_factory->get_session($this->db); global $config, $request; + $session->referer = $referer; + $session->page['root_script_path'] = $root_script_path; + $session->host = $host; + $config['force_server_vars'] = $force_server_vars; + $config['server_name'] = $server_name; + $request->overwrite('SERVER_PORT', $server_port, phpbb_request_interface::SERVER); return $session->validate_referer($check_script_path); } } diff --git a/tests/session/validate_referrer_test.php b/tests/session/validate_referrer_test.php new file mode 100644 index 0000000000..e5faf8a21f --- /dev/null +++ b/tests/session/validate_referrer_test.php @@ -0,0 +1,80 @@ +createXMLDataSet(dirname(__FILE__).'/fixtures/sessions_empty.xml'); + } + + public function setUp() + { + $this->session_factory = new phpbb_session_testable_factory; + $this->db = $this->new_dbal(); + $this->session_facade = + new phpbb_session_testable_facade($this->db, $this->session_factory); + } + + static function referrer_inputs() { + $ex = "example.org"; + $alt = "example.com"; + return array( + // checkpath referrer host forcevars port servername rootpath pass? + // 0 Referrer or host wasn't collected, therefore should validate + array(false, "", $ex, false, 80, $ex, "", true), + array(false, $ex, "", false, 80, $ex, "", true), + // 2 Referrer doesn't match host or server_name + array(false, $alt, $ex, yes, 80, $ex, "", false), + // 3 Everything should check out + array(false, $ex, $ex, false, 80, $ex, "", true), + // 4 Check Script Path + array(true, $ex, $ex, false, 80, $ex, "", true), + array(true, "$ex/foo", $ex, false, 80, $ex, "/foo", true), + array(true, "$ex/bar", $ex, false, 80, $ex, "/foo", false), + // 7 Port (This is not checked unless path is checked) + array(true, "$ex:80/foo", "$ex:80", false, 80, "$ex:80", "/foo", true), + array(true, "$ex:80/bar", "$ex:80", false, 80, "$ex:80", "/foo", false), + array(true, "$ex:79/foo", "$ex:81", false, 81, "$ex:81", "/foo", false), + ); + } + + /** @dataProvider referrer_inputs */ + function test_failing_referrer ( + $check_script_path, + $referrer, + $host, + $force_server_vars, + $server_port, + $server_name, + $root_script_path, + $pass_or_fail + ) + { + //Referrer needs http:// because it's going to get stripped in function. + $referrer = ($referrer? 'http://'.$referrer : ''); + $this->assertEquals( + $pass_or_fail, + $this->session_facade->validate_referer( + $check_script_path, + $referrer, + $host, + $force_server_vars, + $server_port, + $server_name, + $root_script_path + ), "referrer should" . ($pass_or_fail? "" : "n't") . " be validated"); + } +} From ab1c42babf5fcbc07637940bd50ba4b2d7edca81 Mon Sep 17 00:00:00 2001 From: Andy Chase Date: Wed, 3 Jul 2013 12:41:40 -0700 Subject: [PATCH 2054/2494] [ticket/11620] Add indentation, change quote style. indentation is probably more important than 80 characters per line apparently. Single quotes instead of double per coding guidelines. PHPBB3-11620 --- tests/session/validate_referrer_test.php | 34 ++++++++++++------------ 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/tests/session/validate_referrer_test.php b/tests/session/validate_referrer_test.php index e5faf8a21f..0636f04072 100644 --- a/tests/session/validate_referrer_test.php +++ b/tests/session/validate_referrer_test.php @@ -32,22 +32,22 @@ class phpbb_session_validate_referrer_test extends phpbb_database_test_case $ex = "example.org"; $alt = "example.com"; return array( - // checkpath referrer host forcevars port servername rootpath pass? - // 0 Referrer or host wasn't collected, therefore should validate - array(false, "", $ex, false, 80, $ex, "", true), - array(false, $ex, "", false, 80, $ex, "", true), - // 2 Referrer doesn't match host or server_name - array(false, $alt, $ex, yes, 80, $ex, "", false), - // 3 Everything should check out - array(false, $ex, $ex, false, 80, $ex, "", true), - // 4 Check Script Path - array(true, $ex, $ex, false, 80, $ex, "", true), - array(true, "$ex/foo", $ex, false, 80, $ex, "/foo", true), - array(true, "$ex/bar", $ex, false, 80, $ex, "/foo", false), - // 7 Port (This is not checked unless path is checked) - array(true, "$ex:80/foo", "$ex:80", false, 80, "$ex:80", "/foo", true), - array(true, "$ex:80/bar", "$ex:80", false, 80, "$ex:80", "/foo", false), - array(true, "$ex:79/foo", "$ex:81", false, 81, "$ex:81", "/foo", false), + // checkpath referrer host forcevars port servername rootpath pass? + // 0 Referrer or host wasn't collected, therefore should validate + array(false, '', $ex, false, 80, $ex, '', true), + array(false, $ex, '', false, 80, $ex, '', true), + // 2 Referrer doesn't match host or server_name + array(false, $alt, $ex, yes, 80, $ex, '', false), + // 3 Everything should check out + array(false, $ex, $ex, false, 80, $ex, '', true), + // 4 Check Script Path + array(true, $ex, $ex, false, 80, $ex, '', true), + array(true, "$ex/foo", $ex, false, 80, $ex, "/foo", true), + array(true, "$ex/bar", $ex, false, 80, $ex, "/foo", false), + // 7 Port (This is not checked unless path is checked) + array(true, "$ex:80/foo", "$ex:80", false, 80, "$ex:80", "/foo", true), + array(true, "$ex:80/bar", "$ex:80", false, 80, "$ex:80", "/foo", false), + array(true, "$ex:79/foo", "$ex:81", false, 81, "$ex:81", "/foo", false), ); } @@ -75,6 +75,6 @@ class phpbb_session_validate_referrer_test extends phpbb_database_test_case $server_port, $server_name, $root_script_path - ), "referrer should" . ($pass_or_fail? "" : "n't") . " be validated"); + ), "referrer should" . ($pass_or_fail? '' : "n't") . " be validated"); } } From 7ef95ce8ac8d189c65c3c3b27f0da9d1ac46877c Mon Sep 17 00:00:00 2001 From: Andy Chase Date: Fri, 5 Jul 2013 11:52:40 -0700 Subject: [PATCH 2055/2494] [ticket/11620] Fix typo and confusingly named test PHPBB3-11620 --- tests/session/validate_referrer_test.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/session/validate_referrer_test.php b/tests/session/validate_referrer_test.php index 0636f04072..6774166132 100644 --- a/tests/session/validate_referrer_test.php +++ b/tests/session/validate_referrer_test.php @@ -37,7 +37,7 @@ class phpbb_session_validate_referrer_test extends phpbb_database_test_case array(false, '', $ex, false, 80, $ex, '', true), array(false, $ex, '', false, 80, $ex, '', true), // 2 Referrer doesn't match host or server_name - array(false, $alt, $ex, yes, 80, $ex, '', false), + array(false, $alt, $ex, false, 80, $ex, '', false), // 3 Everything should check out array(false, $ex, $ex, false, 80, $ex, '', true), // 4 Check Script Path @@ -52,7 +52,7 @@ class phpbb_session_validate_referrer_test extends phpbb_database_test_case } /** @dataProvider referrer_inputs */ - function test_failing_referrer ( + function test_referrer_inputs ( $check_script_path, $referrer, $host, From 521d35dd6eaf7a6cd8be1ebd8591e4b2b21fd99f Mon Sep 17 00:00:00 2001 From: Andy Chase Date: Fri, 5 Jul 2013 13:10:27 -0700 Subject: [PATCH 2056/2494] [ticket/11620] Add create_test with test for bot detection Added a test for the creation of a session with a simple test for detecting whether a bot is present. PHPBB3-11620 --- tests/session/create_test.php | 86 +++++++++++++++++++++++++++++++ tests/session/testable_facade.php | 26 ++++++---- 2 files changed, 102 insertions(+), 10 deletions(-) create mode 100644 tests/session/create_test.php diff --git a/tests/session/create_test.php b/tests/session/create_test.php new file mode 100644 index 0000000000..773b833cf8 --- /dev/null +++ b/tests/session/create_test.php @@ -0,0 +1,86 @@ +createXMLDataSet(dirname(__FILE__).'/fixtures/sessions_full.xml'); + } + + public function setUp() + { + $this->session_factory = new phpbb_session_testable_factory; + $this->db = $this->new_dbal(); + $this->session_facade = + new phpbb_session_testable_facade($this->db, $this->session_factory); + } + + static function bot($bot_agent, $user_id, $bot_ip) + { + return array(array( + 'bot_agent' => $bot_agent, + 'user_id' => $user_id, + 'bot_ip' => $bot_ip + )); + } + + static function create_inputs() { + return array( + array( + false, + false, + false, + false, + array(), + 'user agent', + '127.0.0.1', + self::bot('user agent', 13, '127.0.0.1'), + '', + function ($test, $output) { + $test->assertEquals($output->data['is_bot'], true, "should be a bot"); + } + ) + ); + } + + /** @dataProvider create_inputs */ + function test_session_create ( + $user_id = false, + $set_admin = false, + $persist_login = false, + $viewonline = true, + array $config_overrides = array(), + $user_agent = "", + $ip_address = "", + array $bot_overrides = array(), + $uri_sid = "", + $test_function + ) + { + $output = $this->session_facade->session_create( + $user_id, + $set_admin, + $persist_login, + $viewonline, + $config_overrides, + $user_agent, + $ip_address, + $bot_overrides, + $uri_sid + ); + $test_function($this, $output); + } +} diff --git a/tests/session/testable_facade.php b/tests/session/testable_facade.php index 886c9b328a..33175a293b 100644 --- a/tests/session/testable_facade.php +++ b/tests/session/testable_facade.php @@ -85,21 +85,27 @@ class phpbb_session_testable_facade $set_admin = false, $persist_login = false, $viewonline = true, - $config_overrides = array(), - $request_overrides = array(), - $bot_overrides = array(), + array $config_overrides = array(), + $user_agent, + $ip_address, + array $bot_overrides = array(), $uri_sid = "" ) { - $session = $this->session_factory->get_session($this->db); - global $config, $request, $cache; - $request->merge(phpbb_request_interface::SERVER, $request_overrides); - $config = array_merge($config, $config_overrides); + $this->session_factory->merge_config_data($config_overrides); // Bots - $cache->merge_cache_data(array('_bots' => $bot_overrides)); + $this->session_factory->merge_cache_data(array('_bots' => $bot_overrides)); + global $request; + $session = $this->session_factory->get_session($this->db); + $session->browser = $user_agent; + $session->ip = $ip_address; // Uri sid - $_GET['sid'] = $uri_sid; - return $session->session_create($user_id, $set_admin, $persist_login, $viewonline); + if ($uri_sid) + { + $_GET['sid'] = $uri_sid; + } + $session->session_create($user_id, $set_admin, $persist_login, $viewonline); + return $session; } function validate_referer( From 6f8187f7faadc543f3e43db278cd7239e8cf7ac7 Mon Sep 17 00:00:00 2001 From: Andy Chase Date: Fri, 5 Jul 2013 13:49:03 -0700 Subject: [PATCH 2057/2494] [ticket/11620] Reworked create_test without data provider PHPBB3-11620 --- tests/session/create_test.php | 53 ++++++++--------------------------- 1 file changed, 11 insertions(+), 42 deletions(-) diff --git a/tests/session/create_test.php b/tests/session/create_test.php index 773b833cf8..9d77a26f17 100644 --- a/tests/session/create_test.php +++ b/tests/session/create_test.php @@ -37,50 +37,19 @@ class phpbb_session_create_test extends phpbb_database_test_case )); } - static function create_inputs() { - return array( - array( - false, - false, - false, - false, - array(), - 'user agent', - '127.0.0.1', - self::bot('user agent', 13, '127.0.0.1'), - '', - function ($test, $output) { - $test->assertEquals($output->data['is_bot'], true, "should be a bot"); - } - ) - ); - } - - /** @dataProvider create_inputs */ - function test_session_create ( - $user_id = false, - $set_admin = false, - $persist_login = false, - $viewonline = true, - array $config_overrides = array(), - $user_agent = "", - $ip_address = "", - array $bot_overrides = array(), - $uri_sid = "", - $test_function - ) + function test_bot_session () { $output = $this->session_facade->session_create( - $user_id, - $set_admin, - $persist_login, - $viewonline, - $config_overrides, - $user_agent, - $ip_address, - $bot_overrides, - $uri_sid + false, + false, + false, + false, + array(), + 'user agent', + '127.0.0.1', + self::bot('user agent', 13, '127.0.0.1'), + '' ); - $test_function($this, $output); + $this->assertEquals($output->data['is_bot'], true, "should be a bot"); } } From 5cdcb689df37fd7cbaaa1b5475caa830e87be318 Mon Sep 17 00:00:00 2001 From: Andy Chase Date: Fri, 5 Jul 2013 14:49:30 -0700 Subject: [PATCH 2058/2494] [ticket/11620] Implemented a provider mock object. Due to an auth_refactor, there is a new dependency in session.php on phpbb_container and a provider. For purposes of testing, implemented a simple one. PHPBB3-11620 --- tests/mock/provider.php | 23 +++++++++++++++++++++++ tests/session/testable_factory.php | 12 +++++++++++- 2 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 tests/mock/provider.php diff --git a/tests/mock/provider.php b/tests/mock/provider.php new file mode 100644 index 0000000000..21ef2fc949 --- /dev/null +++ b/tests/mock/provider.php @@ -0,0 +1,23 @@ +request = new phpbb_mock_request( array(), @@ -83,6 +87,12 @@ class phpbb_session_testable_factory $cache = $this->cache = new phpbb_mock_cache($this->get_cache_data()); $SID = $_SID = null; + $phpbb_container = $this->container = new phpbb_mock_container_builder(); + $phpbb_container->set( + 'auth.provider.db', + new phpbb_provider() + ); + $session = new phpbb_mock_session_testable; return $session; } From a1168972ff4d6e5957da08c22437244c92f9696e Mon Sep 17 00:00:00 2001 From: Andy Chase Date: Fri, 5 Jul 2013 15:00:05 -0700 Subject: [PATCH 2059/2494] [ticket/11620] Added validate_session to provider. PHPBB3-11620 --- tests/mock/provider.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/mock/provider.php b/tests/mock/provider.php index 21ef2fc949..1e7b4bc4ba 100644 --- a/tests/mock/provider.php +++ b/tests/mock/provider.php @@ -12,12 +12,19 @@ * sessions. */ class phpbb_provider { + function autologin() { return array(); } + function kill() { } + + function validate_session($data) + { + return true; + } } From 300867ab1a688449d0a26061fa63155db1bfc101 Mon Sep 17 00:00:00 2001 From: Matthew Fonda Date: Fri, 12 Apr 2013 16:44:36 +0000 Subject: [PATCH 2060/2494] [ticket/11630] Improvements to the PHP lint pre-commit hook The PHP lint pre-commit hook fails to display any output when an error other than a parse error is decteced. Additionally, the hook may not display any meaningful output depending on php.ini settings. This commit removes the dependency on php.ini. PHPBB3-11630 --- git-tools/hooks/pre-commit | 57 ++++---------------------------------- 1 file changed, 5 insertions(+), 52 deletions(-) diff --git a/git-tools/hooks/pre-commit b/git-tools/hooks/pre-commit index 03babe47cd..06ba15c7fa 100755 --- a/git-tools/hooks/pre-commit +++ b/git-tools/hooks/pre-commit @@ -33,9 +33,7 @@ else against=4b825dc642cb6eb9a060e54bf8d69288fbee4904 fi -error=0 errors="" - if ! which "$PHP_BIN" >/dev/null 2>&1 then echo "PHP Syntax check failed:" @@ -73,63 +71,18 @@ do # check the staged file content for syntax errors # using php -l (lint) - # note: if display_errors=stderr in php.ini, - # parse errors are printed on stderr; otherwise - # they are printed on stdout. - # we filter everything other than parse errors - # with a grep below, therefore it should be safe - # to combine stdout and stderr in all circumstances - result=$(git cat-file -p $sha | "$PHP_BIN" -l 2>&1) + result=$(git cat-file -p $sha | "$PHP_BIN" -n -l -ddisplay_errors\=1 -derror_reporting\=E_ALL -dlog_errrors\=0 2>&1) if [ $? -ne 0 ] then - error=1 # Swap back in correct filenames - errors=$(echo "$errors"; echo "$result" |sed -e "s@in - on@in $filename on@g") + errors=$(echo "$errors"; echo "$result" | grep ':' | sed -e "s@in - on@in $filename on@g") fi done unset IFS -if [ $error -eq 1 ] +if [ -n "$errors" ] then - echo "PHP Syntax check failed:" - # php "display errors" (display_errors php.ini value) - # and "log errors" (log_errors php.ini value). - # these are independent settings - see main/main.c in php source. - # the "log errors" setting produces output which - # starts with "PHP Parse error:"; the "display errors" - # setting produces output starting with "Parse error:". - # if both are turned on php dumps the parse error twice. - # therefore here we try to grep for one version and - # if that yields no results grep for the other version. - # - # other fun php facts: - # - # 1. in cli, display_errors and log_errors have different - # destinations by default. display_errors prints to - # standard output and log_errors prints to standard error. - # whether these destinations make sense is left - # as an exercise for the reader. - # 2. as mentioned above, with all output turned on - # php will print parse errors twice, one time on stdout - # and one time on stderr. - # 3. it is possible to set both display_errors and log_errors - # to off. if this is done php will print the text - # "Errors parsing " but will not say what - # the errors are. useful behavior, this. - # 4. on my system display_errors defaults to on and - # log_errors defaults to off, therefore providing - # by default one copy of messages. your mileage may vary. - # 5. by setting display_errors=stderr and log_errors=on, - # both sets of messages will be printed on stderr. - # 6. php-cgi binary, given display_errors=stderr and - # log_errors=on, still prints both sets of messages - # on stderr, but formats one set as an html fragment. - # 7. your entry here? ;) - $echo_e "$errors" | grep "^Parse error:" - if [ $? -ne 0 ] - then - # match failed - $echo_e "$errors" | grep "^PHP Parse error:" - fi + echo "PHP Syntax check failed: " + $echo_e "$errors" exit 1 fi From bdaa40bb550c18f9c7feb4e2448a31a53e2a5bd2 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Sat, 6 Jul 2013 12:58:52 -0500 Subject: [PATCH 2061/2494] [ticket/11420] Fix comments, license link PHPBB3-11420 --- .../310/notification_options_reconvert.php | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/phpBB/includes/db/migration/data/310/notification_options_reconvert.php b/phpBB/includes/db/migration/data/310/notification_options_reconvert.php index 9f2d4b2d75..d994d7ec5f 100644 --- a/phpBB/includes/db/migration/data/310/notification_options_reconvert.php +++ b/phpBB/includes/db/migration/data/310/notification_options_reconvert.php @@ -3,7 +3,7 @@ * * @package migration * @copyright (c) 2013 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 * */ @@ -31,8 +31,11 @@ class phpbb_db_migration_data_310_notification_options_reconvert extends phpbb_d /** * Perform the conversion (separate for testability) + * + * @param phpbb_db_sql_insert_buffer $insert_buffer + * @param string $insert_table */ - public function perform_conversion($insert_buffer, $insert_table) + public function perform_conversion(phpbb_db_sql_insert_buffer $insert_buffer, $insert_table) { $sql = 'DELETE FROM ' . $insert_table; $this->db->sql_query($sql); @@ -58,7 +61,7 @@ class phpbb_db_migration_data_310_notification_options_reconvert extends phpbb_d $notification_methods[] = 'jabber'; } - // Notifications for posts + // Notifications for posts foreach (array('post', 'topic') as $item_type) { $this->add_method_rows( @@ -88,6 +91,15 @@ class phpbb_db_migration_data_310_notification_options_reconvert extends phpbb_d $insert_buffer->flush(); } + /** + * Insert method rows to DB + * + * @param phpbb_db_sql_insert_buffer $insert_buffer + * @param string $item_type + * @param int $item_id + * @param int $user_id + * @param string $methods + */ protected function add_method_rows(phpbb_db_sql_insert_buffer $insert_buffer, $item_type, $item_id, $user_id, array $methods) { $row_base = array( From 9f85a4d118544e6097005ea3ef37e1e627838278 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Sat, 6 Jul 2013 12:59:26 -0500 Subject: [PATCH 2062/2494] [ticket/11420] Use !==, === when comparing strings PHPBB3-11420 --- tests/notification/convert_test.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/notification/convert_test.php b/tests/notification/convert_test.php index fdd0d19e72..e07c144e16 100644 --- a/tests/notification/convert_test.php +++ b/tests/notification/convert_test.php @@ -72,7 +72,7 @@ class phpbb_notification_convert_test extends phpbb_database_test_case { $return = array(); - if ($method != '') + if ($method !== '') { $return[] = array( 'item_type' => $type, @@ -83,7 +83,7 @@ class phpbb_notification_convert_test extends phpbb_database_test_case ); } - if ($method == 'email' || $method == 'both') + if ($method === 'email' || $method === 'both') { $return[] = array( 'item_type' => $type, @@ -94,7 +94,7 @@ class phpbb_notification_convert_test extends phpbb_database_test_case ); } - if ($method == 'jabber' || $method == 'both') + if ($method === 'jabber' || $method === 'both') { $return[] = array( 'item_type' => $type, From 0894a1377013965657f29a42202a630ba83daf95 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Sat, 6 Jul 2013 16:26:56 -0500 Subject: [PATCH 2063/2494] [feature/twig] If DEBUG, EVENT will always look for new/missing tpl event files If debug mode is enabled, lets check for new/removed EVENT templates on page load rather than at compile. This is slower, but makes developing extensions easier (no need to purge the cache when a new event template file is added) PHPBB3-11598 --- phpBB/includes/template/twig/node/event.php | 26 ++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/phpBB/includes/template/twig/node/event.php b/phpBB/includes/template/twig/node/event.php index 984ba35244..971dea14fa 100644 --- a/phpBB/includes/template/twig/node/event.php +++ b/phpBB/includes/template/twig/node/event.php @@ -43,17 +43,37 @@ class phpbb_template_twig_node_event extends Twig_Node { $ext_namespace = str_replace('/', '_', $ext_namespace); - if ($this->environment->getLoader()->exists('@' . $ext_namespace . '/' . $location . '.html')) + if (defined('DEBUG')) + { + // If debug mode is enabled, lets check for new/removed EVENT + // templates on page load rather than at compile. This is + // slower, but makes developing extensions easier (no need to + // purge the cache when a new event template file is added) + $compiler + ->write("if (\$this->env->getLoader()->exists('@{$ext_namespace}/{$location}.html')) {\n") + ->indent() + ; + } + + if (defined('DEBUG') || $this->environment->getLoader()->exists('@' . $ext_namespace . '/' . $location . '.html')) { $compiler ->write("\$previous_look_up_order = \$this->env->getNamespaceLookUpOrder();\n") // We set the namespace lookup order to be this extension first, then the main path - ->write("\$this->env->setNamespaceLookUpOrder(array('" . $ext_namespace . "', '__main__'));\n") - ->write("\$this->env->loadTemplate('@" . $ext_namespace . "/" . $location . ".html')->display(\$context);\n") + ->write("\$this->env->setNamespaceLookUpOrder(array('{$ext_namespace}', '__main__'));\n") + ->write("\$this->env->loadTemplate('@{$ext_namespace}/{$location}.html')->display(\$context);\n") ->write("\$this->env->setNamespaceLookUpOrder(\$previous_look_up_order);\n") ; } + + if (defined('DEBUG')) + { + $compiler + ->outdent() + ->write("}\n\n") + ; + } } } } From c20f92ba1eb089222bfbe7d7acd5992682a9c936 Mon Sep 17 00:00:00 2001 From: David King Date: Mon, 19 Nov 2012 18:15:59 -0500 Subject: [PATCH 2064/2494] [ticket/11215] Correct paths when path info is used for controller access PHPBB3-11215 --- phpBB/app.php | 1 - phpBB/common.php | 3 ++ phpBB/includes/functions.php | 62 ++++++++++++++++++++++++++++-------- 3 files changed, 52 insertions(+), 14 deletions(-) diff --git a/phpBB/app.php b/phpBB/app.php index d93208d585..f1023ff1b5 100644 --- a/phpBB/app.php +++ b/phpBB/app.php @@ -24,7 +24,6 @@ $user->session_begin(); $auth->acl($user->data); $user->setup('app'); -$symfony_request = phpbb_create_symfony_request($request); $http_kernel = $phpbb_container->get('http_kernel'); $response = $http_kernel->handle($symfony_request); $response->send(); diff --git a/phpBB/common.php b/phpBB/common.php index f6f109c3de..236d456eec 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -109,6 +109,9 @@ $db = $phpbb_container->get('dbal.conn'); // make sure request_var uses this request instance request_var('', 0, false, false, $request); // "dependency injection" for a function +// Create a Symfony Request object from our phpbb_request object +$symfony_request = phpbb_create_symfony_request($request); + // Grab global variables, re-cache if necessary $config = $phpbb_container->get('config'); set_config(null, null, null, $config); diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 6a1b3fd4f8..60181c488e 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -2413,6 +2413,7 @@ function append_sid($url, $params = false, $is_amp = true, $session_id = false) { global $_SID, $_EXTRA_URL, $phpbb_hook; global $phpbb_dispatcher; + global $request; if ($params === '' || (is_array($params) && empty($params))) { @@ -2420,6 +2421,12 @@ function append_sid($url, $params = false, $is_amp = true, $session_id = false) $params = false; } + $corrected_root = phpbb_get_web_root_path(phpbb_create_symfony_request($request)); + if ($corrected_root) + { + $url = $corrected_root . substr($url, strlen($phpbb_root_path)); + } + $append_sid_overwrite = false; /** @@ -5209,7 +5216,11 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0 // Determine board url - we may need it later $board_url = generate_board_url() . '/'; - $web_path = (defined('PHPBB_USE_BOARD_URL_PATH') && PHPBB_USE_BOARD_URL_PATH) ? $board_url : $phpbb_root_path; + // This path is sent with the base template paths in the assign_vars() + // call below. We need to correct it in case we are accessing from a + // controller because the web paths will be incorrect otherwise. + $corrected_path = phpbb_get_web_root_path(phpbb_create_symfony_request($request)); + $web_path = (defined('PHPBB_USE_BOARD_URL_PATH') && PHPBB_USE_BOARD_URL_PATH) ? $board_url : $corrected_path; // Send a proper content-language to the output $user_lang = $user->lang['USER_LANG']; @@ -5685,6 +5696,16 @@ function phpbb_convert_30_dbms_to_31($dbms) */ function phpbb_create_symfony_request(phpbb_request $request) { + // If we have already gotten it, don't go back through all the trouble of + // creating it again; instead, just return it. This allows multiple calls + // of this method so we don't have to globalize $symfony_request in other + // functions. + static $symfony_request; + if (null !== $symfony_request) + { + return $symfony_request; + } + // This function is meant to sanitize the global input arrays $sanitizer = function(&$value, $key) { $type_cast_helper = new phpbb_request_type_cast_helper(); @@ -5704,21 +5725,36 @@ function phpbb_create_symfony_request(phpbb_request $request) array_walk_recursive($get_parameters, $sanitizer); array_walk_recursive($post_parameters, $sanitizer); - // Until we fix the issue with relative paths, we have to fake path info - // to allow urls like app.php?controller=foo/bar - $controller = $request->variable('controller', ''); - $path_info = '/' . $controller; - $request_uri = $server_parameters['REQUEST_URI']; + $symfony_request = new Request($get_parameters, $post_parameters, array(), $cookie_parameters, $files_parameters, $server_parameters); + return $symfony_request; +} - // Remove the query string from REQUEST_URI - if ($pos = strpos($request_uri, '?')) +/** +* Get a relative root path from the current URL +* +* @param Request $symfony_request Symfony Request object +*/ +function phpbb_get_web_root_path(Request $symfony_request) +{ + static $path; + if (null !== $path) { - $request_uri = substr($request_uri, 0, $pos); + return $path; } - // Add the path info (i.e. controller route) to the REQUEST_URI - $server_parameters['REQUEST_URI'] = $request_uri . $path_info; - $server_parameters['SCRIPT_NAME'] = ''; + $path_info = $symfony_request->getPathInfo(); + if ($path_info == '/') + { + return ''; + } - return new Request($get_parameters, $post_parameters, array(), $cookie_parameters, $files_parameters, $server_parameters); + $corrections = substr_count($symfony_request->getPathInfo(), '/'); + + $path = ''; + for ($i = 0; $i < $corrections; $i++) + { + $path .= '../'; + } + + return $path; } From 0f522ddf5fb6e7d268f9d9cf428b8e3985f374ea Mon Sep 17 00:00:00 2001 From: David King Date: Mon, 19 Nov 2012 19:36:07 -0500 Subject: [PATCH 2065/2494] [ticket/11215] A few minor optimizations for phpbb_get_web_root_path() PHPBB3-11215 --- phpBB/includes/functions.php | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 60181c488e..213f178694 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -5745,16 +5745,12 @@ function phpbb_get_web_root_path(Request $symfony_request) $path_info = $symfony_request->getPathInfo(); if ($path_info == '/') { - return ''; + $path = ''; + return $path; } - $corrections = substr_count($symfony_request->getPathInfo(), '/'); - - $path = ''; - for ($i = 0; $i < $corrections; $i++) - { - $path .= '../'; - } + $corrections = substr_count($path_info, '/'); + $path = str_repeat('../', $corrections); return $path; } From b9c290b5480a958eabeef66d5e9af799f77e4566 Mon Sep 17 00:00:00 2001 From: David King Date: Tue, 20 Nov 2012 16:13:29 -0500 Subject: [PATCH 2066/2494] [ticket/11215] Correct for different URL but same path info When Symfony Request calculates path info, both of the following URLs give "/" as the path info: ./app.php and ./app.php/ This commit ensures that the proper correction is made. PHPBB3-11215 --- phpBB/includes/functions.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 213f178694..331eaf742e 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -5743,7 +5743,16 @@ function phpbb_get_web_root_path(Request $symfony_request) } $path_info = $symfony_request->getPathInfo(); - if ($path_info == '/') + + // When no path is given (i.e. REQUEST_URI = "./app.php") path info from + // the Symfony Request object is "/". However, that is the same as when + // the REQUEST_URI is "./app.php/". So we want to correct the path when + // we have a trailing slash in the REQUEST_URI, but not when we don't. + $request_uri = $symfony_request->server->get('REQUEST_URI'); + $trailing_slash = substr($request_uri, -1) === '/'; + + // If pathinfo is / and we do not have a trailing slash in the REQUEST_URI + if (!$trailing_slash && '/' === $path_info) { $path = ''; return $path; From 3999d7ec7cc0860d3f955db9088558f92d1ba497 Mon Sep 17 00:00:00 2001 From: Andy Chase Date: Mon, 8 Jul 2013 10:28:40 -0700 Subject: [PATCH 2067/2494] [ticket/11620] More mock provider methods The mock provider object now better matches the interface given for providers. PHPBB3-11620 --- tests/mock/provider.php | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/tests/mock/provider.php b/tests/mock/provider.php index 1e7b4bc4ba..4d0d6fc84c 100644 --- a/tests/mock/provider.php +++ b/tests/mock/provider.php @@ -10,21 +10,43 @@ /** * Mock provider class with basic functions to help test * sessions. + * + * See interface here: + * includes/auth/provider/interface.php */ class phpbb_provider { + function init() + { + return null; + } + + function login($username, $password) + { + return array( + 'status' => "", + 'error_msg' => "", + 'user_row' => "", + ); + } + function autologin() { return array(); } - function kill() + function acp($new) { - + return array(); } - function validate_session($data) + function logout($data, $new_session) { - return true; + return null; + } + + function validate_session($user) + { + return null; } } From 70a553e0b5471c32469961be40e408bd544b670f Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Mon, 8 Jul 2013 15:16:37 -0500 Subject: [PATCH 2068/2494] [feature/twig] Variable regular expressions should be lazy PHPBB3-11598 --- phpBB/includes/template/twig/lexer.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/phpBB/includes/template/twig/lexer.php b/phpBB/includes/template/twig/lexer.php index 5f76c44481..d0a84a8b7f 100644 --- a/phpBB/includes/template/twig/lexer.php +++ b/phpBB/includes/template/twig/lexer.php @@ -98,15 +98,15 @@ class phpbb_template_twig_lexer extends Twig_Lexer // Replace all of our language variables, {L_VARNAME}, with Twig style, {{ lang('NAME') }} // Appends any filters after lang() - $code = preg_replace('#{L_([a-zA-Z0-9_\.]+)(\|[^}]+)?}#', '{{ lang(\'$1\')$2 }}', $code); + $code = preg_replace('#{L_([a-zA-Z0-9_\.]+)(\|[^}]+?)?}#', '{{ lang(\'$1\')$2 }}', $code); // Replace all of our escaped language variables, {LA_VARNAME}, with Twig style, {{ lang('NAME')|addslashes }} // Appends any filters after lang(), but before addslashes - $code = preg_replace('#{LA_([a-zA-Z0-9_\.]+)(\|[^}]+)?}#', '{{ lang(\'$1\')$2|addslashes }}', $code); + $code = preg_replace('#{LA_([a-zA-Z0-9_\.]+)(\|[^}]+?)?}#', '{{ lang(\'$1\')$2|addslashes }}', $code); // Replace all of our variables, {VARNAME}, with Twig style, {{ VARNAME }} // Appends any filters - $code = preg_replace('#{([a-zA-Z0-9_\.]+)(\|[^}]+)?}#', '{{ $1$2 }}', $code); + $code = preg_replace('#{([a-zA-Z0-9_\.]+)(\|[^}]+?)?}#', '{{ $1$2 }}', $code); return parent::tokenize($code, $filename); } From 47ec38c011f3d3d86dacdc3126fc36cdec8b1072 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Mon, 8 Jul 2013 15:18:40 -0500 Subject: [PATCH 2069/2494] [feature/twig] Add simple test to make sure Twig filters/tags are working PHPBB3-11598 --- tests/template/template_test.php | 7 +++++++ tests/template/templates/twig.html | 6 ++++++ tests/template/templates/twig_parent.html | 7 +++++++ 3 files changed, 20 insertions(+) create mode 100644 tests/template/templates/twig.html create mode 100644 tests/template/templates/twig_parent.html diff --git a/tests/template/template_test.php b/tests/template/template_test.php index d99e91bae4..fedfeba33a 100644 --- a/tests/template/template_test.php +++ b/tests/template/template_test.php @@ -309,6 +309,13 @@ class phpbb_template_template_test extends phpbb_template_template_test_case "a\nb\nc\nd", ), */ + array( + 'twig.html', + array('VARIABLE' => 'FOObar',), + array(), + array(), + "13FOOBAR|foobar", + ), ); } diff --git a/tests/template/templates/twig.html b/tests/template/templates/twig.html new file mode 100644 index 0000000000..17b94ad8d4 --- /dev/null +++ b/tests/template/templates/twig.html @@ -0,0 +1,6 @@ + + + +3{VARIABLE|upper}|{VARIABLE|lower} + + diff --git a/tests/template/templates/twig_parent.html b/tests/template/templates/twig_parent.html new file mode 100644 index 0000000000..af528e0da4 --- /dev/null +++ b/tests/template/templates/twig_parent.html @@ -0,0 +1,7 @@ + +1 + + + +2 + \ No newline at end of file From cd1fe789d243e12330a049799818ed7b062ea347 Mon Sep 17 00:00:00 2001 From: Andy Chase Date: Mon, 8 Jul 2013 16:34:46 -0700 Subject: [PATCH 2070/2494] [ticket/11620] Minor changes to tests for coding standards PHPBB3-11620 --- tests/session/create_test.php | 6 +++--- tests/session/extract_page_test.php | 26 ++++++++++++------------ tests/session/testable_facade.php | 12 +++++++++-- tests/session/validate_referrer_test.php | 4 ++-- 4 files changed, 28 insertions(+), 20 deletions(-) diff --git a/tests/session/create_test.php b/tests/session/create_test.php index 9d77a26f17..4a7484321c 100644 --- a/tests/session/create_test.php +++ b/tests/session/create_test.php @@ -33,11 +33,11 @@ class phpbb_session_create_test extends phpbb_database_test_case return array(array( 'bot_agent' => $bot_agent, 'user_id' => $user_id, - 'bot_ip' => $bot_ip + 'bot_ip' => $bot_ip, )); } - function test_bot_session () + function test_bot_session() { $output = $this->session_facade->session_create( false, @@ -50,6 +50,6 @@ class phpbb_session_create_test extends phpbb_database_test_case self::bot('user agent', 13, '127.0.0.1'), '' ); - $this->assertEquals($output->data['is_bot'], true, "should be a bot"); + $this->assertEquals($output->data['is_bot'], true, 'should be a bot'); } } diff --git a/tests/session/extract_page_test.php b/tests/session/extract_page_test.php index f8883dc8c9..c17845526f 100644 --- a/tests/session/extract_page_test.php +++ b/tests/session/extract_page_test.php @@ -15,6 +15,19 @@ class phpbb_session_extract_page_test extends phpbb_database_test_case public $db; public $session_facade; + public function getDataSet() + { + return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/sessions_empty.xml'); + } + + public function setUp() + { + $this->session_factory = new phpbb_session_testable_factory; + $this->db = $this->new_dbal(); + $this->session_facade = + new phpbb_session_testable_facade($this->db, $this->session_factory); + } + static public function extract_current_page_data() { return array( @@ -97,19 +110,6 @@ class phpbb_session_extract_page_test extends phpbb_database_test_case ); } - public function getDataSet() - { - return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/sessions_empty.xml'); - } - - public function setUp() - { - $this->session_factory = new phpbb_session_testable_factory; - $this->db = $this->new_dbal(); - $this->session_facade = - new phpbb_session_testable_facade($this->db, $this->session_factory); - } - /** @dataProvider extract_current_page_data */ function test_extract_current_page($root_path, $php_self, $query_string, $request_uri, $expected) { diff --git a/tests/session/testable_facade.php b/tests/session/testable_facade.php index 33175a293b..d28201adc3 100644 --- a/tests/session/testable_facade.php +++ b/tests/session/testable_facade.php @@ -65,8 +65,16 @@ class phpbb_session_testable_facade } - /** This function has a *lot* of dependencies, so instead of naming them all, - * just ask for overrides */ + /** + * + * This function has a lot of dependencies, so instead of naming them all, + * just ask for overrides + * + * @param update_session_page Boolean of whether to set page of the session + * @param config_overrides An array of overrides for the global config object + * @param request_overrides An array of overrides for the global request object + * @return boolean False if the user is identified, otherwise true. + */ function session_begin ( $update_session_page = true, $config_overrides = array(), diff --git a/tests/session/validate_referrer_test.php b/tests/session/validate_referrer_test.php index 6774166132..1428187f27 100644 --- a/tests/session/validate_referrer_test.php +++ b/tests/session/validate_referrer_test.php @@ -63,8 +63,8 @@ class phpbb_session_validate_referrer_test extends phpbb_database_test_case $pass_or_fail ) { - //Referrer needs http:// because it's going to get stripped in function. - $referrer = ($referrer? 'http://'.$referrer : ''); + // Referrer needs http:// because it's going to get stripped in function. + $referrer = $referrer ? 'http://'.$referrer : ''; $this->assertEquals( $pass_or_fail, $this->session_facade->validate_referer( From f51721e905af68624df422889f92a069abd7b750 Mon Sep 17 00:00:00 2001 From: Andy Chase Date: Mon, 8 Jul 2013 16:38:53 -0700 Subject: [PATCH 2071/2494] [ticket/11620] Rename provider -> mock_auth_provider Rename the class and file name to better match what the class is mocking, as well as implement the interface of that class. PHPBB3-11620 --- tests/mock/{provider.php => auth_provider.php} | 3 ++- tests/session/testable_factory.php | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) rename tests/mock/{provider.php => auth_provider.php} (90%) diff --git a/tests/mock/provider.php b/tests/mock/auth_provider.php similarity index 90% rename from tests/mock/provider.php rename to tests/mock/auth_provider.php index 4d0d6fc84c..cca7865fa2 100644 --- a/tests/mock/provider.php +++ b/tests/mock/auth_provider.php @@ -14,7 +14,8 @@ * See interface here: * includes/auth/provider/interface.php */ -class phpbb_provider { +class phpbb_mock_auth_provider implements phpbb_auth_provider_interface +{ function init() { diff --git a/tests/session/testable_factory.php b/tests/session/testable_factory.php index d0d0dabbec..ace968eb43 100644 --- a/tests/session/testable_factory.php +++ b/tests/session/testable_factory.php @@ -8,7 +8,7 @@ */ require_once dirname(__FILE__) . '/../mock/container_builder.php'; -require_once dirname(__FILE__) . '/../mock/provider.php'; +require_once dirname(__FILE__) . '/../mock/auth_provider.php'; /** * This class exists to setup an instance of phpbb's session class for testing. @@ -90,7 +90,7 @@ class phpbb_session_testable_factory $phpbb_container = $this->container = new phpbb_mock_container_builder(); $phpbb_container->set( 'auth.provider.db', - new phpbb_provider() + new phpbb_mock_auth_provider() ); $session = new phpbb_mock_session_testable; From c96b0b1a47cef409fecc3bd30792e0907a869baa Mon Sep 17 00:00:00 2001 From: Andy Chase Date: Tue, 9 Jul 2013 12:03:17 -0700 Subject: [PATCH 2072/2494] [ticket/11620] Removed unnecessary lines and whitespace PHPBB3-11620 --- tests/mock/auth_provider.php | 7 +------ tests/session/testable_facade.php | 7 +++---- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/tests/mock/auth_provider.php b/tests/mock/auth_provider.php index cca7865fa2..9674c573e3 100644 --- a/tests/mock/auth_provider.php +++ b/tests/mock/auth_provider.php @@ -8,15 +8,10 @@ */ /** - * Mock provider class with basic functions to help test - * sessions. - * - * See interface here: - * includes/auth/provider/interface.php + * Mock auth provider class with basic functions to help test sessions. */ class phpbb_mock_auth_provider implements phpbb_auth_provider_interface { - function init() { return null; diff --git a/tests/session/testable_facade.php b/tests/session/testable_facade.php index d28201adc3..b9f61b80cb 100644 --- a/tests/session/testable_facade.php +++ b/tests/session/testable_facade.php @@ -24,8 +24,8 @@ require_once dirname(__FILE__) . '/../../phpBB/includes/session.php'; */ class phpbb_session_testable_facade { - var $db; - var $session_factory; + protected $db; + protected $session_factory; function __construct($db, $session_factory) { $this->db = $db; @@ -59,12 +59,11 @@ class phpbb_session_testable_facade $config['cookie_domain'] = $cookie_domain_config; $request->overwrite('SERVER_NAME', $host, phpbb_request_interface::SERVER); $request->overwrite('Host', $host, phpbb_request_interface::SERVER); - // Note: There is a php_uname fallthrough in this method + // Note: There is a php_uname function used as a fallthrough // that this function doesn't override return $session->extract_current_hostname(); } - /** * * This function has a lot of dependencies, so instead of naming them all, From 9210d735a53e3c4a4de042b49dae361c436268e1 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 6 Jul 2013 19:40:25 +0200 Subject: [PATCH 2073/2494] [ticket/8319] Do not repeat the replacement PHPBB3-8319 --- phpBB/includes/acp/acp_bbcodes.php | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/phpBB/includes/acp/acp_bbcodes.php b/phpBB/includes/acp/acp_bbcodes.php index ead716b300..31166a56dc 100644 --- a/phpBB/includes/acp/acp_bbcodes.php +++ b/phpBB/includes/acp/acp_bbcodes.php @@ -431,15 +431,11 @@ class acp_bbcodes $fp_replace = str_replace($token, $replace, $fp_replace); $sp_match = str_replace(preg_quote($token, '!'), $sp_tokens[$token_type], $sp_match); - if ($token_type === 'LOCAL_URL') - { - // Prepend the board url to local relative links - $sp_replace = str_replace($token, generate_board_url() . '/' . '${' . ($n + 1) . '}', $sp_replace); - } - else - { - $sp_replace = str_replace($token, '${' . ($n + 1) . '}', $sp_replace); - } + + // Prepend the board url to local relative links + $replace_prepend = ($token_type === 'LOCAL_URL') ? generate_board_url() . '/' : ''; + + $sp_replace = str_replace($token, $replace_prepend . '${' . ($n + 1) . '}', $sp_replace); } $fp_match = '!' . $fp_match . '!' . $modifiers; From 19f7d12328fe1f100cd723fa808a291e634d8737 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 6 Jul 2013 19:56:41 +0200 Subject: [PATCH 2074/2494] [ticket/8319] Add migration file for update change PHPBB3-8319 --- .../migration/data/30x/local_url_bbcode.php | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 phpBB/includes/db/migration/data/30x/local_url_bbcode.php diff --git a/phpBB/includes/db/migration/data/30x/local_url_bbcode.php b/phpBB/includes/db/migration/data/30x/local_url_bbcode.php new file mode 100644 index 0000000000..f324b8880d --- /dev/null +++ b/phpBB/includes/db/migration/data/30x/local_url_bbcode.php @@ -0,0 +1,57 @@ +db->sql_like_expression($this->db->any_char . 'LOCAL_URL' . $this->db->any_char); + $result = $this->db->sql_query($sql); + + while ($row = $this->db->sql_fetchrow($result)) + { + if (!class_exists('acp_bbcodes')) + { + global $phpEx; + phpbb_require_updated('includes/acp/acp_bbcodes.' . $phpEx); + } + $bbcode_match = $row['bbcode_match']; + $bbcode_tpl = $row['bbcode_tpl']; + + $acp_bbcodes = new acp_bbcodes(); + $sql_ary = $acp_bbcodes->build_regexp($bbcode_match, $bbcode_tpl); + + $sql = 'UPDATE ' . BBCODES_TABLE . ' + SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . ' + WHERE bbcode_id = ' . (int) $row['bbcode_id']; + $this->sql_query($sql); + } + $this->db->sql_freeresult($result); + } +} From 9725eb19f8dbc124febe0189799c0b2af0215c63 Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Wed, 10 Jul 2013 11:43:52 -0400 Subject: [PATCH 2075/2494] [feature/twig] Unit tests for includejs PHPBB3-11598 --- tests/template/template_includejs_test.php | 24 ++++++++++++++++------ tests/template/templates/includejs.html | 15 +++++++++++++- 2 files changed, 32 insertions(+), 7 deletions(-) diff --git a/tests/template/template_includejs_test.php b/tests/template/template_includejs_test.php index a57b219150..0061163eeb 100644 --- a/tests/template/template_includejs_test.php +++ b/tests/template/template_includejs_test.php @@ -18,12 +18,24 @@ class phpbb_template_template_includejs_test extends phpbb_template_template_tes // Prepare correct result $scripts = array( - '', - '', - '', - '', - '', - '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', ); // Run test diff --git a/tests/template/templates/includejs.html b/tests/template/templates/includejs.html index 229f1ccc19..dd7b059f12 100644 --- a/tests/template/templates/includejs.html +++ b/tests/template/templates/includejs.html @@ -1,8 +1,21 @@ + + + + -{$SCRIPTS} + + + + + + + + + +{SCRIPTS} From ab5a79a823de50667798d4e49fc7758a3fd9f132 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Wed, 10 Jul 2013 13:19:34 -0500 Subject: [PATCH 2076/2494] [ticket/11388] includejs inherit from includeasset Copied from the INCLUDECSS PR, since this needed to be modified. Added checks for argument strings/anchors/http/https paths in asset files to load files properly PHPBB3-11388 --- .../template/twig/node/includeasset.php | 66 +++++++++++++++++++ .../includes/template/twig/node/includejs.php | 38 ++--------- 2 files changed, 73 insertions(+), 31 deletions(-) create mode 100644 phpBB/includes/template/twig/node/includeasset.php diff --git a/phpBB/includes/template/twig/node/includeasset.php b/phpBB/includes/template/twig/node/includeasset.php new file mode 100644 index 0000000000..181e3b5aa5 --- /dev/null +++ b/phpBB/includes/template/twig/node/includeasset.php @@ -0,0 +1,66 @@ +environment = $environment; + + parent::__construct(array('expr' => $expr), array(), $lineno, $tag); + } + /** + * Compiles the node to PHP. + * + * @param Twig_Compiler A Twig_Compiler instance + */ + public function compile(Twig_Compiler $compiler) + { + $compiler->addDebugInfo($this); + + $config = $this->environment->get_phpbb_config(); + + $compiler + ->write("\$asset_file = ") + ->subcompile($this->getNode('expr')) + ->raw(";\n") + ->write("\$argument_string = '?assets_version={$config['assets_version']}';\n") + ->write("\$anchor_string = '';\n") + ->write("if ((\$argument_string_start = strpos(\$asset_file, '?')) !== false) {\n") + ->indent() + ->write("\$argument_string = substr(\$asset_file, \$argument_string_start);\n") + ->write("\$asset_file = substr(\$asset_file, 0, \$argument_string_start);\n") + ->write("if ((\$anchor_string_start = strpos(\$argument_string, '#')) !== false) {\n") + ->indent() + ->write("\$anchor_string = substr(\$argument_string, \$anchor_string_start);\n") + ->write("\$argument_string = substr(\$argument_string, 0, \$anchor_string_start);\n") + ->outdent() + ->write("}\n") + ->write("\$argument_string .= '&assets_version=" . $config['assets_version'] . "';\n") + ->outdent() + ->write("}\n") + ->write("if (strpos(\$asset_file, 'http://') !== 0 && strpos(\$asset_file, 'https://') !== 0 && !file_exists(\$asset_file)) {\n") + ->indent() + ->write("\$asset_file = \$this->getEnvironment()->getLoader()->getCacheKey(\$asset_file);\n") + ->outdent() + ->write("}\n") + ->write("\$asset_file .= \$argument_string . \$anchor_string;\n") + ->write("\$context['definition']->append('{$this->get_definition_name()}', '") + ; + + $this->append_asset($compiler); + + $compiler + ->raw("\n');\n") + ; + } +} diff --git a/phpBB/includes/template/twig/node/includejs.php b/phpBB/includes/template/twig/node/includejs.php index 943eb89ace..fdf2bea3ed 100644 --- a/phpBB/includes/template/twig/node/includejs.php +++ b/phpBB/includes/template/twig/node/includejs.php @@ -7,25 +7,11 @@ * */ -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) +class phpbb_template_twig_node_includejs extends phpbb_template_twig_node_includeasset { - exit; -} - - -class phpbb_template_twig_node_includejs extends Twig_Node -{ - /** @var Twig_Environment */ - protected $environment; - - public function __construct(Twig_Node_Expression $expr, phpbb_template_twig_environment $environment, $lineno, $tag = null) + public function get_definition_name() { - $this->environment = $environment; - - parent::__construct(array('expr' => $expr), array(), $lineno, $tag); + return 'SCRIPTS'; } /** @@ -33,24 +19,14 @@ class phpbb_template_twig_node_includejs extends Twig_Node * * @param Twig_Compiler A Twig_Compiler instance */ - public function compile(Twig_Compiler $compiler) + protected function append_asset(Twig_Compiler $compiler) { - $compiler->addDebugInfo($this); - $config = $this->environment->get_phpbb_config(); $compiler - ->write("\$js_file = ") - ->subcompile($this->getNode('expr')) - ->raw(";\n") - ->write("if (!file_exists(\$js_file)) {\n") - ->indent() - ->write("\$js_file = \$this->getEnvironment()->getLoader()->getCacheKey(\$js_file);\n") - ->outdent() - ->write("}\n") - ->write("\$context['definition']->append('SCRIPTS', '\n');\n") + ->raw("\n") ; } } From 8d8979eda76cba8e98e6428542db9aaf00edf2d8 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Wed, 10 Jul 2013 13:23:36 -0500 Subject: [PATCH 2077/2494] [ticket/11388] Fixing includejs test Changed expected output to file?(any supplied argument string)&asset_version =($config['asset_version'])#(any supplied anchor string) Testing lines one at a time to make checking them easier. PHPBB3-11388 --- tests/template/template_includejs_test.php | 105 ++++++++++++++++----- tests/template/templates/includejs.html | 57 ++++++----- 2 files changed, 118 insertions(+), 44 deletions(-) diff --git a/tests/template/template_includejs_test.php b/tests/template/template_includejs_test.php index 0061163eeb..b644c8b6f0 100644 --- a/tests/template/template_includejs_test.php +++ b/tests/template/template_includejs_test.php @@ -11,34 +11,93 @@ require_once dirname(__FILE__) . '/template_test_case_with_tree.php'; class phpbb_template_template_includejs_test extends phpbb_template_template_test_case_with_tree { - public function test_includejs_compilation() + public function template_data() + { + return array( + /* + array( + // vars + // expected + ), + */ + array( + array('TEST' => 1), + '', + ), + array( + array('TEST' => 2), + '', + ), + array( + array('TEST' => 3), + '', + ), + array( + array('TEST' => 4), + '', + ), + array( + array('TEST' => 5), + '', + ), + array( + array('TEST' => 6), + '', + ), + array( + array('TEST' => 7), + '', + ), + array( + array('TEST' => 8), + '', + ), + array( + array('TEST' => 9), + '', + ), + array( + array('TEST' => 10), + '', + ), + array( + array('TEST' => 11), + '', + ), + array( + array('TEST' => 12), + '', + ), + array( + array('TEST' => 13), + '', + ), + array( + array('TEST' => 14), + '', + ), + array( + array('TEST' => 15), + '', + ), + array( + array('TEST' => 16), + '', + ), + ); + } + + /** + * @dataProvider template_data + */ + public function test_includejs_compilation($vars, $expected) { // Reset the engine state $this->setup_engine(array('assets_version' => 1)); - // Prepare correct result - $scripts = array( - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - ); + $this->template->assign_vars($vars); // Run test - $this->run_template('includejs.html', array('PARENT' => 'parent_only.js', 'SUBDIR' => 'subdir', 'EXT' => 'js'), array(), array(), implode('', $scripts)); + $this->run_template('includejs.html', array_merge(array('PARENT' => 'parent_only.js', 'SUBDIR' => 'subdir', 'EXT' => 'js'), $vars), array(), array(), $expected); } } diff --git a/tests/template/templates/includejs.html b/tests/template/templates/includejs.html index dd7b059f12..030681337b 100644 --- a/tests/template/templates/includejs.html +++ b/tests/template/templates/includejs.html @@ -1,21 +1,36 @@ - - - - - - - - - - - - - - - - - - - - -{SCRIPTS} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +{$SCRIPTS} From cdb13fc7be4771bc89da624fe0b5f38b0cc3ccd1 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 11 Jul 2013 11:52:12 +0200 Subject: [PATCH 2078/2494] [ticket/9657] Correctly use " vs ' and variables in queries PHPBB3-9657 --- phpBB/includes/content_visibility.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/phpBB/includes/content_visibility.php b/phpBB/includes/content_visibility.php index ac827bd822..88f57a0020 100644 --- a/phpBB/includes/content_visibility.php +++ b/phpBB/includes/content_visibility.php @@ -126,11 +126,11 @@ class phpbb_content_visibility else { // The user is just a normal user - return "$table_alias{$mode}_visibility = " . ITEM_APPROVED . ' + return $table_alias . $mode . '_visibility = ' . ITEM_APPROVED . ' AND ' . $db->sql_in_set($table_alias . 'forum_id', $forum_ids, false, true); } - $where_sql .= "($table_alias{$mode}_visibility = " . ITEM_APPROVED . ' + $where_sql .= '(' . $table_alias . $mode . '_visibility = ' . ITEM_APPROVED . ' AND ' . $db->sql_in_set($table_alias . 'forum_id', $forum_ids) . '))'; return $where_sql; @@ -157,12 +157,12 @@ class phpbb_content_visibility if (sizeof($exclude_forum_ids)) { - $where_sqls[] = '(' . $db->sql_in_set($table_alias . 'forum_id', $exclude_forum_ids, true) . " - AND $table_alias{$mode}_visibility = " . ITEM_APPROVED . ')'; + $where_sqls[] = '(' . $db->sql_in_set($table_alias . 'forum_id', $exclude_forum_ids, true) . ' + AND ' . $table_alias . $mode . '_visibility = ' . ITEM_APPROVED . ')'; } else { - $where_sqls[] = "$table_alias{$mode}_visibility = " . ITEM_APPROVED; + $where_sqls[] = $table_alias . $mode . '_visibility = ' . ITEM_APPROVED; } if (sizeof($approve_forums)) From dc2f13d55d181c1a927b6daa8652f68ee87b4a90 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 11 Jul 2013 11:56:05 +0200 Subject: [PATCH 2079/2494] [ticket/9657] Cast topic_id to integer PHPBB3-9657 --- phpBB/includes/content_visibility.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/content_visibility.php b/phpBB/includes/content_visibility.php index 88f57a0020..f4126d0fff 100644 --- a/phpBB/includes/content_visibility.php +++ b/phpBB/includes/content_visibility.php @@ -565,7 +565,7 @@ class phpbb_content_visibility { $sql = 'SELECT topic_type, topic_posts_approved, topic_posts_unapproved, topic_posts_softdeleted, topic_visibility FROM ' . TOPICS_TABLE . ' - WHERE topic_id = ' . $topic_id; + WHERE topic_id = ' . (int) $topic_id; $result = $db->sql_query($sql); $topic_row = $db->sql_fetchrow($result); $db->sql_freeresult($result); @@ -583,7 +583,7 @@ class phpbb_content_visibility // Get user post count information $sql = 'SELECT poster_id, COUNT(post_id) AS num_posts FROM ' . POSTS_TABLE . ' - WHERE topic_id = ' . $topic_id . ' + WHERE topic_id = ' . (int) $topic_id . ' AND post_postcount = 1 AND post_visibility = ' . ITEM_APPROVED . ' GROUP BY poster_id'; From 5b47d731470ddc1b5723ed13b63cc3f90f3e6671 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 11 Jul 2013 12:08:09 +0200 Subject: [PATCH 2080/2494] [ticket/9657] DO not use \" inside of double quotes PHPBB3-9657 --- phpBB/includes/mcp/mcp_queue.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/phpBB/includes/mcp/mcp_queue.php b/phpBB/includes/mcp/mcp_queue.php index 29c0375e6c..a253a43136 100644 --- a/phpBB/includes/mcp/mcp_queue.php +++ b/phpBB/includes/mcp/mcp_queue.php @@ -305,7 +305,7 @@ class mcp_queue 'MINI_POST_IMG' => ($post_unread) ? $user->img('icon_post_target_unread', 'UNREAD_POST') : $user->img('icon_post_target', 'POST'), - 'RETURN_QUEUE' => sprintf($user->lang['RETURN_QUEUE'], '", ''), + 'RETURN_QUEUE' => sprintf($user->lang['RETURN_QUEUE'], '', ''), 'RETURN_POST' => sprintf($user->lang['RETURN_POST'], '', ''), 'RETURN_TOPIC_SIMPLE' => sprintf($user->lang['RETURN_TOPIC_SIMPLE'], '', ''), 'REPORTED_IMG' => $user->img('icon_topic_reported', $user->lang['POST_REPORTED']), @@ -730,7 +730,7 @@ class mcp_queue $add_message = '

    ' . sprintf($user->lang['RETURN_POST'], '', ''); } - $message = $user->lang[$success_msg] . '

    ' . sprintf($user->lang['RETURN_PAGE'], "", '') . $add_message; + $message = $user->lang[$success_msg] . '

    ' . sprintf($user->lang['RETURN_PAGE'], '', '') . $add_message; if ($request->is_ajax()) { @@ -877,7 +877,7 @@ class mcp_queue $add_message = '

    ' . sprintf($user->lang['RETURN_TOPIC'], '', ''); } - $message = $user->lang[$success_msg] . '

    ' . sprintf($user->lang['RETURN_PAGE'], "", '') . $add_message; + $message = $user->lang[$success_msg] . '

    ' . sprintf($user->lang['RETURN_PAGE'], '', '') . $add_message; if ($request->is_ajax()) { @@ -1209,7 +1209,7 @@ class mcp_queue } else { - $message = $user->lang[$success_msg] . '

    ' . sprintf($user->lang['RETURN_PAGE'], "", ''); + $message = $user->lang[$success_msg] . '

    ' . sprintf($user->lang['RETURN_PAGE'], '', ''); if ($request->is_ajax()) { From ed151cd6aaa5ec875d56d33e8908771a1244f98a Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 11 Jul 2013 12:12:18 +0200 Subject: [PATCH 2081/2494] [ticket/9657] Add , to last element of an array PHPBB3-9657 --- phpBB/includes/mcp/mcp_queue.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/phpBB/includes/mcp/mcp_queue.php b/phpBB/includes/mcp/mcp_queue.php index a253a43136..a42ae6c48c 100644 --- a/phpBB/includes/mcp/mcp_queue.php +++ b/phpBB/includes/mcp/mcp_queue.php @@ -182,8 +182,8 @@ class mcp_queue $template->assign_vars(array( 'S_TOPIC_REVIEW' => true, 'S_BBCODE_ALLOWED' => $post_info['enable_bbcode'], - 'TOPIC_TITLE' => $post_info['topic_title']) - ); + 'TOPIC_TITLE' => $post_info['topic_title'], + )); } $extensions = $attachments = $topic_tracking_info = array(); @@ -246,8 +246,8 @@ class mcp_queue foreach ($attachments as $attachment) { $template->assign_block_vars('attachment', array( - 'DISPLAY_ATTACHMENT' => $attachment) - ); + 'DISPLAY_ATTACHMENT' => $attachment, + )); } } } @@ -922,8 +922,8 @@ class mcp_queue 'mode' => $mode, 'post_id_list' => $post_id_list, 'action' => 'disapprove', - 'redirect' => $redirect) - ); + 'redirect' => $redirect, + )); $notify_poster = $request->is_set('notify_poster'); $disapprove_reason = ''; From fe66f53b0a2399e2fbf08930269c217ddb80702b Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 11 Jul 2013 12:28:01 +0200 Subject: [PATCH 2082/2494] [ticket/9657] Fix labels on confirm_delete_body.html PHPBB3-9657 --- phpBB/styles/prosilver/template/confirm_delete_body.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/phpBB/styles/prosilver/template/confirm_delete_body.html b/phpBB/styles/prosilver/template/confirm_delete_body.html index 817acbf8ba..759b6b46b2 100644 --- a/phpBB/styles/prosilver/template/confirm_delete_body.html +++ b/phpBB/styles/prosilver/template/confirm_delete_body.html @@ -11,7 +11,7 @@ -
    +

    {L_DELETE_REASON_EXPLAIN}
    -
    +
    From 95c88e9099c7721d4436233f8d6649a10ce70c06 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 11 Jul 2013 12:34:12 +0200 Subject: [PATCH 2083/2494] [ticket/9657] Add new line after opening diff PHPBB3-9657 --- phpBB/styles/prosilver/template/viewtopic_body.html | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/phpBB/styles/prosilver/template/viewtopic_body.html b/phpBB/styles/prosilver/template/viewtopic_body.html index 8366dc3d3e..a8bac42842 100644 --- a/phpBB/styles/prosilver/template/viewtopic_body.html +++ b/phpBB/styles/prosilver/template/viewtopic_body.html @@ -199,11 +199,13 @@
    {L_DOWNLOAD_NOTICE}
    -
    {postrow.DELETED_MESSAGE} +
    + {postrow.DELETED_MESSAGE}
    {L_REASON}{L_COLON} {postrow.DELETE_REASON}
    -
    {postrow.EDITED_MESSAGE} +
    + {postrow.EDITED_MESSAGE}
    {L_REASON}{L_COLON} {postrow.EDIT_REASON}
    From 9f89cb4cfbbd46ad45a9c7942fc2233b489bb076 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 11 Jul 2013 13:31:39 +0200 Subject: [PATCH 2084/2494] [ticket/9657] Make content visibility a service and inject everything PHPBB3-9657 --- phpBB/config/services.yml | 13 ++ phpBB/config/tables.yml | 3 + phpBB/includes/content_visibility.php | 224 +++++++++++++++----------- 3 files changed, 146 insertions(+), 94 deletions(-) diff --git a/phpBB/config/services.yml b/phpBB/config/services.yml index 4b272c6abd..e256482e50 100644 --- a/phpBB/config/services.yml +++ b/phpBB/config/services.yml @@ -66,6 +66,19 @@ services: - @dbal.conn - %tables.config_text% + content.visibility: + class: phpbb_content_visibility + arguments: + - @auth + - @dbal.conn + - @user + - %core.root_path% + - %core.php_ext% + - %tables.forums% + - %tables.posts% + - %tables.topics% + - %tables.users% + controller.helper: class: phpbb_controller_helper arguments: diff --git a/phpBB/config/tables.yml b/phpBB/config/tables.yml index ec5fec23ad..fdb448f4e0 100644 --- a/phpBB/config/tables.yml +++ b/phpBB/config/tables.yml @@ -2,10 +2,13 @@ parameters: tables.config: %core.table_prefix%config tables.config_text: %core.table_prefix%config_text tables.ext: %core.table_prefix%ext + tables.forums: %core.table_prefix%forums tables.log: %core.table_prefix%log tables.migrations: %core.table_prefix%migrations tables.modules: %core.table_prefix%modules tables.notification_types: %core.table_prefix%notification_types tables.notifications: %core.table_prefix%notifications + tables.posts: %core.table_prefix%posts + tables.topics: %core.table_prefix%topics tables.user_notifications: %core.table_prefix%user_notifications tables.users: %core.table_prefix%users diff --git a/phpBB/includes/content_visibility.php b/phpBB/includes/content_visibility.php index f4126d0fff..edf6aa3b31 100644 --- a/phpBB/includes/content_visibility.php +++ b/phpBB/includes/content_visibility.php @@ -22,6 +22,59 @@ if (!defined('IN_PHPBB')) */ class phpbb_content_visibility { + /** + * Database object + * @var phpbb_db_driver + */ + protected $this->db; + + /** + * User object + * @var phpbb_user + */ + protected $this->user; + + /** + * Auth object + * @var phpbb_auth + */ + protected $this->auth; + + /** + * phpBB root path + * @var string + */ + protected $phpbb_root_path; + + /** + * PHP Extension + * @var string + */ + protected $php_ext; + + /** + * Constructor + * + * @param phpbb_auth $this->auth Auth object + * @param phpbb_db_driver $this->db Database object + * @param phpbb_user $this->user User object + * @param string $phpbb_root_path Root path + * @param string $php_ext PHP Extension + * @return null + */ + public function __construct($this->auth, phpbb_db_driver $this->db, $this->user, $phpbb_root_path, $phpEx, $forums_table, $posts_table, $topics_table, $users_table) + { + $this->auth = $this->auth; + $this->db = $this->db; + $this->user = $this->user; + $this->phpbb_root_path = $phpbb_root_path; + $this->php_ext = $php_ext; + $this->forums_table = $forums_table; + $this->posts_table = $posts_table; + $this->topics_table = $topics_table; + $this->users_table = $users_table; + } + /** * Can the current logged-in user soft-delete posts? * @@ -30,15 +83,13 @@ class phpbb_content_visibility * @param $post_locked bool Is the post locked? * @return bool */ - static function can_soft_delete($forum_id, $poster_id, $post_locked) + public function can_soft_delete($forum_id, $poster_id, $post_locked) { - global $auth, $user; - - if ($auth->acl_get('m_softdelete', $forum_id)) + if ($this->auth->acl_get('m_softdelete', $forum_id)) { return true; } - else if ($auth->acl_get('f_softdelete', $forum_id) && $poster_id == $user->data['user_id'] && !$post_locked) + else if ($this->auth->acl_get('f_softdelete', $forum_id) && $poster_id == $this->user->data['user_id'] && !$post_locked) { return true; } @@ -54,11 +105,9 @@ class phpbb_content_visibility * @param $forum_id int The forum id is used for permission checks * @return int Number of posts/topics the user can see in the topic/forum */ - static public function get_count($mode, $data, $forum_id) + public function get_count($mode, $data, $forum_id) { - global $auth; - - if (!$auth->acl_get('m_approve', $forum_id)) + if (!$this->auth->acl_get('m_approve', $forum_id)) { return (int) $data[$mode . '_approved']; } @@ -76,11 +125,9 @@ class phpbb_content_visibility * @param $table_alias string Table alias to prefix in SQL queries * @return string The appropriate combination SQL logic for topic/post_visibility */ - static public function get_visibility_sql($mode, $forum_id, $table_alias = '') + public function get_visibility_sql($mode, $forum_id, $table_alias = '') { - global $auth; - - if ($auth->acl_get('m_approve', $forum_id)) + if ($this->auth->acl_get('m_approve', $forum_id)) { return '1 = 1'; } @@ -99,13 +146,11 @@ class phpbb_content_visibility * @param $table_alias string Table alias to prefix in SQL queries * @return string The appropriate combination SQL logic for topic/post_visibility */ - static public function get_forums_visibility_sql($mode, $forum_ids = array(), $table_alias = '') + public function get_forums_visibility_sql($mode, $forum_ids = array(), $table_alias = '') { - global $auth, $db; - $where_sql = '('; - $approve_forums = array_intersect($forum_ids, array_keys($auth->acl_getf('m_approve', true))); + $approve_forums = array_intersect($forum_ids, array_keys($this->auth->acl_getf('m_approve', true))); if (sizeof($approve_forums)) { @@ -115,23 +160,23 @@ class phpbb_content_visibility if (!sizeof($forum_ids)) { // The user can see all posts/topics in all specified forums - return $db->sql_in_set($table_alias . 'forum_id', $approve_forums); + return $this->db->sql_in_set($table_alias . 'forum_id', $approve_forums); } else { // Moderator can view all posts/topics in some forums - $where_sql .= $db->sql_in_set($table_alias . 'forum_id', $approve_forums) . ' OR '; + $where_sql .= $this->db->sql_in_set($table_alias . 'forum_id', $approve_forums) . ' OR '; } } else { // The user is just a normal user return $table_alias . $mode . '_visibility = ' . ITEM_APPROVED . ' - AND ' . $db->sql_in_set($table_alias . 'forum_id', $forum_ids, false, true); + AND ' . $this->db->sql_in_set($table_alias . 'forum_id', $forum_ids, false, true); } $where_sql .= '(' . $table_alias . $mode . '_visibility = ' . ITEM_APPROVED . ' - AND ' . $db->sql_in_set($table_alias . 'forum_id', $forum_ids) . '))'; + AND ' . $this->db->sql_in_set($table_alias . 'forum_id', $forum_ids) . '))'; return $where_sql; } @@ -147,17 +192,15 @@ class phpbb_content_visibility * @param $table_alias string Table alias to prefix in SQL queries * @return string The appropriate combination SQL logic for topic/post_visibility */ - static public function get_global_visibility_sql($mode, $exclude_forum_ids = array(), $table_alias = '') + public function get_global_visibility_sql($mode, $exclude_forum_ids = array(), $table_alias = '') { - global $auth, $db; - $where_sqls = array(); - $approve_forums = array_diff(array_keys($auth->acl_getf('m_approve', true)), $exclude_forum_ids); + $approve_forums = array_diff(array_keys($this->auth->acl_getf('m_approve', true)), $exclude_forum_ids); if (sizeof($exclude_forum_ids)) { - $where_sqls[] = '(' . $db->sql_in_set($table_alias . 'forum_id', $exclude_forum_ids, true) . ' + $where_sqls[] = '(' . $this->db->sql_in_set($table_alias . 'forum_id', $exclude_forum_ids, true) . ' AND ' . $table_alias . $mode . '_visibility = ' . ITEM_APPROVED . ')'; } else @@ -167,7 +210,7 @@ class phpbb_content_visibility if (sizeof($approve_forums)) { - $where_sqls[] = $db->sql_in_set($table_alias . 'forum_id', $approve_forums); + $where_sqls[] = $this->db->sql_in_set($table_alias . 'forum_id', $approve_forums); return '(' . implode(' OR ', $where_sqls) . ')'; } @@ -192,10 +235,8 @@ class phpbb_content_visibility * @param $limit_delete_time mixed Limit updating per topic_id to a certain deletion time * @return array Changed post data, empty array if an error occured. */ - static public function set_post_visibility($visibility, $post_id, $topic_id, $forum_id, $user_id, $time, $reason, $is_starter, $is_latest, $limit_visibility = false, $limit_delete_time = false) + public function set_post_visibility($visibility, $post_id, $topic_id, $forum_id, $user_id, $time, $reason, $is_starter, $is_latest, $limit_visibility = false, $limit_delete_time = false) { - global $db; - if (!in_array($visibility, array(ITEM_APPROVED, ITEM_DELETED))) { return array(); @@ -205,7 +246,7 @@ class phpbb_content_visibility { if (is_array($post_id)) { - $where_sql = $db->sql_in_set('post_id', array_map('intval', $post_id)); + $where_sql = $this->db->sql_in_set('post_id', array_map('intval', $post_id)); } else { @@ -233,12 +274,12 @@ class phpbb_content_visibility } $sql = 'SELECT poster_id, post_id, post_postcount, post_visibility - FROM ' . POSTS_TABLE . ' + FROM ' . $this->posts_table . ' WHERE ' . $where_sql; - $result = $db->sql_query($sql); + $result = $this->db->sql_query($sql); $post_ids = $poster_postcounts = $postcounts = $postcount_visibility = array(); - while ($row = $db->sql_fetchrow($result)) + while ($row = $this->db->sql_fetchrow($result)) { $post_ids[] = (int) $row['post_id']; @@ -263,7 +304,7 @@ class phpbb_content_visibility } } } - $db->sql_freeresult($result); + $this->db->sql_freeresult($result); if (empty($post_ids)) { @@ -277,10 +318,10 @@ class phpbb_content_visibility 'post_delete_reason' => truncate_string($reason, 255, 255, false), ); - $sql = 'UPDATE ' . POSTS_TABLE . ' - SET ' . $db->sql_build_array('UPDATE', $data) . ' - WHERE ' . $db->sql_in_set('post_id', $post_ids); - $db->sql_query($sql); + $sql = 'UPDATE ' . $this->posts_table . ' + SET ' . $this->db->sql_build_array('UPDATE', $data) . ' + WHERE ' . $this->db->sql_in_set('post_id', $post_ids); + $this->db->sql_query($sql); // Group the authors by post count, to reduce the number of queries foreach ($poster_postcounts as $poster_id => $num_posts) @@ -293,24 +334,24 @@ class phpbb_content_visibility { if ($visibility == ITEM_DELETED) { - $sql = 'UPDATE ' . USERS_TABLE . ' + $sql = 'UPDATE ' . $this->users_table . ' SET user_posts = 0 - WHERE ' . $db->sql_in_set('user_id', $poster_ids) . ' + WHERE ' . $this->db->sql_in_set('user_id', $poster_ids) . ' AND user_posts < ' . $num_posts; - $db->sql_query($sql); + $this->db->sql_query($sql); - $sql = 'UPDATE ' . USERS_TABLE . ' + $sql = 'UPDATE ' . $this->users_table . ' SET user_posts = user_posts - ' . $num_posts . ' - WHERE ' . $db->sql_in_set('user_id', $poster_ids) . ' + WHERE ' . $this->db->sql_in_set('user_id', $poster_ids) . ' AND user_posts >= ' . $num_posts; - $db->sql_query($sql); + $this->db->sql_query($sql); } else { - $sql = 'UPDATE ' . USERS_TABLE . ' + $sql = 'UPDATE ' . $this->users_table . ' SET user_posts = user_posts + ' . $num_posts . ' - WHERE ' . $db->sql_in_set('user_id', $poster_ids); - $db->sql_query($sql); + WHERE ' . $this->db->sql_in_set('user_id', $poster_ids); + $this->db->sql_query($sql); } } @@ -333,8 +374,7 @@ class phpbb_content_visibility { if (!function_exists('sync')) { - global $phpEx, $phpbb_root_path; - include($phpbb_root_path . 'includes/functions_admin.' . $phpEx); + include($this->phpbb_root_path . 'includes/functions_admin.' . $this->php_ext); } // ... so we need to use sync, if the first post is changed. @@ -409,15 +449,15 @@ class phpbb_content_visibility } // Update the number for replies and posts - $sql = 'UPDATE ' . TOPICS_TABLE . ' + $sql = 'UPDATE ' . $this->topics_table . ' SET ' . implode(', ', $topic_sql) . ' WHERE topic_id = ' . (int) $topic_id; - $db->sql_query($sql); + $this->db->sql_query($sql); - $sql = 'UPDATE ' . FORUMS_TABLE . ' + $sql = 'UPDATE ' . $this->forums_table . ' SET ' . implode(', ', $forum_sql) . ' WHERE forum_id = ' . (int) $forum_id; - $db->sql_query($sql); + $this->db->sql_query($sql); } } @@ -445,10 +485,8 @@ class phpbb_content_visibility * @param $force_update_all bool Force to update all posts within the topic * @return array Changed topic data, empty array if an error occured. */ - static public function set_topic_visibility($visibility, $topic_id, $forum_id, $user_id, $time, $reason, $force_update_all = false) + public function set_topic_visibility($visibility, $topic_id, $forum_id, $user_id, $time, $reason, $force_update_all = false) { - global $db; - if (!in_array($visibility, array(ITEM_APPROVED, ITEM_DELETED))) { return array(); @@ -457,11 +495,11 @@ class phpbb_content_visibility if (!$force_update_all) { $sql = 'SELECT topic_visibility, topic_delete_time - FROM ' . TOPICS_TABLE . ' + FROM ' . $this->topics_table . ' WHERE topic_id = ' . (int) $topic_id; - $result = $db->sql_query($sql); - $original_topic_data = $db->sql_fetchrow($result); - $db->sql_freeresult($result); + $result = $this->db->sql_query($sql); + $original_topic_data = $this->db->sql_fetchrow($result); + $this->db->sql_freeresult($result); if (!$original_topic_data) { @@ -478,12 +516,12 @@ class phpbb_content_visibility 'topic_delete_reason' => truncate_string($reason, 255, 255, false), ); - $sql = 'UPDATE ' . TOPICS_TABLE . ' - SET ' . $db->sql_build_array('UPDATE', $data) . ' + $sql = 'UPDATE ' . $this->topics_table . ' + SET ' . $this->db->sql_build_array('UPDATE', $data) . ' WHERE topic_id = ' . (int) $topic_id; - $db->sql_query($sql); + $this->db->sql_query($sql); - if (!$db->sql_affectedrows()) + if (!$this->db->sql_affectedrows()) { return array(); } @@ -513,15 +551,15 @@ class phpbb_content_visibility * @param $sql_data array Populated with the SQL changes, may be empty at call time * @return void */ - static public function add_post_to_statistic($data, &$sql_data) + public function add_post_to_statistic($data, &$sql_data) { - $sql_data[TOPICS_TABLE] = (($sql_data[TOPICS_TABLE]) ? $sql_data[TOPICS_TABLE] . ', ' : '') . 'topic_posts_approved = topic_posts_approved + 1'; + $sql_data[$this->topics_table] = (($sql_data[$this->topics_table]) ? $sql_data[$this->topics_table] . ', ' : '') . 'topic_posts_approved = topic_posts_approved + 1'; - $sql_data[FORUMS_TABLE] = (($sql_data[FORUMS_TABLE]) ? $sql_data[FORUMS_TABLE] . ', ' : '') . 'forum_posts_approved = forum_posts_approved + 1'; + $sql_data[$this->forums_table] = (($sql_data[$this->forums_table]) ? $sql_data[$this->forums_table] . ', ' : '') . 'forum_posts_approved = forum_posts_approved + 1'; if ($data['post_postcount']) { - $sql_data[USERS_TABLE] = (($sql_data[USERS_TABLE]) ? $sql_data[USERS_TABLE] . ', ' : '') . 'user_posts = user_posts + 1'; + $sql_data[$this->users_table] = (($sql_data[$this->users_table]) ? $sql_data[$this->users_table] . ', ' : '') . 'user_posts = user_posts + 1'; } set_config_count('num_posts', 1, true); @@ -534,14 +572,14 @@ class phpbb_content_visibility * @param $sql_data array Populated with the SQL changes, may be empty at call time * @return void */ - static public function remove_post_from_statistic($data, &$sql_data) + public function remove_post_from_statistic($data, &$sql_data) { - $sql_data[TOPICS_TABLE] = ((!empty($sql_data[TOPICS_TABLE])) ? $sql_data[TOPICS_TABLE] . ', ' : '') . 'topic_posts_approved = topic_posts_approved - 1'; - $sql_data[FORUMS_TABLE] = ((!empty($sql_data[FORUMS_TABLE])) ? $sql_data[FORUMS_TABLE] . ', ' : '') . 'forum_posts_approved = forum_posts_approved - 1'; + $sql_data[$this->topics_table] = ((!empty($sql_data[$this->topics_table])) ? $sql_data[$this->topics_table] . ', ' : '') . 'topic_posts_approved = topic_posts_approved - 1'; + $sql_data[$this->forums_table] = ((!empty($sql_data[$this->forums_table])) ? $sql_data[$this->forums_table] . ', ' : '') . 'forum_posts_approved = forum_posts_approved - 1'; if ($data['post_postcount']) { - $sql_data[USERS_TABLE] = ((!empty($sql_data[USERS_TABLE])) ? $sql_data[USERS_TABLE] . ', ' : '') . 'user_posts = user_posts - 1'; + $sql_data[$this->users_table] = ((!empty($sql_data[$this->users_table])) ? $sql_data[$this->users_table] . ', ' : '') . 'user_posts = user_posts - 1'; } set_config_count('num_posts', -1, true); @@ -556,60 +594,58 @@ class phpbb_content_visibility * @param $sql_data array Populated with the SQL changes, may be empty at call time * @return void */ - static public function remove_topic_from_statistic($topic_id, $forum_id, &$topic_row, &$sql_data) + public function remove_topic_from_statistic($topic_id, $forum_id, &$topic_row, &$sql_data) { - global $db; - // Do we need to grab some topic informations? if (!sizeof($topic_row)) { $sql = 'SELECT topic_type, topic_posts_approved, topic_posts_unapproved, topic_posts_softdeleted, topic_visibility - FROM ' . TOPICS_TABLE . ' + FROM ' . $this->topics_table . ' WHERE topic_id = ' . (int) $topic_id; - $result = $db->sql_query($sql); - $topic_row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); + $result = $this->db->sql_query($sql); + $topic_row = $this->db->sql_fetchrow($result); + $this->db->sql_freeresult($result); } // If this is an edited topic or the first post the topic gets completely disapproved later on... - $sql_data[FORUMS_TABLE] = (($sql_data[FORUMS_TABLE]) ? $sql_data[FORUMS_TABLE] . ', ' : '') . 'forum_topics_approved = forum_topics_approved - 1'; - $sql_data[FORUMS_TABLE] .= ', forum_posts_approved = forum_posts_approved - ' . $topic_row['topic_posts_approved']; - $sql_data[FORUMS_TABLE] .= ', forum_posts_unapproved = forum_posts_unapproved - ' . $topic_row['topic_posts_unapproved']; - $sql_data[FORUMS_TABLE] .= ', forum_posts_softdeleted = forum_posts_softdeleted - ' . $topic_row['topic_posts_softdeleted']; + $sql_data[$this->forums_table] = (($sql_data[$this->forums_table]) ? $sql_data[$this->forums_table] . ', ' : '') . 'forum_topics_approved = forum_topics_approved - 1'; + $sql_data[$this->forums_table] .= ', forum_posts_approved = forum_posts_approved - ' . $topic_row['topic_posts_approved']; + $sql_data[$this->forums_table] .= ', forum_posts_unapproved = forum_posts_unapproved - ' . $topic_row['topic_posts_unapproved']; + $sql_data[$this->forums_table] .= ', forum_posts_softdeleted = forum_posts_softdeleted - ' . $topic_row['topic_posts_softdeleted']; set_config_count('num_topics', -1, true); set_config_count('num_posts', $topic_row['topic_posts_approved'] * (-1), true); // Get user post count information $sql = 'SELECT poster_id, COUNT(post_id) AS num_posts - FROM ' . POSTS_TABLE . ' + FROM ' . $this->posts_table . ' WHERE topic_id = ' . (int) $topic_id . ' AND post_postcount = 1 AND post_visibility = ' . ITEM_APPROVED . ' GROUP BY poster_id'; - $result = $db->sql_query($sql); + $result = $this->db->sql_query($sql); $postcounts = array(); - while ($row = $db->sql_fetchrow($result)) + while ($row = $this->db->sql_fetchrow($result)) { $postcounts[(int) $row['num_posts']][] = (int) $row['poster_id']; } - $db->sql_freeresult($result); + $this->db->sql_freeresult($result); // Decrement users post count foreach ($postcounts as $num_posts => $poster_ids) { - $sql = 'UPDATE ' . USERS_TABLE . ' + $sql = 'UPDATE ' . $this->users_table . ' SET user_posts = 0 WHERE user_posts < ' . $num_posts . ' - AND ' . $db->sql_in_set('user_id', $poster_ids); - $db->sql_query($sql); + AND ' . $this->db->sql_in_set('user_id', $poster_ids); + $this->db->sql_query($sql); - $sql = 'UPDATE ' . USERS_TABLE . ' + $sql = 'UPDATE ' . $this->users_table . ' SET user_posts = user_posts - ' . $num_posts . ' WHERE user_posts >= ' . $num_posts . ' - AND ' . $db->sql_in_set('user_id', $poster_ids); - $db->sql_query($sql); + AND ' . $this->db->sql_in_set('user_id', $poster_ids); + $this->db->sql_query($sql); } } } From 9aed758c1397c31b979f4aca51249c73d21bd6f5 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 11 Jul 2013 14:24:07 +0200 Subject: [PATCH 2085/2494] [ticket/9657] Use the service instead of the static class PHPBB3-9657 --- phpBB/config/feed.yml | 7 +++++++ phpBB/includes/feed/base.php | 4 +++- phpBB/includes/feed/forum.php | 4 ++-- phpBB/includes/feed/overall.php | 4 ++-- phpBB/includes/feed/topic.php | 2 +- phpBB/includes/feed/topic_base.php | 2 +- phpBB/includes/functions.php | 5 +++-- phpBB/includes/functions_display.php | 16 ++++++++++------ phpBB/includes/functions_posting.php | 23 ++++++++++++++--------- phpBB/includes/mcp/mcp_forum.php | 10 ++++++---- phpBB/includes/mcp/mcp_main.php | 15 +++++++++------ phpBB/includes/mcp/mcp_queue.php | 8 +++++--- phpBB/includes/mcp/mcp_topic.php | 7 ++++--- phpBB/includes/ucp/ucp_main.php | 6 ++++-- phpBB/mcp.php | 6 ++++-- phpBB/posting.php | 12 +++++++----- phpBB/search.php | 8 +++++--- phpBB/viewforum.php | 10 ++++++---- phpBB/viewtopic.php | 16 +++++++++------- 19 files changed, 102 insertions(+), 63 deletions(-) diff --git a/phpBB/config/feed.yml b/phpBB/config/feed.yml index 59eeafd458..5a4cdae815 100644 --- a/phpBB/config/feed.yml +++ b/phpBB/config/feed.yml @@ -23,6 +23,7 @@ services: - @cache.driver - @user - @auth + - @content.visibility - %core.php_ext% feed.forums: @@ -35,6 +36,7 @@ services: - @cache.driver - @user - @auth + - @content.visibility - %core.php_ext% feed.news: @@ -47,6 +49,7 @@ services: - @cache.driver - @user - @auth + - @content.visibility - %core.php_ext% feed.overall: @@ -59,6 +62,7 @@ services: - @cache.driver - @user - @auth + - @content.visibility - %core.php_ext% feed.topic: @@ -71,6 +75,7 @@ services: - @cache.driver - @user - @auth + - @content.visibility - %core.php_ext% feed.topics: @@ -83,6 +88,7 @@ services: - @cache.driver - @user - @auth + - @content.visibility - %core.php_ext% feed.topics_active: @@ -95,4 +101,5 @@ services: - @cache.driver - @user - @auth + - @content.visibility - %core.php_ext% diff --git a/phpBB/includes/feed/base.php b/phpBB/includes/feed/base.php index af28ee8dc8..84fdbe415a 100644 --- a/phpBB/includes/feed/base.php +++ b/phpBB/includes/feed/base.php @@ -80,10 +80,11 @@ abstract class phpbb_feed_base * @param phpbb_cache_driver_interface $cache Cache object * @param phpbb_user $user User object * @param phpbb_auth $auth Auth object + * @param phpbb_content_visibility $content_visibility Auth object * @param string $phpEx php file extension * @return null */ - function __construct(phpbb_feed_helper $helper, phpbb_config $config, phpbb_db_driver $db, phpbb_cache_driver_interface $cache, phpbb_user $user, phpbb_auth $auth, $phpEx) + function __construct(phpbb_feed_helper $helper, phpbb_config $config, phpbb_db_driver $db, phpbb_cache_driver_interface $cache, phpbb_user $user, phpbb_auth $auth, $content_visibility, $phpEx) { $this->config = $config; $this->helper = $helper; @@ -91,6 +92,7 @@ abstract class phpbb_feed_base $this->cache = $cache; $this->user = $user; $this->auth = $auth; + $this->content_visibility = $content_visibility; $this->phpEx = $phpEx; $this->set_keys(); diff --git a/phpBB/includes/feed/forum.php b/phpBB/includes/feed/forum.php index 83b836b81d..fc217c203c 100644 --- a/phpBB/includes/feed/forum.php +++ b/phpBB/includes/feed/forum.php @@ -90,7 +90,7 @@ class phpbb_feed_forum extends phpbb_feed_post_base function get_sql() { - $sql_visibility = phpbb_content_visibility::get_visibility_sql('topic', $this->forum_id); + $sql_visibility = $this->content_visibility->get_visibility_sql('topic', $this->forum_id); // Determine topics with recent activity $sql = 'SELECT topic_id, topic_last_post_time @@ -116,7 +116,7 @@ class phpbb_feed_forum extends phpbb_feed_post_base return false; } - $sql_visibility = phpbb_content_visibility::get_visibility_sql('post', $this->forum_id, 'p.'); + $sql_visibility = $this->content_visibility->get_visibility_sql('post', $this->forum_id, 'p.'); $this->sql = array( 'SELECT' => 'p.post_id, p.topic_id, p.post_time, p.post_edit_time, p.post_visibility, p.post_subject, p.post_text, p.bbcode_bitfield, p.bbcode_uid, p.enable_bbcode, p.enable_smilies, p.enable_magic_url, ' . diff --git a/phpBB/includes/feed/overall.php b/phpBB/includes/feed/overall.php index 7e48120b97..af45840d69 100644 --- a/phpBB/includes/feed/overall.php +++ b/phpBB/includes/feed/overall.php @@ -37,7 +37,7 @@ class phpbb_feed_overall extends phpbb_feed_post_base $sql = 'SELECT topic_id, topic_last_post_time FROM ' . TOPICS_TABLE . ' WHERE topic_moved_id = 0 - AND ' . phpbb_content_visibility::get_forums_visibility_sql('topic', $forum_ids) . ' + AND ' . $this->content_visibility->get_forums_visibility_sql('topic', $forum_ids) . ' ORDER BY topic_last_post_time DESC'; $result = $this->db->sql_query_limit($sql, $this->num_items); @@ -56,7 +56,7 @@ class phpbb_feed_overall extends phpbb_feed_post_base return false; } - $sql_visibility = phpbb_content_visibility::get_visibility_sql('post', array(), 'p.'); + $sql_visibility = $this->content_visibility->get_visibility_sql('post', array(), 'p.'); // Get the actual data $this->sql = array( diff --git a/phpBB/includes/feed/topic.php b/phpBB/includes/feed/topic.php index 42bd291343..10f86486c6 100644 --- a/phpBB/includes/feed/topic.php +++ b/phpBB/includes/feed/topic.php @@ -93,7 +93,7 @@ class phpbb_feed_topic extends phpbb_feed_post_base function get_sql() { - $sql_visibility = phpbb_content_visibility::get_visibility_sql('post', $this->forum_id, 'p.'); + $sql_visibility = $this->content_visibility->get_visibility_sql('post', $this->forum_id, 'p.'); $this->sql = array( 'SELECT' => 'p.post_id, p.post_time, p.post_edit_time, p.post_visibility, p.post_subject, p.post_text, p.bbcode_bitfield, p.bbcode_uid, p.enable_bbcode, p.enable_smilies, p.enable_magic_url, ' . diff --git a/phpBB/includes/feed/topic_base.php b/phpBB/includes/feed/topic_base.php index a2f5a56f1d..b104a46631 100644 --- a/phpBB/includes/feed/topic_base.php +++ b/phpBB/includes/feed/topic_base.php @@ -51,7 +51,7 @@ abstract class phpbb_feed_topic_base extends phpbb_feed_base { $item_row['statistics'] = $this->user->lang['POSTED'] . ' ' . $this->user->lang['POST_BY_AUTHOR'] . ' ' . $this->user_viewprofile($row) . ' ' . $this->separator_stats . ' ' . $this->user->format_date($row[$this->get('published')]) - . ' ' . $this->separator_stats . ' ' . $this->user->lang['REPLIES'] . ' ' . phpbb_content_visibility::get_count('topic_posts', $row, $row['forum_id']) - 1 + . ' ' . $this->separator_stats . ' ' . $this->user->lang['REPLIES'] . ' ' . $this->content_visibility->get_count('topic_posts', $row, $row['forum_id']) - 1 . ' ' . $this->separator_stats . ' ' . $this->user->lang['VIEWS'] . ' ' . $row['topic_views'] . (($this->is_moderator_approve_forum($row['forum_id']) && $row['topic_posts_unapproved']) ? ' ' . $this->separator_stats . ' ' . $this->user->lang['POSTS_UNAPPROVED'] : ''); } diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index e884a2f94c..9664b5663c 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -1974,7 +1974,7 @@ function get_unread_topics($user_id = false, $sql_extra = '', $sql_sort = '', $s */ function update_forum_tracking_info($forum_id, $forum_last_post_time, $f_mark_time = false, $mark_time_forum = false) { - global $db, $tracking_topics, $user, $config, $auth, $request; + global $db, $tracking_topics, $user, $config, $auth, $request, $phpbb_container; // Determine the users last forum mark time if not given. if ($mark_time_forum === false) @@ -1999,7 +1999,8 @@ function update_forum_tracking_info($forum_id, $forum_last_post_time, $f_mark_ti // Handle update of unapproved topics info. // Only update for moderators having m_approve permission for the forum. - $sql_update_unapproved = phpbb_content_visibility::get_visibility_sql('topic', $forum_id, 't.'); + $phpbb_content_visibility = $phpbb_container->get('content.visibility'); + $sql_update_unapproved = $phpbb_content_visibility->get_visibility_sql('topic', $forum_id, 't.'); $sql_update_unapproved = ($sql_update_unapproved) ? ' AND ' . $sql_update_unapproved : ''; // Check the forum for any left unread topics. diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php index 797ca718d8..143813e4ed 100644 --- a/phpBB/includes/functions_display.php +++ b/phpBB/includes/functions_display.php @@ -22,7 +22,7 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod { global $db, $auth, $user, $template; global $phpbb_root_path, $phpEx, $config; - global $request, $phpbb_dispatcher; + global $request, $phpbb_dispatcher, $phpbb_container; $forum_rows = $subforums = $forum_ids = $forum_ids_moderator = $forum_moderators = $active_forum_ary = array(); $parent_id = $visible_forums = 0; @@ -149,6 +149,8 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod $forum_tracking_info = array(); $branch_root_id = $root_data['forum_id']; + $phpbb_content_visibility = $phpbb_container->get('content.visibility'); + while ($row = $db->sql_fetchrow($result)) { /** @@ -215,8 +217,8 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod // Count the difference of real to public topics, so we can display an information to moderators $row['forum_id_unapproved_topics'] = ($auth->acl_get('m_approve', $forum_id) && $row['forum_topics_unapproved']) ? $forum_id : 0; - $row['forum_posts'] = phpbb_content_visibility::get_count('forum_posts', $row, $forum_id); - $row['forum_topics'] = phpbb_content_visibility::get_count('forum_topics', $row, $forum_id); + $row['forum_posts'] = $phpbb_content_visibility->get_count('forum_posts', $row, $forum_id); + $row['forum_topics'] = $phpbb_content_visibility->get_count('forum_topics', $row, $forum_id); // Display active topics from this forum? if ($show_active && $row['forum_type'] == FORUM_POST && $auth->acl_get('f_read', $forum_id) && ($row['forum_flags'] & FORUM_FLAG_ACTIVE_TOPICS)) @@ -1006,7 +1008,7 @@ function display_reasons($reason_id = 0) function display_user_activity(&$userdata) { global $auth, $template, $db, $user; - global $phpbb_root_path, $phpEx; + global $phpbb_root_path, $phpEx, $phpbb_container; // Do not display user activity for users having more than 5000 posts... if ($userdata['user_posts'] > 5000) @@ -1030,12 +1032,14 @@ function display_user_activity(&$userdata) $active_f_row = $active_t_row = array(); if (!empty($forum_ary)) { + $phpbb_content_visibility = $phpbb_container->get('content.visibility'); + // Obtain active forum $sql = 'SELECT forum_id, COUNT(post_id) AS num_posts FROM ' . POSTS_TABLE . ' WHERE poster_id = ' . $userdata['user_id'] . ' AND post_postcount = 1 - AND ' . phpbb_content_visibility::get_forums_visibility_sql('post', $forum_ary) . ' + AND ' . $phpbb_content_visibility->get_forums_visibility_sql('post', $forum_ary) . ' GROUP BY forum_id ORDER BY num_posts DESC'; $result = $db->sql_query_limit($sql, 1); @@ -1057,7 +1061,7 @@ function display_user_activity(&$userdata) FROM ' . POSTS_TABLE . ' WHERE poster_id = ' . $userdata['user_id'] . ' AND post_postcount = 1 - AND ' . phpbb_content_visibility::get_forums_visibility_sql('post', $forum_ary) . ' + AND ' . $phpbb_content_visibility->get_forums_visibility_sql('post', $forum_ary) . ' GROUP BY topic_id ORDER BY num_posts DESC'; $result = $db->sql_query_limit($sql, 1); diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index de88f7cc98..03565c27bb 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -982,13 +982,15 @@ function load_drafts($topic_id = 0, $forum_id = 0, $id = 0, $pm_action = '', $ms function topic_review($topic_id, $forum_id, $mode = 'topic_review', $cur_post_id = 0, $show_quote_button = true) { global $user, $auth, $db, $template, $bbcode, $cache; - global $config, $phpbb_root_path, $phpEx; + global $config, $phpbb_root_path, $phpEx, $phpbb_container; + + $phpbb_content_visibility = $phpbb_container->get('content.visibility'); // Go ahead and pull all data for this topic $sql = 'SELECT p.post_id FROM ' . POSTS_TABLE . ' p' . " WHERE p.topic_id = $topic_id - AND " . phpbb_content_visibility::get_visibility_sql('post', $forum_id, 'p.') . ' + AND " . $phpbb_content_visibility->get_visibility_sql('post', $forum_id, 'p.') . ' ' . (($mode == 'post_review') ? " AND p.post_id > $cur_post_id" : '') . ' ' . (($mode == 'post_review_edit') ? " AND p.post_id = $cur_post_id" : '') . ' ORDER BY p.post_time '; @@ -1177,7 +1179,7 @@ function topic_review($topic_id, $forum_id, $mode = 'topic_review', $cur_post_id */ function delete_post($forum_id, $topic_id, $post_id, &$data, $is_soft = false, $softdelete_reason = '') { - global $db, $user, $auth; + global $db, $user, $auth, $phpbb_container; global $config, $phpEx, $phpbb_root_path; // Specify our post mode @@ -1224,10 +1226,12 @@ function delete_post($forum_id, $topic_id, $post_id, &$data, $is_soft = false, $ $db->sql_freeresult($result); } + $phpbb_content_visibility = $phpbb_container->get('content.visibility'); + // (Soft) delete the post if ($is_soft && ($post_mode != 'delete_topic')) { - phpbb_content_visibility::set_post_visibility(ITEM_DELETED, $post_id, $topic_id, $forum_id, $user->data['user_id'], time(), $softdelete_reason, ($data['topic_first_post_id'] == $post_id), ($data['topic_last_post_id'] == $post_id)); + $phpbb_content_visibility->set_post_visibility(ITEM_DELETED, $post_id, $topic_id, $forum_id, $user->data['user_id'], time(), $softdelete_reason, ($data['topic_first_post_id'] == $post_id), ($data['topic_last_post_id'] == $post_id)); } else if (!$is_soft) { @@ -1264,7 +1268,7 @@ function delete_post($forum_id, $topic_id, $post_id, &$data, $is_soft = false, $ if ($is_soft) { $topic_row = array(); - phpbb_content_visibility::set_topic_visibility(ITEM_DELETED, $topic_id, $forum_id, $user->data['user_id'], time(), $softdelete_reason); + $phpbb_content_visibility->set_topic_visibility(ITEM_DELETED, $topic_id, $forum_id, $user->data['user_id'], time(), $softdelete_reason); } else { @@ -1353,7 +1357,7 @@ function delete_post($forum_id, $topic_id, $post_id, &$data, $is_soft = false, $ $sql = 'SELECT MAX(post_id) as last_post_id FROM ' . POSTS_TABLE . " WHERE topic_id = $topic_id - AND " . phpbb_content_visibility::get_visibility_sql('post', $forum_id); + AND " . $phpbb_content_visibility->get_visibility_sql('post', $forum_id); $result = $db->sql_query($sql); $next_post_id = (int) $db->sql_fetchfield('last_post_id'); $db->sql_freeresult($result); @@ -1364,7 +1368,7 @@ function delete_post($forum_id, $topic_id, $post_id, &$data, $is_soft = false, $ $sql = 'SELECT post_id FROM ' . POSTS_TABLE . " WHERE topic_id = $topic_id - AND " . phpbb_content_visibility::get_visibility_sql('post', $forum_id) . ' + AND " . $phpbb_content_visibility->get_visibility_sql('post', $forum_id) . ' AND post_time > ' . $data['post_time'] . ' ORDER BY post_time ASC'; $result = $db->sql_query_limit($sql, 1); @@ -1379,7 +1383,7 @@ function delete_post($forum_id, $topic_id, $post_id, &$data, $is_soft = false, $ { if ($data['post_visibility'] == ITEM_APPROVED) { - phpbb_content_visibility::remove_post_from_statistic($data, $sql_data); + $phpbb_content_visibility->remove_post_from_statistic($data, $sql_data); } else if ($data['post_visibility'] == ITEM_UNAPPROVED) { @@ -2000,7 +2004,8 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u $is_starter = ($post_mode == 'edit_first_post' || $data['post_visibility'] != ITEM_APPROVED); $is_latest = ($post_mode == 'edit_last_post' || $post_mode == 'edit_topic' || $data['post_visibility'] != ITEM_APPROVED); - phpbb_content_visibility::set_post_visibility($post_visibility, $data['post_id'], $data['topic_id'], $data['forum_id'], $user->data['user_id'], time(), '', $is_starter, $is_latest); + $phpbb_content_visibility = $phpbb_container->get('content.visibility'); + $phpbb_content_visibility->set_post_visibility($post_visibility, $data['post_id'], $data['topic_id'], $data['forum_id'], $user->data['user_id'], time(), '', $is_starter, $is_latest); } else if ($post_mode == 'edit_last_post' || $post_mode == 'edit_topic' || ($post_mode == 'edit_first_post' && !$data['topic_replies'])) { diff --git a/phpBB/includes/mcp/mcp_forum.php b/phpBB/includes/mcp/mcp_forum.php index a7302ce912..841a0afddb 100644 --- a/phpBB/includes/mcp/mcp_forum.php +++ b/phpBB/includes/mcp/mcp_forum.php @@ -22,7 +22,7 @@ function mcp_forum_view($id, $mode, $action, $forum_info) { global $template, $db, $user, $auth, $cache, $module; global $phpEx, $phpbb_root_path, $config; - global $request, $phpbb_dispatcher; + global $request, $phpbb_dispatcher, $phpbb_container; $user->add_lang(array('viewtopic', 'viewforum')); @@ -152,10 +152,12 @@ function mcp_forum_view($id, $mode, $action, $forum_info) $read_tracking_join = $read_tracking_select = ''; } + $phpbb_content_visibility = $phpbb_container->get('content.visibility'); + $sql = 'SELECT t.topic_id FROM ' . TOPICS_TABLE . ' t WHERE t.forum_id = ' . $forum_id . ' - AND ' . phpbb_content_visibility::get_visibility_sql('topic', $forum_id, 't.') . " + AND ' . $phpbb_content_visibility->get_visibility_sql('topic', $forum_id, 't.') . " $limit_time_sql ORDER BY t.topic_type DESC, $sort_order_sql"; $result = $db->sql_query_limit($sql, $topics_per_page, $start); @@ -204,7 +206,7 @@ function mcp_forum_view($id, $mode, $action, $forum_info) $row = &$topic_rows[$topic_id]; - $replies = phpbb_content_visibility::get_count('topic_posts', $row, $forum_id) - 1; + $replies = $phpbb_content_visibility->get_count('topic_posts', $row, $forum_id) - 1; if ($row['topic_status'] == ITEM_MOVED) { @@ -249,7 +251,7 @@ function mcp_forum_view($id, $mode, $action, $forum_info) 'TOPIC_TYPE' => $topic_type, 'TOPIC_TITLE' => $topic_title, - 'REPLIES' => phpbb_content_visibility::get_count('topic_posts', $row, $row['forum_id']) - 1, + 'REPLIES' => $phpbb_content_visibility->get_count('topic_posts', $row, $row['forum_id']) - 1, 'LAST_POST_TIME' => $user->format_date($row['topic_last_post_time']), 'FIRST_POST_TIME' => $user->format_date($row['topic_time']), 'LAST_POST_SUBJECT' => $row['topic_last_post_subject'], diff --git a/phpBB/includes/mcp/mcp_main.php b/phpBB/includes/mcp/mcp_main.php index c044e5c871..62c3eda447 100644 --- a/phpBB/includes/mcp/mcp_main.php +++ b/phpBB/includes/mcp/mcp_main.php @@ -654,7 +654,7 @@ function mcp_move_topic($topic_ids) */ function mcp_restore_topic($topic_ids) { - global $auth, $user, $db, $phpEx, $phpbb_root_path, $request; + global $auth, $user, $db, $phpEx, $phpbb_root_path, $request, $phpbb_container; if (!check_ids($topic_ids, TOPICS_TABLE, 'topic_id', array('m_approve'))) { @@ -678,9 +678,10 @@ function mcp_restore_topic($topic_ids) $data = get_topic_data($topic_ids); + $phpbb_content_visibility = $phpbb_container->get('content.visibility'); foreach ($data as $topic_id => $row) { - $return = phpbb_content_visibility::set_topic_visibility(ITEM_APPROVED, $topic_id, $row['forum_id'], $user->data['user_id'], time(), ''); + $return = $phpbb_content_visibility->set_topic_visibility(ITEM_APPROVED, $topic_id, $row['forum_id'], $user->data['user_id'], time(), ''); if (!empty($return)) { add_log('mod', $row['forum_id'], $topic_id, 'LOG_RESTORE_TOPIC', $row['topic_title'], $row['topic_first_poster_name']); @@ -726,7 +727,7 @@ function mcp_restore_topic($topic_ids) */ function mcp_delete_topic($topic_ids, $is_soft = false, $soft_delete_reason = '', $action = 'delete_topic') { - global $auth, $user, $db, $phpEx, $phpbb_root_path, $request; + global $auth, $user, $db, $phpEx, $phpbb_root_path, $request, $phpbb_container; if (!check_ids($topic_ids, TOPICS_TABLE, 'topic_id', array('m_delete'))) { @@ -761,7 +762,8 @@ function mcp_delete_topic($topic_ids, $is_soft = false, $soft_delete_reason = '' // Only soft delete non-shadow topics if ($is_soft) { - $return = phpbb_content_visibility::set_topic_visibility(ITEM_DELETED, $topic_id, $row['forum_id'], $user->data['user_id'], time(), $soft_delete_reason); + $phpbb_content_visibility = $phpbb_container->get('content.visibility'); + $return = $phpbb_content_visibility->set_topic_visibility(ITEM_DELETED, $topic_id, $row['forum_id'], $user->data['user_id'], time(), $soft_delete_reason); if (!empty($return)) { add_log('mod', $row['forum_id'], $topic_id, 'LOG_SOFTDELETE_TOPIC', $row['topic_title'], $row['topic_first_poster_name']); @@ -854,7 +856,7 @@ function mcp_delete_topic($topic_ids, $is_soft = false, $soft_delete_reason = '' */ function mcp_delete_post($post_ids, $is_soft = false, $soft_delete_reason = '', $action = 'delete_post') { - global $auth, $user, $db, $phpEx, $phpbb_root_path, $request; + global $auth, $user, $db, $phpEx, $phpbb_root_path, $request, $phpbb_container; if (!check_ids($post_ids, POSTS_TABLE, 'post_id', array('m_softdelete'))) { @@ -910,9 +912,10 @@ function mcp_delete_post($post_ids, $is_soft = false, $soft_delete_reason = '', ); } + $phpbb_content_visibility = $phpbb_container->get('content.visibility'); foreach ($topic_info as $topic_id => $topic_data) { - phpbb_content_visibility::set_post_visibility(ITEM_DELETED, $topic_data['posts'], $topic_id, $topic_data['forum_id'], $user->data['user_id'], time(), $soft_delete_reason, isset($topic_data['first_post']), isset($topic_data['last_post'])); + $phpbb_content_visibility->set_post_visibility(ITEM_DELETED, $topic_data['posts'], $topic_id, $topic_data['forum_id'], $user->data['user_id'], time(), $soft_delete_reason, isset($topic_data['first_post']), isset($topic_data['last_post'])); } $affected_topics = sizeof($topic_info); // None of the topics is really deleted, so a redirect won't hurt much. diff --git a/phpBB/includes/mcp/mcp_queue.php b/phpBB/includes/mcp/mcp_queue.php index a42ae6c48c..514d7bc4ee 100644 --- a/phpBB/includes/mcp/mcp_queue.php +++ b/phpBB/includes/mcp/mcp_queue.php @@ -634,9 +634,10 @@ class mcp_queue ); } + $phpbb_content_visibility = $phpbb_container->get('content.visibility'); foreach ($topic_info as $topic_id => $topic_data) { - phpbb_content_visibility::set_post_visibility(ITEM_APPROVED, $topic_data['posts'], $topic_id, $topic_data['forum_id'], $user->data['user_id'], time(), '', isset($topic_data['first_post']), isset($topic_data['last_post'])); + $phpbb_content_visibility->set_post_visibility(ITEM_APPROVED, $topic_data['posts'], $topic_id, $topic_data['forum_id'], $user->data['user_id'], time(), '', isset($topic_data['first_post']), isset($topic_data['last_post'])); } if (sizeof($post_info) >= 1) @@ -759,7 +760,7 @@ class mcp_queue static public function approve_topics($action, $topic_id_list, $id, $mode) { global $db, $template, $user, $config; - global $phpEx, $phpbb_root_path, $request; + global $phpEx, $phpbb_root_path, $request, $phpbb_container; if (!check_ids($topic_id_list, TOPICS_TABLE, 'topic_id', array('m_approve'))) { @@ -784,9 +785,10 @@ class mcp_queue { $notify_poster = ($action == 'approve' && isset($_REQUEST['notify_poster'])) ? true : false; + $phpbb_content_visibility = $phpbb_container->get('content.visibility'); foreach ($topic_info as $topic_id => $topic_data) { - phpbb_content_visibility::set_topic_visibility(ITEM_APPROVED, $topic_id, $topic_data['forum_id'], $user->data['user_id'], time(), ''); + $phpbb_content_visibility->set_topic_visibility(ITEM_APPROVED, $topic_id, $topic_data['forum_id'], $user->data['user_id'], time(), ''); $topic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f={$topic_data['forum_id']}&t={$topic_id}"); diff --git a/phpBB/includes/mcp/mcp_topic.php b/phpBB/includes/mcp/mcp_topic.php index 1d2030edb1..d0e4a2e057 100644 --- a/phpBB/includes/mcp/mcp_topic.php +++ b/phpBB/includes/mcp/mcp_topic.php @@ -21,7 +21,7 @@ if (!defined('IN_PHPBB')) function mcp_topic_view($id, $mode, $action) { global $phpEx, $phpbb_root_path, $config; - global $template, $db, $user, $auth, $cache; + global $template, $db, $user, $auth, $cache, $phpbb_container; $url = append_sid("{$phpbb_root_path}mcp.$phpEx?" . extra_url()); @@ -112,10 +112,11 @@ function mcp_topic_view($id, $mode, $action) mcp_sorting('viewtopic', $sort_days, $sort_key, $sort_dir, $sort_by_sql, $sort_order_sql, $total, $topic_info['forum_id'], $topic_id, $where_sql); $limit_time_sql = ($sort_days) ? 'AND p.post_time >= ' . (time() - ($sort_days * 86400)) : ''; + $phpbb_content_visibility = $phpbb_container->get('content.visibility'); if ($total == -1) { - $total = phpbb_content_visibility::get_count('topic_posts', $topic_info, $topic_info['forum_id']); + $total = $phpbb_content_visibility->get_count('topic_posts', $topic_info, $topic_info['forum_id']); } $posts_per_page = max(0, request_var('posts_per_page', intval($config['posts_per_page']))); @@ -139,7 +140,7 @@ function mcp_topic_view($id, $mode, $action) FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . ' u WHERE ' . (($action == 'reports') ? 'p.post_reported = 1 AND ' : '') . ' p.topic_id = ' . $topic_id . ' - AND ' . phpbb_content_visibility::get_visibility_sql('post', $topic_info['forum_id'], 'p.') . ' + AND ' . $phpbb_content_visibility->get_visibility_sql('post', $topic_info['forum_id'], 'p.') . ' AND p.poster_id = u.user_id ' . $limit_time_sql . ' ORDER BY ' . $sort_order_sql; diff --git a/phpBB/includes/ucp/ucp_main.php b/phpBB/includes/ucp/ucp_main.php index 7aa06464b7..615b567134 100644 --- a/phpBB/includes/ucp/ucp_main.php +++ b/phpBB/includes/ucp/ucp_main.php @@ -642,7 +642,7 @@ class ucp_main */ function assign_topiclist($mode = 'subscribed', $forbidden_forum_ary = array()) { - global $user, $db, $template, $config, $cache, $auth, $phpbb_root_path, $phpEx; + global $user, $db, $template, $config, $cache, $auth, $phpbb_root_path, $phpEx, $phpbb_container; $table = ($mode == 'subscribed') ? TOPICS_WATCH_TABLE : BOOKMARKS_TABLE; $start = request_var('start', 0); @@ -768,6 +768,8 @@ class ucp_main } } + $phpbb_content_visibility = $phpbb_container->get('content.visibility'); + foreach ($topic_list as $topic_id) { $row = &$rowset[$topic_id]; @@ -778,7 +780,7 @@ class ucp_main $unread_topic = (isset($topic_tracking_info[$topic_id]) && $row['topic_last_post_time'] > $topic_tracking_info[$topic_id]) ? true : false; // Replies - $replies = phpbb_content_visibility::get_count('topic_posts', $row, $forum_id) - 1; + $replies = $phpbb_content_visibility->get_count('topic_posts', $row, $forum_id) - 1; if ($row['topic_status'] == ITEM_MOVED && !empty($row['topic_moved_id'])) { diff --git a/phpBB/mcp.php b/phpBB/mcp.php index a0e106e27d..5beea45c7d 100644 --- a/phpBB/mcp.php +++ b/phpBB/mcp.php @@ -502,7 +502,7 @@ function get_post_data($post_ids, $acl_list = false, $read_tracking = false) */ function get_forum_data($forum_id, $acl_list = 'f_list', $read_tracking = false) { - global $auth, $db, $user, $config; + global $auth, $db, $user, $config, $phpbb_container; $rowset = array(); @@ -532,6 +532,8 @@ function get_forum_data($forum_id, $acl_list = 'f_list', $read_tracking = false) WHERE " . $db->sql_in_set('f.forum_id', $forum_id); $result = $db->sql_query($sql); + $phpbb_content_visibility = $phpbb_container->get('content.visibility'); + while ($row = $db->sql_fetchrow($result)) { if ($acl_list && !$auth->acl_gets($acl_list, $row['forum_id'])) @@ -539,7 +541,7 @@ function get_forum_data($forum_id, $acl_list = 'f_list', $read_tracking = false) continue; } - $row['forum_topics_approved'] = phpbb_content_visibility::get_count('forum_topics', $row, $row['forum_id']); + $row['forum_topics_approved'] = $phpbb_content_visibility->get_count('forum_topics', $row, $row['forum_id']); $rowset[$row['forum_id']] = $row; } diff --git a/phpBB/posting.php b/phpBB/posting.php index d5bb536753..ac459197b3 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -98,6 +98,8 @@ if (in_array($mode, array('post', 'reply', 'quote', 'edit', 'delete')) && !$foru trigger_error('NO_FORUM'); } +$phpbb_content_visibility = $phpbb_container->get('content.visibility'); + // We need to know some basic information in all cases before we do anything. switch ($mode) { @@ -128,7 +130,7 @@ switch ($mode) FROM ' . TOPICS_TABLE . ' t, ' . FORUMS_TABLE . " f WHERE t.topic_id = $topic_id AND f.forum_id = t.forum_id - AND " . phpbb_content_visibility::get_visibility_sql('topic', $forum_id, 't.'); + AND " . $phpbb_content_visibility->get_visibility_sql('topic', $forum_id, 't.'); break; case 'quote': @@ -157,7 +159,7 @@ switch ($mode) AND t.topic_id = p.topic_id AND u.user_id = p.poster_id AND f.forum_id = t.forum_id - AND " . phpbb_content_visibility::get_visibility_sql('post', $forum_id, 'p.'); + AND " . $phpbb_content_visibility->get_visibility_sql('post', $forum_id, 'p.'); break; case 'smilies': @@ -304,7 +306,7 @@ switch ($mode) break; case 'soft_delete': - if ($user->data['is_registered'] && phpbb_content_visibility::can_soft_delete($forum_id, $post_data['poster_id'], $post_data['post_edit_locked'])) + if ($user->data['is_registered'] && $phpbb_content_visibility->can_soft_delete($forum_id, $post_data['poster_id'], $post_data['post_edit_locked'])) { $is_authed = true; } @@ -931,7 +933,7 @@ if ($submit || $preview || $refresh) { $is_first_post = ($post_id == $post_data['topic_first_post_id'] || !$post_data['topic_posts_approved']); $is_last_post = ($post_id == $post_data['topic_last_post_id'] || !$post_data['topic_posts_approved']); - $updated_post_data = phpbb_content_visibility::set_post_visibility(ITEM_APPROVED, $post_id, $post_data['topic_id'], $post_data['forum_id'], $user->data['user_id'], time(), '', $is_first_post, $is_last_post); + $updated_post_data = $phpbb_content_visibility->set_post_visibility(ITEM_APPROVED, $post_id, $post_data['topic_id'], $post_data['forum_id'], $user->data['user_id'], time(), '', $is_first_post, $is_last_post); if (!empty($updated_post_data)) { @@ -1490,7 +1492,7 @@ $template->assign_vars(array( 'S_LOCK_POST_CHECKED' => ($lock_post_checked) ? ' checked="checked"' : '', 'S_SOFTDELETE_CHECKED' => ($mode == 'edit' && $post_data['post_visibility'] == ITEM_DELETED) ? ' checked="checked"' : '', 'S_DELETE_REASON' => ($mode == 'edit' && $auth->acl_get('m_softdelete', $forum_id)) ? true : false, - 'S_SOFTDELETE_ALLOWED' => ($mode == 'edit' && phpbb_content_visibility::can_soft_delete($forum_id, $post_data['poster_id'], $lock_post_checked)) ? true : false, + 'S_SOFTDELETE_ALLOWED' => ($mode == 'edit' && $phpbb_content_visibility->can_soft_delete($forum_id, $post_data['poster_id'], $lock_post_checked)) ? true : false, 'S_RESTORE_ALLOWED' => $auth->acl_get('m_approve', $forum_id), 'S_IS_DELETED' => ($mode == 'edit' && $post_data['post_visibility'] == ITEM_DELETED) ? true : false, 'S_LINKS_ALLOWED' => $url_status, diff --git a/phpBB/search.php b/phpBB/search.php index 585bd61f0a..2429c81dae 100644 --- a/phpBB/search.php +++ b/phpBB/search.php @@ -119,6 +119,8 @@ $sort_by_text = array('a' => $user->lang['SORT_AUTHOR'], 't' => $user->lang['SOR $s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = ''; gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param); +$phpbb_content_visibility = $phpbb_container->get('content.visibility'); + if ($keywords || $author || $author_id || $search_id || $submit) { // clear arrays @@ -250,8 +252,8 @@ if ($keywords || $author || $author_id || $search_id || $submit) $db->sql_freeresult($result); // find out in which forums the user is allowed to view posts - $m_approve_posts_fid_sql = phpbb_content_visibility::get_global_visibility_sql('post', $ex_fid_ary, 'p.'); - $m_approve_topics_fid_sql = phpbb_content_visibility::get_global_visibility_sql('topic', $ex_fid_ary, 't.'); + $m_approve_posts_fid_sql = $phpbb_content_visibility->get_global_visibility_sql('post', $ex_fid_ary, 'p.'); + $m_approve_topics_fid_sql = $phpbb_content_visibility->get_global_visibility_sql('topic', $ex_fid_ary, 't.'); if ($reset_search_forum) { @@ -860,7 +862,7 @@ if ($keywords || $author || $author_id || $search_id || $submit) $forum_id = $row['forum_id']; $result_topic_id = $row['topic_id']; $topic_title = censor_text($row['topic_title']); - $replies = phpbb_content_visibility::get_count('topic_posts', $row, $forum_id) - 1; + $replies = $phpbb_content_visibility->get_count('topic_posts', $row, $forum_id) - 1; $view_topic_url_params = "f=$forum_id&t=$result_topic_id" . (($u_hilit) ? "&hilit=$u_hilit" : ''); $view_topic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", $view_topic_url_params); diff --git a/phpBB/viewforum.php b/phpBB/viewforum.php index c180bd098d..4128fbdfeb 100644 --- a/phpBB/viewforum.php +++ b/phpBB/viewforum.php @@ -246,11 +246,13 @@ $sort_by_sql = array('a' => 't.topic_first_poster_name', 't' => 't.topic_last_po $s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = ''; gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param, $default_sort_days, $default_sort_key, $default_sort_dir); +$phpbb_content_visibility = $phpbb_container->get('content.visibility'); + // Limit topics to certain time frame, obtain correct topic count if ($sort_days) { $min_post_time = time() - ($sort_days * 86400); - $sql_visibility = phpbb_content_visibility::get_visibility_sql('topic', $forum_id); + $sql_visibility = $phpbb_content_visibility->get_visibility_sql('topic', $forum_id); $sql = 'SELECT COUNT(topic_id) AS num_topics FROM ' . TOPICS_TABLE . " @@ -274,7 +276,7 @@ if ($sort_days) } else { - $topics_count = phpbb_content_visibility::get_count('forum_topics', $forum_data, $forum_id); + $topics_count = $phpbb_content_visibility->get_count('forum_topics', $forum_data, $forum_id); $sql_limit_time = ''; } @@ -371,7 +373,7 @@ $sql_array = array( 'LEFT_JOIN' => array(), ); -$sql_approved = phpbb_content_visibility::get_visibility_sql('topic', $forum_id, 't.'); +$sql_approved = $phpbb_content_visibility->get_visibility_sql('topic', $forum_id, 't.'); $sql_approved = ($sql_approved) ? ' AND ' . $sql_approved : ''; if ($user->data['is_registered']) @@ -685,7 +687,7 @@ if (sizeof($topic_list)) $s_type_switch_test = ($row['topic_type'] == POST_ANNOUNCE || $row['topic_type'] == POST_GLOBAL) ? 1 : 0; // Replies - $replies = phpbb_content_visibility::get_count('topic_posts', $row, $topic_forum_id) - 1; + $replies = $phpbb_content_visibility->get_count('topic_posts', $row, $topic_forum_id) - 1; if ($row['topic_status'] == ITEM_MOVED) { diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index a73db3938d..db8a192180 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -55,6 +55,8 @@ if (!$topic_id && !$post_id) trigger_error('NO_TOPIC'); } +$phpbb_content_visibility = $phpbb_container->get('content.visibility'); + // Find topic id if user requested a newer or older topic if ($view && !$post_id) { @@ -79,7 +81,7 @@ if ($view && !$post_id) $topic_tracking_info = get_complete_topic_tracking($forum_id, $topic_id); $topic_last_read = (isset($topic_tracking_info[$topic_id])) ? $topic_tracking_info[$topic_id] : 0; - $sql_visibility = phpbb_content_visibility::get_visibility_sql('post', $forum_id); + $sql_visibility = $phpbb_content_visibility->get_visibility_sql('post', $forum_id); $sql = 'SELECT post_id, topic_id, forum_id FROM ' . POSTS_TABLE . " @@ -133,7 +135,7 @@ if ($view && !$post_id) } else { - $sql_visibility = phpbb_content_visibility::get_visibility_sql('topic', $row['forum_id']); + $sql_visibility = $phpbb_content_visibility->get_visibility_sql('topic', $row['forum_id']); $sql = 'SELECT topic_id, forum_id FROM ' . TOPICS_TABLE . ' @@ -275,7 +277,7 @@ if ($post_id) if ($sort_dir == $check_sort) { - $topic_data['prev_posts'] = phpbb_content_visibility::get_count('topic_posts', $topic_data, $forum_id) - 1; + $topic_data['prev_posts'] = $phpbb_content_visibility->get_count('topic_posts', $topic_data, $forum_id) - 1; } else { @@ -284,7 +286,7 @@ if ($post_id) } else { - $sql_visibility = phpbb_content_visibility::get_visibility_sql('post', $forum_id, 'p.'); + $sql_visibility = $phpbb_content_visibility->get_visibility_sql('post', $forum_id, 'p.'); $sql = 'SELECT COUNT(p.post_id) AS prev_posts FROM ' . POSTS_TABLE . " p @@ -309,7 +311,7 @@ if ($post_id) } $topic_id = (int) $topic_data['topic_id']; -$topic_replies = phpbb_content_visibility::get_count('topic_posts', $topic_data, $forum_id) - 1; +$topic_replies = $phpbb_content_visibility->get_count('topic_posts', $topic_data, $forum_id) - 1; // Check sticky/announcement time limit if (($topic_data['topic_type'] == POST_STICKY || $topic_data['topic_type'] == POST_ANNOUNCE) && $topic_data['topic_time_limit'] && ($topic_data['topic_time'] + $topic_data['topic_time_limit']) < time()) @@ -403,7 +405,7 @@ gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $ if ($sort_days) { $min_post_time = time() - ($sort_days * 86400); - $sql_visibility = phpbb_content_visibility::get_visibility_sql('post', $forum_id); + $sql_visibility = $phpbb_content_visibility->get_visibility_sql('post', $forum_id); $sql = 'SELECT COUNT(post_id) AS num_posts FROM ' . POSTS_TABLE . " @@ -944,7 +946,7 @@ $bbcode_bitfield = ''; $i = $i_total = 0; // Go ahead and pull all data for this topic -$sql_visibility = phpbb_content_visibility::get_visibility_sql('post', $forum_id, 'p.'); +$sql_visibility = $phpbb_content_visibility->get_visibility_sql('post', $forum_id, 'p.'); $sql = 'SELECT p.post_id FROM ' . POSTS_TABLE . ' p' . (($join_user_sql[$sort_key]) ? ', ' . USERS_TABLE . ' u': '') . " From 753dc62267118e44b16653113521fe6d0a360720 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 11 Jul 2013 15:02:07 +0200 Subject: [PATCH 2086/2494] [ticket/9657] Fix unit tests PHPBB3-9657 --- phpBB/includes/content_visibility.php | 20 +++++++++---------- tests/content_visibility/delete_post_test.php | 10 ++++++---- .../get_forums_visibility_sql_test.php | 6 ++++-- .../get_global_visibility_sql_test.php | 5 +++-- .../get_visibility_sql_test.php | 5 +++-- .../set_post_visibility_test.php | 6 ++++-- .../set_topic_visibility_test.php | 6 ++++-- 7 files changed, 34 insertions(+), 24 deletions(-) diff --git a/phpBB/includes/content_visibility.php b/phpBB/includes/content_visibility.php index edf6aa3b31..43efef5d7f 100644 --- a/phpBB/includes/content_visibility.php +++ b/phpBB/includes/content_visibility.php @@ -26,19 +26,19 @@ class phpbb_content_visibility * Database object * @var phpbb_db_driver */ - protected $this->db; + protected $db; /** * User object * @var phpbb_user */ - protected $this->user; + protected $user; /** * Auth object * @var phpbb_auth */ - protected $this->auth; + protected $auth; /** * phpBB root path @@ -55,18 +55,18 @@ class phpbb_content_visibility /** * Constructor * - * @param phpbb_auth $this->auth Auth object - * @param phpbb_db_driver $this->db Database object - * @param phpbb_user $this->user User object + * @param phpbb_auth $auth Auth object + * @param phpbb_db_driver $db Database object + * @param phpbb_user $user User object * @param string $phpbb_root_path Root path * @param string $php_ext PHP Extension * @return null */ - public function __construct($this->auth, phpbb_db_driver $this->db, $this->user, $phpbb_root_path, $phpEx, $forums_table, $posts_table, $topics_table, $users_table) + public function __construct($auth, phpbb_db_driver $db, $user, $phpbb_root_path, $phpEx, $forums_table, $posts_table, $topics_table, $users_table) { - $this->auth = $this->auth; - $this->db = $this->db; - $this->user = $this->user; + $this->auth = $auth; + $this->db = $db; + $this->user = $user; $this->phpbb_root_path = $phpbb_root_path; $this->php_ext = $php_ext; $this->forums_table = $forums_table; diff --git a/tests/content_visibility/delete_post_test.php b/tests/content_visibility/delete_post_test.php index e7ab3e3879..6234aac9ad 100644 --- a/tests/content_visibility/delete_post_test.php +++ b/tests/content_visibility/delete_post_test.php @@ -262,16 +262,13 @@ class phpbb_content_visibility_delete_post_test extends phpbb_database_test_case */ public function test_delete_post($forum_id, $topic_id, $post_id, $data, $is_soft, $reason, $expected_posts, $expected_topic, $expected_forum) { - global $auth, $cache, $config, $db, $phpbb_container; + global $auth, $cache, $config, $db, $phpbb_container, $phpbb_root_path, $phpEx; $config['search_type'] = 'phpbb_mock_search'; $cache = new phpbb_mock_cache; $db = $this->new_dbal(); set_config_count(null, null, null, new phpbb_config(array('num_posts' => 3, 'num_topics' => 1))); - $phpbb_container = new phpbb_mock_container_builder(); - $phpbb_container->set('notification_manager', new phpbb_mock_notification_manager()); - // Create auth mock $auth = $this->getMock('phpbb_auth'); $auth->expects($this->any()) @@ -280,6 +277,11 @@ class phpbb_content_visibility_delete_post_test extends phpbb_database_test_case ->will($this->returnValueMap(array( array('m_approve', 1, true), ))); + $user = $this->getMock('phpbb_user'); + + $phpbb_container = new phpbb_mock_container_builder(); + $phpbb_container->set('notification_manager', new phpbb_mock_notification_manager()); + $phpbb_container->set('content.visibility', new phpbb_content_visibility($auth, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE)); delete_post($forum_id, $topic_id, $post_id, $data, $is_soft, $reason); diff --git a/tests/content_visibility/get_forums_visibility_sql_test.php b/tests/content_visibility/get_forums_visibility_sql_test.php index 236b08f74c..7580a53fa4 100644 --- a/tests/content_visibility/get_forums_visibility_sql_test.php +++ b/tests/content_visibility/get_forums_visibility_sql_test.php @@ -119,7 +119,7 @@ class phpbb_content_visibility_get_forums_visibility_sql_test extends phpbb_data */ public function test_get_forums_visibility_sql($table, $mode, $forum_ids, $table_alias, $permissions, $expected) { - global $cache, $db, $auth; + global $cache, $db, $auth, $phpbb_root_path, $phpEx; $cache = new phpbb_mock_cache; $db = $this->new_dbal(); @@ -131,9 +131,11 @@ class phpbb_content_visibility_get_forums_visibility_sql_test extends phpbb_data ->with($this->stringContains('_'), $this->anything()) ->will($this->returnValueMap($permissions)); + $content_visibility = new phpbb_content_visibility($auth, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE); + $result = $db->sql_query('SELECT ' . $mode . '_id FROM ' . $table . ' - WHERE ' . phpbb_content_visibility::get_forums_visibility_sql($mode, $forum_ids, $table_alias) . ' + WHERE ' . $content_visibility->get_forums_visibility_sql($mode, $forum_ids, $table_alias) . ' ORDER BY ' . $mode . '_id ASC'); $this->assertEquals($expected, $db->sql_fetchrowset($result)); diff --git a/tests/content_visibility/get_global_visibility_sql_test.php b/tests/content_visibility/get_global_visibility_sql_test.php index 9d320a4ee7..bdb0a96954 100644 --- a/tests/content_visibility/get_global_visibility_sql_test.php +++ b/tests/content_visibility/get_global_visibility_sql_test.php @@ -119,7 +119,7 @@ class phpbb_content_visibility_get_global_visibility_sql_test extends phpbb_data */ public function test_get_global_visibility_sql($table, $mode, $forum_ids, $table_alias, $permissions, $expected) { - global $cache, $db, $auth; + global $cache, $db, $auth, $phpbb_root_path, $phpEx; $cache = new phpbb_mock_cache; $db = $this->new_dbal(); @@ -130,10 +130,11 @@ class phpbb_content_visibility_get_global_visibility_sql_test extends phpbb_data ->method('acl_getf') ->with($this->stringContains('_'), $this->anything()) ->will($this->returnValueMap($permissions)); + $content_visibility = new phpbb_content_visibility($auth, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE); $result = $db->sql_query('SELECT ' . $mode . '_id FROM ' . $table . ' - WHERE ' . phpbb_content_visibility::get_global_visibility_sql($mode, $forum_ids, $table_alias) . ' + WHERE ' . $content_visibility->get_global_visibility_sql($mode, $forum_ids, $table_alias) . ' ORDER BY ' . $mode . '_id ASC'); $this->assertEquals($expected, $db->sql_fetchrowset($result)); diff --git a/tests/content_visibility/get_visibility_sql_test.php b/tests/content_visibility/get_visibility_sql_test.php index 4af8c062e7..f75c98f899 100644 --- a/tests/content_visibility/get_visibility_sql_test.php +++ b/tests/content_visibility/get_visibility_sql_test.php @@ -66,7 +66,7 @@ class phpbb_content_visibility_get_visibility_sql_test extends phpbb_database_te */ public function test_get_visibility_sql($table, $mode, $forum_id, $table_alias, $permissions, $expected) { - global $cache, $db, $auth; + global $cache, $db, $auth, $phpbb_root_path, $phpEx; $cache = new phpbb_mock_cache; $db = $this->new_dbal(); @@ -77,10 +77,11 @@ class phpbb_content_visibility_get_visibility_sql_test extends phpbb_database_te ->method('acl_get') ->with($this->stringContains('_'), $this->anything()) ->will($this->returnValueMap($permissions)); + $content_visibility = new phpbb_content_visibility($auth, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE); $result = $db->sql_query('SELECT ' . $mode . '_id FROM ' . $table . ' - WHERE ' . phpbb_content_visibility::get_visibility_sql($mode, $forum_id, $table_alias) . ' + WHERE ' . $content_visibility->get_visibility_sql($mode, $forum_id, $table_alias) . ' ORDER BY ' . $mode . '_id ASC'); $this->assertEquals($expected, $db->sql_fetchrowset($result)); diff --git a/tests/content_visibility/set_post_visibility_test.php b/tests/content_visibility/set_post_visibility_test.php index 8f83457cae..845430b21b 100644 --- a/tests/content_visibility/set_post_visibility_test.php +++ b/tests/content_visibility/set_post_visibility_test.php @@ -115,12 +115,14 @@ class phpbb_content_visibility_set_post_visibility_test extends phpbb_database_t */ public function test_set_post_visibility($visibility, $post_id, $topic_id, $forum_id, $user_id, $time, $reason, $is_starter, $is_latest, $expected, $expected_topic) { - global $cache, $db; + global $cache, $db, $auth, $phpbb_root_path, $phpEx; $cache = new phpbb_mock_cache; $db = $this->new_dbal(); + $auth = $this->getMock('phpbb_auth'); + $content_visibility = new phpbb_content_visibility($auth, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE); - phpbb_content_visibility::set_post_visibility($visibility, $post_id, $topic_id, $forum_id, $user_id, $time, $reason, $is_starter, $is_latest); + $content_visibility->set_post_visibility($visibility, $post_id, $topic_id, $forum_id, $user_id, $time, $reason, $is_starter, $is_latest); $result = $db->sql_query('SELECT post_id, post_visibility, post_delete_reason FROM phpbb_posts diff --git a/tests/content_visibility/set_topic_visibility_test.php b/tests/content_visibility/set_topic_visibility_test.php index 31a6b37caa..3061ba44db 100644 --- a/tests/content_visibility/set_topic_visibility_test.php +++ b/tests/content_visibility/set_topic_visibility_test.php @@ -79,12 +79,14 @@ class phpbb_content_visibility_set_topic_visibility_test extends phpbb_database_ */ public function test_set_topic_visibility($visibility, $topic_id, $forum_id, $user_id, $time, $reason, $force_update_all, $expected_posts, $expected_topic) { - global $cache, $db; + global $cache, $db, $auth, $phpbb_root_path, $phpEx; $cache = new phpbb_mock_cache; $db = $this->new_dbal(); + $auth = $this->getMock('phpbb_auth'); + $content_visibility = new phpbb_content_visibility($auth, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE); - phpbb_content_visibility::set_topic_visibility($visibility, $topic_id, $forum_id, $user_id, $time, $reason, $force_update_all); + $content_visibility->set_topic_visibility($visibility, $topic_id, $forum_id, $user_id, $time, $reason, $force_update_all); $result = $db->sql_query('SELECT post_id, post_visibility, post_delete_reason FROM phpbb_posts From 7262045a24a6823e4da71868c14f16b438098caa Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 11 Jul 2013 15:19:39 +0200 Subject: [PATCH 2087/2494] [ticket/9657] Fix notification tests PHPBB3-9657 --- tests/notification/submit_post_base.php | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/notification/submit_post_base.php b/tests/notification/submit_post_base.php index 59daf6c9cb..4e564ce23c 100644 --- a/tests/notification/submit_post_base.php +++ b/tests/notification/submit_post_base.php @@ -96,6 +96,7 @@ class phpbb_notification_submit_post_base extends phpbb_database_test_case // Container $phpbb_container = new phpbb_mock_container_builder(); + $phpbb_container->set('content.visibility', new phpbb_content_visibility($auth, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE)); $user_loader = new phpbb_user_loader($db, $phpbb_root_path, $phpEx, USERS_TABLE); From 99c7483ade84e492f7bffb72cc2463fce2f65b94 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Thu, 11 Jul 2013 08:36:16 -0500 Subject: [PATCH 2088/2494] [ticket/11388] INCLUDEJS supports //(url) PHPBB3-11388 --- phpBB/includes/template/twig/node/includeasset.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/template/twig/node/includeasset.php b/phpBB/includes/template/twig/node/includeasset.php index 181e3b5aa5..647ae22d81 100644 --- a/phpBB/includes/template/twig/node/includeasset.php +++ b/phpBB/includes/template/twig/node/includeasset.php @@ -48,7 +48,7 @@ class phpbb_template_twig_node_includeasset extends Twig_Node ->write("\$argument_string .= '&assets_version=" . $config['assets_version'] . "';\n") ->outdent() ->write("}\n") - ->write("if (strpos(\$asset_file, 'http://') !== 0 && strpos(\$asset_file, 'https://') !== 0 && !file_exists(\$asset_file)) {\n") + ->write("if (strpos(\$asset_file, '//') !== 0 && strpos(\$asset_file, 'http://') !== 0 && strpos(\$asset_file, 'https://') !== 0 && !file_exists(\$asset_file)) {\n") ->indent() ->write("\$asset_file = \$this->getEnvironment()->getLoader()->getCacheKey(\$asset_file);\n") ->outdent() From 648e1e51fad1c2198a30f62c50d7d2272134c399 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Thu, 11 Jul 2013 08:44:48 -0500 Subject: [PATCH 2089/2494] [ticket/11388] INCLUDEJS test for //(url) PHPBB3-11388 --- tests/template/template_includejs_test.php | 4 ++++ tests/template/templates/includejs.html | 2 ++ 2 files changed, 6 insertions(+) diff --git a/tests/template/template_includejs_test.php b/tests/template/template_includejs_test.php index b644c8b6f0..d4a384a1c5 100644 --- a/tests/template/template_includejs_test.php +++ b/tests/template/template_includejs_test.php @@ -84,6 +84,10 @@ class phpbb_template_template_includejs_test extends phpbb_template_template_tes array('TEST' => 16), '', ), + array( + array('TEST' => 17), + '', + ), ); } diff --git a/tests/template/templates/includejs.html b/tests/template/templates/includejs.html index 030681337b..3bcad76af5 100644 --- a/tests/template/templates/includejs.html +++ b/tests/template/templates/includejs.html @@ -32,5 +32,7 @@ + + {$SCRIPTS} From 7a34c7eabe4712333e3a96754a836949ecfe4306 Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Thu, 23 May 2013 11:55:04 +0300 Subject: [PATCH 2090/2494] [ticket/11563] Fix subPanels() Fix subPanels() code Modernize subPanels() with jQuery Use HTML5 data attributes instead of including JS PHPBB3-11563 --- phpBB/styles/prosilver/template/forum_fn.js | 56 ++++++++++++------- .../styles/prosilver/template/mcp_topic.html | 23 +++----- .../prosilver/template/posting_editor.html | 8 +-- .../prosilver/template/posting_layout.html | 7 --- 4 files changed, 47 insertions(+), 47 deletions(-) diff --git a/phpBB/styles/prosilver/template/forum_fn.js b/phpBB/styles/prosilver/template/forum_fn.js index bb29f00490..d4a4f3e83d 100644 --- a/phpBB/styles/prosilver/template/forum_fn.js +++ b/phpBB/styles/prosilver/template/forum_fn.js @@ -106,32 +106,48 @@ function dE(n, s, type) { /** * Alternate display of subPanels */ -function subPanels(p) { - var i, e, t; +jQuery(document).ready(function() { + jQuery('.sub-panels').each(function() { - if (typeof(p) === 'string') { - show_panel = p; - } + var panels = this.getAttribute('data-panels').split(','), + show_panel = this.getAttribute('data-show-panel'); - for (i = 0; i < panels.length; i++) { - e = document.getElementById(panels[i]); - t = document.getElementById(panels[i] + '-tab'); + if (panels.length) { + subPanels(show_panel); + jQuery('a[data-subpanel]', this).click(function () { + subPanels(this.getAttribute('data-subpanel')); + return false; + }); + } - if (e) { - if (panels[i] === show_panel) { - e.style.display = 'block'; - if (t) { - t.className = 'activetab'; - } - } else { - e.style.display = 'none'; - if (t) { - t.className = ''; + function subPanels(p) { + var i, e, t; + + if (typeof(p) === 'string') { + show_panel = p; + } + + for (i = 0; i < panels.length; i++) { + e = document.getElementById(panels[i]); + t = document.getElementById(panels[i] + '-tab'); + + if (e) { + if (panels[i] === show_panel) { + e.style.display = 'block'; + if (t) { + t.className = 'activetab'; + } + } else { + e.style.display = 'none'; + if (t) { + t.className = ''; + } + } } } } - } -} + }); +}); /** * Call print preview diff --git a/phpBB/styles/prosilver/template/mcp_topic.html b/phpBB/styles/prosilver/template/mcp_topic.html index 8dfee55cbf..130824b7b3 100644 --- a/phpBB/styles/prosilver/template/mcp_topic.html +++ b/phpBB/styles/prosilver/template/mcp_topic.html @@ -3,33 +3,24 @@

    {L_TOPIC}{L_COLON} {TOPIC_TITLE}

    - - -
    + diff --git a/phpBB/styles/prosilver/template/posting_editor.html b/phpBB/styles/prosilver/template/posting_editor.html index 3eac8fb03a..c381cfe0ed 100644 --- a/phpBB/styles/prosilver/template/posting_editor.html +++ b/phpBB/styles/prosilver/template/posting_editor.html @@ -193,11 +193,11 @@ -
    + diff --git a/phpBB/styles/prosilver/template/posting_layout.html b/phpBB/styles/prosilver/template/posting_layout.html index 4e9954ef81..c0bd0225de 100644 --- a/phpBB/styles/prosilver/template/posting_layout.html +++ b/phpBB/styles/prosilver/template/posting_layout.html @@ -79,12 +79,5 @@ - - - From 6599cabed7b52fd1822846e7fdc1e647058f9135 Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Thu, 23 May 2013 12:10:08 +0300 Subject: [PATCH 2091/2494] [ticket/11563] Remove unused JS variables Remove unused JS variables from posting_buttons PHPBB3-11563 --- phpBB/styles/prosilver/template/posting_buttons.html | 3 --- 1 file changed, 3 deletions(-) diff --git a/phpBB/styles/prosilver/template/posting_buttons.html b/phpBB/styles/prosilver/template/posting_buttons.html index fadbc9b3ca..2e96a404f3 100644 --- a/phpBB/styles/prosilver/template/posting_buttons.html +++ b/phpBB/styles/prosilver/template/posting_buttons.html @@ -32,9 +32,6 @@ } - var panels = new Array('options-panel', 'attach-panel', 'poll-panel'); - var show_panel = 'options-panel'; - function change_palette() { dE('colour_palette'); From 3c11052fb3896b43685f596dc6e52f9cc07d6807 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Thu, 11 Jul 2013 10:54:55 -0400 Subject: [PATCH 2092/2494] [feature/auth-refactor] Have a base auth class PHPBB3-9734 --- phpBB/includes/auth/provider/apache.php | 19 +------ phpBB/includes/auth/provider/base.php | 69 +++++++++++++++++++++++++ phpBB/includes/auth/provider/db.php | 43 +-------------- phpBB/includes/auth/provider/ldap.php | 27 +--------- 4 files changed, 75 insertions(+), 83 deletions(-) create mode 100644 phpBB/includes/auth/provider/base.php diff --git a/phpBB/includes/auth/provider/apache.php b/phpBB/includes/auth/provider/apache.php index 5f6f2862b6..e0217725d6 100644 --- a/phpBB/includes/auth/provider/apache.php +++ b/phpBB/includes/auth/provider/apache.php @@ -20,7 +20,8 @@ if (!defined('IN_PHPBB')) * * @package auth */ -class phpbb_auth_provider_apache implements phpbb_auth_provider_interface +class phpbb_auth_provider_apache extends phpbb_auth_provider_base + implements phpbb_auth_provider_interface { /** * Apache Authentication Constructor @@ -256,20 +257,4 @@ class phpbb_auth_provider_apache implements phpbb_auth_provider_interface return false; } - - /** - * {@inheritdoc} - */ - public function acp($new) - { - return; - } - - /** - * {@inheritdoc} - */ - public function logout($data, $new_session) - { - return; - } } diff --git a/phpBB/includes/auth/provider/base.php b/phpBB/includes/auth/provider/base.php new file mode 100644 index 0000000000..e053a1829b --- /dev/null +++ b/phpBB/includes/auth/provider/base.php @@ -0,0 +1,69 @@ +php_ext = $php_ext; } - /** - * {@inheritdoc} - */ - public function init() - { - return; - } - /** * {@inheritdoc} */ @@ -302,36 +295,4 @@ class phpbb_auth_provider_db implements phpbb_auth_provider_interface 'user_row' => $row, ); } - - /** - * {@inheritdoc} - */ - public function autologin() - { - return; - } - - /** - * {@inheritdoc} - */ - public function acp($new) - { - return; - } - - /** - * {@inheritdoc} - */ - public function logout($data, $new_session) - { - return; - } - - /** - * {@inheritdoc} - */ - public function validate_session($user) - { - return; - } } diff --git a/phpBB/includes/auth/provider/ldap.php b/phpBB/includes/auth/provider/ldap.php index f67c1e9247..dbb569f466 100644 --- a/phpBB/includes/auth/provider/ldap.php +++ b/phpBB/includes/auth/provider/ldap.php @@ -22,7 +22,8 @@ if (!defined('IN_PHPBB')) * * @package auth */ -class phpbb_auth_provider_ldap implements phpbb_auth_provider_interface +class phpbb_auth_provider_ldap extends phpbb_auth_provider_base + implements phpbb_auth_provider_interface { /** * LDAP Authentication Constructor @@ -283,14 +284,6 @@ class phpbb_auth_provider_ldap implements phpbb_auth_provider_interface ); } - /** - * {@inheritdoc} - */ - public function autologin() - { - return; - } - /** * {@inheritdoc} */ @@ -367,20 +360,4 @@ class phpbb_auth_provider_ldap implements phpbb_auth_provider_interface { return str_replace(array('*', '\\', '(', ')'), array('\\*', '\\\\', '\\(', '\\)'), $string); } - - /** - * {@inheritdoc} - */ - public function logout($data, $new_session) - { - return; - } - - /** - * {@inheritdoc} - */ - public function validate_session($user) - { - return; - } } From a9259b12aa07057c3b9e3575b1429b16bfdb9509 Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Thu, 11 Jul 2013 10:58:18 -0400 Subject: [PATCH 2093/2494] [ticket/11563] Dynamically generate panels list PHPBB3-11563 --- phpBB/styles/prosilver/template/forum_fn.js | 5 ++++- phpBB/styles/prosilver/template/mcp_topic.html | 2 +- phpBB/styles/prosilver/template/posting_editor.html | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/phpBB/styles/prosilver/template/forum_fn.js b/phpBB/styles/prosilver/template/forum_fn.js index d4a4f3e83d..0f11fd7b7a 100644 --- a/phpBB/styles/prosilver/template/forum_fn.js +++ b/phpBB/styles/prosilver/template/forum_fn.js @@ -109,7 +109,10 @@ function dE(n, s, type) { jQuery(document).ready(function() { jQuery('.sub-panels').each(function() { - var panels = this.getAttribute('data-panels').split(','), + var panels = [], + childNodes = jQuery('a[data-subpanel]', this).each(function() { + panels.push(this.getAttribute('data-subpanel')); + }), show_panel = this.getAttribute('data-show-panel'); if (panels.length) { diff --git a/phpBB/styles/prosilver/template/mcp_topic.html b/phpBB/styles/prosilver/template/mcp_topic.html index 130824b7b3..5d4270c2d3 100644 --- a/phpBB/styles/prosilver/template/mcp_topic.html +++ b/phpBB/styles/prosilver/template/mcp_topic.html @@ -11,7 +11,7 @@ -
    +
    • class="activetab"> {L_DISPLAY_OPTIONS} diff --git a/phpBB/styles/prosilver/template/posting_editor.html b/phpBB/styles/prosilver/template/posting_editor.html index c381cfe0ed..2e6f291913 100644 --- a/phpBB/styles/prosilver/template/posting_editor.html +++ b/phpBB/styles/prosilver/template/posting_editor.html @@ -193,7 +193,7 @@ -
      +
      • {L_OPTIONS}
      • {L_ADD_ATTACHMENT}
      • From 1d9794559354d7c52da7751e5d1fdcb17fe949e5 Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Thu, 11 Jul 2013 11:00:04 -0400 Subject: [PATCH 2094/2494] [ticket/11563] Remove duplicate code PHPBB3-11563 --- phpBB/styles/prosilver/template/forum_fn.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/styles/prosilver/template/forum_fn.js b/phpBB/styles/prosilver/template/forum_fn.js index 0f11fd7b7a..1ab1387d10 100644 --- a/phpBB/styles/prosilver/template/forum_fn.js +++ b/phpBB/styles/prosilver/template/forum_fn.js @@ -117,7 +117,7 @@ jQuery(document).ready(function() { if (panels.length) { subPanels(show_panel); - jQuery('a[data-subpanel]', this).click(function () { + childNodes.click(function () { subPanels(this.getAttribute('data-subpanel')); return false; }); From 69c1b1aea89f3c705c19d69aab70c35a7d09747a Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Thu, 11 Jul 2013 11:06:34 -0400 Subject: [PATCH 2095/2494] [feature/auth-refactor] Prevent fatal error in php < 5.3.23 PHPBB3-9734 --- phpBB/includes/auth/provider/base.php | 5 ----- 1 file changed, 5 deletions(-) diff --git a/phpBB/includes/auth/provider/base.php b/phpBB/includes/auth/provider/base.php index e053a1829b..7961bf4dde 100644 --- a/phpBB/includes/auth/provider/base.php +++ b/phpBB/includes/auth/provider/base.php @@ -30,11 +30,6 @@ abstract class phpbb_auth_provider_base implements phpbb_auth_provider_interface return; } - /** - * {@inheritdoc} - */ - abstract public function login($username, $password); - /** * {@inheritdoc} */ From 021eb083abc1fe11d18d756adf12f72b903b13ed Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Thu, 11 Jul 2013 11:09:25 -0400 Subject: [PATCH 2096/2494] [feature/auth-refactor] Remove implements on classes extending base PHPBB3-9734 --- phpBB/includes/auth/provider/apache.php | 1 - phpBB/includes/auth/provider/db.php | 3 +-- phpBB/includes/auth/provider/ldap.php | 1 - 3 files changed, 1 insertion(+), 4 deletions(-) diff --git a/phpBB/includes/auth/provider/apache.php b/phpBB/includes/auth/provider/apache.php index e0217725d6..2e80436f78 100644 --- a/phpBB/includes/auth/provider/apache.php +++ b/phpBB/includes/auth/provider/apache.php @@ -21,7 +21,6 @@ if (!defined('IN_PHPBB')) * @package auth */ class phpbb_auth_provider_apache extends phpbb_auth_provider_base - implements phpbb_auth_provider_interface { /** * Apache Authentication Constructor diff --git a/phpBB/includes/auth/provider/db.php b/phpBB/includes/auth/provider/db.php index b9b808cb5d..0934c56d9b 100644 --- a/phpBB/includes/auth/provider/db.php +++ b/phpBB/includes/auth/provider/db.php @@ -22,8 +22,7 @@ if (!defined('IN_PHPBB')) * * @package auth */ -class phpbb_auth_provider_db extends phpbb_auth_provider_base - implements phpbb_auth_provider_interface +class phpbb_auth_provider_db extends phpbb_auth_provider_base { /** diff --git a/phpBB/includes/auth/provider/ldap.php b/phpBB/includes/auth/provider/ldap.php index dbb569f466..e10986abf0 100644 --- a/phpBB/includes/auth/provider/ldap.php +++ b/phpBB/includes/auth/provider/ldap.php @@ -23,7 +23,6 @@ if (!defined('IN_PHPBB')) * @package auth */ class phpbb_auth_provider_ldap extends phpbb_auth_provider_base - implements phpbb_auth_provider_interface { /** * LDAP Authentication Constructor From 600d3bd1f61c83c339be56eac0aa5ee8e9353fbb Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Thu, 23 May 2013 11:02:29 +0300 Subject: [PATCH 2097/2494] [ticket/11553] Move bulletin points to pseudo class Move bulletin points for .linklist lists to pseudo class Group pseudo classes for .linklist.bulletin and .icon-notification PHPBB3-11553 --- phpBB/styles/prosilver/template/forum_fn.js | 19 +++++++++++ .../styles/prosilver/template/index_body.html | 11 +++++-- .../prosilver/template/overall_footer.html | 23 +++++++------ .../prosilver/template/overall_header.html | 15 +++++---- phpBB/styles/prosilver/theme/buttons.css | 14 ++------ phpBB/styles/prosilver/theme/common.css | 32 +++++++++++++++++++ 6 files changed, 85 insertions(+), 29 deletions(-) diff --git a/phpBB/styles/prosilver/template/forum_fn.js b/phpBB/styles/prosilver/template/forum_fn.js index bb29f00490..019536ef86 100644 --- a/phpBB/styles/prosilver/template/forum_fn.js +++ b/phpBB/styles/prosilver/template/forum_fn.js @@ -385,3 +385,22 @@ function apply_onkeypress_event() { } jQuery(document).ready(apply_onkeypress_event); + +/** +* Adjust HTML code for IE8 and older versions +*/ +(function($) { + $(document).ready(function() { + var test = document.createElement('div'), + oldBrowser = (typeof test.style.borderRadius == 'undefined'); + delete test; + + if (!oldBrowser) { + return; + } + + // Fix .linkslist.bulletin lists + $('ul.linklist.bulletin li:first-child, ul.linklist.bulletin li.rightside:last-child').addClass('no-bulletin'); + }); +})(jQuery); + diff --git a/phpBB/styles/prosilver/template/index_body.html b/phpBB/styles/prosilver/template/index_body.html index 57ad540a4a..e0a9279738 100644 --- a/phpBB/styles/prosilver/template/index_body.html +++ b/phpBB/styles/prosilver/template/index_body.html @@ -4,9 +4,16 @@

        {CURRENT_TIME}
        {L_MCP} ]

        {CURRENT_TIME}

        - - -

        1.iv. Changes since 3.0.7-PL1

        +

        1.v. Changes since 3.0.7-PL1

        Security

          @@ -1179,13 +1324,13 @@
        -

        1.iv. Changes since 3.0.7

        +

        1.vi. Changes since 3.0.7

        • [Sec] Do not expose forum content of forums with ACL entries but no actual permission in ATOM Feeds. (Bug #58595)
        -

        1.vi. Changes since 3.0.6

        +

        1.vii. Changes since 3.0.6

        • [Fix] Allow ban reason and length to be selected and copied in ACP and subsilver2 MCP. (Bug #51095)
        • @@ -1289,7 +1434,7 @@
        -

        1.vii. Changes since 3.0.5

        +

        1.viii. Changes since 3.0.5

        • [Fix] Allow whitespaces in avatar gallery names. (Bug #44955)
        • @@ -1511,7 +1656,7 @@
        • [Feature] Send anonymous statistical information to phpBB on installation and update (optional).
        -

        1.viii. Changes since 3.0.4

        +

        1.ix. Changes since 3.0.4

        • [Fix] Delete user entry from ban list table upon user deletion (Bug #40015 - Patch by TerraFrost)
        • @@ -1600,7 +1745,7 @@
        • [Sec] Only use forum id supplied for posting if global announcement detected. (Reported by nickvergessen)
        -

        1.ix. Changes since 3.0.3

        +

        1.x. Changes since 3.0.3

        • [Fix] Allow mixed-case template directories to be inherited (Bug #36725)
        • @@ -1632,7 +1777,7 @@
        • [Sec] Ask for forum password if post within passworded forum quoted in private message. (Reported by nickvergessen)
        -

        1.x. Changes since 3.0.2

        +

        1.xi. Changes since 3.0.2

        • [Fix] Correctly set topic starter if first post in topic removed (Bug #30575 - Patch by blueray2048)
        • @@ -1731,7 +1876,7 @@
        • [Sec Precaution] Stricter validation of the HTTP_HOST header (Thanks to Techie-Micheal et al for pointing out possible issues in derived code)
        -

        1.xi. Changes since 3.0.1

        +

        1.xii. Changes since 3.0.1

        • [Fix] Ability to set permissions on non-mysql dbms (Bug #24955)
        • @@ -1779,7 +1924,7 @@
        • [Sec] Only allow urls gone through redirect() being used within login_box(). (thanks nookieman)
        -

        1.xii Changes since 3.0.0

        +

        1.xiii Changes since 3.0.0

        • [Change] Validate birthdays (Bug #15004)
        • @@ -1850,7 +1995,7 @@
        • [Fix] Find and display colliding usernames correctly when converting from one database to another (Bug #23925)
        -

        1.xiii. Changes since 3.0.RC8

        +

        1.xiv. Changes since 3.0.RC8

        • [Fix] Cleaned usernames contain only single spaces, so "a_name" and "a__name" are treated as the same name (Bug #15634)
        • @@ -1859,7 +2004,7 @@
        • [Fix] Call garbage_collection() within database updater to correctly close connections (affects Oracle for example)
        -

        1.xiv. Changes since 3.0.RC7

        +

        1.xv. Changes since 3.0.RC7

        • [Fix] Fixed MSSQL related bug in the update system
        • @@ -1894,7 +2039,7 @@
        • [Fix] No duplication of active topics (Bug #15474)
        -

        1.xv. Changes since 3.0.RC6

        +

        1.xvi. Changes since 3.0.RC6

        • [Fix] Submitting language changes using acp_language (Bug #14736)
        • @@ -1904,7 +2049,7 @@
        • [Fix] Able to request new password (Bug #14743)
        -

        1.xvi. Changes since 3.0.RC5

        +

        1.xvii. Changes since 3.0.RC5

        • [Feature] Removing constant PHPBB_EMBEDDED in favor of using an exit_handler(); the constant was meant to achive this more or less.
        • @@ -1967,7 +2112,7 @@
        • [Sec] New password hashing mechanism for storing passwords (#i42)
        -

        1.xvii. Changes since 3.0.RC4

        +

        1.xviii. Changes since 3.0.RC4

        • [Fix] MySQL, PostgreSQL and SQLite related database fixes (Bug #13862)
        • @@ -2018,7 +2163,7 @@
        • [Fix] odbc_autocommit causing existing result sets to be dropped (Bug #14182)
        -

        1.xviii. Changes since 3.0.RC3

        +

        1.xix. Changes since 3.0.RC3

        • [Fix] Fixing some subsilver2 and prosilver style issues
        • @@ -2127,7 +2272,7 @@
        -

        1.xviv. Changes since 3.0.RC2

        +

        1.xx. Changes since 3.0.RC2

        • [Fix] Re-allow searching within the memberlist
        • @@ -2173,7 +2318,7 @@
        -

        1.xx. Changes since 3.0.RC1

        +

        1.xxi. Changes since 3.0.RC1

        • [Fix] (X)HTML issues within the templates (Bug #11255, #11255)
        • From 0297b88aafd3ef12217965f2879af9f9fd12d91f Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 12 Jul 2013 15:41:52 -0400 Subject: [PATCH 2171/2494] [ticket/9657] Add unit tests for softdeleting and moving posts/topics PHPBB3-9657 --- tests/functional/softdelete_test.php | 439 ++++++++++++++++++ .../phpbb_functional_test_case.php | 48 +- 2 files changed, 478 insertions(+), 9 deletions(-) create mode 100644 tests/functional/softdelete_test.php diff --git a/tests/functional/softdelete_test.php b/tests/functional/softdelete_test.php new file mode 100644 index 0000000000..0ebbab66ab --- /dev/null +++ b/tests/functional/softdelete_test.php @@ -0,0 +1,439 @@ +login(); + $this->admin_login(); + + $crawler = self::request('GET', "adm/index.php?i=acp_forums&mode=manage&sid={$this->sid}"); + $form = $crawler->selectButton('addforum')->form(array( + 'forum_name' => 'Soft Delete #1', + )); + $crawler = self::submit($form); + $form = $crawler->selectButton('update')->form(array( + 'forum_perm_from' => 2, + )); + $crawler = self::submit($form); + + $crawler = self::request('GET', "adm/index.php?i=acp_forums&mode=manage&sid={$this->sid}"); + $form = $crawler->selectButton('addforum')->form(array( + 'forum_name' => 'Soft Delete #2', + )); + $crawler = self::submit($form); + $form = $crawler->selectButton('update')->form(array( + 'forum_perm_from' => 2, + )); + $crawler = self::submit($form); + } + + public function test_create_post() + { + $this->login(); + $this->load_ids(array( + 'forums' => array( + 'Soft Delete #1', + 'Soft Delete #2', + ), + )); + + $this->assert_forum_details($this->data['forums']['Soft Delete #1'], array( + 'forum_posts_approved' => 0, + 'forum_posts_unapproved' => 0, + 'forum_posts_softdeleted' => 0, + 'forum_topics_approved' => 0, + 'forum_topics_unapproved' => 0, + 'forum_topics_softdeleted' => 0, + 'forum_last_post_id' => 0, + ), 'initial comparison'); + + // Test creating topic + $post = $this->create_topic($this->data['forums']['Soft Delete #1'], 'Soft Delete Topic #1', 'This is a test topic posted by the testing framework.'); + $crawler = self::request('GET', "viewtopic.php?t={$post['topic_id']}&sid={$this->sid}"); + + $this->assertContains('Soft Delete Topic #1', $crawler->filter('html')->text()); + $this->data['topics']['Soft Delete Topic #1'] = (int) $post['topic_id']; + $this->data['posts']['Soft Delete Topic #1'] = (int) $this->get_parameter_from_link($crawler->filter('.post')->selectLink($this->lang('POST', '', ''))->link()->getUri(), 'p'); + + $this->assert_forum_details($this->data['forums']['Soft Delete #1'], array( + 'forum_posts_approved' => 1, + 'forum_posts_unapproved' => 0, + 'forum_posts_softdeleted' => 0, + 'forum_topics_approved' => 1, + 'forum_topics_unapproved' => 0, + 'forum_topics_softdeleted' => 0, + 'forum_last_post_id' => $this->data['posts']['Soft Delete Topic #1'], + ), 'after creating topic #1'); + + // Test creating a reply + $post2 = $this->create_post($this->data['forums']['Soft Delete #1'], $post['topic_id'], 'Re: Soft Delete Topic #1-#2', 'This is a test post posted by the testing framework.'); + $crawler = self::request('GET', "viewtopic.php?t={$post2['topic_id']}&sid={$this->sid}"); + + $this->assertContains('Re: Soft Delete Topic #1-#2', $crawler->filter('html')->text()); + $this->data['posts']['Re: Soft Delete Topic #1-#2'] = (int) $this->get_parameter_from_link($crawler->filter('.post')->eq(1)->selectLink($this->lang('POST', '', ''))->link()->getUri(), 'p'); + + $this->assert_forum_details($this->data['forums']['Soft Delete #1'], array( + 'forum_posts_approved' => 2, + 'forum_posts_unapproved' => 0, + 'forum_posts_softdeleted' => 0, + 'forum_topics_approved' => 1, + 'forum_topics_unapproved' => 0, + 'forum_topics_softdeleted' => 0, + 'forum_last_post_id' => $this->data['posts']['Re: Soft Delete Topic #1-#2'], + ), 'after replying'); + } + + public function test_softdelete_post() + { + $this->login(); + $this->load_ids(array( + 'forums' => array( + 'Soft Delete #1', + 'Soft Delete #2', + ), + 'topics' => array( + 'Soft Delete Topic #1', + ), + 'posts' => array( + 'Soft Delete Topic #1', + 'Re: Soft Delete Topic #1-#2', + ), + )); + + $this->assert_forum_details($this->data['forums']['Soft Delete #1'], array( + 'forum_posts_approved' => 2, + 'forum_posts_unapproved' => 0, + 'forum_posts_softdeleted' => 0, + 'forum_topics_approved' => 1, + 'forum_topics_unapproved' => 0, + 'forum_topics_softdeleted' => 0, + 'forum_last_post_id' => $this->data['posts']['Re: Soft Delete Topic #1-#2'], + ), 'before softdelete'); + + $this->add_lang('posting'); + $crawler = self::request('GET', "posting.php?mode=delete&f={$this->data['forums']['Soft Delete #1']}&p={$this->data['posts']['Re: Soft Delete Topic #1-#2']}&sid={$this->sid}"); + $this->assertContainsLang('DELETE_PERMANENTLY', $crawler->text()); + + $form = $crawler->selectButton('Yes')->form(); + $crawler = self::submit($form); + $this->assertContainsLang('POST_DELETED', $crawler->text()); + + $this->assert_forum_details($this->data['forums']['Soft Delete #1'], array( + 'forum_posts_approved' => 1, + 'forum_posts_unapproved' => 0, + 'forum_posts_softdeleted' => 1, + 'forum_topics_approved' => 1, + 'forum_topics_unapproved' => 0, + 'forum_topics_softdeleted' => 0, + 'forum_last_post_id' => $this->data['posts']['Soft Delete Topic #1'], + ), 'after softdelete'); + + $crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Soft Delete Topic #1']}&sid={$this->sid}"); + $this->assertContains($this->lang('POST_DISPLAY', '', ''), $crawler->text()); + } + + public function test_move_softdeleted_post() + { + $this->login(); + $this->load_ids(array( + 'forums' => array( + 'Soft Delete #1', + 'Soft Delete #2', + ), + 'topics' => array( + 'Soft Delete Topic #1', + ), + 'posts' => array( + 'Soft Delete Topic #1', + 'Re: Soft Delete Topic #1-#2', + ), + )); + + $this->assert_forum_details($this->data['forums']['Soft Delete #1'], array( + 'forum_posts_approved' => 1, + 'forum_posts_unapproved' => 0, + 'forum_posts_softdeleted' => 1, + 'forum_topics_approved' => 1, + 'forum_topics_unapproved' => 0, + 'forum_topics_softdeleted' => 0, + 'forum_last_post_id' => $this->data['posts']['Soft Delete Topic #1'], + ), 'before moving #1'); + + $this->assert_forum_details($this->data['forums']['Soft Delete #2'], array( + 'forum_posts_approved' => 0, + 'forum_posts_unapproved' => 0, + 'forum_posts_softdeleted' => 0, + 'forum_topics_approved' => 0, + 'forum_topics_unapproved' => 0, + 'forum_topics_softdeleted' => 0, + 'forum_last_post_id' => 0, + ), 'before moving #2'); + + $crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Soft Delete Topic #1']}&sid={$this->sid}"); + + $form = $crawler->selectButton('Go')->eq(2)->form(); + $form['action']->select('move'); + $crawler = self::submit($form); + $this->assertContainsLang('SELECT_DESTINATION_FORUM', $crawler->text()); + + $this->add_lang('mcp'); + $form = $crawler->selectButton('Yes')->form(); + $form['to_forum_id']->select($this->data['forums']['Soft Delete #2']); + $crawler = self::submit($form); + $this->assertContainsLang('TOPIC_MOVED_SUCCESS', $crawler->text()); + + $crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Soft Delete Topic #1']}&sid={$this->sid}"); + $this->assertContains('Soft Delete #2', $crawler->filter('.navlinks')->text()); + $this->assertContains('Soft Delete Topic #1', $crawler->filter('h2')->text()); + + $this->assert_forum_details($this->data['forums']['Soft Delete #1'], array( + 'forum_posts_approved' => 0, + 'forum_posts_unapproved' => 0, + 'forum_posts_softdeleted' => 0, + 'forum_topics_approved' => 0, + 'forum_topics_unapproved' => 0, + 'forum_topics_softdeleted' => 0, + 'forum_last_post_id' => 0, + ), 'after moving #1'); + + $this->assert_forum_details($this->data['forums']['Soft Delete #2'], array( + 'forum_posts_approved' => 1, + 'forum_posts_unapproved' => 0, + 'forum_posts_softdeleted' => 1, + 'forum_topics_approved' => 1, + 'forum_topics_unapproved' => 0, + 'forum_topics_softdeleted' => 0, + 'forum_last_post_id' => $this->data['posts']['Soft Delete Topic #1'], + ), 'after moving #2'); + } + + public function test_softdelete_topic() + { + $this->login(); + $this->load_ids(array( + 'forums' => array( + 'Soft Delete #1', + 'Soft Delete #2', + ), + 'topics' => array( + 'Soft Delete Topic #1', + ), + 'posts' => array( + 'Soft Delete Topic #1', + 'Re: Soft Delete Topic #1-#2', + ), + )); + + $this->assert_forum_details($this->data['forums']['Soft Delete #1'], array( + 'forum_posts_approved' => 0, + 'forum_posts_unapproved' => 0, + 'forum_posts_softdeleted' => 0, + 'forum_topics_approved' => 0, + 'forum_topics_unapproved' => 0, + 'forum_topics_softdeleted' => 0, + 'forum_last_post_id' => 0, + ), 'before softdeleting #1'); + + $this->assert_forum_details($this->data['forums']['Soft Delete #2'], array( + 'forum_posts_approved' => 1, + 'forum_posts_unapproved' => 0, + 'forum_posts_softdeleted' => 1, + 'forum_topics_approved' => 1, + 'forum_topics_unapproved' => 0, + 'forum_topics_softdeleted' => 0, + 'forum_last_post_id' => $this->data['posts']['Soft Delete Topic #1'], + ), 'before softdeleting #2'); + + $crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Soft Delete Topic #1']}&sid={$this->sid}"); + + $this->add_lang('posting'); + $form = $crawler->selectButton('Go')->eq(2)->form(); + $form['action']->select('delete_topic'); + $crawler = self::submit($form); + $this->assertContainsLang('DELETE_PERMANENTLY', $crawler->text()); + + $this->add_lang('mcp'); + $form = $crawler->selectButton('Yes')->form(); + $crawler = self::submit($form); + $this->assertContainsLang('TOPIC_DELETED_SUCCESS', $crawler->text()); + + $crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Soft Delete Topic #1']}&sid={$this->sid}"); + $this->assertContains('Soft Delete #2', $crawler->filter('.navlinks')->text()); + $this->assertContains('Soft Delete Topic #1', $crawler->filter('h2')->text()); + + $this->assert_forum_details($this->data['forums']['Soft Delete #1'], array( + 'forum_posts_approved' => 0, + 'forum_posts_unapproved' => 0, + 'forum_posts_softdeleted' => 0, + 'forum_topics_approved' => 0, + 'forum_topics_unapproved' => 0, + 'forum_topics_softdeleted' => 0, + 'forum_last_post_id' => 0, + ), 'after moving #1'); + + $this->assert_forum_details($this->data['forums']['Soft Delete #2'], array( + 'forum_posts_approved' => 0, + 'forum_posts_unapproved' => 0, + 'forum_posts_softdeleted' => 2, + 'forum_topics_approved' => 0, + 'forum_topics_unapproved' => 0, + 'forum_topics_softdeleted' => 1, + 'forum_last_post_id' => 0, + ), 'after moving #2'); + } + + public function test_move_softdeleted_topic() + { + $this->login(); + $this->load_ids(array( + 'forums' => array( + 'Soft Delete #1', + 'Soft Delete #2', + ), + 'topics' => array( + 'Soft Delete Topic #1', + ), + 'posts' => array( + 'Soft Delete Topic #1', + 'Re: Soft Delete Topic #1-#2', + ), + )); + + $this->assert_forum_details($this->data['forums']['Soft Delete #1'], array( + 'forum_posts_approved' => 0, + 'forum_posts_unapproved' => 0, + 'forum_posts_softdeleted' => 0, + 'forum_topics_approved' => 0, + 'forum_topics_unapproved' => 0, + 'forum_topics_softdeleted' => 0, + 'forum_last_post_id' => 0, + ), 'before moving #1'); + + $this->assert_forum_details($this->data['forums']['Soft Delete #2'], array( + 'forum_posts_approved' => 0, + 'forum_posts_unapproved' => 0, + 'forum_posts_softdeleted' => 2, + 'forum_topics_approved' => 0, + 'forum_topics_unapproved' => 0, + 'forum_topics_softdeleted' => 1, + 'forum_last_post_id' => 0, + ), 'before moving #2'); + + $crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Soft Delete Topic #1']}&sid={$this->sid}"); + + $form = $crawler->selectButton('Go')->eq(2)->form(); + $form['action']->select('move'); + $crawler = self::submit($form); + $this->assertContainsLang('SELECT_DESTINATION_FORUM', $crawler->text()); + + $this->add_lang('mcp'); + $form = $crawler->selectButton('Yes')->form(); + $form['to_forum_id']->select($this->data['forums']['Soft Delete #1']); + $crawler = self::submit($form); + $this->assertContainsLang('TOPIC_MOVED_SUCCESS', $crawler->text()); + + $crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Soft Delete Topic #1']}&sid={$this->sid}"); + $this->assertContains('Soft Delete #1', $crawler->filter('.navlinks')->text()); + $this->assertContains('Soft Delete Topic #1', $crawler->filter('h2')->text()); + + $this->assert_forum_details($this->data['forums']['Soft Delete #1'], array( + 'forum_posts_approved' => 0, + 'forum_posts_unapproved' => 0, + 'forum_posts_softdeleted' => 2, + 'forum_topics_approved' => 0, + 'forum_topics_unapproved' => 0, + 'forum_topics_softdeleted' => 1, + 'forum_last_post_id' => 0, + ), 'after moving #1'); + + $this->assert_forum_details($this->data['forums']['Soft Delete #2'], array( + 'forum_posts_approved' => 0, + 'forum_posts_unapproved' => 0, + 'forum_posts_softdeleted' => 0, + 'forum_topics_approved' => 0, + 'forum_topics_unapproved' => 0, + 'forum_topics_softdeleted' => 0, + 'forum_last_post_id' => 0, + ), 'after moving #2'); + } + + public function assert_forum_details($forum_id, $details, $additional_error_message = '') + { + $this->db = $this->get_db(); + + $sql = 'SELECT ' . implode(', ', array_keys($details)) . ' + FROM phpbb_forums + WHERE forum_id = ' . (int) $forum_id; + $result = $this->db->sql_query($sql); + $data = $this->db->sql_fetchrow($result); + $this->db->sql_freeresult($result); + + $this->assertEquals($details, $data, "Forum {$forum_id} does not match expected {$additional_error_message}"); + } + + public function load_ids($data) + { + $this->db = $this->get_db(); + + if (!empty($data['forums'])) + { + $sql = 'SELECT * + FROM phpbb_forums + WHERE ' . $this->db->sql_in_set('forum_name', $data['forums']); + $result = $this->db->sql_query($sql); + while ($row = $this->db->sql_fetchrow($result)) + { + if (in_array($row['forum_name'], $data['forums'])) + { + $this->data['forums'][$row['forum_name']] = (int) $row['forum_id']; + } + } + $this->db->sql_freeresult($result); + } + + if (!empty($data['topics'])) + { + $sql = 'SELECT * + FROM phpbb_topics + WHERE ' . $this->db->sql_in_set('topic_title', $data['topics']); + $result = $this->db->sql_query($sql); + while ($row = $this->db->sql_fetchrow($result)) + { + if (in_array($row['topic_title'], $data['topics'])) + { + $this->data['topics'][$row['topic_title']] = (int) $row['topic_id']; + } + } + $this->db->sql_freeresult($result); + } + + if (!empty($data['posts'])) + { + $sql = 'SELECT * + FROM phpbb_posts + WHERE ' . $this->db->sql_in_set('post_subject', $data['posts']); + $result = $this->db->sql_query($sql); + while ($row = $this->db->sql_fetchrow($result)) + { + if (in_array($row['post_subject'], $data['posts'])) + { + $this->data['posts'][$row['post_subject']] = (int) $row['post_id']; + } + } + $this->db->sql_freeresult($result); + } + } +} diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index 7e2e750e30..d2d16a4bda 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -767,6 +767,7 @@ class phpbb_functional_test_case extends phpbb_test_case * Be sure to login before creating * * @param int $forum_id + * @param int $topic_id * @param string $subject * @param string $message * @param array $additional_form_data Any additional form data to be sent in the request @@ -823,18 +824,47 @@ class phpbb_functional_test_case extends phpbb_test_case // Instead, I send it as a request with the submit button "post" set to true. $crawler = self::request('POST', $posting_url, $form_data); $this->assertContains($this->lang('POST_STORED'), $crawler->filter('html')->text()); - $url = $crawler->selectLink($this->lang('VIEW_MESSAGE', '', ''))->link()->getUri(); - $matches = $topic_id = $post_id = false; - preg_match_all('#&t=([0-9]+)(&p=([0-9]+))?#', $url, $matches); - - $topic_id = (int) (isset($matches[1][0])) ? $matches[1][0] : 0; - $post_id = (int) (isset($matches[3][0])) ? $matches[3][0] : 0; - return array( - 'topic_id' => $topic_id, - 'post_id' => $post_id, + 'topic_id' => $this->get_parameter_from_link($url, 't'), + 'post_id' => $this->get_parameter_from_link($url, 'p'), ); } + + /* + * Returns the requested parameter from a URL + * + * @param string $url + * @param string $parameter + * @return string Value of the parameter in the URL, null if not set + */ + public function get_parameter_from_link($url, $parameter) + { + if (strpos($url, '?') === false) + { + return null; + } + + $url_parts = explode('?', $url); + if (isset($url_parts[1])) + { + $url_parameters = $url_parts[1]; + if (strpos($url_parameters, '#') !== false) + { + $url_parameters = explode('#', $url_parameters); + $url_parameters = $url_parameters[0]; + } + + foreach (explode('&', $url_parameters) as $url_param) + { + list($param, $value) = explode('=', $url_param); + if ($param == $parameter) + { + return $value; + } + } + } + return null; + } } From 8c5ff0775a4563f2a4ad1e7f30379576e1c5ca21 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 12 Jul 2013 15:42:28 -0400 Subject: [PATCH 2172/2494] [ticket/9657] Fix a little error when moving softdeleted topics PHPBB3-9657 --- phpBB/includes/mcp/mcp_main.php | 1 - 1 file changed, 1 deletion(-) diff --git a/phpBB/includes/mcp/mcp_main.php b/phpBB/includes/mcp/mcp_main.php index b80532a4a0..eddfdc3759 100644 --- a/phpBB/includes/mcp/mcp_main.php +++ b/phpBB/includes/mcp/mcp_main.php @@ -498,7 +498,6 @@ function mcp_move_topic($topic_ids) $posts_moved_unapproved += $topic_info['topic_posts_unapproved']; $posts_moved_softdeleted += $topic_info['topic_posts_softdeleted']; } - $topics_moved = sizeof($topic_data); $db->sql_transaction('begin'); From 631ce22f2c33999229bf05af35e025fb8d399417 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Fri, 12 Jul 2013 15:53:36 -0400 Subject: [PATCH 2173/2494] [ticket/11626] Remove LDAP dependency on template Returns template vars rather than requiring the template. PHPBB3-11626 --- phpBB/config/auth_providers.yml | 1 - phpBB/includes/acp/acp_board.php | 3 ++- phpBB/includes/auth/provider/interface.php | 11 +++++--- phpBB/includes/auth/provider/ldap.php | 29 +++++++++++----------- 4 files changed, 25 insertions(+), 19 deletions(-) diff --git a/phpBB/config/auth_providers.yml b/phpBB/config/auth_providers.yml index 3136e60584..bcc448e4d7 100644 --- a/phpBB/config/auth_providers.yml +++ b/phpBB/config/auth_providers.yml @@ -33,6 +33,5 @@ services: - @dbal.conn - @config - @user - - @template tags: - { name: auth.provider } diff --git a/phpBB/includes/acp/acp_board.php b/phpBB/includes/acp/acp_board.php index 9285608ae2..ad95ad3da3 100644 --- a/phpBB/includes/acp/acp_board.php +++ b/phpBB/includes/acp/acp_board.php @@ -658,8 +658,9 @@ class acp_board $auth_tpl = $provider->get_acp_template($this->new_config); if ($auth_tpl) { + $template->assign_vars($auth_tpl['TEMPLATE_VARS']); $template->assign_block_vars('auth_tpl', array( - 'TEMPLATE_FILE' => $auth_tpl, + 'TEMPLATE_FILE' => $auth_tpl['TEMPLATE_FILE'], )); } } diff --git a/phpBB/includes/auth/provider/interface.php b/phpBB/includes/auth/provider/interface.php index 40c48026cf..47043bc107 100644 --- a/phpBB/includes/auth/provider/interface.php +++ b/phpBB/includes/auth/provider/interface.php @@ -72,9 +72,14 @@ interface phpbb_auth_provider_interface * provider. * @param array $new_config Contains the new configuration values that * have been set in acp_board. - * @return string|null Returns null if not implemented or a string - * containing the name of the acp tempalte file for - * the authentication provider. + * @return array|null Returns null if not implemented or an array with + * the template file name and an array of the vars + * that the template needs that must conform to the + * following example: + * array( + * 'TEMPLATE_FILE' => string, + * 'TEMPLATE_VARS' => array(...), + * ) */ public function get_acp_template($new_config); diff --git a/phpBB/includes/auth/provider/ldap.php b/phpBB/includes/auth/provider/ldap.php index 288fb617f5..56f9c23d55 100644 --- a/phpBB/includes/auth/provider/ldap.php +++ b/phpBB/includes/auth/provider/ldap.php @@ -30,14 +30,12 @@ class phpbb_auth_provider_ldap extends phpbb_auth_provider_base * @param phpbb_db_driver $db * @param phpbb_config $config * @param phpbb_user $user - * @param phpbb_template $template */ - public function __construct(phpbb_db_driver $db, phpbb_config $config, phpbb_user $user, phpbb_template $template) + public function __construct(phpbb_db_driver $db, phpbb_config $config, phpbb_user $user) { $this->db = $db; $this->config = $config; $this->user = $user; - $this->template = $template; } /** @@ -302,18 +300,21 @@ class phpbb_auth_provider_ldap extends phpbb_auth_provider_base */ public function get_acp_template($new_config) { - $this->template->assign_vars(array( - 'AUTH_LDAP_DN' => $new_config['ldap_base_dn'], - 'AUTH_LDAP_EMAIL' => $new_config['ldap_email'], - 'AUTH_LDAP_PASSORD' => $new_config['ldap_password'], - 'AUTH_LDAP_PORT' => $new_config['ldap_port'], - 'AUTH_LDAP_SERVER' => $new_config['ldap_server'], - 'AUTH_LDAP_UID' => $new_config['ldap_uid'], - 'AUTH_LDAP_USER' => $new_config['ldap_user'], - 'AUTH_LDAP_USER_FILTER' => $new_config['ldap_user_filter'], - )); + $this->template->assign_vars(); - return 'auth_provider_ldap.html'; + return array( + 'TEMPLATE_FILE' => 'auth_provider_ldap.html', + 'TEMPLATE_VARS' => array( + 'AUTH_LDAP_DN' => $new_config['ldap_base_dn'], + 'AUTH_LDAP_EMAIL' => $new_config['ldap_email'], + 'AUTH_LDAP_PASSORD' => $new_config['ldap_password'], + 'AUTH_LDAP_PORT' => $new_config['ldap_port'], + 'AUTH_LDAP_SERVER' => $new_config['ldap_server'], + 'AUTH_LDAP_UID' => $new_config['ldap_uid'], + 'AUTH_LDAP_USER' => $new_config['ldap_user'], + 'AUTH_LDAP_USER_FILTER' => $new_config['ldap_user_filter'], + ), + ); } /** From 64308f41b054d11ae267a58e04821b7b1e31af91 Mon Sep 17 00:00:00 2001 From: Joseph Warner Date: Fri, 12 Jul 2013 15:57:35 -0400 Subject: [PATCH 2174/2494] [ticket/11626] Remove last reference to template in ldap PHPBB3-11626 --- phpBB/includes/auth/provider/ldap.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/phpBB/includes/auth/provider/ldap.php b/phpBB/includes/auth/provider/ldap.php index 56f9c23d55..0196529408 100644 --- a/phpBB/includes/auth/provider/ldap.php +++ b/phpBB/includes/auth/provider/ldap.php @@ -300,8 +300,6 @@ class phpbb_auth_provider_ldap extends phpbb_auth_provider_base */ public function get_acp_template($new_config) { - $this->template->assign_vars(); - return array( 'TEMPLATE_FILE' => 'auth_provider_ldap.html', 'TEMPLATE_VARS' => array( From 3375f41ef1eaca8edca344372a31d4aafb739c87 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Fri, 12 Jul 2013 16:14:16 -0400 Subject: [PATCH 2175/2494] [ticket/11668] Move lint test to the end for travis PHPBB3-11668 --- travis/phpunit-mysql-travis.xml | 4 ++++ travis/phpunit-postgres-travis.xml | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/travis/phpunit-mysql-travis.xml b/travis/phpunit-mysql-travis.xml index 179a2a358e..e99f8d6cee 100644 --- a/travis/phpunit-mysql-travis.xml +++ b/travis/phpunit-mysql-travis.xml @@ -15,6 +15,10 @@ ../tests/ tests/functional + tests/lint_test.php + + + tests/lint_test.php ../tests/functional diff --git a/travis/phpunit-postgres-travis.xml b/travis/phpunit-postgres-travis.xml index 12e20547ba..3d1b574716 100644 --- a/travis/phpunit-postgres-travis.xml +++ b/travis/phpunit-postgres-travis.xml @@ -15,6 +15,10 @@ ../tests/ tests/functional + tests/lint_test.php + + + tests/lint_test.php ../tests/functional From 07eadac2f6a57075450c5b543770904839e3764a Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Fri, 12 Jul 2013 16:24:27 -0400 Subject: [PATCH 2176/2494] [ticket/11112] Use https for user-visible links to phpbb.com PHPBB3-11112 --- phpBB/docs/CHANGELOG.html | 2 +- phpBB/docs/FAQ.html | 12 +++++----- phpBB/docs/INSTALL.html | 12 +++++----- phpBB/docs/README.html | 28 +++++++++++----------- phpBB/docs/auth_api.html | 2 +- phpBB/docs/coding-guidelines.html | 4 ++-- phpBB/docs/hook_system.html | 2 +- phpBB/includes/acp/acp_main.php | 2 +- phpBB/includes/acp/acp_send_statistics.php | 2 +- phpBB/includes/db/dbal.php | 2 +- phpBB/language/en/acp/common.php | 2 +- phpBB/language/en/acp/permissions.php | 2 +- phpBB/language/en/help_faq.php | 2 +- phpBB/language/en/install.php | 12 +++++----- phpBB/language/en/ucp.php | 2 +- 15 files changed, 44 insertions(+), 44 deletions(-) diff --git a/phpBB/docs/CHANGELOG.html b/phpBB/docs/CHANGELOG.html index 083566fe86..4b916fadbc 100644 --- a/phpBB/docs/CHANGELOG.html +++ b/phpBB/docs/CHANGELOG.html @@ -2453,7 +2453,7 @@
          -

          This application is opensource software released under the GNU General Public License v2. Please see source code and the docs directory for more details. This package and its contents are Copyright (c) phpBB Group, All Rights Reserved.

          +

          This application is opensource software released under the GNU General Public License v2. Please see source code and the docs directory for more details. This package and its contents are Copyright (c) phpBB Group, All Rights Reserved.

          diff --git a/phpBB/docs/FAQ.html b/phpBB/docs/FAQ.html index dbcefc44c1..9b6440ab21 100644 --- a/phpBB/docs/FAQ.html +++ b/phpBB/docs/FAQ.html @@ -89,7 +89,7 @@

          There are people, companies (unrelated to your hosting provider), etc. that will install your forum, either for free or for a payment. We do not recommend you make use of these offers. Unless the service is provided by your hosting company you will have to divulge passwords and other sensitive details. If you did not know how to use an ATM would you give a passer-by your bank card and PIN and ask them to show you what to do? No, probably not! The same applies to your hosting account details!

          -

          We think a better solution is for you to carefully read the enclosed documentation, read through our knowledge base at www.phpbb.com and if necessary ask for help on any thing you get stuck on. However, the decision is yours but please note we may not offer support if we believe you have had the board installed by a third party. In such cases you should direct your questions to that company or person/s.

          +

          We think a better solution is for you to carefully read the enclosed documentation, read through our knowledge base at www.phpbb.com and if necessary ask for help on any thing you get stuck on. However, the decision is yours but please note we may not offer support if we believe you have had the board installed by a third party. In such cases you should direct your questions to that company or person/s.

      @@ -150,7 +150,7 @@ I want to sue you because i think you host an illegal board!
      -

      This error will occur if phpBB cannot send mail. phpBB can send email two ways; using the PHP mail() function or directly via SMTP. Some hosting providers limit the mail() function to prevent its use in spamming, others may rename it or limit its functionality. If the mail() function got renamed, you are able to enter the correct name within the administration control panel. In either case you may need to make use of SMTP. This requires that you have access to such a facility, e.g. your hosting provider may provide one (perhaps requiring specific written authorisation), etc. Please see www.phpbb.com for additional help on this matter.

      +

      This error will occur if phpBB cannot send mail. phpBB can send email two ways; using the PHP mail() function or directly via SMTP. Some hosting providers limit the mail() function to prevent its use in spamming, others may rename it or limit its functionality. If the mail() function got renamed, you are able to enter the correct name within the administration control panel. In either case you may need to make use of SMTP. This requires that you have access to such a facility, e.g. your hosting provider may provide one (perhaps requiring specific written authorisation), etc. Please see www.phpbb.com for additional help on this matter.

      If you do require SMTP services please do not ask (on our forums or elsewhere) for someone to provide you with one. Open relays are now things of the past thanks to the unthinking spammers out there. Therefore you are unlikely to find someone willing to offer you (free) services.

      @@ -250,7 +250,7 @@ I want to sue you because i think you host an illegal board!
      -

      Please read the paragraph about permissions in our extensive online documentation.

      +

      Please read the paragraph about permissions in our extensive online documentation.

      @@ -306,11 +306,11 @@ I want to sue you because i think you host an illegal board!
      -

      Please read our extensive user documentation first, it may just explain what you want to know.

      +

      Please read our extensive user documentation first, it may just explain what you want to know.

      Feel free to search our community forum for the information you require. PLEASE DO NOT post your question without having first used search, chances are someone has already asked and answered your question. You can find our board here:

      -

      www.phpbb.com

      +

      www.phpbb.com

      @@ -328,7 +328,7 @@ I want to sue you because i think you host an illegal board!
      -

      This application is opensource software released under the GNU General Public License v2. Please see source code and the docs directory for more details. This package and its contents are Copyright (c) phpBB Group, All Rights Reserved.

      +

      This application is opensource software released under the GNU General Public License v2. Please see source code and the docs directory for more details. This package and its contents are Copyright (c) phpBB Group, All Rights Reserved.

      diff --git a/phpBB/docs/INSTALL.html b/phpBB/docs/INSTALL.html index cd1185644b..3fa0597fc8 100644 --- a/phpBB/docs/INSTALL.html +++ b/phpBB/docs/INSTALL.html @@ -46,7 +46,7 @@

      This document will walk you through the basics on installing, updating and converting the forum software.

      -

      A basic overview of running phpBB3 can be found in the accompanying README file. Please ensure you read that document in addition to this! For more detailed information on using, installing, updating and converting phpBB3 you should read the documentation available online.

      +

      A basic overview of running phpBB3 can be found in the accompanying README file. Please ensure you read that document in addition to this! For more detailed information on using, installing, updating and converting phpBB3 you should read the documentation available online.

      Install

      @@ -223,7 +223,7 @@

      Administrator details

      -

      Now you have to create your administration user. This user will have full administration access and he/she will be the first user on your forum. All fields on this page are required. You can also set the default language of your forum on this page. In a vanilla phpBB3 installation, we only include British English. You can download further languages from www.phpbb.com, and add them before installing or later.

      +

      Now you have to create your administration user. This user will have full administration access and he/she will be the first user on your forum. All fields on this page are required. You can also set the default language of your forum on this page. In a vanilla phpBB3 installation, we only include British English. You can download further languages from www.phpbb.com, and add them before installing or later.

      Configuration file

      @@ -302,7 +302,7 @@

      To perform the update, either follow the instructions from the Administration Control Panel->System Tab - this should point out that you are running an outdated version and will guide you through the update - or follow the instructions listed below.

        -
      • Go to the downloads page and download the latest update package listed there, matching your current version.
      • +
      • Go to the downloads page and download the latest update package listed there, matching your current version.
      • Upload the uncompressed archive contents to your phpBB installation - only the install folder is required. Upload the whole install folder, retaining the file structure.
      • After the install folder is present, phpBB3 will go offline automatically.
      • Point your browser to the install directory, for example http://www.example.com/phpBB3/install/
      • @@ -349,7 +349,7 @@

        As with install, the conversion is automated. Your previous 2.0.x database tables will not be changed and the original 2.0.x files will remain unaltered. The conversion is actually only filling your phpBB3 database tables and copying additional data over to your phpBB3 installation. This has the benefit that if something goes wrong, you are able to either re-run the conversion or continue a conversion, while your old board is still accessible. We really recommend that you disable your old installation while converting, else you may have inconsistent data after the conversion.

        -

        Please note that this conversion process may take quite some time and depending on your hosting provider this may result in it failing (due to web server resource limits or other timeout issues). If this is the case, you should ask your provider if they are willing to allow the convert script to temporarily exceed their limits (be nice and they will probably be quite helpful). If your host is unwilling to increase the limits to run the convertor, please see this article for performing the conversion on your local machine: Knowledge Base - Offline Conversions

        +

        Please note that this conversion process may take quite some time and depending on your hosting provider this may result in it failing (due to web server resource limits or other timeout issues). If this is the case, you should ask your provider if they are willing to allow the convert script to temporarily exceed their limits (be nice and they will probably be quite helpful). If your host is unwilling to increase the limits to run the convertor, please see this article for performing the conversion on your local machine: Knowledge Base - Offline Conversions

        Once completed, your board should be immediately available. If you encountered errors, you should report the problems to our bug tracker or seek help via our forums (see README for details).

        @@ -433,7 +433,7 @@
        -

        Like any online site that allows user input, your board could be subject to unwanted posts; often referred to as forum spam. The vast majority of these attacks will be from automated computer programs known as spambots. The attacks, generally, are not personal as the spammers are just trying to find accessible targets. phpBB has a number of anti-spam measures built in, including a range of CAPTCHAs. However, administrators are strongly urged to read and follow the advice for Preventing Spam in phpBB as soon as possible after completing the installation of your board.

        +

        Like any online site that allows user input, your board could be subject to unwanted posts; often referred to as forum spam. The vast majority of these attacks will be from automated computer programs known as spambots. The attacks, generally, are not personal as the spammers are just trying to find accessible targets. phpBB has a number of anti-spam measures built in, including a range of CAPTCHAs. However, administrators are strongly urged to read and follow the advice for Preventing Spam in phpBB as soon as possible after completing the installation of your board.

        @@ -450,7 +450,7 @@
        -

        This application is opensource software released under the GNU General Public License v2. Please see the source code and docs/ directory for more details. This package and its contents are Copyright © phpBB Group, All Rights Reserved.

        +

        This application is opensource software released under the GNU General Public License v2. Please see the source code and docs/ directory for more details. This package and its contents are Copyright © phpBB Group, All Rights Reserved.

        diff --git a/phpBB/docs/README.html b/phpBB/docs/README.html index 81ce736df7..89f573de04 100644 --- a/phpBB/docs/README.html +++ b/phpBB/docs/README.html @@ -132,21 +132,21 @@

        2.i. Languages (Internationalisation - i18n)

        -

        A number of language packs with included style localisations are available. You can find them listed in the Language Packs pages of our downloads section or from the Language Packs section of the Customisation Database.

        +

        A number of language packs with included style localisations are available. You can find them listed in the Language Packs pages of our downloads section or from the Language Packs section of the Customisation Database.

        -

        For more information about language packs, please see: http://www.phpbb.com/languages/

        +

        For more information about language packs, please see: https://www.phpbb.com/languages/

        This is the official location for all supported language sets. If you download a package from a 3rd party site you do so with the understanding that we cannot offer support. Please do not ask for support if you download a language pack from a 3rd party site.

        -

        Installation of these packages is straightforward: simply download the required language pack, uncompress (unzip) it and via FTP transfer the included language and styles folders to the root of your board installation. The language can then be installed via the Administration Control Panel of your board: System tab -> General Tasks -> Language packs. A more detailed description of the process is in the Knowledge Base article, How to Install a Language Pack.

        +

        Installation of these packages is straightforward: simply download the required language pack, uncompress (unzip) it and via FTP transfer the included language and styles folders to the root of your board installation. The language can then be installed via the Administration Control Panel of your board: System tab -> General Tasks -> Language packs. A more detailed description of the process is in the Knowledge Base article, How to Install a Language Pack.

        -

        If your language is not available, please visit our [3.0.x] Translations forum where you will find topics on translations in progress. Should you wish to volunteer to translate a language not currently available or assist in maintaining an existing language pack, you can Apply to become a translator.

        +

        If your language is not available, please visit our [3.0.x] Translations forum where you will find topics on translations in progress. Should you wish to volunteer to translate a language not currently available or assist in maintaining an existing language pack, you can Apply to become a translator.

        2.ii. Styles

        -

        Although the phpBB Group is rather proud of the included styles, we realise that they may not be to everyone's taste. Therefore, phpBB3 allows styles to be switched with relative ease. First, you need to locate and download a style you like. You can find them listed in the Styles section of our Customisation Database.

        +

        Although the phpBB Group is rather proud of the included styles, we realise that they may not be to everyone's taste. Therefore, phpBB3 allows styles to be switched with relative ease. First, you need to locate and download a style you like. You can find them listed in the Styles section of our Customisation Database.

        -

        For more information about styles, please see: http://www.phpbb.com/styles/

        +

        For more information about styles, please see: https://www.phpbb.com/styles/

        Please note that 3rd party styles downloaded for versions of phpBB2 will not work in phpBB3. It is also important to ensure that the style is updated to match the current version of the phpBB software you are using.

        @@ -156,9 +156,9 @@

        2.iii. Modifications

        -

        Although not officially supported by the phpBB Group, phpBB has a thriving modification scene. These third party modifications to the standard phpBB software, known as MODs, extend its capabilities still further. You can browse through many of the MODs in the Modifications section of our Customisation Database.

        +

        Although not officially supported by the phpBB Group, phpBB has a thriving modification scene. These third party modifications to the standard phpBB software, known as MODs, extend its capabilities still further. You can browse through many of the MODs in the Modifications section of our Customisation Database.

        -

        For more information about MODs, please see: http://www.phpbb.com/mods/

        +

        For more information about MODs, please see: https://www.phpbb.com/mods/

        Please remember that any bugs or other issues that occur after you have added any modification should NOT be reported to the bug tracker (see below). First remove the MOD and see if the problem is resolved. Any support for a MOD should only be sought in the "Discussion/Support" forum for that MOD.

        @@ -186,7 +186,7 @@

        Comprehensive documentation is now available on the phpBB website:

        -

        http://www.phpbb.com/support/documentation/3.0/

        +

        https://www.phpbb.com/support/documentation/3.0/

        This covers everything from installation to setting permissions and managing users.

        @@ -194,13 +194,13 @@

        The Knowledge Base consists of a number of detailed articles on some common issues phpBB users may encounter while using the product. The Knowledge Base can be found at:

        -

        http://www.phpbb.com/kb/

        +

        https://www.phpbb.com/kb/

        3.iii. Community Forums

        The phpBB Group maintains a thriving community where a number of people have generously decided to donate their time to help support users. This site can be found at:

        -

        http://www.phpbb.com/community/

        +

        https://www.phpbb.com/community/

        If you do seek help via our forums please be sure to do a search before posting; if someone has experienced the issue before, then you may find that your question has already been answered. Please remember that phpBB is entirely staffed by volunteers, no one receives any compensation for the time they give, including moderators as well as developers; please be respectful and mindful when awaiting responses and receiving support.

        @@ -208,7 +208,7 @@

        Another place you may find help is our IRC channel. This operates on the Freenode IRC network, irc.freenode.net and the channel is #phpbb and can be accessed by any decent IRC client such as mIRC, XChat, etc. Again, please do not abuse this service and be respectful of other users.

        -

        There are other IRC channels available, please see http://www.phpbb.com/support/irc/ for the complete list.

        +

        There are other IRC channels available, please see https://www.phpbb.com/support/irc/ for the complete list.

        @@ -283,7 +283,7 @@

        If you find a potential security related vulnerability in phpBB please DO NOT post it to the bug tracker, public forums, etc.! Doing so may allow unscrupulous users to take advantage of it before we have time to put a fix in place. All security related bugs should be sent to our security tracker:

        -

        http://www.phpbb.com/security/

        +

        https://www.phpbb.com/security/

      @@ -351,7 +351,7 @@
      -

      This application is opensource software released under the GNU General Public License v2. Please see source code and the docs directory for more details. This package and its contents are Copyright © phpBB Group, All Rights Reserved.

      +

      This application is opensource software released under the GNU General Public License v2. Please see source code and the docs directory for more details. This package and its contents are Copyright © phpBB Group, All Rights Reserved.

      diff --git a/phpBB/docs/auth_api.html b/phpBB/docs/auth_api.html index a319460360..eb168e26a6 100644 --- a/phpBB/docs/auth_api.html +++ b/phpBB/docs/auth_api.html @@ -275,7 +275,7 @@ $auth_admin = new auth_admin();
      -

      This application is opensource software released under the GNU General Public License v2. Please see source code and the docs directory for more details. This package and its contents are Copyright (c) phpBB Group, All Rights Reserved.

      +

      This application is opensource software released under the GNU General Public License v2. Please see source code and the docs directory for more details. This package and its contents are Copyright (c) phpBB Group, All Rights Reserved.

      diff --git a/phpBB/docs/coding-guidelines.html b/phpBB/docs/coding-guidelines.html index dd0ee0a82f..a541fe8866 100644 --- a/phpBB/docs/coding-guidelines.html +++ b/phpBB/docs/coding-guidelines.html @@ -1191,7 +1191,7 @@ append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=group&amp; <!-- INCLUDEPHP somefile.php -->
      -

      it will be included and executed inline.

      A note, it is very much encouraged that template designers do not include PHP. The ability to include raw PHP was introduced primarily to allow end users to include banner code, etc. without modifying multiple files (as with 2.0.x). It was not intended for general use ... hence www.phpbb.com will not make available template sets which include PHP. And by default templates will have PHP disabled (the admin will need to specifically activate PHP for a template).

      +

      it will be included and executed inline.

      A note, it is very much encouraged that template designers do not include PHP. The ability to include raw PHP was introduced primarily to allow end users to include banner code, etc. without modifying multiple files (as with 2.0.x). It was not intended for general use ... hence www.phpbb.com will not make available template sets which include PHP. And by default templates will have PHP disabled (the admin will need to specifically activate PHP for a template).

      Conditionals/Control structures

      The most significant addition to 3.0.x are conditions or control structures, "if something then do this else do that". The system deployed is very similar to Smarty. This may confuse some people at first but it offers great potential and great flexibility with a little imagination. In their most simple form these constructs take the form:

      @@ -2323,7 +2323,7 @@ if (utf8_case_fold_nfc($string1) == utf8_case_fold_nfc($string2))
      -

      This application is opensource software released under the GNU General Public License v2. Please see source code and the docs directory for more details. This package and its contents are Copyright (c) phpBB Group, All Rights Reserved.

      +

      This application is opensource software released under the GNU General Public License v2. Please see source code and the docs directory for more details. This package and its contents are Copyright (c) phpBB Group, All Rights Reserved.

      diff --git a/phpBB/docs/hook_system.html b/phpBB/docs/hook_system.html index 1b8131efaf..fbc8baaf75 100644 --- a/phpBB/docs/hook_system.html +++ b/phpBB/docs/hook_system.html @@ -867,7 +867,7 @@ function phpbb_hook_register(&$hook)
      -

      This application is opensource software released under the GNU General Public License v2. Please see source code and the docs directory for more details. This package and its contents are Copyright (c) phpBB Group, All Rights Reserved.

      +

      This application is opensource software released under the GNU General Public License v2. Please see source code and the docs directory for more details. This package and its contents are Copyright (c) phpBB Group, All Rights Reserved.

      diff --git a/phpBB/includes/acp/acp_main.php b/phpBB/includes/acp/acp_main.php index ee7bd4dc45..d80b0d1532 100644 --- a/phpBB/includes/acp/acp_main.php +++ b/phpBB/includes/acp/acp_main.php @@ -402,7 +402,7 @@ class acp_main { $template->assign_vars(array( 'S_PHP_VERSION_OLD' => true, - 'L_PHP_VERSION_OLD' => sprintf($user->lang['PHP_VERSION_OLD'], '', ''), + 'L_PHP_VERSION_OLD' => sprintf($user->lang['PHP_VERSION_OLD'], '', ''), )); } diff --git a/phpBB/includes/acp/acp_send_statistics.php b/phpBB/includes/acp/acp_send_statistics.php index b3baf54983..b8fc2d2c45 100644 --- a/phpBB/includes/acp/acp_send_statistics.php +++ b/phpBB/includes/acp/acp_send_statistics.php @@ -29,7 +29,7 @@ class acp_send_statistics { global $config, $template, $phpbb_admin_path, $phpEx; - $collect_url = "http://www.phpbb.com/stats/receive_stats.php"; + $collect_url = "https://www.phpbb.com/stats/receive_stats.php"; $this->tpl_name = 'acp_send_statistics'; $this->page_title = 'ACP_SEND_STATISTICS'; diff --git a/phpBB/includes/db/dbal.php b/phpBB/includes/db/dbal.php index 9cc337955b..30d2870938 100644 --- a/phpBB/includes/db/dbal.php +++ b/phpBB/includes/db/dbal.php @@ -827,7 +827,7 @@ class dbal
    diff --git a/phpBB/language/en/acp/common.php b/phpBB/language/en/acp/common.php index 00155dd335..04d614c80d 100644 --- a/phpBB/language/en/acp/common.php +++ b/phpBB/language/en/acp/common.php @@ -292,7 +292,7 @@ $lang = array_merge($lang, array( // PHP info $lang = array_merge($lang, array( - 'ACP_PHP_INFO_EXPLAIN' => 'This page lists information on the version of PHP installed on this server. It includes details of loaded modules, available variables and default settings. This information may be useful when diagnosing problems. Please be aware that some hosting companies will limit what information is displayed here for security reasons. You are advised to not give out any details on this page except when asked by official team members on the support forums.', + 'ACP_PHP_INFO_EXPLAIN' => 'This page lists information on the version of PHP installed on this server. It includes details of loaded modules, available variables and default settings. This information may be useful when diagnosing problems. Please be aware that some hosting companies will limit what information is displayed here for security reasons. You are advised to not give out any details on this page except when asked by official team members on the support forums.', 'NO_PHPINFO_AVAILABLE' => 'Information about your PHP configuration is unable to be determined. Phpinfo() has been disabled for security reasons.', )); diff --git a/phpBB/language/en/acp/permissions.php b/phpBB/language/en/acp/permissions.php index c0396cc247..6f0e7144e8 100644 --- a/phpBB/language/en/acp/permissions.php +++ b/phpBB/language/en/acp/permissions.php @@ -53,7 +53,7 @@ $lang = array_merge($lang, array(
    -

    For further information on setting up and managing permissions on your phpBB3 board, please see Chapter 1.5 of our Quick Start Guide.

    +

    For further information on setting up and managing permissions on your phpBB3 board, please see Chapter 1.5 of our Quick Start Guide.

    ', 'ACL_NEVER' => 'Never', diff --git a/phpBB/language/en/help_faq.php b/phpBB/language/en/help_faq.php index c500917d58..dab66779c3 100644 --- a/phpBB/language/en/help_faq.php +++ b/phpBB/language/en/help_faq.php @@ -329,7 +329,7 @@ $help = array( ), array( 0 => 'Who wrote this bulletin board?', - 1 => 'This software (in its unmodified form) is produced, released and is copyright phpBB Group. It is made available under the GNU General Public License and may be freely distributed. See the link for more details.' + 1 => 'This software (in its unmodified form) is produced, released and is copyright phpBB Group. It is made available under the GNU General Public License and may be freely distributed. See the link for more details.' ), array( 0 => 'Why isn’t X feature available?', diff --git a/phpBB/language/en/install.php b/phpBB/language/en/install.php index bdc51a5712..0c85933a66 100644 --- a/phpBB/language/en/install.php +++ b/phpBB/language/en/install.php @@ -80,7 +80,7 @@ $lang = array_merge($lang, array( 'CONTINUE_OLD_CONVERSION' => 'Continue previously started conversion', 'CONVERT' => 'Convert', 'CONVERT_COMPLETE' => 'Conversion completed', - 'CONVERT_COMPLETE_EXPLAIN' => 'You have now successfully converted your board to phpBB 3.0. You can now login and access your board. Please ensure that the settings were transferred correctly before enabling your board by deleting the install directory. Remember that help on using phpBB is available online via the Documentation and the support forums.', + 'CONVERT_COMPLETE_EXPLAIN' => 'You have now successfully converted your board to phpBB 3.0. You can now login and access your board. Please ensure that the settings were transferred correctly before enabling your board by deleting the install directory. Remember that help on using phpBB is available online via the Documentation and the support forums.', 'CONVERT_INTRO' => 'Welcome to the phpBB Unified Convertor Framework', 'CONVERT_INTRO_BODY' => 'From here, you are able to import data from other (installed) board systems. The list below shows all the conversion modules currently available. If there is no convertor shown in this list for the board software you wish to convert from, please check our website where further conversion modules may be available for download.', 'CONVERT_NEW_CONVERSION' => 'New conversion', @@ -194,7 +194,7 @@ $lang = array_merge($lang, array(

    Convert an existing board to phpBB3

    The phpBB Unified Convertor Framework supports the conversion of phpBB 2.0.x and other board systems to phpBB3. If you have an existing board that you wish to convert, please proceed to the convertor.

    Go live with your phpBB3!

    -

    Clicking the button below will take you to a form for submitting statistical data to phpBB in your Administration Control Panel (ACP). We would appreciate it if you could help us by sending that information. Afterwards you should take some time to examine the options available to you. Remember that help is available online via the Documentation, README and the Support Forums.

    Please delete, move or rename the install directory before using your board. While this directory exists, only the Administration Control Panel (ACP) will be accessible.', +

    Clicking the button below will take you to a form for submitting statistical data to phpBB in your Administration Control Panel (ACP). We would appreciate it if you could help us by sending that information. Afterwards you should take some time to examine the options available to you. Remember that help is available online via the Documentation, README and the Support Forums.

    Please delete, move or rename the install directory before using your board. While this directory exists, only the Administration Control Panel (ACP) will be accessible.', 'INSTALL_INTRO' => 'Welcome to Installation', 'INSTALL_INTRO_BODY' => 'With this option, it is possible to install phpBB3 onto your server.

    In order to proceed, you will need your database settings. If you do not know your database settings, please contact your host and ask for them. You will not be able to continue without them. You need:

    @@ -277,7 +277,7 @@ $lang = array_merge($lang, array( 'MAKE_FOLDER_WRITABLE' => 'Please make sure that this folder exists and is writable by the webserver then try again:
    »%s.', 'MAKE_FOLDERS_WRITABLE' => 'Please make sure that these folders exist and are writable by the webserver then try again:
    »%s.', - 'MYSQL_SCHEMA_UPDATE_REQUIRED' => 'Your MySQL database schema for phpBB is outdated. phpBB detected a schema for MySQL 3.x/4.x, but the server runs on MySQL %2$s.
    Before you proceed the update, you need to upgrade the schema.

    Please refer to the Knowledge Base article about upgrading the MySQL schema. If you encounter problems, please use our support forums.', + 'MYSQL_SCHEMA_UPDATE_REQUIRED' => 'Your MySQL database schema for phpBB is outdated. phpBB detected a schema for MySQL 3.x/4.x, but the server runs on MySQL %2$s.
    Before you proceed the update, you need to upgrade the schema.

    Please refer to the Knowledge Base article about upgrading the MySQL schema. If you encounter problems, please use our support forums.', 'NAMING_CONFLICT' => 'Naming conflict: %s and %s are both aliases

    %s', 'NEXT_STEP' => 'Proceed to next step', @@ -345,7 +345,7 @@ $lang = array_merge($lang, array( 'SUB_LICENSE' => 'License', 'SUB_SUPPORT' => 'Support', 'SUCCESSFUL_CONNECT' => 'Successful connection', - 'SUPPORT_BODY' => 'Full support will be provided for the current stable release of phpBB3, free of charge. This includes:

    • installation
    • configuration
    • technical questions
    • problems relating to potential bugs in the software
    • updating from Release Candidate (RC) versions to the latest stable version
    • converting from phpBB 2.0.x to phpBB3
    • converting from other discussion board software to phpBB3 (please see the Convertors Forum)

    We encourage users still running beta versions of phpBB3 to replace their installation with a fresh copy of the latest version.

    MODs / Styles

    For issues relating to MODs, please post in the appropriate Modifications Forum.
    For issues relating to styles, templates and imagesets, please post in the appropriate Styles Forum.

    If your question relates to a specific package, please post directly in the topic dedicated to the package.

    Obtaining Support

    The phpBB Welcome Package
    Support Section
    Quick Start Guide

    To ensure you stay up to date with the latest news and releases, why not subscribe to our mailing list?

    ', + 'SUPPORT_BODY' => 'Full support will be provided for the current stable release of phpBB3, free of charge. This includes:

    • installation
    • configuration
    • technical questions
    • problems relating to potential bugs in the software
    • updating from Release Candidate (RC) versions to the latest stable version
    • converting from phpBB 2.0.x to phpBB3
    • converting from other discussion board software to phpBB3 (please see the Convertors Forum)

    We encourage users still running beta versions of phpBB3 to replace their installation with a fresh copy of the latest version.

    MODs / Styles

    For issues relating to MODs, please post in the appropriate Modifications Forum.
    For issues relating to styles, templates and imagesets, please post in the appropriate Styles Forum.

    If your question relates to a specific package, please post directly in the topic dedicated to the package.

    Obtaining Support

    The phpBB Welcome Package
    Support Section
    Quick Start Guide

    To ensure you stay up to date with the latest news and releases, why not subscribe to our mailing list?

    ', 'SYNC_FORUMS' => 'Starting to synchronise forums', 'SYNC_POST_COUNT' => 'Synchronising post_counts', 'SYNC_POST_COUNT_ID' => 'Synchronising post_counts from entry %1$s to %2$s.', @@ -468,7 +468,7 @@ $lang = array_merge($lang, array( 'NO_ERRORS' => 'No errors', 'NO_UPDATE_FILES' => 'Not updating the following files', 'NO_UPDATE_FILES_EXPLAIN' => 'The following files are new or modified but the directory they normally reside in could not be found on your installation. If this list contains files to other directories than language/ or styles/ than you may have modified your directory structure and the update may be incomplete.', - 'NO_UPDATE_FILES_OUTDATED' => 'No valid update directory was found, please make sure you uploaded the relevant files.

    Your installation does not seem to be up to date. Updates are available for your version of phpBB %1$s, please visit http://www.phpbb.com/downloads/ to obtain the correct package to update from Version %2$s to Version %3$s.', + 'NO_UPDATE_FILES_OUTDATED' => 'No valid update directory was found, please make sure you uploaded the relevant files.

    Your installation does not seem to be up to date. Updates are available for your version of phpBB %1$s, please visit https://www.phpbb.com/downloads/ to obtain the correct package to update from Version %2$s to Version %3$s.', 'NO_UPDATE_FILES_UP_TO_DATE' => 'Your version is up to date. There is no need to run the update tool. If you want to make an integrity check on your files make sure you uploaded the correct update files.', 'NO_UPDATE_INFO' => 'Update file information could not be found.', 'NO_UPDATES_REQUIRED' => 'No updates required', @@ -536,7 +536,7 @@ $lang = array_merge($lang, array(

    The recommended way of updating your installation listed here is only valid for the automatic update package. You are also able to update your installation using the methods listed within the INSTALL.html document. The steps for updating phpBB3 automatically are:

      -
    • Go to the phpBB.com downloads page and download the "Automatic Update Package" archive.

    • +
    • Go to the phpBB.com downloads page and download the "Automatic Update Package" archive.

    • Unpack the archive.

    • Upload the complete uncompressed install folder to your phpBB root directory (where your config.php file is).

    diff --git a/phpBB/language/en/ucp.php b/phpBB/language/en/ucp.php index 0dce2961e5..c8b8893779 100644 --- a/phpBB/language/en/ucp.php +++ b/phpBB/language/en/ucp.php @@ -39,7 +39,7 @@ if (empty($lang) || !is_array($lang)) $lang = array_merge($lang, array( 'TERMS_OF_USE_CONTENT' => 'By accessing “%1$s” (hereinafter “we”, “us”, “our”, “%1$s”, “%2$s”), you agree to be legally bound by the following terms. If you do not agree to be legally bound by all of the following terms then please do not access and/or use “%1$s”. We may change these at any time and we’ll do our utmost in informing you, though it would be prudent to review this regularly yourself as your continued usage of “%1$s” after changes mean you agree to be legally bound by these terms as they are updated and/or amended.

    - Our forums are powered by phpBB (hereinafter “they”, “them”, “their”, “phpBB software”, “www.phpbb.com”, “phpBB Group”, “phpBB Teams”) which is a bulletin board solution released under the “General Public License” (hereinafter “GPL”) and can be downloaded from www.phpbb.com. The phpBB software only facilitates internet based discussions, the phpBB Group are not responsible for what we allow and/or disallow as permissible content and/or conduct. For further information about phpBB, please see: http://www.phpbb.com/.
    + Our forums are powered by phpBB (hereinafter “they”, “them”, “their”, “phpBB software”, “www.phpbb.com”, “phpBB Group”, “phpBB Teams”) which is a bulletin board solution released under the “General Public License” (hereinafter “GPL”) and can be downloaded from www.phpbb.com. The phpBB software only facilitates internet based discussions, the phpBB Group are not responsible for what we allow and/or disallow as permissible content and/or conduct. For further information about phpBB, please see: https://www.phpbb.com/.

    You agree not to post any abusive, obscene, vulgar, slanderous, hateful, threatening, sexually-orientated or any other material that may violate any laws be it of your country, the country where “%1$s” is hosted or International Law. Doing so may lead to you being immediately and permanently banned, with notification of your Internet Service Provider if deemed required by us. The IP address of all posts are recorded to aid in enforcing these conditions. You agree that “%1$s” have the right to remove, edit, move or close any topic at any time should we see fit. As a user you agree to any information you have entered to being stored in a database. While this information will not be disclosed to any third party without your consent, neither “%1$s” nor phpBB shall be held responsible for any hacking attempt that may lead to the data being compromised. ', From 97f633bcedbdc0dd037559f9b7be3f8921a053df Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Fri, 12 Jul 2013 16:08:13 -0400 Subject: [PATCH 2177/2494] [ticket/11671] Add phing as a dependency and upgrade deps PHPBB3-11671 --- phpBB/composer.json | 3 +- phpBB/composer.lock | 170 +++++++++++++++++++++++++++++--------------- 2 files changed, 115 insertions(+), 58 deletions(-) diff --git a/phpBB/composer.json b/phpBB/composer.json index 14190f5e82..9e73936322 100644 --- a/phpBB/composer.json +++ b/phpBB/composer.json @@ -2,6 +2,7 @@ "require-dev": { "fabpot/goutte": "v0.1.0", "phpunit/dbunit": "1.2.*", - "phpunit/phpunit": "3.7.*" + "phpunit/phpunit": "3.7.*", + "phing/phing": "2.4.*" } } diff --git a/phpBB/composer.lock b/phpBB/composer.lock index 70b352a320..dd09b6cd56 100644 --- a/phpBB/composer.lock +++ b/phpBB/composer.lock @@ -1,9 +1,5 @@ { - "_readme": [ - "This file locks the dependencies of your project to a known state", - "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file" - ], - "hash": "656de56578d4eb3e4779bc0ab95524f5", + "hash": "ef6d05965cca4e390fff7ce63e9d2d49", "packages": [ ], @@ -152,6 +148,58 @@ ], "time": "2012-12-19 23:06:35" }, + { + "name": "phing/phing", + "version": "2.4.14", + "source": { + "type": "git", + "url": "https://github.com/phingofficial/phing", + "reference": "2.4.14" + }, + "dist": { + "type": "zip", + "url": "https://github.com/phingofficial/phing/archive/2.4.14.zip", + "reference": "2.4.14", + "shasum": "" + }, + "require": { + "php": ">=5.2.0" + }, + "bin": [ + "bin/phing" + ], + "type": "library", + "autoload": { + "classmap": [ + "classes/phing/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "include-path": [ + "classes" + ], + "license": [ + "LGPL3" + ], + "authors": [ + { + "name": "Michiel Rook", + "email": "mrook@php.net" + }, + { + "name": "Phing Community", + "homepage": "http://www.phing.info/trac/wiki/Development/Contributors" + } + ], + "description": "PHing Is Not GNU make; it's a PHP project build system or build tool based on Apache Ant.", + "homepage": "http://www.phing.info/", + "keywords": [ + "build", + "task", + "tool" + ], + "time": "2012-11-29 21:23:47" + }, { "name": "phpunit/dbunit", "version": "1.2.3", @@ -212,16 +260,16 @@ }, { "name": "phpunit/php-code-coverage", - "version": "1.2.9", + "version": "1.2.12", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "1.2.9" + "reference": "1.2.12" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/1.2.9", - "reference": "1.2.9", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/1.2.12", + "reference": "1.2.12", "shasum": "" }, "require": { @@ -230,11 +278,19 @@ "phpunit/php-text-template": ">=1.1.1@stable", "phpunit/php-token-stream": ">=1.1.3@stable" }, + "require-dev": { + "phpunit/phpunit": "3.7.*@dev" + }, "suggest": { "ext-dom": "*", "ext-xdebug": ">=2.0.5" }, "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.2.x-dev" + } + }, "autoload": { "classmap": [ "PHP/" @@ -261,7 +317,7 @@ "testing", "xunit" ], - "time": "2013-02-26 18:55:56" + "time": "2013-07-06 06:26:16" }, { "name": "phpunit/php-file-iterator", @@ -443,16 +499,16 @@ }, { "name": "phpunit/phpunit", - "version": "3.7.19", + "version": "3.7.22", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "3.7.19" + "reference": "3.7.22" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/3.7.19", - "reference": "3.7.19", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/3.7.22", + "reference": "3.7.22", "shasum": "" }, "require": { @@ -461,12 +517,12 @@ "ext-reflection": "*", "ext-spl": "*", "php": ">=5.3.3", - "phpunit/php-code-coverage": ">=1.2.1,<1.3.0", + "phpunit/php-code-coverage": "~1.2.1", "phpunit/php-file-iterator": ">=1.3.1", "phpunit/php-text-template": ">=1.1.1", - "phpunit/php-timer": ">=1.0.2,<1.1.0", - "phpunit/phpunit-mock-objects": ">=1.2.0,<1.3.0", - "symfony/yaml": ">=2.0.0,<2.3.0" + "phpunit/php-timer": "~1.0.2", + "phpunit/phpunit-mock-objects": "~1.2.0", + "symfony/yaml": "~2.0" }, "require-dev": { "pear-pear/pear": "1.9.4" @@ -513,7 +569,7 @@ "testing", "xunit" ], - "time": "2013-03-25 11:45:06" + "time": "2013-07-06 06:29:15" }, { "name": "phpunit/phpunit-mock-objects", @@ -566,17 +622,17 @@ }, { "name": "symfony/browser-kit", - "version": "v2.1.10", + "version": "v2.1.11", "target-dir": "Symfony/Component/BrowserKit", "source": { "type": "git", "url": "https://github.com/symfony/BrowserKit.git", - "reference": "v2.1.10" + "reference": "v2.1.11" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/BrowserKit/zipball/v2.1.10", - "reference": "v2.1.10", + "url": "https://api.github.com/repos/symfony/BrowserKit/zipball/v2.1.11", + "reference": "v2.1.11", "shasum": "" }, "require": { @@ -616,17 +672,17 @@ }, { "name": "symfony/css-selector", - "version": "v2.1.10", + "version": "v2.1.11", "target-dir": "Symfony/Component/CssSelector", "source": { "type": "git", "url": "https://github.com/symfony/CssSelector.git", - "reference": "v2.1.10" + "reference": "v2.1.11" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/CssSelector/zipball/v2.1.10", - "reference": "v2.1.10", + "url": "https://api.github.com/repos/symfony/CssSelector/zipball/v2.1.11", + "reference": "v2.1.11", "shasum": "" }, "require": { @@ -654,21 +710,21 @@ ], "description": "Symfony CssSelector Component", "homepage": "http://symfony.com", - "time": "2013-01-09 08:51:07" + "time": "2013-05-17 00:31:34" }, { "name": "symfony/dom-crawler", - "version": "v2.1.10", + "version": "v2.1.11", "target-dir": "Symfony/Component/DomCrawler", "source": { "type": "git", "url": "https://github.com/symfony/DomCrawler.git", - "reference": "v2.1.10" + "reference": "v2.1.11" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/DomCrawler/zipball/v2.1.10", - "reference": "v2.1.10", + "url": "https://api.github.com/repos/symfony/DomCrawler/zipball/v2.1.11", + "reference": "v2.1.11", "shasum": "" }, "require": { @@ -702,21 +758,21 @@ ], "description": "Symfony DomCrawler Component", "homepage": "http://symfony.com", - "time": "2013-03-27 17:13:16" + "time": "2013-05-16 00:06:15" }, { "name": "symfony/event-dispatcher", - "version": "v2.2.1", + "version": "v2.3.1", "target-dir": "Symfony/Component/EventDispatcher", "source": { "type": "git", "url": "https://github.com/symfony/EventDispatcher.git", - "reference": "v2.2.1" + "reference": "v2.3.1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/v2.2.1", - "reference": "v2.2.1", + "url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/v2.3.1", + "reference": "v2.3.1", "shasum": "" }, "require": { @@ -726,13 +782,13 @@ "symfony/dependency-injection": ">=2.0,<3.0" }, "suggest": { - "symfony/dependency-injection": "2.2.*", - "symfony/http-kernel": "2.2.*" + "symfony/dependency-injection": "", + "symfony/http-kernel": "" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.3-dev" } }, "autoload": { @@ -756,21 +812,21 @@ ], "description": "Symfony EventDispatcher Component", "homepage": "http://symfony.com", - "time": "2013-02-11 11:26:43" + "time": "2013-05-13 14:36:40" }, { "name": "symfony/finder", - "version": "v2.1.10", + "version": "v2.1.11", "target-dir": "Symfony/Component/Finder", "source": { "type": "git", "url": "https://github.com/symfony/Finder.git", - "reference": "v2.1.10" + "reference": "v2.1.11" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Finder/zipball/v2.1.10", - "reference": "v2.1.10", + "url": "https://api.github.com/repos/symfony/Finder/zipball/v2.1.11", + "reference": "v2.1.11", "shasum": "" }, "require": { @@ -798,21 +854,21 @@ ], "description": "Symfony Finder Component", "homepage": "http://symfony.com", - "time": "2013-03-06 19:26:55" + "time": "2013-05-25 15:47:15" }, { "name": "symfony/process", - "version": "v2.1.9", + "version": "v2.1.11", "target-dir": "Symfony/Component/Process", "source": { "type": "git", "url": "https://github.com/symfony/Process.git", - "reference": "v2.1.9" + "reference": "v2.1.11" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Process/zipball/v2.1.9", - "reference": "v2.1.9", + "url": "https://api.github.com/repos/symfony/Process/zipball/v2.1.11", + "reference": "v2.1.11", "shasum": "" }, "require": { @@ -840,21 +896,21 @@ ], "description": "Symfony Process Component", "homepage": "http://symfony.com", - "time": "2013-03-23 07:44:01" + "time": "2013-05-06 10:21:56" }, { "name": "symfony/yaml", - "version": "v2.2.1", + "version": "v2.3.1", "target-dir": "Symfony/Component/Yaml", "source": { "type": "git", "url": "https://github.com/symfony/Yaml.git", - "reference": "v2.2.1" + "reference": "v2.3.1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Yaml/zipball/v2.2.1", - "reference": "v2.2.1", + "url": "https://api.github.com/repos/symfony/Yaml/zipball/v2.3.1", + "reference": "v2.3.1", "shasum": "" }, "require": { @@ -863,7 +919,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.2-dev" + "dev-master": "2.3-dev" } }, "autoload": { @@ -887,7 +943,7 @@ ], "description": "Symfony Yaml Component", "homepage": "http://symfony.com", - "time": "2013-03-23 07:49:54" + "time": "2013-05-10 18:12:13" } ], "aliases": [ From a01d8cdfa33467f580edb77dbd10185de556cce2 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 12 Jul 2013 21:20:33 -0400 Subject: [PATCH 2178/2494] [ticket/9657] Add functional test for restoring a post/topic PHPBB3-9657 --- tests/functional/softdelete_test.php | 73 ++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) diff --git a/tests/functional/softdelete_test.php b/tests/functional/softdelete_test.php index 0ebbab66ab..b42c52b5cf 100644 --- a/tests/functional/softdelete_test.php +++ b/tests/functional/softdelete_test.php @@ -370,6 +370,79 @@ class phpbb_functional_softdelete_test extends phpbb_functional_test_case ), 'after moving #2'); } + public function test_restore_post() + { + $this->login(); + $this->load_ids(array( + 'forums' => array( + 'Soft Delete #1', + 'Soft Delete #2', + ), + 'topics' => array( + 'Soft Delete Topic #1', + ), + 'posts' => array( + 'Soft Delete Topic #1', + 'Re: Soft Delete Topic #1-#2', + ), + )); + + $this->assert_forum_details($this->data['forums']['Soft Delete #1'], array( + 'forum_posts_approved' => 0, + 'forum_posts_unapproved' => 0, + 'forum_posts_softdeleted' => 2, + 'forum_topics_approved' => 0, + 'forum_topics_unapproved' => 0, + 'forum_topics_softdeleted' => 1, + 'forum_last_post_id' => 0, + ), 'before restoring #1'); + + $this->assert_forum_details($this->data['forums']['Soft Delete #2'], array( + 'forum_posts_approved' => 0, + 'forum_posts_unapproved' => 0, + 'forum_posts_softdeleted' => 0, + 'forum_topics_approved' => 0, + 'forum_topics_unapproved' => 0, + 'forum_topics_softdeleted' => 0, + 'forum_last_post_id' => 0, + ), 'before restoring #2'); + + $crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Soft Delete Topic #1']}&sid={$this->sid}"); + + $this->add_lang('mcp'); + $form = $crawler->selectButton($this->lang('RESTORE'))->form(); + $crawler = self::submit($form); + $this->assertContainsLang('RESTORE_POST', $crawler->text()); + + $form = $crawler->selectButton('Yes')->form(); + $crawler = self::submit($form); + $this->assertContainsLang('POST_RESTORED_SUCCESS', $crawler->text()); + + $crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Soft Delete Topic #1']}&sid={$this->sid}"); + $this->assertContains('Soft Delete #1', $crawler->filter('.navlinks')->text()); + $this->assertContains('Soft Delete Topic #1', $crawler->filter('h2')->text()); + + $this->assert_forum_details($this->data['forums']['Soft Delete #1'], array( + 'forum_posts_approved' => 1, + 'forum_posts_unapproved' => 0, + 'forum_posts_softdeleted' => 1, + 'forum_topics_approved' => 1, + 'forum_topics_unapproved' => 0, + 'forum_topics_softdeleted' => 0, + 'forum_last_post_id' => $this->data['posts']['Soft Delete Topic #1'], + ), 'after restoring #1'); + + $this->assert_forum_details($this->data['forums']['Soft Delete #2'], array( + 'forum_posts_approved' => 0, + 'forum_posts_unapproved' => 0, + 'forum_posts_softdeleted' => 0, + 'forum_topics_approved' => 0, + 'forum_topics_unapproved' => 0, + 'forum_topics_softdeleted' => 0, + 'forum_last_post_id' => 0, + ), 'after restoring #2'); + } + public function assert_forum_details($forum_id, $details, $additional_error_message = '') { $this->db = $this->get_db(); From ee3d4199bbb9d5e5374fe8e04ae9e9f4c6c0ec18 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Fri, 12 Jul 2013 22:40:55 -0400 Subject: [PATCH 2179/2494] [ticket/11112] Do not change opensource.org link to https PHPBB3-11112 --- phpBB/language/en/ucp.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/language/en/ucp.php b/phpBB/language/en/ucp.php index c8b8893779..ad11213052 100644 --- a/phpBB/language/en/ucp.php +++ b/phpBB/language/en/ucp.php @@ -39,7 +39,7 @@ if (empty($lang) || !is_array($lang)) $lang = array_merge($lang, array( 'TERMS_OF_USE_CONTENT' => 'By accessing “%1$s” (hereinafter “we”, “us”, “our”, “%1$s”, “%2$s”), you agree to be legally bound by the following terms. If you do not agree to be legally bound by all of the following terms then please do not access and/or use “%1$s”. We may change these at any time and we’ll do our utmost in informing you, though it would be prudent to review this regularly yourself as your continued usage of “%1$s” after changes mean you agree to be legally bound by these terms as they are updated and/or amended.

    - Our forums are powered by phpBB (hereinafter “they”, “them”, “their”, “phpBB software”, “www.phpbb.com”, “phpBB Group”, “phpBB Teams”) which is a bulletin board solution released under the “General Public License” (hereinafter “GPL”) and can be downloaded from www.phpbb.com. The phpBB software only facilitates internet based discussions, the phpBB Group are not responsible for what we allow and/or disallow as permissible content and/or conduct. For further information about phpBB, please see: https://www.phpbb.com/.
    + Our forums are powered by phpBB (hereinafter “they”, “them”, “their”, “phpBB software”, “www.phpbb.com”, “phpBB Group”, “phpBB Teams”) which is a bulletin board solution released under the “General Public License” (hereinafter “GPL”) and can be downloaded from www.phpbb.com. The phpBB software only facilitates internet based discussions, the phpBB Group are not responsible for what we allow and/or disallow as permissible content and/or conduct. For further information about phpBB, please see: https://www.phpbb.com/.

    You agree not to post any abusive, obscene, vulgar, slanderous, hateful, threatening, sexually-orientated or any other material that may violate any laws be it of your country, the country where “%1$s” is hosted or International Law. Doing so may lead to you being immediately and permanently banned, with notification of your Internet Service Provider if deemed required by us. The IP address of all posts are recorded to aid in enforcing these conditions. You agree that “%1$s” have the right to remove, edit, move or close any topic at any time should we see fit. As a user you agree to any information you have entered to being stored in a database. While this information will not be disclosed to any third party without your consent, neither “%1$s” nor phpBB shall be held responsible for any hacking attempt that may lead to the data being compromised. ', From e96932b0e3fd7c3ed4207886afa575d7c1f2f88a Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 12 Jul 2013 22:43:11 -0400 Subject: [PATCH 2180/2494] [ticket/9657] Add functional test for splitting topic PHPBB3-9657 --- tests/functional/softdelete_test.php | 81 ++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) diff --git a/tests/functional/softdelete_test.php b/tests/functional/softdelete_test.php index b42c52b5cf..512b9af909 100644 --- a/tests/functional/softdelete_test.php +++ b/tests/functional/softdelete_test.php @@ -443,6 +443,87 @@ class phpbb_functional_softdelete_test extends phpbb_functional_test_case ), 'after restoring #2'); } + public function test_split_topic() + { + $this->login(); + $this->load_ids(array( + 'forums' => array( + 'Soft Delete #1', + 'Soft Delete #2', + ), + 'topics' => array( + 'Soft Delete Topic #1', + ), + 'posts' => array( + 'Soft Delete Topic #1', + 'Re: Soft Delete Topic #1-#2', + ), + )); + + $this->assert_forum_details($this->data['forums']['Soft Delete #1'], array( + 'forum_posts_approved' => 1, + 'forum_posts_unapproved' => 0, + 'forum_posts_softdeleted' => 1, + 'forum_topics_approved' => 1, + 'forum_topics_unapproved' => 0, + 'forum_topics_softdeleted' => 0, + 'forum_last_post_id' => $this->data['posts']['Soft Delete Topic #1'], + ), 'before splitting #1'); + + $this->assert_forum_details($this->data['forums']['Soft Delete #2'], array( + 'forum_posts_approved' => 0, + 'forum_posts_unapproved' => 0, + 'forum_posts_softdeleted' => 0, + 'forum_topics_approved' => 0, + 'forum_topics_unapproved' => 0, + 'forum_topics_softdeleted' => 0, + 'forum_last_post_id' => 0, + ), 'before splitting #2'); + + $crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Soft Delete Topic #1']}&sid={$this->sid}"); + + $this->add_lang('mcp'); + $form = $crawler->selectButton('Go')->eq(2)->form(); + $form['action']->select('split'); + $crawler = self::submit($form); + $this->assertContainsLang('SPLIT_TOPIC_EXPLAIN', $crawler->text()); + + $form = $crawler->selectButton('Submit')->form(array( + 'subject' => 'Soft Delete Topic #2', + )); + $form['to_forum_id']->select($this->data['forums']['Soft Delete #2']); + $form['post_id_list'][1]->tick(); + $crawler = self::submit($form); + + $form = $crawler->selectButton('Yes')->form(); + $crawler = self::submit($form); + $this->assertContainsLang('TOPIC_SPLIT_SUCCESS', $crawler->text()); + + $crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Soft Delete Topic #1']}&sid={$this->sid}"); + $this->assertContains('Soft Delete Topic #1', $crawler->filter('h2')->text()); + $this->assertNotContains('Re: Soft Delete Topic #1-#2', $crawler->text()); + + $this->assert_forum_details($this->data['forums']['Soft Delete #1'], array( + 'forum_posts_approved' => 1, + 'forum_posts_unapproved' => 0, + 'forum_posts_softdeleted' => 0, + 'forum_topics_approved' => 1, + 'forum_topics_unapproved' => 0, + 'forum_topics_softdeleted' => 0, + 'forum_last_post_id' => $this->data['posts']['Soft Delete Topic #1'], + ), 'after restoring #1'); + + $this->assert_forum_details($this->data['forums']['Soft Delete #2'], array( + 'forum_posts_approved' => 0, + 'forum_posts_unapproved' => 0, + 'forum_posts_softdeleted' => 1, + 'forum_topics_approved' => 0, + 'forum_topics_unapproved' => 0, + 'forum_topics_softdeleted' => 1, + 'forum_last_post_id' => 0, + ), 'after restoring #2'); + } + public function assert_forum_details($forum_id, $details, $additional_error_message = '') { $this->db = $this->get_db(); From da38d13094a1f62038dbb527bff19c43110d99a2 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 13 Jul 2013 00:53:55 -0400 Subject: [PATCH 2181/2494] [ticket/9657] Add functional tests for forking a copy PHPBB3-9657 --- tests/functional/softdelete_test.php | 168 +++++++++++++++++++++++++++ 1 file changed, 168 insertions(+) diff --git a/tests/functional/softdelete_test.php b/tests/functional/softdelete_test.php index 512b9af909..bd4d34cf99 100644 --- a/tests/functional/softdelete_test.php +++ b/tests/functional/softdelete_test.php @@ -524,6 +524,174 @@ class phpbb_functional_softdelete_test extends phpbb_functional_test_case ), 'after restoring #2'); } + public function test_move_topic_back() + { + $this->login(); + $this->load_ids(array( + 'forums' => array( + 'Soft Delete #1', + 'Soft Delete #2', + ), + 'topics' => array( + 'Soft Delete Topic #1', + 'Soft Delete Topic #2', + ), + 'posts' => array( + 'Soft Delete Topic #1', + 'Re: Soft Delete Topic #1-#2', + ), + )); + + $crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Soft Delete Topic #2']}&sid={$this->sid}"); + + $form = $crawler->selectButton('Go')->eq(1)->form(); + $form['action']->select('move'); + $crawler = self::submit($form); + + $form = $crawler->selectButton('Yes')->form(); + $form['to_forum_id']->select($this->data['forums']['Soft Delete #1']); + $crawler = self::submit($form); + + $this->assert_forum_details($this->data['forums']['Soft Delete #1'], array( + 'forum_posts_approved' => 1, + 'forum_posts_unapproved' => 0, + 'forum_posts_softdeleted' => 1, + 'forum_topics_approved' => 1, + 'forum_topics_unapproved' => 0, + 'forum_topics_softdeleted' => 1, + 'forum_last_post_id' => $this->data['posts']['Soft Delete Topic #1'], + ), 'after moving back'); + } + + public function test_merge_topics() + { + $this->login(); + $this->load_ids(array( + 'forums' => array( + 'Soft Delete #1', + 'Soft Delete #2', + ), + 'topics' => array( + 'Soft Delete Topic #1', + 'Soft Delete Topic #2', + ), + 'posts' => array( + 'Soft Delete Topic #1', + 'Re: Soft Delete Topic #1-#2', + ), + )); + + $this->assert_forum_details($this->data['forums']['Soft Delete #1'], array( + 'forum_posts_approved' => 1, + 'forum_posts_unapproved' => 0, + 'forum_posts_softdeleted' => 1, + 'forum_topics_approved' => 1, + 'forum_topics_unapproved' => 0, + 'forum_topics_softdeleted' => 1, + 'forum_last_post_id' => $this->data['posts']['Soft Delete Topic #1'], + ), 'before merging #1'); + + $crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Soft Delete Topic #2']}&sid={$this->sid}"); + + $this->add_lang('mcp'); + $form = $crawler->selectButton('Go')->eq(1)->form(); + $form['action']->select('merge_topic'); + $crawler = self::submit($form); + $this->assertContainsLang('SELECT_MERGE', $crawler->text()); + + $crawler = self::request('GET', "mcp.php?f={$this->data['forums']['Soft Delete #1']}&t={$this->data['topics']['Soft Delete Topic #2']}&i=main&mode=forum_view&action=merge_topic&to_topic_id={$this->data['topics']['Soft Delete Topic #1']}"); + $this->assertContainsLang('MERGE_TOPICS_CONFIRM', $crawler->text()); + + $form = $crawler->selectButton('Yes')->form(); + $crawler = self::submit($form); + $this->assertContainsLang('POSTS_MERGED_SUCCESS', $crawler->text()); + + $crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Soft Delete Topic #1']}&sid={$this->sid}"); + $this->assertContains('Soft Delete Topic #1', $crawler->filter('h2')->text()); + $this->assertContainsLang('POST_DELETED', $crawler->filter('body')->text()); + + $this->assert_forum_details($this->data['forums']['Soft Delete #1'], array( + 'forum_posts_approved' => 1, + 'forum_posts_unapproved' => 0, + 'forum_posts_softdeleted' => 1, + 'forum_topics_approved' => 1, + 'forum_topics_unapproved' => 0, + 'forum_topics_softdeleted' => 0, + 'forum_last_post_id' => $this->data['posts']['Soft Delete Topic #1'], + ), 'after merging #1'); + } + + public function test_fork_topic() + { + $this->login(); + $this->load_ids(array( + 'forums' => array( + 'Soft Delete #1', + 'Soft Delete #2', + ), + 'topics' => array( + 'Soft Delete Topic #1', + ), + 'posts' => array( + 'Soft Delete Topic #1', + 'Re: Soft Delete Topic #1-#2', + ), + )); + + $this->assert_forum_details($this->data['forums']['Soft Delete #1'], array( + 'forum_posts_approved' => 1, + 'forum_posts_unapproved' => 0, + 'forum_posts_softdeleted' => 1, + 'forum_topics_approved' => 1, + 'forum_topics_unapproved' => 0, + 'forum_topics_softdeleted' => 0, + 'forum_last_post_id' => $this->data['posts']['Soft Delete Topic #1'], + ), 'before forking #1'); + + $this->assert_forum_details($this->data['forums']['Soft Delete #2'], array( + 'forum_posts_approved' => 0, + 'forum_posts_unapproved' => 0, + 'forum_posts_softdeleted' => 0, + 'forum_topics_approved' => 0, + 'forum_topics_unapproved' => 0, + 'forum_topics_softdeleted' => 0, + 'forum_last_post_id' => 0, + ), 'before forking #2'); + + $crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Soft Delete Topic #1']}&sid={$this->sid}"); + + $this->add_lang('mcp'); + $form = $crawler->selectButton('Go')->eq(2)->form(); + $form['action']->select('fork'); + $crawler = self::submit($form); + $this->assertContainsLang('FORK_TOPIC', $crawler->text()); + + $form = $crawler->selectButton('Yes')->form(); + $form['to_forum_id']->select($this->data['forums']['Soft Delete #2']); + $crawler = self::submit($form); + $this->assertContainsLang('TOPIC_FORKED_SUCCESS', $crawler->text()); + + $this->assert_forum_details($this->data['forums']['Soft Delete #1'], array( + 'forum_posts_approved' => 1, + 'forum_posts_unapproved' => 0, + 'forum_posts_softdeleted' => 1, + 'forum_topics_approved' => 1, + 'forum_topics_unapproved' => 0, + 'forum_topics_softdeleted' => 0, + 'forum_last_post_id' => $this->data['posts']['Soft Delete Topic #1'], + ), 'after forking #1'); + + $this->assert_forum_details($this->data['forums']['Soft Delete #2'], array( + 'forum_posts_approved' => 1, + 'forum_posts_unapproved' => 0, + 'forum_posts_softdeleted' => 1, + 'forum_topics_approved' => 1, + 'forum_topics_unapproved' => 0, + 'forum_topics_softdeleted' => 0, + 'forum_last_post_id' => $this->data['posts']['Soft Delete Topic #1'] + 2, + ), 'after forking #2'); + } + public function assert_forum_details($forum_id, $details, $additional_error_message = '') { $this->db = $this->get_db(); From 28e3341fcde976754f122a9c540b20aa705658fc Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 13 Jul 2013 00:54:39 -0400 Subject: [PATCH 2182/2494] [ticket/9657] Keep approval state of posts/topics when copying them PHPBB3-9657 --- phpBB/includes/mcp/mcp_main.php | 41 ++++++++++++++++++++++++++++----- 1 file changed, 35 insertions(+), 6 deletions(-) diff --git a/phpBB/includes/mcp/mcp_main.php b/phpBB/includes/mcp/mcp_main.php index eddfdc3759..275edbe55a 100644 --- a/phpBB/includes/mcp/mcp_main.php +++ b/phpBB/includes/mcp/mcp_main.php @@ -1144,10 +1144,10 @@ function mcp_fork_topic($topic_ids) { $topic_data = get_topic_data($topic_ids, 'f_post'); - $total_posts = 0; + $total_topics = $total_topics_unapproved = $total_topics_softdeleted = 0; + $total_posts = $total_posts_unapproved = $total_posts_softdeleted = 0; $new_topic_id_list = array(); - foreach ($topic_data as $topic_id => $topic_row) { if (!isset($search_type) && $topic_row['enable_indexing']) @@ -1178,7 +1178,7 @@ function mcp_fork_topic($topic_ids) 'forum_id' => (int) $to_forum_id, 'icon_id' => (int) $topic_row['icon_id'], 'topic_attachment' => (int) $topic_row['topic_attachment'], - 'topic_visibility' => ITEM_APPROVED, + 'topic_visibility' => (int) $topic_row['topic_visibility'], 'topic_reported' => 0, 'topic_title' => (string) $topic_row['topic_title'], 'topic_poster' => (int) $topic_row['topic_poster'], @@ -1206,6 +1206,19 @@ function mcp_fork_topic($topic_ids) $new_topic_id = $db->sql_nextid(); $new_topic_id_list[$topic_id] = $new_topic_id; + switch ($topic_row['topic_visibility']) + { + case ITEM_APPROVED: + $total_topics++; + break; + case ITEM_UNAPPROVED: + $total_topics_unapproved++; + break; + case ITEM_DELETED: + $total_topics_softdeleted++; + break; + } + if ($topic_row['poll_start']) { $poll_rows = array(); @@ -1246,7 +1259,6 @@ function mcp_fork_topic($topic_ids) continue; } - $total_posts += sizeof($post_rows); foreach ($post_rows as $row) { $sql_ary = array( @@ -1256,7 +1268,7 @@ function mcp_fork_topic($topic_ids) 'icon_id' => (int) $row['icon_id'], 'poster_ip' => (string) $row['poster_ip'], 'post_time' => (int) $row['post_time'], - 'post_visibility' => ITEM_APPROVED, + 'post_visibility' => (int) $row['post_visibility'], 'post_reported' => 0, 'enable_bbcode' => (int) $row['enable_bbcode'], 'enable_smilies' => (int) $row['enable_smilies'], @@ -1280,6 +1292,19 @@ function mcp_fork_topic($topic_ids) $db->sql_query('INSERT INTO ' . POSTS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary)); $new_post_id = $db->sql_nextid(); + switch ($row['post_visibility']) + { + case ITEM_APPROVED: + $total_posts++; + break; + case ITEM_UNAPPROVED: + $total_posts_unapproved++; + break; + case ITEM_DELETED: + $total_posts_softdeleted++; + break; + } + // Copy whether the topic is dotted markread('post', $to_forum_id, $new_topic_id, 0, $row['poster_id']); @@ -1374,7 +1399,11 @@ function mcp_fork_topic($topic_ids) // Sync new topics, parent forums and board stats $sql = 'UPDATE ' . FORUMS_TABLE . ' SET forum_posts_approved = forum_posts_approved + ' . $total_posts . ', - forum_topics_approved = forum_topics_approved + ' . sizeof($new_topic_id_list) . ' + forum_posts_unapproved = forum_posts_unapproved + ' . $total_posts_unapproved . ', + forum_posts_softdeleted = forum_posts_softdeleted + ' . $total_posts_softdeleted . ', + forum_topics_approved = forum_topics_approved + ' . $total_topics . ', + forum_topics_unapproved = forum_topics_unapproved + ' . $total_topics_unapproved . ', + forum_topics_softdeleted = forum_topics_softdeleted + ' . $total_topics_softdeleted . ' WHERE forum_id = ' . $to_forum_id; $db->sql_query($sql); From 06caac044479c3ff41f48157f40e8cb00e3d5e84 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 10 Jun 2013 13:48:21 +0200 Subject: [PATCH 2183/2494] [ticket/11574] Try to load updated service.yml before the default one PHPBB3-11574 --- phpBB/includes/di/extension/core.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/di/extension/core.php b/phpBB/includes/di/extension/core.php index 9c36ba2fc4..d0a3ebdf99 100644 --- a/phpBB/includes/di/extension/core.php +++ b/phpBB/includes/di/extension/core.php @@ -51,8 +51,16 @@ class phpbb_di_extension_core extends Extension */ public function load(array $config, ContainerBuilder $container) { - $loader = new YamlFileLoader($container, new FileLocator(phpbb_realpath($this->root_path . 'config'))); - $loader->load('services.yml'); + if (file_exists($this->root_path . 'install/update/new/config/services.yml')) + { + $loader = new YamlFileLoader($container, new FileLocator(phpbb_realpath($this->root_path . 'install/update/new/config'))); + $loader->load('services.yml'); + } + else if (file_exists($this->root_path . 'config/services.yml')) + { + $loader = new YamlFileLoader($container, new FileLocator(phpbb_realpath($this->root_path . 'config'))); + $loader->load('services.yml'); + } } /** From 8aca9635f57630b89615d888cc8b92f5ac9b327c Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 10 Jun 2013 13:50:15 +0200 Subject: [PATCH 2184/2494] [ticket/11574] Find language files in update/new before throwing an error PHPBB3-11574 --- phpBB/includes/user.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/phpBB/includes/user.php b/phpBB/includes/user.php index 5530fe3f03..f823e85148 100644 --- a/phpBB/includes/user.php +++ b/phpBB/includes/user.php @@ -590,6 +590,18 @@ class phpbb_user extends phpbb_session $language_filename = $lang_path . $this->lang_name . '/' . $filename . '.' . $phpEx; } + if (!file_exists($language_filename)) + { + // File was not found, try to find it in update directory + $orig_language_filename = $language_filename; + $language_filename = str_replace('language/', 'install/update/new/language/', $language_filename); + if (!file_exists($language_filename)) + { + // Not found either, go back to the original file name + $language_filename = $orig_language_filename; + } + } + if (!file_exists($language_filename)) { global $config; From e12fd2fdda76f629060c517aab9812b8565cc696 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 10 Jun 2013 13:51:55 +0200 Subject: [PATCH 2185/2494] [ticket/11574] Require new files in database_update.php and add a class loader PHPBB3-11574 --- phpBB/install/database_update.php | 34 +++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index b20ca1e4ea..3341c20058 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -41,6 +41,26 @@ if (!function_exists('phpbb_require_updated')) } } +if (!function_exists('phpbb_include_updated')) +{ + function phpbb_include_updated($path, $optional = false) + { + global $phpbb_root_path; + + $new_path = $phpbb_root_path . 'install/update/new/' . $path; + $old_path = $phpbb_root_path . $path; + + if (file_exists($new_path)) + { + include($new_path); + } + else if (!$optional || file_exists($old_path)) + { + include($old_path); + } + } +} + function phpbb_end_update($cache, $config) { $cache->purge(); @@ -82,19 +102,21 @@ $phpbb_adm_relative_path = (isset($phpbb_adm_relative_path)) ? $phpbb_adm_relati $phpbb_admin_path = (defined('PHPBB_ADMIN_PATH')) ? PHPBB_ADMIN_PATH : $phpbb_root_path . $phpbb_adm_relative_path; // Include files -require($phpbb_root_path . 'includes/class_loader.' . $phpEx); +phpbb_require_updated('includes/class_loader.' . $phpEx); -require($phpbb_root_path . 'includes/functions.' . $phpEx); -require($phpbb_root_path . 'includes/functions_content.' . $phpEx); -require($phpbb_root_path . 'includes/functions_container.' . $phpEx); +phpbb_require_updated('includes/functions.' . $phpEx); +phpbb_require_updated('includes/functions_content.' . $phpEx); +phpbb_require_updated('includes/functions_container.' . $phpEx); -require($phpbb_root_path . 'includes/constants.' . $phpEx); -require($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx); +phpbb_require_updated('includes/constants.' . $phpEx); +phpbb_require_updated('includes/utf/utf_tools.' . $phpEx); // Set PHP error handler to ours set_error_handler(defined('PHPBB_MSG_HANDLER') ? PHPBB_MSG_HANDLER : 'msg_handler'); // Setup class loader first +$phpbb_class_loader_new = new phpbb_class_loader('phpbb_', "{$phpbb_root_path}install/update/new/includes/", $phpEx); +$phpbb_class_loader_new->register(); $phpbb_class_loader = new phpbb_class_loader('phpbb_', "{$phpbb_root_path}includes/", $phpEx); $phpbb_class_loader->register(); From f11993c0382d6942a14b37686d2c00dac97a6748 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 10 Jun 2013 13:54:48 +0200 Subject: [PATCH 2186/2494] [ticket/11574] Require new files in install/index.php and add a class loader PHPBB3-11574 --- phpBB/install/index.php | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/phpBB/install/index.php b/phpBB/install/index.php index f745f51974..90cd71d7f3 100644 --- a/phpBB/install/index.php +++ b/phpBB/install/index.php @@ -43,6 +43,23 @@ function phpbb_require_updated($path, $optional = false) } } +function phpbb_include_updated($path, $optional = false) +{ + global $phpbb_root_path; + + $new_path = $phpbb_root_path . 'install/update/new/' . $path; + $old_path = $phpbb_root_path . $path; + + if (file_exists($new_path)) + { + include($new_path); + } + else if (!$optional || file_exists($old_path)) + { + include($old_path); + } +} + phpbb_require_updated('includes/startup.' . $phpEx); // Try to override some limits - maybe it helps some... @@ -78,18 +95,20 @@ $phpbb_adm_relative_path = (isset($phpbb_adm_relative_path)) ? $phpbb_adm_relati $phpbb_admin_path = (defined('PHPBB_ADMIN_PATH')) ? PHPBB_ADMIN_PATH : $phpbb_root_path . $phpbb_adm_relative_path; // Include essential scripts -require($phpbb_root_path . 'includes/class_loader.' . $phpEx); +phpbb_require_updated('includes/class_loader.' . $phpEx); -require($phpbb_root_path . 'includes/functions.' . $phpEx); -require($phpbb_root_path . 'includes/functions_container.' . $phpEx); +phpbb_require_updated('includes/functions.' . $phpEx); +phpbb_require_updated('includes/functions_container.' . $phpEx); phpbb_require_updated('includes/functions_content.' . $phpEx, true); -include($phpbb_root_path . 'includes/functions_admin.' . $phpEx); -include($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx); -require($phpbb_root_path . 'includes/functions_install.' . $phpEx); +phpbb_include_updated('includes/functions_admin.' . $phpEx); +phpbb_include_updated('includes/utf/utf_tools.' . $phpEx); +phpbb_require_updated('includes/functions_install.' . $phpEx); // Setup class loader first +$phpbb_class_loader_new = new phpbb_class_loader('phpbb_', "{$phpbb_root_path}install/update/new/includes/", $phpEx); +$phpbb_class_loader_new->register(); $phpbb_class_loader = new phpbb_class_loader('phpbb_', "{$phpbb_root_path}includes/", $phpEx); $phpbb_class_loader->register(); $phpbb_class_loader_ext = new phpbb_class_loader('phpbb_ext_', "{$phpbb_root_path}ext/", $phpEx); From deac5f53e3e4131c315c93ce1324899da08d233e Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 10 Jun 2013 13:56:32 +0200 Subject: [PATCH 2187/2494] [ticket/11574] Load new language files whenever possible PHPBB3-11574 --- phpBB/install/index.php | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/phpBB/install/index.php b/phpBB/install/index.php index 90cd71d7f3..5494b57610 100644 --- a/phpBB/install/index.php +++ b/phpBB/install/index.php @@ -186,11 +186,23 @@ if (!file_exists($phpbb_root_path . 'language/' . $language) || !is_dir($phpbb_r } // And finally, load the relevant language files -include($phpbb_root_path . 'language/' . $language . '/common.' . $phpEx); -include($phpbb_root_path . 'language/' . $language . '/acp/common.' . $phpEx); -include($phpbb_root_path . 'language/' . $language . '/acp/board.' . $phpEx); -include($phpbb_root_path . 'language/' . $language . '/install.' . $phpEx); -include($phpbb_root_path . 'language/' . $language . '/posting.' . $phpEx); +$load_lang_files = array('common', 'acp/common', 'acp/board', 'install', 'posting'); +$new_path = $phpbb_root_path . 'install/update/new/language/' . $language . '/'; +$old_path = $phpbb_root_path . 'language/' . $language . '/'; + +// NOTE: we can not use "phpbb_include_updated" as the files uses vars which would be required +// to be global while loading. +foreach ($load_lang_files as $lang_file) +{ + if (file_exists($new_path . $lang_file . '.' . $phpEx)) + { + include($new_path . $lang_file . '.' . $phpEx); + } + else + { + include($old_path . $lang_file . '.' . $phpEx); + } +} // usually we would need every single constant here - and it would be consistent. For 3.0.x, use a dirty hack... :( From 3eaeede32176d8831f12529aa2053123293b67ca Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 10 Jun 2013 13:57:47 +0200 Subject: [PATCH 2188/2494] [ticket/11574] Use request object rather then request_var function PHPBB3-11574 --- phpBB/install/index.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/phpBB/install/index.php b/phpBB/install/index.php index 5494b57610..fd6734cbfb 100644 --- a/phpBB/install/index.php +++ b/phpBB/install/index.php @@ -127,7 +127,7 @@ $request = $phpbb_container->get('request'); request_var('', 0, false, false, $request); // "dependency injection" for a function // Try and load an appropriate language if required -$language = basename(request_var('language', '')); +$language = basename($request->variable('language', '')); if ($request->header('Accept-Language') && !$language) { @@ -212,8 +212,8 @@ define('CHMOD_READ', 4); define('CHMOD_WRITE', 2); define('CHMOD_EXECUTE', 1); -$mode = request_var('mode', 'overview'); -$sub = request_var('sub', ''); +$mode = $request->variable('mode', 'overview'); +$sub = $request->variable('sub', ''); // Set PHP error handler to ours set_error_handler(defined('PHPBB_MSG_HANDLER') ? PHPBB_MSG_HANDLER : 'msg_handler'); From fcf343733887d7d42a3060c48b1a009ae0520467 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 10 Jun 2013 13:58:36 +0200 Subject: [PATCH 2189/2494] [ticket/11574] Add correct language parameter to return links PHPBB3-11574 --- phpBB/install/database_update.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 3341c20058..de7f4f202e 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -286,7 +286,7 @@ while (!$migrator->finished()) if ((time() - $update_start_time) >= $safe_time_limit) { echo $user->lang['DATABASE_UPDATE_NOT_COMPLETED'] . '
    '; - echo '' . $user->lang['DATABASE_UPDATE_CONTINUE'] . ''; + echo '' . $user->lang['DATABASE_UPDATE_CONTINUE'] . ''; phpbb_end_update($cache, $config); } @@ -302,7 +302,7 @@ echo $user->lang['DATABASE_UPDATE_COMPLETE'] . '
    '; if ($request->variable('type', 0)) { echo $user->lang['INLINE_UPDATE_SUCCESSFUL'] . '

    '; - echo '' . $user->lang['CONTINUE_UPDATE_NOW'] . ''; + echo '' . $user->lang['CONTINUE_UPDATE_NOW'] . ''; } else { From 14ff1ef540f71e765ceeaa53b87ad62e4c8d8a40 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 10 Jun 2013 14:44:49 +0200 Subject: [PATCH 2190/2494] [ticket/11574] Create phpbb_log object before using it. PHPBB3-11574 --- phpBB/install/install_update.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php index df9b6c1c7e..90c56bcdcc 100644 --- a/phpBB/install/install_update.php +++ b/phpBB/install/install_update.php @@ -509,6 +509,9 @@ class install_update extends module if ($all_up_to_date) { + global $phpbb_log, $phpbb_container; + $phpbb_log = $phpbb_container->get('log'); + // Add database update to log add_log('admin', 'LOG_UPDATE_PHPBB', $this->current_version, $this->update_to_version); From 129e393b66125ed6b19cbc0a8defbefabf5cd5ca Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 10 Jun 2013 15:10:03 +0200 Subject: [PATCH 2191/2494] [ticket/11574] Include vendor into update packages PHPBB3-11574 --- build/package.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/build/package.php b/build/package.php index 48f42b3572..eef6765af6 100755 --- a/build/package.php +++ b/build/package.php @@ -121,6 +121,7 @@ if (sizeof($package->old_packages)) $package->run_command('cp -Rp ' . $package->get('dest_dir') . '/docs ' . $dest_filename_dir); $package->run_command('cp -Rp ' . $package->get('dest_dir') . '/install ' . $dest_filename_dir); + $package->run_command('cp -Rp ' . $package->get('dest_dir') . '/vendor ' . $dest_filename_dir); $package->run_command('mkdir ' . $dest_filename_dir . '/install/update'); $package->run_command('mkdir ' . $dest_filename_dir . '/install/update/old'); @@ -256,6 +257,7 @@ $update_info = array( // Copy the install files to their respective locations $package->run_command('cp -Rp ' . $package->get('dest_dir') . '/docs ' . $package->get('patch_directory')); $package->run_command('cp -Rp ' . $package->get('dest_dir') . '/install ' . $package->get('patch_directory')); + $package->run_command('cp -Rp ' . $package->get('dest_dir') . '/vendor ' . $package->get('patch_directory')); // Remove some files chdir($package->get('patch_directory') . '/install'); From fe7823b6685975012d3c033b335d7ed5fa9756d7 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 6 Jul 2013 19:26:37 +0200 Subject: [PATCH 2192/2494] [ticket/11574] Use log object instead of old function PHPBB3-11574 --- phpBB/install/install_update.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php index 90c56bcdcc..38d9f66629 100644 --- a/phpBB/install/install_update.php +++ b/phpBB/install/install_update.php @@ -509,11 +509,11 @@ class install_update extends module if ($all_up_to_date) { - global $phpbb_log, $phpbb_container; + global $phpbb_container; $phpbb_log = $phpbb_container->get('log'); // Add database update to log - add_log('admin', 'LOG_UPDATE_PHPBB', $this->current_version, $this->update_to_version); + $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_UPDATE_PHPBB', time(), array($this->current_version, $this->update_to_version)); $db->sql_return_on_error(true); $db->sql_query('DELETE FROM ' . CONFIG_TABLE . " WHERE config_name = 'version_update_from'"); From 3bccd10ccd509ae622cfd23f075fce1d1289888a Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 6 Jul 2013 19:35:42 +0200 Subject: [PATCH 2193/2494] [ticket/11574] Only fall back to install/update versions, when IN_INSTALL ;) PHPBB3-11574 --- phpBB/includes/di/extension/core.php | 3 ++- phpBB/includes/user.php | 7 ++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/phpBB/includes/di/extension/core.php b/phpBB/includes/di/extension/core.php index d0a3ebdf99..4e1159e6fd 100644 --- a/phpBB/includes/di/extension/core.php +++ b/phpBB/includes/di/extension/core.php @@ -51,7 +51,8 @@ class phpbb_di_extension_core extends Extension */ public function load(array $config, ContainerBuilder $container) { - if (file_exists($this->root_path . 'install/update/new/config/services.yml')) + // If we are in install, try to use the updated version, when available + if (defined('IN_INSTALL') && file_exists($this->root_path . 'install/update/new/config/services.yml')) { $loader = new YamlFileLoader($container, new FileLocator(phpbb_realpath($this->root_path . 'install/update/new/config'))); $loader->load('services.yml'); diff --git a/phpBB/includes/user.php b/phpBB/includes/user.php index f823e85148..f8ff3b8b13 100644 --- a/phpBB/includes/user.php +++ b/phpBB/includes/user.php @@ -590,14 +590,15 @@ class phpbb_user extends phpbb_session $language_filename = $lang_path . $this->lang_name . '/' . $filename . '.' . $phpEx; } - if (!file_exists($language_filename)) + if (defined('IN_INSTALL')) { - // File was not found, try to find it in update directory + // If we are in install, try to use the updated version, when available $orig_language_filename = $language_filename; $language_filename = str_replace('language/', 'install/update/new/language/', $language_filename); + if (!file_exists($language_filename)) { - // Not found either, go back to the original file name + // Not found, go back to the original file name $language_filename = $orig_language_filename; } } From 6c52fae750ed2955b8c0d737e72f101f4d6f2e3a Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 11 Jul 2013 15:55:04 +0200 Subject: [PATCH 2194/2494] [ticket/11574] Include normalizer so it loads form the correct directory PHPBB3-11574 --- phpBB/install/index.php | 1 + 1 file changed, 1 insertion(+) diff --git a/phpBB/install/index.php b/phpBB/install/index.php index fd6734cbfb..4051a5a08b 100644 --- a/phpBB/install/index.php +++ b/phpBB/install/index.php @@ -103,6 +103,7 @@ phpbb_require_updated('includes/functions_container.' . $phpEx); phpbb_require_updated('includes/functions_content.' . $phpEx, true); phpbb_include_updated('includes/functions_admin.' . $phpEx); +phpbb_include_updated('includes/utf/utf_normalizer.' . $phpEx); phpbb_include_updated('includes/utf/utf_tools.' . $phpEx); phpbb_require_updated('includes/functions_install.' . $phpEx); From 1dea0286a48b4bac6702aad673e13e281690adfb Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Fri, 12 Jul 2013 15:40:49 -0400 Subject: [PATCH 2195/2494] [ticket/11574] Use alternate DI config file for updater PHPBB3-11574 --- phpBB/includes/di/extension/core.php | 23 +++++++---------------- phpBB/includes/functions_container.php | 7 +++++-- phpBB/install/database_update.php | 5 ++++- tests/di/create_container_test.php | 6 +++--- 4 files changed, 19 insertions(+), 22 deletions(-) diff --git a/phpBB/includes/di/extension/core.php b/phpBB/includes/di/extension/core.php index 4e1159e6fd..9d59a24b7e 100644 --- a/phpBB/includes/di/extension/core.php +++ b/phpBB/includes/di/extension/core.php @@ -26,19 +26,19 @@ use Symfony\Component\Config\FileLocator; class phpbb_di_extension_core extends Extension { /** - * phpBB Root path + * Config path * @var string */ - protected $root_path; + protected $config_path; /** * Constructor * - * @param string $root_path Root path + * @param string $config_path Config path */ - public function __construct($root_path) + public function __construct($config_path) { - $this->root_path = $root_path; + $this->config_path = $config_path; } /** @@ -51,17 +51,8 @@ class phpbb_di_extension_core extends Extension */ public function load(array $config, ContainerBuilder $container) { - // If we are in install, try to use the updated version, when available - if (defined('IN_INSTALL') && file_exists($this->root_path . 'install/update/new/config/services.yml')) - { - $loader = new YamlFileLoader($container, new FileLocator(phpbb_realpath($this->root_path . 'install/update/new/config'))); - $loader->load('services.yml'); - } - else if (file_exists($this->root_path . 'config/services.yml')) - { - $loader = new YamlFileLoader($container, new FileLocator(phpbb_realpath($this->root_path . 'config'))); - $loader->load('services.yml'); - } + $loader = new YamlFileLoader($container, new FileLocator(phpbb_realpath($this->config_path))); + $loader->load('services.yml'); } /** diff --git a/phpBB/includes/functions_container.php b/phpBB/includes/functions_container.php index 106b7d75cc..d302b75350 100644 --- a/phpBB/includes/functions_container.php +++ b/phpBB/includes/functions_container.php @@ -53,7 +53,10 @@ function phpbb_create_container(array $extensions, $phpbb_root_path, $php_ext) */ function phpbb_create_install_container($phpbb_root_path, $php_ext) { - $core = new phpbb_di_extension_core($phpbb_root_path); + $other_config_path = $phpbb_root_path . 'install/update/new/config'; + $config_path = file_exists($other_config_path . 'services.yml') ? $other_config_path : $phpbb_root_path . 'config'; + + $core = new phpbb_di_extension_core($config_path); $container = phpbb_create_container(array($core), $phpbb_root_path, $php_ext); $container->setParameter('core.root_path', $phpbb_root_path); @@ -175,7 +178,7 @@ function phpbb_create_default_container($phpbb_root_path, $php_ext) return phpbb_create_dumped_container_unless_debug( array( new phpbb_di_extension_config($phpbb_root_path . 'config.' . $php_ext), - new phpbb_di_extension_core($phpbb_root_path), + new phpbb_di_extension_core($phpbb_root_path . 'config'), ), array( new phpbb_di_pass_collection_pass(), diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index de7f4f202e..b0e28958ac 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -121,9 +121,12 @@ $phpbb_class_loader = new phpbb_class_loader('phpbb_', "{$phpbb_root_path}includ $phpbb_class_loader->register(); // Set up container (must be done here because extensions table may not exist) +$other_config_path = $phpbb_root_path . 'install/update/new/config'; +$config_path = file_exists($other_config_path . 'services.yml') ? $other_config_path : $phpbb_root_path; + $container_extensions = array( new phpbb_di_extension_config($phpbb_root_path . 'config.' . $phpEx), - new phpbb_di_extension_core($phpbb_root_path), + new phpbb_di_extension_core($config_path), ); $container_passes = array( new phpbb_di_pass_collection_pass(), diff --git a/tests/di/create_container_test.php b/tests/di/create_container_test.php index 6de8803df9..d6a5ec823b 100644 --- a/tests/di/create_container_test.php +++ b/tests/di/create_container_test.php @@ -17,7 +17,7 @@ class phpbb_di_container_test extends phpbb_test_case $phpbb_root_path = __DIR__ . '/../../phpBB/'; $extensions = array( new phpbb_di_extension_config(__DIR__ . '/fixtures/config.php'), - new phpbb_di_extension_core($phpbb_root_path), + new phpbb_di_extension_core($phpbb_root_path . 'config'), ); $container = phpbb_create_container($extensions, $phpbb_root_path, 'php'); @@ -29,7 +29,7 @@ class phpbb_di_container_test extends phpbb_test_case $phpbb_root_path = __DIR__ . '/../../phpBB/'; $extensions = array( new phpbb_di_extension_config(__DIR__ . '/fixtures/config.php'), - new phpbb_di_extension_core($phpbb_root_path), + new phpbb_di_extension_core($phpbb_root_path . 'config'), ); $container = phpbb_create_install_container($phpbb_root_path, 'php'); @@ -42,7 +42,7 @@ class phpbb_di_container_test extends phpbb_test_case $phpbb_root_path = __DIR__ . '/../../phpBB/'; $extensions = array( new phpbb_di_extension_config(__DIR__ . '/fixtures/config.php'), - new phpbb_di_extension_core($phpbb_root_path), + new phpbb_di_extension_core($phpbb_root_path . 'config'), ); $container = phpbb_create_compiled_container($extensions, array(), $phpbb_root_path, 'php'); From 51ab2c710e91d98bb182dded1e9d5462451151e8 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Fri, 12 Jul 2013 16:40:20 -0400 Subject: [PATCH 2196/2494] [ticket/11574] Make install language filename less crazy PHPBB3-11574 --- phpBB/includes/user.php | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/phpBB/includes/user.php b/phpBB/includes/user.php index f8ff3b8b13..b39438e315 100644 --- a/phpBB/includes/user.php +++ b/phpBB/includes/user.php @@ -590,17 +590,11 @@ class phpbb_user extends phpbb_session $language_filename = $lang_path . $this->lang_name . '/' . $filename . '.' . $phpEx; } - if (defined('IN_INSTALL')) + // If we are in install, try to use the updated version, when available + $install_language_filename = str_replace('language/', 'install/update/new/language/', $language_filename); + if (defined('IN_INSTALL') && file_exists($install_language_filename)) { - // If we are in install, try to use the updated version, when available - $orig_language_filename = $language_filename; - $language_filename = str_replace('language/', 'install/update/new/language/', $language_filename); - - if (!file_exists($language_filename)) - { - // Not found, go back to the original file name - $language_filename = $orig_language_filename; - } + $language_filename = $install_language_filename; } if (!file_exists($language_filename)) From 31fed4215067ee39e7396f010a06093fe66352ee Mon Sep 17 00:00:00 2001 From: Bruno Ais Date: Sat, 13 Jul 2013 12:58:04 +0100 Subject: [PATCH 2197/2494] [ticket/11656] generate_text_for_display on memberlist.php sub-task of ticket PHPBB3-11635: find and fix all bypasses of generate_text_for_* PHPBB3-11656 --- phpBB/memberlist.php | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/phpBB/memberlist.php b/phpBB/memberlist.php index 7ecf332720..6156e6a292 100644 --- a/phpBB/memberlist.php +++ b/phpBB/memberlist.php @@ -561,17 +561,8 @@ switch ($mode) if ($member['user_sig']) { - $member['user_sig'] = censor_text($member['user_sig']); - - if ($member['user_sig_bbcode_bitfield']) - { - include_once($phpbb_root_path . 'includes/bbcode.' . $phpEx); - $bbcode = new bbcode(); - $bbcode->bbcode_second_pass($member['user_sig'], $member['user_sig_bbcode_uid'], $member['user_sig_bbcode_bitfield']); - } - - $member['user_sig'] = bbcode_nl2br($member['user_sig']); - $member['user_sig'] = smiley_text($member['user_sig']); + $member['user_sig'] = generate_text_for_display($member['user_sig'], $member['user_sig_bbcode_uid'], + $member['user_sig_bbcode_bitfield'], OPTION_FLAG_BBCODE || OPTION_FLAG_SMILIES, true); } $poster_avatar = phpbb_get_user_avatar($member); From 678cccfb049e9988f913afa1aee031c0d7dfb682 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Sat, 13 Jul 2013 09:14:22 -0500 Subject: [PATCH 2198/2494] [ticket/11671] Update composer.lock PHPBB3-11671 --- phpBB/composer.lock | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/phpBB/composer.lock b/phpBB/composer.lock index dd09b6cd56..c7194c2fb5 100644 --- a/phpBB/composer.lock +++ b/phpBB/composer.lock @@ -1,4 +1,8 @@ { + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file" + ], "hash": "ef6d05965cca4e390fff7ce63e9d2d49", "packages": [ From 7b0a6ef06c0f84634ba6f2ba3c2c9d304e61a19a Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Sat, 13 Jul 2013 09:20:18 -0500 Subject: [PATCH 2199/2494] [ticket/11671] Update composer.lock PHPBB3-11671 --- phpBB/composer.lock | 43 ++++++++++++++++++++++++++++--------------- 1 file changed, 28 insertions(+), 15 deletions(-) diff --git a/phpBB/composer.lock b/phpBB/composer.lock index a20c6303ee..7b18d2fd25 100644 --- a/phpBB/composer.lock +++ b/phpBB/composer.lock @@ -29,6 +29,7 @@ "Symfony\\Component\\Config": "" } }, + "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], @@ -78,6 +79,7 @@ "Symfony\\Component\\DependencyInjection": "" } }, + "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], @@ -126,6 +128,7 @@ "Symfony\\Component\\EventDispatcher": "" } }, + "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], @@ -168,6 +171,7 @@ "SessionHandlerInterface": "Symfony/Component/HttpFoundation/Resources/stubs" } }, + "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], @@ -229,6 +233,7 @@ "Symfony\\Component\\HttpKernel": "" } }, + "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], @@ -281,6 +286,7 @@ "Symfony\\Component\\Routing": "" } }, + "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], @@ -322,6 +328,7 @@ "Symfony\\Component\\Yaml": "" } }, + "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], @@ -367,6 +374,7 @@ "Twig_": "lib/" } }, + "notification-url": "https://packagist.org/downloads/", "license": [ "BSD-3" ], @@ -593,16 +601,16 @@ }, { "name": "phpunit/php-code-coverage", - "version": "1.2.11", + "version": "1.2.12", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "1.2.11" + "reference": "1.2.12" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/1.2.11", - "reference": "1.2.11", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/1.2.12", + "reference": "1.2.12", "shasum": "" }, "require": { @@ -612,13 +620,18 @@ "phpunit/php-token-stream": ">=1.1.3@stable" }, "require-dev": { - "phpunit/phpunit": "3.7.*" + "phpunit/phpunit": "3.7.*@dev" }, "suggest": { "ext-dom": "*", "ext-xdebug": ">=2.0.5" }, "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.2.x-dev" + } + }, "autoload": { "classmap": [ "PHP/" @@ -645,7 +658,7 @@ "testing", "xunit" ], - "time": "2013-05-23 18:23:24" + "time": "2013-07-06 06:26:16" }, { "name": "phpunit/php-file-iterator", @@ -827,16 +840,16 @@ }, { "name": "phpunit/phpunit", - "version": "3.7.21", + "version": "3.7.22", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "3.7.21" + "reference": "3.7.22" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/3.7.21", - "reference": "3.7.21", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/3.7.22", + "reference": "3.7.22", "shasum": "" }, "require": { @@ -845,12 +858,12 @@ "ext-reflection": "*", "ext-spl": "*", "php": ">=5.3.3", - "phpunit/php-code-coverage": ">=1.2.1,<1.3.0", + "phpunit/php-code-coverage": "~1.2.1", "phpunit/php-file-iterator": ">=1.3.1", "phpunit/php-text-template": ">=1.1.1", - "phpunit/php-timer": ">=1.0.2,<1.1.0", - "phpunit/phpunit-mock-objects": ">=1.2.0,<1.3.0", - "symfony/yaml": ">=2.0,<3.0" + "phpunit/php-timer": "~1.0.2", + "phpunit/phpunit-mock-objects": "~1.2.0", + "symfony/yaml": "~2.0" }, "require-dev": { "pear-pear/pear": "1.9.4" @@ -897,7 +910,7 @@ "testing", "xunit" ], - "time": "2013-05-23 18:54:29" + "time": "2013-07-06 06:29:15" }, { "name": "phpunit/phpunit-mock-objects", From 6cde302ffaf9d238e279704955a5c00ee0bdfd36 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 13 Jul 2013 10:47:42 -0400 Subject: [PATCH 2200/2494] [ticket/9657] Remove old code PHPBB3-9657 --- phpBB/includes/feed/forum.php | 1 - 1 file changed, 1 deletion(-) diff --git a/phpBB/includes/feed/forum.php b/phpBB/includes/feed/forum.php index 4a159ff3d4..b5f0dd0f8f 100644 --- a/phpBB/includes/feed/forum.php +++ b/phpBB/includes/feed/forum.php @@ -122,7 +122,6 @@ class phpbb_feed_forum extends phpbb_feed_post_base USERS_TABLE => 'u', ), 'WHERE' => $this->db->sql_in_set('p.topic_id', $topic_ids) . ' - ' . (($sql_visibility) ? ' AND ' . $sql_visibility : '') . ' AND ' . $this->content_visibility->get_visibility_sql('post', $this->forum_id, 'p.') . ' AND p.post_time >= ' . $min_post_time . ' AND p.poster_id = u.user_id', From fca4bc53232e22233711a275e252a8006dd89e9a Mon Sep 17 00:00:00 2001 From: Bruno Ais Date: Sat, 13 Jul 2013 15:55:37 +0100 Subject: [PATCH 2201/2494] [ticket/11656] Remove line break in function call sub-task of ticket PHPBB3-11635: find and fix all bypasses of generate_text_for_* PHPBB3-11656 --- phpBB/memberlist.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/phpBB/memberlist.php b/phpBB/memberlist.php index 6156e6a292..09b9dab5c1 100644 --- a/phpBB/memberlist.php +++ b/phpBB/memberlist.php @@ -561,8 +561,7 @@ switch ($mode) if ($member['user_sig']) { - $member['user_sig'] = generate_text_for_display($member['user_sig'], $member['user_sig_bbcode_uid'], - $member['user_sig_bbcode_bitfield'], OPTION_FLAG_BBCODE || OPTION_FLAG_SMILIES, true); + $member['user_sig'] = generate_text_for_display($member['user_sig'], $member['user_sig_bbcode_uid'], $member['user_sig_bbcode_bitfield'], OPTION_FLAG_BBCODE || OPTION_FLAG_SMILIES, true); } $poster_avatar = phpbb_get_user_avatar($member); From 402d987ccbeacb494f1147cdee047a6cf1f19f7b Mon Sep 17 00:00:00 2001 From: Bruno Ais Date: Sat, 13 Jul 2013 15:56:55 +0100 Subject: [PATCH 2202/2494] [ticket/11656] Wrong bitwise OR sub-task of ticket PHPBB3-11635: find and fix all bypasses of generate_text_for_* PHPBB3-11656 --- phpBB/memberlist.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/memberlist.php b/phpBB/memberlist.php index 09b9dab5c1..f8ee82084c 100644 --- a/phpBB/memberlist.php +++ b/phpBB/memberlist.php @@ -561,7 +561,7 @@ switch ($mode) if ($member['user_sig']) { - $member['user_sig'] = generate_text_for_display($member['user_sig'], $member['user_sig_bbcode_uid'], $member['user_sig_bbcode_bitfield'], OPTION_FLAG_BBCODE || OPTION_FLAG_SMILIES, true); + $member['user_sig'] = generate_text_for_display($member['user_sig'], $member['user_sig_bbcode_uid'], $member['user_sig_bbcode_bitfield'], OPTION_FLAG_BBCODE | OPTION_FLAG_SMILIES, true); } $poster_avatar = phpbb_get_user_avatar($member); From 167ca1f33f8265e5dea6481cc69de16ccfdd0dce Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 13 Jul 2013 11:25:38 -0400 Subject: [PATCH 2203/2494] [ticket/9657] Define user before injecting PHPBB3-9657 --- tests/content_visibility/get_forums_visibility_sql_test.php | 2 +- tests/content_visibility/get_global_visibility_sql_test.php | 1 + tests/content_visibility/get_visibility_sql_test.php | 1 + tests/content_visibility/set_post_visibility_test.php | 1 + tests/content_visibility/set_topic_visibility_test.php | 1 + 5 files changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/content_visibility/get_forums_visibility_sql_test.php b/tests/content_visibility/get_forums_visibility_sql_test.php index 7580a53fa4..aa44fa4013 100644 --- a/tests/content_visibility/get_forums_visibility_sql_test.php +++ b/tests/content_visibility/get_forums_visibility_sql_test.php @@ -130,7 +130,7 @@ class phpbb_content_visibility_get_forums_visibility_sql_test extends phpbb_data ->method('acl_getf') ->with($this->stringContains('_'), $this->anything()) ->will($this->returnValueMap($permissions)); - + $user = $this->getMock('phpbb_user'); $content_visibility = new phpbb_content_visibility($auth, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE); $result = $db->sql_query('SELECT ' . $mode . '_id diff --git a/tests/content_visibility/get_global_visibility_sql_test.php b/tests/content_visibility/get_global_visibility_sql_test.php index bdb0a96954..0f019ffa50 100644 --- a/tests/content_visibility/get_global_visibility_sql_test.php +++ b/tests/content_visibility/get_global_visibility_sql_test.php @@ -130,6 +130,7 @@ class phpbb_content_visibility_get_global_visibility_sql_test extends phpbb_data ->method('acl_getf') ->with($this->stringContains('_'), $this->anything()) ->will($this->returnValueMap($permissions)); + $user = $this->getMock('phpbb_user'); $content_visibility = new phpbb_content_visibility($auth, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE); $result = $db->sql_query('SELECT ' . $mode . '_id diff --git a/tests/content_visibility/get_visibility_sql_test.php b/tests/content_visibility/get_visibility_sql_test.php index f75c98f899..cc6c10c649 100644 --- a/tests/content_visibility/get_visibility_sql_test.php +++ b/tests/content_visibility/get_visibility_sql_test.php @@ -77,6 +77,7 @@ class phpbb_content_visibility_get_visibility_sql_test extends phpbb_database_te ->method('acl_get') ->with($this->stringContains('_'), $this->anything()) ->will($this->returnValueMap($permissions)); + $user = $this->getMock('phpbb_user'); $content_visibility = new phpbb_content_visibility($auth, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE); $result = $db->sql_query('SELECT ' . $mode . '_id diff --git a/tests/content_visibility/set_post_visibility_test.php b/tests/content_visibility/set_post_visibility_test.php index 845430b21b..81abf56c75 100644 --- a/tests/content_visibility/set_post_visibility_test.php +++ b/tests/content_visibility/set_post_visibility_test.php @@ -120,6 +120,7 @@ class phpbb_content_visibility_set_post_visibility_test extends phpbb_database_t $cache = new phpbb_mock_cache; $db = $this->new_dbal(); $auth = $this->getMock('phpbb_auth'); + $user = $this->getMock('phpbb_user'); $content_visibility = new phpbb_content_visibility($auth, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE); $content_visibility->set_post_visibility($visibility, $post_id, $topic_id, $forum_id, $user_id, $time, $reason, $is_starter, $is_latest); diff --git a/tests/content_visibility/set_topic_visibility_test.php b/tests/content_visibility/set_topic_visibility_test.php index 3061ba44db..6b5d884a2b 100644 --- a/tests/content_visibility/set_topic_visibility_test.php +++ b/tests/content_visibility/set_topic_visibility_test.php @@ -84,6 +84,7 @@ class phpbb_content_visibility_set_topic_visibility_test extends phpbb_database_ $cache = new phpbb_mock_cache; $db = $this->new_dbal(); $auth = $this->getMock('phpbb_auth'); + $user = $this->getMock('phpbb_user'); $content_visibility = new phpbb_content_visibility($auth, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE); $content_visibility->set_topic_visibility($visibility, $topic_id, $forum_id, $user_id, $time, $reason, $force_update_all); From b4fcdc51e9df126faf5e9aabcbaa50bb33da0bd0 Mon Sep 17 00:00:00 2001 From: Bruno Ais Date: Sat, 13 Jul 2013 13:49:19 +0100 Subject: [PATCH 2204/2494] [ticket/11638] generate_text_for_display on viewtopic.php lines: 835-843 sub-task of ticket PHPBB3-11635: find and fix all bypasses of generate_text_for_* PHPBB3-11638 --- phpBB/viewtopic.php | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index 4dd03202f1..6b789bbb99 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -828,26 +828,15 @@ if (!empty($topic_data['poll_start'])) $poll_total += $poll_option['poll_option_total']; } - if ($poll_info[0]['bbcode_bitfield']) - { - $poll_bbcode = new bbcode(); - } - else - { - $poll_bbcode = false; + $parse_bbcode_flags = OPTION_FLAG_SMILIES; + + if(empty($poll_info[0]['bbcode_bitfield'])){ + $parse_bbcode_flags |= OPTION_FLAG_BBCODE; } for ($i = 0, $size = sizeof($poll_info); $i < $size; $i++) { - $poll_info[$i]['poll_option_text'] = censor_text($poll_info[$i]['poll_option_text']); - - if ($poll_bbcode !== false) - { - $poll_bbcode->bbcode_second_pass($poll_info[$i]['poll_option_text'], $poll_info[$i]['bbcode_uid'], $poll_option['bbcode_bitfield']); - } - - $poll_info[$i]['poll_option_text'] = bbcode_nl2br($poll_info[$i]['poll_option_text']); - $poll_info[$i]['poll_option_text'] = smiley_text($poll_info[$i]['poll_option_text']); + $poll_info[$i]['poll_option_text'] = generate_text_for_display($poll_info[$i]['poll_option_text'], $poll_info[$i]['bbcode_uid'], $poll_option['bbcode_bitfield'], $parse_bbcode_flags, true); } $topic_data['poll_title'] = censor_text($topic_data['poll_title']); From 97054d81f82123f17cd3680326932a8fd021ffa2 Mon Sep 17 00:00:00 2001 From: Bruno Ais Date: Sat, 13 Jul 2013 13:50:44 +0100 Subject: [PATCH 2205/2494] [ticket/11638] generate_text_for_display on viewtopic.php lines: 846-854 sub-task of ticket PHPBB3-11635: find and fix all bypasses of generate_text_for_* PHPBB3-11638 --- phpBB/viewtopic.php | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index 6b789bbb99..d295b91f43 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -839,17 +839,9 @@ if (!empty($topic_data['poll_start'])) $poll_info[$i]['poll_option_text'] = generate_text_for_display($poll_info[$i]['poll_option_text'], $poll_info[$i]['bbcode_uid'], $poll_option['bbcode_bitfield'], $parse_bbcode_flags, true); } - $topic_data['poll_title'] = censor_text($topic_data['poll_title']); - - if ($poll_bbcode !== false) - { - $poll_bbcode->bbcode_second_pass($topic_data['poll_title'], $poll_info[0]['bbcode_uid'], $poll_info[0]['bbcode_bitfield']); - } - - $topic_data['poll_title'] = bbcode_nl2br($topic_data['poll_title']); - $topic_data['poll_title'] = smiley_text($topic_data['poll_title']); - - unset($poll_bbcode); + $topic_data['poll_title'] = generate_text_for_display($topic_data['poll_title'], $poll_info[0]['bbcode_uid'], $poll_info[0]['bbcode_bitfield'], $parse_bbcode_flags, true); + + unset($parse_bbcode_flags); foreach ($poll_info as $poll_option) { From fab7f5fdfd2fd8ec50dae52dfde80a706015dd74 Mon Sep 17 00:00:00 2001 From: David King Date: Sat, 13 Jul 2013 11:43:38 -0400 Subject: [PATCH 2206/2494] [ticket/11215] Don't try to use when it isn't there PHPBB3-112515 --- phpBB/includes/functions.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 40583dee54..f637ab2232 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -5059,7 +5059,7 @@ function phpbb_build_hidden_fields_for_query_params($request, $exclude = null) function page_header($page_title = '', $display_online_list = true, $item_id = 0, $item = 'forum') { global $db, $config, $template, $SID, $_SID, $_EXTRA_URL, $user, $auth, $phpEx, $phpbb_root_path; - global $phpbb_dispatcher, $request, $phpbb_container; + global $phpbb_dispatcher, $request, $phpbb_container, $symfony_request; if (defined('HEADER_INC')) { @@ -5219,7 +5219,7 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0 // This path is sent with the base template paths in the assign_vars() // call below. We need to correct it in case we are accessing from a // controller because the web paths will be incorrect otherwise. - $corrected_path = phpbb_get_web_root_path(phpbb_create_symfony_request($request)); + $corrected_path = $symfony_request !== null ? phpbb_get_web_root_path($symfony_request) : ''; $web_path = (defined('PHPBB_USE_BOARD_URL_PATH') && PHPBB_USE_BOARD_URL_PATH) ? $board_url : $corrected_path; // Send a proper content-language to the output From a58ccdabf30cad5b0373c266fc69368c65cee1a1 Mon Sep 17 00:00:00 2001 From: Bruno Ais Date: Sat, 13 Jul 2013 14:35:22 +0100 Subject: [PATCH 2207/2494] [ticket/11638] generate_text_for_display on viewtopic.php lines: 1395-1403 sub-task of ticket PHPBB3-11635: find and fix all bypasses of generate_text_for_* PHPBB3-11638 --- phpBB/viewtopic.php | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index d295b91f43..34586b1491 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -1380,16 +1380,8 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i) // End signature parsing, only if needed if ($user_cache[$poster_id]['sig'] && $row['enable_sig'] && empty($user_cache[$poster_id]['sig_parsed'])) { - $user_cache[$poster_id]['sig'] = censor_text($user_cache[$poster_id]['sig']); - - if ($user_cache[$poster_id]['sig_bbcode_bitfield']) - { - $bbcode->bbcode_second_pass($user_cache[$poster_id]['sig'], $user_cache[$poster_id]['sig_bbcode_uid'], $user_cache[$poster_id]['sig_bbcode_bitfield']); - } - - $user_cache[$poster_id]['sig'] = bbcode_nl2br($user_cache[$poster_id]['sig']); - $user_cache[$poster_id]['sig'] = smiley_text($user_cache[$poster_id]['sig']); - $user_cache[$poster_id]['sig_parsed'] = true; + $include_bbcode_parse = $user_cache[$poster_id]['sig_bbcode_bitfield'] ? OPTION_FLAG_BBCODE : 0; + $user_cache[$poster_id]['sig'] = generate_text_for_display($user_cache[$poster_id]['sig'], $user_cache[$poster_id]['sig_bbcode_uid'], $user_cache[$poster_id]['sig_bbcode_bitfield'], $include_bbcode_parse | OPTION_FLAG_SMILIES, true); } // Parse the message and subject From 713a2ba573ab49d2add2522392b1f91ca3065dea Mon Sep 17 00:00:00 2001 From: Bruno Ais Date: Sat, 13 Jul 2013 14:35:50 +0100 Subject: [PATCH 2208/2494] [ticket/11638] generate_text_for_display on viewtopic.php lines: 1403-1417 sub-task of ticket PHPBB3-11635: find and fix all bypasses of generate_text_for_* PHPBB3-11638 --- phpBB/viewtopic.php | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index 34586b1491..9274539ab4 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -1385,16 +1385,7 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i) } // Parse the message and subject - $message = censor_text($row['post_text']); - - // Second parse bbcode here - if ($row['bbcode_bitfield']) - { - $bbcode->bbcode_second_pass($message, $row['bbcode_uid'], $row['bbcode_bitfield']); - } - - $message = bbcode_nl2br($message); - $message = smiley_text($message); + $message = generate_text_for_display($message, $row['bbcode_uid'], $row['bbcode_bitfield'], ($row['bbcode_bitfield'] ? OPTION_FLAG_BBCODE : 0) | OPTION_FLAG_SMILIES, true); if (!empty($attachments[$row['post_id']])) { From 7d0c1d02ca428305f3cd4b57249c90d0d86bc3ae Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 13 Jul 2013 12:02:49 -0400 Subject: [PATCH 2209/2494] [ticket/11684] Remove useless confirmation page after login and admin login PHPBB3-11684 --- phpBB/includes/functions.php | 3 +-- tests/test_framework/phpbb_functional_test_case.php | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 6a1b3fd4f8..200614252a 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -3301,8 +3301,7 @@ function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = fa return; } - $redirect = meta_refresh(3, $redirect); - trigger_error($message . '

    ' . sprintf($l_redirect, '', '')); + redirect($redirect); } // Something failed, determine what... diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index f27e339bb7..2f5de76c11 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -610,7 +610,7 @@ class phpbb_functional_test_case extends phpbb_test_case $form = $crawler->selectButton($this->lang('LOGIN'))->form(); $crawler = self::submit($form, array('username' => $username, 'password' => $username . $username)); - $this->assertContains($this->lang('LOGIN_REDIRECT'), $crawler->filter('html')->text()); + $this->assertNotContains($this->lang('LOGIN'), $crawler->filter('.navbar')->text()); $cookies = self::$cookieJar->all(); @@ -659,7 +659,7 @@ class phpbb_functional_test_case extends phpbb_test_case if (strpos($field, 'password_') === 0) { $crawler = self::submit($form, array('username' => $username, $field => $username . $username)); - $this->assertContains($this->lang('LOGIN_ADMIN_SUCCESS'), $crawler->filter('html')->text()); + $this->assertContains($this->lang('ADMIN_PANEL'), $crawler->filter('h1')->text()); $cookies = self::$cookieJar->all(); From 8f95ef55a65cbf58e74840957cf9acfaf9e16d31 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 13 Jul 2013 12:27:00 -0400 Subject: [PATCH 2210/2494] [ticket/11685] Remove logout confirmation page PHPBB3-11685 --- phpBB/includes/acp/acp_main.php | 4 +--- phpBB/ucp.php | 13 ++++++------- tests/functional/auth_test.php | 1 - tests/test_framework/phpbb_functional_test_case.php | 2 +- 4 files changed, 8 insertions(+), 12 deletions(-) diff --git a/phpBB/includes/acp/acp_main.php b/phpBB/includes/acp/acp_main.php index c44bc1b8a6..2eaea392bf 100644 --- a/phpBB/includes/acp/acp_main.php +++ b/phpBB/includes/acp/acp_main.php @@ -63,9 +63,7 @@ class acp_main if ($action === 'admlogout') { $user->unset_admin(); - $redirect_url = append_sid("{$phpbb_root_path}index.$phpEx"); - meta_refresh(3, $redirect_url); - trigger_error($user->lang['ADM_LOGGED_OUT'] . '

    ' . sprintf($user->lang['RETURN_INDEX'], '', '')); + redirect(append_sid("{$phpbb_root_path}index.$phpEx")); } if (!confirm_box(true)) diff --git a/phpBB/ucp.php b/phpBB/ucp.php index a7e75f76c4..7180c54de6 100644 --- a/phpBB/ucp.php +++ b/phpBB/ucp.php @@ -85,17 +85,16 @@ switch ($mode) { $user->session_kill(); $user->session_begin(); - $message = $user->lang['LOGOUT_REDIRECT']; } - else + else if ($user->data['user_id'] != ANONYMOUS) { - $message = ($user->data['user_id'] == ANONYMOUS) ? $user->lang['LOGOUT_REDIRECT'] : $user->lang['LOGOUT_FAILED']; + meta_refresh(3, append_sid("{$phpbb_root_path}index.$phpEx")); + + $message = $user->lang['LOGOUT_FAILED'] . '

    ' . sprintf($user->lang['RETURN_INDEX'], '', ' '); + trigger_error($message); } - meta_refresh(3, append_sid("{$phpbb_root_path}index.$phpEx")); - - $message = $message . '

    ' . sprintf($user->lang['RETURN_INDEX'], '', ' '); - trigger_error($message); + redirect(append_sid("{$phpbb_root_path}index.$phpEx")); break; case 'terms': diff --git a/tests/functional/auth_test.php b/tests/functional/auth_test.php index ff4d3ced5c..cfd85571b7 100644 --- a/tests/functional/auth_test.php +++ b/tests/functional/auth_test.php @@ -39,7 +39,6 @@ class phpbb_functional_auth_test extends phpbb_functional_test_case // logout $crawler = self::request('GET', 'ucp.php?sid=' . $this->sid . '&mode=logout'); - $this->assertContains($this->lang('LOGOUT_REDIRECT'), $crawler->filter('#message')->text()); // look for a register link, which should be visible only when logged out $crawler = self::request('GET', 'index.php'); diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index f27e339bb7..4e0a978839 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -629,7 +629,7 @@ class phpbb_functional_test_case extends phpbb_test_case $this->add_lang('ucp'); $crawler = self::request('GET', 'ucp.php?sid=' . $this->sid . '&mode=logout'); - $this->assertContains($this->lang('LOGOUT_REDIRECT'), $crawler->filter('#message')->text()); + $this->assertContains($this->lang('REGISTER'), $crawler->filter('.navbar')->text()); unset($this->sid); } From e0aef4b3202041335ff0a7b62d9ca8112bd61ce9 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Sat, 13 Jul 2013 18:32:33 +0200 Subject: [PATCH 2211/2494] [ticket/11674] Do not include vendor folder if there are no dependencies. PHPBB3-11674 --- build/build.xml | 42 +++++++++++++++++++++++++++++------------- 1 file changed, 29 insertions(+), 13 deletions(-) diff --git a/build/build.xml b/build/build.xml index e4fe24005f..a418f40b53 100644 --- a/build/build.xml +++ b/build/build.xml @@ -169,26 +169,42 @@ command="git archive ${revision} | tar -xf - -C ../${dir}" checkreturn="true" /> - + + outputProperty='composer-has-dependencies' /> - + + - - + outputProperty='composer-ls-tree-output' /> + + + + + + + + + + + + + + + + + From 598ab05807f6ec97b33eca59847ffb1296d319bb Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Sat, 13 Jul 2013 18:50:49 +0200 Subject: [PATCH 2212/2494] [ticket/11670] Consistency with logo: Replace "phpBB(tm)" with "phpBB(R)". PHPBB3-11670 --- phpBB/language/en/install.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/language/en/install.php b/phpBB/language/en/install.php index bdc51a5712..4c01fa5522 100644 --- a/phpBB/language/en/install.php +++ b/phpBB/language/en/install.php @@ -288,7 +288,7 @@ $lang = array_merge($lang, array( 'NO_LOCATION' => 'Cannot determine location. If you know Imagemagick is installed, you may specify the location later within your administration control panel', 'NO_TABLES_FOUND' => 'No tables found.', - 'OVERVIEW_BODY' => 'Welcome to phpBB3!

    phpBB™ is the most widely used open source bulletin board solution in the world. phpBB3 is the latest installment in a package line started in 2000. Like its predecessors, phpBB3 is feature-rich, user-friendly, and fully supported by the phpBB Team. phpBB3 greatly improves on what made phpBB2 popular, and adds commonly requested features that were not present in previous versions. We hope it exceeds your expectations.

    This installation system will guide you through installing phpBB3, updating to the latest version of phpBB3 from past releases, as well as converting to phpBB3 from a different discussion board system (including phpBB2). For more information, we encourage you to read the installation guide.

    To read the phpBB3 license or learn about obtaining support and our stance on it, please select the respective options from the side menu. To continue, please select the appropriate tab above.', + 'OVERVIEW_BODY' => 'Welcome to phpBB3!

    phpBB® is the most widely used open source bulletin board solution in the world. phpBB3 is the latest installment in a package line started in 2000. Like its predecessors, phpBB3 is feature-rich, user-friendly, and fully supported by the phpBB Team. phpBB3 greatly improves on what made phpBB2 popular, and adds commonly requested features that were not present in previous versions. We hope it exceeds your expectations.

    This installation system will guide you through installing phpBB3, updating to the latest version of phpBB3 from past releases, as well as converting to phpBB3 from a different discussion board system (including phpBB2). For more information, we encourage you to read the installation guide.

    To read the phpBB3 license or learn about obtaining support and our stance on it, please select the respective options from the side menu. To continue, please select the appropriate tab above.', 'PCRE_UTF_SUPPORT' => 'PCRE UTF-8 support', 'PCRE_UTF_SUPPORT_EXPLAIN' => 'phpBB will not run if your PHP installation is not compiled with UTF-8 support in the PCRE extension.', From 6bfa2fc0551af7e4eb99c1452031a2f423611a6f Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Sat, 13 Jul 2013 12:06:05 -0500 Subject: [PATCH 2213/2494] [ticket/11686] Not checking for phpBB Debug errors on functional tests PHPBB3-11686 --- tests/test_framework/phpbb_functional_test_case.php | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index 684d7a84cb..66af0db2b1 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -577,6 +577,7 @@ class phpbb_functional_test_case extends phpbb_test_case // Any output before the doc type means there was an error $content = self::$client->getResponse()->getContent(); + self::assertNotContains('[phpBB Debug]', $content); self::assertStringStartsWith(' Date: Sat, 13 Jul 2013 13:10:21 -0400 Subject: [PATCH 2214/2494] [ticket/11687] Add assets_version to phpbb_config PHPBB3-11687 --- phpBB/install/schemas/schema_data.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/phpBB/install/schemas/schema_data.sql b/phpBB/install/schemas/schema_data.sql index a159534bb2..d03fdf9de4 100644 --- a/phpBB/install/schemas/schema_data.sql +++ b/phpBB/install/schemas/schema_data.sql @@ -39,6 +39,7 @@ INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_sig_pm', '1' INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_sig_smilies', '1'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_smilies', '1'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_topic_notify', '1'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('assets_version', '1'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('attachment_quota', '52428800'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('auth_bbcode_pm', '1'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('auth_flash_pm', '0'); From 9e789c4e9f3e5b4b0697cd900a24467b7be9a71f Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Sat, 13 Jul 2013 19:30:09 +0200 Subject: [PATCH 2215/2494] [prep-release-3.0.12] More changelog items for the 3.0.12 release. --- phpBB/docs/CHANGELOG.html | 3 +++ 1 file changed, 3 insertions(+) diff --git a/phpBB/docs/CHANGELOG.html b/phpBB/docs/CHANGELOG.html index 4b916fadbc..44cc49d8c4 100644 --- a/phpBB/docs/CHANGELOG.html +++ b/phpBB/docs/CHANGELOG.html @@ -188,6 +188,8 @@
  • [PHPBB3-11630] - Improvements to the PHP lint pre-commit hook
  • [PHPBB3-11644] - Skip phpbb_dbal_order_lower_test on MySQL 5.6
  • [PHPBB3-11662] - "occured" should be "occurred"
  • +
  • [PHPBB3-11670] - Replace trademark ™ with ® on "Welcome to phpBB" install page
  • +
  • [PHPBB3-11674] - Do not include vendor folder if there are no dependencies.
  • Improvement

      @@ -235,6 +237,7 @@
    • [PHPBB3-11527] - Upgrade composer.phar to 1.0.0-alpha7
    • [PHPBB3-11529] - Rename RUNNING_TESTS file to .md file to render it on GitHub
    • [PHPBB3-11576] - Make phpBB Test Suite MySQL behave at least as strict as phpBB MySQL driver
    • +
    • [PHPBB3-11671] - Add phing/phing to composer.json

    1.ii. Changes since 3.0.10

    From c1bb179914e4f47876d87aba21ab65e01f79d69c Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Sat, 13 Jul 2013 13:30:33 -0400 Subject: [PATCH 2216/2494] [ticket/10999] Fix assets_version in ACP PHPBB3-10999 --- phpBB/adm/style/overall_footer.html | 2 +- phpBB/includes/functions_acp.php | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/phpBB/adm/style/overall_footer.html b/phpBB/adm/style/overall_footer.html index 54ed4dcc9e..9202cec06b 100644 --- a/phpBB/adm/style/overall_footer.html +++ b/phpBB/adm/style/overall_footer.html @@ -38,7 +38,7 @@ -{SCRIPTS} +{$SCRIPTS} diff --git a/phpBB/includes/functions_acp.php b/phpBB/includes/functions_acp.php index ff0e2a1ac1..60c44e90e1 100644 --- a/phpBB/includes/functions_acp.php +++ b/phpBB/includes/functions_acp.php @@ -82,6 +82,8 @@ function adm_page_header($page_title) 'T_RANKS_PATH' => "{$phpbb_root_path}{$config['ranks_path']}/", 'T_UPLOAD_PATH' => "{$phpbb_root_path}{$config['upload_path']}/", + 'T_ASSETS_VERSION' => $config['assets_version'], + 'ICON_MOVE_UP' => '' . $user->lang['MOVE_UP'] . '', 'ICON_MOVE_UP_DISABLED' => '' . $user->lang['MOVE_UP'] . '', 'ICON_MOVE_DOWN' => '' . $user->lang['MOVE_DOWN'] . '', From 081350678dcfd88104d885385674b8f4a382aa91 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 13 Jul 2013 14:57:31 -0400 Subject: [PATCH 2217/2494] [ticket/9649] Display information on index for moderators on unapproved posts PHPBB3-9649 --- phpBB/includes/functions_display.php | 10 +++++++++- phpBB/styles/prosilver/template/forumlist_body.html | 6 +++++- phpBB/styles/subsilver2/template/forumlist_body.html | 9 ++++++++- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php index 143813e4ed..b1dac64bec 100644 --- a/phpBB/includes/functions_display.php +++ b/phpBB/includes/functions_display.php @@ -215,8 +215,9 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod $forum_tracking_info[$forum_id] = (isset($tracking_topics['f'][$forum_id])) ? (int) (base_convert($tracking_topics['f'][$forum_id], 36, 10) + $config['board_startdate']) : $user->data['user_lastmark']; } - // Count the difference of real to public topics, so we can display an information to moderators + // Lets check whether there are unapproved topics/posts, so we can display an information to moderators $row['forum_id_unapproved_topics'] = ($auth->acl_get('m_approve', $forum_id) && $row['forum_topics_unapproved']) ? $forum_id : 0; + $row['forum_id_unapproved_posts'] = ($auth->acl_get('m_approve', $forum_id) && $row['forum_posts_unapproved']) ? $forum_id : 0; $row['forum_posts'] = $phpbb_content_visibility->get_count('forum_posts', $row, $forum_id); $row['forum_topics'] = $phpbb_content_visibility->get_count('forum_topics', $row, $forum_id); @@ -281,6 +282,11 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod $forum_rows[$parent_id]['forum_id_unapproved_topics'] = $forum_id; } + if (!$forum_rows[$parent_id]['forum_id_unapproved_posts'] && $row['forum_id_unapproved_posts']) + { + $forum_rows[$parent_id]['forum_id_unapproved_posts'] = $forum_id; + } + $forum_rows[$parent_id]['forum_topics'] += $row['forum_topics']; // Do not list redirects in LINK Forums as Posts. @@ -548,6 +554,7 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod 'L_MODERATOR_STR' => $l_moderator, 'U_UNAPPROVED_TOPICS' => ($row['forum_id_unapproved_topics']) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&mode=unapproved_topics&f=' . $row['forum_id_unapproved_topics']) : '', + 'U_UNAPPROVED_POSTS' => ($row['forum_id_unapproved_posts']) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&mode=unapproved_posts&f=' . $row['forum_id_unapproved_posts']) : '', 'U_VIEWFORUM' => $u_viewforum, 'U_LAST_POSTER' => get_username_string('profile', $row['forum_last_poster_id'], $row['forum_last_poster_name'], $row['forum_last_poster_colour']), 'U_LAST_POST' => $last_post_url, @@ -587,6 +594,7 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod 'L_SUBFORUM' => ($visible_forums == 1) ? $user->lang['SUBFORUM'] : $user->lang['SUBFORUMS'], 'LAST_POST_IMG' => $user->img('icon_topic_latest', 'VIEW_LATEST_POST'), 'UNAPPROVED_IMG' => $user->img('icon_topic_unapproved', 'TOPICS_UNAPPROVED'), + 'UNAPPROVED_POST_IMG' => $user->img('icon_topic_unapproved', 'POSTS_UNAPPROVED'), )); if ($return_moderators) diff --git a/phpBB/styles/prosilver/template/forumlist_body.html b/phpBB/styles/prosilver/template/forumlist_body.html index 0c67de76ec..9fb6b3d951 100644 --- a/phpBB/styles/prosilver/template/forumlist_body.html +++ b/phpBB/styles/prosilver/template/forumlist_body.html @@ -50,7 +50,11 @@
    {forumrow.TOPICS} {L_TOPICS}
    {forumrow.POSTS} {L_POSTS}
    - {UNAPPROVED_IMG} + + {UNAPPROVED_IMG} + + {UNAPPROVED_POST_IMG} + {L_LAST_POST} diff --git a/phpBB/styles/subsilver2/template/forumlist_body.html b/phpBB/styles/subsilver2/template/forumlist_body.html index 3e30561f3a..a222607ae8 100644 --- a/phpBB/styles/subsilver2/template/forumlist_body.html +++ b/phpBB/styles/subsilver2/template/forumlist_body.html @@ -64,7 +64,14 @@

    {forumrow.LAST_POST_SUBJECT_TRUNCATED}

    -

    {UNAPPROVED_IMG} {forumrow.LAST_POST_TIME}

    +

    + + {UNAPPROVED_IMG}  + + {UNAPPROVED_POST_IMG}  + + {forumrow.LAST_POST_TIME} +

    {forumrow.LAST_POSTER_FULL} {LAST_POST_IMG}

    From 9f5ee08bae0bd13352dd7a5e59ec959bc17702d4 Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Sat, 13 Jul 2013 16:44:38 -0400 Subject: [PATCH 2218/2494] [ticket/11690] Old module class names may get autoloaded by class_exists PHPBB3-11690 --- phpBB/includes/acp/acp_modules.php | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/phpBB/includes/acp/acp_modules.php b/phpBB/includes/acp/acp_modules.php index ab416fb406..a1e681b29c 100644 --- a/phpBB/includes/acp/acp_modules.php +++ b/phpBB/includes/acp/acp_modules.php @@ -575,13 +575,20 @@ class acp_modules // format. phpbb_acp_info_acp_foo needs to be turned into // acp_foo_info and the respective file has to be included // manually because it does not support auto loading - if (!class_exists($info_class)) + $old_info_class_file = str_replace("phpbb_{$module_class}_info_", '', $cur_module); + $old_info_class = $old_info_class_file . '_info'; + + if (class_exists($old_info_class)) { - $info_class_file = str_replace("phpbb_{$module_class}_info_", '', $cur_module); - $info_class = $info_class_file . '_info'; - if (!class_exists($info_class) && file_exists($directory . $info_class_file . '.' . $phpEx)) + $info_class = $old_info_class; + } + else if (!class_exists($info_class)) + { + $info_class = $old_info_class; + // need to check class exists again because previous checks triggered autoloading + if (!class_exists($info_class) && file_exists($directory . $old_info_class_file . '.' . $phpEx)) { - include($directory . $info_class_file . '.' . $phpEx); + include($directory . $old_info_class_file . '.' . $phpEx); } } From e9cc1e9cd276fa6222e52c7c41feb6ef4829f6e3 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Sat, 13 Jul 2013 16:25:08 -0500 Subject: [PATCH 2219/2494] [ticket/11675] Fix template loop PHPBB3-11675 --- phpBB/adm/style/permission_roles_mask.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/adm/style/permission_roles_mask.html b/phpBB/adm/style/permission_roles_mask.html index 277310edbf..42a7fc3e4e 100644 --- a/phpBB/adm/style/permission_roles_mask.html +++ b/phpBB/adm/style/permission_roles_mask.html @@ -25,7 +25,7 @@ {role_mask.groups.GROUP_NAME} :: {L_GROUPS_NOT_ASSIGNED} - + From 176729ab001300c295695537803f389e175049cf Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Sat, 13 Jul 2013 17:50:35 -0500 Subject: [PATCH 2220/2494] [ticket/11692] Don't update search_type in dev migration if already appended PHPBB3-11692 --- phpBB/includes/db/migration/data/310/dev.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/phpBB/includes/db/migration/data/310/dev.php b/phpBB/includes/db/migration/data/310/dev.php index 13b36bbf30..0fc2950987 100644 --- a/phpBB/includes/db/migration/data/310/dev.php +++ b/phpBB/includes/db/migration/data/310/dev.php @@ -82,7 +82,10 @@ class phpbb_db_migration_data_310_dev extends phpbb_db_migration public function update_data() { return array( - array('config.update', array('search_type', 'phpbb_search_' . $this->config['search_type'])), + array('if', array( + (strpos('phpbb_search_', $this->config['search_type']) !== 0), + array('config.update', array('search_type', 'phpbb_search_' . $this->config['search_type'])), + )), array('config.add', array('fulltext_postgres_ts_name', 'simple')), array('config.add', array('fulltext_postgres_min_word_len', 4)), From 8d303226351f358b24389fb2fd2d9b6bab7aa565 Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Sat, 13 Jul 2013 23:15:26 -0400 Subject: [PATCH 2221/2494] [ticket/11694] Do not locate assets with root path Do not locate assets that start with ./ PHPBB3-11694 --- phpBB/includes/template/twig/node/includeasset.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/template/twig/node/includeasset.php b/phpBB/includes/template/twig/node/includeasset.php index ae113cadc8..990b1c984f 100644 --- a/phpBB/includes/template/twig/node/includeasset.php +++ b/phpBB/includes/template/twig/node/includeasset.php @@ -34,7 +34,7 @@ class phpbb_template_twig_node_includeasset extends Twig_Node ->subcompile($this->getNode('expr')) ->raw(";\n") ->write("\$asset = new phpbb_template_asset(\$asset_file);\n") - ->write("if (\$asset->is_relative()) {\n") + ->write("if (substr(\$asset_file, 0, 2) !== './' && \$asset->is_relative()) {\n") ->indent() ->write("\$asset_path = \$asset->get_path();") ->write("\$local_file = \$this->getEnvironment()->get_phpbb_root_path() . \$asset_path;\n") From d6de892ee40579c45259f8c68ba7eef26accc08b Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 13 Jul 2013 16:47:15 -0400 Subject: [PATCH 2222/2494] [ticket/11574] Fix various path issues in the updater PHPBB3-11574 --- phpBB/includes/functions_container.php | 26 +++++++++++++++++++++++- phpBB/install/database_update.php | 5 ++--- phpBB/install/install_update.php | 28 ++------------------------ 3 files changed, 29 insertions(+), 30 deletions(-) diff --git a/phpBB/includes/functions_container.php b/phpBB/includes/functions_container.php index d302b75350..923a8f370b 100644 --- a/phpBB/includes/functions_container.php +++ b/phpBB/includes/functions_container.php @@ -53,7 +53,7 @@ function phpbb_create_container(array $extensions, $phpbb_root_path, $php_ext) */ function phpbb_create_install_container($phpbb_root_path, $php_ext) { - $other_config_path = $phpbb_root_path . 'install/update/new/config'; + $other_config_path = $phpbb_root_path . 'install/update/new/config/'; $config_path = file_exists($other_config_path . 'services.yml') ? $other_config_path : $phpbb_root_path . 'config'; $core = new phpbb_di_extension_core($config_path); @@ -73,6 +73,30 @@ function phpbb_create_install_container($phpbb_root_path, $php_ext) return $container; } +/** +* Create updater container +* +* @param string $phpbb_root_path Root path +* @param string $php_ext PHP Extension +* @param array $config_path Path to config directory +* @return ContainerBuilder object (compiled) +*/ +function phpbb_create_update_container($phpbb_root_path, $php_ext, $config_path) +{ + return phpbb_create_compiled_container( + array( + new phpbb_di_extension_config($phpbb_root_path . 'config.' . $php_ext), + new phpbb_di_extension_core($config_path), + ), + array( + new phpbb_di_pass_collection_pass(), + new phpbb_di_pass_kernel_pass(), + ), + $phpbb_root_path, + $php_ext + ); +} + /** * Create a compiled ContainerBuilder object * diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index b0e28958ac..51ffdd3c88 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -121,8 +121,8 @@ $phpbb_class_loader = new phpbb_class_loader('phpbb_', "{$phpbb_root_path}includ $phpbb_class_loader->register(); // Set up container (must be done here because extensions table may not exist) -$other_config_path = $phpbb_root_path . 'install/update/new/config'; -$config_path = file_exists($other_config_path . 'services.yml') ? $other_config_path : $phpbb_root_path; +$other_config_path = $phpbb_root_path . 'install/update/new/config/'; +$config_path = file_exists($other_config_path . 'services.yml') ? $other_config_path : $phpbb_root_path . 'config'; $container_extensions = array( new phpbb_di_extension_config($phpbb_root_path . 'config.' . $phpEx), @@ -130,7 +130,6 @@ $container_extensions = array( ); $container_passes = array( new phpbb_di_pass_collection_pass(), - //new phpbb_di_pass_kernel_pass(), ); $phpbb_container = phpbb_create_container($container_extensions, $phpbb_root_path, $phpEx); diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php index 38d9f66629..f9dfaaef50 100644 --- a/phpBB/install/install_update.php +++ b/phpBB/install/install_update.php @@ -75,7 +75,7 @@ class install_update extends module global $request, $phpbb_admin_path, $phpbb_adm_relative_path, $phpbb_container; // Create a normal container now - $phpbb_container = phpbb_create_default_container($phpbb_root_path, $phpEx); + $phpbb_container = phpbb_create_update_container($phpbb_root_path, $phpEx, $phpbb_root_path . 'install/update/new/config'); // Writes into global $cache $cache = $phpbb_container->get('cache'); @@ -125,7 +125,7 @@ class install_update extends module $config['default_lang'] = $language; $user->data['user_lang'] = $language; - $user->setup(array('common', 'acp/common', 'acp/board', 'install', 'posting')); + $user->add_lang(array('common', 'acp/common', 'acp/board', 'install', 'posting')); // Reset the default_lang $config['default_lang'] = $config_default_lang; @@ -302,30 +302,6 @@ class install_update extends module break; case 'update_db': - - // Make sure the database update is valid for the latest version - $valid = false; - $updates_to_version = ''; - - if (file_exists($phpbb_root_path . 'install/database_update.' . $phpEx)) - { - include_once($phpbb_root_path . 'install/database_update.' . $phpEx); - - if ($updates_to_version === $this->update_info['version']['to']) - { - $valid = true; - } - } - - // Should not happen at all - if (!$valid) - { - trigger_error($user->lang['DATABASE_UPDATE_INFO_OLD'], E_USER_ERROR); - } - - // Just a precaution - $cache->purge(); - // Redirect the user to the database update script with some explanations... $template->assign_vars(array( 'S_DB_UPDATE' => true, From c96f8936c969b3fd441c179cc4ffa8ea75d8f901 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 13 Jul 2013 18:19:21 -0400 Subject: [PATCH 2223/2494] [ticket/11574] Fix table prefix in database updater PHPBB3-11574 --- phpBB/install/database_update.php | 3 ++- phpBB/install/index.php | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 51ffdd3c88..5f2d46c7ad 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -25,7 +25,7 @@ if (!function_exists('phpbb_require_updated')) { function phpbb_require_updated($path, $optional = false) { - global $phpbb_root_path; + global $phpbb_root_path, $table_prefix; $new_path = $phpbb_root_path . 'install/update/new/' . $path; $old_path = $phpbb_root_path . $path; @@ -108,6 +108,7 @@ phpbb_require_updated('includes/functions.' . $phpEx); phpbb_require_updated('includes/functions_content.' . $phpEx); phpbb_require_updated('includes/functions_container.' . $phpEx); +require($phpbb_root_path . 'config.' . $phpEx); phpbb_require_updated('includes/constants.' . $phpEx); phpbb_require_updated('includes/utf/utf_tools.' . $phpEx); diff --git a/phpBB/install/index.php b/phpBB/install/index.php index 4051a5a08b..055fb72d7c 100644 --- a/phpBB/install/index.php +++ b/phpBB/install/index.php @@ -28,7 +28,7 @@ if (version_compare(PHP_VERSION, '5.3.3') < 0) function phpbb_require_updated($path, $optional = false) { - global $phpbb_root_path; + global $phpbb_root_path, $table_prefix; $new_path = $phpbb_root_path . 'install/update/new/' . $path; $old_path = $phpbb_root_path . $path; From e6e2a50062eca8b640822b8f616ea4bb23b23566 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sun, 14 Jul 2013 01:28:49 -0400 Subject: [PATCH 2224/2494] [ticket/11574] Add trailing slash for consistency PHPBB3-11574 --- phpBB/includes/functions_container.php | 2 +- phpBB/install/database_update.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/functions_container.php b/phpBB/includes/functions_container.php index 923a8f370b..e22fa9919a 100644 --- a/phpBB/includes/functions_container.php +++ b/phpBB/includes/functions_container.php @@ -54,7 +54,7 @@ function phpbb_create_container(array $extensions, $phpbb_root_path, $php_ext) function phpbb_create_install_container($phpbb_root_path, $php_ext) { $other_config_path = $phpbb_root_path . 'install/update/new/config/'; - $config_path = file_exists($other_config_path . 'services.yml') ? $other_config_path : $phpbb_root_path . 'config'; + $config_path = file_exists($other_config_path . 'services.yml') ? $other_config_path : $phpbb_root_path . 'config/'; $core = new phpbb_di_extension_core($config_path); $container = phpbb_create_container(array($core), $phpbb_root_path, $php_ext); diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 5f2d46c7ad..e0ecc242e1 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -123,7 +123,7 @@ $phpbb_class_loader->register(); // Set up container (must be done here because extensions table may not exist) $other_config_path = $phpbb_root_path . 'install/update/new/config/'; -$config_path = file_exists($other_config_path . 'services.yml') ? $other_config_path : $phpbb_root_path . 'config'; +$config_path = file_exists($other_config_path . 'services.yml') ? $other_config_path : $phpbb_root_path . 'config/'; $container_extensions = array( new phpbb_di_extension_config($phpbb_root_path . 'config.' . $phpEx), From 7030578bbe9e11c18b5becaf8b06e670e3c2e3cd Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Sun, 14 Jul 2013 01:32:34 -0400 Subject: [PATCH 2225/2494] [ticket/11698] Moving all autoloadable files to phpbb/ PHPBB3-11698 --- phpBB/common.php | 6 +++--- phpBB/includes/acp/acp_search.php | 2 +- phpBB/install/database_update.php | 6 +++--- phpBB/install/index.php | 4 ++-- phpBB/install/install_install.php | 6 +++--- phpBB/{includes => phpbb}/auth/auth.php | 0 phpBB/{includes => phpbb}/auth/index.htm | 0 phpBB/{includes => phpbb}/auth/provider/apache.php | 0 phpBB/{includes => phpbb}/auth/provider/base.php | 0 phpBB/{includes => phpbb}/auth/provider/db.php | 0 phpBB/{includes => phpbb}/auth/provider/index.htm | 0 phpBB/{includes => phpbb}/auth/provider/interface.php | 0 phpBB/{includes => phpbb}/auth/provider/ldap.php | 0 phpBB/{includes => phpbb}/avatar/driver/driver.php | 0 phpBB/{includes => phpbb}/avatar/driver/gravatar.php | 0 phpBB/{includes => phpbb}/avatar/driver/interface.php | 0 phpBB/{includes => phpbb}/avatar/driver/local.php | 0 phpBB/{includes => phpbb}/avatar/driver/remote.php | 0 phpBB/{includes => phpbb}/avatar/driver/upload.php | 0 phpBB/{includes => phpbb}/avatar/manager.php | 0 phpBB/{includes => phpbb}/cache/driver/apc.php | 0 phpBB/{includes => phpbb}/cache/driver/base.php | 0 .../{includes => phpbb}/cache/driver/eaccelerator.php | 0 phpBB/{includes => phpbb}/cache/driver/file.php | 0 phpBB/{includes => phpbb}/cache/driver/interface.php | 0 phpBB/{includes => phpbb}/cache/driver/memcache.php | 0 phpBB/{includes => phpbb}/cache/driver/memory.php | 0 phpBB/{includes => phpbb}/cache/driver/null.php | 0 phpBB/{includes => phpbb}/cache/driver/redis.php | 0 phpBB/{includes => phpbb}/cache/driver/wincache.php | 0 phpBB/{includes => phpbb}/cache/driver/xcache.php | 0 phpBB/{includes => phpbb}/cache/service.php | 0 phpBB/{includes => phpbb}/class_loader.php | 0 phpBB/{includes => phpbb}/config/config.php | 0 phpBB/{includes => phpbb}/config/db.php | 0 phpBB/{includes => phpbb}/config/db_text.php | 0 phpBB/{includes => phpbb}/content_visibility.php | 0 phpBB/{includes => phpbb}/controller/exception.php | 0 phpBB/{includes => phpbb}/controller/helper.php | 0 phpBB/{includes => phpbb}/controller/provider.php | 0 phpBB/{includes => phpbb}/controller/resolver.php | 0 phpBB/{includes => phpbb}/cron/manager.php | 0 phpBB/{includes => phpbb}/cron/task/base.php | 0 .../cron/task/core/prune_all_forums.php | 0 .../{includes => phpbb}/cron/task/core/prune_forum.php | 0 phpBB/{includes => phpbb}/cron/task/core/queue.php | 0 .../{includes => phpbb}/cron/task/core/tidy_cache.php | 0 .../cron/task/core/tidy_database.php | 0 .../{includes => phpbb}/cron/task/core/tidy_search.php | 7 +------ .../cron/task/core/tidy_sessions.php | 0 .../cron/task/core/tidy_warnings.php | 0 phpBB/{includes => phpbb}/cron/task/parametrized.php | 0 phpBB/{includes => phpbb}/cron/task/task.php | 0 phpBB/{includes => phpbb}/cron/task/wrapper.php | 0 phpBB/{includes => phpbb}/datetime.php | 0 phpBB/{includes => phpbb}/db/driver/driver.php | 0 phpBB/{includes => phpbb}/db/driver/firebird.php | 0 phpBB/{includes => phpbb}/db/driver/mssql.php | 0 phpBB/{includes => phpbb}/db/driver/mssql_base.php | 0 phpBB/{includes => phpbb}/db/driver/mssql_odbc.php | 0 phpBB/{includes => phpbb}/db/driver/mssqlnative.php | 0 phpBB/{includes => phpbb}/db/driver/mysql.php | 0 phpBB/{includes => phpbb}/db/driver/mysql_base.php | 0 phpBB/{includes => phpbb}/db/driver/mysqli.php | 0 phpBB/{includes => phpbb}/db/driver/oracle.php | 0 phpBB/{includes => phpbb}/db/driver/postgres.php | 0 phpBB/{includes => phpbb}/db/driver/sqlite.php | 0 .../db/migration/data/30x/3_0_1.php | 0 .../db/migration/data/30x/3_0_10.php | 0 .../db/migration/data/30x/3_0_10_rc1.php | 0 .../db/migration/data/30x/3_0_10_rc2.php | 0 .../db/migration/data/30x/3_0_10_rc3.php | 0 .../db/migration/data/30x/3_0_11.php | 0 .../db/migration/data/30x/3_0_11_rc1.php | 0 .../db/migration/data/30x/3_0_11_rc2.php | 0 .../db/migration/data/30x/3_0_12_rc1.php | 0 .../db/migration/data/30x/3_0_1_rc1.php | 0 .../db/migration/data/30x/3_0_2.php | 0 .../db/migration/data/30x/3_0_2_rc1.php | 0 .../db/migration/data/30x/3_0_2_rc2.php | 0 .../db/migration/data/30x/3_0_3.php | 0 .../db/migration/data/30x/3_0_3_rc1.php | 0 .../db/migration/data/30x/3_0_4.php | 0 .../db/migration/data/30x/3_0_4_rc1.php | 0 .../db/migration/data/30x/3_0_5.php | 0 .../db/migration/data/30x/3_0_5_rc1.php | 0 .../db/migration/data/30x/3_0_5_rc1part2.php | 0 .../db/migration/data/30x/3_0_6.php | 0 .../db/migration/data/30x/3_0_6_rc1.php | 0 .../db/migration/data/30x/3_0_6_rc2.php | 0 .../db/migration/data/30x/3_0_6_rc3.php | 0 .../db/migration/data/30x/3_0_6_rc4.php | 0 .../db/migration/data/30x/3_0_7.php | 0 .../db/migration/data/30x/3_0_7_pl1.php | 0 .../db/migration/data/30x/3_0_7_rc1.php | 0 .../db/migration/data/30x/3_0_7_rc2.php | 0 .../db/migration/data/30x/3_0_8.php | 0 .../db/migration/data/30x/3_0_8_rc1.php | 0 .../db/migration/data/30x/3_0_9.php | 0 .../db/migration/data/30x/3_0_9_rc1.php | 0 .../db/migration/data/30x/3_0_9_rc2.php | 0 .../db/migration/data/30x/3_0_9_rc3.php | 0 .../db/migration/data/30x/3_0_9_rc4.php | 0 .../db/migration/data/30x/local_url_bbcode.php | 0 .../db/migration/data/310/avatars.php | 0 .../db/migration/data/310/boardindex.php | 0 .../db/migration/data/310/config_db_text.php | 0 .../{includes => phpbb}/db/migration/data/310/dev.php | 0 .../db/migration/data/310/extensions.php | 0 .../db/migration/data/310/forgot_password.php | 0 .../db/migration/data/310/jquery_update.php | 0 .../data/310/notification_options_reconvert.php | 0 .../db/migration/data/310/notifications.php | 0 .../db/migration/data/310/notifications_schema_fix.php | 0 .../db/migration/data/310/reported_posts_display.php | 0 .../db/migration/data/310/signature_module_auth.php | 0 .../db/migration/data/310/softdelete_p1.php | 0 .../db/migration/data/310/softdelete_p2.php | 0 .../db/migration/data/310/style_update_p1.php | 0 .../db/migration/data/310/style_update_p2.php | 0 .../db/migration/data/310/teampage.php | 0 .../db/migration/data/310/timezone.php | 0 .../db/migration/data/310/timezone_p2.php | 0 phpBB/{includes => phpbb}/db/migration/exception.php | 0 phpBB/{includes => phpbb}/db/migration/migration.php | 0 phpBB/{includes => phpbb}/db/migration/tool/config.php | 0 .../db/migration/tool/interface.php | 0 phpBB/{includes => phpbb}/db/migration/tool/module.php | 0 .../db/migration/tool/permission.php | 0 phpBB/{includes => phpbb}/db/migrator.php | 0 phpBB/{includes => phpbb}/db/sql_insert_buffer.php | 0 phpBB/{includes => phpbb}/di/extension/config.php | 0 phpBB/{includes => phpbb}/di/extension/core.php | 0 phpBB/{includes => phpbb}/di/extension/ext.php | 0 phpBB/{includes => phpbb}/di/pass/collection_pass.php | 0 phpBB/{includes => phpbb}/di/pass/kernel_pass.php | 0 phpBB/{includes => phpbb}/di/service_collection.php | 0 phpBB/{includes => phpbb}/error_collector.php | 0 phpBB/{includes => phpbb}/event/data.php | 0 phpBB/{includes => phpbb}/event/dispatcher.php | 0 .../event/extension_subscriber_loader.php | 0 .../event/kernel_exception_subscriber.php | 0 .../event/kernel_request_subscriber.php | 0 .../event/kernel_terminate_subscriber.php | 0 phpBB/{includes => phpbb}/extension/base.php | 0 phpBB/{includes => phpbb}/extension/exception.php | 0 phpBB/{includes => phpbb}/extension/finder.php | 4 ++-- phpBB/{includes => phpbb}/extension/interface.php | 0 phpBB/{includes => phpbb}/extension/manager.php | 0 .../{includes => phpbb}/extension/metadata_manager.php | 0 phpBB/{includes => phpbb}/extension/provider.php | 0 phpBB/{includes => phpbb}/feed/base.php | 0 phpBB/{includes => phpbb}/feed/factory.php | 0 phpBB/{includes => phpbb}/feed/forum.php | 0 phpBB/{includes => phpbb}/feed/forums.php | 0 phpBB/{includes => phpbb}/feed/helper.php | 0 phpBB/{includes => phpbb}/feed/news.php | 0 phpBB/{includes => phpbb}/feed/overall.php | 0 phpBB/{includes => phpbb}/feed/post_base.php | 0 phpBB/{includes => phpbb}/feed/topic.php | 0 phpBB/{includes => phpbb}/feed/topic_base.php | 0 phpBB/{includes => phpbb}/feed/topics.php | 0 phpBB/{includes => phpbb}/feed/topics_active.php | 0 phpBB/{includes => phpbb}/filesystem.php | 0 phpBB/{includes => phpbb}/groupposition/exception.php | 0 phpBB/{includes => phpbb}/groupposition/interface.php | 0 phpBB/{includes => phpbb}/groupposition/legend.php | 0 phpBB/{includes => phpbb}/groupposition/teampage.php | 0 phpBB/{includes => phpbb}/hook/finder.php | 0 phpBB/{includes => phpbb}/json_response.php | 0 phpBB/{includes => phpbb}/lock/db.php | 0 phpBB/{includes => phpbb}/lock/flock.php | 0 phpBB/{includes => phpbb}/log/interface.php | 0 phpBB/{includes => phpbb}/log/log.php | 0 phpBB/{includes => phpbb}/notification/exception.php | 0 phpBB/{includes => phpbb}/notification/manager.php | 0 phpBB/{includes => phpbb}/notification/method/base.php | 0 .../{includes => phpbb}/notification/method/email.php | 0 .../notification/method/interface.php | 0 .../{includes => phpbb}/notification/method/jabber.php | 0 .../notification/method/messenger_base.php | 0 .../notification/type/approve_post.php | 0 .../notification/type/approve_topic.php | 0 phpBB/{includes => phpbb}/notification/type/base.php | 0 .../{includes => phpbb}/notification/type/bookmark.php | 0 .../notification/type/disapprove_post.php | 0 .../notification/type/disapprove_topic.php | 0 .../notification/type/interface.php | 0 phpBB/{includes => phpbb}/notification/type/pm.php | 0 phpBB/{includes => phpbb}/notification/type/post.php | 0 .../notification/type/post_in_queue.php | 0 phpBB/{includes => phpbb}/notification/type/quote.php | 0 .../notification/type/report_pm.php | 0 .../notification/type/report_pm_closed.php | 0 .../notification/type/report_post.php | 0 .../notification/type/report_post_closed.php | 0 phpBB/{includes => phpbb}/notification/type/topic.php | 0 .../notification/type/topic_in_queue.php | 0 phpBB/{includes => phpbb}/php/ini.php | 0 .../request/deactivated_super_global.php | 0 phpBB/{includes => phpbb}/request/interface.php | 0 phpBB/{includes => phpbb}/request/request.php | 0 phpBB/{includes => phpbb}/request/type_cast_helper.php | 0 .../request/type_cast_helper_interface.php | 0 phpBB/{includes => phpbb}/search/base.php | 0 phpBB/{includes => phpbb}/search/fulltext_mysql.php | 0 phpBB/{includes => phpbb}/search/fulltext_native.php | 0 phpBB/{includes => phpbb}/search/fulltext_postgres.php | 0 phpBB/{includes => phpbb}/search/fulltext_sphinx.php | 0 phpBB/{includes => phpbb}/search/index.htm | 0 phpBB/{includes => phpbb}/search/sphinx/config.php | 0 .../search/sphinx/config_comment.php | 0 .../search/sphinx/config_section.php | 0 .../search/sphinx/config_variable.php | 0 phpBB/{includes => phpbb}/session.php | 0 .../style/extension_path_provider.php | 0 phpBB/{includes => phpbb}/style/path_provider.php | 0 .../style/path_provider_interface.php | 0 phpBB/{includes => phpbb}/style/resource_locator.php | 0 phpBB/{includes => phpbb}/style/style.php | 0 phpBB/{includes => phpbb}/template/asset.php | 0 phpBB/{includes => phpbb}/template/context.php | 0 phpBB/{includes => phpbb}/template/locator.php | 0 phpBB/{includes => phpbb}/template/template.php | 0 phpBB/{includes => phpbb}/template/twig/definition.php | 0 .../{includes => phpbb}/template/twig/environment.php | 0 phpBB/{includes => phpbb}/template/twig/extension.php | 0 phpBB/{includes => phpbb}/template/twig/lexer.php | 0 .../{includes => phpbb}/template/twig/node/define.php | 0 phpBB/{includes => phpbb}/template/twig/node/event.php | 0 .../twig/node/expression/binary/equalequal.php | 0 .../twig/node/expression/binary/notequalequal.php | 0 .../{includes => phpbb}/template/twig/node/include.php | 0 .../template/twig/node/includeasset.php | 0 .../template/twig/node/includecss.php | 0 .../template/twig/node/includejs.php | 0 .../template/twig/node/includephp.php | 0 phpBB/{includes => phpbb}/template/twig/node/php.php | 0 .../template/twig/tokenparser/define.php | 0 .../template/twig/tokenparser/event.php | 0 .../template/twig/tokenparser/include.php | 0 .../template/twig/tokenparser/includecss.php | 0 .../template/twig/tokenparser/includejs.php | 0 .../template/twig/tokenparser/includephp.php | 0 .../template/twig/tokenparser/php.php | 0 phpBB/{includes => phpbb}/template/twig/twig.php | 0 phpBB/{includes => phpbb}/tree/interface.php | 0 phpBB/{includes => phpbb}/tree/nestedset.php | 0 phpBB/{includes => phpbb}/tree/nestedset_forum.php | 0 phpBB/{includes => phpbb}/user.php | 0 phpBB/{includes => phpbb}/user_loader.php | 0 phpunit.xml.all | 5 +++-- phpunit.xml.dist | 5 +++-- phpunit.xml.functional | 5 +++-- tests/bootstrap.php | 4 ++-- tests/class_loader/class_loader_test.php | 10 +++++----- tests/class_loader/{includes => phpbb}/class_name.php | 0 tests/class_loader/{includes => phpbb}/dir.php | 0 .../{includes => phpbb}/dir/class_name.php | 0 .../{includes => phpbb}/dir/subdir/class_name.php | 0 tests/class_loader/{includes => phpbb}/dir2/dir2.php | 0 tests/controller/controller_test.php | 2 +- .../controller/{includes => phpbb}/controller/foo.php | 0 tests/datetime/from_format_test.php | 3 --- tests/dbal/migrator_test.php | 2 -- tests/dbal/migrator_tool_config_test.php | 3 --- tests/dbal/migrator_tool_module_test.php | 2 -- tests/dbal/migrator_tool_permission_test.php | 2 -- tests/error_collector_test.php | 1 - tests/extension/finder_test.php | 8 ++++---- .../{includes => phpbb}/default/implementation.php | 0 tests/log/function_view_log_test.php | 1 - tests/upload/fileupload_test.php | 1 + 273 files changed, 37 insertions(+), 52 deletions(-) rename phpBB/{includes => phpbb}/auth/auth.php (100%) rename phpBB/{includes => phpbb}/auth/index.htm (100%) rename phpBB/{includes => phpbb}/auth/provider/apache.php (100%) rename phpBB/{includes => phpbb}/auth/provider/base.php (100%) rename phpBB/{includes => phpbb}/auth/provider/db.php (100%) rename phpBB/{includes => phpbb}/auth/provider/index.htm (100%) rename phpBB/{includes => phpbb}/auth/provider/interface.php (100%) rename phpBB/{includes => phpbb}/auth/provider/ldap.php (100%) rename phpBB/{includes => phpbb}/avatar/driver/driver.php (100%) rename phpBB/{includes => phpbb}/avatar/driver/gravatar.php (100%) rename phpBB/{includes => phpbb}/avatar/driver/interface.php (100%) rename phpBB/{includes => phpbb}/avatar/driver/local.php (100%) rename phpBB/{includes => phpbb}/avatar/driver/remote.php (100%) rename phpBB/{includes => phpbb}/avatar/driver/upload.php (100%) rename phpBB/{includes => phpbb}/avatar/manager.php (100%) rename phpBB/{includes => phpbb}/cache/driver/apc.php (100%) rename phpBB/{includes => phpbb}/cache/driver/base.php (100%) rename phpBB/{includes => phpbb}/cache/driver/eaccelerator.php (100%) rename phpBB/{includes => phpbb}/cache/driver/file.php (100%) rename phpBB/{includes => phpbb}/cache/driver/interface.php (100%) rename phpBB/{includes => phpbb}/cache/driver/memcache.php (100%) rename phpBB/{includes => phpbb}/cache/driver/memory.php (100%) rename phpBB/{includes => phpbb}/cache/driver/null.php (100%) rename phpBB/{includes => phpbb}/cache/driver/redis.php (100%) rename phpBB/{includes => phpbb}/cache/driver/wincache.php (100%) rename phpBB/{includes => phpbb}/cache/driver/xcache.php (100%) rename phpBB/{includes => phpbb}/cache/service.php (100%) rename phpBB/{includes => phpbb}/class_loader.php (100%) rename phpBB/{includes => phpbb}/config/config.php (100%) rename phpBB/{includes => phpbb}/config/db.php (100%) rename phpBB/{includes => phpbb}/config/db_text.php (100%) rename phpBB/{includes => phpbb}/content_visibility.php (100%) rename phpBB/{includes => phpbb}/controller/exception.php (100%) rename phpBB/{includes => phpbb}/controller/helper.php (100%) rename phpBB/{includes => phpbb}/controller/provider.php (100%) rename phpBB/{includes => phpbb}/controller/resolver.php (100%) rename phpBB/{includes => phpbb}/cron/manager.php (100%) rename phpBB/{includes => phpbb}/cron/task/base.php (100%) rename phpBB/{includes => phpbb}/cron/task/core/prune_all_forums.php (100%) rename phpBB/{includes => phpbb}/cron/task/core/prune_forum.php (100%) rename phpBB/{includes => phpbb}/cron/task/core/queue.php (100%) rename phpBB/{includes => phpbb}/cron/task/core/tidy_cache.php (100%) rename phpBB/{includes => phpbb}/cron/task/core/tidy_database.php (100%) rename phpBB/{includes => phpbb}/cron/task/core/tidy_search.php (90%) rename phpBB/{includes => phpbb}/cron/task/core/tidy_sessions.php (100%) rename phpBB/{includes => phpbb}/cron/task/core/tidy_warnings.php (100%) rename phpBB/{includes => phpbb}/cron/task/parametrized.php (100%) rename phpBB/{includes => phpbb}/cron/task/task.php (100%) rename phpBB/{includes => phpbb}/cron/task/wrapper.php (100%) rename phpBB/{includes => phpbb}/datetime.php (100%) rename phpBB/{includes => phpbb}/db/driver/driver.php (100%) rename phpBB/{includes => phpbb}/db/driver/firebird.php (100%) rename phpBB/{includes => phpbb}/db/driver/mssql.php (100%) rename phpBB/{includes => phpbb}/db/driver/mssql_base.php (100%) rename phpBB/{includes => phpbb}/db/driver/mssql_odbc.php (100%) rename phpBB/{includes => phpbb}/db/driver/mssqlnative.php (100%) rename phpBB/{includes => phpbb}/db/driver/mysql.php (100%) rename phpBB/{includes => phpbb}/db/driver/mysql_base.php (100%) rename phpBB/{includes => phpbb}/db/driver/mysqli.php (100%) rename phpBB/{includes => phpbb}/db/driver/oracle.php (100%) rename phpBB/{includes => phpbb}/db/driver/postgres.php (100%) rename phpBB/{includes => phpbb}/db/driver/sqlite.php (100%) rename phpBB/{includes => phpbb}/db/migration/data/30x/3_0_1.php (100%) rename phpBB/{includes => phpbb}/db/migration/data/30x/3_0_10.php (100%) rename phpBB/{includes => phpbb}/db/migration/data/30x/3_0_10_rc1.php (100%) rename phpBB/{includes => phpbb}/db/migration/data/30x/3_0_10_rc2.php (100%) rename phpBB/{includes => phpbb}/db/migration/data/30x/3_0_10_rc3.php (100%) rename phpBB/{includes => phpbb}/db/migration/data/30x/3_0_11.php (100%) rename phpBB/{includes => phpbb}/db/migration/data/30x/3_0_11_rc1.php (100%) rename phpBB/{includes => phpbb}/db/migration/data/30x/3_0_11_rc2.php (100%) rename phpBB/{includes => phpbb}/db/migration/data/30x/3_0_12_rc1.php (100%) rename phpBB/{includes => phpbb}/db/migration/data/30x/3_0_1_rc1.php (100%) rename phpBB/{includes => phpbb}/db/migration/data/30x/3_0_2.php (100%) rename phpBB/{includes => phpbb}/db/migration/data/30x/3_0_2_rc1.php (100%) rename phpBB/{includes => phpbb}/db/migration/data/30x/3_0_2_rc2.php (100%) rename phpBB/{includes => phpbb}/db/migration/data/30x/3_0_3.php (100%) rename phpBB/{includes => phpbb}/db/migration/data/30x/3_0_3_rc1.php (100%) rename phpBB/{includes => phpbb}/db/migration/data/30x/3_0_4.php (100%) rename phpBB/{includes => phpbb}/db/migration/data/30x/3_0_4_rc1.php (100%) rename phpBB/{includes => phpbb}/db/migration/data/30x/3_0_5.php (100%) rename phpBB/{includes => phpbb}/db/migration/data/30x/3_0_5_rc1.php (100%) rename phpBB/{includes => phpbb}/db/migration/data/30x/3_0_5_rc1part2.php (100%) rename phpBB/{includes => phpbb}/db/migration/data/30x/3_0_6.php (100%) rename phpBB/{includes => phpbb}/db/migration/data/30x/3_0_6_rc1.php (100%) rename phpBB/{includes => phpbb}/db/migration/data/30x/3_0_6_rc2.php (100%) rename phpBB/{includes => phpbb}/db/migration/data/30x/3_0_6_rc3.php (100%) rename phpBB/{includes => phpbb}/db/migration/data/30x/3_0_6_rc4.php (100%) rename phpBB/{includes => phpbb}/db/migration/data/30x/3_0_7.php (100%) rename phpBB/{includes => phpbb}/db/migration/data/30x/3_0_7_pl1.php (100%) rename phpBB/{includes => phpbb}/db/migration/data/30x/3_0_7_rc1.php (100%) rename phpBB/{includes => phpbb}/db/migration/data/30x/3_0_7_rc2.php (100%) rename phpBB/{includes => phpbb}/db/migration/data/30x/3_0_8.php (100%) rename phpBB/{includes => phpbb}/db/migration/data/30x/3_0_8_rc1.php (100%) rename phpBB/{includes => phpbb}/db/migration/data/30x/3_0_9.php (100%) rename phpBB/{includes => phpbb}/db/migration/data/30x/3_0_9_rc1.php (100%) rename phpBB/{includes => phpbb}/db/migration/data/30x/3_0_9_rc2.php (100%) rename phpBB/{includes => phpbb}/db/migration/data/30x/3_0_9_rc3.php (100%) rename phpBB/{includes => phpbb}/db/migration/data/30x/3_0_9_rc4.php (100%) rename phpBB/{includes => phpbb}/db/migration/data/30x/local_url_bbcode.php (100%) rename phpBB/{includes => phpbb}/db/migration/data/310/avatars.php (100%) rename phpBB/{includes => phpbb}/db/migration/data/310/boardindex.php (100%) rename phpBB/{includes => phpbb}/db/migration/data/310/config_db_text.php (100%) rename phpBB/{includes => phpbb}/db/migration/data/310/dev.php (100%) rename phpBB/{includes => phpbb}/db/migration/data/310/extensions.php (100%) rename phpBB/{includes => phpbb}/db/migration/data/310/forgot_password.php (100%) rename phpBB/{includes => phpbb}/db/migration/data/310/jquery_update.php (100%) rename phpBB/{includes => phpbb}/db/migration/data/310/notification_options_reconvert.php (100%) rename phpBB/{includes => phpbb}/db/migration/data/310/notifications.php (100%) rename phpBB/{includes => phpbb}/db/migration/data/310/notifications_schema_fix.php (100%) rename phpBB/{includes => phpbb}/db/migration/data/310/reported_posts_display.php (100%) rename phpBB/{includes => phpbb}/db/migration/data/310/signature_module_auth.php (100%) rename phpBB/{includes => phpbb}/db/migration/data/310/softdelete_p1.php (100%) rename phpBB/{includes => phpbb}/db/migration/data/310/softdelete_p2.php (100%) rename phpBB/{includes => phpbb}/db/migration/data/310/style_update_p1.php (100%) rename phpBB/{includes => phpbb}/db/migration/data/310/style_update_p2.php (100%) rename phpBB/{includes => phpbb}/db/migration/data/310/teampage.php (100%) rename phpBB/{includes => phpbb}/db/migration/data/310/timezone.php (100%) rename phpBB/{includes => phpbb}/db/migration/data/310/timezone_p2.php (100%) rename phpBB/{includes => phpbb}/db/migration/exception.php (100%) rename phpBB/{includes => phpbb}/db/migration/migration.php (100%) rename phpBB/{includes => phpbb}/db/migration/tool/config.php (100%) rename phpBB/{includes => phpbb}/db/migration/tool/interface.php (100%) rename phpBB/{includes => phpbb}/db/migration/tool/module.php (100%) rename phpBB/{includes => phpbb}/db/migration/tool/permission.php (100%) rename phpBB/{includes => phpbb}/db/migrator.php (100%) rename phpBB/{includes => phpbb}/db/sql_insert_buffer.php (100%) rename phpBB/{includes => phpbb}/di/extension/config.php (100%) rename phpBB/{includes => phpbb}/di/extension/core.php (100%) rename phpBB/{includes => phpbb}/di/extension/ext.php (100%) rename phpBB/{includes => phpbb}/di/pass/collection_pass.php (100%) rename phpBB/{includes => phpbb}/di/pass/kernel_pass.php (100%) rename phpBB/{includes => phpbb}/di/service_collection.php (100%) rename phpBB/{includes => phpbb}/error_collector.php (100%) rename phpBB/{includes => phpbb}/event/data.php (100%) rename phpBB/{includes => phpbb}/event/dispatcher.php (100%) rename phpBB/{includes => phpbb}/event/extension_subscriber_loader.php (100%) rename phpBB/{includes => phpbb}/event/kernel_exception_subscriber.php (100%) rename phpBB/{includes => phpbb}/event/kernel_request_subscriber.php (100%) rename phpBB/{includes => phpbb}/event/kernel_terminate_subscriber.php (100%) rename phpBB/{includes => phpbb}/extension/base.php (100%) rename phpBB/{includes => phpbb}/extension/exception.php (100%) rename phpBB/{includes => phpbb}/extension/finder.php (99%) rename phpBB/{includes => phpbb}/extension/interface.php (100%) rename phpBB/{includes => phpbb}/extension/manager.php (100%) rename phpBB/{includes => phpbb}/extension/metadata_manager.php (100%) rename phpBB/{includes => phpbb}/extension/provider.php (100%) rename phpBB/{includes => phpbb}/feed/base.php (100%) rename phpBB/{includes => phpbb}/feed/factory.php (100%) rename phpBB/{includes => phpbb}/feed/forum.php (100%) rename phpBB/{includes => phpbb}/feed/forums.php (100%) rename phpBB/{includes => phpbb}/feed/helper.php (100%) rename phpBB/{includes => phpbb}/feed/news.php (100%) rename phpBB/{includes => phpbb}/feed/overall.php (100%) rename phpBB/{includes => phpbb}/feed/post_base.php (100%) rename phpBB/{includes => phpbb}/feed/topic.php (100%) rename phpBB/{includes => phpbb}/feed/topic_base.php (100%) rename phpBB/{includes => phpbb}/feed/topics.php (100%) rename phpBB/{includes => phpbb}/feed/topics_active.php (100%) rename phpBB/{includes => phpbb}/filesystem.php (100%) rename phpBB/{includes => phpbb}/groupposition/exception.php (100%) rename phpBB/{includes => phpbb}/groupposition/interface.php (100%) rename phpBB/{includes => phpbb}/groupposition/legend.php (100%) rename phpBB/{includes => phpbb}/groupposition/teampage.php (100%) rename phpBB/{includes => phpbb}/hook/finder.php (100%) rename phpBB/{includes => phpbb}/json_response.php (100%) rename phpBB/{includes => phpbb}/lock/db.php (100%) rename phpBB/{includes => phpbb}/lock/flock.php (100%) rename phpBB/{includes => phpbb}/log/interface.php (100%) rename phpBB/{includes => phpbb}/log/log.php (100%) rename phpBB/{includes => phpbb}/notification/exception.php (100%) rename phpBB/{includes => phpbb}/notification/manager.php (100%) rename phpBB/{includes => phpbb}/notification/method/base.php (100%) rename phpBB/{includes => phpbb}/notification/method/email.php (100%) rename phpBB/{includes => phpbb}/notification/method/interface.php (100%) rename phpBB/{includes => phpbb}/notification/method/jabber.php (100%) rename phpBB/{includes => phpbb}/notification/method/messenger_base.php (100%) rename phpBB/{includes => phpbb}/notification/type/approve_post.php (100%) rename phpBB/{includes => phpbb}/notification/type/approve_topic.php (100%) rename phpBB/{includes => phpbb}/notification/type/base.php (100%) rename phpBB/{includes => phpbb}/notification/type/bookmark.php (100%) rename phpBB/{includes => phpbb}/notification/type/disapprove_post.php (100%) rename phpBB/{includes => phpbb}/notification/type/disapprove_topic.php (100%) rename phpBB/{includes => phpbb}/notification/type/interface.php (100%) rename phpBB/{includes => phpbb}/notification/type/pm.php (100%) rename phpBB/{includes => phpbb}/notification/type/post.php (100%) rename phpBB/{includes => phpbb}/notification/type/post_in_queue.php (100%) rename phpBB/{includes => phpbb}/notification/type/quote.php (100%) rename phpBB/{includes => phpbb}/notification/type/report_pm.php (100%) rename phpBB/{includes => phpbb}/notification/type/report_pm_closed.php (100%) rename phpBB/{includes => phpbb}/notification/type/report_post.php (100%) rename phpBB/{includes => phpbb}/notification/type/report_post_closed.php (100%) rename phpBB/{includes => phpbb}/notification/type/topic.php (100%) rename phpBB/{includes => phpbb}/notification/type/topic_in_queue.php (100%) rename phpBB/{includes => phpbb}/php/ini.php (100%) rename phpBB/{includes => phpbb}/request/deactivated_super_global.php (100%) rename phpBB/{includes => phpbb}/request/interface.php (100%) rename phpBB/{includes => phpbb}/request/request.php (100%) rename phpBB/{includes => phpbb}/request/type_cast_helper.php (100%) rename phpBB/{includes => phpbb}/request/type_cast_helper_interface.php (100%) rename phpBB/{includes => phpbb}/search/base.php (100%) rename phpBB/{includes => phpbb}/search/fulltext_mysql.php (100%) rename phpBB/{includes => phpbb}/search/fulltext_native.php (100%) rename phpBB/{includes => phpbb}/search/fulltext_postgres.php (100%) rename phpBB/{includes => phpbb}/search/fulltext_sphinx.php (100%) rename phpBB/{includes => phpbb}/search/index.htm (100%) rename phpBB/{includes => phpbb}/search/sphinx/config.php (100%) rename phpBB/{includes => phpbb}/search/sphinx/config_comment.php (100%) rename phpBB/{includes => phpbb}/search/sphinx/config_section.php (100%) rename phpBB/{includes => phpbb}/search/sphinx/config_variable.php (100%) rename phpBB/{includes => phpbb}/session.php (100%) rename phpBB/{includes => phpbb}/style/extension_path_provider.php (100%) rename phpBB/{includes => phpbb}/style/path_provider.php (100%) rename phpBB/{includes => phpbb}/style/path_provider_interface.php (100%) rename phpBB/{includes => phpbb}/style/resource_locator.php (100%) rename phpBB/{includes => phpbb}/style/style.php (100%) rename phpBB/{includes => phpbb}/template/asset.php (100%) rename phpBB/{includes => phpbb}/template/context.php (100%) rename phpBB/{includes => phpbb}/template/locator.php (100%) rename phpBB/{includes => phpbb}/template/template.php (100%) rename phpBB/{includes => phpbb}/template/twig/definition.php (100%) rename phpBB/{includes => phpbb}/template/twig/environment.php (100%) rename phpBB/{includes => phpbb}/template/twig/extension.php (100%) rename phpBB/{includes => phpbb}/template/twig/lexer.php (100%) rename phpBB/{includes => phpbb}/template/twig/node/define.php (100%) rename phpBB/{includes => phpbb}/template/twig/node/event.php (100%) rename phpBB/{includes => phpbb}/template/twig/node/expression/binary/equalequal.php (100%) rename phpBB/{includes => phpbb}/template/twig/node/expression/binary/notequalequal.php (100%) rename phpBB/{includes => phpbb}/template/twig/node/include.php (100%) rename phpBB/{includes => phpbb}/template/twig/node/includeasset.php (100%) rename phpBB/{includes => phpbb}/template/twig/node/includecss.php (100%) rename phpBB/{includes => phpbb}/template/twig/node/includejs.php (100%) rename phpBB/{includes => phpbb}/template/twig/node/includephp.php (100%) rename phpBB/{includes => phpbb}/template/twig/node/php.php (100%) rename phpBB/{includes => phpbb}/template/twig/tokenparser/define.php (100%) rename phpBB/{includes => phpbb}/template/twig/tokenparser/event.php (100%) rename phpBB/{includes => phpbb}/template/twig/tokenparser/include.php (100%) rename phpBB/{includes => phpbb}/template/twig/tokenparser/includecss.php (100%) rename phpBB/{includes => phpbb}/template/twig/tokenparser/includejs.php (100%) rename phpBB/{includes => phpbb}/template/twig/tokenparser/includephp.php (100%) rename phpBB/{includes => phpbb}/template/twig/tokenparser/php.php (100%) rename phpBB/{includes => phpbb}/template/twig/twig.php (100%) rename phpBB/{includes => phpbb}/tree/interface.php (100%) rename phpBB/{includes => phpbb}/tree/nestedset.php (100%) rename phpBB/{includes => phpbb}/tree/nestedset_forum.php (100%) rename phpBB/{includes => phpbb}/user.php (100%) rename phpBB/{includes => phpbb}/user_loader.php (100%) rename tests/class_loader/{includes => phpbb}/class_name.php (100%) rename tests/class_loader/{includes => phpbb}/dir.php (100%) rename tests/class_loader/{includes => phpbb}/dir/class_name.php (100%) rename tests/class_loader/{includes => phpbb}/dir/subdir/class_name.php (100%) rename tests/class_loader/{includes => phpbb}/dir2/dir2.php (100%) rename tests/controller/{includes => phpbb}/controller/foo.php (100%) rename tests/extension/{includes => phpbb}/default/implementation.php (100%) diff --git a/phpBB/common.php b/phpBB/common.php index f6f109c3de..962a1f951f 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -46,7 +46,7 @@ if (!defined('PHPBB_INSTALLED')) $script_path = preg_replace('#[\\\\/]{2,}#', '/', $script_path); // Eliminate . and .. from the path - require($phpbb_root_path . 'includes/filesystem.' . $phpEx); + require($phpbb_root_path . 'phpbb/filesystem.' . $phpEx); $phpbb_filesystem = new phpbb_filesystem(); $script_path = $phpbb_filesystem->clean_path($script_path); @@ -71,7 +71,7 @@ $phpbb_adm_relative_path = (isset($phpbb_adm_relative_path)) ? $phpbb_adm_relati $phpbb_admin_path = (defined('PHPBB_ADMIN_PATH')) ? PHPBB_ADMIN_PATH : $phpbb_root_path . $phpbb_adm_relative_path; // Include files -require($phpbb_root_path . 'includes/class_loader.' . $phpEx); +require($phpbb_root_path . 'phpbb/class_loader.' . $phpEx); require($phpbb_root_path . 'includes/functions.' . $phpEx); require($phpbb_root_path . 'includes/functions_content.' . $phpEx); @@ -85,7 +85,7 @@ require($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx); set_error_handler(defined('PHPBB_MSG_HANDLER') ? PHPBB_MSG_HANDLER : 'msg_handler'); // Setup class loader first -$phpbb_class_loader = new phpbb_class_loader('phpbb_', "{$phpbb_root_path}includes/", $phpEx); +$phpbb_class_loader = new phpbb_class_loader('phpbb_', "{$phpbb_root_path}phpbb/", $phpEx); $phpbb_class_loader->register(); $phpbb_class_loader_ext = new phpbb_class_loader('phpbb_ext_', "{$phpbb_root_path}ext/", $phpEx); $phpbb_class_loader_ext->register(); diff --git a/phpBB/includes/acp/acp_search.php b/phpBB/includes/acp/acp_search.php index 6618e2c3f9..11a2511aee 100644 --- a/phpBB/includes/acp/acp_search.php +++ b/phpBB/includes/acp/acp_search.php @@ -560,7 +560,7 @@ class acp_search return $finder ->extension_suffix('_backend') ->extension_directory('/search') - ->core_path('includes/search/') + ->core_path('phpbb/search/') ->get_classes(); } diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index b20ca1e4ea..cd6fb7931b 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -82,7 +82,7 @@ $phpbb_adm_relative_path = (isset($phpbb_adm_relative_path)) ? $phpbb_adm_relati $phpbb_admin_path = (defined('PHPBB_ADMIN_PATH')) ? PHPBB_ADMIN_PATH : $phpbb_root_path . $phpbb_adm_relative_path; // Include files -require($phpbb_root_path . 'includes/class_loader.' . $phpEx); +require($phpbb_root_path . 'phpbb/class_loader.' . $phpEx); require($phpbb_root_path . 'includes/functions.' . $phpEx); require($phpbb_root_path . 'includes/functions_content.' . $phpEx); @@ -95,7 +95,7 @@ require($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx); set_error_handler(defined('PHPBB_MSG_HANDLER') ? PHPBB_MSG_HANDLER : 'msg_handler'); // Setup class loader first -$phpbb_class_loader = new phpbb_class_loader('phpbb_', "{$phpbb_root_path}includes/", $phpEx); +$phpbb_class_loader = new phpbb_class_loader('phpbb_', "{$phpbb_root_path}phpbb/", $phpEx); $phpbb_class_loader->register(); // Set up container (must be done here because extensions table may not exist) @@ -217,7 +217,7 @@ $phpbb_extension_manager = $phpbb_container->get('ext.manager'); $finder = $phpbb_extension_manager->get_finder(); $migrations = $finder - ->core_path('includes/db/migration/data/') + ->core_path('phpbb/db/migration/data/') ->get_classes(); $migrator->set_migrations($migrations); diff --git a/phpBB/install/index.php b/phpBB/install/index.php index 84a2a023f8..45e5777e36 100644 --- a/phpBB/install/index.php +++ b/phpBB/install/index.php @@ -78,7 +78,7 @@ $phpbb_adm_relative_path = (isset($phpbb_adm_relative_path)) ? $phpbb_adm_relati $phpbb_admin_path = (defined('PHPBB_ADMIN_PATH')) ? PHPBB_ADMIN_PATH : $phpbb_root_path . $phpbb_adm_relative_path; // Include essential scripts -require($phpbb_root_path . 'includes/class_loader.' . $phpEx); +require($phpbb_root_path . 'phpbb/class_loader.' . $phpEx); require($phpbb_root_path . 'includes/functions.' . $phpEx); require($phpbb_root_path . 'includes/functions_container.' . $phpEx); @@ -90,7 +90,7 @@ include($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx); require($phpbb_root_path . 'includes/functions_install.' . $phpEx); // Setup class loader first -$phpbb_class_loader = new phpbb_class_loader('phpbb_', "{$phpbb_root_path}includes/", $phpEx); +$phpbb_class_loader = new phpbb_class_loader('phpbb_', "{$phpbb_root_path}phpbb/", $phpEx); $phpbb_class_loader->register(); $phpbb_class_loader_ext = new phpbb_class_loader('phpbb_ext_', "{$phpbb_root_path}ext/", $phpEx); $phpbb_class_loader_ext->register(); diff --git a/phpBB/install/install_install.php b/phpBB/install/install_install.php index 3d7b6f7c88..ea23c318e3 100644 --- a/phpBB/install/install_install.php +++ b/phpBB/install/install_install.php @@ -1435,7 +1435,7 @@ class install_install extends module $db->sql_return_on_error(true); include_once($phpbb_root_path . 'includes/constants.' . $phpEx); - include_once($phpbb_root_path . 'includes/search/fulltext_native.' . $phpEx); + include_once($phpbb_root_path . 'phpbb/search/fulltext_native.' . $phpEx); // We need to fill the config to let internal functions correctly work $config = new phpbb_config_db($db, new phpbb_cache_driver_null, CONFIG_TABLE); @@ -1888,7 +1888,7 @@ class install_install extends module /** * Populate migrations for the installation * - * This "installs" all migrations from (root path)/includes/db/migrations/data. + * This "installs" all migrations from (root path)/phpbb/db/migrations/data. * "installs" means it adds all migrations to the migrations table, but does not * perform any of the actions in the migrations. * @@ -1900,7 +1900,7 @@ class install_install extends module $finder = $extension_manager->get_finder(); $migrations = $finder - ->core_path('includes/db/migration/data/') + ->core_path('phpbb/db/migration/data/') ->get_classes(); $migrator->populate_migrations($migrations); } diff --git a/phpBB/includes/auth/auth.php b/phpBB/phpbb/auth/auth.php similarity index 100% rename from phpBB/includes/auth/auth.php rename to phpBB/phpbb/auth/auth.php diff --git a/phpBB/includes/auth/index.htm b/phpBB/phpbb/auth/index.htm similarity index 100% rename from phpBB/includes/auth/index.htm rename to phpBB/phpbb/auth/index.htm diff --git a/phpBB/includes/auth/provider/apache.php b/phpBB/phpbb/auth/provider/apache.php similarity index 100% rename from phpBB/includes/auth/provider/apache.php rename to phpBB/phpbb/auth/provider/apache.php diff --git a/phpBB/includes/auth/provider/base.php b/phpBB/phpbb/auth/provider/base.php similarity index 100% rename from phpBB/includes/auth/provider/base.php rename to phpBB/phpbb/auth/provider/base.php diff --git a/phpBB/includes/auth/provider/db.php b/phpBB/phpbb/auth/provider/db.php similarity index 100% rename from phpBB/includes/auth/provider/db.php rename to phpBB/phpbb/auth/provider/db.php diff --git a/phpBB/includes/auth/provider/index.htm b/phpBB/phpbb/auth/provider/index.htm similarity index 100% rename from phpBB/includes/auth/provider/index.htm rename to phpBB/phpbb/auth/provider/index.htm diff --git a/phpBB/includes/auth/provider/interface.php b/phpBB/phpbb/auth/provider/interface.php similarity index 100% rename from phpBB/includes/auth/provider/interface.php rename to phpBB/phpbb/auth/provider/interface.php diff --git a/phpBB/includes/auth/provider/ldap.php b/phpBB/phpbb/auth/provider/ldap.php similarity index 100% rename from phpBB/includes/auth/provider/ldap.php rename to phpBB/phpbb/auth/provider/ldap.php diff --git a/phpBB/includes/avatar/driver/driver.php b/phpBB/phpbb/avatar/driver/driver.php similarity index 100% rename from phpBB/includes/avatar/driver/driver.php rename to phpBB/phpbb/avatar/driver/driver.php diff --git a/phpBB/includes/avatar/driver/gravatar.php b/phpBB/phpbb/avatar/driver/gravatar.php similarity index 100% rename from phpBB/includes/avatar/driver/gravatar.php rename to phpBB/phpbb/avatar/driver/gravatar.php diff --git a/phpBB/includes/avatar/driver/interface.php b/phpBB/phpbb/avatar/driver/interface.php similarity index 100% rename from phpBB/includes/avatar/driver/interface.php rename to phpBB/phpbb/avatar/driver/interface.php diff --git a/phpBB/includes/avatar/driver/local.php b/phpBB/phpbb/avatar/driver/local.php similarity index 100% rename from phpBB/includes/avatar/driver/local.php rename to phpBB/phpbb/avatar/driver/local.php diff --git a/phpBB/includes/avatar/driver/remote.php b/phpBB/phpbb/avatar/driver/remote.php similarity index 100% rename from phpBB/includes/avatar/driver/remote.php rename to phpBB/phpbb/avatar/driver/remote.php diff --git a/phpBB/includes/avatar/driver/upload.php b/phpBB/phpbb/avatar/driver/upload.php similarity index 100% rename from phpBB/includes/avatar/driver/upload.php rename to phpBB/phpbb/avatar/driver/upload.php diff --git a/phpBB/includes/avatar/manager.php b/phpBB/phpbb/avatar/manager.php similarity index 100% rename from phpBB/includes/avatar/manager.php rename to phpBB/phpbb/avatar/manager.php diff --git a/phpBB/includes/cache/driver/apc.php b/phpBB/phpbb/cache/driver/apc.php similarity index 100% rename from phpBB/includes/cache/driver/apc.php rename to phpBB/phpbb/cache/driver/apc.php diff --git a/phpBB/includes/cache/driver/base.php b/phpBB/phpbb/cache/driver/base.php similarity index 100% rename from phpBB/includes/cache/driver/base.php rename to phpBB/phpbb/cache/driver/base.php diff --git a/phpBB/includes/cache/driver/eaccelerator.php b/phpBB/phpbb/cache/driver/eaccelerator.php similarity index 100% rename from phpBB/includes/cache/driver/eaccelerator.php rename to phpBB/phpbb/cache/driver/eaccelerator.php diff --git a/phpBB/includes/cache/driver/file.php b/phpBB/phpbb/cache/driver/file.php similarity index 100% rename from phpBB/includes/cache/driver/file.php rename to phpBB/phpbb/cache/driver/file.php diff --git a/phpBB/includes/cache/driver/interface.php b/phpBB/phpbb/cache/driver/interface.php similarity index 100% rename from phpBB/includes/cache/driver/interface.php rename to phpBB/phpbb/cache/driver/interface.php diff --git a/phpBB/includes/cache/driver/memcache.php b/phpBB/phpbb/cache/driver/memcache.php similarity index 100% rename from phpBB/includes/cache/driver/memcache.php rename to phpBB/phpbb/cache/driver/memcache.php diff --git a/phpBB/includes/cache/driver/memory.php b/phpBB/phpbb/cache/driver/memory.php similarity index 100% rename from phpBB/includes/cache/driver/memory.php rename to phpBB/phpbb/cache/driver/memory.php diff --git a/phpBB/includes/cache/driver/null.php b/phpBB/phpbb/cache/driver/null.php similarity index 100% rename from phpBB/includes/cache/driver/null.php rename to phpBB/phpbb/cache/driver/null.php diff --git a/phpBB/includes/cache/driver/redis.php b/phpBB/phpbb/cache/driver/redis.php similarity index 100% rename from phpBB/includes/cache/driver/redis.php rename to phpBB/phpbb/cache/driver/redis.php diff --git a/phpBB/includes/cache/driver/wincache.php b/phpBB/phpbb/cache/driver/wincache.php similarity index 100% rename from phpBB/includes/cache/driver/wincache.php rename to phpBB/phpbb/cache/driver/wincache.php diff --git a/phpBB/includes/cache/driver/xcache.php b/phpBB/phpbb/cache/driver/xcache.php similarity index 100% rename from phpBB/includes/cache/driver/xcache.php rename to phpBB/phpbb/cache/driver/xcache.php diff --git a/phpBB/includes/cache/service.php b/phpBB/phpbb/cache/service.php similarity index 100% rename from phpBB/includes/cache/service.php rename to phpBB/phpbb/cache/service.php diff --git a/phpBB/includes/class_loader.php b/phpBB/phpbb/class_loader.php similarity index 100% rename from phpBB/includes/class_loader.php rename to phpBB/phpbb/class_loader.php diff --git a/phpBB/includes/config/config.php b/phpBB/phpbb/config/config.php similarity index 100% rename from phpBB/includes/config/config.php rename to phpBB/phpbb/config/config.php diff --git a/phpBB/includes/config/db.php b/phpBB/phpbb/config/db.php similarity index 100% rename from phpBB/includes/config/db.php rename to phpBB/phpbb/config/db.php diff --git a/phpBB/includes/config/db_text.php b/phpBB/phpbb/config/db_text.php similarity index 100% rename from phpBB/includes/config/db_text.php rename to phpBB/phpbb/config/db_text.php diff --git a/phpBB/includes/content_visibility.php b/phpBB/phpbb/content_visibility.php similarity index 100% rename from phpBB/includes/content_visibility.php rename to phpBB/phpbb/content_visibility.php diff --git a/phpBB/includes/controller/exception.php b/phpBB/phpbb/controller/exception.php similarity index 100% rename from phpBB/includes/controller/exception.php rename to phpBB/phpbb/controller/exception.php diff --git a/phpBB/includes/controller/helper.php b/phpBB/phpbb/controller/helper.php similarity index 100% rename from phpBB/includes/controller/helper.php rename to phpBB/phpbb/controller/helper.php diff --git a/phpBB/includes/controller/provider.php b/phpBB/phpbb/controller/provider.php similarity index 100% rename from phpBB/includes/controller/provider.php rename to phpBB/phpbb/controller/provider.php diff --git a/phpBB/includes/controller/resolver.php b/phpBB/phpbb/controller/resolver.php similarity index 100% rename from phpBB/includes/controller/resolver.php rename to phpBB/phpbb/controller/resolver.php diff --git a/phpBB/includes/cron/manager.php b/phpBB/phpbb/cron/manager.php similarity index 100% rename from phpBB/includes/cron/manager.php rename to phpBB/phpbb/cron/manager.php diff --git a/phpBB/includes/cron/task/base.php b/phpBB/phpbb/cron/task/base.php similarity index 100% rename from phpBB/includes/cron/task/base.php rename to phpBB/phpbb/cron/task/base.php diff --git a/phpBB/includes/cron/task/core/prune_all_forums.php b/phpBB/phpbb/cron/task/core/prune_all_forums.php similarity index 100% rename from phpBB/includes/cron/task/core/prune_all_forums.php rename to phpBB/phpbb/cron/task/core/prune_all_forums.php diff --git a/phpBB/includes/cron/task/core/prune_forum.php b/phpBB/phpbb/cron/task/core/prune_forum.php similarity index 100% rename from phpBB/includes/cron/task/core/prune_forum.php rename to phpBB/phpbb/cron/task/core/prune_forum.php diff --git a/phpBB/includes/cron/task/core/queue.php b/phpBB/phpbb/cron/task/core/queue.php similarity index 100% rename from phpBB/includes/cron/task/core/queue.php rename to phpBB/phpbb/cron/task/core/queue.php diff --git a/phpBB/includes/cron/task/core/tidy_cache.php b/phpBB/phpbb/cron/task/core/tidy_cache.php similarity index 100% rename from phpBB/includes/cron/task/core/tidy_cache.php rename to phpBB/phpbb/cron/task/core/tidy_cache.php diff --git a/phpBB/includes/cron/task/core/tidy_database.php b/phpBB/phpbb/cron/task/core/tidy_database.php similarity index 100% rename from phpBB/includes/cron/task/core/tidy_database.php rename to phpBB/phpbb/cron/task/core/tidy_database.php diff --git a/phpBB/includes/cron/task/core/tidy_search.php b/phpBB/phpbb/cron/task/core/tidy_search.php similarity index 90% rename from phpBB/includes/cron/task/core/tidy_search.php rename to phpBB/phpbb/cron/task/core/tidy_search.php index 3ec25aa021..a3d5b7dbd2 100644 --- a/phpBB/includes/cron/task/core/tidy_search.php +++ b/phpBB/phpbb/cron/task/core/tidy_search.php @@ -61,11 +61,6 @@ class phpbb_cron_task_core_tidy_search extends phpbb_cron_task_base // Select the search method $search_type = basename($this->config['search_type']); - if (!class_exists($search_type)) - { - include($this->phpbb_root_path . "includes/search/$search_type." . $this->php_ext); - } - // We do some additional checks in the module to ensure it can actually be utilised $error = false; $search = new $search_type($error, $this->phpbb_root_path, $this->php_ext, $this->auth, $this->config, $this->db, $this->user); @@ -90,7 +85,7 @@ class phpbb_cron_task_core_tidy_search extends phpbb_cron_task_base // Select the search method $search_type = basename($this->config['search_type']); - return file_exists($this->phpbb_root_path . 'includes/search/' . $search_type . '.' . $this->php_ext); + return class_exists($search_type); } /** diff --git a/phpBB/includes/cron/task/core/tidy_sessions.php b/phpBB/phpbb/cron/task/core/tidy_sessions.php similarity index 100% rename from phpBB/includes/cron/task/core/tidy_sessions.php rename to phpBB/phpbb/cron/task/core/tidy_sessions.php diff --git a/phpBB/includes/cron/task/core/tidy_warnings.php b/phpBB/phpbb/cron/task/core/tidy_warnings.php similarity index 100% rename from phpBB/includes/cron/task/core/tidy_warnings.php rename to phpBB/phpbb/cron/task/core/tidy_warnings.php diff --git a/phpBB/includes/cron/task/parametrized.php b/phpBB/phpbb/cron/task/parametrized.php similarity index 100% rename from phpBB/includes/cron/task/parametrized.php rename to phpBB/phpbb/cron/task/parametrized.php diff --git a/phpBB/includes/cron/task/task.php b/phpBB/phpbb/cron/task/task.php similarity index 100% rename from phpBB/includes/cron/task/task.php rename to phpBB/phpbb/cron/task/task.php diff --git a/phpBB/includes/cron/task/wrapper.php b/phpBB/phpbb/cron/task/wrapper.php similarity index 100% rename from phpBB/includes/cron/task/wrapper.php rename to phpBB/phpbb/cron/task/wrapper.php diff --git a/phpBB/includes/datetime.php b/phpBB/phpbb/datetime.php similarity index 100% rename from phpBB/includes/datetime.php rename to phpBB/phpbb/datetime.php diff --git a/phpBB/includes/db/driver/driver.php b/phpBB/phpbb/db/driver/driver.php similarity index 100% rename from phpBB/includes/db/driver/driver.php rename to phpBB/phpbb/db/driver/driver.php diff --git a/phpBB/includes/db/driver/firebird.php b/phpBB/phpbb/db/driver/firebird.php similarity index 100% rename from phpBB/includes/db/driver/firebird.php rename to phpBB/phpbb/db/driver/firebird.php diff --git a/phpBB/includes/db/driver/mssql.php b/phpBB/phpbb/db/driver/mssql.php similarity index 100% rename from phpBB/includes/db/driver/mssql.php rename to phpBB/phpbb/db/driver/mssql.php diff --git a/phpBB/includes/db/driver/mssql_base.php b/phpBB/phpbb/db/driver/mssql_base.php similarity index 100% rename from phpBB/includes/db/driver/mssql_base.php rename to phpBB/phpbb/db/driver/mssql_base.php diff --git a/phpBB/includes/db/driver/mssql_odbc.php b/phpBB/phpbb/db/driver/mssql_odbc.php similarity index 100% rename from phpBB/includes/db/driver/mssql_odbc.php rename to phpBB/phpbb/db/driver/mssql_odbc.php diff --git a/phpBB/includes/db/driver/mssqlnative.php b/phpBB/phpbb/db/driver/mssqlnative.php similarity index 100% rename from phpBB/includes/db/driver/mssqlnative.php rename to phpBB/phpbb/db/driver/mssqlnative.php diff --git a/phpBB/includes/db/driver/mysql.php b/phpBB/phpbb/db/driver/mysql.php similarity index 100% rename from phpBB/includes/db/driver/mysql.php rename to phpBB/phpbb/db/driver/mysql.php diff --git a/phpBB/includes/db/driver/mysql_base.php b/phpBB/phpbb/db/driver/mysql_base.php similarity index 100% rename from phpBB/includes/db/driver/mysql_base.php rename to phpBB/phpbb/db/driver/mysql_base.php diff --git a/phpBB/includes/db/driver/mysqli.php b/phpBB/phpbb/db/driver/mysqli.php similarity index 100% rename from phpBB/includes/db/driver/mysqli.php rename to phpBB/phpbb/db/driver/mysqli.php diff --git a/phpBB/includes/db/driver/oracle.php b/phpBB/phpbb/db/driver/oracle.php similarity index 100% rename from phpBB/includes/db/driver/oracle.php rename to phpBB/phpbb/db/driver/oracle.php diff --git a/phpBB/includes/db/driver/postgres.php b/phpBB/phpbb/db/driver/postgres.php similarity index 100% rename from phpBB/includes/db/driver/postgres.php rename to phpBB/phpbb/db/driver/postgres.php diff --git a/phpBB/includes/db/driver/sqlite.php b/phpBB/phpbb/db/driver/sqlite.php similarity index 100% rename from phpBB/includes/db/driver/sqlite.php rename to phpBB/phpbb/db/driver/sqlite.php diff --git a/phpBB/includes/db/migration/data/30x/3_0_1.php b/phpBB/phpbb/db/migration/data/30x/3_0_1.php similarity index 100% rename from phpBB/includes/db/migration/data/30x/3_0_1.php rename to phpBB/phpbb/db/migration/data/30x/3_0_1.php diff --git a/phpBB/includes/db/migration/data/30x/3_0_10.php b/phpBB/phpbb/db/migration/data/30x/3_0_10.php similarity index 100% rename from phpBB/includes/db/migration/data/30x/3_0_10.php rename to phpBB/phpbb/db/migration/data/30x/3_0_10.php diff --git a/phpBB/includes/db/migration/data/30x/3_0_10_rc1.php b/phpBB/phpbb/db/migration/data/30x/3_0_10_rc1.php similarity index 100% rename from phpBB/includes/db/migration/data/30x/3_0_10_rc1.php rename to phpBB/phpbb/db/migration/data/30x/3_0_10_rc1.php diff --git a/phpBB/includes/db/migration/data/30x/3_0_10_rc2.php b/phpBB/phpbb/db/migration/data/30x/3_0_10_rc2.php similarity index 100% rename from phpBB/includes/db/migration/data/30x/3_0_10_rc2.php rename to phpBB/phpbb/db/migration/data/30x/3_0_10_rc2.php diff --git a/phpBB/includes/db/migration/data/30x/3_0_10_rc3.php b/phpBB/phpbb/db/migration/data/30x/3_0_10_rc3.php similarity index 100% rename from phpBB/includes/db/migration/data/30x/3_0_10_rc3.php rename to phpBB/phpbb/db/migration/data/30x/3_0_10_rc3.php diff --git a/phpBB/includes/db/migration/data/30x/3_0_11.php b/phpBB/phpbb/db/migration/data/30x/3_0_11.php similarity index 100% rename from phpBB/includes/db/migration/data/30x/3_0_11.php rename to phpBB/phpbb/db/migration/data/30x/3_0_11.php diff --git a/phpBB/includes/db/migration/data/30x/3_0_11_rc1.php b/phpBB/phpbb/db/migration/data/30x/3_0_11_rc1.php similarity index 100% rename from phpBB/includes/db/migration/data/30x/3_0_11_rc1.php rename to phpBB/phpbb/db/migration/data/30x/3_0_11_rc1.php diff --git a/phpBB/includes/db/migration/data/30x/3_0_11_rc2.php b/phpBB/phpbb/db/migration/data/30x/3_0_11_rc2.php similarity index 100% rename from phpBB/includes/db/migration/data/30x/3_0_11_rc2.php rename to phpBB/phpbb/db/migration/data/30x/3_0_11_rc2.php diff --git a/phpBB/includes/db/migration/data/30x/3_0_12_rc1.php b/phpBB/phpbb/db/migration/data/30x/3_0_12_rc1.php similarity index 100% rename from phpBB/includes/db/migration/data/30x/3_0_12_rc1.php rename to phpBB/phpbb/db/migration/data/30x/3_0_12_rc1.php diff --git a/phpBB/includes/db/migration/data/30x/3_0_1_rc1.php b/phpBB/phpbb/db/migration/data/30x/3_0_1_rc1.php similarity index 100% rename from phpBB/includes/db/migration/data/30x/3_0_1_rc1.php rename to phpBB/phpbb/db/migration/data/30x/3_0_1_rc1.php diff --git a/phpBB/includes/db/migration/data/30x/3_0_2.php b/phpBB/phpbb/db/migration/data/30x/3_0_2.php similarity index 100% rename from phpBB/includes/db/migration/data/30x/3_0_2.php rename to phpBB/phpbb/db/migration/data/30x/3_0_2.php diff --git a/phpBB/includes/db/migration/data/30x/3_0_2_rc1.php b/phpBB/phpbb/db/migration/data/30x/3_0_2_rc1.php similarity index 100% rename from phpBB/includes/db/migration/data/30x/3_0_2_rc1.php rename to phpBB/phpbb/db/migration/data/30x/3_0_2_rc1.php diff --git a/phpBB/includes/db/migration/data/30x/3_0_2_rc2.php b/phpBB/phpbb/db/migration/data/30x/3_0_2_rc2.php similarity index 100% rename from phpBB/includes/db/migration/data/30x/3_0_2_rc2.php rename to phpBB/phpbb/db/migration/data/30x/3_0_2_rc2.php diff --git a/phpBB/includes/db/migration/data/30x/3_0_3.php b/phpBB/phpbb/db/migration/data/30x/3_0_3.php similarity index 100% rename from phpBB/includes/db/migration/data/30x/3_0_3.php rename to phpBB/phpbb/db/migration/data/30x/3_0_3.php diff --git a/phpBB/includes/db/migration/data/30x/3_0_3_rc1.php b/phpBB/phpbb/db/migration/data/30x/3_0_3_rc1.php similarity index 100% rename from phpBB/includes/db/migration/data/30x/3_0_3_rc1.php rename to phpBB/phpbb/db/migration/data/30x/3_0_3_rc1.php diff --git a/phpBB/includes/db/migration/data/30x/3_0_4.php b/phpBB/phpbb/db/migration/data/30x/3_0_4.php similarity index 100% rename from phpBB/includes/db/migration/data/30x/3_0_4.php rename to phpBB/phpbb/db/migration/data/30x/3_0_4.php diff --git a/phpBB/includes/db/migration/data/30x/3_0_4_rc1.php b/phpBB/phpbb/db/migration/data/30x/3_0_4_rc1.php similarity index 100% rename from phpBB/includes/db/migration/data/30x/3_0_4_rc1.php rename to phpBB/phpbb/db/migration/data/30x/3_0_4_rc1.php diff --git a/phpBB/includes/db/migration/data/30x/3_0_5.php b/phpBB/phpbb/db/migration/data/30x/3_0_5.php similarity index 100% rename from phpBB/includes/db/migration/data/30x/3_0_5.php rename to phpBB/phpbb/db/migration/data/30x/3_0_5.php diff --git a/phpBB/includes/db/migration/data/30x/3_0_5_rc1.php b/phpBB/phpbb/db/migration/data/30x/3_0_5_rc1.php similarity index 100% rename from phpBB/includes/db/migration/data/30x/3_0_5_rc1.php rename to phpBB/phpbb/db/migration/data/30x/3_0_5_rc1.php diff --git a/phpBB/includes/db/migration/data/30x/3_0_5_rc1part2.php b/phpBB/phpbb/db/migration/data/30x/3_0_5_rc1part2.php similarity index 100% rename from phpBB/includes/db/migration/data/30x/3_0_5_rc1part2.php rename to phpBB/phpbb/db/migration/data/30x/3_0_5_rc1part2.php diff --git a/phpBB/includes/db/migration/data/30x/3_0_6.php b/phpBB/phpbb/db/migration/data/30x/3_0_6.php similarity index 100% rename from phpBB/includes/db/migration/data/30x/3_0_6.php rename to phpBB/phpbb/db/migration/data/30x/3_0_6.php diff --git a/phpBB/includes/db/migration/data/30x/3_0_6_rc1.php b/phpBB/phpbb/db/migration/data/30x/3_0_6_rc1.php similarity index 100% rename from phpBB/includes/db/migration/data/30x/3_0_6_rc1.php rename to phpBB/phpbb/db/migration/data/30x/3_0_6_rc1.php diff --git a/phpBB/includes/db/migration/data/30x/3_0_6_rc2.php b/phpBB/phpbb/db/migration/data/30x/3_0_6_rc2.php similarity index 100% rename from phpBB/includes/db/migration/data/30x/3_0_6_rc2.php rename to phpBB/phpbb/db/migration/data/30x/3_0_6_rc2.php diff --git a/phpBB/includes/db/migration/data/30x/3_0_6_rc3.php b/phpBB/phpbb/db/migration/data/30x/3_0_6_rc3.php similarity index 100% rename from phpBB/includes/db/migration/data/30x/3_0_6_rc3.php rename to phpBB/phpbb/db/migration/data/30x/3_0_6_rc3.php diff --git a/phpBB/includes/db/migration/data/30x/3_0_6_rc4.php b/phpBB/phpbb/db/migration/data/30x/3_0_6_rc4.php similarity index 100% rename from phpBB/includes/db/migration/data/30x/3_0_6_rc4.php rename to phpBB/phpbb/db/migration/data/30x/3_0_6_rc4.php diff --git a/phpBB/includes/db/migration/data/30x/3_0_7.php b/phpBB/phpbb/db/migration/data/30x/3_0_7.php similarity index 100% rename from phpBB/includes/db/migration/data/30x/3_0_7.php rename to phpBB/phpbb/db/migration/data/30x/3_0_7.php diff --git a/phpBB/includes/db/migration/data/30x/3_0_7_pl1.php b/phpBB/phpbb/db/migration/data/30x/3_0_7_pl1.php similarity index 100% rename from phpBB/includes/db/migration/data/30x/3_0_7_pl1.php rename to phpBB/phpbb/db/migration/data/30x/3_0_7_pl1.php diff --git a/phpBB/includes/db/migration/data/30x/3_0_7_rc1.php b/phpBB/phpbb/db/migration/data/30x/3_0_7_rc1.php similarity index 100% rename from phpBB/includes/db/migration/data/30x/3_0_7_rc1.php rename to phpBB/phpbb/db/migration/data/30x/3_0_7_rc1.php diff --git a/phpBB/includes/db/migration/data/30x/3_0_7_rc2.php b/phpBB/phpbb/db/migration/data/30x/3_0_7_rc2.php similarity index 100% rename from phpBB/includes/db/migration/data/30x/3_0_7_rc2.php rename to phpBB/phpbb/db/migration/data/30x/3_0_7_rc2.php diff --git a/phpBB/includes/db/migration/data/30x/3_0_8.php b/phpBB/phpbb/db/migration/data/30x/3_0_8.php similarity index 100% rename from phpBB/includes/db/migration/data/30x/3_0_8.php rename to phpBB/phpbb/db/migration/data/30x/3_0_8.php diff --git a/phpBB/includes/db/migration/data/30x/3_0_8_rc1.php b/phpBB/phpbb/db/migration/data/30x/3_0_8_rc1.php similarity index 100% rename from phpBB/includes/db/migration/data/30x/3_0_8_rc1.php rename to phpBB/phpbb/db/migration/data/30x/3_0_8_rc1.php diff --git a/phpBB/includes/db/migration/data/30x/3_0_9.php b/phpBB/phpbb/db/migration/data/30x/3_0_9.php similarity index 100% rename from phpBB/includes/db/migration/data/30x/3_0_9.php rename to phpBB/phpbb/db/migration/data/30x/3_0_9.php diff --git a/phpBB/includes/db/migration/data/30x/3_0_9_rc1.php b/phpBB/phpbb/db/migration/data/30x/3_0_9_rc1.php similarity index 100% rename from phpBB/includes/db/migration/data/30x/3_0_9_rc1.php rename to phpBB/phpbb/db/migration/data/30x/3_0_9_rc1.php diff --git a/phpBB/includes/db/migration/data/30x/3_0_9_rc2.php b/phpBB/phpbb/db/migration/data/30x/3_0_9_rc2.php similarity index 100% rename from phpBB/includes/db/migration/data/30x/3_0_9_rc2.php rename to phpBB/phpbb/db/migration/data/30x/3_0_9_rc2.php diff --git a/phpBB/includes/db/migration/data/30x/3_0_9_rc3.php b/phpBB/phpbb/db/migration/data/30x/3_0_9_rc3.php similarity index 100% rename from phpBB/includes/db/migration/data/30x/3_0_9_rc3.php rename to phpBB/phpbb/db/migration/data/30x/3_0_9_rc3.php diff --git a/phpBB/includes/db/migration/data/30x/3_0_9_rc4.php b/phpBB/phpbb/db/migration/data/30x/3_0_9_rc4.php similarity index 100% rename from phpBB/includes/db/migration/data/30x/3_0_9_rc4.php rename to phpBB/phpbb/db/migration/data/30x/3_0_9_rc4.php diff --git a/phpBB/includes/db/migration/data/30x/local_url_bbcode.php b/phpBB/phpbb/db/migration/data/30x/local_url_bbcode.php similarity index 100% rename from phpBB/includes/db/migration/data/30x/local_url_bbcode.php rename to phpBB/phpbb/db/migration/data/30x/local_url_bbcode.php diff --git a/phpBB/includes/db/migration/data/310/avatars.php b/phpBB/phpbb/db/migration/data/310/avatars.php similarity index 100% rename from phpBB/includes/db/migration/data/310/avatars.php rename to phpBB/phpbb/db/migration/data/310/avatars.php diff --git a/phpBB/includes/db/migration/data/310/boardindex.php b/phpBB/phpbb/db/migration/data/310/boardindex.php similarity index 100% rename from phpBB/includes/db/migration/data/310/boardindex.php rename to phpBB/phpbb/db/migration/data/310/boardindex.php diff --git a/phpBB/includes/db/migration/data/310/config_db_text.php b/phpBB/phpbb/db/migration/data/310/config_db_text.php similarity index 100% rename from phpBB/includes/db/migration/data/310/config_db_text.php rename to phpBB/phpbb/db/migration/data/310/config_db_text.php diff --git a/phpBB/includes/db/migration/data/310/dev.php b/phpBB/phpbb/db/migration/data/310/dev.php similarity index 100% rename from phpBB/includes/db/migration/data/310/dev.php rename to phpBB/phpbb/db/migration/data/310/dev.php diff --git a/phpBB/includes/db/migration/data/310/extensions.php b/phpBB/phpbb/db/migration/data/310/extensions.php similarity index 100% rename from phpBB/includes/db/migration/data/310/extensions.php rename to phpBB/phpbb/db/migration/data/310/extensions.php diff --git a/phpBB/includes/db/migration/data/310/forgot_password.php b/phpBB/phpbb/db/migration/data/310/forgot_password.php similarity index 100% rename from phpBB/includes/db/migration/data/310/forgot_password.php rename to phpBB/phpbb/db/migration/data/310/forgot_password.php diff --git a/phpBB/includes/db/migration/data/310/jquery_update.php b/phpBB/phpbb/db/migration/data/310/jquery_update.php similarity index 100% rename from phpBB/includes/db/migration/data/310/jquery_update.php rename to phpBB/phpbb/db/migration/data/310/jquery_update.php diff --git a/phpBB/includes/db/migration/data/310/notification_options_reconvert.php b/phpBB/phpbb/db/migration/data/310/notification_options_reconvert.php similarity index 100% rename from phpBB/includes/db/migration/data/310/notification_options_reconvert.php rename to phpBB/phpbb/db/migration/data/310/notification_options_reconvert.php diff --git a/phpBB/includes/db/migration/data/310/notifications.php b/phpBB/phpbb/db/migration/data/310/notifications.php similarity index 100% rename from phpBB/includes/db/migration/data/310/notifications.php rename to phpBB/phpbb/db/migration/data/310/notifications.php diff --git a/phpBB/includes/db/migration/data/310/notifications_schema_fix.php b/phpBB/phpbb/db/migration/data/310/notifications_schema_fix.php similarity index 100% rename from phpBB/includes/db/migration/data/310/notifications_schema_fix.php rename to phpBB/phpbb/db/migration/data/310/notifications_schema_fix.php diff --git a/phpBB/includes/db/migration/data/310/reported_posts_display.php b/phpBB/phpbb/db/migration/data/310/reported_posts_display.php similarity index 100% rename from phpBB/includes/db/migration/data/310/reported_posts_display.php rename to phpBB/phpbb/db/migration/data/310/reported_posts_display.php diff --git a/phpBB/includes/db/migration/data/310/signature_module_auth.php b/phpBB/phpbb/db/migration/data/310/signature_module_auth.php similarity index 100% rename from phpBB/includes/db/migration/data/310/signature_module_auth.php rename to phpBB/phpbb/db/migration/data/310/signature_module_auth.php diff --git a/phpBB/includes/db/migration/data/310/softdelete_p1.php b/phpBB/phpbb/db/migration/data/310/softdelete_p1.php similarity index 100% rename from phpBB/includes/db/migration/data/310/softdelete_p1.php rename to phpBB/phpbb/db/migration/data/310/softdelete_p1.php diff --git a/phpBB/includes/db/migration/data/310/softdelete_p2.php b/phpBB/phpbb/db/migration/data/310/softdelete_p2.php similarity index 100% rename from phpBB/includes/db/migration/data/310/softdelete_p2.php rename to phpBB/phpbb/db/migration/data/310/softdelete_p2.php diff --git a/phpBB/includes/db/migration/data/310/style_update_p1.php b/phpBB/phpbb/db/migration/data/310/style_update_p1.php similarity index 100% rename from phpBB/includes/db/migration/data/310/style_update_p1.php rename to phpBB/phpbb/db/migration/data/310/style_update_p1.php diff --git a/phpBB/includes/db/migration/data/310/style_update_p2.php b/phpBB/phpbb/db/migration/data/310/style_update_p2.php similarity index 100% rename from phpBB/includes/db/migration/data/310/style_update_p2.php rename to phpBB/phpbb/db/migration/data/310/style_update_p2.php diff --git a/phpBB/includes/db/migration/data/310/teampage.php b/phpBB/phpbb/db/migration/data/310/teampage.php similarity index 100% rename from phpBB/includes/db/migration/data/310/teampage.php rename to phpBB/phpbb/db/migration/data/310/teampage.php diff --git a/phpBB/includes/db/migration/data/310/timezone.php b/phpBB/phpbb/db/migration/data/310/timezone.php similarity index 100% rename from phpBB/includes/db/migration/data/310/timezone.php rename to phpBB/phpbb/db/migration/data/310/timezone.php diff --git a/phpBB/includes/db/migration/data/310/timezone_p2.php b/phpBB/phpbb/db/migration/data/310/timezone_p2.php similarity index 100% rename from phpBB/includes/db/migration/data/310/timezone_p2.php rename to phpBB/phpbb/db/migration/data/310/timezone_p2.php diff --git a/phpBB/includes/db/migration/exception.php b/phpBB/phpbb/db/migration/exception.php similarity index 100% rename from phpBB/includes/db/migration/exception.php rename to phpBB/phpbb/db/migration/exception.php diff --git a/phpBB/includes/db/migration/migration.php b/phpBB/phpbb/db/migration/migration.php similarity index 100% rename from phpBB/includes/db/migration/migration.php rename to phpBB/phpbb/db/migration/migration.php diff --git a/phpBB/includes/db/migration/tool/config.php b/phpBB/phpbb/db/migration/tool/config.php similarity index 100% rename from phpBB/includes/db/migration/tool/config.php rename to phpBB/phpbb/db/migration/tool/config.php diff --git a/phpBB/includes/db/migration/tool/interface.php b/phpBB/phpbb/db/migration/tool/interface.php similarity index 100% rename from phpBB/includes/db/migration/tool/interface.php rename to phpBB/phpbb/db/migration/tool/interface.php diff --git a/phpBB/includes/db/migration/tool/module.php b/phpBB/phpbb/db/migration/tool/module.php similarity index 100% rename from phpBB/includes/db/migration/tool/module.php rename to phpBB/phpbb/db/migration/tool/module.php diff --git a/phpBB/includes/db/migration/tool/permission.php b/phpBB/phpbb/db/migration/tool/permission.php similarity index 100% rename from phpBB/includes/db/migration/tool/permission.php rename to phpBB/phpbb/db/migration/tool/permission.php diff --git a/phpBB/includes/db/migrator.php b/phpBB/phpbb/db/migrator.php similarity index 100% rename from phpBB/includes/db/migrator.php rename to phpBB/phpbb/db/migrator.php diff --git a/phpBB/includes/db/sql_insert_buffer.php b/phpBB/phpbb/db/sql_insert_buffer.php similarity index 100% rename from phpBB/includes/db/sql_insert_buffer.php rename to phpBB/phpbb/db/sql_insert_buffer.php diff --git a/phpBB/includes/di/extension/config.php b/phpBB/phpbb/di/extension/config.php similarity index 100% rename from phpBB/includes/di/extension/config.php rename to phpBB/phpbb/di/extension/config.php diff --git a/phpBB/includes/di/extension/core.php b/phpBB/phpbb/di/extension/core.php similarity index 100% rename from phpBB/includes/di/extension/core.php rename to phpBB/phpbb/di/extension/core.php diff --git a/phpBB/includes/di/extension/ext.php b/phpBB/phpbb/di/extension/ext.php similarity index 100% rename from phpBB/includes/di/extension/ext.php rename to phpBB/phpbb/di/extension/ext.php diff --git a/phpBB/includes/di/pass/collection_pass.php b/phpBB/phpbb/di/pass/collection_pass.php similarity index 100% rename from phpBB/includes/di/pass/collection_pass.php rename to phpBB/phpbb/di/pass/collection_pass.php diff --git a/phpBB/includes/di/pass/kernel_pass.php b/phpBB/phpbb/di/pass/kernel_pass.php similarity index 100% rename from phpBB/includes/di/pass/kernel_pass.php rename to phpBB/phpbb/di/pass/kernel_pass.php diff --git a/phpBB/includes/di/service_collection.php b/phpBB/phpbb/di/service_collection.php similarity index 100% rename from phpBB/includes/di/service_collection.php rename to phpBB/phpbb/di/service_collection.php diff --git a/phpBB/includes/error_collector.php b/phpBB/phpbb/error_collector.php similarity index 100% rename from phpBB/includes/error_collector.php rename to phpBB/phpbb/error_collector.php diff --git a/phpBB/includes/event/data.php b/phpBB/phpbb/event/data.php similarity index 100% rename from phpBB/includes/event/data.php rename to phpBB/phpbb/event/data.php diff --git a/phpBB/includes/event/dispatcher.php b/phpBB/phpbb/event/dispatcher.php similarity index 100% rename from phpBB/includes/event/dispatcher.php rename to phpBB/phpbb/event/dispatcher.php diff --git a/phpBB/includes/event/extension_subscriber_loader.php b/phpBB/phpbb/event/extension_subscriber_loader.php similarity index 100% rename from phpBB/includes/event/extension_subscriber_loader.php rename to phpBB/phpbb/event/extension_subscriber_loader.php diff --git a/phpBB/includes/event/kernel_exception_subscriber.php b/phpBB/phpbb/event/kernel_exception_subscriber.php similarity index 100% rename from phpBB/includes/event/kernel_exception_subscriber.php rename to phpBB/phpbb/event/kernel_exception_subscriber.php diff --git a/phpBB/includes/event/kernel_request_subscriber.php b/phpBB/phpbb/event/kernel_request_subscriber.php similarity index 100% rename from phpBB/includes/event/kernel_request_subscriber.php rename to phpBB/phpbb/event/kernel_request_subscriber.php diff --git a/phpBB/includes/event/kernel_terminate_subscriber.php b/phpBB/phpbb/event/kernel_terminate_subscriber.php similarity index 100% rename from phpBB/includes/event/kernel_terminate_subscriber.php rename to phpBB/phpbb/event/kernel_terminate_subscriber.php diff --git a/phpBB/includes/extension/base.php b/phpBB/phpbb/extension/base.php similarity index 100% rename from phpBB/includes/extension/base.php rename to phpBB/phpbb/extension/base.php diff --git a/phpBB/includes/extension/exception.php b/phpBB/phpbb/extension/exception.php similarity index 100% rename from phpBB/includes/extension/exception.php rename to phpBB/phpbb/extension/exception.php diff --git a/phpBB/includes/extension/finder.php b/phpBB/phpbb/extension/finder.php similarity index 99% rename from phpBB/includes/extension/finder.php rename to phpBB/phpbb/extension/finder.php index 49bb2a514f..155a41cda5 100644 --- a/phpBB/includes/extension/finder.php +++ b/phpBB/phpbb/extension/finder.php @@ -275,7 +275,7 @@ class phpbb_extension_finder $classes = array(); foreach ($files as $file => $ext_name) { - $file = preg_replace('#^includes/#', '', $file); + $file = preg_replace('#^(phpbb|includes)/#', '', $file); $classes[] = 'phpbb_' . str_replace('/', '_', substr($file, 0, -strlen('.' . $this->php_ext))); } @@ -377,7 +377,7 @@ class phpbb_extension_finder return $files; } - + /** * Finds all file system entries matching the configured options for one * specific extension diff --git a/phpBB/includes/extension/interface.php b/phpBB/phpbb/extension/interface.php similarity index 100% rename from phpBB/includes/extension/interface.php rename to phpBB/phpbb/extension/interface.php diff --git a/phpBB/includes/extension/manager.php b/phpBB/phpbb/extension/manager.php similarity index 100% rename from phpBB/includes/extension/manager.php rename to phpBB/phpbb/extension/manager.php diff --git a/phpBB/includes/extension/metadata_manager.php b/phpBB/phpbb/extension/metadata_manager.php similarity index 100% rename from phpBB/includes/extension/metadata_manager.php rename to phpBB/phpbb/extension/metadata_manager.php diff --git a/phpBB/includes/extension/provider.php b/phpBB/phpbb/extension/provider.php similarity index 100% rename from phpBB/includes/extension/provider.php rename to phpBB/phpbb/extension/provider.php diff --git a/phpBB/includes/feed/base.php b/phpBB/phpbb/feed/base.php similarity index 100% rename from phpBB/includes/feed/base.php rename to phpBB/phpbb/feed/base.php diff --git a/phpBB/includes/feed/factory.php b/phpBB/phpbb/feed/factory.php similarity index 100% rename from phpBB/includes/feed/factory.php rename to phpBB/phpbb/feed/factory.php diff --git a/phpBB/includes/feed/forum.php b/phpBB/phpbb/feed/forum.php similarity index 100% rename from phpBB/includes/feed/forum.php rename to phpBB/phpbb/feed/forum.php diff --git a/phpBB/includes/feed/forums.php b/phpBB/phpbb/feed/forums.php similarity index 100% rename from phpBB/includes/feed/forums.php rename to phpBB/phpbb/feed/forums.php diff --git a/phpBB/includes/feed/helper.php b/phpBB/phpbb/feed/helper.php similarity index 100% rename from phpBB/includes/feed/helper.php rename to phpBB/phpbb/feed/helper.php diff --git a/phpBB/includes/feed/news.php b/phpBB/phpbb/feed/news.php similarity index 100% rename from phpBB/includes/feed/news.php rename to phpBB/phpbb/feed/news.php diff --git a/phpBB/includes/feed/overall.php b/phpBB/phpbb/feed/overall.php similarity index 100% rename from phpBB/includes/feed/overall.php rename to phpBB/phpbb/feed/overall.php diff --git a/phpBB/includes/feed/post_base.php b/phpBB/phpbb/feed/post_base.php similarity index 100% rename from phpBB/includes/feed/post_base.php rename to phpBB/phpbb/feed/post_base.php diff --git a/phpBB/includes/feed/topic.php b/phpBB/phpbb/feed/topic.php similarity index 100% rename from phpBB/includes/feed/topic.php rename to phpBB/phpbb/feed/topic.php diff --git a/phpBB/includes/feed/topic_base.php b/phpBB/phpbb/feed/topic_base.php similarity index 100% rename from phpBB/includes/feed/topic_base.php rename to phpBB/phpbb/feed/topic_base.php diff --git a/phpBB/includes/feed/topics.php b/phpBB/phpbb/feed/topics.php similarity index 100% rename from phpBB/includes/feed/topics.php rename to phpBB/phpbb/feed/topics.php diff --git a/phpBB/includes/feed/topics_active.php b/phpBB/phpbb/feed/topics_active.php similarity index 100% rename from phpBB/includes/feed/topics_active.php rename to phpBB/phpbb/feed/topics_active.php diff --git a/phpBB/includes/filesystem.php b/phpBB/phpbb/filesystem.php similarity index 100% rename from phpBB/includes/filesystem.php rename to phpBB/phpbb/filesystem.php diff --git a/phpBB/includes/groupposition/exception.php b/phpBB/phpbb/groupposition/exception.php similarity index 100% rename from phpBB/includes/groupposition/exception.php rename to phpBB/phpbb/groupposition/exception.php diff --git a/phpBB/includes/groupposition/interface.php b/phpBB/phpbb/groupposition/interface.php similarity index 100% rename from phpBB/includes/groupposition/interface.php rename to phpBB/phpbb/groupposition/interface.php diff --git a/phpBB/includes/groupposition/legend.php b/phpBB/phpbb/groupposition/legend.php similarity index 100% rename from phpBB/includes/groupposition/legend.php rename to phpBB/phpbb/groupposition/legend.php diff --git a/phpBB/includes/groupposition/teampage.php b/phpBB/phpbb/groupposition/teampage.php similarity index 100% rename from phpBB/includes/groupposition/teampage.php rename to phpBB/phpbb/groupposition/teampage.php diff --git a/phpBB/includes/hook/finder.php b/phpBB/phpbb/hook/finder.php similarity index 100% rename from phpBB/includes/hook/finder.php rename to phpBB/phpbb/hook/finder.php diff --git a/phpBB/includes/json_response.php b/phpBB/phpbb/json_response.php similarity index 100% rename from phpBB/includes/json_response.php rename to phpBB/phpbb/json_response.php diff --git a/phpBB/includes/lock/db.php b/phpBB/phpbb/lock/db.php similarity index 100% rename from phpBB/includes/lock/db.php rename to phpBB/phpbb/lock/db.php diff --git a/phpBB/includes/lock/flock.php b/phpBB/phpbb/lock/flock.php similarity index 100% rename from phpBB/includes/lock/flock.php rename to phpBB/phpbb/lock/flock.php diff --git a/phpBB/includes/log/interface.php b/phpBB/phpbb/log/interface.php similarity index 100% rename from phpBB/includes/log/interface.php rename to phpBB/phpbb/log/interface.php diff --git a/phpBB/includes/log/log.php b/phpBB/phpbb/log/log.php similarity index 100% rename from phpBB/includes/log/log.php rename to phpBB/phpbb/log/log.php diff --git a/phpBB/includes/notification/exception.php b/phpBB/phpbb/notification/exception.php similarity index 100% rename from phpBB/includes/notification/exception.php rename to phpBB/phpbb/notification/exception.php diff --git a/phpBB/includes/notification/manager.php b/phpBB/phpbb/notification/manager.php similarity index 100% rename from phpBB/includes/notification/manager.php rename to phpBB/phpbb/notification/manager.php diff --git a/phpBB/includes/notification/method/base.php b/phpBB/phpbb/notification/method/base.php similarity index 100% rename from phpBB/includes/notification/method/base.php rename to phpBB/phpbb/notification/method/base.php diff --git a/phpBB/includes/notification/method/email.php b/phpBB/phpbb/notification/method/email.php similarity index 100% rename from phpBB/includes/notification/method/email.php rename to phpBB/phpbb/notification/method/email.php diff --git a/phpBB/includes/notification/method/interface.php b/phpBB/phpbb/notification/method/interface.php similarity index 100% rename from phpBB/includes/notification/method/interface.php rename to phpBB/phpbb/notification/method/interface.php diff --git a/phpBB/includes/notification/method/jabber.php b/phpBB/phpbb/notification/method/jabber.php similarity index 100% rename from phpBB/includes/notification/method/jabber.php rename to phpBB/phpbb/notification/method/jabber.php diff --git a/phpBB/includes/notification/method/messenger_base.php b/phpBB/phpbb/notification/method/messenger_base.php similarity index 100% rename from phpBB/includes/notification/method/messenger_base.php rename to phpBB/phpbb/notification/method/messenger_base.php diff --git a/phpBB/includes/notification/type/approve_post.php b/phpBB/phpbb/notification/type/approve_post.php similarity index 100% rename from phpBB/includes/notification/type/approve_post.php rename to phpBB/phpbb/notification/type/approve_post.php diff --git a/phpBB/includes/notification/type/approve_topic.php b/phpBB/phpbb/notification/type/approve_topic.php similarity index 100% rename from phpBB/includes/notification/type/approve_topic.php rename to phpBB/phpbb/notification/type/approve_topic.php diff --git a/phpBB/includes/notification/type/base.php b/phpBB/phpbb/notification/type/base.php similarity index 100% rename from phpBB/includes/notification/type/base.php rename to phpBB/phpbb/notification/type/base.php diff --git a/phpBB/includes/notification/type/bookmark.php b/phpBB/phpbb/notification/type/bookmark.php similarity index 100% rename from phpBB/includes/notification/type/bookmark.php rename to phpBB/phpbb/notification/type/bookmark.php diff --git a/phpBB/includes/notification/type/disapprove_post.php b/phpBB/phpbb/notification/type/disapprove_post.php similarity index 100% rename from phpBB/includes/notification/type/disapprove_post.php rename to phpBB/phpbb/notification/type/disapprove_post.php diff --git a/phpBB/includes/notification/type/disapprove_topic.php b/phpBB/phpbb/notification/type/disapprove_topic.php similarity index 100% rename from phpBB/includes/notification/type/disapprove_topic.php rename to phpBB/phpbb/notification/type/disapprove_topic.php diff --git a/phpBB/includes/notification/type/interface.php b/phpBB/phpbb/notification/type/interface.php similarity index 100% rename from phpBB/includes/notification/type/interface.php rename to phpBB/phpbb/notification/type/interface.php diff --git a/phpBB/includes/notification/type/pm.php b/phpBB/phpbb/notification/type/pm.php similarity index 100% rename from phpBB/includes/notification/type/pm.php rename to phpBB/phpbb/notification/type/pm.php diff --git a/phpBB/includes/notification/type/post.php b/phpBB/phpbb/notification/type/post.php similarity index 100% rename from phpBB/includes/notification/type/post.php rename to phpBB/phpbb/notification/type/post.php diff --git a/phpBB/includes/notification/type/post_in_queue.php b/phpBB/phpbb/notification/type/post_in_queue.php similarity index 100% rename from phpBB/includes/notification/type/post_in_queue.php rename to phpBB/phpbb/notification/type/post_in_queue.php diff --git a/phpBB/includes/notification/type/quote.php b/phpBB/phpbb/notification/type/quote.php similarity index 100% rename from phpBB/includes/notification/type/quote.php rename to phpBB/phpbb/notification/type/quote.php diff --git a/phpBB/includes/notification/type/report_pm.php b/phpBB/phpbb/notification/type/report_pm.php similarity index 100% rename from phpBB/includes/notification/type/report_pm.php rename to phpBB/phpbb/notification/type/report_pm.php diff --git a/phpBB/includes/notification/type/report_pm_closed.php b/phpBB/phpbb/notification/type/report_pm_closed.php similarity index 100% rename from phpBB/includes/notification/type/report_pm_closed.php rename to phpBB/phpbb/notification/type/report_pm_closed.php diff --git a/phpBB/includes/notification/type/report_post.php b/phpBB/phpbb/notification/type/report_post.php similarity index 100% rename from phpBB/includes/notification/type/report_post.php rename to phpBB/phpbb/notification/type/report_post.php diff --git a/phpBB/includes/notification/type/report_post_closed.php b/phpBB/phpbb/notification/type/report_post_closed.php similarity index 100% rename from phpBB/includes/notification/type/report_post_closed.php rename to phpBB/phpbb/notification/type/report_post_closed.php diff --git a/phpBB/includes/notification/type/topic.php b/phpBB/phpbb/notification/type/topic.php similarity index 100% rename from phpBB/includes/notification/type/topic.php rename to phpBB/phpbb/notification/type/topic.php diff --git a/phpBB/includes/notification/type/topic_in_queue.php b/phpBB/phpbb/notification/type/topic_in_queue.php similarity index 100% rename from phpBB/includes/notification/type/topic_in_queue.php rename to phpBB/phpbb/notification/type/topic_in_queue.php diff --git a/phpBB/includes/php/ini.php b/phpBB/phpbb/php/ini.php similarity index 100% rename from phpBB/includes/php/ini.php rename to phpBB/phpbb/php/ini.php diff --git a/phpBB/includes/request/deactivated_super_global.php b/phpBB/phpbb/request/deactivated_super_global.php similarity index 100% rename from phpBB/includes/request/deactivated_super_global.php rename to phpBB/phpbb/request/deactivated_super_global.php diff --git a/phpBB/includes/request/interface.php b/phpBB/phpbb/request/interface.php similarity index 100% rename from phpBB/includes/request/interface.php rename to phpBB/phpbb/request/interface.php diff --git a/phpBB/includes/request/request.php b/phpBB/phpbb/request/request.php similarity index 100% rename from phpBB/includes/request/request.php rename to phpBB/phpbb/request/request.php diff --git a/phpBB/includes/request/type_cast_helper.php b/phpBB/phpbb/request/type_cast_helper.php similarity index 100% rename from phpBB/includes/request/type_cast_helper.php rename to phpBB/phpbb/request/type_cast_helper.php diff --git a/phpBB/includes/request/type_cast_helper_interface.php b/phpBB/phpbb/request/type_cast_helper_interface.php similarity index 100% rename from phpBB/includes/request/type_cast_helper_interface.php rename to phpBB/phpbb/request/type_cast_helper_interface.php diff --git a/phpBB/includes/search/base.php b/phpBB/phpbb/search/base.php similarity index 100% rename from phpBB/includes/search/base.php rename to phpBB/phpbb/search/base.php diff --git a/phpBB/includes/search/fulltext_mysql.php b/phpBB/phpbb/search/fulltext_mysql.php similarity index 100% rename from phpBB/includes/search/fulltext_mysql.php rename to phpBB/phpbb/search/fulltext_mysql.php diff --git a/phpBB/includes/search/fulltext_native.php b/phpBB/phpbb/search/fulltext_native.php similarity index 100% rename from phpBB/includes/search/fulltext_native.php rename to phpBB/phpbb/search/fulltext_native.php diff --git a/phpBB/includes/search/fulltext_postgres.php b/phpBB/phpbb/search/fulltext_postgres.php similarity index 100% rename from phpBB/includes/search/fulltext_postgres.php rename to phpBB/phpbb/search/fulltext_postgres.php diff --git a/phpBB/includes/search/fulltext_sphinx.php b/phpBB/phpbb/search/fulltext_sphinx.php similarity index 100% rename from phpBB/includes/search/fulltext_sphinx.php rename to phpBB/phpbb/search/fulltext_sphinx.php diff --git a/phpBB/includes/search/index.htm b/phpBB/phpbb/search/index.htm similarity index 100% rename from phpBB/includes/search/index.htm rename to phpBB/phpbb/search/index.htm diff --git a/phpBB/includes/search/sphinx/config.php b/phpBB/phpbb/search/sphinx/config.php similarity index 100% rename from phpBB/includes/search/sphinx/config.php rename to phpBB/phpbb/search/sphinx/config.php diff --git a/phpBB/includes/search/sphinx/config_comment.php b/phpBB/phpbb/search/sphinx/config_comment.php similarity index 100% rename from phpBB/includes/search/sphinx/config_comment.php rename to phpBB/phpbb/search/sphinx/config_comment.php diff --git a/phpBB/includes/search/sphinx/config_section.php b/phpBB/phpbb/search/sphinx/config_section.php similarity index 100% rename from phpBB/includes/search/sphinx/config_section.php rename to phpBB/phpbb/search/sphinx/config_section.php diff --git a/phpBB/includes/search/sphinx/config_variable.php b/phpBB/phpbb/search/sphinx/config_variable.php similarity index 100% rename from phpBB/includes/search/sphinx/config_variable.php rename to phpBB/phpbb/search/sphinx/config_variable.php diff --git a/phpBB/includes/session.php b/phpBB/phpbb/session.php similarity index 100% rename from phpBB/includes/session.php rename to phpBB/phpbb/session.php diff --git a/phpBB/includes/style/extension_path_provider.php b/phpBB/phpbb/style/extension_path_provider.php similarity index 100% rename from phpBB/includes/style/extension_path_provider.php rename to phpBB/phpbb/style/extension_path_provider.php diff --git a/phpBB/includes/style/path_provider.php b/phpBB/phpbb/style/path_provider.php similarity index 100% rename from phpBB/includes/style/path_provider.php rename to phpBB/phpbb/style/path_provider.php diff --git a/phpBB/includes/style/path_provider_interface.php b/phpBB/phpbb/style/path_provider_interface.php similarity index 100% rename from phpBB/includes/style/path_provider_interface.php rename to phpBB/phpbb/style/path_provider_interface.php diff --git a/phpBB/includes/style/resource_locator.php b/phpBB/phpbb/style/resource_locator.php similarity index 100% rename from phpBB/includes/style/resource_locator.php rename to phpBB/phpbb/style/resource_locator.php diff --git a/phpBB/includes/style/style.php b/phpBB/phpbb/style/style.php similarity index 100% rename from phpBB/includes/style/style.php rename to phpBB/phpbb/style/style.php diff --git a/phpBB/includes/template/asset.php b/phpBB/phpbb/template/asset.php similarity index 100% rename from phpBB/includes/template/asset.php rename to phpBB/phpbb/template/asset.php diff --git a/phpBB/includes/template/context.php b/phpBB/phpbb/template/context.php similarity index 100% rename from phpBB/includes/template/context.php rename to phpBB/phpbb/template/context.php diff --git a/phpBB/includes/template/locator.php b/phpBB/phpbb/template/locator.php similarity index 100% rename from phpBB/includes/template/locator.php rename to phpBB/phpbb/template/locator.php diff --git a/phpBB/includes/template/template.php b/phpBB/phpbb/template/template.php similarity index 100% rename from phpBB/includes/template/template.php rename to phpBB/phpbb/template/template.php diff --git a/phpBB/includes/template/twig/definition.php b/phpBB/phpbb/template/twig/definition.php similarity index 100% rename from phpBB/includes/template/twig/definition.php rename to phpBB/phpbb/template/twig/definition.php diff --git a/phpBB/includes/template/twig/environment.php b/phpBB/phpbb/template/twig/environment.php similarity index 100% rename from phpBB/includes/template/twig/environment.php rename to phpBB/phpbb/template/twig/environment.php diff --git a/phpBB/includes/template/twig/extension.php b/phpBB/phpbb/template/twig/extension.php similarity index 100% rename from phpBB/includes/template/twig/extension.php rename to phpBB/phpbb/template/twig/extension.php diff --git a/phpBB/includes/template/twig/lexer.php b/phpBB/phpbb/template/twig/lexer.php similarity index 100% rename from phpBB/includes/template/twig/lexer.php rename to phpBB/phpbb/template/twig/lexer.php diff --git a/phpBB/includes/template/twig/node/define.php b/phpBB/phpbb/template/twig/node/define.php similarity index 100% rename from phpBB/includes/template/twig/node/define.php rename to phpBB/phpbb/template/twig/node/define.php diff --git a/phpBB/includes/template/twig/node/event.php b/phpBB/phpbb/template/twig/node/event.php similarity index 100% rename from phpBB/includes/template/twig/node/event.php rename to phpBB/phpbb/template/twig/node/event.php diff --git a/phpBB/includes/template/twig/node/expression/binary/equalequal.php b/phpBB/phpbb/template/twig/node/expression/binary/equalequal.php similarity index 100% rename from phpBB/includes/template/twig/node/expression/binary/equalequal.php rename to phpBB/phpbb/template/twig/node/expression/binary/equalequal.php diff --git a/phpBB/includes/template/twig/node/expression/binary/notequalequal.php b/phpBB/phpbb/template/twig/node/expression/binary/notequalequal.php similarity index 100% rename from phpBB/includes/template/twig/node/expression/binary/notequalequal.php rename to phpBB/phpbb/template/twig/node/expression/binary/notequalequal.php diff --git a/phpBB/includes/template/twig/node/include.php b/phpBB/phpbb/template/twig/node/include.php similarity index 100% rename from phpBB/includes/template/twig/node/include.php rename to phpBB/phpbb/template/twig/node/include.php diff --git a/phpBB/includes/template/twig/node/includeasset.php b/phpBB/phpbb/template/twig/node/includeasset.php similarity index 100% rename from phpBB/includes/template/twig/node/includeasset.php rename to phpBB/phpbb/template/twig/node/includeasset.php diff --git a/phpBB/includes/template/twig/node/includecss.php b/phpBB/phpbb/template/twig/node/includecss.php similarity index 100% rename from phpBB/includes/template/twig/node/includecss.php rename to phpBB/phpbb/template/twig/node/includecss.php diff --git a/phpBB/includes/template/twig/node/includejs.php b/phpBB/phpbb/template/twig/node/includejs.php similarity index 100% rename from phpBB/includes/template/twig/node/includejs.php rename to phpBB/phpbb/template/twig/node/includejs.php diff --git a/phpBB/includes/template/twig/node/includephp.php b/phpBB/phpbb/template/twig/node/includephp.php similarity index 100% rename from phpBB/includes/template/twig/node/includephp.php rename to phpBB/phpbb/template/twig/node/includephp.php diff --git a/phpBB/includes/template/twig/node/php.php b/phpBB/phpbb/template/twig/node/php.php similarity index 100% rename from phpBB/includes/template/twig/node/php.php rename to phpBB/phpbb/template/twig/node/php.php diff --git a/phpBB/includes/template/twig/tokenparser/define.php b/phpBB/phpbb/template/twig/tokenparser/define.php similarity index 100% rename from phpBB/includes/template/twig/tokenparser/define.php rename to phpBB/phpbb/template/twig/tokenparser/define.php diff --git a/phpBB/includes/template/twig/tokenparser/event.php b/phpBB/phpbb/template/twig/tokenparser/event.php similarity index 100% rename from phpBB/includes/template/twig/tokenparser/event.php rename to phpBB/phpbb/template/twig/tokenparser/event.php diff --git a/phpBB/includes/template/twig/tokenparser/include.php b/phpBB/phpbb/template/twig/tokenparser/include.php similarity index 100% rename from phpBB/includes/template/twig/tokenparser/include.php rename to phpBB/phpbb/template/twig/tokenparser/include.php diff --git a/phpBB/includes/template/twig/tokenparser/includecss.php b/phpBB/phpbb/template/twig/tokenparser/includecss.php similarity index 100% rename from phpBB/includes/template/twig/tokenparser/includecss.php rename to phpBB/phpbb/template/twig/tokenparser/includecss.php diff --git a/phpBB/includes/template/twig/tokenparser/includejs.php b/phpBB/phpbb/template/twig/tokenparser/includejs.php similarity index 100% rename from phpBB/includes/template/twig/tokenparser/includejs.php rename to phpBB/phpbb/template/twig/tokenparser/includejs.php diff --git a/phpBB/includes/template/twig/tokenparser/includephp.php b/phpBB/phpbb/template/twig/tokenparser/includephp.php similarity index 100% rename from phpBB/includes/template/twig/tokenparser/includephp.php rename to phpBB/phpbb/template/twig/tokenparser/includephp.php diff --git a/phpBB/includes/template/twig/tokenparser/php.php b/phpBB/phpbb/template/twig/tokenparser/php.php similarity index 100% rename from phpBB/includes/template/twig/tokenparser/php.php rename to phpBB/phpbb/template/twig/tokenparser/php.php diff --git a/phpBB/includes/template/twig/twig.php b/phpBB/phpbb/template/twig/twig.php similarity index 100% rename from phpBB/includes/template/twig/twig.php rename to phpBB/phpbb/template/twig/twig.php diff --git a/phpBB/includes/tree/interface.php b/phpBB/phpbb/tree/interface.php similarity index 100% rename from phpBB/includes/tree/interface.php rename to phpBB/phpbb/tree/interface.php diff --git a/phpBB/includes/tree/nestedset.php b/phpBB/phpbb/tree/nestedset.php similarity index 100% rename from phpBB/includes/tree/nestedset.php rename to phpBB/phpbb/tree/nestedset.php diff --git a/phpBB/includes/tree/nestedset_forum.php b/phpBB/phpbb/tree/nestedset_forum.php similarity index 100% rename from phpBB/includes/tree/nestedset_forum.php rename to phpBB/phpbb/tree/nestedset_forum.php diff --git a/phpBB/includes/user.php b/phpBB/phpbb/user.php similarity index 100% rename from phpBB/includes/user.php rename to phpBB/phpbb/user.php diff --git a/phpBB/includes/user_loader.php b/phpBB/phpbb/user_loader.php similarity index 100% rename from phpBB/includes/user_loader.php rename to phpBB/phpbb/user_loader.php diff --git a/phpunit.xml.all b/phpunit.xml.all index d47864e104..d18518d3e3 100644 --- a/phpunit.xml.all +++ b/phpunit.xml.all @@ -27,9 +27,10 @@ ./phpBB/includes/ + ./phpBB/phpbb/ - ./phpBB/includes/search/fulltext_native.php - ./phpBB/includes/search/fulltext_mysql.php + ./phpBB/phpbb/search/fulltext_native.php + ./phpBB/phpbb/search/fulltext_mysql.php ./phpBB/includes/captcha/ diff --git a/phpunit.xml.dist b/phpunit.xml.dist index ac45597b45..c852f91b50 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -34,9 +34,10 @@ ./phpBB/includes/ + ./phpBB/phpbb/ - ./phpBB/includes/search/fulltext_native.php - ./phpBB/includes/search/fulltext_mysql.php + ./phpBB/phpbb/search/fulltext_native.php + ./phpBB/phpbb/search/fulltext_mysql.php ./phpBB/includes/captcha/ diff --git a/phpunit.xml.functional b/phpunit.xml.functional index 3a3d653b47..cd9cc8771f 100644 --- a/phpunit.xml.functional +++ b/phpunit.xml.functional @@ -33,9 +33,10 @@ ./phpBB/includes/ + ./phpBB/phpbb/ - ./phpBB/includes/search/fulltext_native.php - ./phpBB/includes/search/fulltext_mysql.php + ./phpBB/phpbb/search/fulltext_native.php + ./phpBB/phpbb/search/fulltext_mysql.php ./phpBB/includes/captcha/ diff --git a/tests/bootstrap.php b/tests/bootstrap.php index a38740c82d..68cbb64c03 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -14,13 +14,13 @@ require_once $phpbb_root_path . 'includes/startup.php'; $table_prefix = 'phpbb_'; require_once $phpbb_root_path . 'includes/constants.php'; -require_once $phpbb_root_path . 'includes/class_loader.' . $phpEx; +require_once $phpbb_root_path . 'phpbb/class_loader.' . $phpEx; $phpbb_class_loader_mock = new phpbb_class_loader('phpbb_mock_', $phpbb_root_path . '../tests/mock/', "php"); $phpbb_class_loader_mock->register(); $phpbb_class_loader_ext = new phpbb_class_loader('phpbb_ext_', $phpbb_root_path . 'ext/', "php"); $phpbb_class_loader_ext->register(); -$phpbb_class_loader = new phpbb_class_loader('phpbb_', $phpbb_root_path . 'includes/', "php"); +$phpbb_class_loader = new phpbb_class_loader('phpbb_', $phpbb_root_path . 'phpbb/', "php"); $phpbb_class_loader->register(); require_once 'test_framework/phpbb_test_case_helpers.php'; diff --git a/tests/class_loader/class_loader_test.php b/tests/class_loader/class_loader_test.php index bf27c7c217..2b55c1ff8d 100644 --- a/tests/class_loader/class_loader_test.php +++ b/tests/class_loader/class_loader_test.php @@ -30,9 +30,9 @@ class phpbb_class_loader_test extends PHPUnit_Framework_TestCase public function test_resolve_path() { $prefix = dirname(__FILE__) . '/'; - $class_loader = new phpbb_class_loader('phpbb_', $prefix . 'includes/'); + $class_loader = new phpbb_class_loader('phpbb_', $prefix . 'phpbb/'); - $prefix .= 'includes/'; + $prefix .= 'phpbb/'; $this->assertEquals( '', @@ -71,10 +71,10 @@ class phpbb_class_loader_test extends PHPUnit_Framework_TestCase $cache = new phpbb_mock_cache($cache_map); $prefix = dirname(__FILE__) . '/'; - $class_loader = new phpbb_class_loader('phpbb_', $prefix . 'includes/', 'php', $cache); - $class_loader_ext = new phpbb_class_loader('phpbb_ext_', $prefix . 'includes/', 'php', $cache); + $class_loader = new phpbb_class_loader('phpbb_', $prefix . 'phpbb/', 'php', $cache); + $class_loader_ext = new phpbb_class_loader('phpbb_ext_', $prefix . 'phpbb/', 'php', $cache); - $prefix .= 'includes/'; + $prefix .= 'phpbb/'; $this->assertEquals( $prefix . 'dir/class_name.php', diff --git a/tests/class_loader/includes/class_name.php b/tests/class_loader/phpbb/class_name.php similarity index 100% rename from tests/class_loader/includes/class_name.php rename to tests/class_loader/phpbb/class_name.php diff --git a/tests/class_loader/includes/dir.php b/tests/class_loader/phpbb/dir.php similarity index 100% rename from tests/class_loader/includes/dir.php rename to tests/class_loader/phpbb/dir.php diff --git a/tests/class_loader/includes/dir/class_name.php b/tests/class_loader/phpbb/dir/class_name.php similarity index 100% rename from tests/class_loader/includes/dir/class_name.php rename to tests/class_loader/phpbb/dir/class_name.php diff --git a/tests/class_loader/includes/dir/subdir/class_name.php b/tests/class_loader/phpbb/dir/subdir/class_name.php similarity index 100% rename from tests/class_loader/includes/dir/subdir/class_name.php rename to tests/class_loader/phpbb/dir/subdir/class_name.php diff --git a/tests/class_loader/includes/dir2/dir2.php b/tests/class_loader/phpbb/dir2/dir2.php similarity index 100% rename from tests/class_loader/includes/dir2/dir2.php rename to tests/class_loader/phpbb/dir2/dir2.php diff --git a/tests/controller/controller_test.php b/tests/controller/controller_test.php index c06bf7d548..dfc4f80469 100644 --- a/tests/controller/controller_test.php +++ b/tests/controller/controller_test.php @@ -59,7 +59,7 @@ class phpbb_controller_controller_test extends phpbb_test_case } if (!class_exists('phpbb_controller_foo')) { - include(__DIR__.'/includes/controller/foo.php'); + include(__DIR__.'/phpbb/controller/foo.php'); } $resolver = new phpbb_controller_resolver(new phpbb_user, $container); diff --git a/tests/controller/includes/controller/foo.php b/tests/controller/phpbb/controller/foo.php similarity index 100% rename from tests/controller/includes/controller/foo.php rename to tests/controller/phpbb/controller/foo.php diff --git a/tests/datetime/from_format_test.php b/tests/datetime/from_format_test.php index c28925272e..2d97672878 100644 --- a/tests/datetime/from_format_test.php +++ b/tests/datetime/from_format_test.php @@ -7,9 +7,6 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/session.php'; -require_once dirname(__FILE__) . '/../../phpBB/includes/user.php'; -require_once dirname(__FILE__) . '/../../phpBB/includes/datetime.php'; require_once dirname(__FILE__) . '/../mock/lang.php'; class phpbb_datetime_from_format_test extends phpbb_test_case diff --git a/tests/dbal/migrator_test.php b/tests/dbal/migrator_test.php index 1e40c9c6d6..07eb666e93 100644 --- a/tests/dbal/migrator_test.php +++ b/tests/dbal/migrator_test.php @@ -8,8 +8,6 @@ */ require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; -require_once dirname(__FILE__) . '/../../phpBB/includes/db/migrator.php'; -require_once dirname(__FILE__) . '/../../phpBB/includes/db/migration/migration.php'; require_once dirname(__FILE__) . '/../../phpBB/includes/db/db_tools.php'; require_once dirname(__FILE__) . '/migration/dummy.php'; diff --git a/tests/dbal/migrator_tool_config_test.php b/tests/dbal/migrator_tool_config_test.php index 7d582f230b..b82d1ef48d 100644 --- a/tests/dbal/migrator_tool_config_test.php +++ b/tests/dbal/migrator_tool_config_test.php @@ -7,9 +7,6 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/db/migration/tool/config.php'; -require_once dirname(__FILE__) . '/../../phpBB/includes/db/migration/exception.php'; - class phpbb_dbal_migrator_tool_config_test extends phpbb_test_case { public function setup() diff --git a/tests/dbal/migrator_tool_module_test.php b/tests/dbal/migrator_tool_module_test.php index 3303086b26..828fb76c65 100644 --- a/tests/dbal/migrator_tool_module_test.php +++ b/tests/dbal/migrator_tool_module_test.php @@ -8,8 +8,6 @@ */ require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; -require_once dirname(__FILE__) . '/../../phpBB/includes/db/migration/tool/module.php'; -require_once dirname(__FILE__) . '/../../phpBB/includes/db/migration/exception.php'; class phpbb_dbal_migrator_tool_module_test extends phpbb_database_test_case { diff --git a/tests/dbal/migrator_tool_permission_test.php b/tests/dbal/migrator_tool_permission_test.php index 438ab2b28e..79d9db66da 100644 --- a/tests/dbal/migrator_tool_permission_test.php +++ b/tests/dbal/migrator_tool_permission_test.php @@ -8,8 +8,6 @@ */ require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; -require_once dirname(__FILE__) . '/../../phpBB/includes/db/migration/tool/permission.php'; -require_once dirname(__FILE__) . '/../../phpBB/includes/db/migration/exception.php'; class phpbb_dbal_migrator_tool_permission_test extends phpbb_database_test_case { diff --git a/tests/error_collector_test.php b/tests/error_collector_test.php index d67dea3719..fceb8aa3d8 100644 --- a/tests/error_collector_test.php +++ b/tests/error_collector_test.php @@ -8,7 +8,6 @@ */ require_once dirname(__FILE__) . '/../phpBB/includes/functions.php'; -require_once dirname(__FILE__) . '/../phpBB/includes/error_collector.php'; class phpbb_error_collector_test extends phpbb_test_case { diff --git a/tests/extension/finder_test.php b/tests/extension/finder_test.php index 6f3cebbd7c..3bf2c42573 100644 --- a/tests/extension/finder_test.php +++ b/tests/extension/finder_test.php @@ -36,7 +36,7 @@ class phpbb_extension_finder_test extends phpbb_test_case public function test_suffix_get_classes() { $classes = $this->finder - ->core_path('includes/default/') + ->core_path('phpbb/default/') ->extension_suffix('_class') ->get_classes(); @@ -81,7 +81,7 @@ class phpbb_extension_finder_test extends phpbb_test_case public function test_prefix_get_classes() { $classes = $this->finder - ->core_path('includes/default/') + ->core_path('phpbb/default/') ->extension_prefix('hidden_') ->get_classes(); @@ -98,7 +98,7 @@ class phpbb_extension_finder_test extends phpbb_test_case public function test_directory_get_classes() { $classes = $this->finder - ->core_path('includes/default/') + ->core_path('phpbb/default/') ->extension_directory('type') ->get_classes(); @@ -209,7 +209,7 @@ class phpbb_extension_finder_test extends phpbb_test_case public function test_cached_get_files() { $query = array( - 'core_path' => 'includes/foo', + 'core_path' => 'phpbb/foo', 'core_suffix' => false, 'core_prefix' => false, 'core_directory' => 'bar', diff --git a/tests/extension/includes/default/implementation.php b/tests/extension/phpbb/default/implementation.php similarity index 100% rename from tests/extension/includes/default/implementation.php rename to tests/extension/phpbb/default/implementation.php diff --git a/tests/log/function_view_log_test.php b/tests/log/function_view_log_test.php index 1ab9488568..6827aaa1b6 100644 --- a/tests/log/function_view_log_test.php +++ b/tests/log/function_view_log_test.php @@ -11,7 +11,6 @@ require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; require_once dirname(__FILE__) . '/../../phpBB/includes/functions_admin.php'; require_once dirname(__FILE__) . '/../../phpBB/includes/functions_content.php'; require_once dirname(__FILE__) . '/../../phpBB/includes/utf/utf_tools.php'; -require_once dirname(__FILE__) . '/../../phpBB/includes/session.php'; require_once dirname(__FILE__) . '/../mock/user.php'; require_once dirname(__FILE__) . '/../mock/cache.php'; diff --git a/tests/upload/fileupload_test.php b/tests/upload/fileupload_test.php index 1665c493be..8b9df33a63 100644 --- a/tests/upload/fileupload_test.php +++ b/tests/upload/fileupload_test.php @@ -10,6 +10,7 @@ require_once __DIR__ . '/../../phpBB/includes/functions.php'; require_once __DIR__ . '/../../phpBB/includes/utf/utf_tools.php'; require_once __DIR__ . '/../../phpBB/includes/functions_upload.php'; +require_once __DIR__ . '/../mock/filespec.php'; class phpbb_fileupload_test extends phpbb_test_case { From 057d860d07fe829104aa938338830787415bc1c6 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sun, 14 Jul 2013 00:56:37 -0400 Subject: [PATCH 2226/2494] [ticket/11696] Rename db_tools.php so it can be autoloaded PHPBB3-11696 --- phpBB/config/services.yml | 1 - phpBB/includes/acp/acp_database.php | 4 ---- .../captcha/plugins/phpbb_captcha_qa_plugin.php | 12 ++---------- phpBB/includes/db/{db_tools.php => tools.php} | 0 phpBB/includes/functions_install.php | 6 ------ phpBB/phpbb/search/fulltext_sphinx.php | 5 ----- tests/dbal/auto_increment_test.php | 1 - tests/dbal/db_tools_test.php | 1 - tests/dbal/migrator_test.php | 2 -- tests/extension/metadata_manager_test.php | 2 -- tests/functional/extension_controller_test.php | 1 - tests/functional/metadata_manager_test.php | 2 -- tests/notification/convert_test.php | 2 -- 13 files changed, 2 insertions(+), 37 deletions(-) rename phpBB/includes/db/{db_tools.php => tools.php} (100%) diff --git a/phpBB/config/services.yml b/phpBB/config/services.yml index 25fff79de3..c1579cfb57 100644 --- a/phpBB/config/services.yml +++ b/phpBB/config/services.yml @@ -126,7 +126,6 @@ services: - [sql_connect, [%dbal.dbhost%, %dbal.dbuser%, %dbal.dbpasswd%, %dbal.dbname%, %dbal.dbport%, false, %dbal.new_link%]] dbal.tools: - file: %core.root_path%includes/db/db_tools.%core.php_ext% class: phpbb_db_tools arguments: - @dbal.conn diff --git a/phpBB/includes/acp/acp_database.php b/phpBB/includes/acp/acp_database.php index ebcbd28a87..5d191b3d0f 100644 --- a/phpBB/includes/acp/acp_database.php +++ b/phpBB/includes/acp/acp_database.php @@ -28,10 +28,6 @@ class acp_database global $cache, $db, $user, $auth, $template, $table_prefix; global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx; - if (!class_exists('phpbb_db_tools')) - { - require($phpbb_root_path . 'includes/db/db_tools.' . $phpEx); - } $this->db_tools = new phpbb_db_tools($db); $user->add_lang('acp/database'); diff --git a/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php b/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php index ec7636f511..6843f25d72 100644 --- a/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php +++ b/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php @@ -110,12 +110,8 @@ class phpbb_captcha_qa */ static public function is_installed() { - global $db, $phpbb_root_path, $phpEx; + global $db; - if (!class_exists('phpbb_db_tools', false)) - { - include("$phpbb_root_path/includes/db/db_tools.$phpEx"); - } $db_tool = new phpbb_db_tools($db); return $db_tool->sql_table_exists(CAPTCHA_QUESTIONS_TABLE); @@ -297,12 +293,8 @@ class phpbb_captcha_qa */ function install() { - global $db, $phpbb_root_path, $phpEx; + global $db; - if (!class_exists('phpbb_db_tools')) - { - include("$phpbb_root_path/includes/db/db_tools.$phpEx"); - } $db_tool = new phpbb_db_tools($db); $tables = array(CAPTCHA_QUESTIONS_TABLE, CAPTCHA_ANSWERS_TABLE, CAPTCHA_QA_CONFIRM_TABLE); diff --git a/phpBB/includes/db/db_tools.php b/phpBB/includes/db/tools.php similarity index 100% rename from phpBB/includes/db/db_tools.php rename to phpBB/includes/db/tools.php diff --git a/phpBB/includes/functions_install.php b/phpBB/includes/functions_install.php index 8978e3fadd..bd0ffaaf00 100644 --- a/phpBB/includes/functions_install.php +++ b/phpBB/includes/functions_install.php @@ -184,12 +184,6 @@ function dbms_select($default = '', $only_20x_options = false) */ function get_tables(&$db) { - if (!class_exists('phpbb_db_tools')) - { - global $phpbb_root_path, $phpEx; - require($phpbb_root_path . 'includes/db/db_tools.' . $phpEx); - } - $db_tools = new phpbb_db_tools($db); return $db_tools->sql_list_tables(); diff --git a/phpBB/phpbb/search/fulltext_sphinx.php b/phpBB/phpbb/search/fulltext_sphinx.php index 2f7b236c78..4f3f852664 100644 --- a/phpBB/phpbb/search/fulltext_sphinx.php +++ b/phpBB/phpbb/search/fulltext_sphinx.php @@ -135,11 +135,6 @@ class phpbb_search_fulltext_sphinx $this->db = $db; $this->auth = $auth; - if (!class_exists('phpbb_db_tools')) - { - require($this->phpbb_root_path . 'includes/db/db_tools.' . $this->php_ext); - } - // Initialize phpbb_db_tools object $this->db_tools = new phpbb_db_tools($this->db); diff --git a/tests/dbal/auto_increment_test.php b/tests/dbal/auto_increment_test.php index e87fc1c6bd..077bfad933 100644 --- a/tests/dbal/auto_increment_test.php +++ b/tests/dbal/auto_increment_test.php @@ -8,7 +8,6 @@ */ require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; -require_once dirname(__FILE__) . '/../../phpBB/includes/db/db_tools.php'; class phpbb_dbal_auto_increment_test extends phpbb_database_test_case { diff --git a/tests/dbal/db_tools_test.php b/tests/dbal/db_tools_test.php index c20e46011f..7bdbc696e7 100644 --- a/tests/dbal/db_tools_test.php +++ b/tests/dbal/db_tools_test.php @@ -8,7 +8,6 @@ */ require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; -require_once dirname(__FILE__) . '/../../phpBB/includes/db/db_tools.php'; class phpbb_dbal_db_tools_test extends phpbb_database_test_case { diff --git a/tests/dbal/migrator_test.php b/tests/dbal/migrator_test.php index 07eb666e93..9e55e4dd35 100644 --- a/tests/dbal/migrator_test.php +++ b/tests/dbal/migrator_test.php @@ -8,8 +8,6 @@ */ require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; -require_once dirname(__FILE__) . '/../../phpBB/includes/db/db_tools.php'; - require_once dirname(__FILE__) . '/migration/dummy.php'; require_once dirname(__FILE__) . '/migration/unfulfillable.php'; require_once dirname(__FILE__) . '/migration/if.php'; diff --git a/tests/extension/metadata_manager_test.php b/tests/extension/metadata_manager_test.php index bd88f396d9..e5bd29092e 100644 --- a/tests/extension/metadata_manager_test.php +++ b/tests/extension/metadata_manager_test.php @@ -7,8 +7,6 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/db/db_tools.php'; - class phpbb_extension_metadata_manager_test extends phpbb_database_test_case { protected $class_loader; diff --git a/tests/functional/extension_controller_test.php b/tests/functional/extension_controller_test.php index 9ddf1e3e5c..7d29f0000c 100644 --- a/tests/functional/extension_controller_test.php +++ b/tests/functional/extension_controller_test.php @@ -6,7 +6,6 @@ * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/db/db_tools.php'; /** * @group functional diff --git a/tests/functional/metadata_manager_test.php b/tests/functional/metadata_manager_test.php index c55e7373ea..651c99a99d 100644 --- a/tests/functional/metadata_manager_test.php +++ b/tests/functional/metadata_manager_test.php @@ -7,8 +7,6 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/db/db_tools.php'; - /** * @group functional */ diff --git a/tests/notification/convert_test.php b/tests/notification/convert_test.php index 4d00fa0a1e..c038020385 100644 --- a/tests/notification/convert_test.php +++ b/tests/notification/convert_test.php @@ -6,8 +6,6 @@ * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 * */ - -require_once dirname(__FILE__) . '/../../phpBB/includes/db/db_tools.php'; require_once dirname(__FILE__) . '/../mock/sql_insert_buffer.php'; class phpbb_notification_convert_test extends phpbb_database_test_case From 5d4c443c2df1685578084417123d52b86eb3bfb6 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sun, 14 Jul 2013 01:01:53 -0400 Subject: [PATCH 2227/2494] [ticket/11696] Remove manual loading of db_tools in extension controller test Remember to store the file, before commiting it... PHPBB3-11696 --- tests/functional/extension_module_test.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/functional/extension_module_test.php b/tests/functional/extension_module_test.php index c573ea5410..c31a892ce9 100644 --- a/tests/functional/extension_module_test.php +++ b/tests/functional/extension_module_test.php @@ -6,8 +6,6 @@ * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 * */ - -require_once dirname(__FILE__) . '/../../phpBB/includes/db/db_tools.php'; require_once dirname(__FILE__) . '/../../phpBB/includes/acp/acp_modules.php'; /** From 131194d216f85dffe4fb9d8fd64eb15248fd374b Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sun, 14 Jul 2013 10:12:49 -0400 Subject: [PATCH 2228/2494] [ticket/11696] Rename constructor to __construct() PHPBB3-11696 --- phpBB/includes/db/tools.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/db/tools.php b/phpBB/includes/db/tools.php index 983cdc18ea..492284ffcd 100644 --- a/phpBB/includes/db/tools.php +++ b/phpBB/includes/db/tools.php @@ -303,7 +303,7 @@ class phpbb_db_tools * @param phpbb_db_driver $db Database connection * @param bool $return_statements True if only statements should be returned and no SQL being executed */ - function phpbb_db_tools(phpbb_db_driver $db, $return_statements = false) + public function __construct(phpbb_db_driver $db, $return_statements = false) { $this->db = $db; $this->return_statements = $return_statements; From f302cbe175e99f90448458f44a499eeb33f75261 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sun, 14 Jul 2013 10:16:15 -0400 Subject: [PATCH 2229/2494] [ticket/11696] Move file to new directory PHPBB3-11696 --- phpBB/{includes => phpbb}/db/tools.php | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename phpBB/{includes => phpbb}/db/tools.php (100%) diff --git a/phpBB/includes/db/tools.php b/phpBB/phpbb/db/tools.php similarity index 100% rename from phpBB/includes/db/tools.php rename to phpBB/phpbb/db/tools.php From 405b5e54f6e97f70417af38c27f8fa2fb4062c3e Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sun, 14 Jul 2013 10:49:23 -0400 Subject: [PATCH 2230/2494] [ticket/11702] Fix forum_posts left over for link-click counts in viewforum.php PHPBB3-11702 --- phpBB/viewforum.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/viewforum.php b/phpBB/viewforum.php index 06af674ee6..5a59e021b3 100644 --- a/phpBB/viewforum.php +++ b/phpBB/viewforum.php @@ -105,7 +105,7 @@ if ($forum_data['forum_type'] == FORUM_LINK && $forum_data['forum_link']) if ($forum_data['forum_flags'] & FORUM_FLAG_LINK_TRACK) { $sql = 'UPDATE ' . FORUMS_TABLE . ' - SET forum_posts = forum_posts + 1 + SET forum_posts_approved = forum_posts_approved + 1 WHERE forum_id = ' . $forum_id; $db->sql_query($sql); } From e91b465de1c4cf767bba72c9eebe945b898c3fda Mon Sep 17 00:00:00 2001 From: Victor Nagy Date: Sun, 14 Jul 2013 10:57:19 -0400 Subject: [PATCH 2231/2494] [ticket/11697] author_search() used incorrect parameter The author_search() function in fulltext_mysql.php had an argument $m_approve_fid_ary parameter but it was changed in the Docblock and code to $post_visibility. This change renames that argument according to the docblock, the code and to mirror the other classes. PHPBB3-11697 --- phpBB/includes/search/fulltext_mysql.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/search/fulltext_mysql.php b/phpBB/includes/search/fulltext_mysql.php index 7dc4da8ffe..a1e1b089b9 100644 --- a/phpBB/includes/search/fulltext_mysql.php +++ b/phpBB/includes/search/fulltext_mysql.php @@ -542,7 +542,7 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base * @param int $per_page number of ids each page is supposed to contain * @return boolean|int total number of results */ - public function author_search($type, $firstpost_only, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_fid_ary, $topic_id, $author_ary, $author_name, &$id_ary, &$start, $per_page) + public function author_search($type, $firstpost_only, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $post_visibility, $topic_id, $author_ary, $author_name, &$id_ary, &$start, $per_page) { // No author? No posts if (!sizeof($author_ary)) From 573987d2d2defe3425c083b093bb5a5d3ec2db2a Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 28 Jun 2013 10:52:13 +0200 Subject: [PATCH 2232/2494] [ticket/11582] Add new service for permissions Replace calls to the language-array type with a call to get_types() PHPBB3-11582 --- phpBB/config/services.yml | 5 + phpBB/includes/acp/acp_permissions.php | 9 +- phpBB/includes/permissions.php | 263 ++++++++++++++++++++ phpBB/language/en/acp/permissions_phpbb.php | 16 +- 4 files changed, 280 insertions(+), 13 deletions(-) create mode 100644 phpBB/includes/permissions.php diff --git a/phpBB/config/services.yml b/phpBB/config/services.yml index c1579cfb57..9337fb0a5b 100644 --- a/phpBB/config/services.yml +++ b/phpBB/config/services.yml @@ -8,6 +8,11 @@ imports: - { resource: auth_providers.yml } services: + acl.permissions: + class: phpbb_permissions + arguments: + - @dispatcher + auth: class: phpbb_auth diff --git a/phpBB/includes/acp/acp_permissions.php b/phpBB/includes/acp/acp_permissions.php index a64765f4f5..9c5395c5b2 100644 --- a/phpBB/includes/acp/acp_permissions.php +++ b/phpBB/includes/acp/acp_permissions.php @@ -587,7 +587,10 @@ class acp_permissions */ function build_permission_dropdown($options, $default_option, $permission_scope) { - global $user, $auth; + global $user, $auth, $phpbb_container; + + $permissions = $phpbb_container->get('acl.permissions'); + $permission_types = $permissions->get_types(); $s_dropdown_options = ''; foreach ($options as $setting) @@ -598,8 +601,8 @@ class acp_permissions } $selected = ($setting == $default_option) ? ' selected="selected"' : ''; - $l_setting = (isset($user->lang['permission_type'][$permission_scope][$setting])) ? $user->lang['permission_type'][$permission_scope][$setting] : $user->lang['permission_type'][$setting]; - $s_dropdown_options .= ''; + $l_setting = (isset($permission_types[$permission_scope][$setting])) ? $permission_types[$permission_scope][$setting] : $permission_types[$setting]; + $s_dropdown_options .= ''; } return $s_dropdown_options; diff --git a/phpBB/includes/permissions.php b/phpBB/includes/permissions.php new file mode 100644 index 0000000000..d5389344f7 --- /dev/null +++ b/phpBB/includes/permissions.php @@ -0,0 +1,263 @@ +dispatcher = $phpbb_dispatcher; + } + + public function get_categories() + { + $categories = $this->categories; + + /** + * Allows to specify additional permission categories + * + * @event core.permissions_get_categories + * @var array categories Array with permission categories (pm, post, settings, misc, etc.) + * @since 3.1-A1 + */ + $vars = array('categories'); + extract($this->dispatcher->trigger_event('core.permissions_get_categories', $vars)); + + return $categories; + } + + public function get_types() + { + $types = $this->types; + + /** + * Allows to specify additional permission types + * + * @event core.permissions_get_types + * @var array types Array with permission types (a_, u_, m_, etc.) + * @since 3.1-A1 + */ + $vars = array('types'); + extract($this->dispatcher->trigger_event('core.permissions_get_types', $vars)); + + return $types; + } + + public function get_permissions() + { + $permissions = $this->permissions; + + /** + * Allows to specify additional permissions + * + * @event core.permissions_get_types + * @var array permissions Array with permissions. Each Permission has the following layout: + * 'acl_' => array( + * 'lang' => 'Language Key with a Short description', // Optional, if not set, + * // the permissions identifier 'acl_' is used with + * // all uppercase. + * 'cat' => 'Identifier of the category, the permission should be displayed in', + * ), + * Example: + * 'acl_u_viewprofile' => array( + * 'lang' => 'ACL_U_VIEWPROFILE', + * 'cat' => 'profile', + * ), + * + * @since 3.1-A1 + */ + $vars = array('permissions'); + extract($this->dispatcher->trigger_event('core.permissions_get_permissions', $vars)); + + return $permissions; + } + + protected $types = array( + 'u_' => 'ACL_TYPE_USER', + 'a_' => 'ACL_TYPE_ADMIN', + 'm_' => 'ACL_TYPE_MODERATOR', + 'f_' => 'ACL_TYPE_FORUM', + 'global' => array( + 'm_' => 'ACL_TYPE_GLOBAL_MODERATOR', + ), + ); + + protected $categories = array( + 'actions' => 'Actions', + 'content' => 'Content', + 'forums' => 'Forums', + 'misc' => 'Misc', + 'permissions' => 'Permissions', + 'pm' => 'Private messages', + 'polls' => 'Polls', + 'post' => 'Post', + 'post_actions' => 'Post actions', + 'posting' => 'Posting', + 'profile' => 'Profile', + 'settings' => 'Settings', + 'topic_actions' => 'Topic actions', + 'user_group' => 'Users & Groups', + ); + + protected $permissions = array( + // User Permissions + 'acl_u_viewprofile' => array('lang' => 'Can view profiles, memberlist and online list', 'cat' => 'profile'), + 'acl_u_chgname' => array('lang' => 'Can change username', 'cat' => 'profile'), + 'acl_u_chgpasswd' => array('lang' => 'Can change password', 'cat' => 'profile'), + 'acl_u_chgemail' => array('lang' => 'Can change email address', 'cat' => 'profile'), + 'acl_u_chgavatar' => array('lang' => 'Can change avatar', 'cat' => 'profile'), + 'acl_u_chggrp' => array('lang' => 'Can change default usergroup', 'cat' => 'profile'), + 'acl_u_chgprofileinfo' => array('lang' => 'Can change profile field information', 'cat' => 'profile'), + + 'acl_u_attach' => array('lang' => 'Can attach files', 'cat' => 'post'), + 'acl_u_download' => array('lang' => 'Can download files', 'cat' => 'post'), + 'acl_u_savedrafts' => array('lang' => 'Can save drafts', 'cat' => 'post'), + 'acl_u_chgcensors' => array('lang' => 'Can disable word censors', 'cat' => 'post'), + 'acl_u_sig' => array('lang' => 'Can use signature', 'cat' => 'post'), + + 'acl_u_sendpm' => array('lang' => 'Can send private messages', 'cat' => 'pm'), + 'acl_u_masspm' => array('lang' => 'Can send messages to multiple users', 'cat' => 'pm'), + 'acl_u_masspm_group'=> array('lang' => 'Can send messages to groups', 'cat' => 'pm'), + 'acl_u_readpm' => array('lang' => 'Can read private messages', 'cat' => 'pm'), + 'acl_u_pm_edit' => array('lang' => 'Can edit own private messages', 'cat' => 'pm'), + 'acl_u_pm_delete' => array('lang' => 'Can remove private messages from own folder', 'cat' => 'pm'), + 'acl_u_pm_forward' => array('lang' => 'Can forward private messages', 'cat' => 'pm'), + 'acl_u_pm_emailpm' => array('lang' => 'Can email private messages', 'cat' => 'pm'), + 'acl_u_pm_printpm' => array('lang' => 'Can print private messages', 'cat' => 'pm'), + 'acl_u_pm_attach' => array('lang' => 'Can attach files in private messages', 'cat' => 'pm'), + 'acl_u_pm_download' => array('lang' => 'Can download files in private messages', 'cat' => 'pm'), + 'acl_u_pm_bbcode' => array('lang' => 'Can use BBCode in private messages', 'cat' => 'pm'), + 'acl_u_pm_smilies' => array('lang' => 'Can use smilies in private messages', 'cat' => 'pm'), + 'acl_u_pm_img' => array('lang' => 'Can use [img] BBCode tag in private messages', 'cat' => 'pm'), + 'acl_u_pm_flash' => array('lang' => 'Can use [flash] BBCode tag in private messages', 'cat' => 'pm'), + + 'acl_u_sendemail' => array('lang' => 'Can send emails', 'cat' => 'misc'), + 'acl_u_sendim' => array('lang' => 'Can send instant messages', 'cat' => 'misc'), + 'acl_u_ignoreflood' => array('lang' => 'Can ignore flood limit', 'cat' => 'misc'), + 'acl_u_hideonline' => array('lang' => 'Can hide online status', 'cat' => 'misc'), + 'acl_u_viewonline' => array('lang' => 'Can view hidden online users', 'cat' => 'misc'), + 'acl_u_search' => array('lang' => 'Can search board', 'cat' => 'misc'), + + // Forum Permissions + 'acl_f_list' => array('lang' => 'Can see forum', 'cat' => 'actions'), + 'acl_f_read' => array('lang' => 'Can read forum', 'cat' => 'actions'), + 'acl_f_search' => array('lang' => 'Can search the forum', 'cat' => 'actions'), + 'acl_f_subscribe' => array('lang' => 'Can subscribe forum', 'cat' => 'actions'), + 'acl_f_print' => array('lang' => 'Can print topics', 'cat' => 'actions'), + 'acl_f_email' => array('lang' => 'Can email topics', 'cat' => 'actions'), + 'acl_f_bump' => array('lang' => 'Can bump topics', 'cat' => 'actions'), + 'acl_f_user_lock' => array('lang' => 'Can lock own topics', 'cat' => 'actions'), + 'acl_f_download' => array('lang' => 'Can download files', 'cat' => 'actions'), + 'acl_f_report' => array('lang' => 'Can report posts', 'cat' => 'actions'), + + 'acl_f_post' => array('lang' => 'Can start new topics', 'cat' => 'post'), + 'acl_f_sticky' => array('lang' => 'Can post stickies', 'cat' => 'post'), + 'acl_f_announce' => array('lang' => 'Can post announcements', 'cat' => 'post'), + 'acl_f_reply' => array('lang' => 'Can reply to topics', 'cat' => 'post'), + 'acl_f_edit' => array('lang' => 'Can edit own posts', 'cat' => 'post'), + 'acl_f_delete' => array('lang' => 'Can delete own posts', 'cat' => 'post'), + 'acl_f_ignoreflood' => array('lang' => 'Can ignore flood limit', 'cat' => 'post'), + 'acl_f_postcount' => array('lang' => 'Increment post counter
    Please note that this setting only affects new posts.', 'cat' => 'post'), + 'acl_f_noapprove' => array('lang' => 'Can post without approval', 'cat' => 'post'), + + 'acl_f_attach' => array('lang' => 'Can attach files', 'cat' => 'content'), + 'acl_f_icons' => array('lang' => 'Can use topic/post icons', 'cat' => 'content'), + 'acl_f_bbcode' => array('lang' => 'Can use BBCode', 'cat' => 'content'), + 'acl_f_flash' => array('lang' => 'Can use [flash] BBCode tag', 'cat' => 'content'), + 'acl_f_img' => array('lang' => 'Can use [img] BBCode tag', 'cat' => 'content'), + 'acl_f_sigs' => array('lang' => 'Can use signatures', 'cat' => 'content'), + 'acl_f_smilies' => array('lang' => 'Can use smilies', 'cat' => 'content'), + + 'acl_f_poll' => array('lang' => 'Can create polls', 'cat' => 'polls'), + 'acl_f_vote' => array('lang' => 'Can vote in polls', 'cat' => 'polls'), + 'acl_f_votechg' => array('lang' => 'Can change existing vote', 'cat' => 'polls'), + + // Moderator Permissions + 'acl_m_edit' => array('lang' => 'Can edit posts', 'cat' => 'post_actions'), + 'acl_m_delete' => array('lang' => 'Can delete posts', 'cat' => 'post_actions'), + 'acl_m_approve' => array('lang' => 'Can approve posts', 'cat' => 'post_actions'), + 'acl_m_report' => array('lang' => 'Can close and delete reports', 'cat' => 'post_actions'), + 'acl_m_chgposter' => array('lang' => 'Can change post author', 'cat' => 'post_actions'), + + 'acl_m_move' => array('lang' => 'Can move topics', 'cat' => 'topic_actions'), + 'acl_m_lock' => array('lang' => 'Can lock topics', 'cat' => 'topic_actions'), + 'acl_m_split' => array('lang' => 'Can split topics', 'cat' => 'topic_actions'), + 'acl_m_merge' => array('lang' => 'Can merge topics', 'cat' => 'topic_actions'), + + 'acl_m_info' => array('lang' => 'Can view post details', 'cat' => 'misc'), + 'acl_m_warn' => array('lang' => 'Can issue warnings
    This setting is only assigned globally. It is not forum based.', 'cat' => 'misc'), // This moderator setting is only global (and not local) + 'acl_m_ban' => array('lang' => 'Can manage bans
    This setting is only assigned globally. It is not forum based.', 'cat' => 'misc'), // This moderator setting is only global (and not local) + + // Admin Permissions + 'acl_a_board' => array('lang' => 'Can alter board settings/check for updates', 'cat' => 'settings'), + 'acl_a_server' => array('lang' => 'Can alter server/communication settings', 'cat' => 'settings'), + 'acl_a_jabber' => array('lang' => 'Can alter Jabber settings', 'cat' => 'settings'), + 'acl_a_phpinfo' => array('lang' => 'Can view php settings', 'cat' => 'settings'), + + 'acl_a_forum' => array('lang' => 'Can manage forums', 'cat' => 'forums'), + 'acl_a_forumadd' => array('lang' => 'Can add new forums', 'cat' => 'forums'), + 'acl_a_forumdel' => array('lang' => 'Can delete forums', 'cat' => 'forums'), + 'acl_a_prune' => array('lang' => 'Can prune forums', 'cat' => 'forums'), + + 'acl_a_icons' => array('lang' => 'Can alter topic/post icons and smilies', 'cat' => 'posting'), + 'acl_a_words' => array('lang' => 'Can alter word censors', 'cat' => 'posting'), + 'acl_a_bbcode' => array('lang' => 'Can define BBCode tags', 'cat' => 'posting'), + 'acl_a_attach' => array('lang' => 'Can alter attachment related settings', 'cat' => 'posting'), + + 'acl_a_user' => array('lang' => 'Can manage users
    This also includes seeing the users browser agent within the viewonline list.', 'cat' => 'user_group'), + 'acl_a_userdel' => array('lang' => 'Can delete/prune users', 'cat' => 'user_group'), + 'acl_a_group' => array('lang' => 'Can manage groups', 'cat' => 'user_group'), + 'acl_a_groupadd' => array('lang' => 'Can add new groups', 'cat' => 'user_group'), + 'acl_a_groupdel' => array('lang' => 'Can delete groups', 'cat' => 'user_group'), + 'acl_a_ranks' => array('lang' => 'Can manage ranks', 'cat' => 'user_group'), + 'acl_a_profile' => array('lang' => 'Can manage custom profile fields', 'cat' => 'user_group'), + 'acl_a_names' => array('lang' => 'Can manage disallowed names', 'cat' => 'user_group'), + 'acl_a_ban' => array('lang' => 'Can manage bans', 'cat' => 'user_group'), + + 'acl_a_viewauth' => array('lang' => 'Can view permission masks', 'cat' => 'permissions'), + 'acl_a_authgroups' => array('lang' => 'Can alter permissions for individual groups', 'cat' => 'permissions'), + 'acl_a_authusers' => array('lang' => 'Can alter permissions for individual users', 'cat' => 'permissions'), + 'acl_a_fauth' => array('lang' => 'Can alter forum permission class', 'cat' => 'permissions'), + 'acl_a_mauth' => array('lang' => 'Can alter moderator permission class', 'cat' => 'permissions'), + 'acl_a_aauth' => array('lang' => 'Can alter admin permission class', 'cat' => 'permissions'), + 'acl_a_uauth' => array('lang' => 'Can alter user permission class', 'cat' => 'permissions'), + 'acl_a_roles' => array('lang' => 'Can manage roles', 'cat' => 'permissions'), + 'acl_a_switchperm' => array('lang' => 'Can use others permissions', 'cat' => 'permissions'), + + 'acl_a_styles' => array('lang' => 'Can manage styles', 'cat' => 'misc'), + 'acl_a_extensions' => array('lang' => 'Can manage extensions', 'cat' => 'misc'), + 'acl_a_viewlogs' => array('lang' => 'Can view logs', 'cat' => 'misc'), + 'acl_a_clearlogs' => array('lang' => 'Can clear logs', 'cat' => 'misc'), + 'acl_a_modules' => array('lang' => 'Can manage modules', 'cat' => 'misc'), + 'acl_a_language' => array('lang' => 'Can manage language packs', 'cat' => 'misc'), + 'acl_a_email' => array('lang' => 'Can send mass email', 'cat' => 'misc'), + 'acl_a_bots' => array('lang' => 'Can manage bots', 'cat' => 'misc'), + 'acl_a_reasons' => array('lang' => 'Can manage report/denial reasons', 'cat' => 'misc'), + 'acl_a_backup' => array('lang' => 'Can backup/restore database', 'cat' => 'misc'), + 'acl_a_search' => array('lang' => 'Can manage search backends and settings', 'cat' => 'misc'), + ); +} diff --git a/phpBB/language/en/acp/permissions_phpbb.php b/phpBB/language/en/acp/permissions_phpbb.php index 98679ad544..70312261a1 100644 --- a/phpBB/language/en/acp/permissions_phpbb.php +++ b/phpBB/language/en/acp/permissions_phpbb.php @@ -82,16 +82,12 @@ $lang = array_merge($lang, array( 'user_group' => 'Users & Groups', ), - // With defining 'global' here we are able to specify what is printed out if the permission is within the global scope. - 'permission_type' => array( - 'u_' => 'User permissions', - 'a_' => 'Admin permissions', - 'm_' => 'Moderator permissions', - 'f_' => 'Forum permissions', - 'global' => array( - 'm_' => 'Global moderator permissions', - ), - ), + + 'ACL_TYPE_USER' => 'User permissions', + 'ACL_TYPE_ADMIN' => 'Admin permissions', + 'ACL_TYPE_MODERATOR' => 'Moderator permissions', + 'ACL_TYPE_FORUM' => 'Forum permissions', + 'ACL_TYPE_GLOBAL_MODERATOR' => 'Global moderator permissions', )); // User Permissions From e8d2a2fd8861e5ef2473aa670808dc6098aa1241 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 28 Jun 2013 11:10:33 +0200 Subject: [PATCH 2233/2494] [ticket/11582] Use new class for categories PHPBB3-11582 --- phpBB/includes/acp/acp_permission_roles.php | 7 +++-- phpBB/includes/acp/auth.php | 16 +++++++---- phpBB/includes/permissions.php | 28 +++++++++---------- phpBB/language/en/acp/permissions_phpbb.php | 30 ++++++++++----------- 4 files changed, 44 insertions(+), 37 deletions(-) diff --git a/phpBB/includes/acp/acp_permission_roles.php b/phpBB/includes/acp/acp_permission_roles.php index e830479389..8a2798a90a 100644 --- a/phpBB/includes/acp/acp_permission_roles.php +++ b/phpBB/includes/acp/acp_permission_roles.php @@ -456,7 +456,10 @@ class acp_permission_roles */ function display_auth_options($auth_options) { - global $template, $user; + global $template, $user, $phpbb_container; + + $permissions = $phpbb_container->get('acl.permissions'); + $permission_categories = $permissions->get_categories(); $content_array = $categories = array(); $key_sort_array = array(0); @@ -473,7 +476,7 @@ class acp_permission_roles foreach ($content_array as $cat => $cat_array) { $template->assign_block_vars('auth', array( - 'CAT_NAME' => $user->lang['permission_cat'][$cat], + 'CAT_NAME' => $user->lang($permission_categories[$cat]), 'S_YES' => ($cat_array['S_YES'] && !$cat_array['S_NEVER'] && !$cat_array['S_NO']) ? true : false, 'S_NEVER' => ($cat_array['S_NEVER'] && !$cat_array['S_YES'] && !$cat_array['S_NO']) ? true : false, diff --git a/phpBB/includes/acp/auth.php b/phpBB/includes/acp/auth.php index 6b1da46a12..03cc0c1705 100644 --- a/phpBB/includes/acp/auth.php +++ b/phpBB/includes/acp/auth.php @@ -1100,7 +1100,10 @@ class auth_admin extends phpbb_auth */ function assign_cat_array(&$category_array, $tpl_cat, $tpl_mask, $ug_id, $forum_id, $show_trace = false, $s_view) { - global $template, $user, $phpbb_admin_path, $phpEx; + global $template, $user, $phpbb_admin_path, $phpEx, $phpbb_container; + + $permissions = $phpbb_container->get('acl.permissions'); + $permission_categories = $permissions->get_categories(); @reset($category_array); while (list($cat, $cat_array) = each($category_array)) @@ -1110,8 +1113,8 @@ class auth_admin extends phpbb_auth 'S_NEVER' => ($cat_array['S_NEVER'] && !$cat_array['S_YES'] && !$cat_array['S_NO']) ? true : false, 'S_NO' => ($cat_array['S_NO'] && !$cat_array['S_NEVER'] && !$cat_array['S_YES']) ? true : false, - 'CAT_NAME' => $user->lang['permission_cat'][$cat]) - ); + 'CAT_NAME' => $user->lang($permission_categories[$cat]), + )); /* Sort permissions by name (more naturaly and user friendly than sorting by a primary key) * Commented out due to it's memory consumption and time needed @@ -1176,7 +1179,10 @@ class auth_admin extends phpbb_auth */ function build_permission_array(&$permission_row, &$content_array, &$categories, $key_sort_array) { - global $user; + global $user, $phpbb_container; + + $permissions = $phpbb_container->get('acl.permissions'); + $permission_categories = $permissions->get_categories(); foreach ($key_sort_array as $forum_id) { @@ -1204,7 +1210,7 @@ class auth_admin extends phpbb_auth // Build our categories array if (!isset($categories[$cat])) { - $categories[$cat] = $user->lang['permission_cat'][$cat]; + $categories[$cat] = $user->lang($permission_categories[$cat]); } // Build our content array diff --git a/phpBB/includes/permissions.php b/phpBB/includes/permissions.php index d5389344f7..1e2cf9e4aa 100644 --- a/phpBB/includes/permissions.php +++ b/phpBB/includes/permissions.php @@ -107,20 +107,20 @@ class phpbb_permissions ); protected $categories = array( - 'actions' => 'Actions', - 'content' => 'Content', - 'forums' => 'Forums', - 'misc' => 'Misc', - 'permissions' => 'Permissions', - 'pm' => 'Private messages', - 'polls' => 'Polls', - 'post' => 'Post', - 'post_actions' => 'Post actions', - 'posting' => 'Posting', - 'profile' => 'Profile', - 'settings' => 'Settings', - 'topic_actions' => 'Topic actions', - 'user_group' => 'Users & Groups', + 'actions' => 'ACL_CAT_ACTIONS', + 'content' => 'ACL_CAT_CONTENT', + 'forums' => 'ACL_CAT_FORUMS', + 'misc' => 'ACL_CAT_MISC', + 'permissions' => 'ACL_CAT_PERMISSIONS', + 'pm' => 'ACL_CAT_PM', + 'polls' => 'ACL_CAT_POLLS', + 'post' => 'ACL_CAT_POST', + 'post_actions' => 'ACL_CAT_POST_ACTIONS', + 'posting' => 'ACL_CAT_POSTING', + 'profile' => 'ACL_CAT_PROFILE', + 'settings' => 'ACL_CAT_SETTINGS', + 'topic_actions' => 'ACL_CAT_TOPIC_ACTIONS', + 'user_group' => 'ACL_CAT_USER_GROUP', ); protected $permissions = array( diff --git a/phpBB/language/en/acp/permissions_phpbb.php b/phpBB/language/en/acp/permissions_phpbb.php index 70312261a1..0a669a4b8d 100644 --- a/phpBB/language/en/acp/permissions_phpbb.php +++ b/phpBB/language/en/acp/permissions_phpbb.php @@ -65,22 +65,20 @@ if (empty($lang) || !is_array($lang)) // Define categories and permission types $lang = array_merge($lang, array( - 'permission_cat' => array( - 'actions' => 'Actions', - 'content' => 'Content', - 'forums' => 'Forums', - 'misc' => 'Misc', - 'permissions' => 'Permissions', - 'pm' => 'Private messages', - 'polls' => 'Polls', - 'post' => 'Post', - 'post_actions' => 'Post actions', - 'posting' => 'Posting', - 'profile' => 'Profile', - 'settings' => 'Settings', - 'topic_actions' => 'Topic actions', - 'user_group' => 'Users & Groups', - ), + 'ACL_CAT_ACTIONS' => 'Actions', + 'ACL_CAT_CONTENT' => 'Content', + 'ACL_CAT_FORUMS' => 'Forums', + 'ACL_CAT_MISC' => 'Misc', + 'ACL_CAT_PERMISSIONS' => 'Permissions', + 'ACL_CAT_PM' => 'Private messages', + 'ACL_CAT_POLLS' => 'Polls', + 'ACL_CAT_POST' => 'Post', + 'ACL_CAT_POST_ACTIONS' => 'Post actions', + 'ACL_CAT_POSTING' => 'Posting', + 'ACL_CAT_PROFILE' => 'Profile', + 'ACL_CAT_SETTINGS' => 'Settings', + 'ACL_CAT_TOPIC_ACTIONS' => 'Topic actions', + 'ACL_CAT_USER_GROUP' => 'Users & Groups', 'ACL_TYPE_USER' => 'User permissions', From 137cec58950ad547a204a47b1e84e46fdc29139c Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 28 Jun 2013 11:16:52 +0200 Subject: [PATCH 2234/2494] [ticket/11582] Fix event dispatcher class name PHPBB3-11582 --- phpBB/includes/permissions.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/phpBB/includes/permissions.php b/phpBB/includes/permissions.php index 1e2cf9e4aa..c338727fc0 100644 --- a/phpBB/includes/permissions.php +++ b/phpBB/includes/permissions.php @@ -19,16 +19,16 @@ class phpbb_permissions { /** * Event dispatcher object - * @var phpbb_dispatcher + * @var phpbb_event_dispatcher */ protected $dispatcher; /** * Constructor * - * @param phpbb_dispatcher $phpbb_dispatcher Event dispatcher + * @param phpbb_event_dispatcher $phpbb_dispatcher Event dispatcher * @return null */ - public function __construct($phpbb_dispatcher) + public function __construct(phpbb_event_dispatcher $phpbb_dispatcher) { $this->dispatcher = $phpbb_dispatcher; } From 7f9a1c811647c00b20cfa4f5029f6b569597cb4b Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 28 Jun 2013 11:27:38 +0200 Subject: [PATCH 2235/2494] [ticket/11582] Add event in constructor and add docs PHPBB3-11582 --- phpBB/config/services.yml | 1 + phpBB/includes/permissions.php | 103 +++++++++++++++++++-------------- 2 files changed, 62 insertions(+), 42 deletions(-) diff --git a/phpBB/config/services.yml b/phpBB/config/services.yml index 9337fb0a5b..4110f8c456 100644 --- a/phpBB/config/services.yml +++ b/phpBB/config/services.yml @@ -12,6 +12,7 @@ services: class: phpbb_permissions arguments: - @dispatcher + - @user auth: class: phpbb_auth diff --git a/phpBB/includes/permissions.php b/phpBB/includes/permissions.php index c338727fc0..ddeadc825b 100644 --- a/phpBB/includes/permissions.php +++ b/phpBB/includes/permissions.php @@ -22,59 +22,35 @@ class phpbb_permissions * @var phpbb_event_dispatcher */ protected $dispatcher; + + /** + * User object + * @var phpbb_user + */ + protected $user; + /** * Constructor * * @param phpbb_event_dispatcher $phpbb_dispatcher Event dispatcher + * @param phpbb_user $user User Object * @return null */ - public function __construct(phpbb_event_dispatcher $phpbb_dispatcher) + public function __construct(phpbb_event_dispatcher $phpbb_dispatcher, phpbb_user $user) { $this->dispatcher = $phpbb_dispatcher; - } + $this->user = $user; - public function get_categories() - { $categories = $this->categories; - - /** - * Allows to specify additional permission categories - * - * @event core.permissions_get_categories - * @var array categories Array with permission categories (pm, post, settings, misc, etc.) - * @since 3.1-A1 - */ - $vars = array('categories'); - extract($this->dispatcher->trigger_event('core.permissions_get_categories', $vars)); - - return $categories; - } - - public function get_types() - { $types = $this->types; - - /** - * Allows to specify additional permission types - * - * @event core.permissions_get_types - * @var array types Array with permission types (a_, u_, m_, etc.) - * @since 3.1-A1 - */ - $vars = array('types'); - extract($this->dispatcher->trigger_event('core.permissions_get_types', $vars)); - - return $types; - } - - public function get_permissions() - { $permissions = $this->permissions; /** - * Allows to specify additional permissions + * Allows to specify additional permission categories, types and permissions * - * @event core.permissions_get_types + * @event core.permissions + * @var array types Array with permission types (a_, u_, m_, etc.) + * @var array categories Array with permission categories (pm, post, settings, misc, etc.) * @var array permissions Array with permissions. Each Permission has the following layout: * 'acl_' => array( * 'lang' => 'Language Key with a Short description', // Optional, if not set, @@ -87,13 +63,56 @@ class phpbb_permissions * 'lang' => 'ACL_U_VIEWPROFILE', * 'cat' => 'profile', * ), - * * @since 3.1-A1 */ - $vars = array('permissions'); - extract($this->dispatcher->trigger_event('core.permissions_get_permissions', $vars)); + $vars = array('types', 'categories', 'permissions'); + extract($phpbb_dispatcher->trigger_event('core.permissions', $vars)); - return $permissions; + $this->categories = $categories; + $this->types = $types; + $this->permissions = $permissions; + } + + /** + * Returns an array with all the permission categories (pm, post, settings, misc, etc.) + * + * @return array Layout: cat-identifier => Language key + */ + public function get_categories() + { + return $this->categories; + } + + /** + * Returns an array with all the permission types (a_, u_, m_, etc.) + * + * @return array Layout: type-identifier => Language key + */ + public function get_types() + { + return $this->types; + } + + /** + * Returns an array with all the permissions. + * Each Permission has the following layout: + * 'acl_' => array( + * 'lang' => 'Language Key with a Short description', // Optional, if not set, + * // the permissions identifier 'acl_' is used with + * // all uppercase. + * 'cat' => 'Identifier of the category, the permission should be displayed in', + * ), + * Example: + * 'acl_u_viewprofile' => array( + * 'lang' => 'ACL_U_VIEWPROFILE', + * 'cat' => 'profile', + * ), + * + * @return array + */ + public function get_permissions() + { + return $this->permissions; } protected $types = array( From ce0a182c7fcd0c67020a44109440cd807bee2e82 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 28 Jun 2013 11:40:00 +0200 Subject: [PATCH 2236/2494] [ticket/11582] Add methods to return the language string PHPBB3-11582 --- phpBB/includes/acp/acp_permission_roles.php | 3 +-- phpBB/includes/acp/acp_permissions.php | 7 +++-- phpBB/includes/acp/auth.php | 6 ++--- phpBB/includes/permissions.php | 29 +++++++++++++++++++++ 4 files changed, 35 insertions(+), 10 deletions(-) diff --git a/phpBB/includes/acp/acp_permission_roles.php b/phpBB/includes/acp/acp_permission_roles.php index 8a2798a90a..2a00301543 100644 --- a/phpBB/includes/acp/acp_permission_roles.php +++ b/phpBB/includes/acp/acp_permission_roles.php @@ -459,7 +459,6 @@ class acp_permission_roles global $template, $user, $phpbb_container; $permissions = $phpbb_container->get('acl.permissions'); - $permission_categories = $permissions->get_categories(); $content_array = $categories = array(); $key_sort_array = array(0); @@ -476,7 +475,7 @@ class acp_permission_roles foreach ($content_array as $cat => $cat_array) { $template->assign_block_vars('auth', array( - 'CAT_NAME' => $user->lang($permission_categories[$cat]), + 'CAT_NAME' => $permissions->get_lang_category($cat), 'S_YES' => ($cat_array['S_YES'] && !$cat_array['S_NEVER'] && !$cat_array['S_NO']) ? true : false, 'S_NEVER' => ($cat_array['S_NEVER'] && !$cat_array['S_YES'] && !$cat_array['S_NO']) ? true : false, diff --git a/phpBB/includes/acp/acp_permissions.php b/phpBB/includes/acp/acp_permissions.php index 9c5395c5b2..13e0f1c535 100644 --- a/phpBB/includes/acp/acp_permissions.php +++ b/phpBB/includes/acp/acp_permissions.php @@ -587,10 +587,9 @@ class acp_permissions */ function build_permission_dropdown($options, $default_option, $permission_scope) { - global $user, $auth, $phpbb_container; + global $auth, $phpbb_container; $permissions = $phpbb_container->get('acl.permissions'); - $permission_types = $permissions->get_types(); $s_dropdown_options = ''; foreach ($options as $setting) @@ -601,8 +600,8 @@ class acp_permissions } $selected = ($setting == $default_option) ? ' selected="selected"' : ''; - $l_setting = (isset($permission_types[$permission_scope][$setting])) ? $permission_types[$permission_scope][$setting] : $permission_types[$setting]; - $s_dropdown_options .= ''; + $l_setting = $permissions->get_lang_type($setting, $permission_scope); + $s_dropdown_options .= ''; } return $s_dropdown_options; diff --git a/phpBB/includes/acp/auth.php b/phpBB/includes/acp/auth.php index 03cc0c1705..7a7ccc0c50 100644 --- a/phpBB/includes/acp/auth.php +++ b/phpBB/includes/acp/auth.php @@ -1103,7 +1103,6 @@ class auth_admin extends phpbb_auth global $template, $user, $phpbb_admin_path, $phpEx, $phpbb_container; $permissions = $phpbb_container->get('acl.permissions'); - $permission_categories = $permissions->get_categories(); @reset($category_array); while (list($cat, $cat_array) = each($category_array)) @@ -1113,7 +1112,7 @@ class auth_admin extends phpbb_auth 'S_NEVER' => ($cat_array['S_NEVER'] && !$cat_array['S_YES'] && !$cat_array['S_NO']) ? true : false, 'S_NO' => ($cat_array['S_NO'] && !$cat_array['S_NEVER'] && !$cat_array['S_YES']) ? true : false, - 'CAT_NAME' => $user->lang($permission_categories[$cat]), + 'CAT_NAME' => $permissions->get_lang_category($cat), )); /* Sort permissions by name (more naturaly and user friendly than sorting by a primary key) @@ -1182,7 +1181,6 @@ class auth_admin extends phpbb_auth global $user, $phpbb_container; $permissions = $phpbb_container->get('acl.permissions'); - $permission_categories = $permissions->get_categories(); foreach ($key_sort_array as $forum_id) { @@ -1210,7 +1208,7 @@ class auth_admin extends phpbb_auth // Build our categories array if (!isset($categories[$cat])) { - $categories[$cat] = $user->lang($permission_categories[$cat]); + $categories[$cat] = $permissions->get_lang_category($cat); } // Build our content array diff --git a/phpBB/includes/permissions.php b/phpBB/includes/permissions.php index ddeadc825b..f3b2ab5da0 100644 --- a/phpBB/includes/permissions.php +++ b/phpBB/includes/permissions.php @@ -83,6 +83,16 @@ class phpbb_permissions return $this->categories; } + /** + * Returns the language string of a permission category + * + * @return array Language string + */ + public function get_lang_category($category) + { + return $this->user->lang($this->categories[$category]); + } + /** * Returns an array with all the permission types (a_, u_, m_, etc.) * @@ -93,6 +103,25 @@ class phpbb_permissions return $this->types; } + /** + * Returns the language string of a permission type + * + * @return array Language string + */ + public function get_lang_type($type, $scope = false) + { + if ($scope && isset($this->types[$scope][$type])) + { + $lang_key = $this->types[$scope][$type]; + } + else + { + $lang_key = $this->types[$type]; + } + + return $this->user->lang($lang_key); + } + /** * Returns an array with all the permissions. * Each Permission has the following layout: From 9c653341e4d747302bdde1273fd71199ca3b40ef Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 6 Jul 2013 13:37:59 +0200 Subject: [PATCH 2237/2494] [ticket/11582] Use new methods and remove duplicated entries PHPBB3-11582 --- phpBB/includes/acp/acp_permission_roles.php | 12 +++--- phpBB/includes/acp/acp_permissions.php | 9 +++-- phpBB/includes/acp/auth.php | 13 +++--- phpBB/includes/permissions.php | 44 ++++++++++++++++----- phpBB/language/en/acp/permissions_phpbb.php | 8 ---- 5 files changed, 54 insertions(+), 32 deletions(-) diff --git a/phpBB/includes/acp/acp_permission_roles.php b/phpBB/includes/acp/acp_permission_roles.php index 2a00301543..f7c0494a0b 100644 --- a/phpBB/includes/acp/acp_permission_roles.php +++ b/phpBB/includes/acp/acp_permission_roles.php @@ -306,6 +306,9 @@ class acp_permission_roles trigger_error($user->lang['NO_ROLE_SELECTED'] . adm_back_link($this->u_action), E_USER_WARNING); } + global $phpbb_container; + $phpbb_permissions = $phpbb_container->get('acl.permissions'); + $template->assign_vars(array( 'S_EDIT' => true, @@ -314,9 +317,8 @@ class acp_permission_roles 'ROLE_NAME' => $role_row['role_name'], 'ROLE_DESCRIPTION' => $role_row['role_description'], - 'L_ACL_TYPE' => $user->lang['ACL_TYPE_' . strtoupper($permission_type)], - ) - ); + 'L_ACL_TYPE' => $phpbb_permissions->get_type_lang($permission_type), + )); // We need to fill the auth options array with ACL_NO options ;) $sql = 'SELECT auth_option_id, auth_option @@ -458,7 +460,7 @@ class acp_permission_roles { global $template, $user, $phpbb_container; - $permissions = $phpbb_container->get('acl.permissions'); + $phpbb_permissions = $phpbb_container->get('acl.permissions'); $content_array = $categories = array(); $key_sort_array = array(0); @@ -475,7 +477,7 @@ class acp_permission_roles foreach ($content_array as $cat => $cat_array) { $template->assign_block_vars('auth', array( - 'CAT_NAME' => $permissions->get_lang_category($cat), + 'CAT_NAME' => $phpbb_permissions->get_category_lang($cat), 'S_YES' => ($cat_array['S_YES'] && !$cat_array['S_NEVER'] && !$cat_array['S_NO']) ? true : false, 'S_NEVER' => ($cat_array['S_NEVER'] && !$cat_array['S_YES'] && !$cat_array['S_NO']) ? true : false, diff --git a/phpBB/includes/acp/acp_permissions.php b/phpBB/includes/acp/acp_permissions.php index 13e0f1c535..17c6561b65 100644 --- a/phpBB/includes/acp/acp_permissions.php +++ b/phpBB/includes/acp/acp_permissions.php @@ -510,9 +510,12 @@ class acp_permissions trigger_error($user->lang['ONLY_FORUM_DEFINED'] . adm_back_link($this->u_action), E_USER_WARNING); } + global $phpbb_container; + $phpbb_permissions = $phpbb_container->get('acl.permissions'); + $template->assign_vars(array( 'S_PERMISSION_DROPDOWN' => (sizeof($this->permission_dropdown) > 1) ? $this->build_permission_dropdown($this->permission_dropdown, $permission_type, $permission_scope) : false, - 'L_PERMISSION_TYPE' => $user->lang['ACL_TYPE_' . strtoupper($permission_type)], + 'L_PERMISSION_TYPE' => $phpbb_permissions->get_type_lang($permission_type), 'U_ACTION' => $this->u_action, 'S_HIDDEN_FIELDS' => $s_hidden_fields) @@ -589,7 +592,7 @@ class acp_permissions { global $auth, $phpbb_container; - $permissions = $phpbb_container->get('acl.permissions'); + $phpbb_permissions = $phpbb_container->get('acl.permissions'); $s_dropdown_options = ''; foreach ($options as $setting) @@ -600,7 +603,7 @@ class acp_permissions } $selected = ($setting == $default_option) ? ' selected="selected"' : ''; - $l_setting = $permissions->get_lang_type($setting, $permission_scope); + $l_setting = $phpbb_permissions->get_type_lang($setting, $permission_scope); $s_dropdown_options .= ''; } diff --git a/phpBB/includes/acp/auth.php b/phpBB/includes/acp/auth.php index 7a7ccc0c50..630deb991e 100644 --- a/phpBB/includes/acp/auth.php +++ b/phpBB/includes/acp/auth.php @@ -261,7 +261,8 @@ class auth_admin extends phpbb_auth */ function display_mask($mode, $permission_type, &$hold_ary, $user_mode = 'user', $local = false, $group_display = true) { - global $template, $user, $db, $phpbb_root_path, $phpEx; + global $template, $user, $db, $phpbb_root_path, $phpEx, $phpbb_container; + $phpbb_permissions = $phpbb_container->get('acl.permissions'); // Define names for template loops, might be able to be set $tpl_pmask = 'p_mask'; @@ -269,7 +270,7 @@ class auth_admin extends phpbb_auth $tpl_category = 'category'; $tpl_mask = 'mask'; - $l_acl_type = (isset($user->lang['ACL_TYPE_' . (($local) ? 'LOCAL' : 'GLOBAL') . '_' . strtoupper($permission_type)])) ? $user->lang['ACL_TYPE_' . (($local) ? 'LOCAL' : 'GLOBAL') . '_' . strtoupper($permission_type)] : 'ACL_TYPE_' . (($local) ? 'LOCAL' : 'GLOBAL') . '_' . strtoupper($permission_type); + $l_acl_type = $phpbb_permissions->get_type_lang($permission_type, (($local) ? 'local' : 'global')); // Allow trace for viewing permissions and in user mode $show_trace = ($mode == 'view' && $user_mode == 'user') ? true : false; @@ -1102,7 +1103,7 @@ class auth_admin extends phpbb_auth { global $template, $user, $phpbb_admin_path, $phpEx, $phpbb_container; - $permissions = $phpbb_container->get('acl.permissions'); + $phpbb_permissions = $phpbb_container->get('acl.permissions'); @reset($category_array); while (list($cat, $cat_array) = each($category_array)) @@ -1112,7 +1113,7 @@ class auth_admin extends phpbb_auth 'S_NEVER' => ($cat_array['S_NEVER'] && !$cat_array['S_YES'] && !$cat_array['S_NO']) ? true : false, 'S_NO' => ($cat_array['S_NO'] && !$cat_array['S_NEVER'] && !$cat_array['S_YES']) ? true : false, - 'CAT_NAME' => $permissions->get_lang_category($cat), + 'CAT_NAME' => $phpbb_permissions->get_category_lang($cat), )); /* Sort permissions by name (more naturaly and user friendly than sorting by a primary key) @@ -1180,7 +1181,7 @@ class auth_admin extends phpbb_auth { global $user, $phpbb_container; - $permissions = $phpbb_container->get('acl.permissions'); + $phpbb_permissions = $phpbb_container->get('acl.permissions'); foreach ($key_sort_array as $forum_id) { @@ -1208,7 +1209,7 @@ class auth_admin extends phpbb_auth // Build our categories array if (!isset($categories[$cat])) { - $categories[$cat] = $permissions->get_lang_category($cat); + $categories[$cat] = $phpbb_permissions->get_category_lang($cat); } // Build our content array diff --git a/phpBB/includes/permissions.php b/phpBB/includes/permissions.php index f3b2ab5da0..368fd7bc5f 100644 --- a/phpBB/includes/permissions.php +++ b/phpBB/includes/permissions.php @@ -86,9 +86,9 @@ class phpbb_permissions /** * Returns the language string of a permission category * - * @return array Language string + * @return string Language string */ - public function get_lang_category($category) + public function get_category_lang($category) { return $this->user->lang($this->categories[$category]); } @@ -106,18 +106,22 @@ class phpbb_permissions /** * Returns the language string of a permission type * - * @return array Language string + * @return string Language string */ - public function get_lang_type($type, $scope = false) + public function get_type_lang($type, $scope = false) { if ($scope && isset($this->types[$scope][$type])) { $lang_key = $this->types[$scope][$type]; } - else + else if (isset($this->types[$type])) { $lang_key = $this->types[$type]; } + else + { + $lang_key = 'ACL_TYPE_' . strtoupper(($scope) ? $scope . '_' . $type : $type); + } return $this->user->lang($lang_key); } @@ -144,13 +148,33 @@ class phpbb_permissions return $this->permissions; } + /** + * Returns the category of a permission + * + * @return string + */ + public function get_permission_category($permission) + { + return (isset($this->permissions[$permission]['cat'])) ? $this->permissions[$permission]['cat'] : 'misc'; + } + + /** + * Returns the language string of a permission + * + * @return string Language string + */ + public function get_permission_lang($permission) + { + return (isset($this->permissions[$permission]['lang'])) ? $this->user->lang($this->permissions[$permission]['lang']) : $this->user->lang('ACL_' . strtoupper($permission)); + } + protected $types = array( - 'u_' => 'ACL_TYPE_USER', - 'a_' => 'ACL_TYPE_ADMIN', - 'm_' => 'ACL_TYPE_MODERATOR', - 'f_' => 'ACL_TYPE_FORUM', + 'u_' => 'ACL_TYPE_U_', + 'a_' => 'ACL_TYPE_A_', + 'm_' => 'ACL_TYPE_M_', + 'f_' => 'ACL_TYPE_F_', 'global' => array( - 'm_' => 'ACL_TYPE_GLOBAL_MODERATOR', + 'm_' => 'ACL_TYPE_GLOBAL_M_', ), ); diff --git a/phpBB/language/en/acp/permissions_phpbb.php b/phpBB/language/en/acp/permissions_phpbb.php index 0a669a4b8d..4f2c9067d2 100644 --- a/phpBB/language/en/acp/permissions_phpbb.php +++ b/phpBB/language/en/acp/permissions_phpbb.php @@ -63,7 +63,6 @@ if (empty($lang) || !is_array($lang)) *
    */ -// Define categories and permission types $lang = array_merge($lang, array( 'ACL_CAT_ACTIONS' => 'Actions', 'ACL_CAT_CONTENT' => 'Content', @@ -79,13 +78,6 @@ $lang = array_merge($lang, array( 'ACL_CAT_SETTINGS' => 'Settings', 'ACL_CAT_TOPIC_ACTIONS' => 'Topic actions', 'ACL_CAT_USER_GROUP' => 'Users & Groups', - - - 'ACL_TYPE_USER' => 'User permissions', - 'ACL_TYPE_ADMIN' => 'Admin permissions', - 'ACL_TYPE_MODERATOR' => 'Moderator permissions', - 'ACL_TYPE_FORUM' => 'Forum permissions', - 'ACL_TYPE_GLOBAL_MODERATOR' => 'Global moderator permissions', )); // User Permissions From 22ba3de1a2902b09cb00748664ad2bf328f37734 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 6 Jul 2013 13:52:09 +0200 Subject: [PATCH 2238/2494] [ticket/11582] Use member isntead of a new variable everytime PHPBB3-11582 --- phpBB/includes/acp/acp_permissions.php | 20 +++++++++----------- phpBB/includes/permissions.php | 2 +- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/phpBB/includes/acp/acp_permissions.php b/phpBB/includes/acp/acp_permissions.php index 17c6561b65..ed7159996a 100644 --- a/phpBB/includes/acp/acp_permissions.php +++ b/phpBB/includes/acp/acp_permissions.php @@ -22,15 +22,18 @@ class acp_permissions { var $u_action; var $permission_dropdown; + protected $permissions; function main($id, $mode) { - global $db, $user, $auth, $template, $cache; + global $db, $user, $auth, $template, $cache, $phpbb_container; global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx; include_once($phpbb_root_path . 'includes/functions_user.' . $phpEx); include_once($phpbb_root_path . 'includes/acp/auth.' . $phpEx); + $this->permissions = $phpbb_container->get('acl.permissions'); + $auth_admin = new auth_admin(); $user->add_lang('acp/permissions'); @@ -49,7 +52,7 @@ class acp_permissions if ($user_id && isset($auth_admin->acl_options['id'][$permission]) && $auth->acl_get('a_viewauth')) { - $this->page_title = sprintf($user->lang['TRACE_PERMISSION'], $user->lang['acl_' . $permission]['lang']); + $this->page_title = sprintf($user->lang['TRACE_PERMISSION'], $this->permissions->get_permission_lang($permission)); $this->permission_trace($user_id, $forum_id, $permission); return; } @@ -510,12 +513,9 @@ class acp_permissions trigger_error($user->lang['ONLY_FORUM_DEFINED'] . adm_back_link($this->u_action), E_USER_WARNING); } - global $phpbb_container; - $phpbb_permissions = $phpbb_container->get('acl.permissions'); - $template->assign_vars(array( 'S_PERMISSION_DROPDOWN' => (sizeof($this->permission_dropdown) > 1) ? $this->build_permission_dropdown($this->permission_dropdown, $permission_type, $permission_scope) : false, - 'L_PERMISSION_TYPE' => $phpbb_permissions->get_type_lang($permission_type), + 'L_PERMISSION_TYPE' => $this->permissions->get_type_lang($permission_type), 'U_ACTION' => $this->u_action, 'S_HIDDEN_FIELDS' => $s_hidden_fields) @@ -590,9 +590,7 @@ class acp_permissions */ function build_permission_dropdown($options, $default_option, $permission_scope) { - global $auth, $phpbb_container; - - $phpbb_permissions = $phpbb_container->get('acl.permissions'); + global $auth; $s_dropdown_options = ''; foreach ($options as $setting) @@ -603,7 +601,7 @@ class acp_permissions } $selected = ($setting == $default_option) ? ' selected="selected"' : ''; - $l_setting = $phpbb_permissions->get_type_lang($setting, $permission_scope); + $l_setting = $this->permissions->get_type_lang($setting, $permission_scope); $s_dropdown_options .= ''; } @@ -984,7 +982,7 @@ class acp_permissions $back = request_var('back', 0); $template->assign_vars(array( - 'PERMISSION' => $user->lang['acl_' . $permission]['lang'], + 'PERMISSION' => $this->permissions->get_permission_lang($permission), 'PERMISSION_USERNAME' => $userdata['username'], 'FORUM_NAME' => $forum_name, diff --git a/phpBB/includes/permissions.php b/phpBB/includes/permissions.php index 368fd7bc5f..a450b12aed 100644 --- a/phpBB/includes/permissions.php +++ b/phpBB/includes/permissions.php @@ -165,7 +165,7 @@ class phpbb_permissions */ public function get_permission_lang($permission) { - return (isset($this->permissions[$permission]['lang'])) ? $this->user->lang($this->permissions[$permission]['lang']) : $this->user->lang('ACL_' . strtoupper($permission)); + return (isset($this->permissions['acl_' . $permission]['lang'])) ? $this->user->lang($this->permissions['acl_' . $permission]['lang']) : $this->user->lang('ACL_' . strtoupper($permission)); } protected $types = array( From aadff800dcadfdb21f3188feba754f0e93669781 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 6 Jul 2013 13:57:58 +0200 Subject: [PATCH 2239/2494] [ticket/11582] Remove left over calls to lang['acl_*'] PHPBB3-11582 --- phpBB/includes/acp/acp_permission_roles.php | 2 +- phpBB/includes/acp/auth.php | 18 +++++------------- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/phpBB/includes/acp/acp_permission_roles.php b/phpBB/includes/acp/acp_permission_roles.php index f7c0494a0b..7c972c74ba 100644 --- a/phpBB/includes/acp/acp_permission_roles.php +++ b/phpBB/includes/acp/acp_permission_roles.php @@ -492,7 +492,7 @@ class acp_permission_roles 'S_NO' => ($allowed == ACL_NO) ? true : false, 'FIELD_NAME' => $permission, - 'PERMISSION' => $user->lang['acl_' . $permission]['lang']) + 'PERMISSION' => $phpbb_permissions->get_permission_lang($permission) ); } } diff --git a/phpBB/includes/acp/auth.php b/phpBB/includes/acp/auth.php index 630deb991e..4ade9cab13 100644 --- a/phpBB/includes/acp/auth.php +++ b/phpBB/includes/acp/auth.php @@ -1148,8 +1148,8 @@ class auth_admin extends phpbb_auth 'U_TRACE' => ($show_trace) ? append_sid("{$phpbb_admin_path}index.$phpEx", "i=permissions&mode=trace&u=$ug_id&f=$forum_id&auth=$permission") : '', 'UA_TRACE' => ($show_trace) ? append_sid("{$phpbb_admin_path}index.$phpEx", "i=permissions&mode=trace&u=$ug_id&f=$forum_id&auth=$permission", false) : '', - 'PERMISSION' => $user->lang['acl_' . $permission]['lang']) - ); + 'PERMISSION' => $phpbb_permissions->get_permission_lang($permission), + )); } else { @@ -1166,8 +1166,8 @@ class auth_admin extends phpbb_auth 'U_TRACE' => ($show_trace) ? append_sid("{$phpbb_admin_path}index.$phpEx", "i=permissions&mode=trace&u=$ug_id&f=$forum_id&auth=$permission") : '', 'UA_TRACE' => ($show_trace) ? append_sid("{$phpbb_admin_path}index.$phpEx", "i=permissions&mode=trace&u=$ug_id&f=$forum_id&auth=$permission", false) : '', - 'PERMISSION' => $user->lang['acl_' . $permission]['lang']) - ); + 'PERMISSION' => $phpbb_permissions->get_permission_lang($permission), + )); } } } @@ -1196,15 +1196,7 @@ class auth_admin extends phpbb_auth @reset($permissions); while (list($permission, $auth_setting) = each($permissions)) { - if (!isset($user->lang['acl_' . $permission])) - { - $user->lang['acl_' . $permission] = array( - 'cat' => 'misc', - 'lang' => '{ acl_' . $permission . ' }' - ); - } - - $cat = $user->lang['acl_' . $permission]['cat']; + $cat = $phpbb_permissions->get_permission_category($permission); // Build our categories array if (!isset($categories[$cat])) From 0e86c0247381b141cba53b6ab3fbdba276c521e3 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 6 Jul 2013 15:55:25 +0200 Subject: [PATCH 2240/2494] [ticket/11582] Split permission language strings from logic PHPBB3-11582 --- phpBB/includes/permissions.php | 230 ++++++++++---------- phpBB/language/en/acp/permissions_phpbb.php | 229 ++++++++++--------- 2 files changed, 224 insertions(+), 235 deletions(-) diff --git a/phpBB/includes/permissions.php b/phpBB/includes/permissions.php index a450b12aed..4cb3356c53 100644 --- a/phpBB/includes/permissions.php +++ b/phpBB/includes/permissions.php @@ -197,139 +197,139 @@ class phpbb_permissions protected $permissions = array( // User Permissions - 'acl_u_viewprofile' => array('lang' => 'Can view profiles, memberlist and online list', 'cat' => 'profile'), - 'acl_u_chgname' => array('lang' => 'Can change username', 'cat' => 'profile'), - 'acl_u_chgpasswd' => array('lang' => 'Can change password', 'cat' => 'profile'), - 'acl_u_chgemail' => array('lang' => 'Can change email address', 'cat' => 'profile'), - 'acl_u_chgavatar' => array('lang' => 'Can change avatar', 'cat' => 'profile'), - 'acl_u_chggrp' => array('lang' => 'Can change default usergroup', 'cat' => 'profile'), - 'acl_u_chgprofileinfo' => array('lang' => 'Can change profile field information', 'cat' => 'profile'), + 'acl_u_viewprofile' => array('lang' => 'ACL_U_VIEWPROFILE', 'cat' => 'profile'), + 'acl_u_chgname' => array('lang' => 'ACL_U_CHGNAME', 'cat' => 'profile'), + 'acl_u_chgpasswd' => array('lang' => 'ACL_U_CHGPASSWD', 'cat' => 'profile'), + 'acl_u_chgemail' => array('lang' => 'ACL_U_CHGEMAIL', 'cat' => 'profile'), + 'acl_u_chgavatar' => array('lang' => 'ACL_U_CHGAVATAR', 'cat' => 'profile'), + 'acl_u_chggrp' => array('lang' => 'ACL_U_CHGGRP', 'cat' => 'profile'), + 'acl_u_chgprofileinfo' => array('lang' => 'ACL_U_CHGPROFILEINFO', 'cat' => 'profile'), - 'acl_u_attach' => array('lang' => 'Can attach files', 'cat' => 'post'), - 'acl_u_download' => array('lang' => 'Can download files', 'cat' => 'post'), - 'acl_u_savedrafts' => array('lang' => 'Can save drafts', 'cat' => 'post'), - 'acl_u_chgcensors' => array('lang' => 'Can disable word censors', 'cat' => 'post'), - 'acl_u_sig' => array('lang' => 'Can use signature', 'cat' => 'post'), + 'acl_u_attach' => array('lang' => 'ACL_U_ATTACH', 'cat' => 'post'), + 'acl_u_download' => array('lang' => 'ACL_U_DOWNLOAD', 'cat' => 'post'), + 'acl_u_savedrafts' => array('lang' => 'ACL_U_SAVEDRAFTS', 'cat' => 'post'), + 'acl_u_chgcensors' => array('lang' => 'ACL_U_CHGCENSORS', 'cat' => 'post'), + 'acl_u_sig' => array('lang' => 'ACL_U_SIG', 'cat' => 'post'), - 'acl_u_sendpm' => array('lang' => 'Can send private messages', 'cat' => 'pm'), - 'acl_u_masspm' => array('lang' => 'Can send messages to multiple users', 'cat' => 'pm'), - 'acl_u_masspm_group'=> array('lang' => 'Can send messages to groups', 'cat' => 'pm'), - 'acl_u_readpm' => array('lang' => 'Can read private messages', 'cat' => 'pm'), - 'acl_u_pm_edit' => array('lang' => 'Can edit own private messages', 'cat' => 'pm'), - 'acl_u_pm_delete' => array('lang' => 'Can remove private messages from own folder', 'cat' => 'pm'), - 'acl_u_pm_forward' => array('lang' => 'Can forward private messages', 'cat' => 'pm'), - 'acl_u_pm_emailpm' => array('lang' => 'Can email private messages', 'cat' => 'pm'), - 'acl_u_pm_printpm' => array('lang' => 'Can print private messages', 'cat' => 'pm'), - 'acl_u_pm_attach' => array('lang' => 'Can attach files in private messages', 'cat' => 'pm'), - 'acl_u_pm_download' => array('lang' => 'Can download files in private messages', 'cat' => 'pm'), - 'acl_u_pm_bbcode' => array('lang' => 'Can use BBCode in private messages', 'cat' => 'pm'), - 'acl_u_pm_smilies' => array('lang' => 'Can use smilies in private messages', 'cat' => 'pm'), - 'acl_u_pm_img' => array('lang' => 'Can use [img] BBCode tag in private messages', 'cat' => 'pm'), - 'acl_u_pm_flash' => array('lang' => 'Can use [flash] BBCode tag in private messages', 'cat' => 'pm'), + 'acl_u_sendpm' => array('lang' => 'ACL_U_SENDPM', 'cat' => 'pm'), + 'acl_u_masspm' => array('lang' => 'ACL_U_MASSPM', 'cat' => 'pm'), + 'acl_u_masspm_group'=> array('lang' => 'ACL_U_MASSPM_GROUP', 'cat' => 'pm'), + 'acl_u_readpm' => array('lang' => 'ACL_U_READPM', 'cat' => 'pm'), + 'acl_u_pm_edit' => array('lang' => 'ACL_U_PM_EDIT', 'cat' => 'pm'), + 'acl_u_pm_delete' => array('lang' => 'ACL_U_PM_DELETE', 'cat' => 'pm'), + 'acl_u_pm_forward' => array('lang' => 'ACL_U_PM_FORWARD', 'cat' => 'pm'), + 'acl_u_pm_emailpm' => array('lang' => 'ACL_U_PM_EMAILPM', 'cat' => 'pm'), + 'acl_u_pm_printpm' => array('lang' => 'ACL_U_PM_PRINTPM', 'cat' => 'pm'), + 'acl_u_pm_attach' => array('lang' => 'ACL_U_PM_ATTACH', 'cat' => 'pm'), + 'acl_u_pm_download' => array('lang' => 'ACL_U_PM_DOWNLOAD', 'cat' => 'pm'), + 'acl_u_pm_bbcode' => array('lang' => 'ACL_U_PM_BBCODE', 'cat' => 'pm'), + 'acl_u_pm_smilies' => array('lang' => 'ACL_U_PM_SMILIES', 'cat' => 'pm'), + 'acl_u_pm_img' => array('lang' => 'ACL_U_PM_IMG', 'cat' => 'pm'), + 'acl_u_pm_flash' => array('lang' => 'ACL_U_PM_FLASH', 'cat' => 'pm'), - 'acl_u_sendemail' => array('lang' => 'Can send emails', 'cat' => 'misc'), - 'acl_u_sendim' => array('lang' => 'Can send instant messages', 'cat' => 'misc'), - 'acl_u_ignoreflood' => array('lang' => 'Can ignore flood limit', 'cat' => 'misc'), - 'acl_u_hideonline' => array('lang' => 'Can hide online status', 'cat' => 'misc'), - 'acl_u_viewonline' => array('lang' => 'Can view hidden online users', 'cat' => 'misc'), - 'acl_u_search' => array('lang' => 'Can search board', 'cat' => 'misc'), + 'acl_u_sendemail' => array('lang' => 'ACL_U_SENDEMAIL', 'cat' => 'misc'), + 'acl_u_sendim' => array('lang' => 'ACL_U_SENDIM', 'cat' => 'misc'), + 'acl_u_ignoreflood' => array('lang' => 'ACL_U_IGNOREFLOOD', 'cat' => 'misc'), + 'acl_u_hideonline' => array('lang' => 'ACL_U_HIDEONLINE', 'cat' => 'misc'), + 'acl_u_viewonline' => array('lang' => 'ACL_U_VIEWONLINE', 'cat' => 'misc'), + 'acl_u_search' => array('lang' => 'ACL_U_SEARCH', 'cat' => 'misc'), // Forum Permissions - 'acl_f_list' => array('lang' => 'Can see forum', 'cat' => 'actions'), - 'acl_f_read' => array('lang' => 'Can read forum', 'cat' => 'actions'), - 'acl_f_search' => array('lang' => 'Can search the forum', 'cat' => 'actions'), - 'acl_f_subscribe' => array('lang' => 'Can subscribe forum', 'cat' => 'actions'), - 'acl_f_print' => array('lang' => 'Can print topics', 'cat' => 'actions'), - 'acl_f_email' => array('lang' => 'Can email topics', 'cat' => 'actions'), - 'acl_f_bump' => array('lang' => 'Can bump topics', 'cat' => 'actions'), - 'acl_f_user_lock' => array('lang' => 'Can lock own topics', 'cat' => 'actions'), - 'acl_f_download' => array('lang' => 'Can download files', 'cat' => 'actions'), - 'acl_f_report' => array('lang' => 'Can report posts', 'cat' => 'actions'), + 'acl_f_list' => array('lang' => 'ACL_F_LIST', 'cat' => 'actions'), + 'acl_f_read' => array('lang' => 'ACL_F_READ', 'cat' => 'actions'), + 'acl_f_search' => array('lang' => 'ACL_F_SEARCH', 'cat' => 'actions'), + 'acl_f_subscribe' => array('lang' => 'ACL_F_SUBSCRIBE', 'cat' => 'actions'), + 'acl_f_print' => array('lang' => 'ACL_F_PRINT', 'cat' => 'actions'), + 'acl_f_email' => array('lang' => 'ACL_F_EMAIL', 'cat' => 'actions'), + 'acl_f_bump' => array('lang' => 'ACL_F_BUMP', 'cat' => 'actions'), + 'acl_f_user_lock' => array('lang' => 'ACL_F_USER_LOCK', 'cat' => 'actions'), + 'acl_f_download' => array('lang' => 'ACL_F_DOWNLOAD', 'cat' => 'actions'), + 'acl_f_report' => array('lang' => 'ACL_F_REPORT', 'cat' => 'actions'), - 'acl_f_post' => array('lang' => 'Can start new topics', 'cat' => 'post'), - 'acl_f_sticky' => array('lang' => 'Can post stickies', 'cat' => 'post'), - 'acl_f_announce' => array('lang' => 'Can post announcements', 'cat' => 'post'), - 'acl_f_reply' => array('lang' => 'Can reply to topics', 'cat' => 'post'), - 'acl_f_edit' => array('lang' => 'Can edit own posts', 'cat' => 'post'), - 'acl_f_delete' => array('lang' => 'Can delete own posts', 'cat' => 'post'), - 'acl_f_ignoreflood' => array('lang' => 'Can ignore flood limit', 'cat' => 'post'), - 'acl_f_postcount' => array('lang' => 'Increment post counter
    Please note that this setting only affects new posts.', 'cat' => 'post'), - 'acl_f_noapprove' => array('lang' => 'Can post without approval', 'cat' => 'post'), + 'acl_f_post' => array('lang' => 'ACL_F_POST', 'cat' => 'post'), + 'acl_f_sticky' => array('lang' => 'ACL_F_STICKY', 'cat' => 'post'), + 'acl_f_announce' => array('lang' => 'ACL_F_ANNOUNCE', 'cat' => 'post'), + 'acl_f_reply' => array('lang' => 'ACL_F_REPLY', 'cat' => 'post'), + 'acl_f_edit' => array('lang' => 'ACL_F_EDIT', 'cat' => 'post'), + 'acl_f_delete' => array('lang' => 'ACL_F_DELETE', 'cat' => 'post'), + 'acl_f_ignoreflood' => array('lang' => 'ACL_F_IGNOREFLOOD', 'cat' => 'post'), + 'acl_f_postcount' => array('lang' => 'ACL_F_POSTCOUNT', 'cat' => 'post'), + 'acl_f_noapprove' => array('lang' => 'ACL_F_NOAPPROVE', 'cat' => 'post'), - 'acl_f_attach' => array('lang' => 'Can attach files', 'cat' => 'content'), - 'acl_f_icons' => array('lang' => 'Can use topic/post icons', 'cat' => 'content'), - 'acl_f_bbcode' => array('lang' => 'Can use BBCode', 'cat' => 'content'), - 'acl_f_flash' => array('lang' => 'Can use [flash] BBCode tag', 'cat' => 'content'), - 'acl_f_img' => array('lang' => 'Can use [img] BBCode tag', 'cat' => 'content'), - 'acl_f_sigs' => array('lang' => 'Can use signatures', 'cat' => 'content'), - 'acl_f_smilies' => array('lang' => 'Can use smilies', 'cat' => 'content'), + 'acl_f_attach' => array('lang' => 'ACL_F_ATTACH', 'cat' => 'content'), + 'acl_f_icons' => array('lang' => 'ACL_F_ICONS', 'cat' => 'content'), + 'acl_f_bbcode' => array('lang' => 'ACL_F_BBCODE', 'cat' => 'content'), + 'acl_f_flash' => array('lang' => 'ACL_F_FLASH', 'cat' => 'content'), + 'acl_f_img' => array('lang' => 'ACL_F_IMG', 'cat' => 'content'), + 'acl_f_sigs' => array('lang' => 'ACL_F_SIGS', 'cat' => 'content'), + 'acl_f_smilies' => array('lang' => 'ACL_F_SMILIES', 'cat' => 'content'), - 'acl_f_poll' => array('lang' => 'Can create polls', 'cat' => 'polls'), - 'acl_f_vote' => array('lang' => 'Can vote in polls', 'cat' => 'polls'), - 'acl_f_votechg' => array('lang' => 'Can change existing vote', 'cat' => 'polls'), + 'acl_f_poll' => array('lang' => 'ACL_F_POLL', 'cat' => 'polls'), + 'acl_f_vote' => array('lang' => 'ACL_F_VOTE', 'cat' => 'polls'), + 'acl_f_votechg' => array('lang' => 'ACL_F_VOTECHG', 'cat' => 'polls'), // Moderator Permissions - 'acl_m_edit' => array('lang' => 'Can edit posts', 'cat' => 'post_actions'), - 'acl_m_delete' => array('lang' => 'Can delete posts', 'cat' => 'post_actions'), - 'acl_m_approve' => array('lang' => 'Can approve posts', 'cat' => 'post_actions'), - 'acl_m_report' => array('lang' => 'Can close and delete reports', 'cat' => 'post_actions'), - 'acl_m_chgposter' => array('lang' => 'Can change post author', 'cat' => 'post_actions'), + 'acl_m_edit' => array('lang' => 'ACL_M_EDIT', 'cat' => 'post_actions'), + 'acl_m_delete' => array('lang' => 'ACL_M_DELETE', 'cat' => 'post_actions'), + 'acl_m_approve' => array('lang' => 'ACL_M_APPROVE', 'cat' => 'post_actions'), + 'acl_m_report' => array('lang' => 'ACL_M_REPORT', 'cat' => 'post_actions'), + 'acl_m_chgposter' => array('lang' => 'ACL_M_CHGPOSTER', 'cat' => 'post_actions'), - 'acl_m_move' => array('lang' => 'Can move topics', 'cat' => 'topic_actions'), - 'acl_m_lock' => array('lang' => 'Can lock topics', 'cat' => 'topic_actions'), - 'acl_m_split' => array('lang' => 'Can split topics', 'cat' => 'topic_actions'), - 'acl_m_merge' => array('lang' => 'Can merge topics', 'cat' => 'topic_actions'), + 'acl_m_move' => array('lang' => 'ACL_M_MOVE', 'cat' => 'topic_actions'), + 'acl_m_lock' => array('lang' => 'ACL_M_LOCK', 'cat' => 'topic_actions'), + 'acl_m_split' => array('lang' => 'ACL_M_SPLIT', 'cat' => 'topic_actions'), + 'acl_m_merge' => array('lang' => 'ACL_M_MERGE', 'cat' => 'topic_actions'), - 'acl_m_info' => array('lang' => 'Can view post details', 'cat' => 'misc'), - 'acl_m_warn' => array('lang' => 'Can issue warnings
    This setting is only assigned globally. It is not forum based.', 'cat' => 'misc'), // This moderator setting is only global (and not local) - 'acl_m_ban' => array('lang' => 'Can manage bans
    This setting is only assigned globally. It is not forum based.', 'cat' => 'misc'), // This moderator setting is only global (and not local) + 'acl_m_info' => array('lang' => 'ACL_M_INFO', 'cat' => 'misc'), + 'acl_m_warn' => array('lang' => 'ACL_M_WARN', 'cat' => 'misc'), + 'acl_m_ban' => array('lang' => 'ACL_M_BAN', 'cat' => 'misc'), // Admin Permissions - 'acl_a_board' => array('lang' => 'Can alter board settings/check for updates', 'cat' => 'settings'), - 'acl_a_server' => array('lang' => 'Can alter server/communication settings', 'cat' => 'settings'), - 'acl_a_jabber' => array('lang' => 'Can alter Jabber settings', 'cat' => 'settings'), - 'acl_a_phpinfo' => array('lang' => 'Can view php settings', 'cat' => 'settings'), + 'acl_a_board' => array('lang' => 'ACL_A_BOARD', 'cat' => 'settings'), + 'acl_a_server' => array('lang' => 'ACL_A_SERVER', 'cat' => 'settings'), + 'acl_a_jabber' => array('lang' => 'ACL_A_JABBER', 'cat' => 'settings'), + 'acl_a_phpinfo' => array('lang' => 'ACL_A_PHPINFO', 'cat' => 'settings'), - 'acl_a_forum' => array('lang' => 'Can manage forums', 'cat' => 'forums'), - 'acl_a_forumadd' => array('lang' => 'Can add new forums', 'cat' => 'forums'), - 'acl_a_forumdel' => array('lang' => 'Can delete forums', 'cat' => 'forums'), - 'acl_a_prune' => array('lang' => 'Can prune forums', 'cat' => 'forums'), + 'acl_a_forum' => array('lang' => 'ACL_A_FORUM', 'cat' => 'forums'), + 'acl_a_forumadd' => array('lang' => 'ACL_A_FORUMADD', 'cat' => 'forums'), + 'acl_a_forumdel' => array('lang' => 'ACL_A_FORUMDEL', 'cat' => 'forums'), + 'acl_a_prune' => array('lang' => 'ACL_A_PRUNE', 'cat' => 'forums'), - 'acl_a_icons' => array('lang' => 'Can alter topic/post icons and smilies', 'cat' => 'posting'), - 'acl_a_words' => array('lang' => 'Can alter word censors', 'cat' => 'posting'), - 'acl_a_bbcode' => array('lang' => 'Can define BBCode tags', 'cat' => 'posting'), - 'acl_a_attach' => array('lang' => 'Can alter attachment related settings', 'cat' => 'posting'), + 'acl_a_icons' => array('lang' => 'ACL_A_ICONS', 'cat' => 'posting'), + 'acl_a_words' => array('lang' => 'ACL_A_WORDS', 'cat' => 'posting'), + 'acl_a_bbcode' => array('lang' => 'ACL_A_BBCODE', 'cat' => 'posting'), + 'acl_a_attach' => array('lang' => 'ACL_A_ATTACH', 'cat' => 'posting'), - 'acl_a_user' => array('lang' => 'Can manage users
    This also includes seeing the users browser agent within the viewonline list.', 'cat' => 'user_group'), - 'acl_a_userdel' => array('lang' => 'Can delete/prune users', 'cat' => 'user_group'), - 'acl_a_group' => array('lang' => 'Can manage groups', 'cat' => 'user_group'), - 'acl_a_groupadd' => array('lang' => 'Can add new groups', 'cat' => 'user_group'), - 'acl_a_groupdel' => array('lang' => 'Can delete groups', 'cat' => 'user_group'), - 'acl_a_ranks' => array('lang' => 'Can manage ranks', 'cat' => 'user_group'), - 'acl_a_profile' => array('lang' => 'Can manage custom profile fields', 'cat' => 'user_group'), - 'acl_a_names' => array('lang' => 'Can manage disallowed names', 'cat' => 'user_group'), - 'acl_a_ban' => array('lang' => 'Can manage bans', 'cat' => 'user_group'), + 'acl_a_user' => array('lang' => 'ACL_A_USER', 'cat' => 'user_group'), + 'acl_a_userdel' => array('lang' => 'ACL_A_USERDEL', 'cat' => 'user_group'), + 'acl_a_group' => array('lang' => 'ACL_A_GROUP', 'cat' => 'user_group'), + 'acl_a_groupadd' => array('lang' => 'ACL_A_GROUPADD', 'cat' => 'user_group'), + 'acl_a_groupdel' => array('lang' => 'ACL_A_GROUPDEL', 'cat' => 'user_group'), + 'acl_a_ranks' => array('lang' => 'ACL_A_RANKS', 'cat' => 'user_group'), + 'acl_a_profile' => array('lang' => 'ACL_A_PROFILE', 'cat' => 'user_group'), + 'acl_a_names' => array('lang' => 'ACL_A_NAMES', 'cat' => 'user_group'), + 'acl_a_ban' => array('lang' => 'ACL_A_BAN', 'cat' => 'user_group'), - 'acl_a_viewauth' => array('lang' => 'Can view permission masks', 'cat' => 'permissions'), - 'acl_a_authgroups' => array('lang' => 'Can alter permissions for individual groups', 'cat' => 'permissions'), - 'acl_a_authusers' => array('lang' => 'Can alter permissions for individual users', 'cat' => 'permissions'), - 'acl_a_fauth' => array('lang' => 'Can alter forum permission class', 'cat' => 'permissions'), - 'acl_a_mauth' => array('lang' => 'Can alter moderator permission class', 'cat' => 'permissions'), - 'acl_a_aauth' => array('lang' => 'Can alter admin permission class', 'cat' => 'permissions'), - 'acl_a_uauth' => array('lang' => 'Can alter user permission class', 'cat' => 'permissions'), - 'acl_a_roles' => array('lang' => 'Can manage roles', 'cat' => 'permissions'), - 'acl_a_switchperm' => array('lang' => 'Can use others permissions', 'cat' => 'permissions'), + 'acl_a_viewauth' => array('lang' => 'ACL_A_VIEWAUTH', 'cat' => 'permissions'), + 'acl_a_authgroups' => array('lang' => 'ACL_A_AUTHGROUPS', 'cat' => 'permissions'), + 'acl_a_authusers' => array('lang' => 'ACL_A_AUTHUSERS', 'cat' => 'permissions'), + 'acl_a_fauth' => array('lang' => 'ACL_A_FAUTH', 'cat' => 'permissions'), + 'acl_a_mauth' => array('lang' => 'ACL_A_MAUTH', 'cat' => 'permissions'), + 'acl_a_aauth' => array('lang' => 'ACL_A_AAUTH', 'cat' => 'permissions'), + 'acl_a_uauth' => array('lang' => 'ACL_A_UAUTH', 'cat' => 'permissions'), + 'acl_a_roles' => array('lang' => 'ACL_A_ROLES', 'cat' => 'permissions'), + 'acl_a_switchperm' => array('lang' => 'ACL_A_SWITCHPERM', 'cat' => 'permissions'), - 'acl_a_styles' => array('lang' => 'Can manage styles', 'cat' => 'misc'), - 'acl_a_extensions' => array('lang' => 'Can manage extensions', 'cat' => 'misc'), - 'acl_a_viewlogs' => array('lang' => 'Can view logs', 'cat' => 'misc'), - 'acl_a_clearlogs' => array('lang' => 'Can clear logs', 'cat' => 'misc'), - 'acl_a_modules' => array('lang' => 'Can manage modules', 'cat' => 'misc'), - 'acl_a_language' => array('lang' => 'Can manage language packs', 'cat' => 'misc'), - 'acl_a_email' => array('lang' => 'Can send mass email', 'cat' => 'misc'), - 'acl_a_bots' => array('lang' => 'Can manage bots', 'cat' => 'misc'), - 'acl_a_reasons' => array('lang' => 'Can manage report/denial reasons', 'cat' => 'misc'), - 'acl_a_backup' => array('lang' => 'Can backup/restore database', 'cat' => 'misc'), - 'acl_a_search' => array('lang' => 'Can manage search backends and settings', 'cat' => 'misc'), + 'acl_a_styles' => array('lang' => 'ACL_A_STYLES', 'cat' => 'misc'), + 'acl_a_extensions' => array('lang' => 'ACL_A_EXTENSIONS', 'cat' => 'misc'), + 'acl_a_viewlogs' => array('lang' => 'ACL_A_VIEWLOGS', 'cat' => 'misc'), + 'acl_a_clearlogs' => array('lang' => 'ACL_A_CLEARLOGS', 'cat' => 'misc'), + 'acl_a_modules' => array('lang' => 'ACL_A_MODULES', 'cat' => 'misc'), + 'acl_a_language' => array('lang' => 'ACL_A_LANGUAGE', 'cat' => 'misc'), + 'acl_a_email' => array('lang' => 'ACL_A_EMAIL', 'cat' => 'misc'), + 'acl_a_bots' => array('lang' => 'ACL_A_BOTS', 'cat' => 'misc'), + 'acl_a_reasons' => array('lang' => 'ACL_A_REASONS', 'cat' => 'misc'), + 'acl_a_backup' => array('lang' => 'ACL_A_BACKUP', 'cat' => 'misc'), + 'acl_a_search' => array('lang' => 'ACL_A_SEARCH', 'cat' => 'misc'), ); } diff --git a/phpBB/language/en/acp/permissions_phpbb.php b/phpBB/language/en/acp/permissions_phpbb.php index 4f2c9067d2..edcc812830 100644 --- a/phpBB/language/en/acp/permissions_phpbb.php +++ b/phpBB/language/en/acp/permissions_phpbb.php @@ -56,8 +56,8 @@ if (empty($lang) || !is_array($lang)) * * // Adding the permissions * $lang = array_merge($lang, array( -* 'acl_bug_view' => array('lang' => 'Can view bug reports', 'cat' => 'bugs'), -* 'acl_bug_post' => array('lang' => 'Can post bugs', 'cat' => 'post'), // Using a phpBB category here +* 'acl_bug_view' => 'Can view bug reports', 'cat' => 'bugs'), +* 'acl_bug_post' => 'Can post bugs', // Using a phpBB category here * )); * *
    @@ -82,146 +82,135 @@ $lang = array_merge($lang, array( // User Permissions $lang = array_merge($lang, array( - 'acl_u_viewprofile' => array('lang' => 'Can view profiles, memberlist and online list', 'cat' => 'profile'), - 'acl_u_chgname' => array('lang' => 'Can change username', 'cat' => 'profile'), - 'acl_u_chgpasswd' => array('lang' => 'Can change password', 'cat' => 'profile'), - 'acl_u_chgemail' => array('lang' => 'Can change email address', 'cat' => 'profile'), - 'acl_u_chgavatar' => array('lang' => 'Can change avatar', 'cat' => 'profile'), - 'acl_u_chggrp' => array('lang' => 'Can change default usergroup', 'cat' => 'profile'), - 'acl_u_chgprofileinfo' => array('lang' => 'Can change profile field information', 'cat' => 'profile'), + 'ACL_U_VIEWPROFILE' => 'Can view profiles, memberlist and online list', + 'ACL_U_CHGNAME' => 'Can change username', + 'ACL_U_CHGPASSWD' => 'Can change password', + 'ACL_U_CHGEMAIL' => 'Can change email address', + 'ACL_U_CHGAVATAR' => 'Can change avatar', + 'ACL_U_CHGGRP' => 'Can change default usergroup', + 'ACL_U_CHGPROFILEINFO' => 'Can change profile field information', - 'acl_u_attach' => array('lang' => 'Can attach files', 'cat' => 'post'), - 'acl_u_download' => array('lang' => 'Can download files', 'cat' => 'post'), - 'acl_u_savedrafts' => array('lang' => 'Can save drafts', 'cat' => 'post'), - 'acl_u_chgcensors' => array('lang' => 'Can disable word censors', 'cat' => 'post'), - 'acl_u_sig' => array('lang' => 'Can use signature', 'cat' => 'post'), + 'ACL_U_ATTACH' => 'Can attach files', + 'ACL_U_DOWNLOAD' => 'Can download files', + 'ACL_U_SAVEDRAFTS' => 'Can save drafts', + 'ACL_U_CHGCENSORS' => 'Can disable word censors', + 'ACL_U_SIG' => 'Can use signature', - 'acl_u_sendpm' => array('lang' => 'Can send private messages', 'cat' => 'pm'), - 'acl_u_masspm' => array('lang' => 'Can send messages to multiple users', 'cat' => 'pm'), - 'acl_u_masspm_group'=> array('lang' => 'Can send messages to groups', 'cat' => 'pm'), - 'acl_u_readpm' => array('lang' => 'Can read private messages', 'cat' => 'pm'), - 'acl_u_pm_edit' => array('lang' => 'Can edit own private messages', 'cat' => 'pm'), - 'acl_u_pm_delete' => array('lang' => 'Can remove private messages from own folder', 'cat' => 'pm'), - 'acl_u_pm_forward' => array('lang' => 'Can forward private messages', 'cat' => 'pm'), - 'acl_u_pm_emailpm' => array('lang' => 'Can email private messages', 'cat' => 'pm'), - 'acl_u_pm_printpm' => array('lang' => 'Can print private messages', 'cat' => 'pm'), - 'acl_u_pm_attach' => array('lang' => 'Can attach files in private messages', 'cat' => 'pm'), - 'acl_u_pm_download' => array('lang' => 'Can download files in private messages', 'cat' => 'pm'), - 'acl_u_pm_bbcode' => array('lang' => 'Can use BBCode in private messages', 'cat' => 'pm'), - 'acl_u_pm_smilies' => array('lang' => 'Can use smilies in private messages', 'cat' => 'pm'), - 'acl_u_pm_img' => array('lang' => 'Can use [img] BBCode tag in private messages', 'cat' => 'pm'), - 'acl_u_pm_flash' => array('lang' => 'Can use [flash] BBCode tag in private messages', 'cat' => 'pm'), + 'ACL_U_SENDPM' => 'Can send private messages', + 'ACL_U_MASSPM' => 'Can send messages to multiple users', + 'ACL_U_MASSPM_GROUP'=> 'Can send messages to groups', + 'ACL_U_READPM' => 'Can read private messages', + 'ACL_U_PM_EDIT' => 'Can edit own private messages', + 'ACL_U_PM_DELETE' => 'Can remove private messages from own folder', + 'ACL_U_PM_FORWARD' => 'Can forward private messages', + 'ACL_U_PM_EMAILPM' => 'Can email private messages', + 'ACL_U_PM_PRINTPM' => 'Can print private messages', + 'ACL_U_PM_ATTACH' => 'Can attach files in private messages', + 'ACL_U_PM_DOWNLOAD' => 'Can download files in private messages', + 'ACL_U_PM_BBCODE' => 'Can use BBCode in private messages', + 'ACL_U_PM_SMILIES' => 'Can use smilies in private messages', + 'ACL_U_PM_IMG' => 'Can use [img] BBCode tag in private messages', + 'ACL_U_PM_FLASH' => 'Can use [flash] BBCode tag in private messages', - 'acl_u_sendemail' => array('lang' => 'Can send emails', 'cat' => 'misc'), - 'acl_u_sendim' => array('lang' => 'Can send instant messages', 'cat' => 'misc'), - 'acl_u_ignoreflood' => array('lang' => 'Can ignore flood limit', 'cat' => 'misc'), - 'acl_u_hideonline' => array('lang' => 'Can hide online status', 'cat' => 'misc'), - 'acl_u_viewonline' => array('lang' => 'Can view hidden online users', 'cat' => 'misc'), - 'acl_u_search' => array('lang' => 'Can search board', 'cat' => 'misc'), + 'ACL_U_SENDEMAIL' => 'Can send emails', + 'ACL_U_SENDIM' => 'Can send instant messages', + 'ACL_U_IGNOREFLOOD' => 'Can ignore flood limit', + 'ACL_U_HIDEONLINE' => 'Can hide online status', + 'ACL_U_VIEWONLINE' => 'Can view hidden online users', + 'ACL_U_SEARCH' => 'Can search board', )); // Forum Permissions $lang = array_merge($lang, array( - 'acl_f_list' => array('lang' => 'Can see forum', 'cat' => 'actions'), - 'acl_f_read' => array('lang' => 'Can read forum', 'cat' => 'actions'), - 'acl_f_search' => array('lang' => 'Can search the forum', 'cat' => 'actions'), - 'acl_f_subscribe' => array('lang' => 'Can subscribe forum', 'cat' => 'actions'), - 'acl_f_print' => array('lang' => 'Can print topics', 'cat' => 'actions'), - 'acl_f_email' => array('lang' => 'Can email topics', 'cat' => 'actions'), - 'acl_f_bump' => array('lang' => 'Can bump topics', 'cat' => 'actions'), - 'acl_f_user_lock' => array('lang' => 'Can lock own topics', 'cat' => 'actions'), - 'acl_f_download' => array('lang' => 'Can download files', 'cat' => 'actions'), - 'acl_f_report' => array('lang' => 'Can report posts', 'cat' => 'actions'), + 'ACL_F_POST' => 'Can start new topics', + 'ACL_F_STICKY' => 'Can post stickies', + 'ACL_F_ANNOUNCE' => 'Can post announcements', + 'ACL_F_REPLY' => 'Can reply to topics', + 'ACL_F_EDIT' => 'Can edit own posts', + 'ACL_F_DELETE' => 'Can permanently delete own posts', + 'ACL_F_SOFTDELETE' => 'Can soft delete own posts
    Moderators, who have the approve posts permission, can restore soft deleted posts.', + 'ACL_F_IGNOREFLOOD' => 'Can ignore flood limit', + 'ACL_F_POSTCOUNT' => 'Increment post counter
    Please note that this setting only affects new posts.', + 'ACL_F_NOAPPROVE' => 'Can post without approval', - 'acl_f_post' => array('lang' => 'Can start new topics', 'cat' => 'post'), - 'acl_f_sticky' => array('lang' => 'Can post stickies', 'cat' => 'post'), - 'acl_f_announce' => array('lang' => 'Can post announcements', 'cat' => 'post'), - 'acl_f_reply' => array('lang' => 'Can reply to topics', 'cat' => 'post'), - 'acl_f_edit' => array('lang' => 'Can edit own posts', 'cat' => 'post'), - 'acl_f_delete' => array('lang' => 'Can permanently delete own posts', 'cat' => 'post'), - 'acl_f_softdelete' => array('lang' => 'Can soft delete own posts
    Moderators, who have the approve posts permission, can restore soft deleted posts.', 'cat' => 'post'), - 'acl_f_ignoreflood' => array('lang' => 'Can ignore flood limit', 'cat' => 'post'), - 'acl_f_postcount' => array('lang' => 'Increment post counter
    Please note that this setting only affects new posts.', 'cat' => 'post'), - 'acl_f_noapprove' => array('lang' => 'Can post without approval', 'cat' => 'post'), + 'ACL_F_ATTACH' => 'Can attach files', + 'ACL_F_ICONS' => 'Can use topic/post icons', + 'ACL_F_BBCODE' => 'Can use BBCode', + 'ACL_F_FLASH' => 'Can use [flash] BBCode tag', + 'ACL_F_IMG' => 'Can use [img] BBCode tag', + 'ACL_F_SIGS' => 'Can use signatures', + 'ACL_F_SMILIES' => 'Can use smilies', - 'acl_f_attach' => array('lang' => 'Can attach files', 'cat' => 'content'), - 'acl_f_icons' => array('lang' => 'Can use topic/post icons', 'cat' => 'content'), - 'acl_f_bbcode' => array('lang' => 'Can use BBCode', 'cat' => 'content'), - 'acl_f_flash' => array('lang' => 'Can use [flash] BBCode tag', 'cat' => 'content'), - 'acl_f_img' => array('lang' => 'Can use [img] BBCode tag', 'cat' => 'content'), - 'acl_f_sigs' => array('lang' => 'Can use signatures', 'cat' => 'content'), - 'acl_f_smilies' => array('lang' => 'Can use smilies', 'cat' => 'content'), - - 'acl_f_poll' => array('lang' => 'Can create polls', 'cat' => 'polls'), - 'acl_f_vote' => array('lang' => 'Can vote in polls', 'cat' => 'polls'), - 'acl_f_votechg' => array('lang' => 'Can change existing vote', 'cat' => 'polls'), + 'ACL_F_POLL' => 'Can create polls', + 'ACL_F_VOTE' => 'Can vote in polls', + 'ACL_F_VOTECHG' => 'Can change existing vote', )); // Moderator Permissions $lang = array_merge($lang, array( - 'acl_m_edit' => array('lang' => 'Can edit posts', 'cat' => 'post_actions'), - 'acl_m_delete' => array('lang' => 'Can permanently delete posts', 'cat' => 'post_actions'), - 'acl_m_softdelete' => array('lang' => 'Can soft delete posts
    Moderators, who have the approve posts permission, can restore soft deleted posts.', 'cat' => 'post_actions'), - 'acl_m_approve' => array('lang' => 'Can approve and restore posts', 'cat' => 'post_actions'), - 'acl_m_report' => array('lang' => 'Can close and delete reports', 'cat' => 'post_actions'), - 'acl_m_chgposter' => array('lang' => 'Can change post author', 'cat' => 'post_actions'), + 'ACL_M_EDIT' => 'Can edit posts', + 'ACL_M_DELETE' => 'Can permanently delete posts', + 'ACL_M_SOFTDELETE' => 'Can soft delete posts
    Moderators, who have the approve posts permission, can restore soft deleted posts.', + 'ACL_M_APPROVE' => 'Can approve posts', + 'ACL_M_REPORT' => 'Can close and delete reports', + 'ACL_M_CHGPOSTER' => 'Can change post author', - 'acl_m_move' => array('lang' => 'Can move topics', 'cat' => 'topic_actions'), - 'acl_m_lock' => array('lang' => 'Can lock topics', 'cat' => 'topic_actions'), - 'acl_m_split' => array('lang' => 'Can split topics', 'cat' => 'topic_actions'), - 'acl_m_merge' => array('lang' => 'Can merge topics', 'cat' => 'topic_actions'), + 'ACL_M_MOVE' => 'Can move topics', + 'ACL_M_LOCK' => 'Can lock topics', + 'ACL_M_SPLIT' => 'Can split topics', + 'ACL_M_MERGE' => 'Can merge topics', - 'acl_m_info' => array('lang' => 'Can view post details', 'cat' => 'misc'), - 'acl_m_warn' => array('lang' => 'Can issue warnings
    This setting is only assigned globally. It is not forum based.', 'cat' => 'misc'), // This moderator setting is only global (and not local) - 'acl_m_ban' => array('lang' => 'Can manage bans
    This setting is only assigned globally. It is not forum based.', 'cat' => 'misc'), // This moderator setting is only global (and not local) + 'ACL_M_INFO' => 'Can view post details', + 'ACL_M_WARN' => 'Can issue warnings
    This setting is only assigned globally. It is not forum based.', // This moderator setting is only global (and not local) + 'ACL_M_BAN' => 'Can manage bans
    This setting is only assigned globally. It is not forum based.', // This moderator setting is only global (and not local) )); // Admin Permissions $lang = array_merge($lang, array( - 'acl_a_board' => array('lang' => 'Can alter board settings/check for updates', 'cat' => 'settings'), - 'acl_a_server' => array('lang' => 'Can alter server/communication settings', 'cat' => 'settings'), - 'acl_a_jabber' => array('lang' => 'Can alter Jabber settings', 'cat' => 'settings'), - 'acl_a_phpinfo' => array('lang' => 'Can view php settings', 'cat' => 'settings'), + 'ACL_A_BOARD' => 'Can alter board settings/check for updates', + 'ACL_A_SERVER' => 'Can alter server/communication settings', + 'ACL_A_JABBER' => 'Can alter Jabber settings', + 'ACL_A_PHPINFO' => 'Can view php settings', - 'acl_a_forum' => array('lang' => 'Can manage forums', 'cat' => 'forums'), - 'acl_a_forumadd' => array('lang' => 'Can add new forums', 'cat' => 'forums'), - 'acl_a_forumdel' => array('lang' => 'Can delete forums', 'cat' => 'forums'), - 'acl_a_prune' => array('lang' => 'Can prune forums', 'cat' => 'forums'), + 'ACL_A_FORUM' => 'Can manage forums', + 'ACL_A_FORUMADD' => 'Can add new forums', + 'ACL_A_FORUMDEL' => 'Can delete forums', + 'ACL_A_PRUNE' => 'Can prune forums', - 'acl_a_icons' => array('lang' => 'Can alter topic/post icons and smilies', 'cat' => 'posting'), - 'acl_a_words' => array('lang' => 'Can alter word censors', 'cat' => 'posting'), - 'acl_a_bbcode' => array('lang' => 'Can define BBCode tags', 'cat' => 'posting'), - 'acl_a_attach' => array('lang' => 'Can alter attachment related settings', 'cat' => 'posting'), + 'ACL_A_ICONS' => 'Can alter topic/post icons and smilies', + 'ACL_A_WORDS' => 'Can alter word censors', + 'ACL_A_BBCODE' => 'Can define BBCode tags', + 'ACL_A_ATTACH' => 'Can alter attachment related settings', - 'acl_a_user' => array('lang' => 'Can manage users
    This also includes seeing the users browser agent within the viewonline list.', 'cat' => 'user_group'), - 'acl_a_userdel' => array('lang' => 'Can delete/prune users', 'cat' => 'user_group'), - 'acl_a_group' => array('lang' => 'Can manage groups', 'cat' => 'user_group'), - 'acl_a_groupadd' => array('lang' => 'Can add new groups', 'cat' => 'user_group'), - 'acl_a_groupdel' => array('lang' => 'Can delete groups', 'cat' => 'user_group'), - 'acl_a_ranks' => array('lang' => 'Can manage ranks', 'cat' => 'user_group'), - 'acl_a_profile' => array('lang' => 'Can manage custom profile fields', 'cat' => 'user_group'), - 'acl_a_names' => array('lang' => 'Can manage disallowed names', 'cat' => 'user_group'), - 'acl_a_ban' => array('lang' => 'Can manage bans', 'cat' => 'user_group'), + 'ACL_A_USER' => 'Can manage users
    This also includes seeing the users browser agent within the viewonline list.', + 'ACL_A_USERDEL' => 'Can delete/prune users', + 'ACL_A_GROUP' => 'Can manage groups', + 'ACL_A_GROUPADD' => 'Can add new groups', + 'ACL_A_GROUPDEL' => 'Can delete groups', + 'ACL_A_RANKS' => 'Can manage ranks', + 'ACL_A_PROFILE' => 'Can manage custom profile fields', + 'ACL_A_NAMES' => 'Can manage disallowed names', + 'ACL_A_BAN' => 'Can manage bans', - 'acl_a_viewauth' => array('lang' => 'Can view permission masks', 'cat' => 'permissions'), - 'acl_a_authgroups' => array('lang' => 'Can alter permissions for individual groups', 'cat' => 'permissions'), - 'acl_a_authusers' => array('lang' => 'Can alter permissions for individual users', 'cat' => 'permissions'), - 'acl_a_fauth' => array('lang' => 'Can alter forum permission class', 'cat' => 'permissions'), - 'acl_a_mauth' => array('lang' => 'Can alter moderator permission class', 'cat' => 'permissions'), - 'acl_a_aauth' => array('lang' => 'Can alter admin permission class', 'cat' => 'permissions'), - 'acl_a_uauth' => array('lang' => 'Can alter user permission class', 'cat' => 'permissions'), - 'acl_a_roles' => array('lang' => 'Can manage roles', 'cat' => 'permissions'), - 'acl_a_switchperm' => array('lang' => 'Can use others permissions', 'cat' => 'permissions'), + 'ACL_A_VIEWAUTH' => 'Can view permission masks', + 'ACL_A_AUTHGROUPS' => 'Can alter permissions for individual groups', + 'ACL_A_AUTHUSERS' => 'Can alter permissions for individual users', + 'ACL_A_FAUTH' => 'Can alter forum permission class', + 'ACL_A_MAUTH' => 'Can alter moderator permission class', + 'ACL_A_AAUTH' => 'Can alter admin permission class', + 'ACL_A_UAUTH' => 'Can alter user permission class', + 'ACL_A_ROLES' => 'Can manage roles', + 'ACL_A_SWITCHPERM' => 'Can use others permissions', - 'acl_a_styles' => array('lang' => 'Can manage styles', 'cat' => 'misc'), - 'acl_a_extensions' => array('lang' => 'Can manage extensions', 'cat' => 'misc'), - 'acl_a_viewlogs' => array('lang' => 'Can view logs', 'cat' => 'misc'), - 'acl_a_clearlogs' => array('lang' => 'Can clear logs', 'cat' => 'misc'), - 'acl_a_modules' => array('lang' => 'Can manage modules', 'cat' => 'misc'), - 'acl_a_language' => array('lang' => 'Can manage language packs', 'cat' => 'misc'), - 'acl_a_email' => array('lang' => 'Can send mass email', 'cat' => 'misc'), - 'acl_a_bots' => array('lang' => 'Can manage bots', 'cat' => 'misc'), - 'acl_a_reasons' => array('lang' => 'Can manage report/denial reasons', 'cat' => 'misc'), - 'acl_a_backup' => array('lang' => 'Can backup/restore database', 'cat' => 'misc'), - 'acl_a_search' => array('lang' => 'Can manage search backends and settings', 'cat' => 'misc'), + 'ACL_A_STYLES' => 'Can manage styles', + 'ACL_A_EXTENSIONS' => 'Can manage extensions', + 'ACL_A_VIEWLOGS' => 'Can view logs', + 'ACL_A_CLEARLOGS' => 'Can clear logs', + 'ACL_A_MODULES' => 'Can manage modules', + 'ACL_A_LANGUAGE' => 'Can manage language packs', + 'ACL_A_EMAIL' => 'Can send mass email', + 'ACL_A_BOTS' => 'Can manage bots', + 'ACL_A_REASONS' => 'Can manage report/denial reasons', + 'ACL_A_BACKUP' => 'Can backup/restore database', + 'ACL_A_SEARCH' => 'Can manage search backends and settings', )); From 4a64e2c2b3d4b39cdedec72551076595a9cd6a6e Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 6 Jul 2013 16:07:05 +0200 Subject: [PATCH 2241/2494] [ticket/11582] Fix documentation for adding permissions PHPBB3-11582 --- phpBB/language/en/acp/permissions_phpbb.php | 34 +++++---------------- 1 file changed, 7 insertions(+), 27 deletions(-) diff --git a/phpBB/language/en/acp/permissions_phpbb.php b/phpBB/language/en/acp/permissions_phpbb.php index edcc812830..d0128db34a 100644 --- a/phpBB/language/en/acp/permissions_phpbb.php +++ b/phpBB/language/en/acp/permissions_phpbb.php @@ -33,34 +33,14 @@ if (empty($lang) || !is_array($lang)) // in a url you again do not need to specify an order e.g., 'Click %sHERE%s' is fine /** -* MODDERS PLEASE NOTE +* EXTENSION-DEVELOPERS PLEASE NOTE * -* You are able to put your permission sets into a separate file too by -* prefixing the new file with permissions_ and putting it into the acp -* language folder. -* -* An example of how the file could look like: -* -* -* -* if (empty($lang) || !is_array($lang)) -* { -* $lang = array(); -* } -* -* // Adding new category -* $lang['permission_cat']['bugs'] = 'Bugs'; -* -* // Adding new permission set -* $lang['permission_type']['bug_'] = 'Bug Permissions'; -* -* // Adding the permissions -* $lang = array_merge($lang, array( -* 'acl_bug_view' => 'Can view bug reports', 'cat' => 'bugs'), -* 'acl_bug_post' => 'Can post bugs', // Using a phpBB category here -* )); -* -* +* You are able to put your permission sets into your extension. +* The permissions logic should be added via the 'core.permissions' event. +* You can easily add new permission categories, types and permissions, by +* simply merging them into the respective arrays. +* The respective language strings should be added into a language file, that +* start with 'permissions_', so they are automatically loaded within the ACP. */ $lang = array_merge($lang, array( From aaa44eda2b1df7d7c5c02651c1a9536343eca846 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 8 Jul 2013 00:48:26 +0200 Subject: [PATCH 2242/2494] [ticket/11582] Remove useless prefix PHPBB3-11582 --- phpBB/includes/permissions.php | 244 ++++++++++++++++----------------- 1 file changed, 122 insertions(+), 122 deletions(-) diff --git a/phpBB/includes/permissions.php b/phpBB/includes/permissions.php index 4cb3356c53..1db6843dbb 100644 --- a/phpBB/includes/permissions.php +++ b/phpBB/includes/permissions.php @@ -52,14 +52,14 @@ class phpbb_permissions * @var array types Array with permission types (a_, u_, m_, etc.) * @var array categories Array with permission categories (pm, post, settings, misc, etc.) * @var array permissions Array with permissions. Each Permission has the following layout: - * 'acl_' => array( + * '' => array( * 'lang' => 'Language Key with a Short description', // Optional, if not set, - * // the permissions identifier 'acl_' is used with + * // the permissions identifier '' is used with * // all uppercase. * 'cat' => 'Identifier of the category, the permission should be displayed in', * ), * Example: - * 'acl_u_viewprofile' => array( + * 'u_viewprofile' => array( * 'lang' => 'ACL_U_VIEWPROFILE', * 'cat' => 'profile', * ), @@ -129,14 +129,14 @@ class phpbb_permissions /** * Returns an array with all the permissions. * Each Permission has the following layout: - * 'acl_' => array( + * '' => array( * 'lang' => 'Language Key with a Short description', // Optional, if not set, - * // the permissions identifier 'acl_' is used with + * // the permissions identifier '' is used with * // all uppercase. * 'cat' => 'Identifier of the category, the permission should be displayed in', * ), * Example: - * 'acl_u_viewprofile' => array( + * 'u_viewprofile' => array( * 'lang' => 'ACL_U_VIEWPROFILE', * 'cat' => 'profile', * ), @@ -165,7 +165,7 @@ class phpbb_permissions */ public function get_permission_lang($permission) { - return (isset($this->permissions['acl_' . $permission]['lang'])) ? $this->user->lang($this->permissions['acl_' . $permission]['lang']) : $this->user->lang('ACL_' . strtoupper($permission)); + return (isset($this->permissions[$permission]['lang'])) ? $this->user->lang($this->permissions[$permission]['lang']) : $this->user->lang('ACL_' . strtoupper($permission)); } protected $types = array( @@ -197,139 +197,139 @@ class phpbb_permissions protected $permissions = array( // User Permissions - 'acl_u_viewprofile' => array('lang' => 'ACL_U_VIEWPROFILE', 'cat' => 'profile'), - 'acl_u_chgname' => array('lang' => 'ACL_U_CHGNAME', 'cat' => 'profile'), - 'acl_u_chgpasswd' => array('lang' => 'ACL_U_CHGPASSWD', 'cat' => 'profile'), - 'acl_u_chgemail' => array('lang' => 'ACL_U_CHGEMAIL', 'cat' => 'profile'), - 'acl_u_chgavatar' => array('lang' => 'ACL_U_CHGAVATAR', 'cat' => 'profile'), - 'acl_u_chggrp' => array('lang' => 'ACL_U_CHGGRP', 'cat' => 'profile'), - 'acl_u_chgprofileinfo' => array('lang' => 'ACL_U_CHGPROFILEINFO', 'cat' => 'profile'), + 'u_viewprofile' => array('lang' => 'ACL_U_VIEWPROFILE', 'cat' => 'profile'), + 'u_chgname' => array('lang' => 'ACL_U_CHGNAME', 'cat' => 'profile'), + 'u_chgpasswd' => array('lang' => 'ACL_U_CHGPASSWD', 'cat' => 'profile'), + 'u_chgemail' => array('lang' => 'ACL_U_CHGEMAIL', 'cat' => 'profile'), + 'u_chgavatar' => array('lang' => 'ACL_U_CHGAVATAR', 'cat' => 'profile'), + 'u_chggrp' => array('lang' => 'ACL_U_CHGGRP', 'cat' => 'profile'), + 'u_chgprofileinfo' => array('lang' => 'ACL_U_CHGPROFILEINFO', 'cat' => 'profile'), - 'acl_u_attach' => array('lang' => 'ACL_U_ATTACH', 'cat' => 'post'), - 'acl_u_download' => array('lang' => 'ACL_U_DOWNLOAD', 'cat' => 'post'), - 'acl_u_savedrafts' => array('lang' => 'ACL_U_SAVEDRAFTS', 'cat' => 'post'), - 'acl_u_chgcensors' => array('lang' => 'ACL_U_CHGCENSORS', 'cat' => 'post'), - 'acl_u_sig' => array('lang' => 'ACL_U_SIG', 'cat' => 'post'), + 'u_attach' => array('lang' => 'ACL_U_ATTACH', 'cat' => 'post'), + 'u_download' => array('lang' => 'ACL_U_DOWNLOAD', 'cat' => 'post'), + 'u_savedrafts' => array('lang' => 'ACL_U_SAVEDRAFTS', 'cat' => 'post'), + 'u_chgcensors' => array('lang' => 'ACL_U_CHGCENSORS', 'cat' => 'post'), + 'u_sig' => array('lang' => 'ACL_U_SIG', 'cat' => 'post'), - 'acl_u_sendpm' => array('lang' => 'ACL_U_SENDPM', 'cat' => 'pm'), - 'acl_u_masspm' => array('lang' => 'ACL_U_MASSPM', 'cat' => 'pm'), - 'acl_u_masspm_group'=> array('lang' => 'ACL_U_MASSPM_GROUP', 'cat' => 'pm'), - 'acl_u_readpm' => array('lang' => 'ACL_U_READPM', 'cat' => 'pm'), - 'acl_u_pm_edit' => array('lang' => 'ACL_U_PM_EDIT', 'cat' => 'pm'), - 'acl_u_pm_delete' => array('lang' => 'ACL_U_PM_DELETE', 'cat' => 'pm'), - 'acl_u_pm_forward' => array('lang' => 'ACL_U_PM_FORWARD', 'cat' => 'pm'), - 'acl_u_pm_emailpm' => array('lang' => 'ACL_U_PM_EMAILPM', 'cat' => 'pm'), - 'acl_u_pm_printpm' => array('lang' => 'ACL_U_PM_PRINTPM', 'cat' => 'pm'), - 'acl_u_pm_attach' => array('lang' => 'ACL_U_PM_ATTACH', 'cat' => 'pm'), - 'acl_u_pm_download' => array('lang' => 'ACL_U_PM_DOWNLOAD', 'cat' => 'pm'), - 'acl_u_pm_bbcode' => array('lang' => 'ACL_U_PM_BBCODE', 'cat' => 'pm'), - 'acl_u_pm_smilies' => array('lang' => 'ACL_U_PM_SMILIES', 'cat' => 'pm'), - 'acl_u_pm_img' => array('lang' => 'ACL_U_PM_IMG', 'cat' => 'pm'), - 'acl_u_pm_flash' => array('lang' => 'ACL_U_PM_FLASH', 'cat' => 'pm'), + 'u_sendpm' => array('lang' => 'ACL_U_SENDPM', 'cat' => 'pm'), + 'u_masspm' => array('lang' => 'ACL_U_MASSPM', 'cat' => 'pm'), + 'u_masspm_group'=> array('lang' => 'ACL_U_MASSPM_GROUP', 'cat' => 'pm'), + 'u_readpm' => array('lang' => 'ACL_U_READPM', 'cat' => 'pm'), + 'u_pm_edit' => array('lang' => 'ACL_U_PM_EDIT', 'cat' => 'pm'), + 'u_pm_delete' => array('lang' => 'ACL_U_PM_DELETE', 'cat' => 'pm'), + 'u_pm_forward' => array('lang' => 'ACL_U_PM_FORWARD', 'cat' => 'pm'), + 'u_pm_emailpm' => array('lang' => 'ACL_U_PM_EMAILPM', 'cat' => 'pm'), + 'u_pm_printpm' => array('lang' => 'ACL_U_PM_PRINTPM', 'cat' => 'pm'), + 'u_pm_attach' => array('lang' => 'ACL_U_PM_ATTACH', 'cat' => 'pm'), + 'u_pm_download' => array('lang' => 'ACL_U_PM_DOWNLOAD', 'cat' => 'pm'), + 'u_pm_bbcode' => array('lang' => 'ACL_U_PM_BBCODE', 'cat' => 'pm'), + 'u_pm_smilies' => array('lang' => 'ACL_U_PM_SMILIES', 'cat' => 'pm'), + 'u_pm_img' => array('lang' => 'ACL_U_PM_IMG', 'cat' => 'pm'), + 'u_pm_flash' => array('lang' => 'ACL_U_PM_FLASH', 'cat' => 'pm'), - 'acl_u_sendemail' => array('lang' => 'ACL_U_SENDEMAIL', 'cat' => 'misc'), - 'acl_u_sendim' => array('lang' => 'ACL_U_SENDIM', 'cat' => 'misc'), - 'acl_u_ignoreflood' => array('lang' => 'ACL_U_IGNOREFLOOD', 'cat' => 'misc'), - 'acl_u_hideonline' => array('lang' => 'ACL_U_HIDEONLINE', 'cat' => 'misc'), - 'acl_u_viewonline' => array('lang' => 'ACL_U_VIEWONLINE', 'cat' => 'misc'), - 'acl_u_search' => array('lang' => 'ACL_U_SEARCH', 'cat' => 'misc'), + 'u_sendemail' => array('lang' => 'ACL_U_SENDEMAIL', 'cat' => 'misc'), + 'u_sendim' => array('lang' => 'ACL_U_SENDIM', 'cat' => 'misc'), + 'u_ignoreflood' => array('lang' => 'ACL_U_IGNOREFLOOD', 'cat' => 'misc'), + 'u_hideonline' => array('lang' => 'ACL_U_HIDEONLINE', 'cat' => 'misc'), + 'u_viewonline' => array('lang' => 'ACL_U_VIEWONLINE', 'cat' => 'misc'), + 'u_search' => array('lang' => 'ACL_U_SEARCH', 'cat' => 'misc'), // Forum Permissions - 'acl_f_list' => array('lang' => 'ACL_F_LIST', 'cat' => 'actions'), - 'acl_f_read' => array('lang' => 'ACL_F_READ', 'cat' => 'actions'), - 'acl_f_search' => array('lang' => 'ACL_F_SEARCH', 'cat' => 'actions'), - 'acl_f_subscribe' => array('lang' => 'ACL_F_SUBSCRIBE', 'cat' => 'actions'), - 'acl_f_print' => array('lang' => 'ACL_F_PRINT', 'cat' => 'actions'), - 'acl_f_email' => array('lang' => 'ACL_F_EMAIL', 'cat' => 'actions'), - 'acl_f_bump' => array('lang' => 'ACL_F_BUMP', 'cat' => 'actions'), - 'acl_f_user_lock' => array('lang' => 'ACL_F_USER_LOCK', 'cat' => 'actions'), - 'acl_f_download' => array('lang' => 'ACL_F_DOWNLOAD', 'cat' => 'actions'), - 'acl_f_report' => array('lang' => 'ACL_F_REPORT', 'cat' => 'actions'), + 'f_list' => array('lang' => 'ACL_F_LIST', 'cat' => 'actions'), + 'f_read' => array('lang' => 'ACL_F_READ', 'cat' => 'actions'), + 'f_search' => array('lang' => 'ACL_F_SEARCH', 'cat' => 'actions'), + 'f_subscribe' => array('lang' => 'ACL_F_SUBSCRIBE', 'cat' => 'actions'), + 'f_print' => array('lang' => 'ACL_F_PRINT', 'cat' => 'actions'), + 'f_email' => array('lang' => 'ACL_F_EMAIL', 'cat' => 'actions'), + 'f_bump' => array('lang' => 'ACL_F_BUMP', 'cat' => 'actions'), + 'f_user_lock' => array('lang' => 'ACL_F_USER_LOCK', 'cat' => 'actions'), + 'f_download' => array('lang' => 'ACL_F_DOWNLOAD', 'cat' => 'actions'), + 'f_report' => array('lang' => 'ACL_F_REPORT', 'cat' => 'actions'), - 'acl_f_post' => array('lang' => 'ACL_F_POST', 'cat' => 'post'), - 'acl_f_sticky' => array('lang' => 'ACL_F_STICKY', 'cat' => 'post'), - 'acl_f_announce' => array('lang' => 'ACL_F_ANNOUNCE', 'cat' => 'post'), - 'acl_f_reply' => array('lang' => 'ACL_F_REPLY', 'cat' => 'post'), - 'acl_f_edit' => array('lang' => 'ACL_F_EDIT', 'cat' => 'post'), - 'acl_f_delete' => array('lang' => 'ACL_F_DELETE', 'cat' => 'post'), - 'acl_f_ignoreflood' => array('lang' => 'ACL_F_IGNOREFLOOD', 'cat' => 'post'), - 'acl_f_postcount' => array('lang' => 'ACL_F_POSTCOUNT', 'cat' => 'post'), - 'acl_f_noapprove' => array('lang' => 'ACL_F_NOAPPROVE', 'cat' => 'post'), + 'f_post' => array('lang' => 'ACL_F_POST', 'cat' => 'post'), + 'f_sticky' => array('lang' => 'ACL_F_STICKY', 'cat' => 'post'), + 'f_announce' => array('lang' => 'ACL_F_ANNOUNCE', 'cat' => 'post'), + 'f_reply' => array('lang' => 'ACL_F_REPLY', 'cat' => 'post'), + 'f_edit' => array('lang' => 'ACL_F_EDIT', 'cat' => 'post'), + 'f_delete' => array('lang' => 'ACL_F_DELETE', 'cat' => 'post'), + 'f_ignoreflood' => array('lang' => 'ACL_F_IGNOREFLOOD', 'cat' => 'post'), + 'f_postcount' => array('lang' => 'ACL_F_POSTCOUNT', 'cat' => 'post'), + 'f_noapprove' => array('lang' => 'ACL_F_NOAPPROVE', 'cat' => 'post'), - 'acl_f_attach' => array('lang' => 'ACL_F_ATTACH', 'cat' => 'content'), - 'acl_f_icons' => array('lang' => 'ACL_F_ICONS', 'cat' => 'content'), - 'acl_f_bbcode' => array('lang' => 'ACL_F_BBCODE', 'cat' => 'content'), - 'acl_f_flash' => array('lang' => 'ACL_F_FLASH', 'cat' => 'content'), - 'acl_f_img' => array('lang' => 'ACL_F_IMG', 'cat' => 'content'), - 'acl_f_sigs' => array('lang' => 'ACL_F_SIGS', 'cat' => 'content'), - 'acl_f_smilies' => array('lang' => 'ACL_F_SMILIES', 'cat' => 'content'), + 'f_attach' => array('lang' => 'ACL_F_ATTACH', 'cat' => 'content'), + 'f_icons' => array('lang' => 'ACL_F_ICONS', 'cat' => 'content'), + 'f_bbcode' => array('lang' => 'ACL_F_BBCODE', 'cat' => 'content'), + 'f_flash' => array('lang' => 'ACL_F_FLASH', 'cat' => 'content'), + 'f_img' => array('lang' => 'ACL_F_IMG', 'cat' => 'content'), + 'f_sigs' => array('lang' => 'ACL_F_SIGS', 'cat' => 'content'), + 'f_smilies' => array('lang' => 'ACL_F_SMILIES', 'cat' => 'content'), - 'acl_f_poll' => array('lang' => 'ACL_F_POLL', 'cat' => 'polls'), - 'acl_f_vote' => array('lang' => 'ACL_F_VOTE', 'cat' => 'polls'), - 'acl_f_votechg' => array('lang' => 'ACL_F_VOTECHG', 'cat' => 'polls'), + 'f_poll' => array('lang' => 'ACL_F_POLL', 'cat' => 'polls'), + 'f_vote' => array('lang' => 'ACL_F_VOTE', 'cat' => 'polls'), + 'f_votechg' => array('lang' => 'ACL_F_VOTECHG', 'cat' => 'polls'), // Moderator Permissions - 'acl_m_edit' => array('lang' => 'ACL_M_EDIT', 'cat' => 'post_actions'), - 'acl_m_delete' => array('lang' => 'ACL_M_DELETE', 'cat' => 'post_actions'), - 'acl_m_approve' => array('lang' => 'ACL_M_APPROVE', 'cat' => 'post_actions'), - 'acl_m_report' => array('lang' => 'ACL_M_REPORT', 'cat' => 'post_actions'), - 'acl_m_chgposter' => array('lang' => 'ACL_M_CHGPOSTER', 'cat' => 'post_actions'), + 'm_edit' => array('lang' => 'ACL_M_EDIT', 'cat' => 'post_actions'), + 'm_delete' => array('lang' => 'ACL_M_DELETE', 'cat' => 'post_actions'), + 'm_approve' => array('lang' => 'ACL_M_APPROVE', 'cat' => 'post_actions'), + 'm_report' => array('lang' => 'ACL_M_REPORT', 'cat' => 'post_actions'), + 'm_chgposter' => array('lang' => 'ACL_M_CHGPOSTER', 'cat' => 'post_actions'), - 'acl_m_move' => array('lang' => 'ACL_M_MOVE', 'cat' => 'topic_actions'), - 'acl_m_lock' => array('lang' => 'ACL_M_LOCK', 'cat' => 'topic_actions'), - 'acl_m_split' => array('lang' => 'ACL_M_SPLIT', 'cat' => 'topic_actions'), - 'acl_m_merge' => array('lang' => 'ACL_M_MERGE', 'cat' => 'topic_actions'), + 'm_move' => array('lang' => 'ACL_M_MOVE', 'cat' => 'topic_actions'), + 'm_lock' => array('lang' => 'ACL_M_LOCK', 'cat' => 'topic_actions'), + 'm_split' => array('lang' => 'ACL_M_SPLIT', 'cat' => 'topic_actions'), + 'm_merge' => array('lang' => 'ACL_M_MERGE', 'cat' => 'topic_actions'), - 'acl_m_info' => array('lang' => 'ACL_M_INFO', 'cat' => 'misc'), - 'acl_m_warn' => array('lang' => 'ACL_M_WARN', 'cat' => 'misc'), - 'acl_m_ban' => array('lang' => 'ACL_M_BAN', 'cat' => 'misc'), + 'm_info' => array('lang' => 'ACL_M_INFO', 'cat' => 'misc'), + 'm_warn' => array('lang' => 'ACL_M_WARN', 'cat' => 'misc'), + 'm_ban' => array('lang' => 'ACL_M_BAN', 'cat' => 'misc'), // Admin Permissions - 'acl_a_board' => array('lang' => 'ACL_A_BOARD', 'cat' => 'settings'), - 'acl_a_server' => array('lang' => 'ACL_A_SERVER', 'cat' => 'settings'), - 'acl_a_jabber' => array('lang' => 'ACL_A_JABBER', 'cat' => 'settings'), - 'acl_a_phpinfo' => array('lang' => 'ACL_A_PHPINFO', 'cat' => 'settings'), + 'a_board' => array('lang' => 'ACL_A_BOARD', 'cat' => 'settings'), + 'a_server' => array('lang' => 'ACL_A_SERVER', 'cat' => 'settings'), + 'a_jabber' => array('lang' => 'ACL_A_JABBER', 'cat' => 'settings'), + 'a_phpinfo' => array('lang' => 'ACL_A_PHPINFO', 'cat' => 'settings'), - 'acl_a_forum' => array('lang' => 'ACL_A_FORUM', 'cat' => 'forums'), - 'acl_a_forumadd' => array('lang' => 'ACL_A_FORUMADD', 'cat' => 'forums'), - 'acl_a_forumdel' => array('lang' => 'ACL_A_FORUMDEL', 'cat' => 'forums'), - 'acl_a_prune' => array('lang' => 'ACL_A_PRUNE', 'cat' => 'forums'), + 'a_forum' => array('lang' => 'ACL_A_FORUM', 'cat' => 'forums'), + 'a_forumadd' => array('lang' => 'ACL_A_FORUMADD', 'cat' => 'forums'), + 'a_forumdel' => array('lang' => 'ACL_A_FORUMDEL', 'cat' => 'forums'), + 'a_prune' => array('lang' => 'ACL_A_PRUNE', 'cat' => 'forums'), - 'acl_a_icons' => array('lang' => 'ACL_A_ICONS', 'cat' => 'posting'), - 'acl_a_words' => array('lang' => 'ACL_A_WORDS', 'cat' => 'posting'), - 'acl_a_bbcode' => array('lang' => 'ACL_A_BBCODE', 'cat' => 'posting'), - 'acl_a_attach' => array('lang' => 'ACL_A_ATTACH', 'cat' => 'posting'), + 'a_icons' => array('lang' => 'ACL_A_ICONS', 'cat' => 'posting'), + 'a_words' => array('lang' => 'ACL_A_WORDS', 'cat' => 'posting'), + 'a_bbcode' => array('lang' => 'ACL_A_BBCODE', 'cat' => 'posting'), + 'a_attach' => array('lang' => 'ACL_A_ATTACH', 'cat' => 'posting'), - 'acl_a_user' => array('lang' => 'ACL_A_USER', 'cat' => 'user_group'), - 'acl_a_userdel' => array('lang' => 'ACL_A_USERDEL', 'cat' => 'user_group'), - 'acl_a_group' => array('lang' => 'ACL_A_GROUP', 'cat' => 'user_group'), - 'acl_a_groupadd' => array('lang' => 'ACL_A_GROUPADD', 'cat' => 'user_group'), - 'acl_a_groupdel' => array('lang' => 'ACL_A_GROUPDEL', 'cat' => 'user_group'), - 'acl_a_ranks' => array('lang' => 'ACL_A_RANKS', 'cat' => 'user_group'), - 'acl_a_profile' => array('lang' => 'ACL_A_PROFILE', 'cat' => 'user_group'), - 'acl_a_names' => array('lang' => 'ACL_A_NAMES', 'cat' => 'user_group'), - 'acl_a_ban' => array('lang' => 'ACL_A_BAN', 'cat' => 'user_group'), + 'a_user' => array('lang' => 'ACL_A_USER', 'cat' => 'user_group'), + 'a_userdel' => array('lang' => 'ACL_A_USERDEL', 'cat' => 'user_group'), + 'a_group' => array('lang' => 'ACL_A_GROUP', 'cat' => 'user_group'), + 'a_groupadd' => array('lang' => 'ACL_A_GROUPADD', 'cat' => 'user_group'), + 'a_groupdel' => array('lang' => 'ACL_A_GROUPDEL', 'cat' => 'user_group'), + 'a_ranks' => array('lang' => 'ACL_A_RANKS', 'cat' => 'user_group'), + 'a_profile' => array('lang' => 'ACL_A_PROFILE', 'cat' => 'user_group'), + 'a_names' => array('lang' => 'ACL_A_NAMES', 'cat' => 'user_group'), + 'a_ban' => array('lang' => 'ACL_A_BAN', 'cat' => 'user_group'), - 'acl_a_viewauth' => array('lang' => 'ACL_A_VIEWAUTH', 'cat' => 'permissions'), - 'acl_a_authgroups' => array('lang' => 'ACL_A_AUTHGROUPS', 'cat' => 'permissions'), - 'acl_a_authusers' => array('lang' => 'ACL_A_AUTHUSERS', 'cat' => 'permissions'), - 'acl_a_fauth' => array('lang' => 'ACL_A_FAUTH', 'cat' => 'permissions'), - 'acl_a_mauth' => array('lang' => 'ACL_A_MAUTH', 'cat' => 'permissions'), - 'acl_a_aauth' => array('lang' => 'ACL_A_AAUTH', 'cat' => 'permissions'), - 'acl_a_uauth' => array('lang' => 'ACL_A_UAUTH', 'cat' => 'permissions'), - 'acl_a_roles' => array('lang' => 'ACL_A_ROLES', 'cat' => 'permissions'), - 'acl_a_switchperm' => array('lang' => 'ACL_A_SWITCHPERM', 'cat' => 'permissions'), + 'a_viewauth' => array('lang' => 'ACL_A_VIEWAUTH', 'cat' => 'permissions'), + 'a_authgroups' => array('lang' => 'ACL_A_AUTHGROUPS', 'cat' => 'permissions'), + 'a_authusers' => array('lang' => 'ACL_A_AUTHUSERS', 'cat' => 'permissions'), + 'a_fauth' => array('lang' => 'ACL_A_FAUTH', 'cat' => 'permissions'), + 'a_mauth' => array('lang' => 'ACL_A_MAUTH', 'cat' => 'permissions'), + 'a_aauth' => array('lang' => 'ACL_A_AAUTH', 'cat' => 'permissions'), + 'a_uauth' => array('lang' => 'ACL_A_UAUTH', 'cat' => 'permissions'), + 'a_roles' => array('lang' => 'ACL_A_ROLES', 'cat' => 'permissions'), + 'a_switchperm' => array('lang' => 'ACL_A_SWITCHPERM', 'cat' => 'permissions'), - 'acl_a_styles' => array('lang' => 'ACL_A_STYLES', 'cat' => 'misc'), - 'acl_a_extensions' => array('lang' => 'ACL_A_EXTENSIONS', 'cat' => 'misc'), - 'acl_a_viewlogs' => array('lang' => 'ACL_A_VIEWLOGS', 'cat' => 'misc'), - 'acl_a_clearlogs' => array('lang' => 'ACL_A_CLEARLOGS', 'cat' => 'misc'), - 'acl_a_modules' => array('lang' => 'ACL_A_MODULES', 'cat' => 'misc'), - 'acl_a_language' => array('lang' => 'ACL_A_LANGUAGE', 'cat' => 'misc'), - 'acl_a_email' => array('lang' => 'ACL_A_EMAIL', 'cat' => 'misc'), - 'acl_a_bots' => array('lang' => 'ACL_A_BOTS', 'cat' => 'misc'), - 'acl_a_reasons' => array('lang' => 'ACL_A_REASONS', 'cat' => 'misc'), - 'acl_a_backup' => array('lang' => 'ACL_A_BACKUP', 'cat' => 'misc'), - 'acl_a_search' => array('lang' => 'ACL_A_SEARCH', 'cat' => 'misc'), + 'a_styles' => array('lang' => 'ACL_A_STYLES', 'cat' => 'misc'), + 'a_extensions' => array('lang' => 'ACL_A_EXTENSIONS', 'cat' => 'misc'), + 'a_viewlogs' => array('lang' => 'ACL_A_VIEWLOGS', 'cat' => 'misc'), + 'a_clearlogs' => array('lang' => 'ACL_A_CLEARLOGS', 'cat' => 'misc'), + 'a_modules' => array('lang' => 'ACL_A_MODULES', 'cat' => 'misc'), + 'a_language' => array('lang' => 'ACL_A_LANGUAGE', 'cat' => 'misc'), + 'a_email' => array('lang' => 'ACL_A_EMAIL', 'cat' => 'misc'), + 'a_bots' => array('lang' => 'ACL_A_BOTS', 'cat' => 'misc'), + 'a_reasons' => array('lang' => 'ACL_A_REASONS', 'cat' => 'misc'), + 'a_backup' => array('lang' => 'ACL_A_BACKUP', 'cat' => 'misc'), + 'a_search' => array('lang' => 'ACL_A_SEARCH', 'cat' => 'misc'), ); } From 4b7b7e895b4a0949d19a7524bedddfa969a33ee7 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 10 Jul 2013 16:44:24 +0200 Subject: [PATCH 2243/2494] [ticket/11582] Fix missing @params in the doc blocks PHPBB3-11582 --- phpBB/includes/permissions.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/permissions.php b/phpBB/includes/permissions.php index 1db6843dbb..66360424ea 100644 --- a/phpBB/includes/permissions.php +++ b/phpBB/includes/permissions.php @@ -86,7 +86,8 @@ class phpbb_permissions /** * Returns the language string of a permission category * - * @return string Language string + * @param string $category Identifier of the category + * @return string Language string */ public function get_category_lang($category) { @@ -106,6 +107,8 @@ class phpbb_permissions /** * Returns the language string of a permission type * + * @param string $type Identifier of the type + * @param mixed $scope Scope of the type (should be 'global', 'local' or false) * @return string Language string */ public function get_type_lang($type, $scope = false) @@ -151,7 +154,8 @@ class phpbb_permissions /** * Returns the category of a permission * - * @return string + * @param string $permission Identifier of the permission + * @return string Returns the category identifier of the permission */ public function get_permission_category($permission) { @@ -161,6 +165,7 @@ class phpbb_permissions /** * Returns the language string of a permission * + * @param string $permission Identifier of the permission * @return string Language string */ public function get_permission_lang($permission) From 060754fd6ce998caf8b8e182f53a1464e16e9deb Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 12 Jul 2013 00:05:48 -0400 Subject: [PATCH 2244/2494] [ticket/11582] Fix missing closing bracket PHPBB3-11582 --- phpBB/includes/acp/acp_permission_roles.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/acp/acp_permission_roles.php b/phpBB/includes/acp/acp_permission_roles.php index 7c972c74ba..5657cbe675 100644 --- a/phpBB/includes/acp/acp_permission_roles.php +++ b/phpBB/includes/acp/acp_permission_roles.php @@ -492,8 +492,8 @@ class acp_permission_roles 'S_NO' => ($allowed == ACL_NO) ? true : false, 'FIELD_NAME' => $permission, - 'PERMISSION' => $phpbb_permissions->get_permission_lang($permission) - ); + 'PERMISSION' => $phpbb_permissions->get_permission_lang($permission), + )); } } } From cfb13bb5476dfa7895f984405d6a0c40ddcda08e Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 13 Jul 2013 23:31:13 -0400 Subject: [PATCH 2245/2494] [ticket/11582] Fix extension permission tests PHPBB3-11582 --- .../ext/foo/bar/event/permission_listener.php | 40 +++++++++++++++++++ .../foo/bar/language/en/permissions_foo.php | 3 +- 2 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 tests/functional/fixtures/ext/foo/bar/event/permission_listener.php diff --git a/tests/functional/fixtures/ext/foo/bar/event/permission_listener.php b/tests/functional/fixtures/ext/foo/bar/event/permission_listener.php new file mode 100644 index 0000000000..dfabf7c540 --- /dev/null +++ b/tests/functional/fixtures/ext/foo/bar/event/permission_listener.php @@ -0,0 +1,40 @@ + 'add_permissions', + ); + } + + public function add_permissions($event) + { + $permissions = $event['permissions']; + $permissions['u_foo'] = array('lang' => 'ACL_U_FOO', 'cat' => 'misc'), + $event['permissions'] = $permissions; + } +} diff --git a/tests/functional/fixtures/ext/foo/bar/language/en/permissions_foo.php b/tests/functional/fixtures/ext/foo/bar/language/en/permissions_foo.php index cd4b9a32d1..36c84c5209 100644 --- a/tests/functional/fixtures/ext/foo/bar/language/en/permissions_foo.php +++ b/tests/functional/fixtures/ext/foo/bar/language/en/permissions_foo.php @@ -1,6 +1,5 @@ array('lang' => 'Can view foo', 'cat' => 'misc'), + 'ACL_U_FOO' => 'Can view foo', )); From 9c72bbe284514c1aa70f8ac65e9dfcafb72d36dd Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sun, 14 Jul 2013 12:04:04 -0400 Subject: [PATCH 2246/2494] [ticket/11582] Move file to new directory PHPBB3-11582 --- phpBB/{includes => phpbb}/permissions.php | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename phpBB/{includes => phpbb}/permissions.php (100%) diff --git a/phpBB/includes/permissions.php b/phpBB/phpbb/permissions.php similarity index 100% rename from phpBB/includes/permissions.php rename to phpBB/phpbb/permissions.php From 81e0859041cd181c142a87a5fc78640f92aa5ce0 Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Sun, 14 Jul 2013 12:11:57 -0400 Subject: [PATCH 2247/2494] [ticket/11688] Purge TWIG cache Purge directories Replace opendir() with DirectoryIterator PHPBB3-11688 --- phpBB/phpbb/cache/driver/file.php | 67 +++++++++++++++++++++++++------ 1 file changed, 54 insertions(+), 13 deletions(-) diff --git a/phpBB/phpbb/cache/driver/file.php b/phpBB/phpbb/cache/driver/file.php index 85decbe3e8..7f8c646a11 100644 --- a/phpBB/phpbb/cache/driver/file.php +++ b/phpBB/phpbb/cache/driver/file.php @@ -205,28 +205,36 @@ class phpbb_cache_driver_file extends phpbb_cache_driver_base function purge() { // Purge all phpbb cache files - $dir = @opendir($this->cache_dir); - - if (!$dir) + try + { + $iterator = new DirectoryIterator($this->cache_dir); + } + catch (Exception $e) { return; } - while (($entry = readdir($dir)) !== false) + foreach ($iterator as $fileInfo) { - if (strpos($entry, 'container_') !== 0 && - strpos($entry, 'url_matcher') !== 0 && - strpos($entry, 'sql_') !== 0 && - strpos($entry, 'data_') !== 0 && - strpos($entry, 'ctpl_') !== 0 && - strpos($entry, 'tpl_') !== 0) + if ($fileInfo->isDot()) { continue; } - - $this->remove_file($this->cache_dir . $entry); + $filename = $fileInfo->getFilename(); + if ($fileInfo->isDir()) + { + $this->purge_dir($fileInfo->getPathname()); + } + elseif (strpos($filename, 'container_') === 0 || + strpos($filename, 'url_matcher') === 0 || + strpos($filename, 'sql_') === 0 || + strpos($filename, 'data_') === 0 || + strpos($filename, 'ctpl_') === 0 || + strpos($filename, 'tpl_') === 0) + { + $this->remove_file($fileInfo->getPathname()); + } } - closedir($dir); unset($this->vars); unset($this->var_expires); @@ -241,6 +249,39 @@ class phpbb_cache_driver_file extends phpbb_cache_driver_base $this->is_modified = false; } + /** + * Remove directory + */ + protected function purge_dir($dir) + { + try + { + $iterator = new DirectoryIterator($dir); + } + catch (Exception $e) + { + return; + } + + foreach ($iterator as $fileInfo) + { + if ($fileInfo->isDot()) + { + continue; + } + if ($fileInfo->isDir()) + { + $this->purge_dir($fileInfo->getPathname()); + } + else + { + $this->remove_file($fileInfo->getPathname()); + } + } + + @rmdir($dir); + } + /** * Destroy cache data */ From e4a5ce307d49c215b08e35a79147ba2418f133ff Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sun, 14 Jul 2013 12:55:03 -0400 Subject: [PATCH 2248/2494] [ticket/11582] Test the event and and fix it. PHPBB3-11582 --- phpBB/phpbb/permissions.php | 2 +- tests/functional/extension_permission_lang_test.php | 2 +- .../fixtures/ext/foo/bar/event/permission_listener.php | 2 +- .../fixtures/ext/foo/bar/language/en/permissions_foo.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/phpBB/phpbb/permissions.php b/phpBB/phpbb/permissions.php index 66360424ea..0fbacdad8a 100644 --- a/phpBB/phpbb/permissions.php +++ b/phpBB/phpbb/permissions.php @@ -66,7 +66,7 @@ class phpbb_permissions * @since 3.1-A1 */ $vars = array('types', 'categories', 'permissions'); - extract($phpbb_dispatcher->trigger_event('core.permissions', $vars)); + extract($phpbb_dispatcher->trigger_event('core.permissions', compact($vars))); $this->categories = $categories; $this->types = $types; diff --git a/tests/functional/extension_permission_lang_test.php b/tests/functional/extension_permission_lang_test.php index 6c1720735c..badbdbb057 100644 --- a/tests/functional/extension_permission_lang_test.php +++ b/tests/functional/extension_permission_lang_test.php @@ -75,6 +75,6 @@ class phpbb_functional_extension_permission_lang_test extends phpbb_functional_t $this->assertContains('Can attach files', $crawler->filter('body')->text()); // language from ext/foo/bar/language/en/permissions_foo.php - $this->assertContains('Can view foo', $crawler->filter('body')->text()); + $this->assertContains('Can view foobar', $crawler->filter('body')->text()); } } diff --git a/tests/functional/fixtures/ext/foo/bar/event/permission_listener.php b/tests/functional/fixtures/ext/foo/bar/event/permission_listener.php index dfabf7c540..39cb9f8b46 100644 --- a/tests/functional/fixtures/ext/foo/bar/event/permission_listener.php +++ b/tests/functional/fixtures/ext/foo/bar/event/permission_listener.php @@ -34,7 +34,7 @@ class phpbb_ext_foo_bar_event_permission_listener implements EventSubscriberInte public function add_permissions($event) { $permissions = $event['permissions']; - $permissions['u_foo'] = array('lang' => 'ACL_U_FOO', 'cat' => 'misc'), + $permissions['u_foo'] = array('lang' => 'ACL_U_FOOBAR', 'cat' => 'post'), $event['permissions'] = $permissions; } } diff --git a/tests/functional/fixtures/ext/foo/bar/language/en/permissions_foo.php b/tests/functional/fixtures/ext/foo/bar/language/en/permissions_foo.php index 36c84c5209..64b497c394 100644 --- a/tests/functional/fixtures/ext/foo/bar/language/en/permissions_foo.php +++ b/tests/functional/fixtures/ext/foo/bar/language/en/permissions_foo.php @@ -1,5 +1,5 @@ 'Can view foo', + 'ACL_U_FOOBAR' => 'Can view foobar with permission foo', )); From a68aed51190e10535d364db056de97098cd56019 Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Sun, 14 Jul 2013 13:20:41 -0400 Subject: [PATCH 2249/2494] [ticket/11688] tpl_ files are no longer used Remove tpl_ and ctpl_ from cache->purge() because those prefixes are no longer used. PHPBB3-11688 --- phpBB/phpbb/cache/driver/file.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/phpBB/phpbb/cache/driver/file.php b/phpBB/phpbb/cache/driver/file.php index 7f8c646a11..19596f5205 100644 --- a/phpBB/phpbb/cache/driver/file.php +++ b/phpBB/phpbb/cache/driver/file.php @@ -228,9 +228,7 @@ class phpbb_cache_driver_file extends phpbb_cache_driver_base elseif (strpos($filename, 'container_') === 0 || strpos($filename, 'url_matcher') === 0 || strpos($filename, 'sql_') === 0 || - strpos($filename, 'data_') === 0 || - strpos($filename, 'ctpl_') === 0 || - strpos($filename, 'tpl_') === 0) + strpos($filename, 'data_') === 0) { $this->remove_file($fileInfo->getPathname()); } From a9a6305d939467dd7e3a003a4c52f408c93f8c8c Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sun, 14 Jul 2013 13:20:58 -0400 Subject: [PATCH 2250/2494] [ticket/11582] Fix little typo PHPBB3-11582 --- .../fixtures/ext/foo/bar/event/permission_listener.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/functional/fixtures/ext/foo/bar/event/permission_listener.php b/tests/functional/fixtures/ext/foo/bar/event/permission_listener.php index 39cb9f8b46..6986755f71 100644 --- a/tests/functional/fixtures/ext/foo/bar/event/permission_listener.php +++ b/tests/functional/fixtures/ext/foo/bar/event/permission_listener.php @@ -34,7 +34,7 @@ class phpbb_ext_foo_bar_event_permission_listener implements EventSubscriberInte public function add_permissions($event) { $permissions = $event['permissions']; - $permissions['u_foo'] = array('lang' => 'ACL_U_FOOBAR', 'cat' => 'post'), + $permissions['u_foo'] = array('lang' => 'ACL_U_FOOBAR', 'cat' => 'post'); $event['permissions'] = $permissions; } } From 2a41128e6be929bf6bc3135ba738e1889a0640a9 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Sun, 14 Jul 2013 19:48:41 +0200 Subject: [PATCH 2251/2494] [ticket/11704] Correctly escape " PHPBB3-11704 --- build/build.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/build.xml b/build/build.xml index a418f40b53..cee8160eff 100644 --- a/build/build.xml +++ b/build/build.xml @@ -171,7 +171,7 @@ From da1ee75140608220b13908c74f5157033689db8c Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Sun, 14 Jul 2013 19:48:55 +0200 Subject: [PATCH 2252/2494] [ticket/11704] Use the correct directory for dependency checking. PHPBB3-11704 --- build/build.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/build.xml b/build/build.xml index cee8160eff..bb88bd3cfa 100644 --- a/build/build.xml +++ b/build/build.xml @@ -170,7 +170,7 @@ checkreturn="true" /> - From a0e5f833113221493540376b9b73718f7a517595 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 14 Jul 2013 15:13:09 -0400 Subject: [PATCH 2253/2494] [ticket/11706] Use @ to suppress errors for getimagesize in remote avatar PHPBB3-11706 --- phpBB/phpbb/avatar/driver/remote.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/phpbb/avatar/driver/remote.php b/phpBB/phpbb/avatar/driver/remote.php index 7da58107a1..d629a490fd 100644 --- a/phpBB/phpbb/avatar/driver/remote.php +++ b/phpBB/phpbb/avatar/driver/remote.php @@ -93,7 +93,7 @@ class phpbb_avatar_driver_remote extends phpbb_avatar_driver // Make sure getimagesize works... if (function_exists('getimagesize')) { - if (($width <= 0 || $height <= 0) && (($image_data = getimagesize($url)) === false)) + if (($width <= 0 || $height <= 0) && (($image_data = @getimagesize($url)) === false)) { $error[] = 'UNABLE_GET_IMAGE_SIZE'; return false; From 8928240dc3fefd42d8e98132451e2de92ff7cbec Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sun, 14 Jul 2013 15:40:09 -0400 Subject: [PATCH 2254/2494] [ticket/11574] Fix more issues in the updater * Stupid mistake in phpbb_create_update_container * Do not bootstrap extensions in installer/updater * Fix template lookup in installer/updater * Do not attempt to delete posts from bots The latter is a really fun problem. Since deleting posts now depends on a new db column that does not exist yet, we cannot call delete_post from a migration, ever. By using retain, we can hack around the issue for now. PHPBB3-11574 --- phpBB/includes/functions_container.php | 12 ++++++------ phpBB/install/index.php | 6 +++++- phpBB/install/install_update.php | 12 ------------ phpBB/phpbb/db/migration/data/30x/3_0_12_rc1.php | 2 +- 4 files changed, 12 insertions(+), 20 deletions(-) diff --git a/phpBB/includes/functions_container.php b/phpBB/includes/functions_container.php index 5c6bd6dd8a..7cbfa17a0e 100644 --- a/phpBB/includes/functions_container.php +++ b/phpBB/includes/functions_container.php @@ -148,9 +148,11 @@ function phpbb_create_install_container($phpbb_root_path, $php_ext) */ function phpbb_create_update_container($phpbb_root_path, $php_ext, $config_path) { + $config_file = $phpbb_root_path . 'config.' . $php_ext; return phpbb_create_compiled_container( + $config_file, array( - new phpbb_di_extension_config($phpbb_root_path . 'config.' . $php_ext), + new phpbb_di_extension_config($config_file), new phpbb_di_extension_core($config_path), ), array( @@ -173,11 +175,6 @@ function phpbb_create_update_container($phpbb_root_path, $php_ext, $config_path) */ function phpbb_create_compiled_container($config_file, array $extensions, array $passes, $phpbb_root_path, $php_ext) { - $installed_exts = phpbb_bootstrap_enabled_exts($config_file, $phpbb_root_path); - - // Now pass the enabled extension paths into the ext compiler extension - $extensions[] = new phpbb_di_extension_ext($installed_exts); - // Create the final container to be compiled and cached $container = phpbb_create_container($extensions, $phpbb_root_path, $php_ext); @@ -258,11 +255,14 @@ function phpbb_create_dumped_container_unless_debug($config_file, array $extensi function phpbb_create_default_container($phpbb_root_path, $php_ext) { $config_file = $phpbb_root_path . 'config.' . $php_ext; + $installed_exts = phpbb_bootstrap_enabled_exts($config_file, $phpbb_root_path); + return phpbb_create_dumped_container_unless_debug( $config_file, array( new phpbb_di_extension_config($config_file), new phpbb_di_extension_core($phpbb_root_path . 'config'), + new phpbb_di_extension_ext($installed_exts), ), array( new phpbb_di_pass_collection_pass(), diff --git a/phpBB/install/index.php b/phpBB/install/index.php index ada1f43905..fe61c53558 100644 --- a/phpBB/install/index.php +++ b/phpBB/install/index.php @@ -249,7 +249,11 @@ $phpbb_style_path_provider = new phpbb_style_path_provider(); $template = new phpbb_template_twig($phpbb_root_path, $phpEx, $config, $user, new phpbb_template_context()); $phpbb_style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $phpbb_style_resource_locator, $phpbb_style_path_provider, $template); $phpbb_style->set_ext_dir_prefix('adm/'); -$phpbb_style->set_custom_style('admin', $phpbb_admin_path . 'style', array(), ''); + +$paths = array($phpbb_admin_path . 'style', $phpbb_root_path . 'install/update/new/adm/style'); +$paths = array_filter($paths, 'is_dir'); +$phpbb_style->set_custom_style('admin', $paths, array(), ''); + $template->assign_var('T_ASSETS_PATH', '../assets'); $template->assign_var('T_TEMPLATE_PATH', $phpbb_admin_path . 'style'); diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php index f9dfaaef50..478cc9f76f 100644 --- a/phpBB/install/install_update.php +++ b/phpBB/install/install_update.php @@ -222,12 +222,6 @@ class install_update extends module if ($this->test_update === false) { - // Got the updater template itself updated? If so, we are able to directly use it - but only if all three files are present - if (in_array($phpbb_adm_relative_path . 'style/install_update.html', $this->update_info['files'])) - { - $this->tpl_name = '../../install/update/new/adm/style/install_update'; - } - // What about the language file? Got it updated? if (in_array('language/en/install.' . $phpEx, $this->update_info['files'])) { @@ -1068,12 +1062,6 @@ class install_update extends module $this->tpl_name = 'install_update_diff'; - // Got the diff template itself updated? If so, we are able to directly use it - if (in_array($phpbb_adm_relative_path . 'style/install_update_diff.html', $this->update_info['files'])) - { - $this->tpl_name = '../../install/update/new/adm/style/install_update_diff'; - } - $this->page_title = 'VIEWING_FILE_DIFF'; $status = request_var('status', ''); diff --git a/phpBB/phpbb/db/migration/data/30x/3_0_12_rc1.php b/phpBB/phpbb/db/migration/data/30x/3_0_12_rc1.php index 6a31a51201..a89a409dfd 100644 --- a/phpBB/phpbb/db/migration/data/30x/3_0_12_rc1.php +++ b/phpBB/phpbb/db/migration/data/30x/3_0_12_rc1.php @@ -108,7 +108,7 @@ class phpbb_db_migration_data_30x_3_0_12_rc1 extends phpbb_db_migration WHERE user_id = $bot_user_id"; $this->sql_query($sql); - user_delete('remove', $bot_user_id); + user_delete('retain', $bot_user_id); } else { From f96f2a9e23b41106c6a8ed71ad3538141c648c2f Mon Sep 17 00:00:00 2001 From: Bruno Ais Date: Mon, 15 Jul 2013 20:06:54 +0100 Subject: [PATCH 2255/2494] [ticket/11639] generate_text_for_display on functions_posting.php sub-task of ticket PHPBB3-11635: find and fix all bypasses of generate_text_for_* PHPBB3-11639 --- phpBB/includes/functions_posting.php | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index b9b518ad32..d277ef06a3 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -1104,14 +1104,12 @@ function topic_review($topic_id, $forum_id, $mode = 'topic_review', $cur_post_id $decoded_message = bbcode_nl2br($decoded_message); } - - if ($row['bbcode_bitfield']) - { - $bbcode->bbcode_second_pass($message, $row['bbcode_uid'], $row['bbcode_bitfield']); - } - - $message = bbcode_nl2br($message); - $message = smiley_text($message, !$row['enable_smilies']); + $parse_flags = ($row['bbcode_bitfield'] ? OPTION_FLAG_BBCODE : 0); + $parse_flags |= ($row['enable_smilies'] ? OPTION_FLAG_SMILIES : 0); + + $message = generate_text_for_display($message, $row['bbcode_uid'], $row['bbcode_bitfield'], $parse_flags , false); + + unset($parse_flags); if (!empty($attachments[$row['post_id']])) { From dde9a1fb27e6db3c1b4cd41d8848496a3ef8d363 Mon Sep 17 00:00:00 2001 From: Bruno Ais Date: Mon, 15 Jul 2013 20:08:17 +0100 Subject: [PATCH 2256/2494] [ticket/11639] Added an useful comment. sub-task of ticket PHPBB3-11635: find and fix all bypasses of generate_text_for_* PHPBB3-11639 --- phpBB/includes/functions_posting.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index d277ef06a3..49fbe92256 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -1104,9 +1104,10 @@ function topic_review($topic_id, $forum_id, $mode = 'topic_review', $cur_post_id $decoded_message = bbcode_nl2br($decoded_message); } + $parse_flags = ($row['bbcode_bitfield'] ? OPTION_FLAG_BBCODE : 0); $parse_flags |= ($row['enable_smilies'] ? OPTION_FLAG_SMILIES : 0); - + // Do not censor text because it has already been censored before $message = generate_text_for_display($message, $row['bbcode_uid'], $row['bbcode_bitfield'], $parse_flags , false); unset($parse_flags); From 5f19ca6a6f3ad6641954c58c44ef0c94d1609e5a Mon Sep 17 00:00:00 2001 From: Bruno Ais Date: Mon, 15 Jul 2013 20:09:59 +0100 Subject: [PATCH 2257/2494] [ticket/11639] Whitespace fixing sub-task of ticket PHPBB3-11635: find and fix all bypasses of generate_text_for_* PHPBB3-11639 --- phpBB/includes/functions_posting.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index 49fbe92256..ad75ed1079 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -1104,12 +1104,12 @@ function topic_review($topic_id, $forum_id, $mode = 'topic_review', $cur_post_id $decoded_message = bbcode_nl2br($decoded_message); } - + $parse_flags = ($row['bbcode_bitfield'] ? OPTION_FLAG_BBCODE : 0); $parse_flags |= ($row['enable_smilies'] ? OPTION_FLAG_SMILIES : 0); // Do not censor text because it has already been censored before $message = generate_text_for_display($message, $row['bbcode_uid'], $row['bbcode_bitfield'], $parse_flags , false); - + unset($parse_flags); if (!empty($attachments[$row['post_id']])) From 0759b606c25a6ae38ab4c7eb35ebcc2b01e3f5eb Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Tue, 16 Jul 2013 20:11:28 +0300 Subject: [PATCH 2258/2494] [ticket/11708] Fix bulletin points in notifications PHPBB3-11708 --- phpBB/styles/prosilver/theme/common.css | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/phpBB/styles/prosilver/theme/common.css b/phpBB/styles/prosilver/theme/common.css index e58386de45..a2b8034187 100644 --- a/phpBB/styles/prosilver/theme/common.css +++ b/phpBB/styles/prosilver/theme/common.css @@ -758,6 +758,10 @@ p.rules a { clear: both; } +#notification_list ul li:before, #notification_list ul li:after { + display: none; +} + #notification_list > .header { padding: 0 10px; font-family: Arial, "Helvetica Neue", Helvetica, Arial, sans-serif; From 792c730f15ef61d444dcdbcee91831ec89366a88 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Tue, 16 Jul 2013 20:11:58 +0200 Subject: [PATCH 2259/2494] [ticket/10931] Add phpbb_php_ini as a service. PHPBB3-10931 --- phpBB/config/services.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/phpBB/config/services.yml b/phpBB/config/services.yml index c1579cfb57..6d30a154e2 100644 --- a/phpBB/config/services.yml +++ b/phpBB/config/services.yml @@ -239,6 +239,9 @@ services: - %tables.notifications% - %tables.user_notifications% + php_ini: + class: phpbb_php_ini + request: class: phpbb_request From fc6bed28566590c26fab5845a6b94cf9b795e4da Mon Sep 17 00:00:00 2001 From: Bruno Ais Date: Tue, 16 Jul 2013 20:25:08 +0100 Subject: [PATCH 2260/2494] [ticket/11640] generate_text_for_display on functions_privmsgs.php sub-task of ticket PHPBB3-11635: find and fix all bypasses of generate_text_for_* PHPBB3-11640 --- phpBB/includes/functions_privmsgs.php | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/phpBB/includes/functions_privmsgs.php b/phpBB/includes/functions_privmsgs.php index 14278a2529..001cf7bba0 100644 --- a/phpBB/includes/functions_privmsgs.php +++ b/phpBB/includes/functions_privmsgs.php @@ -2018,14 +2018,12 @@ function message_history($msg_id, $user_id, $message_row, $folder, $in_post_mode $decoded_message = bbcode_nl2br($decoded_message); } - - if ($row['bbcode_bitfield']) - { - $bbcode->bbcode_second_pass($message, $row['bbcode_uid'], $row['bbcode_bitfield']); - } - - $message = bbcode_nl2br($message); - $message = smiley_text($message, !$row['enable_smilies']); + + $parse_flags = ($row['bbcode_bitfield'] ? OPTION_FLAG_BBCODE : 0); + $parse_flags |= ($row['enable_smilies'] ? OPTION_FLAG_SMILIES : 0); + + $message = generate_text_for_display($message, $row['bbcode_uid'], $row['bbcode_bitfield'], $parse_flags , false); + unset($parse_flags); $subject = censor_text($subject); From e1e8d4ed347cb1707ee4cfca8d05e679b575fe0c Mon Sep 17 00:00:00 2001 From: Bruno Ais Date: Tue, 16 Jul 2013 21:01:47 +0100 Subject: [PATCH 2261/2494] [ticket/11641] generate_text_for_display on mcp/mcp_pm_reports.php sub-task of ticket PHPBB3-11635: find and fix all bypasses of generate_text_for_* PHPBB3-11641 --- phpBB/includes/mcp/mcp_pm_reports.php | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/phpBB/includes/mcp/mcp_pm_reports.php b/phpBB/includes/mcp/mcp_pm_reports.php index 99ff397a66..dc953aae33 100644 --- a/phpBB/includes/mcp/mcp_pm_reports.php +++ b/phpBB/includes/mcp/mcp_pm_reports.php @@ -115,17 +115,8 @@ class mcp_pm_reports } // Process message, leave it uncensored - $message = $pm_info['message_text']; + $message = generate_text_for_display($pm_info['message_text'], $pm_info['bbcode_uid'], $pm_info['bbcode_bitfield'], ($pm_info['bbcode_bitfield'] ? OPTION_FLAG_BBCODE : 0) | OPTION_FLAG_SMILIES, false); - if ($pm_info['bbcode_bitfield']) - { - include_once($phpbb_root_path . 'includes/bbcode.' . $phpEx); - $bbcode = new bbcode($pm_info['bbcode_bitfield']); - $bbcode->bbcode_second_pass($message, $pm_info['bbcode_uid'], $pm_info['bbcode_bitfield']); - } - - $message = bbcode_nl2br($message); - $message = smiley_text($message); $report['report_text'] = make_clickable(bbcode_nl2br($report['report_text'])); if ($pm_info['message_attachment'] && $auth->acl_get('u_pm_download')) From e7bf3abd1ac79fabab7da925e55bd884aee0663d Mon Sep 17 00:00:00 2001 From: Bruno Ais Date: Tue, 16 Jul 2013 21:15:59 +0100 Subject: [PATCH 2262/2494] [ticket/11642] generate_text_for_display on mcp/mcp_post.php sub-task of ticket PHPBB3-11635: find and fix all bypasses of generate_text_for_* PHPBB3-11642 --- phpBB/includes/mcp/mcp_post.php | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/phpBB/includes/mcp/mcp_post.php b/phpBB/includes/mcp/mcp_post.php index 520c964228..235b2a44be 100644 --- a/phpBB/includes/mcp/mcp_post.php +++ b/phpBB/includes/mcp/mcp_post.php @@ -125,17 +125,7 @@ function mcp_post_details($id, $mode, $action) $post_unread = (isset($topic_tracking_info[$post_info['topic_id']]) && $post_info['post_time'] > $topic_tracking_info[$post_info['topic_id']]) ? true : false; // Process message, leave it uncensored - $message = $post_info['post_text']; - - if ($post_info['bbcode_bitfield']) - { - include_once($phpbb_root_path . 'includes/bbcode.' . $phpEx); - $bbcode = new bbcode($post_info['bbcode_bitfield']); - $bbcode->bbcode_second_pass($message, $post_info['bbcode_uid'], $post_info['bbcode_bitfield']); - } - - $message = bbcode_nl2br($message); - $message = smiley_text($message); + $message = generate_text_for_display($post_info['message_text'], $post_info['bbcode_uid'], $post_info['bbcode_bitfield'], ($post_info['bbcode_bitfield'] ? OPTION_FLAG_BBCODE : 0) | OPTION_FLAG_SMILIES, false); if ($post_info['post_attachment'] && $auth->acl_get('u_download') && $auth->acl_get('f_download', $post_info['forum_id'])) { From 596e9bb69df2f5d0c07c0b8201cc770bbe5253a0 Mon Sep 17 00:00:00 2001 From: Bruno Ais Date: Tue, 16 Jul 2013 21:20:22 +0100 Subject: [PATCH 2263/2494] [ticket/11643] generate_text_for_display on mcp/mcp_queue.php sub-task of ticket PHPBB3-11635: find and fix all bypasses of generate_text_for_* PHPBB3-11643 --- phpBB/includes/mcp/mcp_queue.php | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/phpBB/includes/mcp/mcp_queue.php b/phpBB/includes/mcp/mcp_queue.php index 24afa1f210..14490343c2 100644 --- a/phpBB/includes/mcp/mcp_queue.php +++ b/phpBB/includes/mcp/mcp_queue.php @@ -132,17 +132,7 @@ class mcp_queue $post_unread = (isset($topic_tracking_info[$post_info['topic_id']]) && $post_info['post_time'] > $topic_tracking_info[$post_info['topic_id']]) ? true : false; // Process message, leave it uncensored - $message = $post_info['post_text']; - - if ($post_info['bbcode_bitfield']) - { - include_once($phpbb_root_path . 'includes/bbcode.' . $phpEx); - $bbcode = new bbcode($post_info['bbcode_bitfield']); - $bbcode->bbcode_second_pass($message, $post_info['bbcode_uid'], $post_info['bbcode_bitfield']); - } - - $message = bbcode_nl2br($message); - $message = smiley_text($message); + $message = generate_text_for_display($post_info['message_text'], $post_info['bbcode_uid'], $post_info['bbcode_bitfield'], ($post_info['bbcode_bitfield'] ? OPTION_FLAG_BBCODE : 0) | OPTION_FLAG_SMILIES, false); if ($post_info['post_attachment'] && $auth->acl_get('u_download') && $auth->acl_get('f_download', $post_info['forum_id'])) { From d183431894b85ca2ebc778ccb8fd52ecf91082fb Mon Sep 17 00:00:00 2001 From: Bruno Ais Date: Tue, 16 Jul 2013 21:28:06 +0100 Subject: [PATCH 2264/2494] [ticket/11653] generate_text_for_display on mcp/mcp_topic.php sub-task of ticket PHPBB3-11635: find and fix all bypasses of generate_text_for_* PHPBB3-11653 --- phpBB/includes/mcp/mcp_topic.php | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/phpBB/includes/mcp/mcp_topic.php b/phpBB/includes/mcp/mcp_topic.php index e3dd5a6b57..3491f37bcb 100644 --- a/phpBB/includes/mcp/mcp_topic.php +++ b/phpBB/includes/mcp/mcp_topic.php @@ -213,13 +213,7 @@ function mcp_topic_view($id, $mode, $action) $message = $row['post_text']; $post_subject = ($row['post_subject'] != '') ? $row['post_subject'] : $topic_info['topic_title']; - if ($row['bbcode_bitfield']) - { - $bbcode->bbcode_second_pass($message, $row['bbcode_uid'], $row['bbcode_bitfield']); - } - - $message = bbcode_nl2br($message); - $message = smiley_text($message); + $message = generate_text_for_display($message, $row['bbcode_uid'], $row['bbcode_bitfield'], ($row['bbcode_bitfield'] ? OPTION_FLAG_BBCODE : 0) | OPTION_FLAG_SMILIES, false); if (!empty($attachments[$row['post_id']])) { From d6a747fbd0f80e9f2c93f09aab6a0a89ec5afd26 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 17 Jul 2013 17:27:15 +0200 Subject: [PATCH 2265/2494] [ticket/11582] Correctly add all required fixtures PHPBB3-11582 --- tests/functional/extension_permission_lang_test.php | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/functional/extension_permission_lang_test.php b/tests/functional/extension_permission_lang_test.php index badbdbb057..19adb89819 100644 --- a/tests/functional/extension_permission_lang_test.php +++ b/tests/functional/extension_permission_lang_test.php @@ -18,6 +18,7 @@ class phpbb_functional_extension_permission_lang_test extends phpbb_functional_t static protected $fixtures = array( 'foo/bar/language/en/', + 'foo/bar/event/', ); static public function setUpBeforeClass() From 96989e536dd5fc603f3598fa7a2a50414331d76c Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 17 Jul 2013 23:55:20 +0200 Subject: [PATCH 2266/2494] [ticket/11531] Use abstract class for avatar tests and unify test cases PHPBB3-11531 --- tests/functional/avatar_acp_groups_test.php | 152 ++++++++++++ tests/functional/avatar_acp_test.php | 139 ----------- tests/functional/avatar_acp_users_test.php | 152 ++++++++++++ tests/functional/avatar_test.php | 246 -------------------- tests/functional/avatar_ucp_groups_test.php | 151 ++++++++++++ tests/functional/avatar_ucp_users_test.php | 151 ++++++++++++ tests/functional/common_avatar_test.php | 80 +++++++ 7 files changed, 686 insertions(+), 385 deletions(-) create mode 100644 tests/functional/avatar_acp_groups_test.php delete mode 100644 tests/functional/avatar_acp_test.php create mode 100644 tests/functional/avatar_acp_users_test.php delete mode 100644 tests/functional/avatar_test.php create mode 100644 tests/functional/avatar_ucp_groups_test.php create mode 100644 tests/functional/avatar_ucp_users_test.php create mode 100644 tests/functional/common_avatar_test.php diff --git a/tests/functional/avatar_acp_groups_test.php b/tests/functional/avatar_acp_groups_test.php new file mode 100644 index 0000000000..62b7409bdb --- /dev/null +++ b/tests/functional/avatar_acp_groups_test.php @@ -0,0 +1,152 @@ + 'test@example.com', + 'avatar_gravatar_width' => 80, + 'avatar_gravatar_height' => 80, + ), + ), + // Gravatar with incorrect size + array( + 'The submitted avatar is 120 wide and 120 high. Avatars must be at least 20 wide and 20 high, but no larger than 90 wide and 90 high.', + 'avatar_driver_gravatar', + array( + 'avatar_gravatar_email' => 'test@example.com', + 'avatar_gravatar_width' => 120, + 'avatar_gravatar_height' => 120, + ), + ), + // Incorrect email supplied for gravatar + array( + 'EMAIL_INVALID_EMAIL', + 'avatar_driver_gravatar', + array( + 'avatar_gravatar_email' => 'test.example.com', + 'avatar_gravatar_width' => 80, + 'avatar_gravatar_height' => 80, + ), + ), + // Upload image from remote + array( + 'GROUP_UPDATED', + 'avatar_driver_upload', + array( + 'avatar_upload_url' => 'https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', + ), + ), + // Incorrect URL + array( + 'AVATAR_URL_INVALID', + 'avatar_driver_upload', + array( + 'avatar_upload_url' => 'https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0?s=80', + ), + ), + /* + // Does not work due to DomCrawler issue + // Valid file upload + array( + 'GROUP_UPDATED', + 'avatar_driver_upload', + array( + 'avatar_upload_file' => array('upload', $this->path . 'valid.jpg'), + ), + ), + */ + // Correct remote avatar + array( + 'GROUP_UPDATED', + 'avatar_driver_remote', + array( + 'avatar_remote_url' => 'https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', + 'avatar_remote_width' => 80, + 'avatar_remote_height' => 80, + ), + ), + // Remote avatar with incorrect size + array( + 'The submitted avatar is 120 wide and 120 high. Avatars must be at least 20 wide and 20 high, but no larger than 90 wide and 90 high.', + 'avatar_driver_remote', + array( + 'avatar_remote_url' => 'https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', + 'avatar_remote_width' => 120, + 'avatar_remote_height' => 120, + ), + ), + // Wrong driver selected + array( + 'NO_AVATAR_SELECTED', + 'avatar_driver_upload', + array( + 'avatar_remote_url' => 'https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', + 'avatar_remote_width' => 80, + 'avatar_remote_height' => 80, + ), + ), + // File does not exist, remote avatar currently does + // not check if file exists if size is specified + array( + 'GROUP_UPDATED', + 'avatar_driver_remote', + array( + 'avatar_remote_url' => 'https://www.phpbb.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', + 'avatar_remote_width' => 80, + 'avatar_remote_height' => 80, + ), + ), + // File does not exist and remote avatar errors when + // trying to get the image size + array( + 'UNABLE_GET_IMAGE_SIZE', + 'avatar_driver_remote', + array( + 'avatar_remote_url' => 'https://www.phpbb.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', + 'avatar_remote_width' => '', + 'avatar_remote_height' => '', + ), + ), + // Delete avatar image to reset group settings + array( + 'GROUP_UPDATED', + 'avatar_driver_gravatar', + array( + 'avatar_delete' => array('tick', ''), + ), + ), + ); + } + + /** + * @dataProvider avatar_acp_groups_data + */ + public function test_avatar_acp_groups($expected, $avatar_type, $data) + { + $this->assert_avatar_submit($expected, $avatar_type, $data); + } +} diff --git a/tests/functional/avatar_acp_test.php b/tests/functional/avatar_acp_test.php deleted file mode 100644 index 609ccbb477..0000000000 --- a/tests/functional/avatar_acp_test.php +++ /dev/null @@ -1,139 +0,0 @@ -path = __DIR__ . '/fixtures/files/'; - $this->login(); - $this->admin_login(); - $this->add_lang(array('acp/board', 'ucp', 'acp/users', 'acp/groups')); - } - - public function test_acp_settings() - { - $crawler = $this->request('GET', 'adm/index.php?i=acp_board&mode=avatar&sid=' . $this->sid); - // Check the default entries we should have - $this->assertContainsLang('ALLOW_GRAVATAR', $crawler->text()); - $this->assertContainsLang('ALLOW_REMOTE', $crawler->text()); - $this->assertContainsLang('ALLOW_AVATARS', $crawler->text()); - $this->assertContainsLang('ALLOW_LOCAL', $crawler->text()); - - // Now start setting the needed settings - $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); - $form['config[allow_avatar_local]']->select(1); - $form['config[allow_avatar_gravatar]']->select(1); - $form['config[allow_avatar_remote]']->select(1); - $form['config[allow_avatar_remote_upload]']->select(1); - $crawler = self::submit($form); - $this->assertContainsLang('CONFIG_UPDATED', $crawler->text()); - } - - public function test_user_acp_settings() - { - $crawler = $this->request('GET', 'adm/index.php?i=users&u=2&sid=' . $this->sid); - - // Select "Avatar" in the drop-down menu - $form = $crawler->selectButton($this->lang('GO'))->form(); - $form['mode']->select('avatar'); - $crawler = self::submit($form); - $this->assertContainsLang('AVATAR_TYPE', $crawler->text()); - - // Test if setting a gravatar avatar properly works - $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); - $form['avatar_driver']->select('avatar_driver_gravatar'); - $form['avatar_gravatar_email']->setValue('test@example.com'); - $form['avatar_gravatar_width']->setValue(80); - $form['avatar_gravatar_height']->setValue(80); - $crawler = self::submit($form); - $this->assertContainsLang('USER_AVATAR_UPDATED', $crawler->text()); - - // Go back to previous page - $crawler = $this->request('GET', 'adm/index.php?i=users&u=2&sid=' . $this->sid); - - // Select "Avatar" in the drop-down menu - $form = $crawler->selectButton($this->lang('GO'))->form(); - $form['mode']->select('avatar'); - $crawler = self::submit($form); - $this->assertContainsLang('AVATAR_TYPE', $crawler->text()); - - // Test uploading a remote avatar - $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); - $form['avatar_driver']->select('avatar_driver_upload'); - // use default gravatar supplied by test@example.com and default size = 80px - $form['avatar_upload_url']->setValue('https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg'); - $crawler = self::submit($form); - $this->assertContainsLang('USER_AVATAR_UPDATED', $crawler->text()); - - // Go back to previous page - $crawler = $this->request('GET', 'adm/index.php?i=users&u=2&sid=' . $this->sid); - - // Select "Avatar" in the drop-down menu - $form = $crawler->selectButton($this->lang('GO'))->form(); - $form['mode']->select('avatar'); - $crawler = self::submit($form); - $this->assertContainsLang('AVATAR_TYPE', $crawler->text()); - - // Submit gravatar with incorrect email and correct size - $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); - $form['avatar_driver']->select('avatar_driver_gravatar'); - $form['avatar_gravatar_email']->setValue('test.example.com'); - $form['avatar_gravatar_width']->setValue(80); - $form['avatar_gravatar_height']->setValue(80); - $crawler = self::submit($form); - $this->assertContainsLang('EMAIL_INVALID_EMAIL', $crawler->text()); - } - - public function test_group_acp_settings() - { - // Test setting group avatar of admin group - $crawler = $this->request('GET', 'adm/index.php?i=acp_groups&mode=manage&action=edit&g=5&sid=' . $this->sid); - $this->assertContainsLang('AVATAR_TYPE', $crawler->text()); - - // Test if setting a gravatar avatar properly works - $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); - $form['avatar_driver']->select('avatar_driver_gravatar'); - $form['avatar_gravatar_email']->setValue('test@example.com'); - $form['avatar_gravatar_width']->setValue(80); - $form['avatar_gravatar_height']->setValue(80); - $crawler = self::submit($form); - $this->assertContainsLang('GROUP_UPDATED', $crawler->text()); - - // Go back to previous page - $crawler = $this->request('GET', 'adm/index.php?i=acp_groups&mode=manage&action=edit&g=5&sid=' . $this->sid); - - // Test uploading a remote avatar - $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); - $form['avatar_driver']->select('avatar_driver_upload'); - // use default gravatar supplied by test@example.com and default size = 80px - $form['avatar_upload_url']->setValue('https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg'); - $crawler = self::submit($form); - $this->assertContainsLang('GROUP_UPDATED', $crawler->text()); - - // Go back to previous page - $crawler = $this->request('GET', 'adm/index.php?i=acp_groups&mode=manage&action=edit&g=5&sid=' . $this->sid); - - // Submit gravatar with incorrect email and correct size - $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); - $form['avatar_driver']->select('avatar_driver_gravatar'); - $form['avatar_gravatar_email']->setValue('test.example.com'); - $form['avatar_gravatar_width']->setValue(80); - $form['avatar_gravatar_height']->setValue(80); - $crawler = self::submit($form); - $this->assertContainsLang('EMAIL_INVALID_EMAIL', $crawler->text()); - } -} diff --git a/tests/functional/avatar_acp_users_test.php b/tests/functional/avatar_acp_users_test.php new file mode 100644 index 0000000000..38ebcc8940 --- /dev/null +++ b/tests/functional/avatar_acp_users_test.php @@ -0,0 +1,152 @@ + 'test@example.com', + 'avatar_gravatar_width' => 80, + 'avatar_gravatar_height' => 80, + ), + ), + // Gravatar with incorrect sizes + array( + 'The submitted avatar is 120 wide and 120 high. Avatars must be at least 20 wide and 20 high, but no larger than 90 wide and 90 high.', + 'avatar_driver_gravatar', + array( + 'avatar_gravatar_email' => 'test@example.com', + 'avatar_gravatar_width' => 120, + 'avatar_gravatar_height' => 120, + ), + ), + // Gravatar with incorrect email + array( + 'EMAIL_INVALID_EMAIL', + 'avatar_driver_gravatar', + array( + 'avatar_gravatar_email' => 'test.example.com', + 'avatar_gravatar_width' => 80, + 'avatar_gravatar_height' => 80, + ), + ), + // Remote avatar with correct link + array( + 'USER_AVATAR_UPDATED', + 'avatar_driver_upload', + array( + 'avatar_upload_url' => 'https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', + ), + ), + // Incorrect URL + array( + 'AVATAR_URL_INVALID', + 'avatar_driver_upload', + array( + 'avatar_upload_url' => 'https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0?s=80', + ), + ), + /* + // Does not work due to DomCrawler issue + // Valid file upload + array( + 'PROFILE_UPDATED', + 'avatar_driver_upload', + array( + 'avatar_upload_file' => array('upload', $this->path . 'valid.jpg'), + ), + ), + */ + // Correct remote avatar + array( + 'USER_AVATAR_UPDATED', + 'avatar_driver_remote', + array( + 'avatar_remote_url' => 'https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', + 'avatar_remote_width' => 80, + 'avatar_remote_height' => 80, + ), + ), + // Remote avatar with incorrect size + array( + 'The submitted avatar is 120 wide and 120 high. Avatars must be at least 20 wide and 20 high, but no larger than 90 wide and 90 high.', + 'avatar_driver_remote', + array( + 'avatar_remote_url' => 'https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', + 'avatar_remote_width' => 120, + 'avatar_remote_height' => 120, + ), + ), + // Wrong driver selected + array( + 'NO_AVATAR_SELECTED', + 'avatar_driver_upload', + array( + 'avatar_remote_url' => 'https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', + 'avatar_remote_width' => 80, + 'avatar_remote_height' => 80, + ), + ), + // File does not exist, remote avatar currently does + // not check if file exists if size is specified + array( + 'USER_AVATAR_UPDATED', + 'avatar_driver_remote', + array( + 'avatar_remote_url' => 'https://www.phpbb.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', + 'avatar_remote_width' => 80, + 'avatar_remote_height' => 80, + ), + ), + // File does not exist and remote avatar errors when + // trying to get the image size + array( + 'UNABLE_GET_IMAGE_SIZE', + 'avatar_driver_remote', + array( + 'avatar_remote_url' => 'https://www.phpbb.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', + 'avatar_remote_width' => '', + 'avatar_remote_height' => '', + ), + ), + // Reset avatar settings + array( + 'USER_AVATAR_UPDATED', + 'avatar_driver_gravatar', + array( + 'avatar_delete' => array('tick', ''), + ), + ), + ); + } + + /** + * @dataProvider avatar_acp_users_data + */ + public function test_avatar_acp_users($expected, $avatar_type, $data) + { + $this->assert_avatar_submit($expected, $avatar_type, $data); + } +} diff --git a/tests/functional/avatar_test.php b/tests/functional/avatar_test.php deleted file mode 100644 index c96ed46d30..0000000000 --- a/tests/functional/avatar_test.php +++ /dev/null @@ -1,246 +0,0 @@ -path = __DIR__ . '/fixtures/files/'; - $this->login(); - $this->admin_login(); - $this->add_lang(array('acp/board', 'ucp', 'acp/groups')); - } - - public function test_acp_settings() - { - $crawler = $this->request('GET', 'adm/index.php?i=acp_board&mode=avatar&sid=' . $this->sid); - // Check the default entries we should have - $this->assertContainsLang('ALLOW_GRAVATAR', $crawler->text()); - $this->assertContainsLang('ALLOW_REMOTE', $crawler->text()); - $this->assertContainsLang('ALLOW_AVATARS', $crawler->text()); - $this->assertContainsLang('ALLOW_LOCAL', $crawler->text()); - - // Now start setting the needed settings - $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); - $form['config[allow_avatar_local]']->select(1); - $form['config[allow_avatar_gravatar]']->select(1); - $form['config[allow_avatar_remote]']->select(1); - $form['config[allow_avatar_remote_upload]']->select(1); - $crawler = self::submit($form); - $this->assertContainsLang('CONFIG_UPDATED', $crawler->text()); - } - - public function test_gravatar_avatar() - { - // Get ACP settings - $crawler = $this->request('GET', 'adm/index.php?i=acp_board&mode=avatar&sid=' . $this->sid); - $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); - $this->form_content = $form->getValues(); - - // Check if required form elements exist - $crawler = $this->request('GET', 'ucp.php?i=ucp_profile&mode=avatar&sid=' . $this->sid); - $this->assertContainsLang('AVATAR_TYPE', $crawler->text()); - $this->assertContainsLang('AVATAR_DRIVER_GRAVATAR_TITLE', $crawler->filter('#avatar_driver')->text()); - $this->assertContainsLang('GRAVATAR_AVATAR_EMAIL', $crawler->text()); - - // Submit gravatar with correct email and correct size - $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); - $form['avatar_driver']->select('avatar_driver_gravatar'); - $form['avatar_gravatar_email']->setValue('test@example.com'); - $form['avatar_gravatar_width']->setValue(80); - $form['avatar_gravatar_height']->setValue(80); - $crawler = self::submit($form); - $this->assertContainsLang('PROFILE_UPDATED', $crawler->text()); - - // Submit gravatar with correct mail but incorrect size - $crawler = $this->request('GET', 'ucp.php?i=ucp_profile&mode=avatar&sid=' . $this->sid); - $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); - $form['avatar_driver']->select('avatar_driver_gravatar'); - $form['avatar_gravatar_email']->setValue('test@example.com'); - $form['avatar_gravatar_width']->setValue(120); - $form['avatar_gravatar_height']->setValue(120); - $crawler = self::submit($form); - $this->assertContains(sprintf($this->lang['AVATAR_WRONG_SIZE'], - $this->form_content['config[avatar_min_width]'], - $this->form_content['config[avatar_min_height]'], - $this->form_content['config[avatar_max_width]'], - $this->form_content['config[avatar_max_height]'], - '120', - '120' - ), $crawler->text()); - - // Submit gravatar with incorrect email and correct size - $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); - $form['avatar_driver']->select('avatar_driver_gravatar'); - $form['avatar_gravatar_email']->setValue('test.example.com'); - $form['avatar_gravatar_width']->setValue(80); - $form['avatar_gravatar_height']->setValue(80); - $crawler = self::submit($form); - $this->assertContainsLang('EMAIL_INVALID_EMAIL', $crawler->text()); - } - - public function test_upload_avatar() - { - // Check if required form elements exist - $crawler = $this->request('GET', 'ucp.php?i=ucp_profile&mode=avatar&sid=' . $this->sid); - $this->assertContainsLang('AVATAR_DRIVER_UPLOAD_TITLE', $crawler->filter('#avatar_driver')->text()); - $this->assertContainsLang('UPLOAD_AVATAR_FILE', $crawler->text()); - $this->assertContainsLang('UPLOAD_AVATAR_URL', $crawler->text()); - - // Upload remote avatar with correct size and correct link - $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); - $form['avatar_driver']->select('avatar_driver_upload'); - // use default gravatar supplied by test@example.com and default size = 80px - $form['avatar_upload_url']->setValue('https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg'); - $crawler = self::submit($form); - $this->assertContainsLang('PROFILE_UPDATED', $crawler->text()); - - // This will fail as the upload avatar currently expects a file that ends with an extension, e.g. .jpg - $crawler = $this->request('GET', 'ucp.php?i=ucp_profile&mode=avatar&sid=' . $this->sid); - $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); - $form['avatar_driver']->select('avatar_driver_upload'); - // use default gravatar supplied by test@example.com and size (s) = 80px - $form['avatar_upload_url']->setValue('https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0?s=80'); - $crawler = self::submit($form); - $this->assertContainsLang('AVATAR_URL_INVALID', $crawler->text()); - - // Submit gravatar with correct email and correct size - $crawler = $this->request('GET', 'ucp.php?i=ucp_profile&mode=avatar&sid=' . $this->sid); - $this->markTestIncomplete('Test fails due to bug in DomCrawler with Symfony < 2.2: https://github.com/symfony/symfony/issues/4674.'); - $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); - $form['avatar_driver']->select('avatar_driver_upload'); - $form['avatar_upload_file']->setValue($this->path . 'valid.jpg'); - $crawler = self::submit($form); - $this->assertContainsLang('PROFILE_UPDATED', $crawler->text()); - } - - public function test_remote_avatar() - { - // Get ACP settings - $crawler = $this->request('GET', 'adm/index.php?i=acp_board&mode=avatar&sid=' . $this->sid); - $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); - $this->form_content = $form->getValues(); - - // Check if required form elements exist - $crawler = $this->request('GET', 'ucp.php?i=ucp_profile&mode=avatar&sid=' . $this->sid); - $this->assertContainsLang('AVATAR_DRIVER_REMOTE_TITLE', $crawler->filter('#avatar_driver')->text()); - $this->assertContainsLang('LINK_REMOTE_AVATAR', $crawler->text()); - $this->assertContainsLang('LINK_REMOTE_SIZE', $crawler->text()); - - // Set remote avatar with correct size and correct link - $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); - $form['avatar_driver']->select('avatar_driver_remote'); - // use default gravatar supplied by test@example.com and default size = 80px - $form['avatar_remote_url']->setValue('https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg'); - $form['avatar_remote_width']->setValue(80); - $form['avatar_remote_height']->setValue(80); - $crawler = self::submit($form); - $this->assertContainsLang('PROFILE_UPDATED', $crawler->text()); - - // Set remote avatar with incorrect size - $crawler = $this->request('GET', 'ucp.php?i=ucp_profile&mode=avatar&sid=' . $this->sid); - $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); - $form['avatar_driver']->select('avatar_driver_remote'); - // use default gravatar supplied by test@example.com and size (s) = 80px - $form['avatar_remote_url']->setValue('https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg'); - $form['avatar_remote_width']->setValue(120); - $form['avatar_remote_height']->setValue(120); - $crawler = self::submit($form); - $this->assertContains(sprintf($this->lang['AVATAR_WRONG_SIZE'], - $this->form_content['config[avatar_min_width]'], - $this->form_content['config[avatar_min_height]'], - $this->form_content['config[avatar_max_width]'], - $this->form_content['config[avatar_max_height]'], - '120', - '120' - ), $crawler->text()); - - // Enter correct data in form entries but select incorrect avatar driver - $crawler = $this->request('GET', 'ucp.php?i=ucp_profile&mode=avatar&sid=' . $this->sid); - $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); - $form['avatar_driver']->select('avatar_driver_upload'); - // use default gravatar supplied by test@example.com and size (s) = 80px - $form['avatar_remote_url']->setValue('https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg'); - $form['avatar_remote_width']->setValue(80); - $form['avatar_remote_height']->setValue(80); - $crawler = self::submit($form); - $this->assertContainsLang('NO_AVATAR_SELECTED', $crawler->text()); - - /* - * Enter incorrect link to a remote avatar_driver - * Due to the fact that this link to phpbb.com will not serve a 404 error but rather a 404 page, - * the remote avatar will think that this is a properly working avatar. This Bug also exists in - * the current phpBB 3.0.11 release. - */ - $crawler = $this->request('GET', 'ucp.php?i=ucp_profile&mode=avatar&sid=' . $this->sid); - $this->markTestIncomplete('Test currently fails because the remote avatar does not seem to check if it is an image'); - $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); - $form['avatar_driver']->select('avatar_driver_remote'); - // use random incorrect link to phpBB.com - $form['avatar_remote_url']->setValue('https://www.phpbb.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg'); - $form['avatar_remote_width']->setValue(80); - $form['avatar_remote_height']->setValue(80); - $crawler = self::submit($form); - $this->assertContainsLang('NO_AVATAR_SELECTED', $crawler->text()); - } - - - public function test_group_ucp_settings() - { - // Test setting group avatar of admin group - $crawler = $this->request('GET', 'ucp.php?i=ucp_groups&mode=manage&action=edit&g=5&sid=' . $this->sid); - $this->assertContainsLang('AVATAR_TYPE', $crawler->text()); - - // Test if setting a gravatar avatar properly works - $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); - $form['avatar_driver']->select('avatar_driver_gravatar'); - $form['avatar_gravatar_email']->setValue('test@example.com'); - $form['avatar_gravatar_width']->setValue(80); - $form['avatar_gravatar_height']->setValue(80); - $crawler = self::submit($form); - $this->assertContainsLang('GROUP_UPDATED', $crawler->text()); - - // Go back to previous page - $crawler = $this->request('GET', 'ucp.php?i=ucp_groups&mode=manage&action=edit&g=5&sid=' . $this->sid); - - // Test uploading a remote avatar - $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); - $form['avatar_driver']->select('avatar_driver_upload'); - // use default gravatar supplied by test@example.com and default size = 80px - $form['avatar_upload_url']->setValue('https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg'); - $crawler = self::submit($form); - $this->assertContainsLang('GROUP_UPDATED', $crawler->text()); - - // Go back to previous page - $crawler = $this->request('GET', 'ucp.php?i=ucp_groups&mode=manage&action=edit&g=5&sid=' . $this->sid); - - // Submit gravatar with incorrect email and correct size - $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); - $form['avatar_driver']->select('avatar_driver_gravatar'); - $form['avatar_gravatar_email']->setValue('test.example.com'); - $form['avatar_gravatar_width']->setValue(80); - $form['avatar_gravatar_height']->setValue(80); - $crawler = self::submit($form); - $this->assertContainsLang('EMAIL_INVALID_EMAIL', $crawler->text()); - - // Delete avatar - $crawler = $this->request('GET', 'ucp.php?i=ucp_groups&mode=manage&action=edit&g=5&sid=' . $this->sid); - $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); - $form['avatar_delete']->tick(); - $crawler = self::submit($form); - $this->assertContainsLang('GROUP_UPDATED', $crawler->text()); - } -} diff --git a/tests/functional/avatar_ucp_groups_test.php b/tests/functional/avatar_ucp_groups_test.php new file mode 100644 index 0000000000..bd34f67491 --- /dev/null +++ b/tests/functional/avatar_ucp_groups_test.php @@ -0,0 +1,151 @@ + 'test@example.com', + 'avatar_gravatar_width' => 80, + 'avatar_gravatar_height' => 80, + ), + ), + // Gravatar with incorrect sizing + array( + 'The submitted avatar is 120 wide and 120 high. Avatars must be at least 20 wide and 20 high, but no larger than 90 wide and 90 high.', + 'avatar_driver_gravatar', + array( + 'avatar_gravatar_email' => 'test@example.com', + 'avatar_gravatar_width' => 120, + 'avatar_gravatar_height' => 120, + ), + ), + // Gravatar with incorrect email address + array( + 'EMAIL_INVALID_EMAIL', + 'avatar_driver_gravatar', + array( + 'avatar_gravatar_email' => 'test.example.com', + 'avatar_gravatar_width' => 80, + 'avatar_gravatar_height' => 80, + ), + ), + // Correct remote upload avatar + array( + 'GROUP_UPDATED', + 'avatar_driver_upload', + array( + 'avatar_upload_url' => 'https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', + ), + ), + // Incorrect URL + array( + 'AVATAR_URL_INVALID', + 'avatar_driver_upload', + array( + 'avatar_upload_url' => 'https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0?s=80', + ), + ), + /* + // Does not work due to DomCrawler issue + // Valid file upload + array( + 'GROUP_UPDATED', + 'avatar_driver_upload', + array( + 'avatar_upload_file' => array('upload', $this->path . 'valid.jpg'), + ), + ), + */ + // Correct remote avatar + array( + 'GROUP_UPDATED', + 'avatar_driver_remote', + array( + 'avatar_remote_url' => 'https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', + 'avatar_remote_width' => 80, + 'avatar_remote_height' => 80, + ), + ), + // Remote avatar with incorrect size + array( + 'The submitted avatar is 120 wide and 120 high. Avatars must be at least 20 wide and 20 high, but no larger than 90 wide and 90 high.', + 'avatar_driver_remote', + array( + 'avatar_remote_url' => 'https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', + 'avatar_remote_width' => 120, + 'avatar_remote_height' => 120, + ), + ), + // Wrong driver selected + array( + 'NO_AVATAR_SELECTED', + 'avatar_driver_upload', + array( + 'avatar_remote_url' => 'https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', + 'avatar_remote_width' => 80, + 'avatar_remote_height' => 80, + ), + ), + // File does not exist, remote avatar currently does + // not check if file exists if size is specified + array( + 'GROUP_UPDATED', + 'avatar_driver_remote', + array( + 'avatar_remote_url' => 'https://www.phpbb.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', + 'avatar_remote_width' => 80, + 'avatar_remote_height' => 80, + ), + ), + // File does not exist and remote avatar errors when + // trying to get the image size + array( + 'UNABLE_GET_IMAGE_SIZE', + 'avatar_driver_remote', + array( + 'avatar_remote_url' => 'https://www.phpbb.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', + 'avatar_remote_width' => '', + 'avatar_remote_height' => '', + ), + ), + array( + 'GROUP_UPDATED', + 'avatar_driver_gravatar', + array( + 'avatar_delete' => array('tick', ''), + ), + ), + ); + } + + /** + * @dataProvider avatar_ucp_groups_data + */ + public function test_avatar_ucp_groups($expected, $avatar_type, $data) + { + $this->assert_avatar_submit($expected, $avatar_type, $data); + } +} diff --git a/tests/functional/avatar_ucp_users_test.php b/tests/functional/avatar_ucp_users_test.php new file mode 100644 index 0000000000..6b2c2344b3 --- /dev/null +++ b/tests/functional/avatar_ucp_users_test.php @@ -0,0 +1,151 @@ + 'test@example.com', + 'avatar_gravatar_width' => 80, + 'avatar_gravatar_height' => 80, + ), + ), + // Gravatar with incorrect sizing + array( + 'The submitted avatar is 120 wide and 120 high. Avatars must be at least 20 wide and 20 high, but no larger than 90 wide and 90 high.', + 'avatar_driver_gravatar', + array( + 'avatar_gravatar_email' => 'test@example.com', + 'avatar_gravatar_width' => 120, + 'avatar_gravatar_height' => 120, + ), + ), + // Gravatar with incorrect email address + array( + 'EMAIL_INVALID_EMAIL', + 'avatar_driver_gravatar', + array( + 'avatar_gravatar_email' => 'test.example.com', + 'avatar_gravatar_width' => 80, + 'avatar_gravatar_height' => 80, + ), + ), + // Correct remote upload avatar + array( + 'PROFILE_UPDATED', + 'avatar_driver_upload', + array( + 'avatar_upload_url' => 'https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', + ), + ), + // Incorrect URL + array( + 'AVATAR_URL_INVALID', + 'avatar_driver_upload', + array( + 'avatar_upload_url' => 'https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0?s=80', + ), + ), + /* + // Does not work due to DomCrawler issue + // Valid file upload + array( + 'PROFILE_UPDATED', + 'avatar_driver_upload', + array( + 'avatar_upload_file' => array('upload', $this->path . 'valid.jpg'), + ), + ), + */ + // Correct remote avatar + array( + 'PROFILE_UPDATED', + 'avatar_driver_remote', + array( + 'avatar_remote_url' => 'https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', + 'avatar_remote_width' => 80, + 'avatar_remote_height' => 80, + ), + ), + // Remote avatar with incorrect size + array( + 'The submitted avatar is 120 wide and 120 high. Avatars must be at least 20 wide and 20 high, but no larger than 90 wide and 90 high.', + 'avatar_driver_remote', + array( + 'avatar_remote_url' => 'https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', + 'avatar_remote_width' => 120, + 'avatar_remote_height' => 120, + ), + ), + // Wrong driver selected + array( + 'NO_AVATAR_SELECTED', + 'avatar_driver_upload', + array( + 'avatar_remote_url' => 'https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', + 'avatar_remote_width' => 80, + 'avatar_remote_height' => 80, + ), + ), + // File does not exist, remote avatar currently does + // not check if file exists if size is specified + array( + 'PROFILE_UPDATED', + 'avatar_driver_remote', + array( + 'avatar_remote_url' => 'https://www.phpbb.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', + 'avatar_remote_width' => 80, + 'avatar_remote_height' => 80, + ), + ), + // File does not exist and remote avatar errors when + // trying to get the image size + array( + 'UNABLE_GET_IMAGE_SIZE', + 'avatar_driver_remote', + array( + 'avatar_remote_url' => 'https://www.phpbb.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', + 'avatar_remote_width' => '', + 'avatar_remote_height' => '', + ), + ), + array( + 'PROFILE_UPDATED', + 'avatar_driver_gravatar', + array( + 'avatar_delete' => array('tick', ''), + ), + ), + ); + } + + /** + * @dataProvider avatar_ucp_groups_data + */ + public function test_avatar_ucp_groups($expected, $avatar_type, $data) + { + $this->assert_avatar_submit($expected, $avatar_type, $data); + } +} diff --git a/tests/functional/common_avatar_test.php b/tests/functional/common_avatar_test.php new file mode 100644 index 0000000000..c0f21d07c2 --- /dev/null +++ b/tests/functional/common_avatar_test.php @@ -0,0 +1,80 @@ +path = __DIR__ . '/fixtures/files/'; + $this->login(); + $this->admin_login(); + $this->add_lang(array('acp/board', 'ucp', 'acp/users', 'acp/groups')); + $this->set_acp_settings(); + } + + private function set_acp_settings() + { + $crawler = self::request('GET', 'adm/index.php?i=acp_board&mode=avatar&sid=' . $this->sid); + // Check the default entries we should have + $this->assertContainsLang('ALLOW_GRAVATAR', $crawler->text()); + $this->assertContainsLang('ALLOW_REMOTE', $crawler->text()); + $this->assertContainsLang('ALLOW_AVATARS', $crawler->text()); + $this->assertContainsLang('ALLOW_LOCAL', $crawler->text()); + + // Now start setting the needed settings + $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); + $form['config[allow_avatar_local]']->select(1); + $form['config[allow_avatar_gravatar]']->select(1); + $form['config[allow_avatar_remote]']->select(1); + $form['config[allow_avatar_remote_upload]']->select(1); + $crawler = self::submit($form); + $this->assertContainsLang('CONFIG_UPDATED', $crawler->text()); + } + + public function assert_avatar_submit($expected, $type, $data, $button_text = 'SUBMIT') + { + $crawler = self::request('GET', $this->get_url() . '&sid=' . $this->sid); + + // Test if setting a gravatar avatar properly works + $form = $crawler->selectButton($this->lang($button_text))->form(); + $form['avatar_driver']->select($type); + + foreach ($data as $key => $value) + { + if (is_array($value)) + { + $form[$key]->$value[0]($value[1]); + } + else + { + $form[$key]->setValue($value); + } + } + + $crawler = self::submit($form); + + try + { + $this->assertContainsLang($expected, $crawler->text()); + } + catch (Exception $e) + { + $this->assertContains($expected, $crawler->text()); + } + } +} From 16b411616575cdd4023fb42bb77b56e43db735e0 Mon Sep 17 00:00:00 2001 From: Bruno Ais Date: Thu, 18 Jul 2013 16:15:36 +0100 Subject: [PATCH 2267/2494] [ticket/11654] generate_text_for_display on mcp/mcp_warn.php sub-task of ticket PHPBB3-11635: find and fix all bypasses of generate_text_for_* PHPBB3-11654 --- phpBB/includes/mcp/mcp_warn.php | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/phpBB/includes/mcp/mcp_warn.php b/phpBB/includes/mcp/mcp_warn.php index 4ef477775d..d0fcd8a77d 100644 --- a/phpBB/includes/mcp/mcp_warn.php +++ b/phpBB/includes/mcp/mcp_warn.php @@ -289,19 +289,7 @@ class mcp_warn // We want to make the message available here as a reminder // Parse the message and subject - $message = censor_text($user_row['post_text']); - - // Second parse bbcode here - if ($user_row['bbcode_bitfield']) - { - include_once($phpbb_root_path . 'includes/bbcode.' . $phpEx); - - $bbcode = new bbcode($user_row['bbcode_bitfield']); - $bbcode->bbcode_second_pass($message, $user_row['bbcode_uid'], $user_row['bbcode_bitfield']); - } - - $message = bbcode_nl2br($message); - $message = smiley_text($message); + $message = generate_text_for_display($message, $user_row['bbcode_uid'], $user_row['bbcode_bitfield'], ($user_row['bbcode_bitfield'] ? OPTION_FLAG_BBCODE : 0) | OPTION_FLAG_SMILIES, true); // Generate the appropriate user information for the user we are looking at if (!function_exists('phpbb_get_user_avatar')) From d05c04ae40326768e35464d42e3bd9e51b140155 Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Thu, 18 Jul 2013 19:10:36 +0300 Subject: [PATCH 2268/2494] [ticket/11712] Fixing typo in editor.js PHPBB3-11712 --- phpBB/styles/prosilver/template/editor.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/styles/prosilver/template/editor.js b/phpBB/styles/prosilver/template/editor.js index 235cc0025b..4c70ee345f 100644 --- a/phpBB/styles/prosilver/template/editor.js +++ b/phpBB/styles/prosilver/template/editor.js @@ -301,7 +301,7 @@ function colorPalette(dir, width, height) { var r = 0, g = 0, b = 0, - numberList = new Array(6); + numberList = new Array(6), color = '', html = ''; From f421c082f73b26f5578d14af7cdbfefd013f554a Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Thu, 18 Jul 2013 22:41:23 +0200 Subject: [PATCH 2269/2494] [ticket/11713] Do not remove module if it couldn't be deleted Up to now, the module or module category was always removed with jQuery, even if there was an error. With this change, the modules will not be deleted by jQuery if the return JSON array will have SUCCESS set to false. PHPBB3-11713 --- phpBB/adm/style/ajax.js | 6 ++++-- phpBB/includes/acp/acp_modules.php | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/phpBB/adm/style/ajax.js b/phpBB/adm/style/ajax.js index 6f21dfa6ac..efb0639f1b 100644 --- a/phpBB/adm/style/ajax.js +++ b/phpBB/adm/style/ajax.js @@ -127,8 +127,10 @@ phpbb.addAjaxCallback('activate_deactivate', function(res) { * The removes the parent row of the link or form that triggered the callback, * and is good for stuff like the removal of forums. */ -phpbb.addAjaxCallback('row_delete', function() { - $(this).parents('tr').remove(); +phpbb.addAjaxCallback('row_delete', function(res) { + if (res.SUCCESS !== false) { + $(this).parents('tr').remove(); + } }); diff --git a/phpBB/includes/acp/acp_modules.php b/phpBB/includes/acp/acp_modules.php index a1e681b29c..7a1d30196d 100644 --- a/phpBB/includes/acp/acp_modules.php +++ b/phpBB/includes/acp/acp_modules.php @@ -379,6 +379,7 @@ class acp_modules $json_response->send(array( 'MESSAGE_TITLE' => $user->lang('ERROR'), 'MESSAGE_TEXT' => implode('
    ', $errors), + 'SUCCESS' => false, )); } From ef7a7cac6dc3f313960a70462b084fbeaff9d4bd Mon Sep 17 00:00:00 2001 From: Bruno Ais Date: Fri, 19 Jul 2013 18:27:25 +0100 Subject: [PATCH 2270/2494] [ticket/11655] generate_text_for_display on ucp_pm_viewmessage.php sub-task of ticket PHPBB3-11635: find and fix all bypasses of generate_text_for_* PHPBB3-11655 --- phpBB/includes/ucp/ucp_pm_viewmessage.php | 28 ++--------------------- 1 file changed, 2 insertions(+), 26 deletions(-) diff --git a/phpBB/includes/ucp/ucp_pm_viewmessage.php b/phpBB/includes/ucp/ucp_pm_viewmessage.php index b7d2dd6821..0a8a3d55ab 100644 --- a/phpBB/includes/ucp/ucp_pm_viewmessage.php +++ b/phpBB/includes/ucp/ucp_pm_viewmessage.php @@ -76,17 +76,7 @@ function view_message($id, $mode, $folder_id, $msg_id, $folder, $message_row) $user_info = get_user_information($author_id, $message_row); // Parse the message and subject - $message = censor_text($message_row['message_text']); - - // Second parse bbcode here - if ($message_row['bbcode_bitfield']) - { - $bbcode->bbcode_second_pass($message, $message_row['bbcode_uid'], $message_row['bbcode_bitfield']); - } - - // Always process smilies after parsing bbcodes - $message = bbcode_nl2br($message); - $message = smiley_text($message); + $message = generate_text_for_display($message_row['message_text'], $message_row['bbcode_uid'], $message_row['bbcode_bitfield'], ($message_row['bbcode_bitfield'] ? OPTION_FLAG_BBCODE : 0) | OPTION_FLAG_SMILIES, true); // Replace naughty words such as farty pants $message_row['message_subject'] = censor_text($message_row['message_subject']); @@ -160,21 +150,7 @@ function view_message($id, $mode, $folder_id, $msg_id, $folder, $message_row) // End signature parsing, only if needed if ($signature) { - $signature = censor_text($signature); - - if ($user_info['user_sig_bbcode_bitfield']) - { - if ($bbcode === false) - { - include($phpbb_root_path . 'includes/bbcode.' . $phpEx); - $bbcode = new bbcode($user_info['user_sig_bbcode_bitfield']); - } - - $bbcode->bbcode_second_pass($signature, $user_info['user_sig_bbcode_uid'], $user_info['user_sig_bbcode_bitfield']); - } - - $signature = bbcode_nl2br($signature); - $signature = smiley_text($signature); + $signature = generate_text_for_display($signature, $user_info['bbcode_uid'], $user_info['bbcode_bitfield'], ($user_info['bbcode_bitfield'] ? OPTION_FLAG_BBCODE : 0) | OPTION_FLAG_SMILIES, true); } $url = append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm'); From b92f660ed389414a1d8550a5ba92804f7151eb79 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Fri, 19 Jul 2013 13:08:41 -0500 Subject: [PATCH 2271/2494] [ticket/11718] Twig lexer only correcting statements in IF, not ELSEIF PHPBB3-11718 --- phpBB/phpbb/template/twig/lexer.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/phpBB/phpbb/template/twig/lexer.php b/phpBB/phpbb/template/twig/lexer.php index 46412ad048..cb44de76f1 100644 --- a/phpBB/phpbb/template/twig/lexer.php +++ b/phpBB/phpbb/template/twig/lexer.php @@ -219,19 +219,20 @@ class phpbb_template_twig_lexer extends Twig_Lexer { $callback = function($matches) { + $inner = $matches[2]; // Replace $TEST with definition.TEST - $matches[1] = preg_replace('#\s\$([a-zA-Z_0-9]+)#', ' definition.$1', $matches[1]); + $inner = preg_replace('#\s\$([a-zA-Z_0-9]+)#', ' definition.$1', $inner); // Replace .test with test|length - $matches[1] = preg_replace('#\s\.([a-zA-Z_0-9\.]+)#', ' $1|length', $matches[1]); + $inner = preg_replace('#\s\.([a-zA-Z_0-9\.]+)#', ' $1|length', $inner); - return ''; + return ""; }; // Replace our "div by" with Twig's divisibleby (Twig does not like test names with spaces) $code = preg_replace('# div by ([0-9]+)#', ' divisibleby($1)', $code); - return preg_replace_callback('##', $callback, $code); + return preg_replace_callback('##', $callback, $code); } /** From 1c59ad87b026794e44ce6c7561feabd3eb7bf165 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Fri, 19 Jul 2013 13:34:08 -0500 Subject: [PATCH 2272/2494] [ticket/11718] Quick test for fixes in ELSEIF PHPBB3-11718 --- tests/template/template_test.php | 2 +- tests/template/templates/define.html | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/template/template_test.php b/tests/template/template_test.php index 802f0c19ba..86af97cc84 100644 --- a/tests/template/template_test.php +++ b/tests/template/template_test.php @@ -151,7 +151,7 @@ class phpbb_template_template_test extends phpbb_template_template_test_case array(), array('loop' => array(array(), array(), array(), array(), array(), array(), array()), 'test' => array(array()), 'test.deep' => array(array()), 'test.deep.defines' => array(array())), array(), - "xyz\nabc\nabc\nbar\nbar\nabc", + "xyz\nabc\n\$VALUE == 'abc'\nabc\nbar\nbar\nabc", ), array( 'define_advanced.html', diff --git a/tests/template/templates/define.html b/tests/template/templates/define.html index 4e6d0ee793..5b8ed9ac40 100644 --- a/tests/template/templates/define.html +++ b/tests/template/templates/define.html @@ -2,6 +2,11 @@ {$VALUE} {$VALUE} + +$VALUE != 'abc' + +$VALUE == 'abc' + {$INCLUDED_VALUE} {$VALUE} From 375976eb38882f42155f1f7fa2c849add8dbcf08 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Fri, 19 Jul 2013 14:12:28 -0500 Subject: [PATCH 2273/2494] [ticket/11707] Twig DEFINE not working as expected PHPBB3-11707 --- phpBB/phpbb/template/twig/lexer.php | 12 ++++++++---- tests/template/template_test.php | 2 +- tests/template/templates/define.html | 2 ++ 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/phpBB/phpbb/template/twig/lexer.php b/phpBB/phpbb/template/twig/lexer.php index 46412ad048..1fa4c5b3e6 100644 --- a/phpBB/phpbb/template/twig/lexer.php +++ b/phpBB/phpbb/template/twig/lexer.php @@ -126,10 +126,14 @@ class phpbb_template_twig_lexer extends Twig_Lexer { $callback = function($matches) { - // Remove any quotes that may have been used in different implementations - // E.g. DEFINE $TEST = 'blah' vs INCLUDE foo - // Replace {} with start/end to parse variables (' ~ TEST ~ '.html) - $matches[2] = str_replace(array('"', "'", '{', '}'), array('', '', "' ~ ", " ~ '"), $matches[2]); + // Remove matching quotes at the beginning/end if a statement; + // E.g. 'asdf'"' -> asdf'" + // E.g. "asdf'"" -> asdf'" + // E.g. 'asdf'" -> 'asdf'" + $matches[2] = preg_replace('#^([\'"])?(.+?)\1$#', '$2', $matches[2]); + + // Replace template variables with start/end to parse variables (' ~ TEST ~ '.html) + $matches[2] = preg_replace('#{([a-zA-Z0-9_\.$]+)}#', "'~ \$1 ~'", $matches[2]); // Surround the matches in single quotes ('' ~ TEST ~ '.html') return ""; diff --git a/tests/template/template_test.php b/tests/template/template_test.php index 802f0c19ba..2ed0f03698 100644 --- a/tests/template/template_test.php +++ b/tests/template/template_test.php @@ -151,7 +151,7 @@ class phpbb_template_template_test extends phpbb_template_template_test_case array(), array('loop' => array(array(), array(), array(), array(), array(), array(), array()), 'test' => array(array()), 'test.deep' => array(array()), 'test.deep.defines' => array(array())), array(), - "xyz\nabc\nabc\nbar\nbar\nabc", + "xyz\nabc\nabc\nbar\nbar\nabc\ntest!@#$%^&*()_-=+{}[]:;\",<.>/?", ), array( 'define_advanced.html', diff --git a/tests/template/templates/define.html b/tests/template/templates/define.html index 4e6d0ee793..f0df16a8f8 100644 --- a/tests/template/templates/define.html +++ b/tests/template/templates/define.html @@ -7,3 +7,5 @@ {$VALUE} {$VALUE} + +{$VALUE} From e48f0555e9e40a9e1d3e9a60e25a9f206c565efe Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sat, 20 Jul 2013 14:36:38 +0200 Subject: [PATCH 2274/2494] [ticket/11531] Reduced amount of avatar functional tests to minimum The tests were reduced to only test one case that should be correct and one that should fail. Different test cases have been split up over the specific test files for the acp groups, acp users, ucp groups, and ucp users page. PHPBB3-11531 --- tests/functional/avatar_acp_groups_test.php | 89 -------------------- tests/functional/avatar_acp_users_test.php | 91 --------------------- tests/functional/avatar_ucp_groups_test.php | 80 ------------------ tests/functional/avatar_ucp_users_test.php | 89 -------------------- 4 files changed, 349 deletions(-) diff --git a/tests/functional/avatar_acp_groups_test.php b/tests/functional/avatar_acp_groups_test.php index 62b7409bdb..9fdc29cc76 100644 --- a/tests/functional/avatar_acp_groups_test.php +++ b/tests/functional/avatar_acp_groups_test.php @@ -42,95 +42,6 @@ class phpbb_functional_avatar_acp_groups_test extends phpbb_functional_common_av 'avatar_gravatar_height' => 120, ), ), - // Incorrect email supplied for gravatar - array( - 'EMAIL_INVALID_EMAIL', - 'avatar_driver_gravatar', - array( - 'avatar_gravatar_email' => 'test.example.com', - 'avatar_gravatar_width' => 80, - 'avatar_gravatar_height' => 80, - ), - ), - // Upload image from remote - array( - 'GROUP_UPDATED', - 'avatar_driver_upload', - array( - 'avatar_upload_url' => 'https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', - ), - ), - // Incorrect URL - array( - 'AVATAR_URL_INVALID', - 'avatar_driver_upload', - array( - 'avatar_upload_url' => 'https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0?s=80', - ), - ), - /* - // Does not work due to DomCrawler issue - // Valid file upload - array( - 'GROUP_UPDATED', - 'avatar_driver_upload', - array( - 'avatar_upload_file' => array('upload', $this->path . 'valid.jpg'), - ), - ), - */ - // Correct remote avatar - array( - 'GROUP_UPDATED', - 'avatar_driver_remote', - array( - 'avatar_remote_url' => 'https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', - 'avatar_remote_width' => 80, - 'avatar_remote_height' => 80, - ), - ), - // Remote avatar with incorrect size - array( - 'The submitted avatar is 120 wide and 120 high. Avatars must be at least 20 wide and 20 high, but no larger than 90 wide and 90 high.', - 'avatar_driver_remote', - array( - 'avatar_remote_url' => 'https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', - 'avatar_remote_width' => 120, - 'avatar_remote_height' => 120, - ), - ), - // Wrong driver selected - array( - 'NO_AVATAR_SELECTED', - 'avatar_driver_upload', - array( - 'avatar_remote_url' => 'https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', - 'avatar_remote_width' => 80, - 'avatar_remote_height' => 80, - ), - ), - // File does not exist, remote avatar currently does - // not check if file exists if size is specified - array( - 'GROUP_UPDATED', - 'avatar_driver_remote', - array( - 'avatar_remote_url' => 'https://www.phpbb.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', - 'avatar_remote_width' => 80, - 'avatar_remote_height' => 80, - ), - ), - // File does not exist and remote avatar errors when - // trying to get the image size - array( - 'UNABLE_GET_IMAGE_SIZE', - 'avatar_driver_remote', - array( - 'avatar_remote_url' => 'https://www.phpbb.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', - 'avatar_remote_width' => '', - 'avatar_remote_height' => '', - ), - ), // Delete avatar image to reset group settings array( 'GROUP_UPDATED', diff --git a/tests/functional/avatar_acp_users_test.php b/tests/functional/avatar_acp_users_test.php index 38ebcc8940..0afd05e530 100644 --- a/tests/functional/avatar_acp_users_test.php +++ b/tests/functional/avatar_acp_users_test.php @@ -22,26 +22,6 @@ class phpbb_functional_avatar_acp_users_test extends phpbb_functional_common_ava public function avatar_acp_users_data() { return array( - // Correct gravatar - array( - 'USER_AVATAR_UPDATED', - 'avatar_driver_gravatar', - array( - 'avatar_gravatar_email' => 'test@example.com', - 'avatar_gravatar_width' => 80, - 'avatar_gravatar_height' => 80, - ), - ), - // Gravatar with incorrect sizes - array( - 'The submitted avatar is 120 wide and 120 high. Avatars must be at least 20 wide and 20 high, but no larger than 90 wide and 90 high.', - 'avatar_driver_gravatar', - array( - 'avatar_gravatar_email' => 'test@example.com', - 'avatar_gravatar_width' => 120, - 'avatar_gravatar_height' => 120, - ), - ), // Gravatar with incorrect email array( 'EMAIL_INVALID_EMAIL', @@ -60,77 +40,6 @@ class phpbb_functional_avatar_acp_users_test extends phpbb_functional_common_ava 'avatar_upload_url' => 'https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', ), ), - // Incorrect URL - array( - 'AVATAR_URL_INVALID', - 'avatar_driver_upload', - array( - 'avatar_upload_url' => 'https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0?s=80', - ), - ), - /* - // Does not work due to DomCrawler issue - // Valid file upload - array( - 'PROFILE_UPDATED', - 'avatar_driver_upload', - array( - 'avatar_upload_file' => array('upload', $this->path . 'valid.jpg'), - ), - ), - */ - // Correct remote avatar - array( - 'USER_AVATAR_UPDATED', - 'avatar_driver_remote', - array( - 'avatar_remote_url' => 'https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', - 'avatar_remote_width' => 80, - 'avatar_remote_height' => 80, - ), - ), - // Remote avatar with incorrect size - array( - 'The submitted avatar is 120 wide and 120 high. Avatars must be at least 20 wide and 20 high, but no larger than 90 wide and 90 high.', - 'avatar_driver_remote', - array( - 'avatar_remote_url' => 'https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', - 'avatar_remote_width' => 120, - 'avatar_remote_height' => 120, - ), - ), - // Wrong driver selected - array( - 'NO_AVATAR_SELECTED', - 'avatar_driver_upload', - array( - 'avatar_remote_url' => 'https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', - 'avatar_remote_width' => 80, - 'avatar_remote_height' => 80, - ), - ), - // File does not exist, remote avatar currently does - // not check if file exists if size is specified - array( - 'USER_AVATAR_UPDATED', - 'avatar_driver_remote', - array( - 'avatar_remote_url' => 'https://www.phpbb.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', - 'avatar_remote_width' => 80, - 'avatar_remote_height' => 80, - ), - ), - // File does not exist and remote avatar errors when - // trying to get the image size - array( - 'UNABLE_GET_IMAGE_SIZE', - 'avatar_driver_remote', - array( - 'avatar_remote_url' => 'https://www.phpbb.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', - 'avatar_remote_width' => '', - 'avatar_remote_height' => '', - ), - ), // Reset avatar settings array( 'USER_AVATAR_UPDATED', diff --git a/tests/functional/avatar_ucp_groups_test.php b/tests/functional/avatar_ucp_groups_test.php index bd34f67491..233b7d36e1 100644 --- a/tests/functional/avatar_ucp_groups_test.php +++ b/tests/functional/avatar_ucp_groups_test.php @@ -22,44 +22,6 @@ class phpbb_functional_avatar_ucp_groups_test extends phpbb_functional_common_av public function avatar_ucp_groups_data() { return array( - // Gravatar with correct settings - array( - 'GROUP_UPDATED', - 'avatar_driver_gravatar', - array( - 'avatar_gravatar_email' => 'test@example.com', - 'avatar_gravatar_width' => 80, - 'avatar_gravatar_height' => 80, - ), - ), - // Gravatar with incorrect sizing - array( - 'The submitted avatar is 120 wide and 120 high. Avatars must be at least 20 wide and 20 high, but no larger than 90 wide and 90 high.', - 'avatar_driver_gravatar', - array( - 'avatar_gravatar_email' => 'test@example.com', - 'avatar_gravatar_width' => 120, - 'avatar_gravatar_height' => 120, - ), - ), - // Gravatar with incorrect email address - array( - 'EMAIL_INVALID_EMAIL', - 'avatar_driver_gravatar', - array( - 'avatar_gravatar_email' => 'test.example.com', - 'avatar_gravatar_width' => 80, - 'avatar_gravatar_height' => 80, - ), - ), - // Correct remote upload avatar - array( - 'GROUP_UPDATED', - 'avatar_driver_upload', - array( - 'avatar_upload_url' => 'https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', - ), - ), // Incorrect URL array( 'AVATAR_URL_INVALID', @@ -89,48 +51,6 @@ class phpbb_functional_avatar_ucp_groups_test extends phpbb_functional_common_av 'avatar_remote_height' => 80, ), ), - // Remote avatar with incorrect size - array( - 'The submitted avatar is 120 wide and 120 high. Avatars must be at least 20 wide and 20 high, but no larger than 90 wide and 90 high.', - 'avatar_driver_remote', - array( - 'avatar_remote_url' => 'https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', - 'avatar_remote_width' => 120, - 'avatar_remote_height' => 120, - ), - ), - // Wrong driver selected - array( - 'NO_AVATAR_SELECTED', - 'avatar_driver_upload', - array( - 'avatar_remote_url' => 'https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', - 'avatar_remote_width' => 80, - 'avatar_remote_height' => 80, - ), - ), - // File does not exist, remote avatar currently does - // not check if file exists if size is specified - array( - 'GROUP_UPDATED', - 'avatar_driver_remote', - array( - 'avatar_remote_url' => 'https://www.phpbb.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', - 'avatar_remote_width' => 80, - 'avatar_remote_height' => 80, - ), - ), - // File does not exist and remote avatar errors when - // trying to get the image size - array( - 'UNABLE_GET_IMAGE_SIZE', - 'avatar_driver_remote', - array( - 'avatar_remote_url' => 'https://www.phpbb.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', - 'avatar_remote_width' => '', - 'avatar_remote_height' => '', - ), - ), array( 'GROUP_UPDATED', 'avatar_driver_gravatar', diff --git a/tests/functional/avatar_ucp_users_test.php b/tests/functional/avatar_ucp_users_test.php index 6b2c2344b3..fa6282abf4 100644 --- a/tests/functional/avatar_ucp_users_test.php +++ b/tests/functional/avatar_ucp_users_test.php @@ -32,73 +32,6 @@ class phpbb_functional_avatar_ucp_users_test extends phpbb_functional_common_ava 'avatar_gravatar_height' => 80, ), ), - // Gravatar with incorrect sizing - array( - 'The submitted avatar is 120 wide and 120 high. Avatars must be at least 20 wide and 20 high, but no larger than 90 wide and 90 high.', - 'avatar_driver_gravatar', - array( - 'avatar_gravatar_email' => 'test@example.com', - 'avatar_gravatar_width' => 120, - 'avatar_gravatar_height' => 120, - ), - ), - // Gravatar with incorrect email address - array( - 'EMAIL_INVALID_EMAIL', - 'avatar_driver_gravatar', - array( - 'avatar_gravatar_email' => 'test.example.com', - 'avatar_gravatar_width' => 80, - 'avatar_gravatar_height' => 80, - ), - ), - // Correct remote upload avatar - array( - 'PROFILE_UPDATED', - 'avatar_driver_upload', - array( - 'avatar_upload_url' => 'https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', - ), - ), - // Incorrect URL - array( - 'AVATAR_URL_INVALID', - 'avatar_driver_upload', - array( - 'avatar_upload_url' => 'https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0?s=80', - ), - ), - /* - // Does not work due to DomCrawler issue - // Valid file upload - array( - 'PROFILE_UPDATED', - 'avatar_driver_upload', - array( - 'avatar_upload_file' => array('upload', $this->path . 'valid.jpg'), - ), - ), - */ - // Correct remote avatar - array( - 'PROFILE_UPDATED', - 'avatar_driver_remote', - array( - 'avatar_remote_url' => 'https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', - 'avatar_remote_width' => 80, - 'avatar_remote_height' => 80, - ), - ), - // Remote avatar with incorrect size - array( - 'The submitted avatar is 120 wide and 120 high. Avatars must be at least 20 wide and 20 high, but no larger than 90 wide and 90 high.', - 'avatar_driver_remote', - array( - 'avatar_remote_url' => 'https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', - 'avatar_remote_width' => 120, - 'avatar_remote_height' => 120, - ), - ), // Wrong driver selected array( 'NO_AVATAR_SELECTED', @@ -109,28 +42,6 @@ class phpbb_functional_avatar_ucp_users_test extends phpbb_functional_common_ava 'avatar_remote_height' => 80, ), ), - // File does not exist, remote avatar currently does - // not check if file exists if size is specified - array( - 'PROFILE_UPDATED', - 'avatar_driver_remote', - array( - 'avatar_remote_url' => 'https://www.phpbb.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', - 'avatar_remote_width' => 80, - 'avatar_remote_height' => 80, - ), - ), - // File does not exist and remote avatar errors when - // trying to get the image size - array( - 'UNABLE_GET_IMAGE_SIZE', - 'avatar_driver_remote', - array( - 'avatar_remote_url' => 'https://www.phpbb.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', - 'avatar_remote_width' => '', - 'avatar_remote_height' => '', - ), - ), array( 'PROFILE_UPDATED', 'avatar_driver_gravatar', From b3ad2fc23f35fce2a888bb8f9c35ece247e0bc09 Mon Sep 17 00:00:00 2001 From: Bruno Ais Date: Sat, 20 Jul 2013 16:16:10 +0100 Subject: [PATCH 2275/2494] [ticket/11642] Fixed typo in the variable name. sub-task of ticket PHPBB3-11635: find and fix all bypasses of generate_text_for_* PHPBB3-11642 --- phpBB/includes/mcp/mcp_post.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/mcp/mcp_post.php b/phpBB/includes/mcp/mcp_post.php index 235b2a44be..e8768957e0 100644 --- a/phpBB/includes/mcp/mcp_post.php +++ b/phpBB/includes/mcp/mcp_post.php @@ -125,7 +125,7 @@ function mcp_post_details($id, $mode, $action) $post_unread = (isset($topic_tracking_info[$post_info['topic_id']]) && $post_info['post_time'] > $topic_tracking_info[$post_info['topic_id']]) ? true : false; // Process message, leave it uncensored - $message = generate_text_for_display($post_info['message_text'], $post_info['bbcode_uid'], $post_info['bbcode_bitfield'], ($post_info['bbcode_bitfield'] ? OPTION_FLAG_BBCODE : 0) | OPTION_FLAG_SMILIES, false); + $message = generate_text_for_display($post_info['post_text'], $post_info['bbcode_uid'], $post_info['bbcode_bitfield'], ($post_info['bbcode_bitfield'] ? OPTION_FLAG_BBCODE : 0) | OPTION_FLAG_SMILIES, false); if ($post_info['post_attachment'] && $auth->acl_get('u_download') && $auth->acl_get('f_download', $post_info['forum_id'])) { From f1bfbde3f5bdb9191057f28dd623dc2a3a530bf7 Mon Sep 17 00:00:00 2001 From: Bruno Ais Date: Sat, 20 Jul 2013 16:19:27 +0100 Subject: [PATCH 2276/2494] [ticket/11643] Fixed typo in the variable name. sub-task of ticket PHPBB3-11635: find and fix all bypasses of generate_text_for_* PHPBB3-11643 --- phpBB/includes/mcp/mcp_queue.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/mcp/mcp_queue.php b/phpBB/includes/mcp/mcp_queue.php index 14490343c2..2c95dc6a67 100644 --- a/phpBB/includes/mcp/mcp_queue.php +++ b/phpBB/includes/mcp/mcp_queue.php @@ -132,7 +132,7 @@ class mcp_queue $post_unread = (isset($topic_tracking_info[$post_info['topic_id']]) && $post_info['post_time'] > $topic_tracking_info[$post_info['topic_id']]) ? true : false; // Process message, leave it uncensored - $message = generate_text_for_display($post_info['message_text'], $post_info['bbcode_uid'], $post_info['bbcode_bitfield'], ($post_info['bbcode_bitfield'] ? OPTION_FLAG_BBCODE : 0) | OPTION_FLAG_SMILIES, false); + $message = generate_text_for_display($post_info['post_text'], $post_info['bbcode_uid'], $post_info['bbcode_bitfield'], ($post_info['bbcode_bitfield'] ? OPTION_FLAG_BBCODE : 0) | OPTION_FLAG_SMILIES, false); if ($post_info['post_attachment'] && $auth->acl_get('u_download') && $auth->acl_get('f_download', $post_info['forum_id'])) { From fc64e6997f9d54362a7fbe2f7a366fb8ba497deb Mon Sep 17 00:00:00 2001 From: Bruno Ais Date: Sat, 20 Jul 2013 16:24:31 +0100 Subject: [PATCH 2277/2494] [ticket/11638] Fixed typo in the variable name. sub-task of ticket PHPBB3-11635: find and fix all bypasses of generate_text_for_* PHPBB3-11638 --- phpBB/viewtopic.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index 9274539ab4..d18478fbfa 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -1385,7 +1385,7 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i) } // Parse the message and subject - $message = generate_text_for_display($message, $row['bbcode_uid'], $row['bbcode_bitfield'], ($row['bbcode_bitfield'] ? OPTION_FLAG_BBCODE : 0) | OPTION_FLAG_SMILIES, true); + $message = generate_text_for_display($row['post_text'], $row['bbcode_uid'], $row['bbcode_bitfield'], ($row['bbcode_bitfield'] ? OPTION_FLAG_BBCODE : 0) | OPTION_FLAG_SMILIES, true); if (!empty($attachments[$row['post_id']])) { From 73414823048cac8c2963b2034ba13daaf60c3fee Mon Sep 17 00:00:00 2001 From: Bruno Ais Date: Sat, 20 Jul 2013 16:25:05 +0100 Subject: [PATCH 2278/2494] [ticket/11638] Fixed not following guidelines for brackets sub-task of ticket PHPBB3-11635: find and fix all bypasses of generate_text_for_* PHPBB3-11638 --- phpBB/viewtopic.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index d18478fbfa..de76d1186d 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -830,7 +830,8 @@ if (!empty($topic_data['poll_start'])) $parse_bbcode_flags = OPTION_FLAG_SMILIES; - if(empty($poll_info[0]['bbcode_bitfield'])){ + if(empty($poll_info[0]['bbcode_bitfield'])) + { $parse_bbcode_flags |= OPTION_FLAG_BBCODE; } From 0ef1bcac2b3152bbf389b512fd373987a7d0edce Mon Sep 17 00:00:00 2001 From: Bruno Ais Date: Sat, 20 Jul 2013 16:31:08 +0100 Subject: [PATCH 2279/2494] [ticket/11639] Whitespace fixing sub-task of ticket PHPBB3-11635: find and fix all bypasses of generate_text_for_* PHPBB3-11639 --- phpBB/includes/functions_posting.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index ad75ed1079..49a1797321 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -1108,7 +1108,7 @@ function topic_review($topic_id, $forum_id, $mode = 'topic_review', $cur_post_id $parse_flags = ($row['bbcode_bitfield'] ? OPTION_FLAG_BBCODE : 0); $parse_flags |= ($row['enable_smilies'] ? OPTION_FLAG_SMILIES : 0); // Do not censor text because it has already been censored before - $message = generate_text_for_display($message, $row['bbcode_uid'], $row['bbcode_bitfield'], $parse_flags , false); + $message = generate_text_for_display($message, $row['bbcode_uid'], $row['bbcode_bitfield'], $parse_flags, false); unset($parse_flags); From 67ba959d9b34ff727b77206f4c706b1fbe024cb2 Mon Sep 17 00:00:00 2001 From: Bruno Ais Date: Sat, 20 Jul 2013 16:35:28 +0100 Subject: [PATCH 2280/2494] [ticket/11654] first parameter fail sub-task of ticket PHPBB3-11635: find and fix all bypasses of generate_text_for_* PHPBB3-11654 --- phpBB/includes/mcp/mcp_warn.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/mcp/mcp_warn.php b/phpBB/includes/mcp/mcp_warn.php index d0fcd8a77d..65cf641418 100644 --- a/phpBB/includes/mcp/mcp_warn.php +++ b/phpBB/includes/mcp/mcp_warn.php @@ -289,7 +289,7 @@ class mcp_warn // We want to make the message available here as a reminder // Parse the message and subject - $message = generate_text_for_display($message, $user_row['bbcode_uid'], $user_row['bbcode_bitfield'], ($user_row['bbcode_bitfield'] ? OPTION_FLAG_BBCODE : 0) | OPTION_FLAG_SMILIES, true); + $message = generate_text_for_display($user_row['post_text'], $user_row['bbcode_uid'], $user_row['bbcode_bitfield'], ($user_row['bbcode_bitfield'] ? OPTION_FLAG_BBCODE : 0) | OPTION_FLAG_SMILIES, true); // Generate the appropriate user information for the user we are looking at if (!function_exists('phpbb_get_user_avatar')) From 43b172c8aabbfbcc5180a3f3ad5daede45fcc041 Mon Sep 17 00:00:00 2001 From: Bruno Ais Date: Sat, 20 Jul 2013 16:44:24 +0100 Subject: [PATCH 2281/2494] [ticket/11655] wrong var names for the uid and for the bitfield sub-task of ticket PHPBB3-11635: find and fix all bypasses of generate_text_for_* PHPBB3-11655 --- phpBB/includes/ucp/ucp_pm_viewmessage.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/ucp/ucp_pm_viewmessage.php b/phpBB/includes/ucp/ucp_pm_viewmessage.php index 0a8a3d55ab..52a28e3552 100644 --- a/phpBB/includes/ucp/ucp_pm_viewmessage.php +++ b/phpBB/includes/ucp/ucp_pm_viewmessage.php @@ -150,7 +150,7 @@ function view_message($id, $mode, $folder_id, $msg_id, $folder, $message_row) // End signature parsing, only if needed if ($signature) { - $signature = generate_text_for_display($signature, $user_info['bbcode_uid'], $user_info['bbcode_bitfield'], ($user_info['bbcode_bitfield'] ? OPTION_FLAG_BBCODE : 0) | OPTION_FLAG_SMILIES, true); + $signature = generate_text_for_display($signature, $user_info['user_sig_bbcode_uid'], $user_info['user_sig_bbcode_bitfield'], ($user_info['user_sig_bbcode_bitfield'] ? OPTION_FLAG_BBCODE : 0) | OPTION_FLAG_SMILIES, true); } $url = append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm'); From 603dc1f78617e64e41f61daf85f463b0465123ec Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sat, 20 Jul 2013 15:09:28 +0200 Subject: [PATCH 2282/2494] [ticket/11717] Use topic_posts_approved instead of topic_replies Due to the move to soft-delete, the topic_replies column no longer exists in the topics table. Instead, the column topic_posts_approved should be used. PHPBB3-11717 --- phpBB/includes/functions_posting.php | 5 ++++- phpBB/includes/ucp/ucp_prefs.php | 2 +- phpBB/phpbb/feed/topic.php | 2 +- phpBB/search.php | 4 ++-- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index 03565c27bb..f80736a6c4 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -1995,6 +1995,9 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u } } + $first_post_topic_info = ($post_mode == 'edit_first_post' && (($post_visibility == ITEM_DELETED && $data['topic_posts_softdeleted'] == 1) || + ($post_visibility == ITEM_UNAPPROVED && $data['topic_posts_unapproved'] == 1) || + ($post_visibility == ITEM_APPROVED && $data['topic_posts_approved'] == 1))); // Fix the post's and topic's visibility and first/last post information, when the post is edited if (($post_mode != 'post' && $post_mode != 'reply') && $data['post_visibility'] != $post_visibility) { @@ -2007,7 +2010,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u $phpbb_content_visibility = $phpbb_container->get('content.visibility'); $phpbb_content_visibility->set_post_visibility($post_visibility, $data['post_id'], $data['topic_id'], $data['forum_id'], $user->data['user_id'], time(), '', $is_starter, $is_latest); } - else if ($post_mode == 'edit_last_post' || $post_mode == 'edit_topic' || ($post_mode == 'edit_first_post' && !$data['topic_replies'])) + else if ($post_mode == 'edit_last_post' || $post_mode == 'edit_topic' || $first_post_topic_info) { if ($post_visibility == ITEM_APPROVED || $data['topic_visibility'] == $post_visibility) { diff --git a/phpBB/includes/ucp/ucp_prefs.php b/phpBB/includes/ucp/ucp_prefs.php index 7c3286c1d1..f24578da84 100644 --- a/phpBB/includes/ucp/ucp_prefs.php +++ b/phpBB/includes/ucp/ucp_prefs.php @@ -267,7 +267,7 @@ class ucp_prefs $limit_topic_days = array(0 => $user->lang['ALL_TOPICS'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']); $sort_by_topic_text = array('a' => $user->lang['AUTHOR'], 't' => $user->lang['POST_TIME'], 'r' => $user->lang['REPLIES'], 's' => $user->lang['SUBJECT'], 'v' => $user->lang['VIEWS']); - $sort_by_topic_sql = array('a' => 't.topic_first_poster_name', 't' => 't.topic_last_post_time', 'r' => 't.topic_replies', 's' => 't.topic_title', 'v' => 't.topic_views'); + $sort_by_topic_sql = array('a' => 't.topic_first_poster_name', 't' => 't.topic_last_post_time', 'r' => 't.topic_posts_approved', 's' => 't.topic_title', 'v' => 't.topic_views'); // Post ordering options $limit_post_days = array(0 => $user->lang['ALL_POSTS'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']); diff --git a/phpBB/phpbb/feed/topic.php b/phpBB/phpbb/feed/topic.php index 36f958ac60..696b0f5a52 100644 --- a/phpBB/phpbb/feed/topic.php +++ b/phpBB/phpbb/feed/topic.php @@ -43,7 +43,7 @@ class phpbb_feed_topic extends phpbb_feed_post_base function open() { - $sql = 'SELECT f.forum_options, f.forum_password, t.topic_id, t.forum_id, t.topic_visibility, t.topic_title, t.topic_time, t.topic_views, t.topic_replies, t.topic_type + $sql = 'SELECT f.forum_options, f.forum_password, t.topic_id, t.forum_id, t.topic_visibility, t.topic_title, t.topic_time, t.topic_views, t.topic_posts_approved, t.topic_type FROM ' . TOPICS_TABLE . ' t LEFT JOIN ' . FORUMS_TABLE . ' f ON (f.forum_id = t.forum_id) diff --git a/phpBB/search.php b/phpBB/search.php index 2429c81dae..8bcbfc498b 100644 --- a/phpBB/search.php +++ b/phpBB/search.php @@ -366,7 +366,7 @@ if ($keywords || $author || $author_id || $search_id || $submit) { $sql = "SELECT p.post_id FROM $sort_join" . POSTS_TABLE . ' p, ' . TOPICS_TABLE . " t - WHERE t.topic_replies = 0 + WHERE t.topic_posts_approved = 1 AND p.topic_id = t.topic_id $last_post_time AND $m_approve_posts_fid_sql @@ -378,7 +378,7 @@ if ($keywords || $author || $author_id || $search_id || $submit) { $sql = 'SELECT DISTINCT ' . $sort_by_sql[$sort_key] . ", p.topic_id FROM $sort_join" . POSTS_TABLE . ' p, ' . TOPICS_TABLE . " t - WHERE t.topic_replies = 0 + WHERE t.topic_posts_approved = 1 AND t.topic_moved_id = 0 AND p.topic_id = t.topic_id $last_post_time From 56df3fd8cafde10b230c925c7eb455003ae76382 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sat, 20 Jul 2013 22:02:51 +0200 Subject: [PATCH 2283/2494] [ticket/11720] Do not call $captcha->validate if $captcha is not set PHPBB3-11566 changed big parts of code. Unfortunately, a call to $captcha->validate was added that is being called even if $captcha hasn't been initialized. This change will fix this issue. PHPBB3-11720 --- phpBB/report.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/phpBB/report.php b/phpBB/report.php index c92ecdfdcc..c909b4fcf3 100644 --- a/phpBB/report.php +++ b/phpBB/report.php @@ -146,10 +146,13 @@ $s_hidden_fields = ''; // Submit report? if ($submit && $reason_id) { - $visual_confirmation_response = $captcha->validate(); - if ($visual_confirmation_response) + if (isset($captcha)) { - $error[] = $visual_confirmation_response; + $visual_confirmation_response = $captcha->validate(); + if ($visual_confirmation_response) + { + $error[] = $visual_confirmation_response; + } } $sql = 'SELECT * From 865bf0db3d5ca3f8bbadd009ce0a5e8324de49c1 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sat, 20 Jul 2013 22:35:45 +0200 Subject: [PATCH 2284/2494] [ticket/11720] Add functional test for submitting report as user The already existing functional tests were not ran as the filename was missing the appended "_test". PHPBB3-11720 --- ...ptcha.php => report_post_captcha_test.php} | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) rename tests/functional/{report_post_captcha.php => report_post_captcha_test.php} (89%) diff --git a/tests/functional/report_post_captcha.php b/tests/functional/report_post_captcha_test.php similarity index 89% rename from tests/functional/report_post_captcha.php rename to tests/functional/report_post_captcha_test.php index af713775c5..8283465041 100644 --- a/tests/functional/report_post_captcha.php +++ b/tests/functional/report_post_captcha_test.php @@ -12,13 +12,6 @@ */ class phpbb_functional_report_post_captcha_test extends phpbb_functional_test_case { - public function test_user_report_post() - { - $this->login(); - $crawler = self::request('GET', 'report.php?f=2&p=1'); - $this->assertNotContains($this->lang('CONFIRM_CODE'), $crawler->filter('html')->text()); - } - public function test_guest_report_post() { $crawler = self::request('GET', 'report.php?f=2&p=1'); @@ -31,6 +24,18 @@ class phpbb_functional_report_post_captcha_test extends phpbb_functional_test_ca $this->set_reporting_guest(-1); } + public function test_user_report_post() + { + $this->login(); + $crawler = self::request('GET', 'report.php?f=2&p=1'); + $this->assertNotContains($this->lang('CONFIRM_CODE'), $crawler->filter('html')->text()); + + $this->add_lang('mcp'); + $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); + $crawler = self::submit($form); + $this->assertContains($this->lang('POST_REPORTED_SUCCESS'), $crawler->text()); + } + protected function set_reporting_guest($report_post_allowed) { $this->login(); From 570e21285bab8f98b45dfa46d0c6b6a8de885055 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Mon, 22 Jul 2013 03:30:27 +0200 Subject: [PATCH 2285/2494] [ticket/11722] Remove reference assignment for $captcha in report.php PHPBB3-11722 --- phpBB/report.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/report.php b/phpBB/report.php index 063e55e571..c9ca57ecbe 100644 --- a/phpBB/report.php +++ b/phpBB/report.php @@ -147,7 +147,7 @@ else if ($config['enable_post_confirm'] && !$user->data['is_registered']) { include($phpbb_root_path . 'includes/captcha/captcha_factory.' . $phpEx); - $captcha =& phpbb_captcha_factory::get_instance($config['captcha_plugin']); + $captcha = phpbb_captcha_factory::get_instance($config['captcha_plugin']); $captcha->init(CONFIRM_REPORT); } From effafa4b4d82e8f0debcda2e84e03117433e5a7d Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 22 Jul 2013 10:42:46 +0200 Subject: [PATCH 2286/2494] [ticket/11717] Add 'has' to boolean variable and reduce line length PHPBB3-11717 --- phpBB/includes/functions_posting.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index f80736a6c4..103cc81205 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -1995,9 +1995,10 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u } } - $first_post_topic_info = ($post_mode == 'edit_first_post' && (($post_visibility == ITEM_DELETED && $data['topic_posts_softdeleted'] == 1) || - ($post_visibility == ITEM_UNAPPROVED && $data['topic_posts_unapproved'] == 1) || - ($post_visibility == ITEM_APPROVED && $data['topic_posts_approved'] == 1))); + $first_post_has_topic_info = ($post_mode == 'edit_first_post' && + (($post_visibility == ITEM_DELETED && $data['topic_posts_softdeleted'] == 1) || + ($post_visibility == ITEM_UNAPPROVED && $data['topic_posts_unapproved'] == 1) || + ($post_visibility == ITEM_APPROVED && $data['topic_posts_approved'] == 1))); // Fix the post's and topic's visibility and first/last post information, when the post is edited if (($post_mode != 'post' && $post_mode != 'reply') && $data['post_visibility'] != $post_visibility) { @@ -2010,7 +2011,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u $phpbb_content_visibility = $phpbb_container->get('content.visibility'); $phpbb_content_visibility->set_post_visibility($post_visibility, $data['post_id'], $data['topic_id'], $data['forum_id'], $user->data['user_id'], time(), '', $is_starter, $is_latest); } - else if ($post_mode == 'edit_last_post' || $post_mode == 'edit_topic' || $first_post_topic_info) + else if ($post_mode == 'edit_last_post' || $post_mode == 'edit_topic' || $first_post_has_topic_info) { if ($post_visibility == ITEM_APPROVED || $data['topic_visibility'] == $post_visibility) { From 580131b5c316925107d1c8bed586b1c6044f4c6e Mon Sep 17 00:00:00 2001 From: Bruno Ais Date: Mon, 22 Jul 2013 11:16:47 +0100 Subject: [PATCH 2287/2494] [ticket/11640] removed the unset sub-task of ticket PHPBB3-11635: find and fix all bypasses of generate_text_for_* PHPBB3-11640 --- phpBB/includes/functions_privmsgs.php | 1 - 1 file changed, 1 deletion(-) diff --git a/phpBB/includes/functions_privmsgs.php b/phpBB/includes/functions_privmsgs.php index 001cf7bba0..15907feedd 100644 --- a/phpBB/includes/functions_privmsgs.php +++ b/phpBB/includes/functions_privmsgs.php @@ -2023,7 +2023,6 @@ function message_history($msg_id, $user_id, $message_row, $folder, $in_post_mode $parse_flags |= ($row['enable_smilies'] ? OPTION_FLAG_SMILIES : 0); $message = generate_text_for_display($message, $row['bbcode_uid'], $row['bbcode_bitfield'], $parse_flags , false); - unset($parse_flags); $subject = censor_text($subject); From 128af41a7ce983a1b54406e5c467e40b14af7afc Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 22 Jul 2013 12:47:32 +0200 Subject: [PATCH 2288/2494] [ticket/11725] Use new paths for phpbb_class_loader in file.php In the PR #1559, the paths were changed from "{$phpbb_root_path}includes/" to "{$phpbb_root_path}phpbb/" for the class loader. However, this was not changed in all files that use it. PHPBB3-11725 --- phpBB/download/file.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpBB/download/file.php b/phpBB/download/file.php index cf7128b25b..5a091db7c7 100644 --- a/phpBB/download/file.php +++ b/phpBB/download/file.php @@ -41,7 +41,7 @@ if (isset($_GET['avatar'])) exit; } - require($phpbb_root_path . 'includes/class_loader.' . $phpEx); + require($phpbb_root_path . 'phpbb/class_loader.' . $phpEx); require($phpbb_root_path . 'includes/constants.' . $phpEx); require($phpbb_root_path . 'includes/functions.' . $phpEx); @@ -50,7 +50,7 @@ if (isset($_GET['avatar'])) require($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx); // Setup class loader first - $phpbb_class_loader = new phpbb_class_loader('phpbb_', "{$phpbb_root_path}includes/", $phpEx); + $phpbb_class_loader = new phpbb_class_loader('phpbb_', "{$phpbb_root_path}phpbb/", $phpEx); $phpbb_class_loader->register(); $phpbb_class_loader_ext = new phpbb_class_loader('phpbb_ext_', "{$phpbb_root_path}ext/", $phpEx); $phpbb_class_loader_ext->register(); From 2eb32ef515c59b19bd1bb4f7e6d56736733ea9d8 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 22 Jul 2013 13:38:19 +0200 Subject: [PATCH 2289/2494] [ticket/11531] Check if uploaded avatar is properly displayed in tests PHPBB3-11531 --- tests/functional/avatar_ucp_users_test.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/functional/avatar_ucp_users_test.php b/tests/functional/avatar_ucp_users_test.php index fa6282abf4..f828559e0d 100644 --- a/tests/functional/avatar_ucp_users_test.php +++ b/tests/functional/avatar_ucp_users_test.php @@ -59,4 +59,20 @@ class phpbb_functional_avatar_ucp_users_test extends phpbb_functional_common_ava { $this->assert_avatar_submit($expected, $avatar_type, $data); } + + public function test_display_upload_avatar() + { + $this->assert_avatar_submit('PROFILE_UPDATED', + 'avatar_driver_upload', + array( + 'avatar_upload_url' => 'https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', + ) + ); + + $crawler = self::request('GET', $this->get_url() . '&sid=' . $this->sid); + $avatar_link = $crawler->filter('img')->attr('src'); + $crawler = self::request('GET', $avatar_link . '&sid=' . $this->sid, array(), false); + $content = self::$client->getResponse()->getContent(); + self::assertEquals(false, stripos(trim($content), 'debug'), 'Output contains debug message'); + } } From 43538fdca15b9b6cd1d64a7808b4e4a4d2027221 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Mon, 22 Jul 2013 12:23:53 -0500 Subject: [PATCH 2290/2494] [ticket/11726] Don't run lint tests on Travis on postgres PHPBB3-11726 --- travis/phpunit-postgres-travis.xml | 3 --- 1 file changed, 3 deletions(-) diff --git a/travis/phpunit-postgres-travis.xml b/travis/phpunit-postgres-travis.xml index 3d1b574716..aa829f4d30 100644 --- a/travis/phpunit-postgres-travis.xml +++ b/travis/phpunit-postgres-travis.xml @@ -17,9 +17,6 @@ tests/functional tests/lint_test.php - - tests/lint_test.php - ../tests/functional From 62d7a0570071bb572fa60e502596d21eaee57376 Mon Sep 17 00:00:00 2001 From: asperous Date: Thu, 11 Jul 2013 14:58:41 -0700 Subject: [PATCH 2291/2494] [ticket/11620] Abstracted session setUp into a test_case class When defining a database test case with a setUp function, it is important to call the parent's setup function, because that is when the database is setup. PHPBB3-11620 --- tests/session/create_test.php | 16 ++--------- tests/session/extract_hostname_test.php | 16 ++--------- tests/session/extract_page_test.php | 16 ++--------- tests/session/validate_referrer_test.php | 16 ++--------- .../phpbb_session_test_case.php | 27 +++++++++++++++++++ 5 files changed, 35 insertions(+), 56 deletions(-) create mode 100644 tests/test_framework/phpbb_session_test_case.php diff --git a/tests/session/create_test.php b/tests/session/create_test.php index 4a7484321c..a8248ae62c 100644 --- a/tests/session/create_test.php +++ b/tests/session/create_test.php @@ -7,27 +7,15 @@ * */ -require_once dirname(__FILE__) . '/testable_facade.php'; +require_once dirname(__FILE__) . '/../test_framework/phpbb_session_test_case.php'; -class phpbb_session_create_test extends phpbb_database_test_case +class phpbb_session_create_test extends phpbb_session_test_case { - public $session_factory; - public $db; - public $session_facade; - public function getDataSet() { return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/sessions_full.xml'); } - public function setUp() - { - $this->session_factory = new phpbb_session_testable_factory; - $this->db = $this->new_dbal(); - $this->session_facade = - new phpbb_session_testable_facade($this->db, $this->session_factory); - } - static function bot($bot_agent, $user_id, $bot_ip) { return array(array( diff --git a/tests/session/extract_hostname_test.php b/tests/session/extract_hostname_test.php index cd71f82b17..5ff43cbb60 100644 --- a/tests/session/extract_hostname_test.php +++ b/tests/session/extract_hostname_test.php @@ -7,27 +7,15 @@ * */ -require_once dirname(__FILE__) . '/testable_facade.php'; +require_once dirname(__FILE__) . '/../test_framework/phpbb_session_test_case.php'; -class phpbb_session_extract_hostname_test extends phpbb_database_test_case +class phpbb_session_extract_hostname_test extends phpbb_session_test_case { - public $session_factory; - public $db; - public $session_facade; - public function getDataSet() { return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/sessions_empty.xml'); } - public function setUp() - { - $this->session_factory = new phpbb_session_testable_factory; - $this->db = $this->new_dbal(); - $this->session_facade = - new phpbb_session_testable_facade($this->db, $this->session_factory); - } - static public function extract_current_hostname_data() { return array ( diff --git a/tests/session/extract_page_test.php b/tests/session/extract_page_test.php index c17845526f..9346973bc4 100644 --- a/tests/session/extract_page_test.php +++ b/tests/session/extract_page_test.php @@ -7,27 +7,15 @@ * */ -require_once dirname(__FILE__) . '/testable_facade.php'; +require_once dirname(__FILE__) . '/../test_framework/phpbb_session_test_case.php'; -class phpbb_session_extract_page_test extends phpbb_database_test_case +class phpbb_session_extract_page_test extends phpbb_session_test_case { - public $session_factory; - public $db; - public $session_facade; - public function getDataSet() { return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/sessions_empty.xml'); } - public function setUp() - { - $this->session_factory = new phpbb_session_testable_factory; - $this->db = $this->new_dbal(); - $this->session_facade = - new phpbb_session_testable_facade($this->db, $this->session_factory); - } - static public function extract_current_page_data() { return array( diff --git a/tests/session/validate_referrer_test.php b/tests/session/validate_referrer_test.php index 1428187f27..f91ac5f1f9 100644 --- a/tests/session/validate_referrer_test.php +++ b/tests/session/validate_referrer_test.php @@ -7,27 +7,15 @@ * */ -require_once dirname(__FILE__) . '/testable_facade.php'; +require_once dirname(__FILE__) . '/../test_framework/phpbb_session_test_case.php'; -class phpbb_session_validate_referrer_test extends phpbb_database_test_case +class phpbb_session_validate_referrer_test extends phpbb_session_test_case { - public $session_factory; - public $db; - public $session_facade; - public function getDataSet() { return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/sessions_empty.xml'); } - public function setUp() - { - $this->session_factory = new phpbb_session_testable_factory; - $this->db = $this->new_dbal(); - $this->session_facade = - new phpbb_session_testable_facade($this->db, $this->session_factory); - } - static function referrer_inputs() { $ex = "example.org"; $alt = "example.com"; diff --git a/tests/test_framework/phpbb_session_test_case.php b/tests/test_framework/phpbb_session_test_case.php new file mode 100644 index 0000000000..6ff7d8e2ef --- /dev/null +++ b/tests/test_framework/phpbb_session_test_case.php @@ -0,0 +1,27 @@ +session_factory = new phpbb_session_testable_factory; + $this->db = $this->new_dbal(); + $this->session_facade = + new phpbb_session_testable_facade($this->db, $this->session_factory); + } +} From 0f708646241ed43c86793d8cbe0b5fea7397f0e6 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 22 Jul 2013 20:06:30 +0200 Subject: [PATCH 2292/2494] [ticket/11582] Move global declaration to beginning of block PHPBB3-11582 --- phpBB/includes/acp/acp_permission_roles.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/phpBB/includes/acp/acp_permission_roles.php b/phpBB/includes/acp/acp_permission_roles.php index 5657cbe675..17e48d6576 100644 --- a/phpBB/includes/acp/acp_permission_roles.php +++ b/phpBB/includes/acp/acp_permission_roles.php @@ -25,7 +25,7 @@ class acp_permission_roles function main($id, $mode) { - global $db, $user, $auth, $template, $cache; + global $db, $user, $auth, $template, $cache, $phpbb_container; global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx; include_once($phpbb_root_path . 'includes/functions_user.' . $phpEx); @@ -306,7 +306,6 @@ class acp_permission_roles trigger_error($user->lang['NO_ROLE_SELECTED'] . adm_back_link($this->u_action), E_USER_WARNING); } - global $phpbb_container; $phpbb_permissions = $phpbb_container->get('acl.permissions'); $template->assign_vars(array( From 87e65224d45c0571e90e00156abd165bd6bbe059 Mon Sep 17 00:00:00 2001 From: Andy Chase Date: Mon, 22 Jul 2013 11:07:17 -0700 Subject: [PATCH 2293/2494] [ticket/11620] Cherry-Pick merge tests from session-storage-cache PHPBB3-11620 --- tests/session/testable_facade.php | 16 +++++----- tests/session/unset_admin_test.php | 48 ++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+), 7 deletions(-) create mode 100644 tests/session/unset_admin_test.php diff --git a/tests/session/testable_facade.php b/tests/session/testable_facade.php index b9f61b80cb..1cb1c94b52 100644 --- a/tests/session/testable_facade.php +++ b/tests/session/testable_facade.php @@ -77,14 +77,16 @@ class phpbb_session_testable_facade function session_begin ( $update_session_page = true, $config_overrides = array(), - $request_overrides = array() + $request_overrides = array(), + $cookies_overrides = array() ) { + $this->session_factory->merge_config_data($config_overrides); + $this->session_factory->merge_server_data($request_overrides); + $this->session_factory->set_cookies($cookies_overrides); $session = $this->session_factory->get_session($this->db); - global $config, $request; - $request->merge(phpbb_request_interface::SERVER, $request_overrides); - $config = array_merge($config, $config_overrides); - return $session->session_begin($update_session_page); + $session->session_begin($update_session_page); + return $session; } function session_create ( @@ -93,8 +95,8 @@ class phpbb_session_testable_facade $persist_login = false, $viewonline = true, array $config_overrides = array(), - $user_agent, - $ip_address, + $user_agent = 'user agent', + $ip_address = '127.0.0.1', array $bot_overrides = array(), $uri_sid = "" ) diff --git a/tests/session/unset_admin_test.php b/tests/session/unset_admin_test.php new file mode 100644 index 0000000000..bbb5eb1439 --- /dev/null +++ b/tests/session/unset_admin_test.php @@ -0,0 +1,48 @@ +createXMLDataSet(dirname(__FILE__).'/fixtures/sessions_full.xml'); + } + + function get_test_session() + { + return $this->session_facade->session_begin( + true, + // Config + array( + 'session_length' => time(), // need to do this to allow sessions started at time 0 + ), + // Server + array( + 'HTTP_USER_AGENT' => "user agent", + 'REMOTE_ADDR' => "127.0.0.1", + ), + // Cookies + array( + '_sid' => 'bar_session000000000000000000000', + '_u' => 4, + ) + ); + } + + public function test_unset_admin() + { + $session = $this->get_test_session(); + $this->assertEquals(1, $session->data['session_admin'], 'should be an admin before test starts'); + $session->unset_admin(); + $session = $this->get_test_session(); + $this->assertEquals(0, $session->data['session_admin'], 'should be not be an admin after unset_admin'); + } +} From f7da773c06534cd9b359bc5e6430469c2ff9a4bc Mon Sep 17 00:00:00 2001 From: asperous Date: Thu, 11 Jul 2013 20:23:12 -0700 Subject: [PATCH 2294/2494] [ticket/11620] Added manual key test PHPBB3-11620 --- tests/session/fixtures/sessions_key.xml | 44 +++++++++++++++++++++++++ tests/session/session_key_tests.php | 28 ++++++++++++++++ 2 files changed, 72 insertions(+) create mode 100644 tests/session/fixtures/sessions_key.xml create mode 100644 tests/session/session_key_tests.php diff --git a/tests/session/fixtures/sessions_key.xml b/tests/session/fixtures/sessions_key.xml new file mode 100644 index 0000000000..246d284557 --- /dev/null +++ b/tests/session/fixtures/sessions_key.xml @@ -0,0 +1,44 @@ + + + + key_id + user_id + last_ip + last_login + + a87ff679a2f3e71d9181a67b7542122c + 4 + 127.0.0.1 + 0 + +
    + + session_id + session_user_id + session_ip + session_browser + + bar_session000000000000000000000 + 4 + 127.0.0.1 + user agent + 1 + +
    + + user_id + username_clean + user_permissions + user_sig + user_occ + user_interests + + 4 + bar + + + + + +
    +
    diff --git a/tests/session/session_key_tests.php b/tests/session/session_key_tests.php new file mode 100644 index 0000000000..382ed06a15 --- /dev/null +++ b/tests/session/session_key_tests.php @@ -0,0 +1,28 @@ +createXMLDataSet(dirname(__FILE__).'/fixtures/sessions_key.xml'); + } + + public function test_set_key_manually() + { + $this->session_factory->merge_config_data(array('allow_autologin' => true)); + $session = $this->session_factory->get_session($this->db); + $session->cookie_data['u'] = 4; + $session->cookie_data['k'] = 4; + $session->session_create(4, false, 4); + $this->assertEquals(4, $session->data['user_id']); + } +} From f5a09858d044592fa027e5ce23f4060aec0c38fa Mon Sep 17 00:00:00 2001 From: asperous Date: Fri, 12 Jul 2013 07:15:46 -0700 Subject: [PATCH 2295/2494] [ticket/11620] Added a session key reset test PHPBB3-11620 --- tests/session/session_key_tests.php | 33 ++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/tests/session/session_key_tests.php b/tests/session/session_key_tests.php index 382ed06a15..bc3d6dd71c 100644 --- a/tests/session/session_key_tests.php +++ b/tests/session/session_key_tests.php @@ -1,4 +1,4 @@ -createXMLDataSet(dirname(__FILE__).'/fixtures/sessions_key.xml'); @@ -18,11 +21,31 @@ class phpbb_session_login_keys_test extends phpbb_session_test_case public function test_set_key_manually() { + // With AutoLogin setup $this->session_factory->merge_config_data(array('allow_autologin' => true)); $session = $this->session_factory->get_session($this->db); - $session->cookie_data['u'] = 4; - $session->cookie_data['k'] = 4; - $session->session_create(4, false, 4); - $this->assertEquals(4, $session->data['user_id']); + // Using a user_id and key that is already in the database + $session->cookie_data['u'] = $this->user_id; + $session->cookie_data['k'] = $this->key_id; + // Try to access session + $session->session_create($this->user_id, false, $this->user_id); + + $this->assertEquals($this->user_id, $session->data['user_id'], "session should automatically login"); + } + + public function test_reset_keys() + { + // With AutoLogin setup + $this->session_factory->merge_config_data(array('allow_autologin' => true)); + $session = $this->session_factory->get_session($this->db); + // Reset of the keys for this user + $session->reset_login_keys($this->user_id); + // Using a user_id and key that was in the database (before reset) + $session->cookie_data['u'] = $this->user_id; + $session->cookie_data['k'] = $this->key_id; + // Try to access session + $session->session_create($this->user_id, false, $this->user_id); + + $this->assertNotEquals($this->user_id, $session->data['user_id'], "session should be cleared"); } } From 750ea771084d96097ea5a22c11a6659e8f39869d Mon Sep 17 00:00:00 2001 From: asperous Date: Fri, 12 Jul 2013 07:20:46 -0700 Subject: [PATCH 2296/2494] [ticket/11620] Typo in file name session_key_tests -> test PHPBB3-11620 --- tests/session/{session_key_tests.php => session_key_test.php} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename tests/session/{session_key_tests.php => session_key_test.php} (100%) diff --git a/tests/session/session_key_tests.php b/tests/session/session_key_test.php similarity index 100% rename from tests/session/session_key_tests.php rename to tests/session/session_key_test.php From 016faad6682495a35566d2d0451697486a47e80c Mon Sep 17 00:00:00 2001 From: asperous Date: Fri, 12 Jul 2013 09:47:06 -0700 Subject: [PATCH 2297/2494] [ticket/11620] Remove typo in beginning of session_key_test PHPBB3-11620 --- tests/session/session_key_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/session/session_key_test.php b/tests/session/session_key_test.php index bc3d6dd71c..6406742168 100644 --- a/tests/session/session_key_test.php +++ b/tests/session/session_key_test.php @@ -1,4 +1,4 @@ -_ Date: Fri, 12 Jul 2013 09:54:38 -0700 Subject: [PATCH 2298/2494] [ticket/11620] Added a test for checking if users are banned PHPBB3-11620 --- tests/mock/session_testable.php | 4 ++ tests/session/check_ban_test.php | 51 ++++++++++++++++ tests/session/fixtures/sessions_banlist.xml | 66 +++++++++++++++++++++ 3 files changed, 121 insertions(+) create mode 100644 tests/session/check_ban_test.php create mode 100644 tests/session/fixtures/sessions_banlist.xml diff --git a/tests/mock/session_testable.php b/tests/mock/session_testable.php index 56ff8c8b32..283f9af192 100644 --- a/tests/mock/session_testable.php +++ b/tests/mock/session_testable.php @@ -58,5 +58,9 @@ class phpbb_mock_session_testable extends phpbb_session } } } + + public function setup() + { + } } diff --git a/tests/session/check_ban_test.php b/tests/session/check_ban_test.php new file mode 100644 index 0000000000..ec1f5e3aa1 --- /dev/null +++ b/tests/session/check_ban_test.php @@ -0,0 +1,51 @@ +createXMLDataSet(dirname(__FILE__).'/fixtures/sessions_banlist.xml'); + } + + static function check_banned_data() + { + return array( + array('All false values, should not be banned', + false, false, false, false, /* ?: */ false), + array('Matching values in the database, should be banned', + 4, '127.0.0.1', 'bar@example.org', true, /* ?: */ true), + array('IP Banned, should be banned', + false, '127.1.1.1', false, falseN, /* ?: */ true), + ); + } + + /** @dataProvider check_banned_data */ + public function test_check_is_banned($test_msg, $user_id, $user_ips, $user_email, $return, $should_be_banned) + { + $session = $this->session_factory->get_session($this->db); + // Change the global cache object for this test because + // the mock cache object does not hit the database as is + // needed for this test. + global $cache; + $old_cache = $cache; + $cache = new phpbb_cache_driver_file(); + + $is_banned = + $session->check_ban($user_id, $user_ips, $user_email, $return); + $this->assertEquals($should_be_banned, $is_banned, $test_msg); + + $cache = $old_cache; + } +} diff --git a/tests/session/fixtures/sessions_banlist.xml b/tests/session/fixtures/sessions_banlist.xml new file mode 100644 index 0000000000..9422fc0665 --- /dev/null +++ b/tests/session/fixtures/sessions_banlist.xml @@ -0,0 +1,66 @@ + + + + user_id + username_clean + user_permissions + user_sig + user_occ + user_interests + + 1 + anonymous + + + + + +
    + + session_id + session_user_id + session_ip + session_browser + session_admin + + bar_session000000000000000000000 + 4 + 127.0.0.1 + user agent + 1 + +
    + + ban_id + ban_userid + ban_ip + ban_email + ban_start + ban_end + ban_exclude + ban_reason + ban_give_reason + + 2 + 4 + 127.0.0.1 + bar@example.org + 1111 + 0 + 0 + HAHAHA + 1 + + + 3 + 0 + 127.1.1.1 + + 1111 + 0 + 0 + HAHAHA + 1 + +
    +
    From 362480263cbad6cabbe2637edca153b27d97c493 Mon Sep 17 00:00:00 2001 From: Andy Chase Date: Tue, 25 Jun 2013 12:20:42 -0700 Subject: [PATCH 2299/2494] [ticket/11615] Rename continue -> check_isvalid for clarity PHPBB3-11615 --- tests/session/{continue_test.php => check_isvalid_test.php} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename tests/session/{continue_test.php => check_isvalid_test.php} (98%) diff --git a/tests/session/continue_test.php b/tests/session/check_isvalid_test.php similarity index 98% rename from tests/session/continue_test.php rename to tests/session/check_isvalid_test.php index e5a7f7a4a1..7cc6f13286 100644 --- a/tests/session/continue_test.php +++ b/tests/session/check_isvalid_test.php @@ -9,7 +9,7 @@ require_once dirname(__FILE__) . '/testable_factory.php'; -class phpbb_session_continue_test extends phpbb_database_test_case +class phpbb_session_check_isvalid_test extends phpbb_database_test_case { public function getDataSet() { From e74abfaa2c25b7c9b4f2f865fbf6800de0761a6b Mon Sep 17 00:00:00 2001 From: Andy Chase Date: Tue, 25 Jun 2013 12:24:02 -0700 Subject: [PATCH 2300/2494] [ticket/11615] Refactored isvalid test to be more imperative Refactoring the continue/is_valid test to remove the confusing data provider work around, while still keeping redundancies down to a minimum. PHPBB3-11615 --- tests/session/check_isvalid_test.php | 126 +++++++++------------------ tests/session/testable_factory.php | 28 +++++- 2 files changed, 66 insertions(+), 88 deletions(-) diff --git a/tests/session/check_isvalid_test.php b/tests/session/check_isvalid_test.php index 7cc6f13286..8083e3406a 100644 --- a/tests/session/check_isvalid_test.php +++ b/tests/session/check_isvalid_test.php @@ -2,7 +2,7 @@ /** * * @package testing -* @copyright (c) 2011 phpBB Group +* @copyright (c) 2013 phpBB Group * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 * */ @@ -16,42 +16,7 @@ class phpbb_session_check_isvalid_test extends phpbb_database_test_case return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/sessions_full.xml'); } - static public function session_begin_attempts() - { - // The session_id field is defined as CHAR(32) in the database schema. - // Thus the data we put in session_id fields has to have a length of 32 characters on stricter DBMSes. - // Thus we fill those strings up with zeroes until they have a string length of 32. - - return array( - array( - 'bar_session000000000000000000000', '4', 'user agent', '127.0.0.1', - array( - array('session_id' => 'anon_session00000000000000000000', 'session_user_id' => 1), - array('session_id' => 'bar_session000000000000000000000', 'session_user_id' => 4), - ), - array(), - 'If a request comes with a valid session id with matching user agent and IP, no new session should be created.', - ), - array( - 'anon_session00000000000000000000', '4', 'user agent', '127.0.0.1', - array( - array('session_id' => '__new_session_id__', 'session_user_id' => 1), // use generated SID - array('session_id' => 'bar_session000000000000000000000', 'session_user_id' => 4), - ), - array( - 'u' => array('1', null), - 'k' => array(null, null), - 'sid' => array('__new_session_id__', null), - ), - 'If a request comes with a valid session id and IP but different user id and user agent, a new anonymous session is created and the session matching the supplied session id is deleted.', - ), - ); - } - - /** - * @dataProvider session_begin_attempts - */ - public function test_session_begin_valid_session($session_id, $user_id, $user_agent, $ip, $expected_sessions, $expected_cookies, $message) + protected function access_with($session_id, $user_id, $user_agent, $ip) { global $phpbb_container, $phpbb_root_path, $phpEx; @@ -68,66 +33,53 @@ class phpbb_session_check_isvalid_test extends phpbb_database_test_case ->will($this->returnValue($auth_provider)); $session_factory = new phpbb_session_testable_factory; - $session_factory->set_cookies(array( - '_sid' => $session_id, - '_u' => $user_id, - )); - $session_factory->merge_config_data(array( - 'session_length' => time(), // need to do this to allow sessions started at time 0 - )); - $session_factory->merge_server_data(array( - 'HTTP_USER_AGENT' => $user_agent, - 'REMOTE_ADDR' => $ip, - )); + $session_factory->merge_test_data($session_id, $user_id, $user_agent, $ip); $session = $session_factory->get_session($db); $session->page = array('page' => 'page', 'forum' => 0); $session->session_begin(); - - $sql = 'SELECT session_id, session_user_id - FROM phpbb_sessions - ORDER BY session_user_id'; - - $expected_sessions = $this->replace_session($expected_sessions, $session->session_id); - $expected_cookies = $this->replace_session($expected_cookies, $session->session_id); - - $this->assertSqlResultEquals( - $expected_sessions, - $sql, - $message - ); - - $session->check_cookies($this, $expected_cookies); - $session_factory->check($this); + return $session; } - /** - * Replaces recursively the value __new_session_id__ with the given session - * id. - * - * @param array $array An array of data - * @param string $session_id The new session id to use instead of the - * placeholder. - * @return array The input array with all occurances of __new_session_id__ - * replaced. - */ - public function replace_session($array, $session_id) + protected function check_session_equals($expected_sessions, $message) { - foreach ($array as $key => &$value) - { - if ($value === '__new_session_id__') - { - $value = $session_id; - } + $sql = 'SELECT session_id, session_user_id + FROM phpbb_sessions + ORDER BY session_user_id'; - if (is_array($value)) - { - $value = $this->replace_session($value, $session_id); - } - } + $this->assertSqlResultEquals($expected_sessions, $sql, $message); + } - return $array; + public function test_session_valid_session_exists() + { + $session = $this->access_with('bar_session000000000000000000000', '4', 'user agent', '127.0.0.1'); + $session->check_cookies($this, array()); + + $this->check_session_equals(array( + array('session_id' => 'anon_session00000000000000000000', 'session_user_id' => 1), + array('session_id' => 'bar_session000000000000000000000', 'session_user_id' => 4), + ), + 'If a request comes with a valid session id with matching user agent and IP, no new session should be created.' + ); + } + + public function test_session_invalid_make_new_annon_session() + { + $session = $this->access_with('anon_session00000000000000000000', '4', 'user agent', '127.0.0.1'); + $session->check_cookies($this, array( + 'u' => array('1', null), + 'k' => array(null, null), + 'sid' => array($session->session_id, null), + )); + + $this->check_session_equals(array( + array('session_id' => $session->session_id, 'session_user_id' => 1), // use generated SID + array('session_id' => 'bar_session000000000000000000000', 'session_user_id' => 4), + ), + 'If a request comes with a valid session id and IP but different user id and user agent, + a new anonymous session is created and the session matching the supplied session id is deleted.' + ); } } diff --git a/tests/session/testable_factory.php b/tests/session/testable_factory.php index ace968eb43..8733ce15ef 100644 --- a/tests/session/testable_factory.php +++ b/tests/session/testable_factory.php @@ -2,7 +2,7 @@ /** * * @package testing -* @copyright (c) 2011 phpBB Group +* @copyright (c) 2013 phpBB Group * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 * */ @@ -174,6 +174,32 @@ class phpbb_session_testable_factory return $this->server_data = array_merge($this->server_data, $server_data); } + /** + * Set cookies, merge config and server data in one step. + * + * New values overwrite old ones. + * + * @param $session_id + * @param $user_id + * @param $user_agent + * @param $ip + * @param int $time + */ + public function merge_test_data($session_id, $user_id, $user_agent, $ip, $time = 0) + { + $this->set_cookies(array( + '_sid' => $session_id, + '_u' => $user_id, + )); + $this->merge_config_data(array( + 'session_length' => time() + $time, // need to do this to allow sessions started at time 0 + )); + $this->merge_server_data(array( + 'HTTP_USER_AGENT' => $user_agent, + 'REMOTE_ADDR' => $ip, + )); + } + /** * Retrieve all server variables to be passed to the session. * From 2d850ba7a8f57dd74a23f0feaedf5c5fc409a520 Mon Sep 17 00:00:00 2001 From: asperous Date: Fri, 12 Jul 2013 11:08:16 -0700 Subject: [PATCH 2301/2494] [ticket/11620] Refactored check_isvalid_test to use session_test_case Since the continue->isvalid refactoring is now in a branch with the session_test_case framework, this test can be refactored to use that framework. PHPBB3-11620 --- tests/session/check_isvalid_test.php | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/tests/session/check_isvalid_test.php b/tests/session/check_isvalid_test.php index 8083e3406a..6c21359c7d 100644 --- a/tests/session/check_isvalid_test.php +++ b/tests/session/check_isvalid_test.php @@ -7,9 +7,10 @@ * */ -require_once dirname(__FILE__) . '/testable_factory.php'; +require_once dirname(__FILE__) . '/../test_framework/phpbb_session_test_case.php'; -class phpbb_session_check_isvalid_test extends phpbb_database_test_case + +class phpbb_session_check_isvalid_test extends phpbb_session_test_case { public function getDataSet() { @@ -18,28 +19,13 @@ class phpbb_session_check_isvalid_test extends phpbb_database_test_case protected function access_with($session_id, $user_id, $user_agent, $ip) { - global $phpbb_container, $phpbb_root_path, $phpEx; + $this->session_factory->merge_test_data($session_id, $user_id, $user_agent, $ip); - $db = $this->new_dbal(); - $config = new phpbb_config(array()); - $request = $this->getMock('phpbb_request'); - $user = $this->getMock('phpbb_user'); - - $auth_provider = new phpbb_auth_provider_db($db, $config, $request, $user, $phpbb_root_path, $phpEx); - $phpbb_container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface'); - $phpbb_container->expects($this->any()) - ->method('get') - ->with('auth.provider.db') - ->will($this->returnValue($auth_provider)); - - $session_factory = new phpbb_session_testable_factory; - $session_factory->merge_test_data($session_id, $user_id, $user_agent, $ip); - - $session = $session_factory->get_session($db); + $session = $this->session_factory->get_session($this->db); $session->page = array('page' => 'page', 'forum' => 0); $session->session_begin(); - $session_factory->check($this); + $this->session_factory->check($this); return $session; } From 13e4271c502152b8fa318422d808aabeb97e6c8c Mon Sep 17 00:00:00 2001 From: asperous Date: Fri, 12 Jul 2013 11:28:17 -0700 Subject: [PATCH 2302/2494] [ticket/11620] Fixed a typo on check_ban_test PHPBB3-11620 --- tests/session/check_ban_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/session/check_ban_test.php b/tests/session/check_ban_test.php index ec1f5e3aa1..6795338f23 100644 --- a/tests/session/check_ban_test.php +++ b/tests/session/check_ban_test.php @@ -27,7 +27,7 @@ class phpbb_session_check_ban_test extends phpbb_session_test_case array('Matching values in the database, should be banned', 4, '127.0.0.1', 'bar@example.org', true, /* ?: */ true), array('IP Banned, should be banned', - false, '127.1.1.1', false, falseN, /* ?: */ true), + false, '127.1.1.1', false, false, /* ?: */ true), ); } From af3a4ee33a148c864c30d22a2031cfc7e1b7bcf3 Mon Sep 17 00:00:00 2001 From: asperous Date: Fri, 12 Jul 2013 13:04:09 -0700 Subject: [PATCH 2303/2494] [ticket/11620] Fixed check_ban_test errors with cache and ban warning message PHPBB3-11620 --- tests/session/check_ban_test.php | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/tests/session/check_ban_test.php b/tests/session/check_ban_test.php index 6795338f23..6ff688ee3d 100644 --- a/tests/session/check_ban_test.php +++ b/tests/session/check_ban_test.php @@ -38,14 +38,26 @@ class phpbb_session_check_ban_test extends phpbb_session_test_case // Change the global cache object for this test because // the mock cache object does not hit the database as is // needed for this test. - global $cache; - $old_cache = $cache; - $cache = new phpbb_cache_driver_file(); + global $cache, $config, $phpbb_root_path, $php_ext; + $cache = new phpbb_cache_service( + new phpbb_cache_driver_file(), + $config, + $this->db, + $phpbb_root_path, + $php_ext + ); - $is_banned = - $session->check_ban($user_id, $user_ips, $user_email, $return); + try + { + $is_banned = + $session->check_ban($user_id, $user_ips, $user_email, $return); + } catch (PHPUnit_Framework_Error_Notice $e) + { + // User error was triggered, user must have been banned + $is_banned = true; + } $this->assertEquals($should_be_banned, $is_banned, $test_msg); - $cache = $old_cache; + $cache = new phpbb_mock_cache(); } } From 7dbd85ad02b031fc2392adfd27c66c3725ef117b Mon Sep 17 00:00:00 2001 From: asperous Date: Fri, 12 Jul 2013 13:04:37 -0700 Subject: [PATCH 2304/2494] [ticket/11620] Added garbage_collection_test PHPBB3-11620 --- tests/session/fixtures/sessions_garbage.xml | 58 +++++++++++++++++++ tests/session/garbage_collection_test.php | 63 +++++++++++++++++++++ 2 files changed, 121 insertions(+) create mode 100644 tests/session/fixtures/sessions_garbage.xml create mode 100644 tests/session/garbage_collection_test.php diff --git a/tests/session/fixtures/sessions_garbage.xml b/tests/session/fixtures/sessions_garbage.xml new file mode 100644 index 0000000000..23c44a975b --- /dev/null +++ b/tests/session/fixtures/sessions_garbage.xml @@ -0,0 +1,58 @@ + + + + user_id + username_clean + user_permissions + user_sig + user_occ + user_interests + + 4 + bar + + + + + +
    + + session_id + session_user_id + session_ip + session_browser + session_admin + + anon_session00000000000000000000 + 1 + 127.0.0.1 + anonymous user agent + 0 + + + bar_session000000000000000000000 + 4 + 127.0.0.1 + user agent + 1 + +
    + + attempt_ip + attempt_browser + attempt_forwarded_for + attempt_time + user_id + username + username_clean + + 127.0.0.1 + browser + + 0001 + 4 + bar + bar + +
    +
    diff --git a/tests/session/garbage_collection_test.php b/tests/session/garbage_collection_test.php new file mode 100644 index 0000000000..1b607dfb4f --- /dev/null +++ b/tests/session/garbage_collection_test.php @@ -0,0 +1,63 @@ +createXMLDataSet(dirname(__FILE__).'/fixtures/sessions_garbage.xml'); + } + + public function setUp() + { + parent::setUp(); + $this->session = $this->session_factory->get_session($this->db); + } + + protected function assert_sessions_equal($expected, $msg) + { + $sql = 'SELECT session_id, session_user_id + FROM phpbb_sessions + ORDER BY session_user_id'; + + $this->assertSqlResultEquals($expected, $sql, $msg); + } + + public function test_cleanup_all() + { + $this->assert_sessions_equal( + array( + array + ( + 'session_id' => 'anon_session00000000000000000000', + 'session_user_id' => 1, + ), + array + ( + 'session_id' => 'bar_session000000000000000000000', + 'session_user_id' => 4, + )), + 'Before test, should have some sessions.' + ); + // Set session length so it clears all + global $config; + $config['session_length'] = 0; + // There is an error unless the captcha plugin is set + $config['captcha_plugin'] = 'phpbb_captcha_nogd'; + $this->session->session_gc(); + $this->assert_sessions_equal( + array(), + 'After setting session time to 0, should remove all.' + ); + } +} From 30f198c61a56deb14223a60a8ebf370cc90d9f4b Mon Sep 17 00:00:00 2001 From: asperous Date: Sat, 13 Jul 2013 07:32:49 -0700 Subject: [PATCH 2305/2494] [ticket/11620] Update auth_provider for new interface PHPBB3-11620 --- tests/mock/auth_provider.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/mock/auth_provider.php b/tests/mock/auth_provider.php index 9674c573e3..e0a2abd2d5 100644 --- a/tests/mock/auth_provider.php +++ b/tests/mock/auth_provider.php @@ -31,7 +31,7 @@ class phpbb_mock_auth_provider implements phpbb_auth_provider_interface return array(); } - function acp($new) + function acp() { return array(); } @@ -45,4 +45,9 @@ class phpbb_mock_auth_provider implements phpbb_auth_provider_interface { return null; } + + public function get_acp_template($new_config) + { + return null; + } } From 25b189d33bbf2b94da6f9f969e8d91ade8eba30a Mon Sep 17 00:00:00 2001 From: asperous Date: Sat, 13 Jul 2013 08:26:46 -0700 Subject: [PATCH 2306/2494] [ticket/11620] Cleanup creation_test that was renamed on a cherry-pick PHPBB3-11620 --- tests/session/creation_test.php | 69 --------------------------------- 1 file changed, 69 deletions(-) delete mode 100644 tests/session/creation_test.php diff --git a/tests/session/creation_test.php b/tests/session/creation_test.php deleted file mode 100644 index fde76d6b06..0000000000 --- a/tests/session/creation_test.php +++ /dev/null @@ -1,69 +0,0 @@ -createXMLDataSet(dirname(__FILE__).'/fixtures/sessions_empty.xml'); - } - - // also see security/extract_current_page.php - - public function test_login_session_create() - { - global $phpbb_container, $phpbb_root_path, $phpEx; - - $db = $this->new_dbal(); - $config = new phpbb_config(array()); - $request = $this->getMock('phpbb_request'); - $user = $this->getMock('phpbb_user'); - - $auth_provider = new phpbb_auth_provider_db($db, $config, $request, $user, $phpbb_root_path, $phpEx); - $phpbb_container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface'); - $phpbb_container->expects($this->any()) - ->method('get') - ->with('auth.provider.db') - ->will($this->returnValue($auth_provider)); - - $session_factory = new phpbb_session_testable_factory; - - $session = $session_factory->get_session($db); - $session->page = array('page' => 'page', 'forum' => 0); - - $session->session_create(3); - - $sql = 'SELECT session_user_id - FROM phpbb_sessions'; - - $this->assertSqlResultEquals( - array(array('session_user_id' => 3)), - $sql, - 'Check if exactly one session for user id 3 was created' - ); - - $one_year_in_seconds = 365 * 24 * 60 * 60; - $cookie_expire = $session->time_now + $one_year_in_seconds; - - $session->check_cookies($this, array( - 'u' => array(null, $cookie_expire), - 'k' => array(null, $cookie_expire), - 'sid' => array($session->session_id, $cookie_expire), - )); - - global $SID, $_SID; - $this->assertEquals($session->session_id, $_SID); - $this->assertEquals('?sid=' . $session->session_id, $SID); - - $session_factory->check($this); - } -} - From de2cb595336ee49aeb4bab4ee857fbe71e249599 Mon Sep 17 00:00:00 2001 From: asperous Date: Sat, 13 Jul 2013 08:38:02 -0700 Subject: [PATCH 2307/2494] [ticket/11620] Fix a static calls to non-static for session captcha These changes fixes an error in certain version of php that throws an error if you call a non-static method statically. PHPBB3-11620 --- phpBB/includes/captcha/captcha_factory.php | 3 ++- phpBB/includes/session.php | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/captcha/captcha_factory.php b/phpBB/includes/captcha/captcha_factory.php index 1ed8e119b5..af79f059fe 100644 --- a/phpBB/includes/captcha/captcha_factory.php +++ b/phpBB/includes/captcha/captcha_factory.php @@ -50,7 +50,8 @@ class phpbb_captcha_factory { include($phpbb_root_path . "includes/captcha/plugins/{$name}_plugin." . $phpEx); } - call_user_func(array($name, 'garbage_collect'), 0); + $captcha = new $name; + $captcha->garbage_collect(''); } /** diff --git a/phpBB/includes/session.php b/phpBB/includes/session.php index 66bf053f7d..392a55e48f 100644 --- a/phpBB/includes/session.php +++ b/phpBB/includes/session.php @@ -1016,7 +1016,8 @@ class phpbb_session { include($phpbb_root_path . "includes/captcha/captcha_factory." . $phpEx); } - phpbb_captcha_factory::garbage_collect($config['captcha_plugin']); + $captcha_factory = new phpbb_captcha_factory(); + $captcha_factory->garbage_collect($config['captcha_plugin']); $sql = 'DELETE FROM ' . LOGIN_ATTEMPT_TABLE . ' WHERE attempt_time < ' . (time() - (int) $config['ip_login_limit_time']); From cc1aef47fb4f5d37415436c62067ad2dcde768bb Mon Sep 17 00:00:00 2001 From: Andy Chase Date: Mon, 22 Jul 2013 11:13:31 -0700 Subject: [PATCH 2308/2494] [ticket/11620] Changes for code guidelines consistency PHPBB3-11620 --- tests/session/extract_page_test.php | 20 ++++++++++---------- tests/session/testable_facade.php | 3 ++- tests/session/validate_referrer_test.php | 5 +++-- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/tests/session/extract_page_test.php b/tests/session/extract_page_test.php index 9346973bc4..4dbbbc9c59 100644 --- a/tests/session/extract_page_test.php +++ b/tests/session/extract_page_test.php @@ -32,8 +32,8 @@ class phpbb_session_extract_page_test extends phpbb_session_test_case 'root_script_path' => '/phpBB/', 'page' => 'index.php', 'forum' => 0, - ) - ) , + ), + ), array( './', '/phpBB/ucp.php', @@ -47,8 +47,8 @@ class phpbb_session_extract_page_test extends phpbb_session_test_case 'root_script_path' => '/phpBB/', 'page' => 'ucp.php?mode=login', 'forum' => 0, - ) - ) , + ), + ), array( './', '/phpBB/ucp.php', @@ -62,8 +62,8 @@ class phpbb_session_extract_page_test extends phpbb_session_test_case 'root_script_path' => '/phpBB/', 'page' => 'ucp.php?mode=register', 'forum' => 0, - ) - ) , + ), + ), array( './', '/phpBB/ucp.php', @@ -77,8 +77,8 @@ class phpbb_session_extract_page_test extends phpbb_session_test_case 'root_script_path' => '/phpBB/', 'page' => 'ucp.php?mode=register', 'forum' => 0, - ) - ) , + ), + ), array( './../', '/phpBB/adm/index.php', @@ -93,8 +93,8 @@ class phpbb_session_extract_page_test extends phpbb_session_test_case 'root_script_path' => '/phpBB/', //'page' => 'adm/index.php', 'forum' => 0, - ) - ) + ), + ), ); } diff --git a/tests/session/testable_facade.php b/tests/session/testable_facade.php index 1cb1c94b52..1343b34a79 100644 --- a/tests/session/testable_facade.php +++ b/tests/session/testable_facade.php @@ -27,7 +27,8 @@ class phpbb_session_testable_facade protected $db; protected $session_factory; - function __construct($db, $session_factory) { + function __construct($db, $session_factory) + { $this->db = $db; $this->session_factory = $session_factory; } diff --git a/tests/session/validate_referrer_test.php b/tests/session/validate_referrer_test.php index f91ac5f1f9..b517b668ac 100644 --- a/tests/session/validate_referrer_test.php +++ b/tests/session/validate_referrer_test.php @@ -52,7 +52,7 @@ class phpbb_session_validate_referrer_test extends phpbb_session_test_case ) { // Referrer needs http:// because it's going to get stripped in function. - $referrer = $referrer ? 'http://'.$referrer : ''; + $referrer = $referrer ? 'http://' . $referrer : ''; $this->assertEquals( $pass_or_fail, $this->session_facade->validate_referer( @@ -63,6 +63,7 @@ class phpbb_session_validate_referrer_test extends phpbb_session_test_case $server_port, $server_name, $root_script_path - ), "referrer should" . ($pass_or_fail? '' : "n't") . " be validated"); + ), + "referrer should" . ($pass_or_fail ? '' : "n't") . " be validated"); } } From 28e98466d959875d2f5b0e917c32783c1039dc23 Mon Sep 17 00:00:00 2001 From: Andy Chase Date: Mon, 22 Jul 2013 12:26:02 -0700 Subject: [PATCH 2309/2494] [ticket/11620] Changes to match merge PHPBB3-11620 --- tests/session/fixtures/sessions_full.xml | 3 +++ tests/session/testable_facade.php | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/session/fixtures/sessions_full.xml b/tests/session/fixtures/sessions_full.xml index 509687f4d2..6bbaf1c9d5 100644 --- a/tests/session/fixtures/sessions_full.xml +++ b/tests/session/fixtures/sessions_full.xml @@ -37,17 +37,20 @@ session_user_id session_ip session_browser + session_admin anon_session00000000000000000000 1 127.0.0.1 anonymous user agent + 0 bar_session000000000000000000000 4 127.0.0.1 user agent + 1 diff --git a/tests/session/testable_facade.php b/tests/session/testable_facade.php index 1343b34a79..c5e58fce05 100644 --- a/tests/session/testable_facade.php +++ b/tests/session/testable_facade.php @@ -8,7 +8,7 @@ */ require_once dirname(__FILE__) . '/testable_factory.php'; -require_once dirname(__FILE__) . '/../../phpBB/includes/session.php'; +require_once dirname(__FILE__) . '/../../phpBB/phpbb/session.php'; /** * This class exists to expose session.php's functions in a more testable way. From 974da6449c2f18f52086bd5ee6d24aafed046e37 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 22 Jul 2013 22:00:27 +0200 Subject: [PATCH 2310/2494] [ticket/11723] Correctly redirect user to agreement page and let him leave This patch consists of two changes. The first one will make sure that $agree is correctly reset to 0 and the user redirected back to the agreement page after changing the display language. Secondly, by reseting 'change_lang', the user will be able to agree to the terms on the agreement page again. The changed language will still be kept, as this is correctly saved in the 'lang' field that is passed to the ucp_register page. The variable $agree has also been changed to be boolean. It is not used as an integer anywere in the ucp_register file. PHPBB3-11723 --- phpBB/includes/ucp/ucp_register.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/phpBB/includes/ucp/ucp_register.php b/phpBB/includes/ucp/ucp_register.php index 70fbfe46fb..7bc7ac8191 100644 --- a/phpBB/includes/ucp/ucp_register.php +++ b/phpBB/includes/ucp/ucp_register.php @@ -38,7 +38,7 @@ class ucp_register include($phpbb_root_path . 'includes/functions_profile_fields.' . $phpEx); $coppa = $request->is_set('coppa') ? (int) $request->variable('coppa', false) : false; - $agreed = (int) $request->variable('agreed', false); + $agreed = $request->variable('agreed', false); $submit = $request->is_set_post('submit'); $change_lang = request_var('change_lang', ''); $user_lang = request_var('lang', $user->lang_name); @@ -63,7 +63,7 @@ class ucp_register $submit = false; // Setting back agreed to let the user view the agreement in his/her language - $agreed = ($request->variable('change_lang', false)) ? 0 : $agreed; + $agreed = false; } $user->lang_name = $user_lang = $use_lang; @@ -89,7 +89,7 @@ class ucp_register $add_coppa = ($coppa !== false) ? '&coppa=' . $coppa : ''; $s_hidden_fields = array( - 'change_lang' => $change_lang, + 'change_lang' => '', ); // If we change the language, we want to pass on some more possible parameter. From 9dbd42e9452fe8459de905170f9031a4515cc0b2 Mon Sep 17 00:00:00 2001 From: Andy Chase Date: Mon, 22 Jul 2013 13:51:06 -0700 Subject: [PATCH 2311/2494] [ticket/11620] Space between . in directory import concatenation PHPBB3-11620 --- tests/session/check_ban_test.php | 2 +- tests/session/check_isvalid_test.php | 2 +- tests/session/create_test.php | 2 +- tests/session/extract_hostname_test.php | 2 +- tests/session/extract_page_test.php | 2 +- tests/session/garbage_collection_test.php | 2 +- tests/session/session_key_test.php | 2 +- tests/session/unset_admin_test.php | 2 +- tests/session/validate_referrer_test.php | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/session/check_ban_test.php b/tests/session/check_ban_test.php index 6ff688ee3d..dfe971ea27 100644 --- a/tests/session/check_ban_test.php +++ b/tests/session/check_ban_test.php @@ -16,7 +16,7 @@ class phpbb_session_check_ban_test extends phpbb_session_test_case public function getDataSet() { - return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/sessions_banlist.xml'); + return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/sessions_banlist.xml'); } static function check_banned_data() diff --git a/tests/session/check_isvalid_test.php b/tests/session/check_isvalid_test.php index 6c21359c7d..24dce7c9c4 100644 --- a/tests/session/check_isvalid_test.php +++ b/tests/session/check_isvalid_test.php @@ -14,7 +14,7 @@ class phpbb_session_check_isvalid_test extends phpbb_session_test_case { public function getDataSet() { - return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/sessions_full.xml'); + return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/sessions_full.xml'); } protected function access_with($session_id, $user_id, $user_agent, $ip) diff --git a/tests/session/create_test.php b/tests/session/create_test.php index a8248ae62c..64140f9883 100644 --- a/tests/session/create_test.php +++ b/tests/session/create_test.php @@ -13,7 +13,7 @@ class phpbb_session_create_test extends phpbb_session_test_case { public function getDataSet() { - return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/sessions_full.xml'); + return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/sessions_full.xml'); } static function bot($bot_agent, $user_id, $bot_ip) diff --git a/tests/session/extract_hostname_test.php b/tests/session/extract_hostname_test.php index 5ff43cbb60..bd183fd438 100644 --- a/tests/session/extract_hostname_test.php +++ b/tests/session/extract_hostname_test.php @@ -13,7 +13,7 @@ class phpbb_session_extract_hostname_test extends phpbb_session_test_case { public function getDataSet() { - return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/sessions_empty.xml'); + return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/sessions_empty.xml'); } static public function extract_current_hostname_data() diff --git a/tests/session/extract_page_test.php b/tests/session/extract_page_test.php index 4dbbbc9c59..f4ae8de021 100644 --- a/tests/session/extract_page_test.php +++ b/tests/session/extract_page_test.php @@ -13,7 +13,7 @@ class phpbb_session_extract_page_test extends phpbb_session_test_case { public function getDataSet() { - return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/sessions_empty.xml'); + return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/sessions_empty.xml'); } static public function extract_current_page_data() diff --git a/tests/session/garbage_collection_test.php b/tests/session/garbage_collection_test.php index 1b607dfb4f..b1be958d62 100644 --- a/tests/session/garbage_collection_test.php +++ b/tests/session/garbage_collection_test.php @@ -15,7 +15,7 @@ class phpbb_session_garbage_collection_test extends phpbb_session_test_case public function getDataSet() { - return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/sessions_garbage.xml'); + return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/sessions_garbage.xml'); } public function setUp() diff --git a/tests/session/session_key_test.php b/tests/session/session_key_test.php index 6406742168..1cf2101385 100644 --- a/tests/session/session_key_test.php +++ b/tests/session/session_key_test.php @@ -16,7 +16,7 @@ class phpbb_session_login_keys_test extends phpbb_session_test_case public function getDataSet() { - return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/sessions_key.xml'); + return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/sessions_key.xml'); } public function test_set_key_manually() diff --git a/tests/session/unset_admin_test.php b/tests/session/unset_admin_test.php index bbb5eb1439..1d5b1759ab 100644 --- a/tests/session/unset_admin_test.php +++ b/tests/session/unset_admin_test.php @@ -13,7 +13,7 @@ class phpbb_session_unset_admin_test extends phpbb_session_test_case { public function getDataSet() { - return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/sessions_full.xml'); + return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/sessions_full.xml'); } function get_test_session() diff --git a/tests/session/validate_referrer_test.php b/tests/session/validate_referrer_test.php index b517b668ac..f78bf36c1b 100644 --- a/tests/session/validate_referrer_test.php +++ b/tests/session/validate_referrer_test.php @@ -13,7 +13,7 @@ class phpbb_session_validate_referrer_test extends phpbb_session_test_case { public function getDataSet() { - return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/sessions_empty.xml'); + return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/sessions_empty.xml'); } static function referrer_inputs() { From 9d38ded22875e023d4391e7724673087f87fa481 Mon Sep 17 00:00:00 2001 From: Andy Chase Date: Mon, 22 Jul 2013 13:52:17 -0700 Subject: [PATCH 2312/2494] [ticket/11620] Expected and actual test conditions wrongly swapped PHPBB3-11620 --- tests/session/create_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/session/create_test.php b/tests/session/create_test.php index 64140f9883..0faedf4db2 100644 --- a/tests/session/create_test.php +++ b/tests/session/create_test.php @@ -38,6 +38,6 @@ class phpbb_session_create_test extends phpbb_session_test_case self::bot('user agent', 13, '127.0.0.1'), '' ); - $this->assertEquals($output->data['is_bot'], true, 'should be a bot'); + $this->assertEquals(true, $output->data['is_bot'] , 'should be a bot'); } } From aa77367267d381f1f87f1ed725e4f5f4a3135922 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 22 Jul 2013 22:54:55 +0200 Subject: [PATCH 2313/2494] [ticket/11728] Replace topic_approved with topic_visibility PHPBB3-11728 --- phpBB/phpbb/feed/topic.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/phpbb/feed/topic.php b/phpBB/phpbb/feed/topic.php index 696b0f5a52..bb1753d823 100644 --- a/phpBB/phpbb/feed/topic.php +++ b/phpBB/phpbb/feed/topic.php @@ -60,7 +60,7 @@ class phpbb_feed_topic extends phpbb_feed_post_base $this->forum_id = (int) $this->topic_data['forum_id']; // Make sure topic is either approved or user authed - if (!$this->topic_data['topic_approved'] && !$this->auth->acl_get('m_approve', $this->forum_id)) + if ($this->topic_data['topic_visibility'] != ITEM_APPROVED && !$this->auth->acl_get('m_approve', $this->forum_id)) { trigger_error('SORRY_AUTH_READ'); } From 80f81dd0d2d4aaef0b9c770d6071526aaca79e06 Mon Sep 17 00:00:00 2001 From: Andy Chase Date: Mon, 22 Jul 2013 15:04:30 -0700 Subject: [PATCH 2314/2494] [ticket/11731] Remove static calls to captcha garbage collector PHPBB3-11731 --- phpBB/includes/captcha/captcha_factory.php | 3 ++- phpBB/phpbb/session.php | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/captcha/captcha_factory.php b/phpBB/includes/captcha/captcha_factory.php index 1ed8e119b5..fac45087e3 100644 --- a/phpBB/includes/captcha/captcha_factory.php +++ b/phpBB/includes/captcha/captcha_factory.php @@ -50,7 +50,8 @@ class phpbb_captcha_factory { include($phpbb_root_path . "includes/captcha/plugins/{$name}_plugin." . $phpEx); } - call_user_func(array($name, 'garbage_collect'), 0); + $captcha = self::get_instance($name); + $captcha->garbage_collect(0); } /** diff --git a/phpBB/phpbb/session.php b/phpBB/phpbb/session.php index e0585b1523..dc33786666 100644 --- a/phpBB/phpbb/session.php +++ b/phpBB/phpbb/session.php @@ -1022,7 +1022,8 @@ class phpbb_session { include($phpbb_root_path . "includes/captcha/captcha_factory." . $phpEx); } - phpbb_captcha_factory::garbage_collect($config['captcha_plugin']); + $captcha_factory = new phpbb_captcha_factory(); + $captcha_factory->garbage_collect($config['captcha_plugin']); $sql = 'DELETE FROM ' . LOGIN_ATTEMPT_TABLE . ' WHERE attempt_time < ' . (time() - (int) $config['ip_login_limit_time']); From 8dc8ee205a30e4f1813f2b85e0176cc47100f47b Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 23 Jul 2013 00:58:03 +0200 Subject: [PATCH 2315/2494] [ticket/11733] Add browse test for feed.php PHPBB3-11733 --- tests/functional/browse_test.php | 7 +++++++ .../phpbb_functional_test_case.php | 21 +++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/tests/functional/browse_test.php b/tests/functional/browse_test.php index 18a2ad9464..c3be301762 100644 --- a/tests/functional/browse_test.php +++ b/tests/functional/browse_test.php @@ -29,4 +29,11 @@ class phpbb_functional_browse_test extends phpbb_functional_test_case $crawler = self::request('GET', 'viewtopic.php?t=1'); $this->assertGreaterThan(0, $crawler->filter('.postbody')->count()); } + + public function test_feed() + { + $crawler = self::request('GET', 'feed.php', array(), false); + self::assert_response_xml(); + $this->assertGreaterThan(0, $crawler->filter('entry')->count()); + } } diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index ed307c3ce2..de3611c4cc 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -747,6 +747,27 @@ class phpbb_functional_test_case extends phpbb_test_case self::assertStringStartsWith('getResponse()->getContent(); + self::assertNotContains('[phpBB Debug]', $content); + self::assertStringStartsWith(' Date: Tue, 23 Jul 2013 00:59:51 +0200 Subject: [PATCH 2316/2494] [ticket/11733] Fix "Illegal offset type" Warning caused by overall feed PHPBB3-11733 --- phpBB/phpbb/feed/overall.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/phpbb/feed/overall.php b/phpBB/phpbb/feed/overall.php index 869df7cde0..224d97ec03 100644 --- a/phpBB/phpbb/feed/overall.php +++ b/phpBB/phpbb/feed/overall.php @@ -72,7 +72,7 @@ class phpbb_feed_overall extends phpbb_feed_post_base ), ), 'WHERE' => $this->db->sql_in_set('p.topic_id', $topic_ids) . ' - AND ' . $this->content_visibility->get_visibility_sql('post', array(), 'p.') . ' + AND ' . $this->content_visibility->get_forums_visibility_sql('post', $forum_ids, 'p.') . ' AND p.post_time >= ' . $min_post_time . ' AND u.user_id = p.poster_id', 'ORDER_BY' => 'p.post_time DESC', From cc6147f8769b7d70c9c48257c787ff00552beaf4 Mon Sep 17 00:00:00 2001 From: Andy Chase Date: Mon, 22 Jul 2013 15:41:51 -0700 Subject: [PATCH 2317/2494] [ticket/11620] Minor indentation changes and comment clarity PHPBB3-11620 --- tests/session/check_ban_test.php | 11 +++++------ tests/session/check_isvalid_test.php | 1 - 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/tests/session/check_ban_test.php b/tests/session/check_ban_test.php index dfe971ea27..303751f54c 100644 --- a/tests/session/check_ban_test.php +++ b/tests/session/check_ban_test.php @@ -23,11 +23,11 @@ class phpbb_session_check_ban_test extends phpbb_session_test_case { return array( array('All false values, should not be banned', - false, false, false, false, /* ?: */ false), + false, false, false, false, /* should be banned? -> */ false), array('Matching values in the database, should be banned', - 4, '127.0.0.1', 'bar@example.org', true, /* ?: */ true), + 4, '127.0.0.1', 'bar@example.org', true, /* should be banned? -> */ true), array('IP Banned, should be banned', - false, '127.1.1.1', false, false, /* ?: */ true), + false, '127.1.1.1', false, false, /* should be banned? -> */ true), ); } @@ -38,7 +38,7 @@ class phpbb_session_check_ban_test extends phpbb_session_test_case // Change the global cache object for this test because // the mock cache object does not hit the database as is // needed for this test. - global $cache, $config, $phpbb_root_path, $php_ext; + global $cache, $config, $phpbb_root_path, $php_ext; $cache = new phpbb_cache_service( new phpbb_cache_driver_file(), $config, @@ -49,8 +49,7 @@ class phpbb_session_check_ban_test extends phpbb_session_test_case try { - $is_banned = - $session->check_ban($user_id, $user_ips, $user_email, $return); + $is_banned = $session->check_ban($user_id, $user_ips, $user_email, $return); } catch (PHPUnit_Framework_Error_Notice $e) { // User error was triggered, user must have been banned diff --git a/tests/session/check_isvalid_test.php b/tests/session/check_isvalid_test.php index 24dce7c9c4..c60770dad8 100644 --- a/tests/session/check_isvalid_test.php +++ b/tests/session/check_isvalid_test.php @@ -9,7 +9,6 @@ require_once dirname(__FILE__) . '/../test_framework/phpbb_session_test_case.php'; - class phpbb_session_check_isvalid_test extends phpbb_session_test_case { public function getDataSet() From 568de3b8ceb68c4d988a7e69b0d357bd43bdd25b Mon Sep 17 00:00:00 2001 From: Andy Chase Date: Mon, 22 Jul 2013 15:44:22 -0700 Subject: [PATCH 2318/2494] [ticket/11620] Changed incorrect global variable PHPBB3-11620 --- tests/session/check_ban_test.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/session/check_ban_test.php b/tests/session/check_ban_test.php index 303751f54c..fe7c70575a 100644 --- a/tests/session/check_ban_test.php +++ b/tests/session/check_ban_test.php @@ -38,13 +38,13 @@ class phpbb_session_check_ban_test extends phpbb_session_test_case // Change the global cache object for this test because // the mock cache object does not hit the database as is // needed for this test. - global $cache, $config, $phpbb_root_path, $php_ext; + global $cache, $config, $phpbb_root_path, $phpEx; $cache = new phpbb_cache_service( new phpbb_cache_driver_file(), $config, $this->db, $phpbb_root_path, - $php_ext + $phpEx ); try From 0c54fb034b71cfc2bff338430acb1e2b43083dd5 Mon Sep 17 00:00:00 2001 From: Andy Chase Date: Mon, 22 Jul 2013 17:39:14 -0700 Subject: [PATCH 2319/2494] [ticket/11620] Move check_ban_test functions to setUp/tearDown for clarity PHPBB3-11620 --- tests/session/check_ban_test.php | 36 +++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/tests/session/check_ban_test.php b/tests/session/check_ban_test.php index fe7c70575a..8d6c9a866d 100644 --- a/tests/session/check_ban_test.php +++ b/tests/session/check_ban_test.php @@ -13,6 +13,8 @@ class phpbb_session_check_ban_test extends phpbb_session_test_case { protected $user_id = 4; protected $key_id = 4; + protected $session; + protected $backup_cache; public function getDataSet() { @@ -31,14 +33,16 @@ class phpbb_session_check_ban_test extends phpbb_session_test_case ); } - /** @dataProvider check_banned_data */ - public function test_check_is_banned($test_msg, $user_id, $user_ips, $user_email, $return, $should_be_banned) + public function setUp() { - $session = $this->session_factory->get_session($this->db); - // Change the global cache object for this test because - // the mock cache object does not hit the database as is - // needed for this test. + parent::setUp(); + // Get session here so that config is mocked correctly + $this->session = $this->session_factory->get_session($this->db); global $cache, $config, $phpbb_root_path, $phpEx; + $this->backup_cache = $cache; + // Change the global cache object for this test because + // the mock cache object does not hit the database as is needed + // for this test. $cache = new phpbb_cache_service( new phpbb_cache_driver_file(), $config, @@ -46,17 +50,29 @@ class phpbb_session_check_ban_test extends phpbb_session_test_case $phpbb_root_path, $phpEx ); + } + public function tearDown() + { + parent::tearDown(); + // Set cache back to what it was before the test changed it + global $cache; + $cache = $this->backup_cache; + } + + /** @dataProvider check_banned_data */ + public function test_check_is_banned($test_msg, $user_id, $user_ips, $user_email, $return, $should_be_banned) + { try { - $is_banned = $session->check_ban($user_id, $user_ips, $user_email, $return); - } catch (PHPUnit_Framework_Error_Notice $e) + $is_banned = $this->session->check_ban($user_id, $user_ips, $user_email, $return); + } + catch (PHPUnit_Framework_Error_Notice $e) { // User error was triggered, user must have been banned $is_banned = true; } - $this->assertEquals($should_be_banned, $is_banned, $test_msg); - $cache = new phpbb_mock_cache(); + $this->assertEquals($should_be_banned, $is_banned, $test_msg); } } From 2fe2724e684304e1c8323c047d1dde6cd732afcd Mon Sep 17 00:00:00 2001 From: Andy Chase Date: Mon, 22 Jul 2013 17:39:45 -0700 Subject: [PATCH 2320/2494] [ticket/11620] Whitespace and combine function into test_case PHPBB3-11620 --- tests/mock/auth_provider.php | 8 +++---- tests/session/check_isvalid_test.php | 13 ++--------- tests/session/create_test.php | 2 +- tests/session/garbage_collection_test.php | 22 +++++-------------- tests/session/testable_facade.php | 8 +++---- tests/session/validate_referrer_test.php | 7 +++--- .../phpbb_session_test_case.php | 9 ++++++++ 7 files changed, 30 insertions(+), 39 deletions(-) diff --git a/tests/mock/auth_provider.php b/tests/mock/auth_provider.php index e0a2abd2d5..9d002334d6 100644 --- a/tests/mock/auth_provider.php +++ b/tests/mock/auth_provider.php @@ -20,10 +20,10 @@ class phpbb_mock_auth_provider implements phpbb_auth_provider_interface function login($username, $password) { return array( - 'status' => "", - 'error_msg' => "", - 'user_row' => "", - ); + 'status' => "", + 'error_msg' => "", + 'user_row' => "", + ); } function autologin() diff --git a/tests/session/check_isvalid_test.php b/tests/session/check_isvalid_test.php index c60770dad8..760e2a6f24 100644 --- a/tests/session/check_isvalid_test.php +++ b/tests/session/check_isvalid_test.php @@ -28,21 +28,12 @@ class phpbb_session_check_isvalid_test extends phpbb_session_test_case return $session; } - protected function check_session_equals($expected_sessions, $message) - { - $sql = 'SELECT session_id, session_user_id - FROM phpbb_sessions - ORDER BY session_user_id'; - - $this->assertSqlResultEquals($expected_sessions, $sql, $message); - } - public function test_session_valid_session_exists() { $session = $this->access_with('bar_session000000000000000000000', '4', 'user agent', '127.0.0.1'); $session->check_cookies($this, array()); - $this->check_session_equals(array( + $this->check_sessions_equals(array( array('session_id' => 'anon_session00000000000000000000', 'session_user_id' => 1), array('session_id' => 'bar_session000000000000000000000', 'session_user_id' => 4), ), @@ -59,7 +50,7 @@ class phpbb_session_check_isvalid_test extends phpbb_session_test_case 'sid' => array($session->session_id, null), )); - $this->check_session_equals(array( + $this->check_sessions_equals(array( array('session_id' => $session->session_id, 'session_user_id' => 1), // use generated SID array('session_id' => 'bar_session000000000000000000000', 'session_user_id' => 4), ), diff --git a/tests/session/create_test.php b/tests/session/create_test.php index 0faedf4db2..442445599b 100644 --- a/tests/session/create_test.php +++ b/tests/session/create_test.php @@ -38,6 +38,6 @@ class phpbb_session_create_test extends phpbb_session_test_case self::bot('user agent', 13, '127.0.0.1'), '' ); - $this->assertEquals(true, $output->data['is_bot'] , 'should be a bot'); + $this->assertEquals(true, $output->data['is_bot'], 'should be a bot'); } } diff --git a/tests/session/garbage_collection_test.php b/tests/session/garbage_collection_test.php index b1be958d62..e7d01785dd 100644 --- a/tests/session/garbage_collection_test.php +++ b/tests/session/garbage_collection_test.php @@ -24,29 +24,19 @@ class phpbb_session_garbage_collection_test extends phpbb_session_test_case $this->session = $this->session_factory->get_session($this->db); } - protected function assert_sessions_equal($expected, $msg) - { - $sql = 'SELECT session_id, session_user_id - FROM phpbb_sessions - ORDER BY session_user_id'; - - $this->assertSqlResultEquals($expected, $sql, $msg); - } - public function test_cleanup_all() { - $this->assert_sessions_equal( + $this->check_sessions_equals( array( - array - ( + array( 'session_id' => 'anon_session00000000000000000000', 'session_user_id' => 1, ), - array - ( + array( 'session_id' => 'bar_session000000000000000000000', 'session_user_id' => 4, - )), + ), + ), 'Before test, should have some sessions.' ); // Set session length so it clears all @@ -55,7 +45,7 @@ class phpbb_session_garbage_collection_test extends phpbb_session_test_case // There is an error unless the captcha plugin is set $config['captcha_plugin'] = 'phpbb_captcha_nogd'; $this->session->session_gc(); - $this->assert_sessions_equal( + $this->check_sessions_equals( array(), 'After setting session time to 0, should remove all.' ); diff --git a/tests/session/testable_facade.php b/tests/session/testable_facade.php index c5e58fce05..9f0a3c5f59 100644 --- a/tests/session/testable_facade.php +++ b/tests/session/testable_facade.php @@ -33,7 +33,7 @@ class phpbb_session_testable_facade $this->session_factory = $session_factory; } - function extract_current_page ( + function extract_current_page( $root_path, $php_self, $query_string, @@ -48,7 +48,7 @@ class phpbb_session_testable_facade return phpbb_session::extract_current_page($root_path); } - function extract_current_hostname ( + function extract_current_hostname( $host, $server_name_config, $cookie_domain_config @@ -75,7 +75,7 @@ class phpbb_session_testable_facade * @param request_overrides An array of overrides for the global request object * @return boolean False if the user is identified, otherwise true. */ - function session_begin ( + function session_begin( $update_session_page = true, $config_overrides = array(), $request_overrides = array(), @@ -90,7 +90,7 @@ class phpbb_session_testable_facade return $session; } - function session_create ( + function session_create( $user_id = false, $set_admin = false, $persist_login = false, diff --git a/tests/session/validate_referrer_test.php b/tests/session/validate_referrer_test.php index f78bf36c1b..a302229287 100644 --- a/tests/session/validate_referrer_test.php +++ b/tests/session/validate_referrer_test.php @@ -16,7 +16,8 @@ class phpbb_session_validate_referrer_test extends phpbb_session_test_case return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/sessions_empty.xml'); } - static function referrer_inputs() { + static function referrer_inputs() + { $ex = "example.org"; $alt = "example.com"; return array( @@ -39,8 +40,8 @@ class phpbb_session_validate_referrer_test extends phpbb_session_test_case ); } - /** @dataProvider referrer_inputs */ - function test_referrer_inputs ( + /** @dataProvider referrer_inputs */ + function test_referrer_inputs( $check_script_path, $referrer, $host, diff --git a/tests/test_framework/phpbb_session_test_case.php b/tests/test_framework/phpbb_session_test_case.php index 6ff7d8e2ef..e6a2b03bba 100644 --- a/tests/test_framework/phpbb_session_test_case.php +++ b/tests/test_framework/phpbb_session_test_case.php @@ -24,4 +24,13 @@ abstract class phpbb_session_test_case extends phpbb_database_test_case $this->session_facade = new phpbb_session_testable_facade($this->db, $this->session_factory); } + + protected function check_sessions_equals($expected_sessions, $message) + { + $sql = 'SELECT session_id, session_user_id + FROM phpbb_sessions + ORDER BY session_user_id'; + + $this->assertSqlResultEquals($expected_sessions, $sql, $message); + } } From c36699811221b17c563a7525b790e0c6c3ab98e0 Mon Sep 17 00:00:00 2001 From: Bruno Ais Date: Tue, 23 Jul 2013 12:47:18 +0100 Subject: [PATCH 2321/2494] [ticket/11654] Moved some code to reduce line width. sub-task of ticket PHPBB3-11635: find and fix all bypasses of generate_text_for_* PHPBB3-11654 --- phpBB/includes/mcp/mcp_warn.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/phpBB/includes/mcp/mcp_warn.php b/phpBB/includes/mcp/mcp_warn.php index 65cf641418..bb21d3d377 100644 --- a/phpBB/includes/mcp/mcp_warn.php +++ b/phpBB/includes/mcp/mcp_warn.php @@ -289,7 +289,8 @@ class mcp_warn // We want to make the message available here as a reminder // Parse the message and subject - $message = generate_text_for_display($user_row['post_text'], $user_row['bbcode_uid'], $user_row['bbcode_bitfield'], ($user_row['bbcode_bitfield'] ? OPTION_FLAG_BBCODE : 0) | OPTION_FLAG_SMILIES, true); + $parse_flags = OPTION_FLAG_SMILIES | ($row['bbcode_bitfield'] ? OPTION_FLAG_BBCODE : 0); + $message = generate_text_for_display($user_row['post_text'], $user_row['bbcode_uid'], $user_row['bbcode_bitfield'], $parse_flags, true); // Generate the appropriate user information for the user we are looking at if (!function_exists('phpbb_get_user_avatar')) From 6b0b0f2a9fdd2e2169534756e9ceb4421125c7ea Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Sun, 14 Jul 2013 12:10:49 -0500 Subject: [PATCH 2322/2494] [ticket/11701] Loop variables are not passed correctly to events PHPBB3-11701 --- phpBB/phpbb/template/twig/lexer.php | 10 +++++----- phpBB/phpbb/template/twig/twig.php | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/phpBB/phpbb/template/twig/lexer.php b/phpBB/phpbb/template/twig/lexer.php index 4f88147542..606ca347ae 100644 --- a/phpBB/phpbb/template/twig/lexer.php +++ b/phpBB/phpbb/template/twig/lexer.php @@ -191,20 +191,20 @@ class phpbb_template_twig_lexer extends Twig_Lexer // Recursive...fix any child nodes $body = $parent_class->fix_begin_tokens($body, $parent_nodes); - // Rename loopname vars (to prevent collisions, loop children are named (loop name)_loop_element) - $body = str_replace($name . '.', $name . '_loop_element.', $body); + // Rename loopname vars + $body = str_replace($name . '.', $name . '.', $body); // Need the parent variable name array_pop($parent_nodes); - $parent = (!empty($parent_nodes)) ? end($parent_nodes) . '_loop_element.' : ''; + $parent = (!empty($parent_nodes)) ? end($parent_nodes) . '.' : ''; if ($subset !== '') { $subset = '|subset(' . $subset . ')'; } - // Turn into a Twig for loop, using (loop name)_loop_element for each child - return "{% for {$name}_loop_element in {$parent}{$name}{$subset} %}{$body}{% endfor %}"; + // Turn into a Twig for loop + return "{% for {$name} in loops.{$parent}{$name}{$subset} %}{$body}{% endfor %}"; }; // Replace correctly, only needs to be done once diff --git a/phpBB/phpbb/template/twig/twig.php b/phpBB/phpbb/template/twig/twig.php index 92a37d1634..6cff1bb8e4 100644 --- a/phpBB/phpbb/template/twig/twig.php +++ b/phpBB/phpbb/template/twig/twig.php @@ -429,15 +429,15 @@ class phpbb_template_twig implements phpbb_template $vars = array_merge( $context_vars['.'][0], // To get normal vars - $context_vars, // To get loops array( 'definition' => new phpbb_template_twig_definition(), 'user' => $this->user, + 'loops' => $context_vars, // To get loops ) ); // cleanup - unset($vars['.']); + unset($vars['loops']['.']); return $vars; } From 0d31420ae099b9284c6240bfbda0f03f1be155c1 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Sun, 14 Jul 2013 12:18:44 -0500 Subject: [PATCH 2323/2494] [ticket/11701] Remove useless str_replace PHPBB3-11701 --- phpBB/phpbb/template/twig/lexer.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/phpBB/phpbb/template/twig/lexer.php b/phpBB/phpbb/template/twig/lexer.php index 606ca347ae..3c072adff9 100644 --- a/phpBB/phpbb/template/twig/lexer.php +++ b/phpBB/phpbb/template/twig/lexer.php @@ -191,9 +191,6 @@ class phpbb_template_twig_lexer extends Twig_Lexer // Recursive...fix any child nodes $body = $parent_class->fix_begin_tokens($body, $parent_nodes); - // Rename loopname vars - $body = str_replace($name . '.', $name . '.', $body); - // Need the parent variable name array_pop($parent_nodes); $parent = (!empty($parent_nodes)) ? end($parent_nodes) . '.' : ''; From 1d2d3032d3f0f614b0df9851c373618e205580f8 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 23 Jul 2013 16:26:01 +0200 Subject: [PATCH 2324/2494] [ticket/11734] Readd accidently removed language strings of forum permissions PHPBB3-11734 --- phpBB/language/en/acp/permissions_phpbb.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/phpBB/language/en/acp/permissions_phpbb.php b/phpBB/language/en/acp/permissions_phpbb.php index d0128db34a..5ea151f6ea 100644 --- a/phpBB/language/en/acp/permissions_phpbb.php +++ b/phpBB/language/en/acp/permissions_phpbb.php @@ -102,6 +102,17 @@ $lang = array_merge($lang, array( // Forum Permissions $lang = array_merge($lang, array( + 'ACL_F_LIST' => 'Can see forum', + 'ACL_F_READ' => 'Can read forum', + 'ACL_F_SEARCH' => 'Can search the forum', + 'ACL_F_SUBSCRIBE' => 'Can subscribe forum', + 'ACL_F_PRINT' => 'Can print topics', + 'ACL_F_EMAIL' => 'Can email topics', + 'ACL_F_BUMP' => 'Can bump topics', + 'ACL_F_USER_LOCK' => 'Can lock own topics', + 'ACL_F_DOWNLOAD' => 'Can download files', + 'ACL_F_REPORT' => 'Can report posts', + 'ACL_F_POST' => 'Can start new topics', 'ACL_F_STICKY' => 'Can post stickies', 'ACL_F_ANNOUNCE' => 'Can post announcements', From c0b9db1c626c88780b2ee5f5a237561a125c54aa Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Sun, 14 Jul 2013 14:10:11 -0500 Subject: [PATCH 2325/2494] [ticket/11701] Fix loops var check PHPBB3-11701 --- phpBB/phpbb/template/twig/lexer.php | 8 +++-- tests/template/template_test.php | 32 +++++++++---------- tests/template/templates/include_loop.html | 8 ++--- .../templates/include_loop_define.html | 6 ++-- tests/template/templates/loop.html | 14 ++++---- tests/template/templates/loop_advanced.html | 20 ++++++------ tests/template/templates/loop_size.html | 10 +++--- tests/template/templates/loop_vars.html | 18 +++++------ 8 files changed, 60 insertions(+), 56 deletions(-) diff --git a/phpBB/phpbb/template/twig/lexer.php b/phpBB/phpbb/template/twig/lexer.php index 3c072adff9..4f127bd7e6 100644 --- a/phpBB/phpbb/template/twig/lexer.php +++ b/phpBB/phpbb/template/twig/lexer.php @@ -200,8 +200,9 @@ class phpbb_template_twig_lexer extends Twig_Lexer $subset = '|subset(' . $subset . ')'; } + $parent = ($parent) ?: 'loops.'; // Turn into a Twig for loop - return "{% for {$name} in loops.{$parent}{$name}{$subset} %}{$body}{% endfor %}"; + return "{% for {$name} in {$parent}{$name}{$subset} %}{$body}{% endfor %}"; }; // Replace correctly, only needs to be done once @@ -224,7 +225,10 @@ class phpbb_template_twig_lexer extends Twig_Lexer // Replace $TEST with definition.TEST $inner = preg_replace('#\s\$([a-zA-Z_0-9]+)#', ' definition.$1', $inner); - // Replace .test with test|length + // Replace .foo with loops.foo|length + $inner = preg_replace('#\s\.([a-zA-Z_0-9]+)#', ' loops.$1|length', $inner); + + // Replace .foo.bar with foo.bar|length $inner = preg_replace('#\s\.([a-zA-Z_0-9\.]+)#', ' $1|length', $inner); return ""; diff --git a/tests/template/template_test.php b/tests/template/template_test.php index dd9ba21c26..0a6b680100 100644 --- a/tests/template/template_test.php +++ b/tests/template/template_test.php @@ -93,49 +93,49 @@ class phpbb_template_template_test extends phpbb_template_template_test_case array( 'loop.html', array(), - array('loop' => array(array())), + array('test_loop' => array(array())), array(), "loop\nloop", ), array( 'loop.html', array(), - array('loop' => array(array(), array()), 'loop.block' => array(array())), + array('test_loop' => array(array(), array()), 'test_loop.block' => array(array())), array(), "loop\nloop\nloop\nloop", ), array( 'loop.html', array(), - array('loop' => array(array(), array()), 'loop.block' => array(array()), 'block' => array(array(), array())), + array('test_loop' => array(array(), array()), 'test_loop.block' => array(array()), 'block' => array(array(), array())), array(), "loop\nloop\nloop\nloop\nloop#0-block#0\nloop#0-block#1\nloop#1-block#0\nloop#1-block#1", ), array( 'loop_vars.html', array(), - array('loop' => array(array('VARIABLE' => 'x'))), + array('test_loop' => array(array('VARIABLE' => 'x'))), array(), "first\n0 - a\nx - b\nset\nlast", ), array( 'loop_vars.html', array(), - array('loop' => array(array('VARIABLE' => 'x'), array('VARIABLE' => 'y'))), + array('test_loop' => array(array('VARIABLE' => 'x'), array('VARIABLE' => 'y'))), array(), "first\n0 - a\nx - b\nset\n1 - a\ny - b\nset\nlast", ), array( 'loop_vars.html', array(), - array('loop' => array(array('VARIABLE' => 'x'), array('VARIABLE' => 'y')), 'loop.inner' => array(array(), array())), + array('test_loop' => array(array('VARIABLE' => 'x'), array('VARIABLE' => 'y')), 'test_loop.inner' => array(array(), array())), array(), "first\n0 - a\nx - b\nset\n1 - a\ny - b\nset\nlast\n0 - c\n1 - c\nlast inner", ), array( 'loop_advanced.html', array(), - array('loop' => array(array(), array(), array(), array(), array(), array(), array())), + array('test_loop' => array(array(), array(), array(), array(), array(), array(), array())), array(), "101234561\nx\n101234561\nx\n101234561\nx\n1234561\nx\n1\nx\n101\nx\n234\nx\n10\nx\n561\nx\n561", ), @@ -149,14 +149,14 @@ class phpbb_template_template_test extends phpbb_template_template_test_case array( 'define.html', array(), - array('loop' => array(array(), array(), array(), array(), array(), array(), array()), 'test' => array(array()), 'test.deep' => array(array()), 'test.deep.defines' => array(array())), + array('test_loop' => array(array(), array(), array(), array(), array(), array(), array()), 'test' => array(array()), 'test.deep' => array(array()), 'test.deep.defines' => array(array())), array(), "xyz\nabc\n\$VALUE == 'abc'abc\nbar\nbar\nabc\ntest!@#$%^&*()_-=+{}[]:;\",<.>/?", ), array( 'define_advanced.html', array(), - array('loop' => array(array(), array(), array(), array(), array(), array(), array()), 'test' => array(array()), 'test.deep' => array(array()), 'test.deep.defines' => array(array())), + array('test_loop' => array(array(), array(), array(), array(), array(), array(), array()), 'test' => array(array()), 'test.deep' => array(array()), 'test.deep.defines' => array(array())), array(), "abc\nzxc\ncde\nbcd", ), @@ -200,7 +200,7 @@ class phpbb_template_template_test extends phpbb_template_template_test_case array( 'include_loop.html', array(), - array('loop' => array(array('NESTED_FILE' => 'include_loop1.html')), 'loop.inner' => array(array('NESTED_FILE' => 'include_loop1.html'), array('NESTED_FILE' => 'include_loop2.html'), array('NESTED_FILE' => 'include_loop3.html'))), + array('test_loop' => array(array('NESTED_FILE' => 'include_loop1.html')), 'test_loop.inner' => array(array('NESTED_FILE' => 'include_loop1.html'), array('NESTED_FILE' => 'include_loop2.html'), array('NESTED_FILE' => 'include_loop3.html'))), array(), "1\n_1\n_02\n_3", ), @@ -221,8 +221,8 @@ class phpbb_template_template_test extends phpbb_template_template_test_case array( 'loop_vars.html', array(), - array('loop' => array(array('VARIABLE' => 'x'), array('VARIABLE' => 'y')), 'loop.inner' => array(array(), array())), - array('loop'), + array('test_loop' => array(array('VARIABLE' => 'x'), array('VARIABLE' => 'y')), 'test_loop.inner' => array(array(), array())), + array('test_loop'), '', ), array( @@ -235,7 +235,7 @@ class phpbb_template_template_test extends phpbb_template_template_test_case array( 'include_loop_define.html', array('VARIABLE' => 'value'), - array('loop' => array(array('NESTED_FILE' => 'variable.html'))), + array('test_loop' => array(array('NESTED_FILE' => 'variable.html'))), array(), 'value', ), @@ -243,8 +243,8 @@ class phpbb_template_template_test extends phpbb_template_template_test_case array( 'loop_vars.html', array(), - array('loop' => array(array('VARIABLE' => 'x'), array('VARIABLE' => 'y')), 'loop.inner' => array(array(), array())), - array('loop.inner'), + array('test_loop' => array(array('VARIABLE' => 'x'), array('VARIABLE' => 'y')), 'test_loop.inner' => array(array(), array())), + array('test_loop.inner'), "first\n0\n0\n2\nx\nset\n1\n1\n2\ny\nset\nlast", ),*/ array( @@ -295,7 +295,7 @@ class phpbb_template_template_test extends phpbb_template_template_test_case array( 'loop_size.html', array(), - array('loop' => array(array()), 'empty_loop' => array()), + array('test_loop' => array(array()), 'empty_loop' => array()), array(), "nonexistent = 0\n! nonexistent\n\nempty = 0\n! empty\nloop\n\nin loop", ), diff --git a/tests/template/templates/include_loop.html b/tests/template/templates/include_loop.html index d5c3d9bc82..5cad34b363 100644 --- a/tests/template/templates/include_loop.html +++ b/tests/template/templates/include_loop.html @@ -1,4 +1,4 @@ - - -_ - + + +_ + diff --git a/tests/template/templates/include_loop_define.html b/tests/template/templates/include_loop_define.html index f539b21396..4bab09422e 100644 --- a/tests/template/templates/include_loop_define.html +++ b/tests/template/templates/include_loop_define.html @@ -1,4 +1,4 @@ - - + + - + diff --git a/tests/template/templates/loop.html b/tests/template/templates/loop.html index de1a10004d..f541e934df 100644 --- a/tests/template/templates/loop.html +++ b/tests/template/templates/loop.html @@ -1,21 +1,21 @@ - + loop noloop - + - + loop noloop - + loop - + -loop#{loop.S_ROW_COUNT}-block#{block.S_ROW_COUNT} +loop#{test_loop.S_ROW_COUNT}-block#{block.S_ROW_COUNT} - + diff --git a/tests/template/templates/loop_advanced.html b/tests/template/templates/loop_advanced.html index c75fe55f03..1f56686eaa 100644 --- a/tests/template/templates/loop_advanced.html +++ b/tests/template/templates/loop_advanced.html @@ -1,19 +1,19 @@ -{loop.S_FIRST_ROW}{loop.S_ROW_COUNT}{loop.S_LAST_ROW} +{test_loop.S_FIRST_ROW}{test_loop.S_ROW_COUNT}{test_loop.S_LAST_ROW} x -{loop.S_FIRST_ROW}{loop.S_ROW_COUNT}{loop.S_LAST_ROW} +{test_loop.S_FIRST_ROW}{test_loop.S_ROW_COUNT}{test_loop.S_LAST_ROW} x -{loop.S_FIRST_ROW}{loop.S_ROW_COUNT}{loop.S_LAST_ROW} +{test_loop.S_FIRST_ROW}{test_loop.S_ROW_COUNT}{test_loop.S_LAST_ROW} x -{loop.S_FIRST_ROW}{loop.S_ROW_COUNT}{loop.S_LAST_ROW} +{test_loop.S_FIRST_ROW}{test_loop.S_ROW_COUNT}{test_loop.S_LAST_ROW} x -{loop.S_FIRST_ROW}{loop.S_ROW_COUNT}{loop.S_LAST_ROW} +{test_loop.S_FIRST_ROW}{test_loop.S_ROW_COUNT}{test_loop.S_LAST_ROW} x -{loop.S_FIRST_ROW}{loop.S_ROW_COUNT}{loop.S_LAST_ROW} +{test_loop.S_FIRST_ROW}{test_loop.S_ROW_COUNT}{test_loop.S_LAST_ROW} x -{loop.S_FIRST_ROW}{loop.S_ROW_COUNT}{loop.S_LAST_ROW} +{test_loop.S_FIRST_ROW}{test_loop.S_ROW_COUNT}{test_loop.S_LAST_ROW} x -{loop.S_FIRST_ROW}{loop.S_ROW_COUNT}{loop.S_LAST_ROW} +{test_loop.S_FIRST_ROW}{test_loop.S_ROW_COUNT}{test_loop.S_LAST_ROW} x -{loop.S_FIRST_ROW}{loop.S_ROW_COUNT}{loop.S_LAST_ROW} +{test_loop.S_FIRST_ROW}{test_loop.S_ROW_COUNT}{test_loop.S_LAST_ROW} x -{loop.S_FIRST_ROW}{loop.S_ROW_COUNT}{loop.S_LAST_ROW} +{test_loop.S_FIRST_ROW}{test_loop.S_ROW_COUNT}{test_loop.S_LAST_ROW} diff --git a/tests/template/templates/loop_size.html b/tests/template/templates/loop_size.html index 8f581cef10..2b1fcd2dd4 100644 --- a/tests/template/templates/loop_size.html +++ b/tests/template/templates/loop_size.html @@ -22,18 +22,18 @@ ! empty - + loop - + loop = 0 - + ! loop - + in loop - + diff --git a/tests/template/templates/loop_vars.html b/tests/template/templates/loop_vars.html index 7d86d4b7b6..70a3eb2cec 100644 --- a/tests/template/templates/loop_vars.html +++ b/tests/template/templates/loop_vars.html @@ -1,13 +1,13 @@ - -first -{loop.S_ROW_NUM} - a -{loop.VARIABLE} - b -set - + +first +{test_loop.S_ROW_NUM} - a +{test_loop.VARIABLE} - b +set + last -{inner.S_ROW_NUM} - c -last inner +{test_loop.inner.S_ROW_NUM} - c +last inner - + From 2d764ef7d54104be2925aa015193da20c4383c5d Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Fri, 19 Jul 2013 11:31:52 -0500 Subject: [PATCH 2326/2494] [ticket/11701] Fix regex for appending |length PHPBB3-11701 --- phpBB/phpbb/template/twig/lexer.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpBB/phpbb/template/twig/lexer.php b/phpBB/phpbb/template/twig/lexer.php index 4f127bd7e6..95b3043403 100644 --- a/phpBB/phpbb/template/twig/lexer.php +++ b/phpBB/phpbb/template/twig/lexer.php @@ -226,10 +226,10 @@ class phpbb_template_twig_lexer extends Twig_Lexer $inner = preg_replace('#\s\$([a-zA-Z_0-9]+)#', ' definition.$1', $inner); // Replace .foo with loops.foo|length - $inner = preg_replace('#\s\.([a-zA-Z_0-9]+)#', ' loops.$1|length', $inner); + $inner = preg_replace('#\s\.([a-zA-Z_0-9]+) #', ' loops.$1|length ', $inner); // Replace .foo.bar with foo.bar|length - $inner = preg_replace('#\s\.([a-zA-Z_0-9\.]+)#', ' $1|length', $inner); + $inner = preg_replace('#\s\.([a-zA-Z_0-9\.]+) #', ' $1|length ', $inner); return ""; }; From ea250a5ef5dd3e790b22336e5a9e74c77da35569 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Fri, 19 Jul 2013 12:43:24 -0500 Subject: [PATCH 2327/2494] [ticket/11701] Refix regex for appending |length PHPBB3-11701 --- phpBB/phpbb/template/twig/lexer.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpBB/phpbb/template/twig/lexer.php b/phpBB/phpbb/template/twig/lexer.php index 95b3043403..3534311b7a 100644 --- a/phpBB/phpbb/template/twig/lexer.php +++ b/phpBB/phpbb/template/twig/lexer.php @@ -226,10 +226,10 @@ class phpbb_template_twig_lexer extends Twig_Lexer $inner = preg_replace('#\s\$([a-zA-Z_0-9]+)#', ' definition.$1', $inner); // Replace .foo with loops.foo|length - $inner = preg_replace('#\s\.([a-zA-Z_0-9]+) #', ' loops.$1|length ', $inner); + $inner = preg_replace('#\s\.([a-zA-Z_0-9]+)([^a-zA-Z_0-9\.])#', ' loops.$1|length$2', $inner); // Replace .foo.bar with foo.bar|length - $inner = preg_replace('#\s\.([a-zA-Z_0-9\.]+) #', ' $1|length ', $inner); + $inner = preg_replace('#\s\.([a-zA-Z_0-9\.]+)([^a-zA-Z_0-9\.])#', ' $1|length$2', $inner); return ""; }; From 30bfd7fb61bbe1d7ca50290730d8c4b6094c41a4 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Fri, 19 Jul 2013 13:25:53 -0500 Subject: [PATCH 2328/2494] [ticket/11701] Test events in loops PHPBB3-11701 --- .../trivial/styles/all/template/test_event_loop.html | 1 + .../ext_trivial/styles/silver/template/event_loop.html | 3 +++ tests/template/template_events_test.php | 10 ++++++++++ 3 files changed, 14 insertions(+) create mode 100644 tests/template/datasets/ext_trivial/ext/trivial/styles/all/template/test_event_loop.html create mode 100644 tests/template/datasets/ext_trivial/styles/silver/template/event_loop.html diff --git a/tests/template/datasets/ext_trivial/ext/trivial/styles/all/template/test_event_loop.html b/tests/template/datasets/ext_trivial/ext/trivial/styles/all/template/test_event_loop.html new file mode 100644 index 0000000000..149398d6bd --- /dev/null +++ b/tests/template/datasets/ext_trivial/ext/trivial/styles/all/template/test_event_loop.html @@ -0,0 +1 @@ +{event_loop.S_ROW_COUNT}| \ No newline at end of file diff --git a/tests/template/datasets/ext_trivial/styles/silver/template/event_loop.html b/tests/template/datasets/ext_trivial/styles/silver/template/event_loop.html new file mode 100644 index 0000000000..c70d8f86d7 --- /dev/null +++ b/tests/template/datasets/ext_trivial/styles/silver/template/event_loop.html @@ -0,0 +1,3 @@ + +event_loop + diff --git a/tests/template/template_events_test.php b/tests/template/template_events_test.php index f7bcd2dcc6..d3b65e763a 100644 --- a/tests/template/template_events_test.php +++ b/tests/template/template_events_test.php @@ -80,6 +80,16 @@ Zeta test event in all', array(), 'two in silver in omega', ), + array( + 'EVENT in loop', + 'ext_trivial', + array('silver'), + 'event_loop.html', + array(), + array('event_loop' => array(array(), array(), array())), + array(), + 'event_loop0|event_loop1|event_loop2', + ), ); } From 0f83d7fd6cf6819c0fe2f4bfa9f65873f7124b72 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Fri, 19 Jul 2013 13:36:28 -0500 Subject: [PATCH 2329/2494] [ticket/11701] New line at EOF PHPBB3-11701 --- .../ext/trivial/styles/all/template/test_event_loop.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/template/datasets/ext_trivial/ext/trivial/styles/all/template/test_event_loop.html b/tests/template/datasets/ext_trivial/ext/trivial/styles/all/template/test_event_loop.html index 149398d6bd..235e129f85 100644 --- a/tests/template/datasets/ext_trivial/ext/trivial/styles/all/template/test_event_loop.html +++ b/tests/template/datasets/ext_trivial/ext/trivial/styles/all/template/test_event_loop.html @@ -1 +1 @@ -{event_loop.S_ROW_COUNT}| \ No newline at end of file +{event_loop.S_ROW_COUNT}| From bf04bfcced7934704e7f2682ee608f490cb3fc76 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Tue, 23 Jul 2013 11:16:23 -0500 Subject: [PATCH 2330/2494] [ticket/11667] Use @inheritdoc PHPBB3-11667 --- phpBB/phpbb/template/twig/node/includecss.php | 9 ++------- phpBB/phpbb/template/twig/node/includejs.php | 9 ++------- 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/phpBB/phpbb/template/twig/node/includecss.php b/phpBB/phpbb/template/twig/node/includecss.php index 450edb3e1e..a9d9b46d69 100644 --- a/phpBB/phpbb/template/twig/node/includecss.php +++ b/phpBB/phpbb/template/twig/node/includecss.php @@ -10,9 +10,7 @@ class phpbb_template_twig_node_includecss extends phpbb_template_twig_node_includeasset { /** - * Get the definition name - * - * @return string (e.g. 'SCRIPTS') + * {@inheritdoc} */ public function get_definition_name() { @@ -20,10 +18,7 @@ class phpbb_template_twig_node_includecss extends phpbb_template_twig_node_inclu } /** - * Append the output code for the asset - * - * @param Twig_Compiler A Twig_Compiler instance - * @return null + * {@inheritdoc} */ public function append_asset(Twig_Compiler $compiler) { diff --git a/phpBB/phpbb/template/twig/node/includejs.php b/phpBB/phpbb/template/twig/node/includejs.php index 50ab448e0f..2b4b55fb0a 100644 --- a/phpBB/phpbb/template/twig/node/includejs.php +++ b/phpBB/phpbb/template/twig/node/includejs.php @@ -10,9 +10,7 @@ class phpbb_template_twig_node_includejs extends phpbb_template_twig_node_includeasset { /** - * Get the definition name - * - * @return string (e.g. 'SCRIPTS') + * {@inheritdoc} */ public function get_definition_name() { @@ -20,10 +18,7 @@ class phpbb_template_twig_node_includejs extends phpbb_template_twig_node_includ } /** - * Append the output code for the asset - * - * @param Twig_Compiler A Twig_Compiler instance - * @return null + * {@inheritdoc} */ protected function append_asset(Twig_Compiler $compiler) { From 1372b4f20801d6079798832f15caf38949fe9333 Mon Sep 17 00:00:00 2001 From: Bruno Ais Date: Wed, 24 Jul 2013 10:33:06 +0100 Subject: [PATCH 2331/2494] [ticket/11639] Removed a non-needed unset sub-task of ticket PHPBB3-11635: find and fix all bypasses of generate_text_for_* PHPBB3-11639 --- phpBB/includes/functions_posting.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index 49a1797321..acf0cc874b 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -1110,8 +1110,6 @@ function topic_review($topic_id, $forum_id, $mode = 'topic_review', $cur_post_id // Do not censor text because it has already been censored before $message = generate_text_for_display($message, $row['bbcode_uid'], $row['bbcode_bitfield'], $parse_flags, false); - unset($parse_flags); - if (!empty($attachments[$row['post_id']])) { $update_count = array(); From 13fa346e8f5b496f5e51ea20e9420a48228a5072 Mon Sep 17 00:00:00 2001 From: Bruno Ais Date: Wed, 24 Jul 2013 11:38:04 +0100 Subject: [PATCH 2332/2494] [ticket/11656] Made the check for the bitfield just like other PR's sub-task of ticket PHPBB3-11635: find and fix all bypasses of generate_text_for_* PHPBB3-11656 --- phpBB/memberlist.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/phpBB/memberlist.php b/phpBB/memberlist.php index f8ee82084c..018526d034 100644 --- a/phpBB/memberlist.php +++ b/phpBB/memberlist.php @@ -561,7 +561,8 @@ switch ($mode) if ($member['user_sig']) { - $member['user_sig'] = generate_text_for_display($member['user_sig'], $member['user_sig_bbcode_uid'], $member['user_sig_bbcode_bitfield'], OPTION_FLAG_BBCODE | OPTION_FLAG_SMILIES, true); + $parse_flags = ($member['user_sig_bbcode_bitfield'] ? OPTION_FLAG_BBCODE : 0) | OPTION_FLAG_SMILIES; + $member['user_sig'] = generate_text_for_display($member['user_sig'], $member['user_sig_bbcode_uid'], $member['user_sig_bbcode_bitfield'], $parse_flags, true); } $poster_avatar = phpbb_get_user_avatar($member); From 4ed322b5b8642ec8d0a6faf23d9ea751e81dbf69 Mon Sep 17 00:00:00 2001 From: Bruno Ais Date: Wed, 24 Jul 2013 11:59:28 +0100 Subject: [PATCH 2333/2494] [ticket/11638] Updated: bitwise $parse_flags use optionset() sub-task of ticket PHPBB3-11635: find and fix all bypasses of generate_text_for_* PHPBB3-11638 --- phpBB/viewtopic.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index de76d1186d..303b9bb6da 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -1381,8 +1381,9 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i) // End signature parsing, only if needed if ($user_cache[$poster_id]['sig'] && $row['enable_sig'] && empty($user_cache[$poster_id]['sig_parsed'])) { - $include_bbcode_parse = $user_cache[$poster_id]['sig_bbcode_bitfield'] ? OPTION_FLAG_BBCODE : 0; - $user_cache[$poster_id]['sig'] = generate_text_for_display($user_cache[$poster_id]['sig'], $user_cache[$poster_id]['sig_bbcode_uid'], $user_cache[$poster_id]['sig_bbcode_bitfield'], $include_bbcode_parse | OPTION_FLAG_SMILIES, true); + $parse_flags = phpbb_optionset(OPTION_FLAG_SMILIES, true, 0); + $parse_flags = phpbb_optionset(OPTION_FLAG_BBCODE, $user_cache[$poster_id]['sig_bbcode_bitfield'], $parse_flag); + $user_cache[$poster_id]['sig'] = generate_text_for_display($user_cache[$poster_id]['sig'], $user_cache[$poster_id]['sig_bbcode_uid'], $parse_flags, true); } // Parse the message and subject From 0dcf24acc10e7ad52bf47c39faf14b118fd1566d Mon Sep 17 00:00:00 2001 From: Oliver Schramm Date: Wed, 24 Jul 2013 12:41:40 +0200 Subject: [PATCH 2334/2494] [ticket/8228] Fix whitespaces before code in Firefox Based on the "[code] enhancements" modification by TerraFrost PHPBB3-8228 --- phpBB/styles/prosilver/template/bbcode.html | 4 ++-- phpBB/styles/prosilver/template/forum_fn.js | 5 +++-- phpBB/styles/prosilver/theme/colours.css | 2 +- phpBB/styles/prosilver/theme/content.css | 2 +- phpBB/styles/subsilver2/template/bbcode.html | 4 ++-- 5 files changed, 9 insertions(+), 8 deletions(-) diff --git a/phpBB/styles/prosilver/template/bbcode.html b/phpBB/styles/prosilver/template/bbcode.html index c0c0a2da46..460d102c28 100644 --- a/phpBB/styles/prosilver/template/bbcode.html +++ b/phpBB/styles/prosilver/template/bbcode.html @@ -12,8 +12,8 @@
    -
    {L_CODE}{L_COLON} {L_SELECT_ALL_CODE}
    -
    +
    {L_CODE}{L_COLON} {L_SELECT_ALL_CODE}
    
    +
    diff --git a/phpBB/styles/prosilver/template/forum_fn.js b/phpBB/styles/prosilver/template/forum_fn.js index eccb12e827..42a68a2ef5 100644 --- a/phpBB/styles/prosilver/template/forum_fn.js +++ b/phpBB/styles/prosilver/template/forum_fn.js @@ -187,7 +187,7 @@ function displayBlocks(c, e, t) { function selectCode(a) { // Get ID of code block - var e = a.parentNode.parentNode.getElementsByTagName('CODE')[0]; + var e = a.parentNode.parentNode.getElementsByTagName('PRE')[0]; var s, r; // Not IE and IE9+ @@ -205,7 +205,8 @@ function selectCode(a) { } r = document.createRange(); - r.selectNodeContents(e); + r.setStart(e.firstChild, 0); + r.setEnd(e.lastChild, e.lastChild.textContent.length); s.removeAllRanges(); s.addRange(r); } diff --git a/phpBB/styles/prosilver/theme/colours.css b/phpBB/styles/prosilver/theme/colours.css index 7d0462be1b..801d607d9c 100644 --- a/phpBB/styles/prosilver/theme/colours.css +++ b/phpBB/styles/prosilver/theme/colours.css @@ -479,7 +479,7 @@ dl.codebox dt { border-bottom-color: #CCCCCC; } -dl.codebox code { +dl.codebox pre { color: #2E8B57; } diff --git a/phpBB/styles/prosilver/theme/content.css b/phpBB/styles/prosilver/theme/content.css index 4b8c972697..0cab12910b 100644 --- a/phpBB/styles/prosilver/theme/content.css +++ b/phpBB/styles/prosilver/theme/content.css @@ -491,7 +491,7 @@ blockquote dl.codebox { margin-left: 0; } -dl.codebox code { +dl.codebox pre { /* Also see tweaks.css */ overflow: auto; display: block; diff --git a/phpBB/styles/subsilver2/template/bbcode.html b/phpBB/styles/subsilver2/template/bbcode.html index efcf5e1acb..5558716cad 100644 --- a/phpBB/styles/subsilver2/template/bbcode.html +++ b/phpBB/styles/subsilver2/template/bbcode.html @@ -21,11 +21,11 @@ -
    {L_CODE}{L_COLON}
    +
    {L_CODE}{L_COLON}
     
     
     
    -
    + From 029015e1542e7719d4a35d350093f4dfb3a7313e Mon Sep 17 00:00:00 2001 From: Bruno Ais Date: Wed, 24 Jul 2013 12:31:14 +0100 Subject: [PATCH 2335/2494] [ticket/11638] Reverted to use the $parse tags way as the other ones sub-task of ticket PHPBB3-11635: find and fix all bypasses of generate_text_for_* PHPBB3-11638 --- phpBB/viewtopic.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index 303b9bb6da..a0e7eb6a94 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -1381,9 +1381,8 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i) // End signature parsing, only if needed if ($user_cache[$poster_id]['sig'] && $row['enable_sig'] && empty($user_cache[$poster_id]['sig_parsed'])) { - $parse_flags = phpbb_optionset(OPTION_FLAG_SMILIES, true, 0); - $parse_flags = phpbb_optionset(OPTION_FLAG_BBCODE, $user_cache[$poster_id]['sig_bbcode_bitfield'], $parse_flag); - $user_cache[$poster_id]['sig'] = generate_text_for_display($user_cache[$poster_id]['sig'], $user_cache[$poster_id]['sig_bbcode_uid'], $parse_flags, true); + $parse_flags = ($user_cache[$poster_id]['sig_bbcode_bitfield'] ? OPTION_FLAG_BBCODE : 0) | OPTION_FLAG_SMILIES; + $user_cache[$poster_id]['sig'] = generate_text_for_display($user_cache[$poster_id]['sig'], $user_cache[$poster_id]['sig_bbcode_uid'], $user_cache[$poster_id]['sig_bbcode_bitfield'], $parse_flags, true); } // Parse the message and subject From 6c68348a71891219b039ae98a5a0af2fd52d3956 Mon Sep 17 00:00:00 2001 From: Bruno Ais Date: Wed, 24 Jul 2013 12:31:38 +0100 Subject: [PATCH 2336/2494] [ticket/11638] Use the $parse_flags like the other commits sub-task of ticket PHPBB3-11635: find and fix all bypasses of generate_text_for_* PHPBB3-11638 --- phpBB/viewtopic.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index a0e7eb6a94..151176fc6f 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -1386,7 +1386,8 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i) } // Parse the message and subject - $message = generate_text_for_display($row['post_text'], $row['bbcode_uid'], $row['bbcode_bitfield'], ($row['bbcode_bitfield'] ? OPTION_FLAG_BBCODE : 0) | OPTION_FLAG_SMILIES, true); + $parse_flags = ($row['bbcode_bitfield'] ? OPTION_FLAG_BBCODE : 0) | OPTION_FLAG_SMILIES; + $message = generate_text_for_display($row['post_text'], $row['bbcode_uid'], $row['bbcode_bitfield'], $parse_flags, true); if (!empty($attachments[$row['post_id']])) { From 4cdccbd42b2f6ee54c6edb7f96ec3a0cac2ae8ea Mon Sep 17 00:00:00 2001 From: Bruno Ais Date: Wed, 24 Jul 2013 12:45:23 +0100 Subject: [PATCH 2337/2494] [ticket/11638] Removed the unneeded reset. sub-task of ticket PHPBB3-11635: find and fix all bypasses of generate_text_for_* PHPBB3-11638 --- phpBB/viewtopic.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index 151176fc6f..64006fbe61 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -830,7 +830,7 @@ if (!empty($topic_data['poll_start'])) $parse_bbcode_flags = OPTION_FLAG_SMILIES; - if(empty($poll_info[0]['bbcode_bitfield'])) + if (empty($poll_info[0]['bbcode_bitfield'])) { $parse_bbcode_flags |= OPTION_FLAG_BBCODE; } @@ -841,8 +841,6 @@ if (!empty($topic_data['poll_start'])) } $topic_data['poll_title'] = generate_text_for_display($topic_data['poll_title'], $poll_info[0]['bbcode_uid'], $poll_info[0]['bbcode_bitfield'], $parse_bbcode_flags, true); - - unset($parse_bbcode_flags); foreach ($poll_info as $poll_option) { From 27126e065dd6a8de44c9da718b4b5b9895544bb1 Mon Sep 17 00:00:00 2001 From: Oliver Schramm Date: Wed, 24 Jul 2013 17:22:10 +0200 Subject: [PATCH 2338/2494] [ticket/11741] Fix empty brackets and remove bullet PHPBB3-11741 --- phpBB/styles/subsilver2/template/overall_header.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpBB/styles/subsilver2/template/overall_header.html b/phpBB/styles/subsilver2/template/overall_header.html index bc2307154b..b0d7ce6fab 100644 --- a/phpBB/styles/subsilver2/template/overall_header.html +++ b/phpBB/styles/subsilver2/template/overall_header.html @@ -154,8 +154,8 @@ function marklist(id, name, state) + + @@ -23,7 +25,33 @@ var text_name = 'signature'; // ]]> - + +
    - - [ {NOTIFICATIONS_COUNT} ] • + + [ {NOTIFICATIONS_COUNT}
    {L_NOTIFICATIONS} From 5af63a7860678ac55f84201cf7dbbdf82dcdc8e8 Mon Sep 17 00:00:00 2001 From: Oliver Schramm Date: Wed, 24 Jul 2013 18:15:03 +0200 Subject: [PATCH 2339/2494] [ticket/10917] Fixed notice that files are out of date when updating to an unreleased version PHPBB3-10917 --- phpBB/install/install_update.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php index c18a0fb4ec..5393040061 100644 --- a/phpBB/install/install_update.php +++ b/phpBB/install/install_update.php @@ -204,7 +204,7 @@ class install_update extends module } // Check if the update files stored are for the latest version... - if ($this->latest_version != $this->update_info['version']['to']) + if (version_compare(strtolower($this->latest_version), strtolower($this->update_info['version']['to']), '>')) { $this->unequal_version = true; From 98b385bc1c14a3155dd429f8d9118f4d7eb95556 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Wed, 24 Jul 2013 11:59:21 -0500 Subject: [PATCH 2340/2494] [ticket/11628] Remove style resource locator No longer used since Twig was implemented. PHPBB3-11628 --- phpBB/config/services.yml | 4 - phpBB/includes/bbcode.php | 3 +- phpBB/install/index.php | 3 +- phpBB/phpbb/style/resource_locator.php | 348 ------------------------- phpBB/phpbb/style/style.php | 45 +--- phpBB/phpbb/template/locator.php | 163 ------------ 6 files changed, 3 insertions(+), 563 deletions(-) delete mode 100644 phpBB/phpbb/style/resource_locator.php delete mode 100644 phpBB/phpbb/template/locator.php diff --git a/phpBB/config/services.yml b/phpBB/config/services.yml index 8abc413a5a..4902f4b6f6 100644 --- a/phpBB/config/services.yml +++ b/phpBB/config/services.yml @@ -258,13 +258,9 @@ services: - %core.php_ext% - @config - @user - - @style.resource_locator - @style.path_provider_ext - @template - style.resource_locator: - class: phpbb_style_resource_locator - style.path_provider_ext: class: phpbb_style_extension_path_provider arguments: diff --git a/phpBB/includes/bbcode.php b/phpBB/includes/bbcode.php index fd00728510..4ce6f17d90 100644 --- a/phpBB/includes/bbcode.php +++ b/phpBB/includes/bbcode.php @@ -132,10 +132,9 @@ class bbcode { $this->template_bitfield = new bitfield($user->style['bbcode_bitfield']); - $style_resource_locator = new phpbb_style_resource_locator(); $style_path_provider = new phpbb_style_extension_path_provider($phpbb_extension_manager, new phpbb_style_path_provider(), $phpbb_root_path); $template = new phpbb_template_twig($phpbb_root_path, $phpEx, $config, $user, new phpbb_template_context(), $phpbb_extension_manager); - $style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $style_resource_locator, $style_path_provider, $template); + $style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $style_path_provider, $template); $style->set_style(); $template->set_filenames(array('bbcode.html' => 'bbcode.html')); $this->template_filename = $template->get_source_file_for_handle('bbcode.html'); diff --git a/phpBB/install/index.php b/phpBB/install/index.php index 45e5777e36..f924b05547 100644 --- a/phpBB/install/index.php +++ b/phpBB/install/index.php @@ -212,10 +212,9 @@ $config = new phpbb_config(array( 'load_tplcompile' => '1' )); -$phpbb_style_resource_locator = new phpbb_style_resource_locator(); $phpbb_style_path_provider = new phpbb_style_path_provider(); $template = new phpbb_template_twig($phpbb_root_path, $phpEx, $config, $user, new phpbb_template_context()); -$phpbb_style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $phpbb_style_resource_locator, $phpbb_style_path_provider, $template); +$phpbb_style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $phpbb_style_path_provider, $template); $phpbb_style->set_ext_dir_prefix('adm/'); $phpbb_style->set_custom_style('admin', $phpbb_admin_path . 'style', array(), ''); $template->assign_var('T_ASSETS_PATH', '../assets'); diff --git a/phpBB/phpbb/style/resource_locator.php b/phpBB/phpbb/style/resource_locator.php deleted file mode 100644 index 4cf767c062..0000000000 --- a/phpBB/phpbb/style/resource_locator.php +++ /dev/null @@ -1,348 +0,0 @@ -set_default_template_path(); - } - - /** - * Sets the list of style paths - * - * These paths will be searched for style files in the provided order. - * Paths may be outside of phpBB, but templates loaded from these paths - * will still be cached. - * - * @param array $style_paths An array of paths to style directories - * @return null - */ - public function set_paths($style_paths) - { - $this->roots = array(); - $this->files = array(); - $this->filenames = array(); - - foreach ($style_paths as $key => $paths) - { - foreach ($paths as $path) - { - // Make sure $path has no ending slash - if (substr($path, -1) === '/') - { - $path = substr($path, 0, -1); - } - $this->roots[$key][] = $path; - } - } - } - - /** - * Sets the location of templates directory within style directories. - * - * The location must be a relative path, with a trailing slash. - * Typically it is one directory level deep, e.g. "template/". - * - * @param string $template_path Relative path to templates directory within style directories - * @return null - */ - public function set_template_path($template_path) - { - $this->template_path = $template_path; - } - - /** - * Sets the location of templates directory within style directories - * to the default, which is "template/". - * - * @return null - */ - public function set_default_template_path() - { - $this->template_path = 'template/'; - } - - /** - * {@inheritDoc} - */ - public function set_filenames(array $filename_array) - { - foreach ($filename_array as $handle => $filename) - { - if (empty($filename)) - { - trigger_error("style resource locator: set_filenames: Empty filename specified for $handle", E_USER_ERROR); - } - - $this->filename[$handle] = $filename; - - foreach ($this->roots as $root_key => $root_paths) - { - foreach ($root_paths as $root_index => $root) - { - $this->files[$root_key][$root_index][$handle] = $root . '/' . $this->template_path . $filename; - } - } - } - } - - /** - * {@inheritDoc} - */ - public function get_filename_for_handle($handle) - { - if (!isset($this->filename[$handle])) - { - trigger_error("style resource locator: get_filename_for_handle: No file specified for handle $handle", E_USER_ERROR); - } - return $this->filename[$handle]; - } - - /** - * {@inheritDoc} - */ - public function get_virtual_source_file_for_handle($handle) - { - // If we don't have a file assigned to this handle, die. - if (!isset($this->files['style'][0][$handle])) - { - trigger_error("style resource locator: No file specified for handle $handle", E_USER_ERROR); - } - - $source_file = $this->files['style'][0][$handle]; - return $source_file; - } - - /** - * {@inheritDoc} - */ - public function get_source_file_for_handle($handle, $find_all = false) - { - // If we don't have a file assigned to this handle, die. - if (!isset($this->files['style'][0][$handle])) - { - trigger_error("style resource locator: No file specified for handle $handle", E_USER_ERROR); - } - - // locate a source file that exists - $source_file = $this->files['style'][0][$handle]; - $tried = $source_file; - $found = false; - $found_all = array(); - foreach ($this->roots as $root_key => $root_paths) - { - foreach ($root_paths as $root_index => $root) - { - $source_file = $this->files[$root_key][$root_index][$handle]; - $tried .= ', ' . $source_file; - if (file_exists($source_file)) - { - $found = true; - break; - } - } - if ($found) - { - if ($find_all) - { - $found_all[] = $source_file; - $found = false; - } - else - { - break; - } - } - } - - // search failed - if (!$found && !$find_all) - { - trigger_error("style resource locator: File for handle $handle does not exist. Could not find: $tried", E_USER_ERROR); - } - - return ($find_all) ? $found_all : $source_file; - } - - /** - * {@inheritDoc} - */ - public function get_first_file_location($files, $return_default = false, $return_full_path = true) - { - // set default value - $default_result = false; - - // check all available paths - foreach ($this->roots as $root_paths) - { - foreach ($root_paths as $path) - { - // check all files - foreach ($files as $filename) - { - $source_file = $path . '/' . $filename; - if (file_exists($source_file)) - { - return ($return_full_path) ? $source_file : $filename; - } - - // assign first file as result if $return_default is true - if ($return_default && $default_result === false) - { - $default_result = $source_file; - } - } - } - } - - // search failed - return $default_result; - } - - /** - * Obtains filesystem path for a template file. - * - * The simplest use is specifying a single template file as a string - * in the first argument. This template file should be a basename - * of a template file in the selected style, or its parent styles - * if template inheritance is being utilized. - * - * Note: "selected style" is whatever style the style resource locator - * is configured for. - * - * The return value then will be a path, relative to the current - * directory or absolute, to the template file in the selected style - * or its closest parent. - * - * If the selected style does not have the template file being searched, - * (and if inheritance is involved, none of the parents have it either), - * false will be returned. - * - * Specifying true for $return_default will cause the function to - * return the first path which was checked for existence in the event - * that the template file was not found, instead of false. - * This is the path in the selected style itself, not any of its - * parents. - * - * $files can be given an array of templates instead of a single - * template. When given an array, the function will try to resolve - * each template in the array to a path, and will return the first - * path that exists, or false if none exist. - * - * If $files is an array and template inheritance is involved, first - * each of the files will be checked in the selected style, then each - * of the files will be checked in the immediate parent, and so on. - * - * If $return_full_path is false, then instead of returning a usable - * path (when the template is found) only the template's basename - * will be returned. This can be used to check which of the templates - * specified in $files exists. Naturally more than one template must - * be given in $files. - * - * This function works identically to get_first_file_location except - * it operates on a list of templates, not files. Practically speaking, - * the templates given in the first argument first are prepended with - * the template path (property in this class), then given to - * get_first_file_location for the rest of the processing. - * - * Templates given to this function can be relative paths for templates - * located in subdirectories of the template directories. The paths - * should be relative to the templates directory (template/ by default). - * - * @param string or array $files List of templates to locate. If there is only - * one template, $files can be a string to make code easier to read. - * @param bool $return_default Determines what to return if template does not - * exist. If true, function will return location where template is - * supposed to be. If false, function will return false. - * @param bool $return_full_path If true, function will return full path - * to template. If false, function will return template file name. - * This parameter can be used to check which one of set of template - * files is available. - * @return string or boolean Source template path if template exists or $return_default is - * true. False if template does not exist and $return_default is false - */ - public function get_first_template_location($templates, $return_default = false, $return_full_path = true) - { - // add template path prefix - $files = array(); - if (is_string($templates)) - { - $files[] = $this->template_path . $templates; - } - else - { - foreach ($templates as $template) - { - $files[] = $this->template_path . $template; - } - } - - return $this->get_first_file_location($files, $return_default, $return_full_path); - } -} diff --git a/phpBB/phpbb/style/style.php b/phpBB/phpbb/style/style.php index 034f518091..9756fb74ac 100644 --- a/phpBB/phpbb/style/style.php +++ b/phpBB/phpbb/style/style.php @@ -52,12 +52,6 @@ class phpbb_style */ private $user; - /** - * Style resource locator - * @var phpbb_style_resource_locator - */ - private $locator; - /** * Style path provider * @var phpbb_style_path_provider @@ -69,17 +63,15 @@ class phpbb_style * * @param string $phpbb_root_path phpBB root path * @param user $user current user - * @param phpbb_style_resource_locator $locator style resource locator * @param phpbb_style_path_provider $provider style path provider * @param phpbb_template $template template */ - public function __construct($phpbb_root_path, $php_ext, $config, $user, phpbb_style_resource_locator $locator, phpbb_style_path_provider_interface $provider, phpbb_template $template) + public function __construct($phpbb_root_path, $php_ext, $config, $user, phpbb_style_path_provider_interface $provider, phpbb_template $template) { $this->phpbb_root_path = $phpbb_root_path; $this->php_ext = $php_ext; $this->config = $config; $this->user = $user; - $this->locator = $locator; $this->provider = $provider; $this->template = $template; } @@ -130,7 +122,6 @@ class phpbb_style } $this->provider->set_styles($paths); - $this->locator->set_paths($this->provider); $new_paths = array(); foreach ($paths as $path) @@ -168,12 +159,6 @@ class phpbb_style $this->names = $names; $this->provider->set_styles($paths); - $this->locator->set_paths($this->provider); - - if ($template_path !== false) - { - $this->locator->set_template_path($template_path); - } $new_paths = array(); foreach ($paths as $path) @@ -210,32 +195,4 @@ class phpbb_style { $this->provider->set_ext_dir_prefix($ext_dir_prefix); } - - /** - * Locates source file path, accounting for styles tree and verifying that - * the path exists. - * - * @param string or array $files List of files to locate. If there is only - * one file, $files can be a string to make code easier to read. - * @param bool $return_default Determines what to return if file does not - * exist. If true, function will return location where file is - * supposed to be. If false, function will return false. - * @param bool $return_full_path If true, function will return full path - * to file. If false, function will return file name. This - * parameter can be used to check which one of set of files - * is available. - * @return string or boolean Source file path if file exists or $return_default is - * true. False if file does not exist and $return_default is false - */ - public function locate($files, $return_default = false, $return_full_path = true) - { - // convert string to array - if (is_string($files)) - { - $files = array($files); - } - - // use resource locator to find files - return $this->locator->get_first_file_location($files, $return_default, $return_full_path); - } } diff --git a/phpBB/phpbb/template/locator.php b/phpBB/phpbb/template/locator.php deleted file mode 100644 index f6fd20bcc2..0000000000 --- a/phpBB/phpbb/template/locator.php +++ /dev/null @@ -1,163 +0,0 @@ - filename pairs. - * - * @param array $filename_array Should be a hash of handle => filename pairs. - */ - public function set_filenames(array $filename_array); - - /** - * Determines the filename for a template handle. - * - * The filename comes from array used in a set_filenames call, - * which should have been performed prior to invoking this function. - * Return value is a file basename (without path). - * - * @param $handle string Template handle - * @return string Filename corresponding to the template handle - */ - public function get_filename_for_handle($handle); - - /** - * Determines the source file path for a template handle without - * regard for styles tree. - * - * This function returns the path in "primary" style directory - * corresponding to the given template handle. That path may or - * may not actually exist on the filesystem. Because this function - * does not perform stat calls to determine whether the path it - * returns actually exists, it is faster than get_source_file_for_handle. - * - * Use get_source_file_for_handle to obtain the actual path that is - * guaranteed to exist (which might come from the parent style - * directory if primary style has parent styles). - * - * This function will trigger an error if the handle was never - * associated with a template file via set_filenames. - * - * @param $handle string Template handle - * @return string Path to source file path in primary style directory - */ - public function get_virtual_source_file_for_handle($handle); - - /** - * Determines the source file path for a template handle, accounting - * for styles tree and verifying that the path exists. - * - * This function returns the actual path that may be compiled for - * the specified template handle. It will trigger an error if - * the template handle was never associated with a template path - * via set_filenames or if the template file does not exist on the - * filesystem. - * - * Use get_virtual_source_file_for_handle to just resolve a template - * handle to a path without any filesystem or styles tree checks. - * - * @param string $handle Template handle (i.e. "friendly" template name) - * @param bool $find_all If true, each root path will be checked and function - * will return array of files instead of string and will not - * trigger a error if template does not exist - * @return string Source file path - */ - public function get_source_file_for_handle($handle, $find_all = false); - - /** - * Obtains a complete filesystem path for a file in a style. - * - * This function traverses the style tree (selected style and - * its parents in order, if inheritance is being used) and finds - * the first file on the filesystem matching specified relative path, - * or the first of the specified paths if more than one path is given. - * - * This function can be used to determine filesystem path of any - * file under any style, with the consequence being that complete - * relative to the style directory path must be provided as an argument. - * - * In particular, this function can be used to locate templates - * and javascript files. - * - * For locating templates get_first_template_location should be used - * as it prepends the configured template path to the template basename. - * - * Note: "selected style" is whatever style the style resource locator - * is configured for. - * - * The return value then will be a path, relative to the current - * directory or absolute, to the first existing file in the selected - * style or its closest parent. - * - * If the selected style does not have the file being searched, - * (and if inheritance is involved, none of the parents have it either), - * false will be returned. - * - * Multiple files can be specified, in which case the first file in - * the list that can be found on the filesystem is returned. - * - * If multiple files are specified and inheritance is involved, - * first each of the specified files is checked in the selected style, - * then each of the specified files is checked in the immediate parent, - * etc. - * - * Specifying true for $return_default will cause the function to - * return the first path which was checked for existence in the event - * that the template file was not found, instead of false. - * This is always a path in the selected style itself, not any of its - * parents. - * - * If $return_full_path is false, then instead of returning a usable - * path (when the file is found) the file's path relative to the style - * directory will be returned. This is the same path as was given to - * the function as a parameter. This can be used to check which of the - * files specified in $files exists. Naturally this requires passing - * more than one file in $files. - * - * @param array $files List of files to locate. - * @param bool $return_default Determines what to return if file does not - * exist. If true, function will return location where file is - * supposed to be. If false, function will return false. - * @param bool $return_full_path If true, function will return full path - * to file. If false, function will return file name. This - * parameter can be used to check which one of set of files - * is available. - * @return string or boolean Source file path if file exists or $return_default is - * true. False if file does not exist and $return_default is false - */ - public function get_first_file_location($files, $return_default = false, $return_full_path = true); -} From 44a82dd0837a4693b6a4a410c21c438f244094d3 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Wed, 24 Jul 2013 12:05:04 -0500 Subject: [PATCH 2341/2494] [ticket/11628] Remove style path provider No longer used since Twig was implemented. PHPBB3-11628 --- phpBB/config/services.yml | 11 -- phpBB/includes/bbcode.php | 3 +- phpBB/install/index.php | 4 +- phpBB/phpbb/style/extension_path_provider.php | 137 ------------------ phpBB/phpbb/style/path_provider.php | 62 -------- phpBB/phpbb/style/path_provider_interface.php | 42 ------ phpBB/phpbb/style/style.php | 25 +--- tests/controller/helper_url_test.php | 5 +- tests/extension/style_path_provider_test.php | 50 ------- tests/template/template_events_test.php | 4 +- tests/template/template_test_case.php | 6 +- .../template/template_test_case_with_tree.php | 4 +- 12 files changed, 7 insertions(+), 346 deletions(-) delete mode 100644 phpBB/phpbb/style/extension_path_provider.php delete mode 100644 phpBB/phpbb/style/path_provider.php delete mode 100644 phpBB/phpbb/style/path_provider_interface.php delete mode 100644 tests/extension/style_path_provider_test.php diff --git a/phpBB/config/services.yml b/phpBB/config/services.yml index 4902f4b6f6..7acc44f24d 100644 --- a/phpBB/config/services.yml +++ b/phpBB/config/services.yml @@ -258,19 +258,8 @@ services: - %core.php_ext% - @config - @user - - @style.path_provider_ext - @template - style.path_provider_ext: - class: phpbb_style_extension_path_provider - arguments: - - @ext.manager - - @style.path_provider - - %core.root_path% - - style.path_provider: - class: phpbb_style_path_provider - template: class: phpbb_template_twig arguments: diff --git a/phpBB/includes/bbcode.php b/phpBB/includes/bbcode.php index 4ce6f17d90..9b1939030a 100644 --- a/phpBB/includes/bbcode.php +++ b/phpBB/includes/bbcode.php @@ -132,9 +132,8 @@ class bbcode { $this->template_bitfield = new bitfield($user->style['bbcode_bitfield']); - $style_path_provider = new phpbb_style_extension_path_provider($phpbb_extension_manager, new phpbb_style_path_provider(), $phpbb_root_path); $template = new phpbb_template_twig($phpbb_root_path, $phpEx, $config, $user, new phpbb_template_context(), $phpbb_extension_manager); - $style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $style_path_provider, $template); + $style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $template); $style->set_style(); $template->set_filenames(array('bbcode.html' => 'bbcode.html')); $this->template_filename = $template->get_source_file_for_handle('bbcode.html'); diff --git a/phpBB/install/index.php b/phpBB/install/index.php index f924b05547..46660723ba 100644 --- a/phpBB/install/index.php +++ b/phpBB/install/index.php @@ -212,10 +212,8 @@ $config = new phpbb_config(array( 'load_tplcompile' => '1' )); -$phpbb_style_path_provider = new phpbb_style_path_provider(); $template = new phpbb_template_twig($phpbb_root_path, $phpEx, $config, $user, new phpbb_template_context()); -$phpbb_style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $phpbb_style_path_provider, $template); -$phpbb_style->set_ext_dir_prefix('adm/'); +$phpbb_style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $template); $phpbb_style->set_custom_style('admin', $phpbb_admin_path . 'style', array(), ''); $template->assign_var('T_ASSETS_PATH', '../assets'); $template->assign_var('T_TEMPLATE_PATH', $phpbb_admin_path . 'style'); diff --git a/phpBB/phpbb/style/extension_path_provider.php b/phpBB/phpbb/style/extension_path_provider.php deleted file mode 100644 index ec1d85f821..0000000000 --- a/phpBB/phpbb/style/extension_path_provider.php +++ /dev/null @@ -1,137 +0,0 @@ -base_path_provider = $base_path_provider; - $this->phpbb_root_path = $phpbb_root_path; - } - - /** - * Sets a prefix for style paths searched within extensions. - * - * The prefix is inserted between the extension's path e.g. ext/foo/ and - * the looked up style path, e.g. styles/bar/. So it should not have a - * leading slash, but should have a trailing slash. - * - * @param string $ext_dir_prefix The prefix including trailing slash - * @return null - */ - public function set_ext_dir_prefix($ext_dir_prefix) - { - $this->ext_dir_prefix = $ext_dir_prefix; - } - - /** - * Finds style paths using the extension manager - * - * Locates a path (e.g. styles/prosilver/) in all active extensions. - * Then appends the core style paths based in the current working - * directory. - * - * @return array List of style paths - */ - public function find() - { - $directories = array(); - - $finder = $this->extension_manager->get_finder(); - foreach ($this->base_path_provider as $key => $paths) - { - if ($key == 'style') - { - foreach ($paths as $path) - { - $directories['style'][] = $path; - if ($path && !phpbb_is_absolute($path)) - { - // Remove phpBB root path from the style path, - // so the finder is able to find extension styles, - // when the root path is not ./ - if (strpos($path, $this->phpbb_root_path) === 0) - { - $path = substr($path, strlen($this->phpbb_root_path)); - } - - $result = $finder->directory('/' . $this->ext_dir_prefix . $path) - ->get_directories(true, false, true); - foreach ($result as $ext => $ext_path) - { - // Make sure $ext_path has no ending slash - if (substr($ext_path, -1) === '/') - { - $ext_path = substr($ext_path, 0, -1); - } - $directories[$ext][] = $ext_path; - } - } - } - } - } - - return $directories; - } - - /** - * Overwrites the current style paths - * - * @param array $styles An array of style paths. The first element is the main style. - * @return null - */ - public function set_styles(array $styles) - { - $this->base_path_provider->set_styles($styles); - $this->items = null; - } -} diff --git a/phpBB/phpbb/style/path_provider.php b/phpBB/phpbb/style/path_provider.php deleted file mode 100644 index 731d682e88..0000000000 --- a/phpBB/phpbb/style/path_provider.php +++ /dev/null @@ -1,62 +0,0 @@ -paths = array('style' => $styles); - } - - /** - * Retrieve an iterator over all style paths - * - * @return ArrayIterator An iterator for the array of style paths - */ - public function getIterator() - { - return new ArrayIterator($this->paths); - } -} diff --git a/phpBB/phpbb/style/path_provider_interface.php b/phpBB/phpbb/style/path_provider_interface.php deleted file mode 100644 index 1a6153a4d3..0000000000 --- a/phpBB/phpbb/style/path_provider_interface.php +++ /dev/null @@ -1,42 +0,0 @@ -phpbb_root_path = $phpbb_root_path; $this->php_ext = $php_ext; $this->config = $config; $this->user = $user; - $this->provider = $provider; $this->template = $template; } @@ -121,8 +113,6 @@ class phpbb_style } } - $this->provider->set_styles($paths); - $new_paths = array(); foreach ($paths as $path) { @@ -158,8 +148,6 @@ class phpbb_style } $this->names = $names; - $this->provider->set_styles($paths); - $new_paths = array(); foreach ($paths as $path) { @@ -184,15 +172,4 @@ class phpbb_style { return $this->phpbb_root_path . trim($style_base_directory, '/') . '/' . $path; } - - /** - * Defines a prefix to use for style paths in extensions - * - * @param string $ext_dir_prefix The prefix including trailing slash - * @return null - */ - public function set_ext_dir_prefix($ext_dir_prefix) - { - $this->provider->set_ext_dir_prefix($ext_dir_prefix); - } } diff --git a/tests/controller/helper_url_test.php b/tests/controller/helper_url_test.php index 6686b77e8f..29399af77a 100644 --- a/tests/controller/helper_url_test.php +++ b/tests/controller/helper_url_test.php @@ -48,12 +48,9 @@ class phpbb_controller_helper_url_test extends phpbb_test_case global $phpbb_dispatcher, $phpbb_root_path, $phpEx; $phpbb_dispatcher = new phpbb_mock_event_dispatcher; - $this->style_resource_locator = new phpbb_style_resource_locator(); $this->user = $this->getMock('phpbb_user'); $this->template = new phpbb_template_twig($phpbb_root_path, $phpEx, $config, $this->user, new phpbb_template_context()); - $this->style_resource_locator = new phpbb_style_resource_locator(); - $this->style_provider = new phpbb_style_path_provider(); - $this->style = new phpbb_style($phpbb_root_path, $phpEx, new phpbb_config(array()), $this->user, $this->style_resource_locator, $this->style_provider, $this->template); + $this->style = new phpbb_style($phpbb_root_path, $phpEx, new phpbb_config(array()), $this->user, $this->template); $helper = new phpbb_controller_helper($this->template, $this->user, '', 'php'); $this->assertEquals($helper->url($route, $params, $is_amp, $session_id), $expected); diff --git a/tests/extension/style_path_provider_test.php b/tests/extension/style_path_provider_test.php deleted file mode 100644 index e1021c20ac..0000000000 --- a/tests/extension/style_path_provider_test.php +++ /dev/null @@ -1,50 +0,0 @@ -relative_root_path = './'; - $this->root_path = dirname(__FILE__) . '/'; - } - - public function test_find() - { - $phpbb_style_path_provider = new phpbb_style_path_provider(); - $phpbb_style_path_provider->set_styles(array($this->relative_root_path . 'styles/prosilver')); - $phpbb_style_extension_path_provider = new phpbb_style_extension_path_provider(new phpbb_mock_extension_manager( - $this->root_path, - array( - 'foo' => array( - 'ext_name' => 'foo', - 'ext_active' => '1', - 'ext_path' => 'ext/foo/', - ), - 'bar' => array( - 'ext_name' => 'bar', - 'ext_active' => '1', - 'ext_path' => 'ext/bar/', - ), - )), $phpbb_style_path_provider, $this->relative_root_path); - - $this->assertEquals(array( - 'style' => array( - $this->relative_root_path . 'styles/prosilver', - ), - 'bar' => array( - $this->root_path . 'ext/bar/styles/prosilver', - ), - ), $phpbb_style_extension_path_provider->find()); - } -} diff --git a/tests/template/template_events_test.php b/tests/template/template_events_test.php index f7bcd2dcc6..c3ebcb8739 100644 --- a/tests/template/template_events_test.php +++ b/tests/template/template_events_test.php @@ -103,13 +103,11 @@ Zeta test event in all', $config = new phpbb_config(array_merge($defaults, $new_config)); $this->template_path = dirname(__FILE__) . "/datasets/$dataset/styles/silver/template"; - $this->style_resource_locator = new phpbb_style_resource_locator(); $this->extension_manager = new phpbb_mock_filesystem_extension_manager( dirname(__FILE__) . "/datasets/$dataset/" ); $this->template = new phpbb_template_twig($phpbb_root_path, $phpEx, $config, $user, new phpbb_template_context, $this->extension_manager); - $this->style_provider = new phpbb_style_path_provider(); - $this->style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $this->style_resource_locator, $this->style_provider, $this->template); + $this->style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $this->template); $this->style->set_custom_style('silver', array($this->template_path), $style_names, ''); } } diff --git a/tests/template/template_test_case.php b/tests/template/template_test_case.php index 6d87e5ebc0..87573a53fe 100644 --- a/tests/template/template_test_case.php +++ b/tests/template/template_test_case.php @@ -14,8 +14,6 @@ class phpbb_template_template_test_case extends phpbb_test_case protected $style; protected $template; protected $template_path; - protected $style_resource_locator; - protected $style_provider; protected $user; protected $test_path = 'tests/template'; @@ -67,10 +65,8 @@ class phpbb_template_template_test_case extends phpbb_test_case $this->user = new phpbb_user; $this->template_path = $this->test_path . '/templates'; - $this->style_resource_locator = new phpbb_style_resource_locator(); - $this->style_provider = new phpbb_style_path_provider(); $this->template = new phpbb_template_twig($phpbb_root_path, $phpEx, $config, $this->user, new phpbb_template_context()); - $this->style = new phpbb_style($phpbb_root_path, $phpEx, $config, $this->user, $this->style_resource_locator, $this->style_provider, $this->template); + $this->style = new phpbb_style($phpbb_root_path, $phpEx, $config, $this->user, $this->template); $this->style->set_custom_style('tests', $this->template_path, array(), ''); } diff --git a/tests/template/template_test_case_with_tree.php b/tests/template/template_test_case_with_tree.php index 4b8cbada45..50a6e9190d 100644 --- a/tests/template/template_test_case_with_tree.php +++ b/tests/template/template_test_case_with_tree.php @@ -20,10 +20,8 @@ class phpbb_template_template_test_case_with_tree extends phpbb_template_templat $this->template_path = $this->test_path . '/templates'; $this->parent_template_path = $this->test_path . '/parent_templates'; - $this->style_resource_locator = new phpbb_style_resource_locator(); - $this->style_provider = new phpbb_style_path_provider(); $this->template = new phpbb_template_twig($phpbb_root_path, $phpEx, $config, $user, new phpbb_template_context()); - $this->style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $this->style_resource_locator, $this->style_provider, $this->template); + $this->style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $this->template); $this->style->set_custom_style('tests', array($this->template_path, $this->parent_template_path), array(), ''); } } From e80503696350d7410e82e63e9d108d65e3c35696 Mon Sep 17 00:00:00 2001 From: Oliver Schramm Date: Wed, 24 Jul 2013 19:08:49 +0200 Subject: [PATCH 2342/2494] [ticket/10917] Using phpbb wrapper PHPBB3-10917 --- phpBB/install/install_update.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php index 5393040061..5419e3edf1 100644 --- a/phpBB/install/install_update.php +++ b/phpBB/install/install_update.php @@ -204,7 +204,7 @@ class install_update extends module } // Check if the update files stored are for the latest version... - if (version_compare(strtolower($this->latest_version), strtolower($this->update_info['version']['to']), '>')) + if (phpbb_version_compare($this->latest_version, $this->update_info['version']['to'], '>')) { $this->unequal_version = true; From 5d1afb453211d42a8deacb66684c136385918192 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Wed, 24 Jul 2013 12:24:35 -0500 Subject: [PATCH 2343/2494] [ticket/11628] Remove phpbb_style (move methods to phpbb_template) PHPBB3-11628 --- phpBB/adm/index.php | 2 +- phpBB/adm/swatch.php | 2 +- phpBB/common.php | 1 - phpBB/config/services.yml | 11 +- phpBB/includes/bbcode.php | 3 +- phpBB/includes/functions_module.php | 6 +- phpBB/install/index.php | 3 +- phpBB/install/install_update.php | 4 +- phpBB/phpbb/controller/resolver.php | 16 +- phpBB/phpbb/style/style.php | 175 ------------------ phpBB/phpbb/template/template.php | 30 +++ phpBB/phpbb/template/twig/twig.php | 107 ++++++++++- phpBB/phpbb/user.php | 4 +- tests/controller/helper_url_test.php | 1 - tests/template/includephp_test.php | 2 +- tests/template/template_events_test.php | 3 +- tests/template/template_test.php | 2 +- tests/template/template_test_case.php | 4 +- .../template/template_test_case_with_tree.php | 3 +- 19 files changed, 161 insertions(+), 218 deletions(-) delete mode 100644 phpBB/phpbb/style/style.php diff --git a/phpBB/adm/index.php b/phpBB/adm/index.php index 8cd1967c75..3f29072899 100644 --- a/phpBB/adm/index.php +++ b/phpBB/adm/index.php @@ -50,7 +50,7 @@ $module_id = request_var('i', ''); $mode = request_var('mode', ''); // Set custom style for admin area -$phpbb_style->set_custom_style('admin', $phpbb_admin_path . 'style', array(), ''); +$template->set_custom_style('admin', $phpbb_admin_path . 'style', array(), ''); $template->assign_var('T_ASSETS_PATH', $phpbb_root_path . 'assets'); $template->assign_var('T_TEMPLATE_PATH', $phpbb_admin_path . 'style'); diff --git a/phpBB/adm/swatch.php b/phpBB/adm/swatch.php index 3ae38d0d8b..70441ffeed 100644 --- a/phpBB/adm/swatch.php +++ b/phpBB/adm/swatch.php @@ -22,7 +22,7 @@ $auth->acl($user->data); $user->setup(); // Set custom template for admin area -$phpbb_style->set_custom_style('admin', $phpbb_admin_path . 'style', array(), ''); +$template->set_custom_style('admin', $phpbb_admin_path . 'style', array(), ''); $template->set_filenames(array( 'body' => 'colour_swatch.html') diff --git a/phpBB/common.php b/phpBB/common.php index 962a1f951f..6a1f307d64 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -121,7 +121,6 @@ $phpbb_extension_manager = $phpbb_container->get('ext.manager'); $phpbb_subscriber_loader = $phpbb_container->get('event.subscriber_loader'); $template = $phpbb_container->get('template'); -$phpbb_style = $phpbb_container->get('style'); // Add own hook handler require($phpbb_root_path . 'includes/hooks/index.' . $phpEx); diff --git a/phpBB/config/services.yml b/phpBB/config/services.yml index 7acc44f24d..d0753322da 100644 --- a/phpBB/config/services.yml +++ b/phpBB/config/services.yml @@ -98,7 +98,7 @@ services: arguments: - @user - @service_container - - @style + - @template cron.task_collection: class: phpbb_di_service_collection @@ -251,15 +251,6 @@ services: request: class: phpbb_request - style: - class: phpbb_style - arguments: - - %core.root_path% - - %core.php_ext% - - @config - - @user - - @template - template: class: phpbb_template_twig arguments: diff --git a/phpBB/includes/bbcode.php b/phpBB/includes/bbcode.php index 9b1939030a..2fa6a8b099 100644 --- a/phpBB/includes/bbcode.php +++ b/phpBB/includes/bbcode.php @@ -133,8 +133,7 @@ class bbcode $this->template_bitfield = new bitfield($user->style['bbcode_bitfield']); $template = new phpbb_template_twig($phpbb_root_path, $phpEx, $config, $user, new phpbb_template_context(), $phpbb_extension_manager); - $style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $template); - $style->set_style(); + $template->set_style(); $template->set_filenames(array('bbcode.html' => 'bbcode.html')); $this->template_filename = $template->get_source_file_for_handle('bbcode.html'); } diff --git a/phpBB/includes/functions_module.php b/phpBB/includes/functions_module.php index 99c24fcb19..a5ece1ecac 100644 --- a/phpBB/includes/functions_module.php +++ b/phpBB/includes/functions_module.php @@ -455,7 +455,7 @@ class p_master */ function load_active($mode = false, $module_url = false, $execute_module = true) { - global $phpbb_root_path, $phpbb_admin_path, $phpEx, $user, $phpbb_style; + global $phpbb_root_path, $phpbb_admin_path, $phpEx, $user, $template; $module_path = $this->include_path . $this->p_class; $icat = request_var('icat', ''); @@ -508,7 +508,7 @@ class p_master if (is_dir($module_style_dir)) { - $phpbb_style->set_custom_style('admin', array($module_style_dir, $phpbb_admin_path . 'style'), array(), ''); + $template->set_custom_style('admin', array($module_style_dir, $phpbb_admin_path . 'style'), array(), ''); } } @@ -537,7 +537,7 @@ class p_master if (is_dir($phpbb_root_path . $module_style_dir)) { - $phpbb_style->set_style(array($module_style_dir, 'styles')); + $template->set_style(array($module_style_dir, 'styles')); } } diff --git a/phpBB/install/index.php b/phpBB/install/index.php index 46660723ba..fd0d8a2d48 100644 --- a/phpBB/install/index.php +++ b/phpBB/install/index.php @@ -213,8 +213,7 @@ $config = new phpbb_config(array( )); $template = new phpbb_template_twig($phpbb_root_path, $phpEx, $config, $user, new phpbb_template_context()); -$phpbb_style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $template); -$phpbb_style->set_custom_style('admin', $phpbb_admin_path . 'style', array(), ''); +$template->set_custom_style('admin', $phpbb_admin_path . 'style', array(), ''); $template->assign_var('T_ASSETS_PATH', '../assets'); $template->assign_var('T_TEMPLATE_PATH', $phpbb_admin_path . 'style'); diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php index df9b6c1c7e..51fbd1975c 100644 --- a/phpBB/install/install_update.php +++ b/phpBB/install/install_update.php @@ -71,7 +71,7 @@ class install_update extends module function main($mode, $sub) { - global $phpbb_style, $template, $phpEx, $phpbb_root_path, $user, $db, $config, $cache, $auth, $language; + global $template, $phpEx, $phpbb_root_path, $user, $db, $config, $cache, $auth, $language; global $request, $phpbb_admin_path, $phpbb_adm_relative_path, $phpbb_container; // Create a normal container now @@ -138,7 +138,7 @@ class install_update extends module } // Set custom template again. ;) - $phpbb_style->set_custom_style('admin', $phpbb_admin_path . 'style', array(), ''); + $template->set_custom_style('admin', $phpbb_admin_path . 'style', array(), ''); $template->assign_vars(array( 'S_USER_LANG' => $user->lang['USER_LANG'], diff --git a/phpBB/phpbb/controller/resolver.php b/phpBB/phpbb/controller/resolver.php index 95dfc8da8e..850df84a0f 100644 --- a/phpBB/phpbb/controller/resolver.php +++ b/phpBB/phpbb/controller/resolver.php @@ -38,23 +38,23 @@ class phpbb_controller_resolver implements ControllerResolverInterface protected $container; /** - * phpbb_style object - * @var phpbb_style + * phpbb_template object + * @var phpbb_template */ - protected $style; + protected $template; /** * Construct method * * @param phpbb_user $user User Object * @param ContainerInterface $container ContainerInterface object - * @param phpbb_style $style + * @param phpbb_template_interface $template */ - public function __construct(phpbb_user $user, ContainerInterface $container, phpbb_style $style = null) + public function __construct(phpbb_user $user, ContainerInterface $container, phpbb_template $template = null) { $this->user = $user; $this->container = $container; - $this->style = $style; + $this->template = $template; } /** @@ -96,13 +96,13 @@ class phpbb_controller_resolver implements ControllerResolverInterface $controller_dir = explode('_', get_class($controller_object)); // 0 phpbb, 1 ext, 2 vendor, 3 extension name, ... - if (!is_null($this->style) && isset($controller_dir[3]) && $controller_dir[1] === 'ext') + if (!is_null($this->template) && isset($controller_dir[3]) && $controller_dir[1] === 'ext') { $controller_style_dir = 'ext/' . $controller_dir[2] . '/' . $controller_dir[3] . '/styles'; if (is_dir($controller_style_dir)) { - $this->style->set_style(array($controller_style_dir, 'styles')); + $this->template->set_style(array($controller_style_dir, 'styles')); } } diff --git a/phpBB/phpbb/style/style.php b/phpBB/phpbb/style/style.php deleted file mode 100644 index 283e3015ca..0000000000 --- a/phpBB/phpbb/style/style.php +++ /dev/null @@ -1,175 +0,0 @@ -phpbb_root_path = $phpbb_root_path; - $this->php_ext = $php_ext; - $this->config = $config; - $this->user = $user; - $this->template = $template; - } - - /** - * Get the style tree of the style preferred by the current user - * - * @return array Style tree, most specific first - */ - public function get_user_style() - { - $style_list = array( - $this->user->style['style_path'], - ); - - if ($this->user->style['style_parent_id']) - { - $style_list = array_merge($style_list, array_reverse(explode('/', $this->user->style['style_parent_tree']))); - } - - return $style_list; - } - - /** - * Set style location based on (current) user's chosen style. - * - * @param array $style_directories The directories to add style paths for - * E.g. array('ext/foo/bar/styles', 'styles') - * Default: array('styles') (phpBB's style directory) - * @return bool true - */ - public function set_style($style_directories = array('styles')) - { - $this->names = $this->get_user_style(); - - $paths = array(); - foreach ($style_directories as $directory) - { - foreach ($this->names as $name) - { - $path = $this->get_style_path($name, $directory); - - if (is_dir($path)) - { - $paths[] = $path; - } - } - } - - $new_paths = array(); - foreach ($paths as $path) - { - $new_paths[] = $path . '/template/'; - } - - $this->template->set_style_names($this->names, $new_paths, ($style_directories === array('styles'))); - - return true; - } - - /** - * Set custom style location (able to use directory outside of phpBB). - * - * Note: Templates are still compiled to phpBB's cache directory. - * - * @param string $name Name of style, used for cache prefix. Examples: "admin", "prosilver" - * @param array or string $paths Array of style paths, relative to current root directory - * @param array $names Array of names of templates in inheritance tree order, used by extensions. If empty, $name will be used. - * @param string $template_path Path to templates, relative to style directory. False if path should be set to default (templates/). - * @return bool true - */ - public function set_custom_style($name, $paths, $names = array(), $template_path = false) - { - if (is_string($paths)) - { - $paths = array($paths); - } - - if (empty($names)) - { - $names = array($name); - } - $this->names = $names; - - $new_paths = array(); - foreach ($paths as $path) - { - $new_paths[] = $path . '/' . (($template_path !== false) ? $template_path : 'template/'); - } - - $this->template->set_style_names($names, $new_paths); - - return true; - } - - /** - * Get location of style directory for specific style_path - * - * @param string $path Style path, such as "prosilver" - * @param string $style_base_directory The base directory the style is in - * E.g. 'styles', 'ext/foo/bar/styles' - * Default: 'styles' - * @return string Path to style directory, relative to current path - */ - public function get_style_path($path, $style_base_directory = 'styles') - { - return $this->phpbb_root_path . trim($style_base_directory, '/') . '/' . $path; - } -} diff --git a/phpBB/phpbb/template/template.php b/phpBB/phpbb/template/template.php index 89a01e924d..537c4eaf01 100644 --- a/phpBB/phpbb/template/template.php +++ b/phpBB/phpbb/template/template.php @@ -33,6 +33,36 @@ interface phpbb_template */ public function set_filenames(array $filename_array); + /** + * Get the style tree of the style preferred by the current user + * + * @return array Style tree, most specific first + */ + public function get_user_style(); + + /** + * Set style location based on (current) user's chosen style. + * + * @param array $style_directories The directories to add style paths for + * E.g. array('ext/foo/bar/styles', 'styles') + * Default: array('styles') (phpBB's style directory) + * @return bool true + */ + public function set_style($style_directories = array('styles')); + + /** + * Set custom style location (able to use directory outside of phpBB). + * + * Note: Templates are still compiled to phpBB's cache directory. + * + * @param string $name Name of style, used for cache prefix. Examples: "admin", "prosilver" + * @param array or string $paths Array of style paths, relative to current root directory + * @param array $names Array of names of templates in inheritance tree order, used by extensions. If empty, $name will be used. + * @param string $template_path Path to templates, relative to style directory. False if path should be set to default (templates/). + * @return bool true + */ + public function set_custom_style($name, $paths, $names = array(), $template_path = false); + /** * Sets the style names/paths corresponding to style hierarchy being compiled * and/or rendered. diff --git a/phpBB/phpbb/template/twig/twig.php b/phpBB/phpbb/template/twig/twig.php index 92a37d1634..92a52d26b8 100644 --- a/phpBB/phpbb/template/twig/twig.php +++ b/phpBB/phpbb/template/twig/twig.php @@ -177,6 +177,97 @@ class phpbb_template_twig implements phpbb_template return $this; } + /** + * Get the style tree of the style preferred by the current user + * + * @return array Style tree, most specific first + */ + public function get_user_style() + { + $style_list = array( + $this->user->style['style_path'], + ); + + if ($this->user->style['style_parent_id']) + { + $style_list = array_merge($style_list, array_reverse(explode('/', $this->user->style['style_parent_tree']))); + } + + return $style_list; + } + + /** + * Set style location based on (current) user's chosen style. + * + * @param array $style_directories The directories to add style paths for + * E.g. array('ext/foo/bar/styles', 'styles') + * Default: array('styles') (phpBB's style directory) + * @return bool true + */ + public function set_style($style_directories = array('styles')) + { + $this->names = $this->get_user_style(); + + $paths = array(); + foreach ($style_directories as $directory) + { + foreach ($this->names as $name) + { + $path = $this->get_style_path($name, $directory); + + if (is_dir($path)) + { + $paths[] = $path; + } + } + } + + $new_paths = array(); + foreach ($paths as $path) + { + $new_paths[] = $path . '/template/'; + } + + $this->set_style_names($this->names, $new_paths, ($style_directories === array('styles'))); + + return true; + } + + /** + * Set custom style location (able to use directory outside of phpBB). + * + * Note: Templates are still compiled to phpBB's cache directory. + * + * @param string $name Name of style, used for cache prefix. Examples: "admin", "prosilver" + * @param array or string $paths Array of style paths, relative to current root directory + * @param array $names Array of names of templates in inheritance tree order, used by extensions. If empty, $name will be used. + * @param string $template_path Path to templates, relative to style directory. False if path should be set to default (templates/). + * @return bool true + */ + public function set_custom_style($name, $paths, $names = array(), $template_path = false) + { + if (is_string($paths)) + { + $paths = array($paths); + } + + if (empty($names)) + { + $names = array($name); + } + $this->names = $names; + + $new_paths = array(); + foreach ($paths as $path) + { + $new_paths[] = $path . '/' . (($template_path !== false) ? $template_path : 'template/'); + } + + $this->set_style_names($names, $new_paths); + + return true; + } + /** * Sets the style names/paths corresponding to style hierarchy being compiled * and/or rendered. @@ -194,7 +285,7 @@ class phpbb_template_twig implements phpbb_template // Set as __main__ namespace $this->twig->getLoader()->setPaths($style_paths); - // Core style namespace from phpbb_style::set_style() + // Core style namespace from this::set_style() if ($is_core) { $this->twig->getLoader()->setPaths($style_paths, 'core'); @@ -462,4 +553,18 @@ class phpbb_template_twig implements phpbb_template { return $this->twig->getLoader()->getCacheKey($this->get_filename_from_handle($handle)); } + + /** + * Get location of style directory for specific style_path + * + * @param string $path Style path, such as "prosilver" + * @param string $style_base_directory The base directory the style is in + * E.g. 'styles', 'ext/foo/bar/styles' + * Default: 'styles' + * @return string Path to style directory, relative to current path + */ + protected function get_style_path($path, $style_base_directory = 'styles') + { + return $this->phpbb_root_path . trim($style_base_directory, '/') . '/' . $path; + } } diff --git a/phpBB/phpbb/user.php b/phpBB/phpbb/user.php index 5530fe3f03..2828bab6a8 100644 --- a/phpBB/phpbb/user.php +++ b/phpBB/phpbb/user.php @@ -75,7 +75,7 @@ class phpbb_user extends phpbb_session */ function setup($lang_set = false, $style_id = false) { - global $db, $phpbb_style, $template, $config, $auth, $phpEx, $phpbb_root_path, $cache; + global $db, $template, $config, $auth, $phpEx, $phpbb_root_path, $cache; global $phpbb_dispatcher; if ($this->data['user_id'] != ANONYMOUS) @@ -236,7 +236,7 @@ class phpbb_user extends phpbb_session } } - $phpbb_style->set_style(); + $template->set_style(); $this->img_lang = $this->lang_name; diff --git a/tests/controller/helper_url_test.php b/tests/controller/helper_url_test.php index 29399af77a..fc7d02e9cf 100644 --- a/tests/controller/helper_url_test.php +++ b/tests/controller/helper_url_test.php @@ -50,7 +50,6 @@ class phpbb_controller_helper_url_test extends phpbb_test_case $phpbb_dispatcher = new phpbb_mock_event_dispatcher; $this->user = $this->getMock('phpbb_user'); $this->template = new phpbb_template_twig($phpbb_root_path, $phpEx, $config, $this->user, new phpbb_template_context()); - $this->style = new phpbb_style($phpbb_root_path, $phpEx, new phpbb_config(array()), $this->user, $this->template); $helper = new phpbb_controller_helper($this->template, $this->user, '', 'php'); $this->assertEquals($helper->url($route, $params, $is_amp, $session_id), $expected); diff --git a/tests/template/includephp_test.php b/tests/template/includephp_test.php index ff7b890d11..1afa933514 100644 --- a/tests/template/includephp_test.php +++ b/tests/template/includephp_test.php @@ -46,7 +46,7 @@ class phpbb_template_includephp_test extends phpbb_template_template_test_case $this->setup_engine(array('tpl_allow_php' => true)); - $this->style->set_custom_style('tests', $cache_dir, array(), ''); + $this->template->set_custom_style('tests', $cache_dir, array(), ''); $this->run_template('includephp_absolute.html', array(), array(), array(), "Path is absolute.\ntesting included php"); diff --git a/tests/template/template_events_test.php b/tests/template/template_events_test.php index c3ebcb8739..7de3ebbfae 100644 --- a/tests/template/template_events_test.php +++ b/tests/template/template_events_test.php @@ -107,7 +107,6 @@ Zeta test event in all', dirname(__FILE__) . "/datasets/$dataset/" ); $this->template = new phpbb_template_twig($phpbb_root_path, $phpEx, $config, $user, new phpbb_template_context, $this->extension_manager); - $this->style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $this->template); - $this->style->set_custom_style('silver', array($this->template_path), $style_names, ''); + $this->template->set_custom_style('silver', array($this->template_path), $style_names, ''); } } diff --git a/tests/template/template_test.php b/tests/template/template_test.php index dd9ba21c26..3989f10229 100644 --- a/tests/template/template_test.php +++ b/tests/template/template_test.php @@ -410,7 +410,7 @@ class phpbb_template_template_test extends phpbb_template_template_test_case $this->setup_engine(array('tpl_allow_php' => true)); - $this->style->set_custom_style('tests', $cache_dir, array(), ''); + $this->template->set_custom_style('tests', $cache_dir, array(), ''); $this->run_template('php.html', array(), array(), array(), 'test'); } diff --git a/tests/template/template_test_case.php b/tests/template/template_test_case.php index 87573a53fe..f90d291d15 100644 --- a/tests/template/template_test_case.php +++ b/tests/template/template_test_case.php @@ -11,7 +11,6 @@ require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; class phpbb_template_template_test_case extends phpbb_test_case { - protected $style; protected $template; protected $template_path; protected $user; @@ -66,8 +65,7 @@ class phpbb_template_template_test_case extends phpbb_test_case $this->template_path = $this->test_path . '/templates'; $this->template = new phpbb_template_twig($phpbb_root_path, $phpEx, $config, $this->user, new phpbb_template_context()); - $this->style = new phpbb_style($phpbb_root_path, $phpEx, $config, $this->user, $this->template); - $this->style->set_custom_style('tests', $this->template_path, array(), ''); + $this->template->set_custom_style('tests', $this->template_path, array(), ''); } protected function setUp() diff --git a/tests/template/template_test_case_with_tree.php b/tests/template/template_test_case_with_tree.php index 50a6e9190d..7de719f430 100644 --- a/tests/template/template_test_case_with_tree.php +++ b/tests/template/template_test_case_with_tree.php @@ -21,7 +21,6 @@ class phpbb_template_template_test_case_with_tree extends phpbb_template_templat $this->template_path = $this->test_path . '/templates'; $this->parent_template_path = $this->test_path . '/parent_templates'; $this->template = new phpbb_template_twig($phpbb_root_path, $phpEx, $config, $user, new phpbb_template_context()); - $this->style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $this->template); - $this->style->set_custom_style('tests', array($this->template_path, $this->parent_template_path), array(), ''); + $this->template->set_custom_style('tests', array($this->template_path, $this->parent_template_path), array(), ''); } } From 85ff05bec635e8e6ef0fb64a561e2dd400b53897 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Wed, 24 Jul 2013 12:34:22 -0500 Subject: [PATCH 2344/2494] [ticket/11628] Remove $this->names, $this->style_names from phpbb_template These are not used anywhere PHPBB3-11628 --- phpBB/phpbb/template/twig/twig.php | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/phpBB/phpbb/template/twig/twig.php b/phpBB/phpbb/template/twig/twig.php index 92a52d26b8..4ae918ed86 100644 --- a/phpBB/phpbb/template/twig/twig.php +++ b/phpBB/phpbb/template/twig/twig.php @@ -74,16 +74,6 @@ class phpbb_template_twig implements phpbb_template */ protected $extension_manager; - /** - * Name of the style that the template being compiled and/or rendered - * belongs to, and its parents, in inheritance tree order. - * - * Used to invoke style-specific template events. - * - * @var array - */ - protected $style_names; - /** * Twig Environment * @@ -206,12 +196,12 @@ class phpbb_template_twig implements phpbb_template */ public function set_style($style_directories = array('styles')) { - $this->names = $this->get_user_style(); + $names = $this->get_user_style(); $paths = array(); foreach ($style_directories as $directory) { - foreach ($this->names as $name) + foreach ($names as $name) { $path = $this->get_style_path($name, $directory); @@ -228,7 +218,7 @@ class phpbb_template_twig implements phpbb_template $new_paths[] = $path . '/template/'; } - $this->set_style_names($this->names, $new_paths, ($style_directories === array('styles'))); + $this->set_style_names($names, $new_paths, ($style_directories === array('styles'))); return true; } @@ -255,7 +245,6 @@ class phpbb_template_twig implements phpbb_template { $names = array($name); } - $this->names = $names; $new_paths = array(); foreach ($paths as $path) @@ -280,8 +269,6 @@ class phpbb_template_twig implements phpbb_template */ public function set_style_names(array $style_names, array $style_paths, $is_core = false) { - $this->style_names = $style_names; - // Set as __main__ namespace $this->twig->getLoader()->setPaths($style_paths); From ecaed319ab46ee4dd45fe788a05aaeff96afc1d2 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Wed, 24 Jul 2013 12:42:37 -0500 Subject: [PATCH 2345/2494] [ticket/11628] Move setting core namespace to set_style() PHPBB3-11628 --- phpBB/phpbb/template/twig/twig.php | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/phpBB/phpbb/template/twig/twig.php b/phpBB/phpbb/template/twig/twig.php index 4ae918ed86..eb84da20dc 100644 --- a/phpBB/phpbb/template/twig/twig.php +++ b/phpBB/phpbb/template/twig/twig.php @@ -196,6 +196,12 @@ class phpbb_template_twig implements phpbb_template */ public function set_style($style_directories = array('styles')) { + if ($style_directories !== array('styles') && $this->twig->getLoader()->getPaths('core') === array()) + { + // We should set up the core styles path since not already setup + $this->set_style(); + } + $names = $this->get_user_style(); $paths = array(); @@ -203,7 +209,7 @@ class phpbb_template_twig implements phpbb_template { foreach ($names as $name) { - $path = $this->get_style_path($name, $directory); + $path = $this->get_style_path($name, $directory) . 'template/'; if (is_dir($path)) { @@ -212,13 +218,15 @@ class phpbb_template_twig implements phpbb_template } } - $new_paths = array(); - foreach ($paths as $path) + // If we're setting up the main phpBB styles directory and the core + // namespace isn't setup yet, we will set it up now + if ($style_directories === array('styles') && $this->twig->getLoader()->getPaths('core') === array()) { - $new_paths[] = $path . '/template/'; + // Set up the core style paths namespace + $this->twig->getLoader()->setPaths($paths, 'core'); } - $this->set_style_names($names, $new_paths, ($style_directories === array('styles'))); + $this->set_style_names($names, $paths); return true; } @@ -263,21 +271,13 @@ class phpbb_template_twig implements phpbb_template * * @param array $style_names List of style names in inheritance tree order * @param array $style_paths List of style paths in inheritance tree order - * @param bool $is_core True if the style names are the "core" styles for this page load - * Core means the main phpBB template files * @return phpbb_template $this */ - public function set_style_names(array $style_names, array $style_paths, $is_core = false) + public function set_style_names(array $style_names, array $style_paths) { // Set as __main__ namespace $this->twig->getLoader()->setPaths($style_paths); - // Core style namespace from this::set_style() - if ($is_core) - { - $this->twig->getLoader()->setPaths($style_paths, 'core'); - } - // Add admin namespace if (is_dir($this->phpbb_root_path . $this->adm_relative_path . 'style/')) { @@ -552,6 +552,6 @@ class phpbb_template_twig implements phpbb_template */ protected function get_style_path($path, $style_base_directory = 'styles') { - return $this->phpbb_root_path . trim($style_base_directory, '/') . '/' . $path; + return $this->phpbb_root_path . trim($style_base_directory, '/') . '/' . rtrim($path, '/') . '/'; } } From bfbc7aa74250ea5e9e39efc63caf7cfdb9407e14 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Wed, 24 Jul 2013 12:45:35 -0500 Subject: [PATCH 2346/2494] [ticket/11628] Return $this from set_style, set_custom_style PHPBB3-11628 --- phpBB/phpbb/template/template.php | 4 ++-- phpBB/phpbb/template/twig/twig.php | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/phpBB/phpbb/template/template.php b/phpBB/phpbb/template/template.php index 537c4eaf01..95a48ba0ad 100644 --- a/phpBB/phpbb/template/template.php +++ b/phpBB/phpbb/template/template.php @@ -46,7 +46,7 @@ interface phpbb_template * @param array $style_directories The directories to add style paths for * E.g. array('ext/foo/bar/styles', 'styles') * Default: array('styles') (phpBB's style directory) - * @return bool true + * @return phpbb_template $this */ public function set_style($style_directories = array('styles')); @@ -59,7 +59,7 @@ interface phpbb_template * @param array or string $paths Array of style paths, relative to current root directory * @param array $names Array of names of templates in inheritance tree order, used by extensions. If empty, $name will be used. * @param string $template_path Path to templates, relative to style directory. False if path should be set to default (templates/). - * @return bool true + * @return phpbb_template $this */ public function set_custom_style($name, $paths, $names = array(), $template_path = false); diff --git a/phpBB/phpbb/template/twig/twig.php b/phpBB/phpbb/template/twig/twig.php index eb84da20dc..48ea8edeb1 100644 --- a/phpBB/phpbb/template/twig/twig.php +++ b/phpBB/phpbb/template/twig/twig.php @@ -192,7 +192,7 @@ class phpbb_template_twig implements phpbb_template * @param array $style_directories The directories to add style paths for * E.g. array('ext/foo/bar/styles', 'styles') * Default: array('styles') (phpBB's style directory) - * @return bool true + * @return phpbb_template $this */ public function set_style($style_directories = array('styles')) { @@ -228,7 +228,7 @@ class phpbb_template_twig implements phpbb_template $this->set_style_names($names, $paths); - return true; + return $this; } /** @@ -240,7 +240,7 @@ class phpbb_template_twig implements phpbb_template * @param array or string $paths Array of style paths, relative to current root directory * @param array $names Array of names of templates in inheritance tree order, used by extensions. If empty, $name will be used. * @param string $template_path Path to templates, relative to style directory. False if path should be set to default (templates/). - * @return bool true + * @return phpbb_template $this */ public function set_custom_style($name, $paths, $names = array(), $template_path = false) { @@ -262,7 +262,7 @@ class phpbb_template_twig implements phpbb_template $this->set_style_names($names, $new_paths); - return true; + return $this; } /** From 4b761f65758c40db4851983fa3a08d354da3323d Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Wed, 24 Jul 2013 12:55:41 -0500 Subject: [PATCH 2347/2494] [ticket/11628] Remove third parameter ($names) from set_custom_style This was basically duplicating functionality. $names would be used if not empty, else array($name) would be used. Merged functionality into the first argument PHPBB3-11628 --- phpBB/adm/index.php | 2 +- phpBB/adm/swatch.php | 2 +- phpBB/includes/functions_module.php | 2 +- phpBB/install/index.php | 2 +- phpBB/install/install_update.php | 2 +- phpBB/phpbb/template/template.php | 5 ++--- phpBB/phpbb/template/twig/twig.php | 9 ++++----- tests/template/includephp_test.php | 2 +- tests/template/template_events_test.php | 2 +- tests/template/template_test.php | 2 +- tests/template/template_test_case.php | 2 +- tests/template/template_test_case_with_tree.php | 2 +- 12 files changed, 16 insertions(+), 18 deletions(-) diff --git a/phpBB/adm/index.php b/phpBB/adm/index.php index 3f29072899..c79327d22c 100644 --- a/phpBB/adm/index.php +++ b/phpBB/adm/index.php @@ -50,7 +50,7 @@ $module_id = request_var('i', ''); $mode = request_var('mode', ''); // Set custom style for admin area -$template->set_custom_style('admin', $phpbb_admin_path . 'style', array(), ''); +$template->set_custom_style('admin', $phpbb_admin_path . 'style', ''); $template->assign_var('T_ASSETS_PATH', $phpbb_root_path . 'assets'); $template->assign_var('T_TEMPLATE_PATH', $phpbb_admin_path . 'style'); diff --git a/phpBB/adm/swatch.php b/phpBB/adm/swatch.php index 70441ffeed..ef89081dc8 100644 --- a/phpBB/adm/swatch.php +++ b/phpBB/adm/swatch.php @@ -22,7 +22,7 @@ $auth->acl($user->data); $user->setup(); // Set custom template for admin area -$template->set_custom_style('admin', $phpbb_admin_path . 'style', array(), ''); +$template->set_custom_style('admin', $phpbb_admin_path . 'style', ''); $template->set_filenames(array( 'body' => 'colour_swatch.html') diff --git a/phpBB/includes/functions_module.php b/phpBB/includes/functions_module.php index a5ece1ecac..c84e02afe6 100644 --- a/phpBB/includes/functions_module.php +++ b/phpBB/includes/functions_module.php @@ -508,7 +508,7 @@ class p_master if (is_dir($module_style_dir)) { - $template->set_custom_style('admin', array($module_style_dir, $phpbb_admin_path . 'style'), array(), ''); + $template->set_custom_style('admin', array($module_style_dir, $phpbb_admin_path . 'style'), ''); } } diff --git a/phpBB/install/index.php b/phpBB/install/index.php index fd0d8a2d48..f80b975e2c 100644 --- a/phpBB/install/index.php +++ b/phpBB/install/index.php @@ -213,7 +213,7 @@ $config = new phpbb_config(array( )); $template = new phpbb_template_twig($phpbb_root_path, $phpEx, $config, $user, new phpbb_template_context()); -$template->set_custom_style('admin', $phpbb_admin_path . 'style', array(), ''); +$template->set_custom_style('admin', $phpbb_admin_path . 'style', ''); $template->assign_var('T_ASSETS_PATH', '../assets'); $template->assign_var('T_TEMPLATE_PATH', $phpbb_admin_path . 'style'); diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php index 51fbd1975c..63f10c96d7 100644 --- a/phpBB/install/install_update.php +++ b/phpBB/install/install_update.php @@ -138,7 +138,7 @@ class install_update extends module } // Set custom template again. ;) - $template->set_custom_style('admin', $phpbb_admin_path . 'style', array(), ''); + $template->set_custom_style('admin', $phpbb_admin_path . 'style', ''); $template->assign_vars(array( 'S_USER_LANG' => $user->lang['USER_LANG'], diff --git a/phpBB/phpbb/template/template.php b/phpBB/phpbb/template/template.php index 95a48ba0ad..c77586587f 100644 --- a/phpBB/phpbb/template/template.php +++ b/phpBB/phpbb/template/template.php @@ -55,13 +55,12 @@ interface phpbb_template * * Note: Templates are still compiled to phpBB's cache directory. * - * @param string $name Name of style, used for cache prefix. Examples: "admin", "prosilver" + * @param string|array $names Array of names or string of name of template(s) in inheritance tree order, used by extensions. * @param array or string $paths Array of style paths, relative to current root directory - * @param array $names Array of names of templates in inheritance tree order, used by extensions. If empty, $name will be used. * @param string $template_path Path to templates, relative to style directory. False if path should be set to default (templates/). * @return phpbb_template $this */ - public function set_custom_style($name, $paths, $names = array(), $template_path = false); + public function set_custom_style($names, $paths, $template_path = false); /** * Sets the style names/paths corresponding to style hierarchy being compiled diff --git a/phpBB/phpbb/template/twig/twig.php b/phpBB/phpbb/template/twig/twig.php index 48ea8edeb1..c9249196e7 100644 --- a/phpBB/phpbb/template/twig/twig.php +++ b/phpBB/phpbb/template/twig/twig.php @@ -236,22 +236,21 @@ class phpbb_template_twig implements phpbb_template * * Note: Templates are still compiled to phpBB's cache directory. * - * @param string $name Name of style, used for cache prefix. Examples: "admin", "prosilver" + * @param string|array $names Array of names or string of name of template(s) in inheritance tree order, used by extensions. * @param array or string $paths Array of style paths, relative to current root directory - * @param array $names Array of names of templates in inheritance tree order, used by extensions. If empty, $name will be used. * @param string $template_path Path to templates, relative to style directory. False if path should be set to default (templates/). * @return phpbb_template $this */ - public function set_custom_style($name, $paths, $names = array(), $template_path = false) + public function set_custom_style($names, $paths, $template_path = false) { if (is_string($paths)) { $paths = array($paths); } - if (empty($names)) + if (!is_array($names)) { - $names = array($name); + $names = array($names); } $new_paths = array(); diff --git a/tests/template/includephp_test.php b/tests/template/includephp_test.php index 1afa933514..70e7cea232 100644 --- a/tests/template/includephp_test.php +++ b/tests/template/includephp_test.php @@ -46,7 +46,7 @@ class phpbb_template_includephp_test extends phpbb_template_template_test_case $this->setup_engine(array('tpl_allow_php' => true)); - $this->template->set_custom_style('tests', $cache_dir, array(), ''); + $this->template->set_custom_style('tests', $cache_dir, ''); $this->run_template('includephp_absolute.html', array(), array(), array(), "Path is absolute.\ntesting included php"); diff --git a/tests/template/template_events_test.php b/tests/template/template_events_test.php index 7de3ebbfae..1b2ab38e2b 100644 --- a/tests/template/template_events_test.php +++ b/tests/template/template_events_test.php @@ -107,6 +107,6 @@ Zeta test event in all', dirname(__FILE__) . "/datasets/$dataset/" ); $this->template = new phpbb_template_twig($phpbb_root_path, $phpEx, $config, $user, new phpbb_template_context, $this->extension_manager); - $this->template->set_custom_style('silver', array($this->template_path), $style_names, ''); + $this->template->set_custom_style(((!empty($style_names)) ? $style_names : 'silver'), array($this->template_path), ''); } } diff --git a/tests/template/template_test.php b/tests/template/template_test.php index 3989f10229..0cc53f4d07 100644 --- a/tests/template/template_test.php +++ b/tests/template/template_test.php @@ -410,7 +410,7 @@ class phpbb_template_template_test extends phpbb_template_template_test_case $this->setup_engine(array('tpl_allow_php' => true)); - $this->template->set_custom_style('tests', $cache_dir, array(), ''); + $this->template->set_custom_style('tests', $cache_dir, ''); $this->run_template('php.html', array(), array(), array(), 'test'); } diff --git a/tests/template/template_test_case.php b/tests/template/template_test_case.php index f90d291d15..00c89e4501 100644 --- a/tests/template/template_test_case.php +++ b/tests/template/template_test_case.php @@ -65,7 +65,7 @@ class phpbb_template_template_test_case extends phpbb_test_case $this->template_path = $this->test_path . '/templates'; $this->template = new phpbb_template_twig($phpbb_root_path, $phpEx, $config, $this->user, new phpbb_template_context()); - $this->template->set_custom_style('tests', $this->template_path, array(), ''); + $this->template->set_custom_style('tests', $this->template_path, ''); } protected function setUp() diff --git a/tests/template/template_test_case_with_tree.php b/tests/template/template_test_case_with_tree.php index 7de719f430..1a29fd27b0 100644 --- a/tests/template/template_test_case_with_tree.php +++ b/tests/template/template_test_case_with_tree.php @@ -21,6 +21,6 @@ class phpbb_template_template_test_case_with_tree extends phpbb_template_templat $this->template_path = $this->test_path . '/templates'; $this->parent_template_path = $this->test_path . '/parent_templates'; $this->template = new phpbb_template_twig($phpbb_root_path, $phpEx, $config, $user, new phpbb_template_context()); - $this->template->set_custom_style('tests', array($this->template_path, $this->parent_template_path), array(), ''); + $this->template->set_custom_style('tests', array($this->template_path, $this->parent_template_path), ''); } } From 67627f3336f7a90a7de67427d25c8cdd43d74f6e Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Wed, 24 Jul 2013 13:01:30 -0500 Subject: [PATCH 2348/2494] [ticket/11628] Change set_custom_style $template path to default to string Rather than default to false and compare === false ? 'template/' : value just assign this default in the arguments PHPBB3-11628 --- phpBB/phpbb/template/template.php | 4 ++-- phpBB/phpbb/template/twig/twig.php | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/phpBB/phpbb/template/template.php b/phpBB/phpbb/template/template.php index c77586587f..c929934376 100644 --- a/phpBB/phpbb/template/template.php +++ b/phpBB/phpbb/template/template.php @@ -57,10 +57,10 @@ interface phpbb_template * * @param string|array $names Array of names or string of name of template(s) in inheritance tree order, used by extensions. * @param array or string $paths Array of style paths, relative to current root directory - * @param string $template_path Path to templates, relative to style directory. False if path should be set to default (templates/). + * @param string $template_path Path to templates, relative to style directory. Default (template/). * @return phpbb_template $this */ - public function set_custom_style($names, $paths, $template_path = false); + public function set_custom_style($names, $paths, $template_path = 'template/'); /** * Sets the style names/paths corresponding to style hierarchy being compiled diff --git a/phpBB/phpbb/template/twig/twig.php b/phpBB/phpbb/template/twig/twig.php index c9249196e7..5537b1195c 100644 --- a/phpBB/phpbb/template/twig/twig.php +++ b/phpBB/phpbb/template/twig/twig.php @@ -238,10 +238,10 @@ class phpbb_template_twig implements phpbb_template * * @param string|array $names Array of names or string of name of template(s) in inheritance tree order, used by extensions. * @param array or string $paths Array of style paths, relative to current root directory - * @param string $template_path Path to templates, relative to style directory. False if path should be set to default (templates/). + * @param string $template_path Path to templates, relative to style directory. Default (template/). * @return phpbb_template $this */ - public function set_custom_style($names, $paths, $template_path = false) + public function set_custom_style($names, $paths, $template_path = 'template/') { if (is_string($paths)) { @@ -256,7 +256,7 @@ class phpbb_template_twig implements phpbb_template $new_paths = array(); foreach ($paths as $path) { - $new_paths[] = $path . '/' . (($template_path !== false) ? $template_path : 'template/'); + $new_paths[] = $path . '/' . ltrim($template_path, '/'); } $this->set_style_names($names, $new_paths); From 44142782095f4a847e575dde40faef867c704220 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Wed, 24 Jul 2013 13:04:27 -0500 Subject: [PATCH 2349/2494] [ticket/11628] Set admin namespace in the constructor PHPBB3-11628 --- phpBB/phpbb/template/twig/twig.php | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/phpBB/phpbb/template/twig/twig.php b/phpBB/phpbb/template/twig/twig.php index 5537b1195c..72ba70ecc4 100644 --- a/phpBB/phpbb/template/twig/twig.php +++ b/phpBB/phpbb/template/twig/twig.php @@ -43,12 +43,6 @@ class phpbb_template_twig implements phpbb_template */ protected $phpbb_root_path; - /** - * adm relative path - * @var string - */ - protected $adm_relative_path; - /** * PHP file extension * @var string @@ -102,7 +96,6 @@ class phpbb_template_twig implements phpbb_template public function __construct($phpbb_root_path, $php_ext, $config, $user, phpbb_template_context $context, phpbb_extension_manager $extension_manager = null, $adm_relative_path = null) { $this->phpbb_root_path = $phpbb_root_path; - $this->adm_relative_path = $adm_relative_path; $this->php_ext = $php_ext; $this->config = $config; $this->user = $user; @@ -137,6 +130,12 @@ class phpbb_template_twig implements phpbb_template $lexer = new phpbb_template_twig_lexer($this->twig); $this->twig->setLexer($lexer); + + // Add admin namespace + if ($adm_relative_path !== null && is_dir($this->phpbb_root_path . $adm_relative_path . 'style/')) + { + $this->twig->getLoader()->setPaths($this->phpbb_root_path . $adm_relative_path . 'style/', 'admin'); + } } /** @@ -277,12 +276,6 @@ class phpbb_template_twig implements phpbb_template // Set as __main__ namespace $this->twig->getLoader()->setPaths($style_paths); - // Add admin namespace - if (is_dir($this->phpbb_root_path . $this->adm_relative_path . 'style/')) - { - $this->twig->getLoader()->setPaths($this->phpbb_root_path . $this->adm_relative_path . 'style/', 'admin'); - } - // Add all namespaces for all extensions if ($this->extension_manager instanceof phpbb_extension_manager) { From 863592a8bedbacf3e7bf6bee458797e819020e6f Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Wed, 24 Jul 2013 13:19:20 -0500 Subject: [PATCH 2350/2494] [ticket/11628] Remove set_style_names function, moved to set_custom_style PHPBB3-11628 --- phpBB/includes/functions_messenger.php | 2 +- phpBB/phpbb/template/template.php | 10 ---------- phpBB/phpbb/template/twig/twig.php | 27 ++++++-------------------- 3 files changed, 7 insertions(+), 32 deletions(-) diff --git a/phpBB/includes/functions_messenger.php b/phpBB/includes/functions_messenger.php index 0222a57bcc..89dd3c70fc 100644 --- a/phpBB/includes/functions_messenger.php +++ b/phpBB/includes/functions_messenger.php @@ -660,7 +660,7 @@ class messenger { $this->setup_template(); - $this->template->set_style_names(array($path_name), $paths); + $this->template->set_custom_style($path_name, $paths, ''); } } diff --git a/phpBB/phpbb/template/template.php b/phpBB/phpbb/template/template.php index c929934376..8554365c95 100644 --- a/phpBB/phpbb/template/template.php +++ b/phpBB/phpbb/template/template.php @@ -62,16 +62,6 @@ interface phpbb_template */ public function set_custom_style($names, $paths, $template_path = 'template/'); - /** - * Sets the style names/paths corresponding to style hierarchy being compiled - * and/or rendered. - * - * @param array $style_names List of style names in inheritance tree order - * @param array $style_paths List of style paths in inheritance tree order - * @return phpbb_template $this - */ - public function set_style_names(array $style_names, array $style_paths); - /** * Clears all variables and blocks assigned to this template. * diff --git a/phpBB/phpbb/template/twig/twig.php b/phpBB/phpbb/template/twig/twig.php index 72ba70ecc4..26f454e972 100644 --- a/phpBB/phpbb/template/twig/twig.php +++ b/phpBB/phpbb/template/twig/twig.php @@ -225,7 +225,7 @@ class phpbb_template_twig implements phpbb_template $this->twig->getLoader()->setPaths($paths, 'core'); } - $this->set_style_names($names, $paths); + $this->set_custom_style($names, $paths, ''); return $this; } @@ -247,39 +247,24 @@ class phpbb_template_twig implements phpbb_template $paths = array($paths); } - if (!is_array($names)) + if (is_string($names)) { $names = array($names); } - $new_paths = array(); + $style_paths = array(); foreach ($paths as $path) { - $new_paths[] = $path . '/' . ltrim($template_path, '/'); + $style_paths[] = $path . '/' . ltrim($template_path, '/'); } - $this->set_style_names($names, $new_paths); - - return $this; - } - - /** - * Sets the style names/paths corresponding to style hierarchy being compiled - * and/or rendered. - * - * @param array $style_names List of style names in inheritance tree order - * @param array $style_paths List of style paths in inheritance tree order - * @return phpbb_template $this - */ - public function set_style_names(array $style_names, array $style_paths) - { // Set as __main__ namespace $this->twig->getLoader()->setPaths($style_paths); // Add all namespaces for all extensions if ($this->extension_manager instanceof phpbb_extension_manager) { - $style_names[] = 'all'; + $names[] = 'all'; foreach ($this->extension_manager->all_enabled() as $ext_namespace => $ext_path) { @@ -287,7 +272,7 @@ class phpbb_template_twig implements phpbb_template $namespace = str_replace('/', '_', $ext_namespace); $paths = array(); - foreach ($style_names as $style_name) + foreach ($names as $style_name) { $ext_style_path = $ext_path . 'styles/' . $style_name . '/template'; From 12c22585069066957cc3211136ebd480295d4758 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Wed, 24 Jul 2013 13:25:20 -0500 Subject: [PATCH 2351/2494] [ticket/11628] Remove template_path option on set_custom_style This was set to default 'template/' to append template/ to all the paths, but every location was actually just setting it to '' to not append anything. So removed the option entirely (additional paths can be appended to the paths being sent to the function already) PHPBB3-11628 --- phpBB/adm/index.php | 2 +- phpBB/adm/swatch.php | 2 +- phpBB/includes/functions_messenger.php | 2 +- phpBB/includes/functions_module.php | 2 +- phpBB/install/index.php | 2 +- phpBB/install/install_update.php | 2 +- phpBB/phpbb/template/template.php | 3 +-- phpBB/phpbb/template/twig/twig.php | 13 +++---------- tests/template/includephp_test.php | 2 +- tests/template/template_events_test.php | 2 +- tests/template/template_test.php | 2 +- tests/template/template_test_case.php | 2 +- tests/template/template_test_case_with_tree.php | 2 +- 13 files changed, 15 insertions(+), 23 deletions(-) diff --git a/phpBB/adm/index.php b/phpBB/adm/index.php index c79327d22c..3520eb8b70 100644 --- a/phpBB/adm/index.php +++ b/phpBB/adm/index.php @@ -50,7 +50,7 @@ $module_id = request_var('i', ''); $mode = request_var('mode', ''); // Set custom style for admin area -$template->set_custom_style('admin', $phpbb_admin_path . 'style', ''); +$template->set_custom_style('admin', $phpbb_admin_path . 'style'); $template->assign_var('T_ASSETS_PATH', $phpbb_root_path . 'assets'); $template->assign_var('T_TEMPLATE_PATH', $phpbb_admin_path . 'style'); diff --git a/phpBB/adm/swatch.php b/phpBB/adm/swatch.php index ef89081dc8..cdd6bf3969 100644 --- a/phpBB/adm/swatch.php +++ b/phpBB/adm/swatch.php @@ -22,7 +22,7 @@ $auth->acl($user->data); $user->setup(); // Set custom template for admin area -$template->set_custom_style('admin', $phpbb_admin_path . 'style', ''); +$template->set_custom_style('admin', $phpbb_admin_path . 'style'); $template->set_filenames(array( 'body' => 'colour_swatch.html') diff --git a/phpBB/includes/functions_messenger.php b/phpBB/includes/functions_messenger.php index 89dd3c70fc..3a9e1fa77b 100644 --- a/phpBB/includes/functions_messenger.php +++ b/phpBB/includes/functions_messenger.php @@ -660,7 +660,7 @@ class messenger { $this->setup_template(); - $this->template->set_custom_style($path_name, $paths, ''); + $this->template->set_custom_style($path_name, $paths); } } diff --git a/phpBB/includes/functions_module.php b/phpBB/includes/functions_module.php index c84e02afe6..8f0f6a837a 100644 --- a/phpBB/includes/functions_module.php +++ b/phpBB/includes/functions_module.php @@ -508,7 +508,7 @@ class p_master if (is_dir($module_style_dir)) { - $template->set_custom_style('admin', array($module_style_dir, $phpbb_admin_path . 'style'), ''); + $template->set_custom_style('admin', array($module_style_dir, $phpbb_admin_path . 'style')); } } diff --git a/phpBB/install/index.php b/phpBB/install/index.php index f80b975e2c..84d751e279 100644 --- a/phpBB/install/index.php +++ b/phpBB/install/index.php @@ -213,7 +213,7 @@ $config = new phpbb_config(array( )); $template = new phpbb_template_twig($phpbb_root_path, $phpEx, $config, $user, new phpbb_template_context()); -$template->set_custom_style('admin', $phpbb_admin_path . 'style', ''); +$template->set_custom_style('admin', $phpbb_admin_path . 'style'); $template->assign_var('T_ASSETS_PATH', '../assets'); $template->assign_var('T_TEMPLATE_PATH', $phpbb_admin_path . 'style'); diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php index 63f10c96d7..a105944fb3 100644 --- a/phpBB/install/install_update.php +++ b/phpBB/install/install_update.php @@ -138,7 +138,7 @@ class install_update extends module } // Set custom template again. ;) - $template->set_custom_style('admin', $phpbb_admin_path . 'style', ''); + $template->set_custom_style('admin', $phpbb_admin_path . 'style'); $template->assign_vars(array( 'S_USER_LANG' => $user->lang['USER_LANG'], diff --git a/phpBB/phpbb/template/template.php b/phpBB/phpbb/template/template.php index 8554365c95..9881938a8f 100644 --- a/phpBB/phpbb/template/template.php +++ b/phpBB/phpbb/template/template.php @@ -57,10 +57,9 @@ interface phpbb_template * * @param string|array $names Array of names or string of name of template(s) in inheritance tree order, used by extensions. * @param array or string $paths Array of style paths, relative to current root directory - * @param string $template_path Path to templates, relative to style directory. Default (template/). * @return phpbb_template $this */ - public function set_custom_style($names, $paths, $template_path = 'template/'); + public function set_custom_style($names, $paths); /** * Clears all variables and blocks assigned to this template. diff --git a/phpBB/phpbb/template/twig/twig.php b/phpBB/phpbb/template/twig/twig.php index 26f454e972..4aa1774ef4 100644 --- a/phpBB/phpbb/template/twig/twig.php +++ b/phpBB/phpbb/template/twig/twig.php @@ -225,7 +225,7 @@ class phpbb_template_twig implements phpbb_template $this->twig->getLoader()->setPaths($paths, 'core'); } - $this->set_custom_style($names, $paths, ''); + $this->set_custom_style($names, $paths); return $this; } @@ -237,10 +237,9 @@ class phpbb_template_twig implements phpbb_template * * @param string|array $names Array of names or string of name of template(s) in inheritance tree order, used by extensions. * @param array or string $paths Array of style paths, relative to current root directory - * @param string $template_path Path to templates, relative to style directory. Default (template/). * @return phpbb_template $this */ - public function set_custom_style($names, $paths, $template_path = 'template/') + public function set_custom_style($names, $paths) { if (is_string($paths)) { @@ -252,14 +251,8 @@ class phpbb_template_twig implements phpbb_template $names = array($names); } - $style_paths = array(); - foreach ($paths as $path) - { - $style_paths[] = $path . '/' . ltrim($template_path, '/'); - } - // Set as __main__ namespace - $this->twig->getLoader()->setPaths($style_paths); + $this->twig->getLoader()->setPaths($paths); // Add all namespaces for all extensions if ($this->extension_manager instanceof phpbb_extension_manager) diff --git a/tests/template/includephp_test.php b/tests/template/includephp_test.php index 70e7cea232..a0dd8368cf 100644 --- a/tests/template/includephp_test.php +++ b/tests/template/includephp_test.php @@ -46,7 +46,7 @@ class phpbb_template_includephp_test extends phpbb_template_template_test_case $this->setup_engine(array('tpl_allow_php' => true)); - $this->template->set_custom_style('tests', $cache_dir, ''); + $this->template->set_custom_style('tests', $cache_dir); $this->run_template('includephp_absolute.html', array(), array(), array(), "Path is absolute.\ntesting included php"); diff --git a/tests/template/template_events_test.php b/tests/template/template_events_test.php index 1b2ab38e2b..f0cdeb39c5 100644 --- a/tests/template/template_events_test.php +++ b/tests/template/template_events_test.php @@ -107,6 +107,6 @@ Zeta test event in all', dirname(__FILE__) . "/datasets/$dataset/" ); $this->template = new phpbb_template_twig($phpbb_root_path, $phpEx, $config, $user, new phpbb_template_context, $this->extension_manager); - $this->template->set_custom_style(((!empty($style_names)) ? $style_names : 'silver'), array($this->template_path), ''); + $this->template->set_custom_style(((!empty($style_names)) ? $style_names : 'silver'), array($this->template_path)); } } diff --git a/tests/template/template_test.php b/tests/template/template_test.php index 0cc53f4d07..2f3ca6e313 100644 --- a/tests/template/template_test.php +++ b/tests/template/template_test.php @@ -410,7 +410,7 @@ class phpbb_template_template_test extends phpbb_template_template_test_case $this->setup_engine(array('tpl_allow_php' => true)); - $this->template->set_custom_style('tests', $cache_dir, ''); + $this->template->set_custom_style('tests', $cache_dir); $this->run_template('php.html', array(), array(), array(), 'test'); } diff --git a/tests/template/template_test_case.php b/tests/template/template_test_case.php index 00c89e4501..91895502ad 100644 --- a/tests/template/template_test_case.php +++ b/tests/template/template_test_case.php @@ -65,7 +65,7 @@ class phpbb_template_template_test_case extends phpbb_test_case $this->template_path = $this->test_path . '/templates'; $this->template = new phpbb_template_twig($phpbb_root_path, $phpEx, $config, $this->user, new phpbb_template_context()); - $this->template->set_custom_style('tests', $this->template_path, ''); + $this->template->set_custom_style('tests', $this->template_path); } protected function setUp() diff --git a/tests/template/template_test_case_with_tree.php b/tests/template/template_test_case_with_tree.php index 1a29fd27b0..477192c28a 100644 --- a/tests/template/template_test_case_with_tree.php +++ b/tests/template/template_test_case_with_tree.php @@ -21,6 +21,6 @@ class phpbb_template_template_test_case_with_tree extends phpbb_template_templat $this->template_path = $this->test_path . '/templates'; $this->parent_template_path = $this->test_path . '/parent_templates'; $this->template = new phpbb_template_twig($phpbb_root_path, $phpEx, $config, $user, new phpbb_template_context()); - $this->template->set_custom_style('tests', array($this->template_path, $this->parent_template_path), ''); + $this->template->set_custom_style('tests', array($this->template_path, $this->parent_template_path)); } } From 3b46f77e4e77defdd7c38249c865fdaecd83629e Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Wed, 24 Jul 2013 13:26:55 -0500 Subject: [PATCH 2352/2494] [ticket/11628] Shorten an if to an inline statement PHPBB3-11628 --- phpBB/phpbb/template/twig/twig.php | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/phpBB/phpbb/template/twig/twig.php b/phpBB/phpbb/template/twig/twig.php index 4aa1774ef4..c3ed52c3bd 100644 --- a/phpBB/phpbb/template/twig/twig.php +++ b/phpBB/phpbb/template/twig/twig.php @@ -241,15 +241,8 @@ class phpbb_template_twig implements phpbb_template */ public function set_custom_style($names, $paths) { - if (is_string($paths)) - { - $paths = array($paths); - } - - if (is_string($names)) - { - $names = array($names); - } + $paths = (is_string($paths)) ? array($paths) : $paths; + $names = (is_string($names)) ? array($names) : $names; // Set as __main__ namespace $this->twig->getLoader()->setPaths($paths); From 8795a354fed4e78b64cce531e6deaec9aa4d56f8 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Wed, 24 Jul 2013 13:31:09 -0500 Subject: [PATCH 2353/2494] [ticket/11628] Remove the one usage of get_style_path() Makes the code easier to follow PHPBB3-11628 --- phpBB/phpbb/template/template.php | 2 +- phpBB/phpbb/template/twig/twig.php | 18 ++---------------- 2 files changed, 3 insertions(+), 17 deletions(-) diff --git a/phpBB/phpbb/template/template.php b/phpBB/phpbb/template/template.php index 9881938a8f..6b9c331a3e 100644 --- a/phpBB/phpbb/template/template.php +++ b/phpBB/phpbb/template/template.php @@ -56,7 +56,7 @@ interface phpbb_template * Note: Templates are still compiled to phpBB's cache directory. * * @param string|array $names Array of names or string of name of template(s) in inheritance tree order, used by extensions. - * @param array or string $paths Array of style paths, relative to current root directory + * @param string|array or string $paths Array of style paths, relative to current root directory * @return phpbb_template $this */ public function set_custom_style($names, $paths); diff --git a/phpBB/phpbb/template/twig/twig.php b/phpBB/phpbb/template/twig/twig.php index c3ed52c3bd..0b5b4105ae 100644 --- a/phpBB/phpbb/template/twig/twig.php +++ b/phpBB/phpbb/template/twig/twig.php @@ -208,7 +208,7 @@ class phpbb_template_twig implements phpbb_template { foreach ($names as $name) { - $path = $this->get_style_path($name, $directory) . 'template/'; + $path = $this->phpbb_root_path . trim($directory, '/') . "/{$name}/template/"; if (is_dir($path)) { @@ -236,7 +236,7 @@ class phpbb_template_twig implements phpbb_template * Note: Templates are still compiled to phpBB's cache directory. * * @param string|array $names Array of names or string of name of template(s) in inheritance tree order, used by extensions. - * @param array or string $paths Array of style paths, relative to current root directory + * @param string|array or string $paths Array of style paths, relative to current root directory * @return phpbb_template $this */ public function set_custom_style($names, $paths) @@ -503,18 +503,4 @@ class phpbb_template_twig implements phpbb_template { return $this->twig->getLoader()->getCacheKey($this->get_filename_from_handle($handle)); } - - /** - * Get location of style directory for specific style_path - * - * @param string $path Style path, such as "prosilver" - * @param string $style_base_directory The base directory the style is in - * E.g. 'styles', 'ext/foo/bar/styles' - * Default: 'styles' - * @return string Path to style directory, relative to current path - */ - protected function get_style_path($path, $style_base_directory = 'styles') - { - return $this->phpbb_root_path . trim($style_base_directory, '/') . '/' . rtrim($path, '/') . '/'; - } } From 427fa17f7fd9db6f69a6cb4634198a2f484e0bd9 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Wed, 24 Jul 2013 13:34:41 -0500 Subject: [PATCH 2354/2494] [ticket/11628] Fix a bug I noticed in template->destroy Should not be setting $this->context = array()! PHPBB3-11628 --- phpBB/phpbb/template/twig/twig.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/phpbb/template/twig/twig.php b/phpBB/phpbb/template/twig/twig.php index 0b5b4105ae..710411c594 100644 --- a/phpBB/phpbb/template/twig/twig.php +++ b/phpBB/phpbb/template/twig/twig.php @@ -282,7 +282,7 @@ class phpbb_template_twig implements phpbb_template */ public function destroy() { - $this->context = array(); + $this->context->clear(); return $this; } From ffbc144a739740ad1901c9eaf481815c9ec2d918 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Wed, 24 Jul 2013 13:38:12 -0500 Subject: [PATCH 2355/2494] [ticket/11628] Make get_template_vars protected Remove all references to it and the hacky code in messenger that was using it PHPBB3-11628 --- phpBB/includes/functions_messenger.php | 31 ++++++-------------------- phpBB/phpbb/template/twig/twig.php | 2 +- 2 files changed, 8 insertions(+), 25 deletions(-) diff --git a/phpBB/includes/functions_messenger.php b/phpBB/includes/functions_messenger.php index 3a9e1fa77b..3bfc1a44f0 100644 --- a/phpBB/includes/functions_messenger.php +++ b/phpBB/includes/functions_messenger.php @@ -21,7 +21,7 @@ if (!defined('IN_PHPBB')) */ class messenger { - var $vars, $msg, $extra_headers, $replyto, $from, $subject; + var $msg, $extra_headers, $replyto, $from, $subject; var $addresses = array(); var $mail_priority = MAIL_NORMAL_PRIORITY; @@ -53,7 +53,7 @@ class messenger function reset() { $this->addresses = $this->extra_headers = array(); - $this->vars = $this->msg = $this->replyto = $this->from = ''; + $this->msg = $this->replyto = $this->from = ''; $this->mail_priority = MAIL_NORMAL_PRIORITY; } @@ -258,8 +258,6 @@ class messenger 'body' => $template_file . '.txt', )); - $this->vars = $this->template->get_template_vars(); - return true; } @@ -288,26 +286,11 @@ class messenger global $config, $user; // We add some standard variables we always use, no need to specify them always - if (!isset($this->vars['U_BOARD'])) - { - $this->assign_vars(array( - 'U_BOARD' => generate_board_url(), - )); - } - - if (!isset($this->vars['EMAIL_SIG'])) - { - $this->assign_vars(array( - 'EMAIL_SIG' => str_replace('
    ', "\n", "-- \n" . htmlspecialchars_decode($config['board_email_sig'])), - )); - } - - if (!isset($this->vars['SITENAME'])) - { - $this->assign_vars(array( - 'SITENAME' => htmlspecialchars_decode($config['sitename']), - )); - } + $this->assign_vars(array( + 'U_BOARD' => generate_board_url(), + 'EMAIL_SIG' => str_replace('
    ', "\n", "-- \n" . htmlspecialchars_decode($config['board_email_sig'])), + 'SITENAME' => htmlspecialchars_decode($config['sitename']), + )); // Parse message through template $this->msg = trim($this->template->assign_display('body')); diff --git a/phpBB/phpbb/template/twig/twig.php b/phpBB/phpbb/template/twig/twig.php index 710411c594..582939c252 100644 --- a/phpBB/phpbb/template/twig/twig.php +++ b/phpBB/phpbb/template/twig/twig.php @@ -464,7 +464,7 @@ class phpbb_template_twig implements phpbb_template * * @return array */ - public function get_template_vars() + protected function get_template_vars() { $context_vars = $this->context->get_data_ref(); From ce0a1bb3c59e5815e8c39dc9f7b70ca9810df6e3 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Wed, 24 Jul 2013 13:44:39 -0500 Subject: [PATCH 2356/2494] [ticket/11628] Remove remaining style_path_provider_test PHPBB3-11628 --- .../subdir/style_path_provider_test.php | 18 ------------------ 1 file changed, 18 deletions(-) delete mode 100644 tests/extension/subdir/style_path_provider_test.php diff --git a/tests/extension/subdir/style_path_provider_test.php b/tests/extension/subdir/style_path_provider_test.php deleted file mode 100644 index 1b5ce62e5f..0000000000 --- a/tests/extension/subdir/style_path_provider_test.php +++ /dev/null @@ -1,18 +0,0 @@ -relative_root_path = '../'; - $this->root_path = dirname(__FILE__) . '/../'; - } -} From a9f05775025f010339fee5607df9b890abf472f8 Mon Sep 17 00:00:00 2001 From: Oliver Schramm Date: Thu, 25 Jul 2013 12:29:25 +0200 Subject: [PATCH 2357/2494] [ticket/11062] Load new strings from user's language file if provided PHPBB3-11062 --- phpBB/install/install_update.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php index c18a0fb4ec..0afd6b07bb 100644 --- a/phpBB/install/install_update.php +++ b/phpBB/install/install_update.php @@ -232,6 +232,13 @@ class install_update extends module } // What about the language file? Got it updated? + if (in_array('language/' . $language . '/install.' . $phpEx, $this->update_info['files'])) + { + $lang = array(); + include($this->new_location . 'language/' . $language . '/install.' . $phpEx); + // this is the user's language.. just merge it + $user->lang = array_merge($user->lang, $lang); + } if (in_array('language/en/install.' . $phpEx, $this->update_info['files'])) { $lang = array(); From 7304ac9c3ca817716f14bb8817a201b149e5ebef Mon Sep 17 00:00:00 2001 From: Oliver Schramm Date: Thu, 25 Jul 2013 13:10:45 +0200 Subject: [PATCH 2358/2494] [ticket/11062] If user's language is english there is no further work needed PHPBB3-11062 --- phpBB/install/install_update.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php index 0afd6b07bb..9823703f0a 100644 --- a/phpBB/install/install_update.php +++ b/phpBB/install/install_update.php @@ -239,7 +239,7 @@ class install_update extends module // this is the user's language.. just merge it $user->lang = array_merge($user->lang, $lang); } - if (in_array('language/en/install.' . $phpEx, $this->update_info['files'])) + if ($language != 'en' && in_array('language/en/install.' . $phpEx, $this->update_info['files'])) { $lang = array(); include($this->new_location . 'language/en/install.' . $phpEx); From c5de4dd51dfba4737e4b46af05546f3c6a4f8da6 Mon Sep 17 00:00:00 2001 From: MichaelC Date: Thu, 25 Jul 2013 13:06:11 +0100 Subject: [PATCH 2359/2494] [ticket/11740] Update FAQ to include Ideas Centre PHPBB3-11740 --- phpBB/language/en/help_faq.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/language/en/help_faq.php b/phpBB/language/en/help_faq.php index dab66779c3..b68336e0f7 100644 --- a/phpBB/language/en/help_faq.php +++ b/phpBB/language/en/help_faq.php @@ -333,7 +333,7 @@ $help = array( ), array( 0 => 'Why isn’t X feature available?', - 1 => 'This software was written by and licensed through phpBB Group. If you believe a feature needs to be added, or you want to report a bug, please visit the phpBB Area51 website, where you will find resources to do so.' + 1 => 'This software was written by and licensed through phpBB Group. If you believe a feature needs to be added please visit the phpBB Ideas Centre, where you can upvote existing ideas or suggest new features.' ), array( 0 => 'Who do I contact about abusive and/or legal matters related to this board?', From 866e475f9644dd3575ed62bfb0e7dde0338fd5cc Mon Sep 17 00:00:00 2001 From: Oliver Schramm Date: Thu, 25 Jul 2013 15:47:55 +0200 Subject: [PATCH 2360/2494] [ticket/10037] Apply attached patch with a few changes PHPBB3-10037 --- phpBB/includes/ucp/ucp_profile.php | 3 ++ .../prosilver/template/posting_smilies.html | 4 +-- .../subsilver2/template/posting_smilies.html | 4 +-- .../template/ucp_profile_signature.html | 35 ++++++++++++++++++- 4 files changed, 41 insertions(+), 5 deletions(-) diff --git a/phpBB/includes/ucp/ucp_profile.php b/phpBB/includes/ucp/ucp_profile.php index d35d13b6c1..847311058b 100644 --- a/phpBB/includes/ucp/ucp_profile.php +++ b/phpBB/includes/ucp/ucp_profile.php @@ -548,6 +548,9 @@ class ucp_profile // Build custom bbcodes array display_custom_bbcodes(); + // Generate smiley listing + generate_smilies('inline', 0); + break; case 'avatar': diff --git a/phpBB/styles/prosilver/template/posting_smilies.html b/phpBB/styles/prosilver/template/posting_smilies.html index 86ac24aa53..d45b185ed3 100644 --- a/phpBB/styles/prosilver/template/posting_smilies.html +++ b/phpBB/styles/prosilver/template/posting_smilies.html @@ -2,8 +2,8 @@ diff --git a/phpBB/styles/subsilver2/template/posting_smilies.html b/phpBB/styles/subsilver2/template/posting_smilies.html index fcab578bd9..d2224887bc 100644 --- a/phpBB/styles/subsilver2/template/posting_smilies.html +++ b/phpBB/styles/subsilver2/template/posting_smilies.html @@ -2,8 +2,8 @@ diff --git a/phpBB/styles/subsilver2/template/ucp_profile_signature.html b/phpBB/styles/subsilver2/template/ucp_profile_signature.html index a33726e166..8588a99438 100644 --- a/phpBB/styles/subsilver2/template/ucp_profile_signature.html +++ b/phpBB/styles/subsilver2/template/ucp_profile_signature.html @@ -5,9 +5,11 @@
    {L_TITLE}
    {L_SIGNATURE_EXPLAIN}
    + + + + +
    + {L_SIGNATURE_EXPLAIN} + + + + + + + + + + + + + +
    {L_SMILIES}
    + + {smiley.SMILEY_CODE} + +
    {L_MORE_SMILIES}
    + +
    + @@ -47,6 +75,11 @@
    + +
    + From 57bc3c7d3aaa66fc66798bc1e60b88ae17b110a9 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Thu, 25 Jul 2013 09:32:28 -0500 Subject: [PATCH 2361/2494] [ticket/11628] phpbb_template, not phpbb_template_interface PHPBB3-11628 --- phpBB/phpbb/controller/resolver.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/phpbb/controller/resolver.php b/phpBB/phpbb/controller/resolver.php index 850df84a0f..d772507261 100644 --- a/phpBB/phpbb/controller/resolver.php +++ b/phpBB/phpbb/controller/resolver.php @@ -48,7 +48,7 @@ class phpbb_controller_resolver implements ControllerResolverInterface * * @param phpbb_user $user User Object * @param ContainerInterface $container ContainerInterface object - * @param phpbb_template_interface $template + * @param phpbb_template $template */ public function __construct(phpbb_user $user, ContainerInterface $container, phpbb_template $template = null) { From 37ceb57d12b936d810da645b6eb49aa2b1d12a5e Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Fri, 26 Jul 2013 18:27:47 -0700 Subject: [PATCH 2362/2494] [ticket/11747] Add $phpbb_dispatcher to global PHPBB3-11747 --- phpBB/includes/ucp/ucp_prefs.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/ucp/ucp_prefs.php b/phpBB/includes/ucp/ucp_prefs.php index f24578da84..73b01deb22 100644 --- a/phpBB/includes/ucp/ucp_prefs.php +++ b/phpBB/includes/ucp/ucp_prefs.php @@ -26,7 +26,7 @@ class ucp_prefs function main($id, $mode) { - global $config, $db, $user, $auth, $template, $phpbb_root_path, $phpEx; + global $config, $db, $user, $auth, $template, $phpbb_dispatcher, $phpbb_root_path, $phpEx; $submit = (isset($_POST['submit'])) ? true : false; $error = $data = array(); From 79cd86bcbcfb2bf0f27d06fc475ea967ea38755b Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Fri, 26 Jul 2013 18:29:06 -0700 Subject: [PATCH 2363/2494] [ticket/11747] ucp_prefs_personal core events PHPBB3-11747 --- phpBB/includes/ucp/ucp_prefs.php | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/phpBB/includes/ucp/ucp_prefs.php b/phpBB/includes/ucp/ucp_prefs.php index 73b01deb22..8a92f22bba 100644 --- a/phpBB/includes/ucp/ucp_prefs.php +++ b/phpBB/includes/ucp/ucp_prefs.php @@ -55,6 +55,20 @@ class ucp_prefs $data['notifymethod'] = NOTIFY_BOTH; } + /** + * Add UCP edit global settings data before they are assigned to the template or submitted + * + * To assign data to the template, use $template->assign_vars() + * + * @event core.ucp_prefs_personal_data + * @var bool submit Do we display the form only + * or did the user press submit + * @var array data Array with current ucp options data + * @since 3.1-A1 + */ + $vars = array('submit', 'data'); + extract($phpbb_dispatcher->trigger_event('core.ucp_prefs_personal_data', compact($vars))); + if ($submit) { if ($config['override_user_style']) @@ -93,6 +107,17 @@ class ucp_prefs 'user_style' => $data['style'], ); + /** + * Update UCP edit global settings data on form submit + * + * @event core.ucp_prefs_personal_update_data + * @var array data Submitted display options data + * @var array sql_ary Display options data we udpate + * @since 3.1-A1 + */ + $vars = array('data', 'sql_ary'); + extract($phpbb_dispatcher->trigger_event('core.ucp_prefs_personal_update_data', compact($vars))); + $sql = 'UPDATE ' . USERS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' WHERE user_id = ' . $user->data['user_id']; From cd329c55a7bd7222982283e5a378e511c06bdfe8 Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Fri, 26 Jul 2013 18:31:05 -0700 Subject: [PATCH 2364/2494] [ticket/11747] ucp_prefs_personal template events PHPBB3-11747 --- phpBB/docs/events.md | 14 ++++++++++++++ .../prosilver/template/ucp_prefs_personal.html | 2 ++ .../subsilver2/template/ucp_prefs_personal.html | 2 ++ 3 files changed, 18 insertions(+) diff --git a/phpBB/docs/events.md b/phpBB/docs/events.md index 3723bf7b3f..cc12410df2 100644 --- a/phpBB/docs/events.md +++ b/phpBB/docs/events.md @@ -119,6 +119,20 @@ ucp_pm_viewmessage_print_head_append * Location: styles/prosilver/template/ucp_pm_viewmessage_print.html * Purpose: Add asset calls directly before the `` tag of the Print PM screen +ucp_prefs_personal_before +=== +* Locations: + + styles/prosilver/template/ucp_prefs_personal.html + + styles/subsilver2/template/ucp_prefs_personal.html +* Purpose: Add user options to the top of the Edit Global Settings screen + +ucp_prefs_personal_after +=== +* Locations: + + styles/prosilver/template/ucp_prefs_personal.html + + styles/subsilver2/template/ucp_prefs_personal.html +* Purpose: Add user options to the bottom of the Edit Global Settings screen + viewtopic_print_head_append === * Location: styles/prosilver/template/viewtopic_print.html diff --git a/phpBB/styles/prosilver/template/ucp_prefs_personal.html b/phpBB/styles/prosilver/template/ucp_prefs_personal.html index 9a639786b7..4484dd7a55 100644 --- a/phpBB/styles/prosilver/template/ucp_prefs_personal.html +++ b/phpBB/styles/prosilver/template/ucp_prefs_personal.html @@ -9,6 +9,7 @@

    {ERROR}

    +
    @@ -71,6 +72,7 @@
    +
    diff --git a/phpBB/styles/subsilver2/template/ucp_prefs_personal.html b/phpBB/styles/subsilver2/template/ucp_prefs_personal.html index 8f6e345e69..f39090c8fe 100644 --- a/phpBB/styles/subsilver2/template/ucp_prefs_personal.html +++ b/phpBB/styles/subsilver2/template/ucp_prefs_personal.html @@ -29,6 +29,7 @@ {ERROR} + {L_SHOW_EMAIL}{L_COLON} checked="checked" />{L_YES}   checked="checked" />{L_NO} @@ -75,6 +76,7 @@
    style="display:none;">
    + {S_HIDDEN_FIELDS}   From d3859aa87427a75cb7c9f7645de3317a834b00ee Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Fri, 26 Jul 2013 18:31:58 -0700 Subject: [PATCH 2365/2494] [ticket/11747] ucp_prefs_view core events PHPBB3-11747 --- phpBB/includes/ucp/ucp_prefs.php | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/phpBB/includes/ucp/ucp_prefs.php b/phpBB/includes/ucp/ucp_prefs.php index 8a92f22bba..31cf5a4447 100644 --- a/phpBB/includes/ucp/ucp_prefs.php +++ b/phpBB/includes/ucp/ucp_prefs.php @@ -234,6 +234,20 @@ class ucp_prefs 'wordcensor' => request_var('wordcensor', (bool) $user->optionget('viewcensors')), ); + /** + * Add UCP edit display options data before they are assigned to the template or submitted + * + * To assign data to the template, use $template->assign_vars() + * + * @event core.ucp_prefs_view_data + * @var bool submit Do we display the form only + * or did the user press submit + * @var array data Array with current ucp options data + * @since 3.1-A1 + */ + $vars = array('submit', 'data'); + extract($phpbb_dispatcher->trigger_event('core.ucp_prefs_view_data', compact($vars))); + if ($submit) { $error = validate_data($data, array( @@ -272,6 +286,17 @@ class ucp_prefs 'user_post_show_days' => $data['post_st'], ); + /** + * Update UCP edit display options data on form submit + * + * @event core.ucp_prefs_view_update_data + * @var array data Submitted display options data + * @var array sql_ary Display options data we udpate + * @since 3.1-A1 + */ + $vars = array('data', 'sql_ary'); + extract($phpbb_dispatcher->trigger_event('core.ucp_prefs_view_update_data', compact($vars))); + $sql = 'UPDATE ' . USERS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' WHERE user_id = ' . $user->data['user_id']; From b716e1177d0fc94f1b5b8102fd35b61a6874e324 Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Fri, 26 Jul 2013 18:33:07 -0700 Subject: [PATCH 2366/2494] [ticket/11747] ucp_prefs_view template events PHPBB3-11747 --- phpBB/docs/events.md | 32 +++++++++++++++++++ .../prosilver/template/ucp_prefs_view.html | 4 +++ .../subsilver2/template/ucp_prefs_view.html | 4 +++ 3 files changed, 40 insertions(+) diff --git a/phpBB/docs/events.md b/phpBB/docs/events.md index cc12410df2..93f83e8d1c 100644 --- a/phpBB/docs/events.md +++ b/phpBB/docs/events.md @@ -133,6 +133,38 @@ ucp_prefs_personal_after + styles/subsilver2/template/ucp_prefs_personal.html * Purpose: Add user options to the bottom of the Edit Global Settings screen +ucp_prefs_view_radio_buttons_before +=== +* Locations: + + styles/prosilver/template/ucp_prefs_view.html + + styles/subsilver2/template/ucp_prefs_view.html +* Purpose: Add options to the top of the radio buttons section of the Edit +Display Options screen + +ucp_prefs_view_radio_buttons_after +=== +* Locations: + + styles/prosilver/template/ucp_prefs_view.html + + styles/subsilver2/template/ucp_prefs_view.html +* Purpose: Add options to the bottom of the radio buttons section of the Edit +Display Options screen + +ucp_prefs_view_select_menu_before +=== +* Locations: + + styles/prosilver/template/ucp_prefs_view.html + + styles/subsilver2/template/ucp_prefs_view.html +* Purpose: Add options to the top of the drop down menus section of the Edit +Display Options screen + +ucp_prefs_view_select_menu_after +=== +* Locations: + + styles/prosilver/template/ucp_prefs_view.html + + styles/subsilver2/template/ucp_prefs_view.html +* Purpose: Add options to the bottom of the drop down menus section of the Edit +Display Options screen + viewtopic_print_head_append === * Location: styles/prosilver/template/viewtopic_print.html diff --git a/phpBB/styles/prosilver/template/ucp_prefs_view.html b/phpBB/styles/prosilver/template/ucp_prefs_view.html index 51561349c3..55e5531075 100644 --- a/phpBB/styles/prosilver/template/ucp_prefs_view.html +++ b/phpBB/styles/prosilver/template/ucp_prefs_view.html @@ -9,6 +9,7 @@

    {ERROR}

    +
    @@ -53,7 +54,9 @@
    +
    +
    {S_TOPIC_SORT_DAYS}
    @@ -79,6 +82,7 @@
    {S_POST_SORT_DIR}
    +
    diff --git a/phpBB/styles/subsilver2/template/ucp_prefs_view.html b/phpBB/styles/subsilver2/template/ucp_prefs_view.html index cc1b20a987..c9336a4da5 100644 --- a/phpBB/styles/subsilver2/template/ucp_prefs_view.html +++ b/phpBB/styles/subsilver2/template/ucp_prefs_view.html @@ -9,6 +9,7 @@ {ERROR} + {L_VIEW_IMAGES}{L_COLON} checked="checked" />{L_YES}    checked="checked" />{L_NO} @@ -35,9 +36,11 @@ checked="checked" />{L_YES}    checked="checked" />{L_NO} + + {L_VIEW_TOPICS_DAYS}{L_COLON} {S_TOPIC_SORT_DAYS} @@ -65,6 +68,7 @@ {L_VIEW_POSTS_DIR}{L_COLON} {S_POST_SORT_DIR} + {S_HIDDEN_FIELDS}   From 01e133f3563181e163aa0fc85e89a6fc35d31c0f Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Fri, 26 Jul 2013 18:33:27 -0700 Subject: [PATCH 2367/2494] [ticket/11747] ucp_prefs_post core events PHPBB3-11747 --- phpBB/includes/ucp/ucp_prefs.php | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/phpBB/includes/ucp/ucp_prefs.php b/phpBB/includes/ucp/ucp_prefs.php index 31cf5a4447..e80cc2dce3 100644 --- a/phpBB/includes/ucp/ucp_prefs.php +++ b/phpBB/includes/ucp/ucp_prefs.php @@ -385,6 +385,20 @@ class ucp_prefs ); add_form_key('ucp_prefs_post'); + /** + * Add UCP edit posting defaults data before they are assigned to the template or submitted + * + * To assign data to the template, use $template->assign_vars() + * + * @event core.ucp_prefs_post_data + * @var bool submit Do we display the form only + * or did the user press submit + * @var array data Array with current ucp options data + * @since 3.1-A1 + */ + $vars = array('submit', 'data'); + extract($phpbb_dispatcher->trigger_event('core.ucp_prefs_post_data', compact($vars))); + if ($submit) { if (check_form_key('ucp_prefs_post')) @@ -398,6 +412,17 @@ class ucp_prefs 'user_notify' => $data['notify'], ); + /** + * Update UCP edit posting defaults data on form submit + * + * @event core.ucp_prefs_post_update_data + * @var array data Submitted display options data + * @var array sql_ary Display options data we udpate + * @since 3.1-A1 + */ + $vars = array('data', 'sql_ary'); + extract($phpbb_dispatcher->trigger_event('core.ucp_prefs_post_update_data', compact($vars))); + $sql = 'UPDATE ' . USERS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' WHERE user_id = ' . $user->data['user_id']; From 442b2a292e2b761b58f2ba88fd5922d0090ec4a5 Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Fri, 26 Jul 2013 18:33:54 -0700 Subject: [PATCH 2368/2494] [ticket/11747] ucp_prefs_post template events PHPBB3-11747 --- phpBB/docs/events.md | 14 ++++++++++++++ .../styles/prosilver/template/ucp_prefs_post.html | 2 ++ .../styles/subsilver2/template/ucp_prefs_post.html | 2 ++ 3 files changed, 18 insertions(+) diff --git a/phpBB/docs/events.md b/phpBB/docs/events.md index 93f83e8d1c..74bbc675d2 100644 --- a/phpBB/docs/events.md +++ b/phpBB/docs/events.md @@ -133,6 +133,20 @@ ucp_prefs_personal_after + styles/subsilver2/template/ucp_prefs_personal.html * Purpose: Add user options to the bottom of the Edit Global Settings screen +ucp_prefs_post_before +=== +* Locations: + + styles/prosilver/template/ucp_prefs_post.html + + styles/subsilver2/template/ucp_prefs_post.html +* Purpose: Add user options to the top of the Edit Posting Defaults screen + +ucp_prefs_post_after +=== +* Locations: + + styles/prosilver/template/ucp_prefs_post.html + + styles/subsilver2/template/ucp_prefs_post.html +* Purpose: Add user options to the bottom of the Edit Posting Defaults screen + ucp_prefs_view_radio_buttons_before === * Locations: diff --git a/phpBB/styles/prosilver/template/ucp_prefs_post.html b/phpBB/styles/prosilver/template/ucp_prefs_post.html index 6c68b2bccc..2b8fea832a 100644 --- a/phpBB/styles/prosilver/template/ucp_prefs_post.html +++ b/phpBB/styles/prosilver/template/ucp_prefs_post.html @@ -8,6 +8,7 @@

    {ERROR}

    +
    @@ -36,6 +37,7 @@
    +
    diff --git a/phpBB/styles/subsilver2/template/ucp_prefs_post.html b/phpBB/styles/subsilver2/template/ucp_prefs_post.html index 03f1472942..5dcd431e82 100644 --- a/phpBB/styles/subsilver2/template/ucp_prefs_post.html +++ b/phpBB/styles/subsilver2/template/ucp_prefs_post.html @@ -9,6 +9,7 @@ {ERROR} + {L_DEFAULT_BBCODE}{L_COLON} checked="checked" />{L_YES}    checked="checked" />{L_NO} @@ -25,6 +26,7 @@ {L_DEFAULT_NOTIFY}{L_COLON} checked="checked" />{L_YES}    checked="checked" />{L_NO} + {S_HIDDEN_FIELDS}   From dacca5657a59fe1e69f5609cf9112e8e2cdac369 Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Fri, 26 Jul 2013 22:25:27 -0700 Subject: [PATCH 2369/2494] [ticket/11747] Use _prepend and _append for template events PHPBB3-11747 --- phpBB/docs/events.md | 16 ++++++++-------- .../prosilver/template/ucp_prefs_personal.html | 4 ++-- .../prosilver/template/ucp_prefs_post.html | 4 ++-- .../prosilver/template/ucp_prefs_view.html | 8 ++++---- .../subsilver2/template/ucp_prefs_personal.html | 4 ++-- .../subsilver2/template/ucp_prefs_post.html | 4 ++-- .../subsilver2/template/ucp_prefs_view.html | 8 ++++---- 7 files changed, 24 insertions(+), 24 deletions(-) diff --git a/phpBB/docs/events.md b/phpBB/docs/events.md index 74bbc675d2..f6a92aaf69 100644 --- a/phpBB/docs/events.md +++ b/phpBB/docs/events.md @@ -119,35 +119,35 @@ ucp_pm_viewmessage_print_head_append * Location: styles/prosilver/template/ucp_pm_viewmessage_print.html * Purpose: Add asset calls directly before the `` tag of the Print PM screen -ucp_prefs_personal_before +ucp_prefs_personal_prepend === * Locations: + styles/prosilver/template/ucp_prefs_personal.html + styles/subsilver2/template/ucp_prefs_personal.html * Purpose: Add user options to the top of the Edit Global Settings screen -ucp_prefs_personal_after +ucp_prefs_personal_append === * Locations: + styles/prosilver/template/ucp_prefs_personal.html + styles/subsilver2/template/ucp_prefs_personal.html * Purpose: Add user options to the bottom of the Edit Global Settings screen -ucp_prefs_post_before +ucp_prefs_post_prepend === * Locations: + styles/prosilver/template/ucp_prefs_post.html + styles/subsilver2/template/ucp_prefs_post.html * Purpose: Add user options to the top of the Edit Posting Defaults screen -ucp_prefs_post_after +ucp_prefs_post_append === * Locations: + styles/prosilver/template/ucp_prefs_post.html + styles/subsilver2/template/ucp_prefs_post.html * Purpose: Add user options to the bottom of the Edit Posting Defaults screen -ucp_prefs_view_radio_buttons_before +ucp_prefs_view_radio_buttons_prepend === * Locations: + styles/prosilver/template/ucp_prefs_view.html @@ -155,7 +155,7 @@ ucp_prefs_view_radio_buttons_before * Purpose: Add options to the top of the radio buttons section of the Edit Display Options screen -ucp_prefs_view_radio_buttons_after +ucp_prefs_view_radio_buttons_append === * Locations: + styles/prosilver/template/ucp_prefs_view.html @@ -163,7 +163,7 @@ ucp_prefs_view_radio_buttons_after * Purpose: Add options to the bottom of the radio buttons section of the Edit Display Options screen -ucp_prefs_view_select_menu_before +ucp_prefs_view_select_menu_prepend === * Locations: + styles/prosilver/template/ucp_prefs_view.html @@ -171,7 +171,7 @@ ucp_prefs_view_select_menu_before * Purpose: Add options to the top of the drop down menus section of the Edit Display Options screen -ucp_prefs_view_select_menu_after +ucp_prefs_view_select_menu_append === * Locations: + styles/prosilver/template/ucp_prefs_view.html diff --git a/phpBB/styles/prosilver/template/ucp_prefs_personal.html b/phpBB/styles/prosilver/template/ucp_prefs_personal.html index 4484dd7a55..8111496dcb 100644 --- a/phpBB/styles/prosilver/template/ucp_prefs_personal.html +++ b/phpBB/styles/prosilver/template/ucp_prefs_personal.html @@ -9,7 +9,7 @@

    {ERROR}

    - +
    @@ -72,7 +72,7 @@
    - +
    diff --git a/phpBB/styles/prosilver/template/ucp_prefs_post.html b/phpBB/styles/prosilver/template/ucp_prefs_post.html index 2b8fea832a..891e49af6f 100644 --- a/phpBB/styles/prosilver/template/ucp_prefs_post.html +++ b/phpBB/styles/prosilver/template/ucp_prefs_post.html @@ -8,7 +8,7 @@

    {ERROR}

    - +
    @@ -37,7 +37,7 @@
    - +
    diff --git a/phpBB/styles/prosilver/template/ucp_prefs_view.html b/phpBB/styles/prosilver/template/ucp_prefs_view.html index 55e5531075..7f8d0a344c 100644 --- a/phpBB/styles/prosilver/template/ucp_prefs_view.html +++ b/phpBB/styles/prosilver/template/ucp_prefs_view.html @@ -9,7 +9,7 @@

    {ERROR}

    - +
    @@ -54,9 +54,9 @@
    - +
    - +
    {S_TOPIC_SORT_DAYS}
    @@ -82,7 +82,7 @@
    {S_POST_SORT_DIR}
    - +
    diff --git a/phpBB/styles/subsilver2/template/ucp_prefs_personal.html b/phpBB/styles/subsilver2/template/ucp_prefs_personal.html index f39090c8fe..cd5fc9a13f 100644 --- a/phpBB/styles/subsilver2/template/ucp_prefs_personal.html +++ b/phpBB/styles/subsilver2/template/ucp_prefs_personal.html @@ -29,7 +29,7 @@ {ERROR} - + {L_SHOW_EMAIL}{L_COLON} checked="checked" />{L_YES}   checked="checked" />{L_NO} @@ -76,7 +76,7 @@
    style="display:none;">
    - + {S_HIDDEN_FIELDS}   diff --git a/phpBB/styles/subsilver2/template/ucp_prefs_post.html b/phpBB/styles/subsilver2/template/ucp_prefs_post.html index 5dcd431e82..0a558b863c 100644 --- a/phpBB/styles/subsilver2/template/ucp_prefs_post.html +++ b/phpBB/styles/subsilver2/template/ucp_prefs_post.html @@ -9,7 +9,7 @@ {ERROR} - + {L_DEFAULT_BBCODE}{L_COLON} checked="checked" />{L_YES}    checked="checked" />{L_NO} @@ -26,7 +26,7 @@ {L_DEFAULT_NOTIFY}{L_COLON} checked="checked" />{L_YES}    checked="checked" />{L_NO} - + {S_HIDDEN_FIELDS}   diff --git a/phpBB/styles/subsilver2/template/ucp_prefs_view.html b/phpBB/styles/subsilver2/template/ucp_prefs_view.html index c9336a4da5..c10c458627 100644 --- a/phpBB/styles/subsilver2/template/ucp_prefs_view.html +++ b/phpBB/styles/subsilver2/template/ucp_prefs_view.html @@ -9,7 +9,7 @@ {ERROR} - + {L_VIEW_IMAGES}{L_COLON} checked="checked" />{L_YES}    checked="checked" />{L_NO} @@ -36,11 +36,11 @@ checked="checked" />{L_YES}    checked="checked" />{L_NO} - + - + {L_VIEW_TOPICS_DAYS}{L_COLON} {S_TOPIC_SORT_DAYS} @@ -68,7 +68,7 @@ {L_VIEW_POSTS_DIR}{L_COLON} {S_POST_SORT_DIR} - + {S_HIDDEN_FIELDS}   From 9ea9afd1c431c8b6531adeac38b928f1ed6ba709 Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Sat, 27 Jul 2013 09:19:34 -0700 Subject: [PATCH 2370/2494] [ticket/11747] Tweak some of the wording in the events doc PHPBB3-11747 --- phpBB/docs/events.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/phpBB/docs/events.md b/phpBB/docs/events.md index f6a92aaf69..300498b063 100644 --- a/phpBB/docs/events.md +++ b/phpBB/docs/events.md @@ -124,35 +124,35 @@ ucp_prefs_personal_prepend * Locations: + styles/prosilver/template/ucp_prefs_personal.html + styles/subsilver2/template/ucp_prefs_personal.html -* Purpose: Add user options to the top of the Edit Global Settings screen +* Purpose: Add user options to the top of the Edit Global Settings block ucp_prefs_personal_append === * Locations: + styles/prosilver/template/ucp_prefs_personal.html + styles/subsilver2/template/ucp_prefs_personal.html -* Purpose: Add user options to the bottom of the Edit Global Settings screen +* Purpose: Add user options to the bottom of the Edit Global Settings block ucp_prefs_post_prepend === * Locations: + styles/prosilver/template/ucp_prefs_post.html + styles/subsilver2/template/ucp_prefs_post.html -* Purpose: Add user options to the top of the Edit Posting Defaults screen +* Purpose: Add user options to the top of the Edit Posting Defaults block ucp_prefs_post_append === * Locations: + styles/prosilver/template/ucp_prefs_post.html + styles/subsilver2/template/ucp_prefs_post.html -* Purpose: Add user options to the bottom of the Edit Posting Defaults screen +* Purpose: Add user options to the bottom of the Edit Posting Defaults block ucp_prefs_view_radio_buttons_prepend === * Locations: + styles/prosilver/template/ucp_prefs_view.html + styles/subsilver2/template/ucp_prefs_view.html -* Purpose: Add options to the top of the radio buttons section of the Edit +* Purpose: Add options to the top of the radio buttons block of the Edit Display Options screen ucp_prefs_view_radio_buttons_append @@ -160,7 +160,7 @@ ucp_prefs_view_radio_buttons_append * Locations: + styles/prosilver/template/ucp_prefs_view.html + styles/subsilver2/template/ucp_prefs_view.html -* Purpose: Add options to the bottom of the radio buttons section of the Edit +* Purpose: Add options to the bottom of the radio buttons block of the Edit Display Options screen ucp_prefs_view_select_menu_prepend @@ -168,7 +168,7 @@ ucp_prefs_view_select_menu_prepend * Locations: + styles/prosilver/template/ucp_prefs_view.html + styles/subsilver2/template/ucp_prefs_view.html -* Purpose: Add options to the top of the drop down menus section of the Edit +* Purpose: Add options to the top of the drop-down lists block of the Edit Display Options screen ucp_prefs_view_select_menu_append @@ -176,7 +176,7 @@ ucp_prefs_view_select_menu_append * Locations: + styles/prosilver/template/ucp_prefs_view.html + styles/subsilver2/template/ucp_prefs_view.html -* Purpose: Add options to the bottom of the drop down menus section of the Edit +* Purpose: Add options to the bottom of the drop-down lists block of the Edit Display Options screen viewtopic_print_head_append From 9e68404de5277de23baa153a29f4a3825e233e1e Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Sat, 27 Jul 2013 10:44:39 -0700 Subject: [PATCH 2371/2494] [ticket/11749] PHP Events for search.php PHPBB3-11749 --- phpBB/search.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/phpBB/search.php b/phpBB/search.php index 8bcbfc498b..d0484bf598 100644 --- a/phpBB/search.php +++ b/phpBB/search.php @@ -687,6 +687,18 @@ if ($keywords || $author || $author_id || $search_id || $submit) $tracking_topics = ($tracking_topics) ? tracking_unserialize($tracking_topics) : array(); } + /** + * Event to modify the SQL query before the topic data is retrieved + * + * @event core.search_get_topic_data + * @var string sql_select The SQL SELECT string used by search to get topic data + * @var string sql_from The SQL FROM string used by search to get topic data + * @var string sql_where The SQL WHERE string used by search to get topic data + * @since 3.1-A1 + */ + $vars = array('sql_select', 'sql_from', 'sql_where'); + extract($phpbb_dispatcher->trigger_event('core.search_get_topic_data', compact($vars))); + $sql = "SELECT $sql_select FROM $sql_from WHERE $sql_where"; @@ -989,6 +1001,17 @@ if ($keywords || $author || $author_id || $search_id || $submit) ); } + /** + * Modify the topic data before it is assigned to the template + * + * @event core.search_modify_tpl_ary + * @var array row Array with topic data + * @var array tpl_ary Template block array with topic data + * @since 3.1-A1 + */ + $vars = array('row', 'tpl_ary'); + extract($phpbb_dispatcher->trigger_event('core.search_modify_tpl_ary', compact($vars))); + $template->assign_block_vars('searchresults', array_merge($tpl_ary, array( 'FORUM_ID' => $forum_id, 'TOPIC_ID' => $result_topic_id, From 9ffb150d47d3db42c1816ffa662e73046a1b5d03 Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Sat, 27 Jul 2013 10:45:40 -0700 Subject: [PATCH 2372/2494] [ticket/11749] PHP Events for viewforum.php PHPBB3-11749 --- phpBB/viewforum.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/phpBB/viewforum.php b/phpBB/viewforum.php index 5a59e021b3..1fa2030671 100644 --- a/phpBB/viewforum.php +++ b/phpBB/viewforum.php @@ -372,6 +372,16 @@ $sql_array = array( 'LEFT_JOIN' => array(), ); +/** +* Event to modify the SQL query before the topic data is retrieved +* +* @event core.viewforum_get_topic_data +* @var array sql_array The SQL array to get the data of all topics +* @since 3.1-A1 +*/ +$vars = array('sql_array'); +extract($phpbb_dispatcher->trigger_event('core.viewforum_get_topic_data', compact($vars))); + $sql_approved = ' AND ' . $phpbb_content_visibility->get_visibility_sql('topic', $forum_id, 't.'); if ($user->data['is_registered']) @@ -554,6 +564,17 @@ if (sizeof($shadow_topic_list)) $sql = 'SELECT * FROM ' . TOPICS_TABLE . ' WHERE ' . $db->sql_in_set('topic_id', array_keys($shadow_topic_list)); + + /** + * Event to modify the SQL query before the shadowtopic data is retrieved + * + * @event core.viewforum_get_shadowtopic_data + * @var string sql The SQL string to get the data of any shadowtopics + * @since 3.1-A1 + */ + $vars = array('sql'); + extract($phpbb_dispatcher->trigger_event('core.viewforum_get_shadowtopic_data', compact($vars))); + $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) From 8e636e4572ef11af61f2b2c6dfb56d7a9530c8de Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Sat, 27 Jul 2013 10:48:40 -0700 Subject: [PATCH 2373/2494] [ticket/11749] Template events for topic_list_row_pre/append PHPBB3-11749 --- phpBB/docs/events.md | 18 ++++++++++++++++++ .../prosilver/template/search_results.html | 2 ++ .../prosilver/template/viewforum_body.html | 2 ++ .../subsilver2/template/search_results.html | 2 ++ .../subsilver2/template/viewforum_body.html | 4 ++++ 5 files changed, 28 insertions(+) diff --git a/phpBB/docs/events.md b/phpBB/docs/events.md index 3723bf7b3f..855f238653 100644 --- a/phpBB/docs/events.md +++ b/phpBB/docs/events.md @@ -114,6 +114,24 @@ simple_footer_after * Location: styles/prosilver/template/simple_footer.html * Purpose: Add content directly prior to the `` tag of the simple footer +topiclist_row_prepend +=== +* Locations: + + styles/prosilver/template/search_results.html + + styles/prosilver/template/viewforum_body.html + + styles/subsilver2/template/search_results.html + + styles/subsilver2/template/viewforum_body.html +* Purpose: Add content into topic rows (inside the elements containing topic titles) + +topiclist_row_append +=== +* Locations: + + styles/prosilver/template/search_results.html + + styles/prosilver/template/viewforum_body.html + + styles/subsilver2/template/search_results.html + + styles/subsilver2/template/viewforum_body.html +* Purpose: Add content into topic rows (inside the elements containing topic titles) + ucp_pm_viewmessage_print_head_append === * Location: styles/prosilver/template/ucp_pm_viewmessage_print.html diff --git a/phpBB/styles/prosilver/template/search_results.html b/phpBB/styles/prosilver/template/search_results.html index f0424c45db..54e8867526 100644 --- a/phpBB/styles/prosilver/template/search_results.html +++ b/phpBB/styles/prosilver/template/search_results.html @@ -63,6 +63,7 @@
    style="background-image: url({T_ICONS_PATH}{searchresults.TOPIC_ICON_IMG}); background-repeat: no-repeat;" title="{searchresults.TOPIC_FOLDER_IMG_ALT}">
    + {NEWEST_POST_IMG} {searchresults.TOPIC_TITLE} {searchresults.ATTACH_ICON_IMG} {searchresults.UNAPPROVED_IMG} @@ -83,6 +84,7 @@
    {L_POST_BY_AUTHOR} {searchresults.TOPIC_AUTHOR_FULL} » {searchresults.FIRST_POST_TIME} » {L_IN} {searchresults.FORUM_TITLE} +
    diff --git a/phpBB/styles/prosilver/template/viewforum_body.html b/phpBB/styles/prosilver/template/viewforum_body.html index 69b0608a64..ecd993d7fb 100644 --- a/phpBB/styles/prosilver/template/viewforum_body.html +++ b/phpBB/styles/prosilver/template/viewforum_body.html @@ -144,6 +144,7 @@
    style="background-image: url({T_ICONS_PATH}{topicrow.TOPIC_ICON_IMG}); background-repeat: no-repeat;" title="{topicrow.TOPIC_FOLDER_IMG_ALT}">
    + {NEWEST_POST_IMG} {topicrow.TOPIC_TITLE} {topicrow.UNAPPROVED_IMG} {DELETED_IMG} @@ -164,6 +165,7 @@ {topicrow.ATTACH_ICON_IMG} {L_POST_BY_AUTHOR} {topicrow.TOPIC_AUTHOR_FULL} » {topicrow.FIRST_POST_TIME} » {L_IN} {topicrow.FORUM_NAME} +
    {topicrow.REPLIES} {L_REPLIES}
    diff --git a/phpBB/styles/subsilver2/template/search_results.html b/phpBB/styles/subsilver2/template/search_results.html index d98079de20..19ba0b196a 100644 --- a/phpBB/styles/subsilver2/template/search_results.html +++ b/phpBB/styles/subsilver2/template/search_results.html @@ -34,6 +34,7 @@ + {NEWEST_POST_IMG} {searchresults.ATTACH_ICON_IMG} {searchresults.TOPIC_TITLE} @@ -58,6 +59,7 @@ ]

    {L_IN} {searchresults.FORUM_TITLE}

    +

    {searchresults.TOPIC_AUTHOR_FULL}

    {searchresults.TOPIC_REPLIES}

    diff --git a/phpBB/styles/subsilver2/template/viewforum_body.html b/phpBB/styles/subsilver2/template/viewforum_body.html index d07e9a1372..dfbe0a605b 100644 --- a/phpBB/styles/subsilver2/template/viewforum_body.html +++ b/phpBB/styles/subsilver2/template/viewforum_body.html @@ -40,6 +40,7 @@ + {NEWEST_POST_IMG} {topicrow.ATTACH_ICON_IMG} {topicrow.TOPIC_TYPE} {topicrow.TOPIC_TITLE} @@ -63,6 +64,7 @@ ]

    +

    {topicrow.TOPIC_AUTHOR_FULL}

    {topicrow.REPLIES}

    @@ -203,6 +205,7 @@ + {NEWEST_POST_IMG} {topicrow.ATTACH_ICON_IMG} {topicrow.TOPIC_TYPE} {topicrow.TOPIC_TITLE} @@ -227,6 +230,7 @@ ]

    {L_IN} {topicrow.FORUM_NAME}

    +

    {topicrow.TOPIC_AUTHOR_FULL}

    {topicrow.REPLIES}

    From d8584877a19ece5b5d6cd1d0ec752905ef8501e7 Mon Sep 17 00:00:00 2001 From: Oliver Schramm Date: Sat, 27 Jul 2013 22:37:44 +0200 Subject: [PATCH 2374/2494] [ticket/10917] Revert use of phpbb wrapper PHPBB3-10917 --- phpBB/install/install_update.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php index 9ac17e7579..e8fcabfc2d 100644 --- a/phpBB/install/install_update.php +++ b/phpBB/install/install_update.php @@ -204,7 +204,7 @@ class install_update extends module } // Check if the update files stored are for the latest version... - if (phpbb_version_compare($this->latest_version, $this->update_info['version']['to'], '>')) + if (version_compare(strtolower($this->latest_version), strtolower($this->update_info['version']['to']), '>')) { $this->unequal_version = true; From d5c56c5d503ea4b12852866e2d3b956e92a92aea Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Sat, 27 Jul 2013 20:02:03 -0500 Subject: [PATCH 2375/2494] [ticket/11724] Support "ELSE IF" and "ELSEIF" in the same way PHPBB3-11724 --- phpBB/phpbb/template/twig/lexer.php | 3 ++- tests/template/template_test.php | 7 +++++++ tests/template/templates/if.html | 2 ++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/phpBB/phpbb/template/twig/lexer.php b/phpBB/phpbb/template/twig/lexer.php index 4f88147542..1a640e559e 100644 --- a/phpBB/phpbb/template/twig/lexer.php +++ b/phpBB/phpbb/template/twig/lexer.php @@ -236,7 +236,8 @@ class phpbb_template_twig_lexer extends Twig_Lexer // Replace our "div by" with Twig's divisibleby (Twig does not like test names with spaces) $code = preg_replace('# div by ([0-9]+)#', ' divisibleby($1)', $code); - return preg_replace_callback('##', $callback, $code); + // (ELSE)?\s?IF; match IF|ELSEIF|ELSE IF; replace ELSE IF with ELSEIF + return preg_replace_callback('##', $callback, $code); } /** diff --git a/tests/template/template_test.php b/tests/template/template_test.php index dd9ba21c26..2a40107d90 100644 --- a/tests/template/template_test.php +++ b/tests/template/template_test.php @@ -62,6 +62,13 @@ class phpbb_template_template_test extends phpbb_template_template_test_case array(), '1!false', ), + array( + 'if.html', + array('S_OTHER_OTHER_VALUE' => true), + array(), + array(), + '|S_OTHER_OTHER_VALUE|!false', + ), array( 'if.html', array('S_VALUE' => false, 'S_OTHER_VALUE' => true), diff --git a/tests/template/templates/if.html b/tests/template/templates/if.html index c010aff7fa..f6ab6e575a 100644 --- a/tests/template/templates/if.html +++ b/tests/template/templates/if.html @@ -2,6 +2,8 @@ 1 2 + +|S_OTHER_OTHER_VALUE| 03 From dd875f13e875a726c9ea4654a90a74878658e423 Mon Sep 17 00:00:00 2001 From: Oliver Schramm Date: Sun, 28 Jul 2013 02:35:01 +0200 Subject: [PATCH 2376/2494] [ticket/10917] Variable used only once so delete it The variable $this->unequal_version was only used once and only to display the version the package updates to. To display the version it updates to makes no sense when the update files just aren't meant to update from the current version. (It's already shown in an error message) So I deleted the variable from there. Furthermore the use of version_compare makes the variable useless in that context which is why I deleted the variable from the whole file and replaced it in the relevant if statement with the old comparison. PHPBB3-10917 --- phpBB/install/install_update.php | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php index e8fcabfc2d..2f3ee1c55a 100644 --- a/phpBB/install/install_update.php +++ b/phpBB/install/install_update.php @@ -58,7 +58,6 @@ class install_update extends module var $new_location; var $latest_version; var $current_version; - var $unequal_version; var $update_to_version; @@ -76,7 +75,6 @@ class install_update extends module $this->tpl_name = 'install_update'; $this->page_title = 'UPDATE_INSTALLATION'; - $this->unequal_version = false; $this->old_location = $phpbb_root_path . 'install/update/old/'; $this->new_location = $phpbb_root_path . 'install/update/new/'; @@ -195,8 +193,6 @@ class install_update extends module // Check if the update files are actually meant to update from the current version if ($this->current_version != $this->update_info['version']['from']) { - $this->unequal_version = true; - $template->assign_vars(array( 'S_ERROR' => true, 'ERROR_MSG' => sprintf($user->lang['INCOMPATIBLE_UPDATE_FILES'], $this->current_version, $this->update_info['version']['from'], $this->update_info['version']['to']), @@ -206,8 +202,6 @@ class install_update extends module // Check if the update files stored are for the latest version... if (version_compare(strtolower($this->latest_version), strtolower($this->update_info['version']['to']), '>')) { - $this->unequal_version = true; - $template->assign_vars(array( 'S_WARNING' => true, 'WARNING_MSG' => sprintf($user->lang['OLD_UPDATE_FILES'], $this->update_info['version']['from'], $this->update_info['version']['to'], $this->latest_version)) @@ -294,7 +288,7 @@ class install_update extends module ); // Print out version the update package updates to - if ($this->unequal_version) + if ($this->latest_version != $this->update_info['version']['to']) { $template->assign_var('PACKAGE_VERSION', $this->update_info['version']['to']); } From 0215e0bd95104c628cf084e1be0df72b2752346c Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Sun, 28 Jul 2013 21:31:12 -0500 Subject: [PATCH 2377/2494] [ticket/11724] Replace spaces with tabs PHPBB3-11724 --- phpBB/phpbb/template/twig/lexer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/phpbb/template/twig/lexer.php b/phpBB/phpbb/template/twig/lexer.php index 1a640e559e..7cb84167bf 100644 --- a/phpBB/phpbb/template/twig/lexer.php +++ b/phpBB/phpbb/template/twig/lexer.php @@ -237,7 +237,7 @@ class phpbb_template_twig_lexer extends Twig_Lexer $code = preg_replace('# div by ([0-9]+)#', ' divisibleby($1)', $code); // (ELSE)?\s?IF; match IF|ELSEIF|ELSE IF; replace ELSE IF with ELSEIF - return preg_replace_callback('##', $callback, $code); + return preg_replace_callback('##', $callback, $code); } /** From 9902f1c75178aa72d3b89f51033fcda552141b40 Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Mon, 29 Jul 2013 00:05:31 -0700 Subject: [PATCH 2378/2494] [ticket/11749] Move event after all template data has been defined PHPBB3-11749 --- phpBB/search.php | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/phpBB/search.php b/phpBB/search.php index d0484bf598..40c0b9a8ce 100644 --- a/phpBB/search.php +++ b/phpBB/search.php @@ -1001,18 +1001,7 @@ if ($keywords || $author || $author_id || $search_id || $submit) ); } - /** - * Modify the topic data before it is assigned to the template - * - * @event core.search_modify_tpl_ary - * @var array row Array with topic data - * @var array tpl_ary Template block array with topic data - * @since 3.1-A1 - */ - $vars = array('row', 'tpl_ary'); - extract($phpbb_dispatcher->trigger_event('core.search_modify_tpl_ary', compact($vars))); - - $template->assign_block_vars('searchresults', array_merge($tpl_ary, array( + $tpl_ary = array_merge($tpl_ary, array( 'FORUM_ID' => $forum_id, 'TOPIC_ID' => $result_topic_id, 'POST_ID' => ($show_results == 'posts') ? $row['post_id'] : false, @@ -1024,9 +1013,22 @@ if ($keywords || $author || $author_id || $search_id || $submit) 'U_VIEW_TOPIC' => $view_topic_url, 'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $forum_id), - 'U_VIEW_POST' => (!empty($row['post_id'])) ? append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=" . $row['topic_id'] . '&p=' . $row['post_id'] . (($u_hilit) ? '&hilit=' . $u_hilit : '')) . '#p' . $row['post_id'] : '') + 'U_VIEW_POST' => (!empty($row['post_id'])) ? append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=" . $row['topic_id'] . '&p=' . $row['post_id'] . (($u_hilit) ? '&hilit=' . $u_hilit : '')) . '#p' . $row['post_id'] : '', )); + /** + * Modify the topic data before it is assigned to the template + * + * @event core.search_modify_tpl_ary + * @var array row Array with topic data + * @var array tpl_ary Template block array with topic data + * @since 3.1-A1 + */ + $vars = array('row', 'tpl_ary'); + extract($phpbb_dispatcher->trigger_event('core.search_modify_tpl_ary', compact($vars))); + + $template->assign_block_vars('searchresults', $tpl_ary); + if ($show_results == 'topics') { phpbb_generate_template_pagination($template, $view_topic_url, 'searchresults.pagination', 'start', $replies + 1, $config['posts_per_page'], 1, true, true); From b8fef3b33a5c04c6637667b0a9a9f3b24ba2c594 Mon Sep 17 00:00:00 2001 From: Bruno Ais Date: Mon, 29 Jul 2013 16:55:58 +0100 Subject: [PATCH 2379/2494] [ticket/11640] removed the space that I wonder what it was doing there. sub-task of ticket PHPBB3-11635: find and fix all bypasses of generate_text_for_* PHPBB3-11640 --- phpBB/includes/functions_privmsgs.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/functions_privmsgs.php b/phpBB/includes/functions_privmsgs.php index 15907feedd..5fc6de8e02 100644 --- a/phpBB/includes/functions_privmsgs.php +++ b/phpBB/includes/functions_privmsgs.php @@ -2022,7 +2022,7 @@ function message_history($msg_id, $user_id, $message_row, $folder, $in_post_mode $parse_flags = ($row['bbcode_bitfield'] ? OPTION_FLAG_BBCODE : 0); $parse_flags |= ($row['enable_smilies'] ? OPTION_FLAG_SMILIES : 0); - $message = generate_text_for_display($message, $row['bbcode_uid'], $row['bbcode_bitfield'], $parse_flags , false); + $message = generate_text_for_display($message, $row['bbcode_uid'], $row['bbcode_bitfield'], $parse_flags, false); $subject = censor_text($subject); From ccc5c5f6b8c197c0f96349e139472ddbe17f19ce Mon Sep 17 00:00:00 2001 From: Bruno Ais Date: Mon, 29 Jul 2013 17:00:51 +0100 Subject: [PATCH 2380/2494] [ticket/11638] Changed the layout to match the other similar commits sub-task of ticket PHPBB3-11635: find and fix all bypasses of generate_text_for_* PHPBB3-11638 --- phpBB/viewtopic.php | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index 64006fbe61..a24c40f697 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -828,19 +828,14 @@ if (!empty($topic_data['poll_start'])) $poll_total += $poll_option['poll_option_total']; } - $parse_bbcode_flags = OPTION_FLAG_SMILIES; - - if (empty($poll_info[0]['bbcode_bitfield'])) - { - $parse_bbcode_flags |= OPTION_FLAG_BBCODE; - } + $parse_flags = ($row['bbcode_bitfield'] ? OPTION_FLAG_BBCODE : 0) | OPTION_FLAG_SMILIES; for ($i = 0, $size = sizeof($poll_info); $i < $size; $i++) { - $poll_info[$i]['poll_option_text'] = generate_text_for_display($poll_info[$i]['poll_option_text'], $poll_info[$i]['bbcode_uid'], $poll_option['bbcode_bitfield'], $parse_bbcode_flags, true); + $poll_info[$i]['poll_option_text'] = generate_text_for_display($poll_info[$i]['poll_option_text'], $poll_info[$i]['bbcode_uid'], $poll_option['bbcode_bitfield'], $parse_flags, true); } - $topic_data['poll_title'] = generate_text_for_display($topic_data['poll_title'], $poll_info[0]['bbcode_uid'], $poll_info[0]['bbcode_bitfield'], $parse_bbcode_flags, true); + $topic_data['poll_title'] = generate_text_for_display($topic_data['poll_title'], $poll_info[0]['bbcode_uid'], $poll_info[0]['bbcode_bitfield'], $parse_flags, true); foreach ($poll_info as $poll_option) { From 5bb08a1ab973ee13237876d11b001c4ed6658892 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 29 Jul 2013 21:30:01 +0200 Subject: [PATCH 2381/2494] [ticket/11574] Change order of files and database update PHPBB3-11574 --- phpBB/adm/style/install_update.html | 46 ++++++++++++++--------------- phpBB/install/database_update.php | 3 +- phpBB/install/index.php | 2 +- phpBB/install/install_update.php | 33 ++++++++++++++++----- phpBB/language/en/install.php | 6 ++-- 5 files changed, 55 insertions(+), 35 deletions(-) diff --git a/phpBB/adm/style/install_update.html b/phpBB/adm/style/install_update.html index b5fa46dbf6..bd46f7877e 100644 --- a/phpBB/adm/style/install_update.html +++ b/phpBB/adm/style/install_update.html @@ -109,27 +109,14 @@ - +
    - +
    +

    {L_CHECK_FILES_EXPLAIN}

    + +
    -
    -

    {L_UPDATE_DATABASE_EXPLAIN}

    - -
    - -
    - - -
    - -
    -

    {L_CHECK_FILES_UP_TO_DATE}

    - -
    - -
    - + @@ -155,6 +142,11 @@ +
    +

    {L_UPDATE_DB_SUCCESS}

    +

    {L_EVERYTHING_UP_TO_DATE}

    +
    +

    {L_UPDATE_DB_SUCCESS}



    @@ -174,10 +166,18 @@ -
    -

    {L_UPDATE_SUCCESS}

    -

    {L_ALL_FILES_UP_TO_DATE}

    -
    +

    {L_UPDATE_FILE_SUCCESS}

    +

    {L_ALL_FILES_UP_TO_DATE}

    + +

    {L_UPDATE_DATABASE_EXPLAIN}

    + +
    + +
    + +
    + +

    {L_COLLECTED_INFORMATION}

    diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 44cbc74d29..f69f0f6986 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -110,6 +110,7 @@ phpbb_require_updated('includes/functions_container.' . $phpEx); require($phpbb_root_path . 'config.' . $phpEx); phpbb_require_updated('includes/constants.' . $phpEx); +phpbb_include_updated('includes/utf/utf_normalizer.' . $phpEx); phpbb_require_updated('includes/utf/utf_tools.' . $phpEx); // Set PHP error handler to ours @@ -305,7 +306,7 @@ echo $user->lang['DATABASE_UPDATE_COMPLETE'] . '
    '; if ($request->variable('type', 0)) { echo $user->lang['INLINE_UPDATE_SUCCESSFUL'] . '

    '; - echo '' . $user->lang['CONTINUE_UPDATE_NOW'] . ''; + echo '' . $user->lang['CONTINUE_UPDATE_NOW'] . ''; } else { diff --git a/phpBB/install/index.php b/phpBB/install/index.php index fe61c53558..bd39e231f4 100644 --- a/phpBB/install/index.php +++ b/phpBB/install/index.php @@ -250,7 +250,7 @@ $template = new phpbb_template_twig($phpbb_root_path, $phpEx, $config, $user, ne $phpbb_style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $phpbb_style_resource_locator, $phpbb_style_path_provider, $template); $phpbb_style->set_ext_dir_prefix('adm/'); -$paths = array($phpbb_admin_path . 'style', $phpbb_root_path . 'install/update/new/adm/style'); +$paths = array($phpbb_root_path . 'install/update/new/adm/style', $phpbb_admin_path . 'style'); $paths = array_filter($paths, 'is_dir'); $phpbb_style->set_custom_style('admin', $paths, array(), ''); diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php index 478cc9f76f..a8abfc7cfc 100644 --- a/phpBB/install/install_update.php +++ b/phpBB/install/install_update.php @@ -39,7 +39,7 @@ if (!empty($setmodules)) 'module_filename' => substr(basename(__FILE__), 0, -strlen($phpEx)-1), 'module_order' => 30, 'module_subs' => '', - 'module_stages' => array('INTRO', 'VERSION_CHECK', 'UPDATE_DB', 'FILE_CHECK', 'UPDATE_FILES'), + 'module_stages' => array('INTRO', 'VERSION_CHECK', 'FILE_CHECK', 'UPDATE_FILES', 'UPDATE_DB'), 'module_reqs' => '' ); } @@ -74,6 +74,11 @@ class install_update extends module global $phpbb_style, $template, $phpEx, $phpbb_root_path, $user, $db, $config, $cache, $auth, $language; global $request, $phpbb_admin_path, $phpbb_adm_relative_path, $phpbb_container; + // We must enable super globals, otherwise creating a new instance of the request class, + // using the new container with a dbal connection will fail with the following PHP Notice: + // Object of class phpbb_request_deactivated_super_global could not be converted to int + $request->enable_super_globals(); + // Create a normal container now $phpbb_container = phpbb_create_update_container($phpbb_root_path, $phpEx, $phpbb_root_path . 'install/update/new/config'); @@ -138,7 +143,9 @@ class install_update extends module } // Set custom template again. ;) - $phpbb_style->set_custom_style('admin', $phpbb_admin_path . 'style', array(), ''); + $paths = array($phpbb_root_path . 'install/update/new/adm/style', $phpbb_admin_path . 'style'); + $paths = array_filter($paths, 'is_dir'); + $phpbb_style->set_custom_style('admin', $paths, array(), ''); $template->assign_vars(array( 'S_USER_LANG' => $user->lang['USER_LANG'], @@ -267,15 +274,14 @@ class install_update extends module $this->page_title = 'STAGE_VERSION_CHECK'; $template->assign_vars(array( - 'S_UP_TO_DATE' => $up_to_date, 'S_VERSION_CHECK' => true, - 'U_ACTION' => append_sid($this->p_master->module_url, "language=$language&mode=$mode&sub=file_check"), - 'U_DB_UPDATE_ACTION' => append_sid($this->p_master->module_url, "language=$language&mode=$mode&sub=update_db"), + 'U_ACTION' => append_sid($this->p_master->module_url, "language=$language&mode=$mode&sub=file_check"), + 'S_UP_TO_DATE' => $up_to_date, 'LATEST_VERSION' => $this->latest_version, - 'CURRENT_VERSION' => $this->current_version) - ); + 'CURRENT_VERSION' => $this->current_version, + )); // Print out version the update package updates to if ($this->unequal_version) @@ -303,6 +309,7 @@ class install_update extends module 'U_DB_UPDATE' => append_sid($phpbb_root_path . 'install/database_update.' . $phpEx, 'type=1&language=' . $user->data['user_lang']), 'U_DB_UPDATE_ACTION' => append_sid($this->p_master->module_url, "language=$language&mode=$mode&sub=update_db"), 'U_ACTION' => append_sid($this->p_master->module_url, "language=$language&mode=$mode&sub=file_check"), + 'L_EVERYTHING_UP_TO_DATE' => $user->lang('EVERYTHING_UP_TO_DATE', append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=login'), append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=login&redirect=' . $phpbb_adm_relative_path . 'index.php%3Fi=send_statistics%26mode=send_statistics')), )); break; @@ -470,13 +477,23 @@ class install_update extends module $template->assign_vars(array( 'S_FILE_CHECK' => true, 'S_ALL_UP_TO_DATE' => $all_up_to_date, - 'L_ALL_FILES_UP_TO_DATE' => $user->lang('ALL_FILES_UP_TO_DATE', append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=login'), append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=login&redirect=' . $phpbb_adm_relative_path . 'index.php%3Fi=send_statistics%26mode=send_statistics')), 'S_VERSION_UP_TO_DATE' => $up_to_date, + 'S_UP_TO_DATE' => $up_to_date, 'U_ACTION' => append_sid($this->p_master->module_url, "language=$language&mode=$mode&sub=file_check"), 'U_UPDATE_ACTION' => append_sid($this->p_master->module_url, "language=$language&mode=$mode&sub=update_files"), 'U_DB_UPDATE_ACTION' => append_sid($this->p_master->module_url, "language=$language&mode=$mode&sub=update_db"), )); + // Since some people try to update to RC releases, but phpBB.com tells them the last version is the version they currently run + // we are faced with the updater thinking the database schema is up-to-date; which it is, but should be updated none-the-less + // We now try to cope with this by triggering the update process + if (version_compare(str_replace('rc', 'RC', strtolower($this->current_version)), str_replace('rc', 'RC', strtolower($this->update_info['version']['to'])), '<')) + { + $template->assign_vars(array( + 'S_UP_TO_DATE' => false, + )); + } + if ($all_up_to_date) { global $phpbb_container; diff --git a/phpBB/language/en/install.php b/phpBB/language/en/install.php index be45047861..f994f339a9 100644 --- a/phpBB/language/en/install.php +++ b/phpBB/language/en/install.php @@ -374,7 +374,7 @@ $lang = array_merge($lang, array( // Updater $lang = array_merge($lang, array( - 'ALL_FILES_UP_TO_DATE' => 'All files are up to date with the latest phpBB version. You should now login to your board and check if everything is working fine. Do not forget to delete, rename or move your install directory! Please send us updated information about your server and board configurations from the Send statistics module in your ACP.', + 'ALL_FILES_UP_TO_DATE' => 'All files are up to date with the latest phpBB version.', 'ARCHIVE_FILE' => 'Source file within archive', 'BACK' => 'Back', @@ -419,8 +419,9 @@ $lang = array_merge($lang, array( 'DOWNLOAD_UPDATE_METHOD' => 'Download modified files archive', 'DOWNLOAD_UPDATE_METHOD_EXPLAIN' => 'Once downloaded you should unpack the archive. You will find the modified files you need to upload to your phpBB root directory within it. Please upload the files to their respective locations then. After you have uploaded all files, please check the files again with the other button below.', - 'ERROR' => 'Error', 'EDIT_USERNAME' => 'Edit username', + 'ERROR' => 'Error', + 'EVERYTHING_UP_TO_DATE' => 'Everything is up to date with the latest phpBB version. You should now login to your board and check if everything is working fine. Do not forget to delete, rename or move your install directory! Please send us updated information about your server and board configurations from the Send statistics module in your ACP.', 'FILE_ALREADY_UP_TO_DATE' => 'File is already up to date.', 'FILE_DIFF_NOT_ALLOWED' => 'File not allowed to be diffed.', @@ -570,6 +571,7 @@ $lang = array_merge($lang, array( 'UPLOAD_METHOD' => 'Upload method', 'UPDATE_DB_SUCCESS' => 'Database update was successful.', + 'UPDATE_FILE_SUCCESS' => 'File update was successful.', 'USER_ACTIVE' => 'Active user', 'USER_INACTIVE' => 'Inactive user', From 5f3f41d6d6fb5c997ab7b70482fef542a5534b6a Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 29 Jul 2013 23:47:31 +0200 Subject: [PATCH 2382/2494] [ticket/11574] Remove old "continue step"-message PHPBB3-11574 --- phpBB/adm/style/install_update.html | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/phpBB/adm/style/install_update.html b/phpBB/adm/style/install_update.html index bd46f7877e..57e2c8ffea 100644 --- a/phpBB/adm/style/install_update.html +++ b/phpBB/adm/style/install_update.html @@ -143,23 +143,10 @@
    -

    {L_UPDATE_DB_SUCCESS}

    +

    {L_UPDATE_SUCCESS}

    {L_EVERYTHING_UP_TO_DATE}

    -

    {L_UPDATE_DB_SUCCESS}

    - -

    - -
    - -
    -

    {L_CHECK_FILES_EXPLAIN}

    - -
    - -
    - From 18164e63e2897a755a214b8fcb4b6d84897888e6 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Tue, 30 Jul 2013 01:06:10 +0200 Subject: [PATCH 2383/2494] [ticket/11752] HTTP -> HTTPs in email/installed.txt PHPBB3-11752 --- phpBB/language/en/email/installed.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/language/en/email/installed.txt b/phpBB/language/en/email/installed.txt index 2aa03a7f33..60e52e37c4 100644 --- a/phpBB/language/en/email/installed.txt +++ b/phpBB/language/en/email/installed.txt @@ -12,7 +12,7 @@ Username: {USERNAME} Board URL: {U_BOARD} ---------------------------- -Useful information regarding the phpBB software can be found in the docs folder of your installation and on phpBB.com's support page - http://www.phpbb.com/support/ +Useful information regarding the phpBB software can be found in the docs folder of your installation and on phpBB.com's support page - https://www.phpbb.com/support/ In order to keep your board safe and secure, we highly recommended keeping current with software releases. For your convenience, a mailing list is available at the page referenced above. From 0ff2e93c1937f96f8fcd733a152a0c2f263706b1 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 30 Jul 2013 01:18:32 +0200 Subject: [PATCH 2384/2494] [ticket/11574] Do not display incompatible package note after successful update PHPBB3-11574 --- phpBB/install/install_update.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php index dce0134730..4ae39f202f 100644 --- a/phpBB/install/install_update.php +++ b/phpBB/install/install_update.php @@ -313,6 +313,11 @@ class install_update extends module 'L_EVERYTHING_UP_TO_DATE' => $user->lang('EVERYTHING_UP_TO_DATE', append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=login'), append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=login&redirect=' . $phpbb_adm_relative_path . 'index.php%3Fi=send_statistics%26mode=send_statistics')), )); + // Do not display incompatible package note after successful update + if ($config['version'] == $this->update_info['version']['to']) + { + $template->assign_var('S_ERROR', false); + } break; case 'file_check': From 32499c8808bb72812f66ba00e35c5af128a4d4e2 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 30 Jul 2013 01:38:06 +0200 Subject: [PATCH 2385/2494] [ticket/11574] Remove install/udpate/new/ fallback from database_update.php Since we switched the order, everything should be in the normal root by then. PHPBB3-11574 --- phpBB/install/database_update.php | 67 +++++-------------------------- phpBB/language/en/install.php | 2 +- 2 files changed, 12 insertions(+), 57 deletions(-) diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index f69f0f6986..3be5ea659c 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -21,46 +21,6 @@ define('IN_INSTALL', true); $phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './../'; $phpEx = substr(strrchr(__FILE__, '.'), 1); -if (!function_exists('phpbb_require_updated')) -{ - function phpbb_require_updated($path, $optional = false) - { - global $phpbb_root_path, $table_prefix; - - $new_path = $phpbb_root_path . 'install/update/new/' . $path; - $old_path = $phpbb_root_path . $path; - - if (file_exists($new_path)) - { - require($new_path); - } - else if (!$optional || file_exists($old_path)) - { - require($old_path); - } - } -} - -if (!function_exists('phpbb_include_updated')) -{ - function phpbb_include_updated($path, $optional = false) - { - global $phpbb_root_path; - - $new_path = $phpbb_root_path . 'install/update/new/' . $path; - $old_path = $phpbb_root_path . $path; - - if (file_exists($new_path)) - { - include($new_path); - } - else if (!$optional || file_exists($old_path)) - { - include($old_path); - } - } -} - function phpbb_end_update($cache, $config) { $cache->purge(); @@ -89,7 +49,7 @@ function phpbb_end_update($cache, $config) exit_handler(); } -phpbb_require_updated('includes/startup.' . $phpEx); +require($phpbb_root_path . 'includes/startup.' . $phpEx); include($phpbb_root_path . 'config.' . $phpEx); if (!defined('PHPBB_INSTALLED') || empty($dbms) || empty($acm_type)) @@ -102,33 +62,28 @@ $phpbb_adm_relative_path = (isset($phpbb_adm_relative_path)) ? $phpbb_adm_relati $phpbb_admin_path = (defined('PHPBB_ADMIN_PATH')) ? PHPBB_ADMIN_PATH : $phpbb_root_path . $phpbb_adm_relative_path; // Include files -phpbb_require_updated('phpbb/class_loader.' . $phpEx); +require($phpbb_root_path . 'phpbb/class_loader.' . $phpEx); -phpbb_require_updated('includes/functions.' . $phpEx); -phpbb_require_updated('includes/functions_content.' . $phpEx); -phpbb_require_updated('includes/functions_container.' . $phpEx); +require($phpbb_root_path . 'includes/functions.' . $phpEx); +require($phpbb_root_path . 'includes/functions_content.' . $phpEx); +require($phpbb_root_path . 'includes/functions_container.' . $phpEx); require($phpbb_root_path . 'config.' . $phpEx); -phpbb_require_updated('includes/constants.' . $phpEx); -phpbb_include_updated('includes/utf/utf_normalizer.' . $phpEx); -phpbb_require_updated('includes/utf/utf_tools.' . $phpEx); +require($phpbb_root_path . 'includes/constants.' . $phpEx); +include($phpbb_root_path . 'includes/utf/utf_normalizer.' . $phpEx); +require($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx); // Set PHP error handler to ours set_error_handler(defined('PHPBB_MSG_HANDLER') ? PHPBB_MSG_HANDLER : 'msg_handler'); // Setup class loader first -$phpbb_class_loader_new = new phpbb_class_loader('phpbb_', "{$phpbb_root_path}install/update/new/phpbb/", $phpEx); -$phpbb_class_loader_new->register(); $phpbb_class_loader = new phpbb_class_loader('phpbb_', "{$phpbb_root_path}phpbb/", $phpEx); $phpbb_class_loader->register(); // Set up container (must be done here because extensions table may not exist) -$other_config_path = $phpbb_root_path . 'install/update/new/config/'; -$config_path = file_exists($other_config_path . 'services.yml') ? $other_config_path : $phpbb_root_path . 'config/'; - $container_extensions = array( new phpbb_di_extension_config($phpbb_root_path . 'config.' . $phpEx), - new phpbb_di_extension_core($config_path), + new phpbb_di_extension_core($phpbb_root_path . 'config/'), ); $container_passes = array( new phpbb_di_pass_collection_pass(), @@ -289,8 +244,8 @@ while (!$migrator->finished()) // Are we approaching the time limit? If so we want to pause the update and continue after refreshing if ((time() - $update_start_time) >= $safe_time_limit) { - echo $user->lang['DATABASE_UPDATE_NOT_COMPLETED'] . '
    '; - echo '' . $user->lang['DATABASE_UPDATE_CONTINUE'] . ''; + echo '
    ' . $user->lang['DATABASE_UPDATE_NOT_COMPLETED'] . '

    '; + echo '' . $user->lang['DATABASE_UPDATE_CONTINUE'] . ''; phpbb_end_update($cache, $config); } diff --git a/phpBB/language/en/install.php b/phpBB/language/en/install.php index f994f339a9..03c9562983 100644 --- a/phpBB/language/en/install.php +++ b/phpBB/language/en/install.php @@ -398,7 +398,7 @@ $lang = array_merge($lang, array( 'DATABASE_TYPE' => 'Database type', 'DATABASE_UPDATE_COMPLETE' => 'Database updater has completed!', - 'DATABASE_UPDATE_CONTINUE' => 'Continue database update.', + 'DATABASE_UPDATE_CONTINUE' => 'Continue database update', 'DATABASE_UPDATE_INFO_OLD' => 'The database update file within the install directory is outdated. Please make sure you uploaded the correct version of the file.', 'DATABASE_UPDATE_NOT_COMPLETED' => 'The database update has not yet completed.', 'DELETE_USER_REMOVE' => 'Delete user and remove posts', From 8a6f3a58000b7d969bd9108f2bdb34203354d39b Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Tue, 30 Jul 2013 01:54:11 +0200 Subject: [PATCH 2386/2494] [ticket/11524] Add another isset() to mitigate "Illegal string offset 'limit'" ... on PHP 5.4 or higher. PHPBB3-11524 --- phpBB/develop/mysql_upgrader.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/phpBB/develop/mysql_upgrader.php b/phpBB/develop/mysql_upgrader.php index 05d279a099..17ce12e2bf 100644 --- a/phpBB/develop/mysql_upgrader.php +++ b/phpBB/develop/mysql_upgrader.php @@ -149,7 +149,8 @@ foreach ($schema_data as $table_name => $table_data) list($orig_column_type, $column_length) = explode(':', $column_data[0]); $column_type = sprintf($dbms_type_map['mysql_41'][$orig_column_type . ':'], $column_length); - if (isset($dbms_type_map['mysql_40'][$orig_column_type . ':']['limit'][0])) + if (isset($dbms_type_map['mysql_40'][$orig_column_type . ':']['limit']) && + isset($dbms_type_map['mysql_40'][$orig_column_type . ':']['limit'][0])) { switch ($dbms_type_map['mysql_40'][$orig_column_type . ':']['limit'][0]) { From 404f2881135373060086116003122a9f6d851adf Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Tue, 30 Jul 2013 02:01:24 +0200 Subject: [PATCH 2387/2494] [ticket/11753] Update MySQL upgrader schema data. PHPBB3-11753 --- phpBB/develop/mysql_upgrader.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/phpBB/develop/mysql_upgrader.php b/phpBB/develop/mysql_upgrader.php index 05d279a099..b3f40b2ca4 100644 --- a/phpBB/develop/mysql_upgrader.php +++ b/phpBB/develop/mysql_upgrader.php @@ -694,6 +694,24 @@ function get_schema_struct() ), ); + $schema_data['phpbb_login_attempts'] = array( + 'COLUMNS' => array( + 'attempt_ip' => array('VCHAR:40', ''), + 'attempt_browser' => array('VCHAR:150', ''), + 'attempt_forwarded_for' => array('VCHAR:255', ''), + 'attempt_time' => array('TIMESTAMP', 0), + 'user_id' => array('UINT', 0), + 'username' => array('VCHAR_UNI:255', 0), + 'username_clean' => array('VCHAR_CI', 0), + ), + 'KEYS' => array( + 'att_ip' => array('INDEX', array('attempt_ip', 'attempt_time')), + 'att_for' => array('INDEX', array('attempt_forwarded_for', 'attempt_time')), + 'att_time' => array('INDEX', array('attempt_time')), + 'user_id' => array('INDEX', 'user_id'), + ), + ); + $schema_data['phpbb_moderator_cache'] = array( 'COLUMNS' => array( 'forum_id' => array('UINT', 0), @@ -897,6 +915,7 @@ function get_schema_struct() 'field_default_value' => array('VCHAR_UNI', ''), 'field_validation' => array('VCHAR_UNI:20', ''), 'field_required' => array('BOOL', 0), + 'field_show_novalue' => array('BOOL', 0), 'field_show_on_reg' => array('BOOL', 0), 'field_show_on_vt' => array('BOOL', 0), 'field_show_profile' => array('BOOL', 0), From a3de463b3027733f0560a420fb1c61e5413a8957 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Tue, 30 Jul 2013 02:01:41 +0200 Subject: [PATCH 2388/2494] [ticket/11753] Remove ?> from MySQL Upgrader. PHPBB3-11753 --- phpBB/develop/mysql_upgrader.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/phpBB/develop/mysql_upgrader.php b/phpBB/develop/mysql_upgrader.php index b3f40b2ca4..6dd577ebf7 100644 --- a/phpBB/develop/mysql_upgrader.php +++ b/phpBB/develop/mysql_upgrader.php @@ -1415,5 +1415,3 @@ function get_schema_struct() return $schema_data; } - -?> \ No newline at end of file From c335edc038461449d86c2278cf414f304dcc735b Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Tue, 30 Jul 2013 12:21:34 +0300 Subject: [PATCH 2389/2494] [ticket/11754] Remove styleswitcher leftovers PHPBB3-11754 --- phpBB/includes/functions.php | 2 -- phpBB/styles/prosilver/template/overall_header.html | 2 -- phpBB/styles/prosilver/template/simple_header.html | 2 -- 3 files changed, 6 deletions(-) diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 49f2e469bc..3db843ffd1 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -5390,8 +5390,6 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0 'T_UPLOAD' => $config['upload_path'], 'SITE_LOGO_IMG' => $user->img('site_logo'), - - 'A_COOKIE_SETTINGS' => addslashes('; path=' . $config['cookie_path'] . ((!$config['cookie_domain'] || $config['cookie_domain'] == 'localhost' || $config['cookie_domain'] == '127.0.0.1') ? '' : '; domain=' . $config['cookie_domain']) . ((!$config['cookie_secure']) ? '' : '; secure')), )); // application/xhtml+xml not used because of IE diff --git a/phpBB/styles/prosilver/template/overall_header.html b/phpBB/styles/prosilver/template/overall_header.html index ddbd917bd6..fcce0060f3 100644 --- a/phpBB/styles/prosilver/template/overall_header.html +++ b/phpBB/styles/prosilver/template/overall_header.html @@ -30,8 +30,6 @@ var on_page = '{ON_PAGE}'; var per_page = '{PER_PAGE}'; var base_url = '{A_BASE_URL}'; - var style_cookie = 'phpBBstyle'; - var style_cookie_settings = '{A_COOKIE_SETTINGS}'; var onload_functions = new Array(); var onunload_functions = new Array(); diff --git a/phpBB/styles/prosilver/template/simple_header.html b/phpBB/styles/prosilver/template/simple_header.html index 667698c371..5bdc539f40 100644 --- a/phpBB/styles/prosilver/template/simple_header.html +++ b/phpBB/styles/prosilver/template/simple_header.html @@ -14,10 +14,8 @@ var on_page = '{ON_PAGE}'; var per_page = '{PER_PAGE}'; var base_url = '{A_BASE_URL}'; - var style_cookie = 'phpBBstyle'; var onload_functions = new Array(); var onunload_functions = new Array(); - var style_cookie_settings = '{A_COOKIE_SETTINGS}'; /** * New function for handling multiple calls to window.onload and window.unload by pentapenguin From 212294382d2626012bb1caf0dde1392e59b1ca31 Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Tue, 30 Jul 2013 12:32:14 +0300 Subject: [PATCH 2390/2494] [ticket/11688] Rename purge_dir to remove_dir PHPBB3-11688 --- phpBB/phpbb/cache/driver/file.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/phpBB/phpbb/cache/driver/file.php b/phpBB/phpbb/cache/driver/file.php index 19596f5205..66a74ea4eb 100644 --- a/phpBB/phpbb/cache/driver/file.php +++ b/phpBB/phpbb/cache/driver/file.php @@ -223,7 +223,7 @@ class phpbb_cache_driver_file extends phpbb_cache_driver_base $filename = $fileInfo->getFilename(); if ($fileInfo->isDir()) { - $this->purge_dir($fileInfo->getPathname()); + $this->remove_dir($fileInfo->getPathname()); } elseif (strpos($filename, 'container_') === 0 || strpos($filename, 'url_matcher') === 0 || @@ -250,7 +250,7 @@ class phpbb_cache_driver_file extends phpbb_cache_driver_base /** * Remove directory */ - protected function purge_dir($dir) + protected function remove_dir($dir) { try { @@ -269,7 +269,7 @@ class phpbb_cache_driver_file extends phpbb_cache_driver_base } if ($fileInfo->isDir()) { - $this->purge_dir($fileInfo->getPathname()); + $this->remove_dir($fileInfo->getPathname()); } else { From 8295d0fb36df1c11af45f9062e17520d661e625c Mon Sep 17 00:00:00 2001 From: Bruno Ais Date: Tue, 30 Jul 2013 11:15:46 +0100 Subject: [PATCH 2391/2494] [ticket/11638] Variable names goof... sub-task of ticket PHPBB3-11635: find and fix all bypasses of generate_text_for_* PHPBB3-11638 --- phpBB/viewtopic.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index a24c40f697..e120322a4f 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -828,7 +828,7 @@ if (!empty($topic_data['poll_start'])) $poll_total += $poll_option['poll_option_total']; } - $parse_flags = ($row['bbcode_bitfield'] ? OPTION_FLAG_BBCODE : 0) | OPTION_FLAG_SMILIES; + $parse_flags = ($poll_info[0]['bbcode_bitfield'] ? OPTION_FLAG_BBCODE : 0) | OPTION_FLAG_SMILIES; for ($i = 0, $size = sizeof($poll_info); $i < $size; $i++) { From 95c603d545ade8ab37e81fd99f2b62765a54bcb0 Mon Sep 17 00:00:00 2001 From: Oliver Schramm Date: Tue, 30 Jul 2013 18:00:47 +0200 Subject: [PATCH 2392/2494] [ticket/8228] Fix still existing problems with code in firefox A user of a board mentioned that there are still some problems in firefox if php-highlighting is on. So I used a snippet which they worked on for weeks. Link to the snippet (in german): http://www.ongray-design.de/forum/viewtopic.php?t=541 PHPBB3-8228 --- phpBB/styles/prosilver/template/bbcode.html | 4 ++-- phpBB/styles/prosilver/template/forum_fn.js | 5 ++--- phpBB/styles/prosilver/theme/bidi.css | 2 +- phpBB/styles/prosilver/theme/colours.css | 6 +++--- phpBB/styles/prosilver/theme/content.css | 8 ++++---- phpBB/styles/prosilver/theme/print.css | 2 +- 6 files changed, 13 insertions(+), 14 deletions(-) diff --git a/phpBB/styles/prosilver/template/bbcode.html b/phpBB/styles/prosilver/template/bbcode.html index 460d102c28..909c09df5a 100644 --- a/phpBB/styles/prosilver/template/bbcode.html +++ b/phpBB/styles/prosilver/template/bbcode.html @@ -12,8 +12,8 @@
    -
    {L_CODE}{L_COLON} {L_SELECT_ALL_CODE}
    
    -
    +

    {L_CODE}{L_COLON} {L_SELECT_ALL_CODE}

    +
    diff --git a/phpBB/styles/prosilver/template/forum_fn.js b/phpBB/styles/prosilver/template/forum_fn.js index 42a68a2ef5..eccb12e827 100644 --- a/phpBB/styles/prosilver/template/forum_fn.js +++ b/phpBB/styles/prosilver/template/forum_fn.js @@ -187,7 +187,7 @@ function displayBlocks(c, e, t) { function selectCode(a) { // Get ID of code block - var e = a.parentNode.parentNode.getElementsByTagName('PRE')[0]; + var e = a.parentNode.parentNode.getElementsByTagName('CODE')[0]; var s, r; // Not IE and IE9+ @@ -205,8 +205,7 @@ function selectCode(a) { } r = document.createRange(); - r.setStart(e.firstChild, 0); - r.setEnd(e.lastChild, e.lastChild.textContent.length); + r.selectNodeContents(e); s.removeAllRanges(); s.addRange(r); } diff --git a/phpBB/styles/prosilver/theme/bidi.css b/phpBB/styles/prosilver/theme/bidi.css index f617428565..a921805327 100644 --- a/phpBB/styles/prosilver/theme/bidi.css +++ b/phpBB/styles/prosilver/theme/bidi.css @@ -422,7 +422,7 @@ margin-left: 0; } -.rtl blockquote dl.codebox { +.rtl blockquote .codebox { margin-right: 0; } diff --git a/phpBB/styles/prosilver/theme/colours.css b/phpBB/styles/prosilver/theme/colours.css index 801d607d9c..5548905ede 100644 --- a/phpBB/styles/prosilver/theme/colours.css +++ b/phpBB/styles/prosilver/theme/colours.css @@ -470,16 +470,16 @@ blockquote blockquote blockquote { } /* Code block */ -dl.codebox { +.codebox { background-color: #FFFFFF; border-color: #C9D2D8; } -dl.codebox dt { +.codebox p { border-bottom-color: #CCCCCC; } -dl.codebox pre { +.codebox code { color: #2E8B57; } diff --git a/phpBB/styles/prosilver/theme/content.css b/phpBB/styles/prosilver/theme/content.css index 0cab12910b..c56c7f9ef8 100644 --- a/phpBB/styles/prosilver/theme/content.css +++ b/phpBB/styles/prosilver/theme/content.css @@ -472,13 +472,13 @@ blockquote.uncited { } /* Code block */ -dl.codebox { +.codebox { padding: 3px; border: 1px solid transparent; font-size: 1em; } -dl.codebox dt { +.codebox p { text-transform: uppercase; border-bottom: 1px solid transparent; margin-bottom: 3px; @@ -487,11 +487,11 @@ dl.codebox dt { display: block; } -blockquote dl.codebox { +blockquote .codebox { margin-left: 0; } -dl.codebox pre { +.codebox code { /* Also see tweaks.css */ overflow: auto; display: block; diff --git a/phpBB/styles/prosilver/theme/print.css b/phpBB/styles/prosilver/theme/print.css index bc3ca80fdc..88de620493 100644 --- a/phpBB/styles/prosilver/theme/print.css +++ b/phpBB/styles/prosilver/theme/print.css @@ -136,4 +136,4 @@ div.spacer { clear: both; } /* Accessibility tweaks: Mozilla.org */ .skip_link { display: none; } -dl.codebox dt { display: none; } +.codebox p { display: none; } From 5eb321d3113136f5e6cbc1f0ad911636f93f94df Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Tue, 30 Jul 2013 21:02:40 +0300 Subject: [PATCH 2393/2494] [ticket/11688] Fix docblock PHPBB3-11688 --- phpBB/phpbb/cache/driver/file.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/phpBB/phpbb/cache/driver/file.php b/phpBB/phpbb/cache/driver/file.php index 66a74ea4eb..944dfd6541 100644 --- a/phpBB/phpbb/cache/driver/file.php +++ b/phpBB/phpbb/cache/driver/file.php @@ -249,6 +249,10 @@ class phpbb_cache_driver_file extends phpbb_cache_driver_base /** * Remove directory + * + * @param string $dir Directory to remove + * + * @return null */ protected function remove_dir($dir) { @@ -267,6 +271,7 @@ class phpbb_cache_driver_file extends phpbb_cache_driver_base { continue; } + if ($fileInfo->isDir()) { $this->remove_dir($fileInfo->getPathname()); From 8892205644a9423998441472b48a29dcea321360 Mon Sep 17 00:00:00 2001 From: Oliver Schramm Date: Tue, 30 Jul 2013 22:32:05 +0200 Subject: [PATCH 2394/2494] [ticket/11757] Fix typo in signature_module_auth migration PHPBB3-11757 --- phpBB/phpbb/db/migration/data/310/signature_module_auth.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/phpbb/db/migration/data/310/signature_module_auth.php b/phpBB/phpbb/db/migration/data/310/signature_module_auth.php index e4fbb27bcb..02cd70059a 100644 --- a/phpBB/phpbb/db/migration/data/310/signature_module_auth.php +++ b/phpBB/phpbb/db/migration/data/310/signature_module_auth.php @@ -17,7 +17,7 @@ class phpbb_db_migration_data_310_signature_module_auth extends phpbb_db_migrati AND module_basename = 'ucp_profile' AND module_mode = 'signature'"; $result = $this->db->sql_query($sql); - $module_auth = $this->db_sql_fetchfield('module_auth'); + $module_auth = $this->db->sql_fetchfield('module_auth'); $this->db->sql_freeresult($result); return $module_auth === 'acl_u_sig' || $module_auth === false; From 715e408ee6765f84b812636e808786f73f43699b Mon Sep 17 00:00:00 2001 From: Oliver Schramm Date: Wed, 31 Jul 2013 00:00:50 +0200 Subject: [PATCH 2395/2494] [ticket/11464] Add missing and remove unnecessary database entry PHPBB3-11464 --- phpBB/install/schemas/schema_data.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/install/schemas/schema_data.sql b/phpBB/install/schemas/schema_data.sql index d03fdf9de4..0a31b89aab 100644 --- a/phpBB/install/schemas/schema_data.sql +++ b/phpBB/install/schemas/schema_data.sql @@ -170,7 +170,7 @@ INSERT INTO phpbb_config (config_name, config_value) VALUES ('limit_search_load' INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_anon_lastread', '0'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_birthdays', '1'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_cpf_memberlist', '0'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_cpf_profile', '0'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_cpf_pm', '0'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_cpf_viewprofile', '1'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_cpf_viewtopic', '0'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_db_lastread', '1'); From 6f883b6791e1bc9b168c98d4a95e9bbed6731a74 Mon Sep 17 00:00:00 2001 From: Oliver Schramm Date: Wed, 31 Jul 2013 14:04:50 +0200 Subject: [PATCH 2396/2494] [ticket/10037] Fix table in subsilver2 Thanks, nickvergessen! ;-) PHPBB3-10037 --- .../template/ucp_profile_signature.html | 42 ++++++++----------- 1 file changed, 18 insertions(+), 24 deletions(-) diff --git a/phpBB/styles/subsilver2/template/ucp_profile_signature.html b/phpBB/styles/subsilver2/template/ucp_profile_signature.html index 8588a99438..54e8aaa723 100644 --- a/phpBB/styles/subsilver2/template/ucp_profile_signature.html +++ b/phpBB/styles/subsilver2/template/ucp_profile_signature.html @@ -1,5 +1,12 @@ + + @@ -18,20 +25,10 @@ - From 07bc935efea32de9cbef7039730d910b1e2befea Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 31 Jul 2013 23:03:32 +0200 Subject: [PATCH 2397/2494] [ticket/11751] Add mcp modules for softdelete on update PHPBB3-11751 --- .../data/310/softdelete_mcp_modules.php | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 phpBB/phpbb/db/migration/data/310/softdelete_mcp_modules.php diff --git a/phpBB/phpbb/db/migration/data/310/softdelete_mcp_modules.php b/phpBB/phpbb/db/migration/data/310/softdelete_mcp_modules.php new file mode 100644 index 0000000000..f80f55d19a --- /dev/null +++ b/phpBB/phpbb/db/migration/data/310/softdelete_mcp_modules.php @@ -0,0 +1,55 @@ +db->sql_query($sql); + $module_id = $this->db->sql_fetchfield('module_id'); + $this->db->sql_freeresult($result); + + return $module_id !== false; + } + + static public function depends_on() + { + return array( + 'phpbb_db_migration_data_310_dev', + 'phpbb_db_migration_data_310_softdelete_p2', + ); + } + + public function update_data() + { + return array( + array('module.add', array( + 'mcp', + 'MCP_QUEUE', + array( + 'module_basename' => 'mcp_queue', + 'modes' => array('deleted_topics'), + ), + )), + array('module.add', array( + 'mcp', + 'MCP_QUEUE', + array( + 'module_basename' => 'mcp_queue', + 'modes' => array('deleted_posts'), + ), + )), + ); + } +} From c2aff70cf561c1787be6cdaa193432d0cbdf432d Mon Sep 17 00:00:00 2001 From: Bruno Ais Date: Thu, 1 Aug 2013 10:03:04 +0100 Subject: [PATCH 2398/2494] [ticket/11655] Use $parse_flags sub-task of ticket PHPBB3-11635: find and fix all bypasses of generate_text_for_* PHPBB3-11655 --- phpBB/includes/ucp/ucp_pm_viewmessage.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/phpBB/includes/ucp/ucp_pm_viewmessage.php b/phpBB/includes/ucp/ucp_pm_viewmessage.php index 52a28e3552..8e7ae49fa4 100644 --- a/phpBB/includes/ucp/ucp_pm_viewmessage.php +++ b/phpBB/includes/ucp/ucp_pm_viewmessage.php @@ -76,7 +76,8 @@ function view_message($id, $mode, $folder_id, $msg_id, $folder, $message_row) $user_info = get_user_information($author_id, $message_row); // Parse the message and subject - $message = generate_text_for_display($message_row['message_text'], $message_row['bbcode_uid'], $message_row['bbcode_bitfield'], ($message_row['bbcode_bitfield'] ? OPTION_FLAG_BBCODE : 0) | OPTION_FLAG_SMILIES, true); + $parse_flags = ($message_row['bbcode_bitfield'] ? OPTION_FLAG_BBCODE : 0) | OPTION_FLAG_SMILIES + $message = generate_text_for_display($message_row['message_text'], $message_row['bbcode_uid'], $message_row['bbcode_bitfield'], $parse_flags, true); // Replace naughty words such as farty pants $message_row['message_subject'] = censor_text($message_row['message_subject']); From 776773522ba129c0e7d0918b2f6beccd4c044dbe Mon Sep 17 00:00:00 2001 From: Bruno Ais Date: Thu, 1 Aug 2013 10:07:58 +0100 Subject: [PATCH 2399/2494] [ticket/11653] Use $parse_flags sub-task of ticket PHPBB3-11635: find and fix all bypasses of generate_text_for_* PHPBB3-11653 --- phpBB/includes/mcp/mcp_topic.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/phpBB/includes/mcp/mcp_topic.php b/phpBB/includes/mcp/mcp_topic.php index 3491f37bcb..5014879b02 100644 --- a/phpBB/includes/mcp/mcp_topic.php +++ b/phpBB/includes/mcp/mcp_topic.php @@ -213,7 +213,8 @@ function mcp_topic_view($id, $mode, $action) $message = $row['post_text']; $post_subject = ($row['post_subject'] != '') ? $row['post_subject'] : $topic_info['topic_title']; - $message = generate_text_for_display($message, $row['bbcode_uid'], $row['bbcode_bitfield'], ($row['bbcode_bitfield'] ? OPTION_FLAG_BBCODE : 0) | OPTION_FLAG_SMILIES, false); + $parse_flags = ($row['bbcode_bitfield'] ? OPTION_FLAG_BBCODE : 0) | OPTION_FLAG_SMILIES; + $message = generate_text_for_display($message, $row['bbcode_uid'], $row['bbcode_bitfield'], $parse_flags, false); if (!empty($attachments[$row['post_id']])) { From c806375828c01c011915f1438f718349aaaaf282 Mon Sep 17 00:00:00 2001 From: Bruno Ais Date: Thu, 1 Aug 2013 10:09:11 +0100 Subject: [PATCH 2400/2494] [ticket/11653] Missing ";" sub-task of ticket PHPBB3-11635: find and fix all bypasses of generate_text_for_* PHPBB3-11653 --- phpBB/includes/ucp/ucp_pm_viewmessage.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/ucp/ucp_pm_viewmessage.php b/phpBB/includes/ucp/ucp_pm_viewmessage.php index 8e7ae49fa4..79c4297858 100644 --- a/phpBB/includes/ucp/ucp_pm_viewmessage.php +++ b/phpBB/includes/ucp/ucp_pm_viewmessage.php @@ -76,7 +76,7 @@ function view_message($id, $mode, $folder_id, $msg_id, $folder, $message_row) $user_info = get_user_information($author_id, $message_row); // Parse the message and subject - $parse_flags = ($message_row['bbcode_bitfield'] ? OPTION_FLAG_BBCODE : 0) | OPTION_FLAG_SMILIES + $parse_flags = ($message_row['bbcode_bitfield'] ? OPTION_FLAG_BBCODE : 0) | OPTION_FLAG_SMILIES; $message = generate_text_for_display($message_row['message_text'], $message_row['bbcode_uid'], $message_row['bbcode_bitfield'], $parse_flags, true); // Replace naughty words such as farty pants From ea6938d3e518b636529238ab9ffd5b57b1a19241 Mon Sep 17 00:00:00 2001 From: Bruno Ais Date: Thu, 1 Aug 2013 10:11:08 +0100 Subject: [PATCH 2401/2494] [ticket/11643] Use $parse_flags sub-task of ticket PHPBB3-11635: find and fix all bypasses of generate_text_for_* PHPBB3-11643 --- phpBB/includes/mcp/mcp_queue.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/phpBB/includes/mcp/mcp_queue.php b/phpBB/includes/mcp/mcp_queue.php index 2c95dc6a67..190fccab9a 100644 --- a/phpBB/includes/mcp/mcp_queue.php +++ b/phpBB/includes/mcp/mcp_queue.php @@ -132,7 +132,8 @@ class mcp_queue $post_unread = (isset($topic_tracking_info[$post_info['topic_id']]) && $post_info['post_time'] > $topic_tracking_info[$post_info['topic_id']]) ? true : false; // Process message, leave it uncensored - $message = generate_text_for_display($post_info['post_text'], $post_info['bbcode_uid'], $post_info['bbcode_bitfield'], ($post_info['bbcode_bitfield'] ? OPTION_FLAG_BBCODE : 0) | OPTION_FLAG_SMILIES, false); + $parse_flags = ($post_info['bbcode_bitfield'] ? OPTION_FLAG_BBCODE : 0) | OPTION_FLAG_SMILIES; + $message = generate_text_for_display($post_info['post_text'], $post_info['bbcode_uid'], $post_info['bbcode_bitfield'], $parse_flags, false); if ($post_info['post_attachment'] && $auth->acl_get('u_download') && $auth->acl_get('f_download', $post_info['forum_id'])) { From a302a09ffbe174e6720ce250121d34ba8b6fd626 Mon Sep 17 00:00:00 2001 From: Bruno Ais Date: Thu, 1 Aug 2013 10:12:58 +0100 Subject: [PATCH 2402/2494] [ticket/11642] Use $parse_flags sub-task of ticket PHPBB3-11635: find and fix all bypasses of generate_text_for_* PHPBB3-11642 --- phpBB/includes/mcp/mcp_post.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/phpBB/includes/mcp/mcp_post.php b/phpBB/includes/mcp/mcp_post.php index e8768957e0..e9f6ce0471 100644 --- a/phpBB/includes/mcp/mcp_post.php +++ b/phpBB/includes/mcp/mcp_post.php @@ -125,7 +125,8 @@ function mcp_post_details($id, $mode, $action) $post_unread = (isset($topic_tracking_info[$post_info['topic_id']]) && $post_info['post_time'] > $topic_tracking_info[$post_info['topic_id']]) ? true : false; // Process message, leave it uncensored - $message = generate_text_for_display($post_info['post_text'], $post_info['bbcode_uid'], $post_info['bbcode_bitfield'], ($post_info['bbcode_bitfield'] ? OPTION_FLAG_BBCODE : 0) | OPTION_FLAG_SMILIES, false); + $parse_flags = ($post_info['bbcode_bitfield'] ? OPTION_FLAG_BBCODE : 0) | OPTION_FLAG_SMILIES; + $message = generate_text_for_display($post_info['post_text'], $post_info['bbcode_uid'], $post_info['bbcode_bitfield'], $parse_flags, false); if ($post_info['post_attachment'] && $auth->acl_get('u_download') && $auth->acl_get('f_download', $post_info['forum_id'])) { From 3ae33910fc600ae86f0036370958bd7ec19e7ab9 Mon Sep 17 00:00:00 2001 From: Bruno Ais Date: Thu, 1 Aug 2013 10:14:34 +0100 Subject: [PATCH 2403/2494] [ticket/11653] Use $parse_flags sub-task of ticket PHPBB3-11635: find and fix all bypasses of generate_text_for_* PHPBB3-11653 --- phpBB/includes/ucp/ucp_pm_viewmessage.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/phpBB/includes/ucp/ucp_pm_viewmessage.php b/phpBB/includes/ucp/ucp_pm_viewmessage.php index 79c4297858..c7b4489daf 100644 --- a/phpBB/includes/ucp/ucp_pm_viewmessage.php +++ b/phpBB/includes/ucp/ucp_pm_viewmessage.php @@ -151,7 +151,8 @@ function view_message($id, $mode, $folder_id, $msg_id, $folder, $message_row) // End signature parsing, only if needed if ($signature) { - $signature = generate_text_for_display($signature, $user_info['user_sig_bbcode_uid'], $user_info['user_sig_bbcode_bitfield'], ($user_info['user_sig_bbcode_bitfield'] ? OPTION_FLAG_BBCODE : 0) | OPTION_FLAG_SMILIES, true); + $parse_flags = ($user_info['user_sig_bbcode_bitfield'] ? OPTION_FLAG_BBCODE : 0) | OPTION_FLAG_SMILIES; + $signature = generate_text_for_display($signature, $user_info['user_sig_bbcode_uid'], $user_info['user_sig_bbcode_bitfield'], $parse_flags, true); } $url = append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm'); From 2f251972790e7836d9c35eb2f5b49fda97f736d6 Mon Sep 17 00:00:00 2001 From: Bruno Ais Date: Thu, 1 Aug 2013 10:16:33 +0100 Subject: [PATCH 2404/2494] [ticket/11641] Use $parse_flags sub-task of ticket PHPBB3-11635: find and fix all bypasses of generate_text_for_* PHPBB3-11641 --- phpBB/includes/mcp/mcp_pm_reports.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/phpBB/includes/mcp/mcp_pm_reports.php b/phpBB/includes/mcp/mcp_pm_reports.php index dc953aae33..cb61b25174 100644 --- a/phpBB/includes/mcp/mcp_pm_reports.php +++ b/phpBB/includes/mcp/mcp_pm_reports.php @@ -115,7 +115,8 @@ class mcp_pm_reports } // Process message, leave it uncensored - $message = generate_text_for_display($pm_info['message_text'], $pm_info['bbcode_uid'], $pm_info['bbcode_bitfield'], ($pm_info['bbcode_bitfield'] ? OPTION_FLAG_BBCODE : 0) | OPTION_FLAG_SMILIES, false); + $parse_flags = ($pm_info['bbcode_bitfield'] ? OPTION_FLAG_BBCODE : 0) | OPTION_FLAG_SMILIES; + $message = generate_text_for_display($pm_info['message_text'], $pm_info['bbcode_uid'], $pm_info['bbcode_bitfield'], $parse_flags, false); $report['report_text'] = make_clickable(bbcode_nl2br($report['report_text'])); From ea8f584de9d572f8c58b26acd1fd7551c42ab59c Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Thu, 1 Aug 2013 17:26:34 +0200 Subject: [PATCH 2405/2494] [prep-release-3.0.12] Bumping version number for 3.0.12-RC2. --- build/build.xml | 4 ++-- phpBB/includes/constants.php | 2 +- phpBB/install/database_update.php | 8 +++++++- phpBB/install/schemas/schema_data.sql | 2 +- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/build/build.xml b/build/build.xml index a418f40b53..db327ccc30 100644 --- a/build/build.xml +++ b/build/build.xml @@ -2,9 +2,9 @@ - + - + diff --git a/phpBB/includes/constants.php b/phpBB/includes/constants.php index 0a853adb9b..09e1e50b8d 100644 --- a/phpBB/includes/constants.php +++ b/phpBB/includes/constants.php @@ -25,7 +25,7 @@ if (!defined('IN_PHPBB')) */ // phpBB Version -define('PHPBB_VERSION', '3.0.12-RC1'); +define('PHPBB_VERSION', '3.0.12-RC2'); // QA-related // define('PHPBB_QA', 1); diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 5cb410bf29..59f795e37e 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -8,7 +8,7 @@ * */ -define('UPDATES_TO_VERSION', '3.0.12-RC1'); +define('UPDATES_TO_VERSION', '3.0.12-RC2'); // Enter any version to update from to test updates. The version within the db will not be updated. define('DEBUG_FROM_VERSION', false); @@ -1005,6 +1005,8 @@ function database_update_info() '3.0.11-RC2' => array(), // No changes from 3.0.11 to 3.0.12-RC1 '3.0.11' => array(), + // No changes from 3.0.12-RC1 to 3.0.12-RC2 + '3.0.12-RC1' => array(), /** @todo DROP LOGIN_ATTEMPT_TABLE.attempt_id in 3.0.13-RC1 */ ); @@ -2236,6 +2238,10 @@ function change_database_data(&$no_updates, $version) $no_updates = false; break; + + // No changes from 3.0.12-RC1 to 3.0.12-RC2 + case '3.0.12-RC1': + break; } } diff --git a/phpBB/install/schemas/schema_data.sql b/phpBB/install/schemas/schema_data.sql index 04b92b19c6..cfe3c0c4cb 100644 --- a/phpBB/install/schemas/schema_data.sql +++ b/phpBB/install/schemas/schema_data.sql @@ -246,7 +246,7 @@ INSERT INTO phpbb_config (config_name, config_value) VALUES ('topics_per_page', INSERT INTO phpbb_config (config_name, config_value) VALUES ('tpl_allow_php', '0'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('upload_icons_path', 'images/upload_icons'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('upload_path', 'files'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('version', '3.0.12-RC1'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('version', '3.0.12-RC2'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('warnings_expire_days', '90'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('warnings_gc', '14400'); From 0a73d64b9772971b7e43e989c659184ee20c5bc6 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Thu, 1 Aug 2013 17:28:21 +0200 Subject: [PATCH 2406/2494] [prep-release-3.0.12] Update Changelog for 3.0.12-RC2 release. --- phpBB/docs/CHANGELOG.html | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/phpBB/docs/CHANGELOG.html b/phpBB/docs/CHANGELOG.html index 44cc49d8c4..f2d5ddc212 100644 --- a/phpBB/docs/CHANGELOG.html +++ b/phpBB/docs/CHANGELOG.html @@ -190,6 +190,8 @@
  • [PHPBB3-11662] - "occured" should be "occurred"
  • [PHPBB3-11670] - Replace trademark ™ with ® on "Welcome to phpBB" install page
  • [PHPBB3-11674] - Do not include vendor folder if there are no dependencies.
  • +
  • [PHPBB3-11524] - MySQL Upgrader throws warnings on PHP 5.4
  • +
  • [PHPBB3-11720] - Reporting posts leads to white page error
  • Improvement

      @@ -213,6 +215,7 @@
    • [PHPBB3-11294] - Update extension list in running tests doc
    • [PHPBB3-11368] - Latest pm reports row count
    • [PHPBB3-11583] - InnoDB supports FULLTEXT index since MySQL 5.6.4.
    • +
    • [PHPBB3-11740] - Update link in FAQ to Ideas Centre

    Sub-task

      @@ -238,6 +241,8 @@
    • [PHPBB3-11529] - Rename RUNNING_TESTS file to .md file to render it on GitHub
    • [PHPBB3-11576] - Make phpBB Test Suite MySQL behave at least as strict as phpBB MySQL driver
    • [PHPBB3-11671] - Add phing/phing to composer.json
    • +
    • [PHPBB3-11752] - Update phpBB.com URLs to https in email templates
    • +
    • [PHPBB3-11753] - Upgrade mysql_upgrader.php schema data.

    1.ii. Changes since 3.0.10

    From 7d90f0a8a00ac66f6a561766e25fb4ea16a4111b Mon Sep 17 00:00:00 2001 From: Oliver Schramm Date: Fri, 2 Aug 2013 02:49:28 +0200 Subject: [PATCH 2407/2494] [ticket/11759] Change lowercase to uppercase PHPBB3-11759 --- phpBB/phpbb/db/migration/data/30x/3_0_10_rc1.php | 4 ++-- phpBB/phpbb/db/migration/data/30x/3_0_10_rc2.php | 4 ++-- phpBB/phpbb/db/migration/data/30x/3_0_10_rc3.php | 4 ++-- phpBB/phpbb/db/migration/data/30x/3_0_11_rc1.php | 4 ++-- phpBB/phpbb/db/migration/data/30x/3_0_11_rc2.php | 4 ++-- phpBB/phpbb/db/migration/data/30x/3_0_12_rc1.php | 4 ++-- phpBB/phpbb/db/migration/data/30x/3_0_1_rc1.php | 4 ++-- phpBB/phpbb/db/migration/data/30x/3_0_2_rc1.php | 4 ++-- phpBB/phpbb/db/migration/data/30x/3_0_2_rc2.php | 4 ++-- phpBB/phpbb/db/migration/data/30x/3_0_3_rc1.php | 4 ++-- phpBB/phpbb/db/migration/data/30x/3_0_4_rc1.php | 4 ++-- phpBB/phpbb/db/migration/data/30x/3_0_5_rc1.php | 2 +- phpBB/phpbb/db/migration/data/30x/3_0_5_rc1part2.php | 4 ++-- phpBB/phpbb/db/migration/data/30x/3_0_6_rc1.php | 4 ++-- phpBB/phpbb/db/migration/data/30x/3_0_6_rc2.php | 4 ++-- phpBB/phpbb/db/migration/data/30x/3_0_6_rc3.php | 4 ++-- phpBB/phpbb/db/migration/data/30x/3_0_6_rc4.php | 4 ++-- phpBB/phpbb/db/migration/data/30x/3_0_7_rc1.php | 4 ++-- phpBB/phpbb/db/migration/data/30x/3_0_7_rc2.php | 4 ++-- phpBB/phpbb/db/migration/data/30x/3_0_8_rc1.php | 4 ++-- phpBB/phpbb/db/migration/data/30x/3_0_9_rc1.php | 4 ++-- phpBB/phpbb/db/migration/data/30x/3_0_9_rc2.php | 4 ++-- phpBB/phpbb/db/migration/data/30x/3_0_9_rc3.php | 4 ++-- phpBB/phpbb/db/migration/data/30x/3_0_9_rc4.php | 4 ++-- 24 files changed, 47 insertions(+), 47 deletions(-) diff --git a/phpBB/phpbb/db/migration/data/30x/3_0_10_rc1.php b/phpBB/phpbb/db/migration/data/30x/3_0_10_rc1.php index 0ed05812dc..459b423736 100644 --- a/phpBB/phpbb/db/migration/data/30x/3_0_10_rc1.php +++ b/phpBB/phpbb/db/migration/data/30x/3_0_10_rc1.php @@ -11,7 +11,7 @@ class phpbb_db_migration_data_30x_3_0_10_rc1 extends phpbb_db_migration { public function effectively_installed() { - return version_compare($this->config['version'], '3.0.10-rc1', '>='); + return version_compare($this->config['version'], '3.0.10-RC1', '>='); } static public function depends_on() @@ -24,7 +24,7 @@ class phpbb_db_migration_data_30x_3_0_10_rc1 extends phpbb_db_migration return array( array('config.add', array('email_max_chunk_size', 50)), - array('config.update', array('version', '3.0.10-rc1')), + array('config.update', array('version', '3.0.10-RC1')), ); } } diff --git a/phpBB/phpbb/db/migration/data/30x/3_0_10_rc2.php b/phpBB/phpbb/db/migration/data/30x/3_0_10_rc2.php index b14b3b00aa..8d21cab45d 100644 --- a/phpBB/phpbb/db/migration/data/30x/3_0_10_rc2.php +++ b/phpBB/phpbb/db/migration/data/30x/3_0_10_rc2.php @@ -11,7 +11,7 @@ class phpbb_db_migration_data_30x_3_0_10_rc2 extends phpbb_db_migration { public function effectively_installed() { - return version_compare($this->config['version'], '3.0.10-rc2', '>='); + return version_compare($this->config['version'], '3.0.10-RC2', '>='); } static public function depends_on() @@ -22,7 +22,7 @@ class phpbb_db_migration_data_30x_3_0_10_rc2 extends phpbb_db_migration public function update_data() { return array( - array('config.update', array('version', '3.0.10-rc2')), + array('config.update', array('version', '3.0.10-RC2')), ); } } diff --git a/phpBB/phpbb/db/migration/data/30x/3_0_10_rc3.php b/phpBB/phpbb/db/migration/data/30x/3_0_10_rc3.php index 473057d65d..296c3c40af 100644 --- a/phpBB/phpbb/db/migration/data/30x/3_0_10_rc3.php +++ b/phpBB/phpbb/db/migration/data/30x/3_0_10_rc3.php @@ -11,7 +11,7 @@ class phpbb_db_migration_data_30x_3_0_10_rc3 extends phpbb_db_migration { public function effectively_installed() { - return version_compare($this->config['version'], '3.0.10-rc3', '>='); + return version_compare($this->config['version'], '3.0.10-RC3', '>='); } static public function depends_on() @@ -22,7 +22,7 @@ class phpbb_db_migration_data_30x_3_0_10_rc3 extends phpbb_db_migration public function update_data() { return array( - array('config.update', array('version', '3.0.10-rc3')), + array('config.update', array('version', '3.0.10-RC3')), ); } } diff --git a/phpBB/phpbb/db/migration/data/30x/3_0_11_rc1.php b/phpBB/phpbb/db/migration/data/30x/3_0_11_rc1.php index dddfc0e0e7..3a3908258f 100644 --- a/phpBB/phpbb/db/migration/data/30x/3_0_11_rc1.php +++ b/phpBB/phpbb/db/migration/data/30x/3_0_11_rc1.php @@ -11,7 +11,7 @@ class phpbb_db_migration_data_30x_3_0_11_rc1 extends phpbb_db_migration { public function effectively_installed() { - return version_compare($this->config['version'], '3.0.11-rc1', '>='); + return version_compare($this->config['version'], '3.0.11-RC1', '>='); } static public function depends_on() @@ -25,7 +25,7 @@ class phpbb_db_migration_data_30x_3_0_11_rc1 extends phpbb_db_migration array('custom', array(array(&$this, 'cleanup_deactivated_styles'))), array('custom', array(array(&$this, 'delete_orphan_private_messages'))), - array('config.update', array('version', '3.0.11-rc1')), + array('config.update', array('version', '3.0.11-RC1')), ); } diff --git a/phpBB/phpbb/db/migration/data/30x/3_0_11_rc2.php b/phpBB/phpbb/db/migration/data/30x/3_0_11_rc2.php index fac8523e8c..4b1b5642ce 100644 --- a/phpBB/phpbb/db/migration/data/30x/3_0_11_rc2.php +++ b/phpBB/phpbb/db/migration/data/30x/3_0_11_rc2.php @@ -11,7 +11,7 @@ class phpbb_db_migration_data_30x_3_0_11_rc2 extends phpbb_db_migration { public function effectively_installed() { - return version_compare($this->config['version'], '3.0.11-rc2', '>='); + return version_compare($this->config['version'], '3.0.11-RC2', '>='); } static public function depends_on() @@ -44,7 +44,7 @@ class phpbb_db_migration_data_30x_3_0_11_rc2 extends phpbb_db_migration public function update_data() { return array( - array('config.update', array('version', '3.0.11-rc2')), + array('config.update', array('version', '3.0.11-RC2')), ); } } diff --git a/phpBB/phpbb/db/migration/data/30x/3_0_12_rc1.php b/phpBB/phpbb/db/migration/data/30x/3_0_12_rc1.php index 6a31a51201..97331e9bb2 100644 --- a/phpBB/phpbb/db/migration/data/30x/3_0_12_rc1.php +++ b/phpBB/phpbb/db/migration/data/30x/3_0_12_rc1.php @@ -13,7 +13,7 @@ class phpbb_db_migration_data_30x_3_0_12_rc1 extends phpbb_db_migration { public function effectively_installed() { - return version_compare($this->config['version'], '3.0.12-rc1', '>='); + return version_compare($this->config['version'], '3.0.12-RC1', '>='); } static public function depends_on() @@ -28,7 +28,7 @@ class phpbb_db_migration_data_30x_3_0_12_rc1 extends phpbb_db_migration array('custom', array(array(&$this, 'update_bots'))), array('custom', array(array(&$this, 'disable_bots_from_receiving_pms'))), - array('config.update', array('version', '3.0.12-rc1')), + array('config.update', array('version', '3.0.12-RC1')), ); } diff --git a/phpBB/phpbb/db/migration/data/30x/3_0_1_rc1.php b/phpBB/phpbb/db/migration/data/30x/3_0_1_rc1.php index 562ccf077c..761ed5d2ec 100644 --- a/phpBB/phpbb/db/migration/data/30x/3_0_1_rc1.php +++ b/phpBB/phpbb/db/migration/data/30x/3_0_1_rc1.php @@ -11,7 +11,7 @@ class phpbb_db_migration_data_30x_3_0_1_rc1 extends phpbb_db_migration { public function effectively_installed() { - return version_compare($this->config['version'], '3.0.1-rc1', '>='); + return version_compare($this->config['version'], '3.0.1-RC1', '>='); } public function update_schema() @@ -74,7 +74,7 @@ class phpbb_db_migration_data_30x_3_0_1_rc1 extends phpbb_db_migration array('custom', array(array(&$this, 'fix_unset_last_view_time'))), array('custom', array(array(&$this, 'reset_smiley_size'))), - array('config.update', array('version', '3.0.1-rc1')), + array('config.update', array('version', '3.0.1-RC1')), ); } diff --git a/phpBB/phpbb/db/migration/data/30x/3_0_2_rc1.php b/phpBB/phpbb/db/migration/data/30x/3_0_2_rc1.php index a960e90765..a84f3c2d92 100644 --- a/phpBB/phpbb/db/migration/data/30x/3_0_2_rc1.php +++ b/phpBB/phpbb/db/migration/data/30x/3_0_2_rc1.php @@ -11,7 +11,7 @@ class phpbb_db_migration_data_30x_3_0_2_rc1 extends phpbb_db_migration { public function effectively_installed() { - return version_compare($this->config['version'], '3.0.2-rc1', '>='); + return version_compare($this->config['version'], '3.0.2-RC1', '>='); } static public function depends_on() @@ -26,7 +26,7 @@ class phpbb_db_migration_data_30x_3_0_2_rc1 extends phpbb_db_migration array('config.add', array('check_attachment_content', '1')), array('config.add', array('mime_triggers', 'body|head|html|img|plaintext|a href|pre|script|table|title')), - array('config.update', array('version', '3.0.2-rc1')), + array('config.update', array('version', '3.0.2-RC1')), ); } } diff --git a/phpBB/phpbb/db/migration/data/30x/3_0_2_rc2.php b/phpBB/phpbb/db/migration/data/30x/3_0_2_rc2.php index 8917dfea77..33bacc077f 100644 --- a/phpBB/phpbb/db/migration/data/30x/3_0_2_rc2.php +++ b/phpBB/phpbb/db/migration/data/30x/3_0_2_rc2.php @@ -11,7 +11,7 @@ class phpbb_db_migration_data_30x_3_0_2_rc2 extends phpbb_db_migration { public function effectively_installed() { - return version_compare($this->config['version'], '3.0.2-rc2', '>='); + return version_compare($this->config['version'], '3.0.2-RC2', '>='); } static public function depends_on() @@ -74,7 +74,7 @@ class phpbb_db_migration_data_30x_3_0_2_rc2 extends phpbb_db_migration public function update_data() { return array( - array('config.update', array('version', '3.0.2-rc2')), + array('config.update', array('version', '3.0.2-RC2')), ); } } diff --git a/phpBB/phpbb/db/migration/data/30x/3_0_3_rc1.php b/phpBB/phpbb/db/migration/data/30x/3_0_3_rc1.php index 4b102e1a2e..69433f386e 100644 --- a/phpBB/phpbb/db/migration/data/30x/3_0_3_rc1.php +++ b/phpBB/phpbb/db/migration/data/30x/3_0_3_rc1.php @@ -11,7 +11,7 @@ class phpbb_db_migration_data_30x_3_0_3_rc1 extends phpbb_db_migration { public function effectively_installed() { - return version_compare($this->config['version'], '3.0.3-rc1', '>='); + return version_compare($this->config['version'], '3.0.3-RC1', '>='); } static public function depends_on() @@ -60,7 +60,7 @@ class phpbb_db_migration_data_30x_3_0_3_rc1 extends phpbb_db_migration array('permission.add', array('u_masspm_group', true, 'u_masspm')), array('custom', array(array(&$this, 'correct_acp_email_permissions'))), - array('config.update', array('version', '3.0.3-rc1')), + array('config.update', array('version', '3.0.3-RC1')), ); } diff --git a/phpBB/phpbb/db/migration/data/30x/3_0_4_rc1.php b/phpBB/phpbb/db/migration/data/30x/3_0_4_rc1.php index 8ad75a557b..e45bd3eeee 100644 --- a/phpBB/phpbb/db/migration/data/30x/3_0_4_rc1.php +++ b/phpBB/phpbb/db/migration/data/30x/3_0_4_rc1.php @@ -11,7 +11,7 @@ class phpbb_db_migration_data_30x_3_0_4_rc1 extends phpbb_db_migration { public function effectively_installed() { - return version_compare($this->config['version'], '3.0.4-rc1', '>='); + return version_compare($this->config['version'], '3.0.4-RC1', '>='); } static public function depends_on() @@ -76,7 +76,7 @@ class phpbb_db_migration_data_30x_3_0_4_rc1 extends phpbb_db_migration return array( array('custom', array(array(&$this, 'update_custom_profile_fields'))), - array('config.update', array('version', '3.0.4-rc1')), + array('config.update', array('version', '3.0.4-RC1')), ); } diff --git a/phpBB/phpbb/db/migration/data/30x/3_0_5_rc1.php b/phpBB/phpbb/db/migration/data/30x/3_0_5_rc1.php index ea17cc1e31..62ae7bff1a 100644 --- a/phpBB/phpbb/db/migration/data/30x/3_0_5_rc1.php +++ b/phpBB/phpbb/db/migration/data/30x/3_0_5_rc1.php @@ -11,7 +11,7 @@ class phpbb_db_migration_data_30x_3_0_5_rc1 extends phpbb_db_migration { public function effectively_installed() { - return version_compare($this->config['version'], '3.0.5-rc1', '>='); + return version_compare($this->config['version'], '3.0.5-RC1', '>='); } static public function depends_on() diff --git a/phpBB/phpbb/db/migration/data/30x/3_0_5_rc1part2.php b/phpBB/phpbb/db/migration/data/30x/3_0_5_rc1part2.php index 8538347b1a..d72176489b 100644 --- a/phpBB/phpbb/db/migration/data/30x/3_0_5_rc1part2.php +++ b/phpBB/phpbb/db/migration/data/30x/3_0_5_rc1part2.php @@ -11,7 +11,7 @@ class phpbb_db_migration_data_30x_3_0_5_rc1part2 extends phpbb_db_migration { public function effectively_installed() { - return version_compare($this->config['version'], '3.0.5-rc1', '>='); + return version_compare($this->config['version'], '3.0.5-RC1', '>='); } static public function depends_on() @@ -36,7 +36,7 @@ class phpbb_db_migration_data_30x_3_0_5_rc1part2 extends phpbb_db_migration public function update_data() { return array( - array('config.update', array('version', '3.0.5-rc1')), + array('config.update', array('version', '3.0.5-RC1')), ); } } diff --git a/phpBB/phpbb/db/migration/data/30x/3_0_6_rc1.php b/phpBB/phpbb/db/migration/data/30x/3_0_6_rc1.php index 38c282ebf0..25f4995b0e 100644 --- a/phpBB/phpbb/db/migration/data/30x/3_0_6_rc1.php +++ b/phpBB/phpbb/db/migration/data/30x/3_0_6_rc1.php @@ -11,7 +11,7 @@ class phpbb_db_migration_data_30x_3_0_6_rc1 extends phpbb_db_migration { public function effectively_installed() { - return version_compare($this->config['version'], '3.0.6-rc1', '>='); + return version_compare($this->config['version'], '3.0.6-RC1', '>='); } static public function depends_on() @@ -185,7 +185,7 @@ class phpbb_db_migration_data_30x_3_0_6_rc1 extends phpbb_db_migration array('custom', array(array(&$this, 'add_newly_registered_group'))), array('custom', array(array(&$this, 'set_user_options_default'))), - array('config.update', array('version', '3.0.6-rc1')), + array('config.update', array('version', '3.0.6-RC1')), ); } diff --git a/phpBB/phpbb/db/migration/data/30x/3_0_6_rc2.php b/phpBB/phpbb/db/migration/data/30x/3_0_6_rc2.php index a939dbd489..d5d14ab05d 100644 --- a/phpBB/phpbb/db/migration/data/30x/3_0_6_rc2.php +++ b/phpBB/phpbb/db/migration/data/30x/3_0_6_rc2.php @@ -11,7 +11,7 @@ class phpbb_db_migration_data_30x_3_0_6_rc2 extends phpbb_db_migration { public function effectively_installed() { - return version_compare($this->config['version'], '3.0.6-rc2', '>='); + return version_compare($this->config['version'], '3.0.6-RC2', '>='); } static public function depends_on() @@ -22,7 +22,7 @@ class phpbb_db_migration_data_30x_3_0_6_rc2 extends phpbb_db_migration public function update_data() { return array( - array('config.update', array('version', '3.0.6-rc2')), + array('config.update', array('version', '3.0.6-RC2')), ); } } diff --git a/phpBB/phpbb/db/migration/data/30x/3_0_6_rc3.php b/phpBB/phpbb/db/migration/data/30x/3_0_6_rc3.php index b3f09d8ab8..f3f1fb42f4 100644 --- a/phpBB/phpbb/db/migration/data/30x/3_0_6_rc3.php +++ b/phpBB/phpbb/db/migration/data/30x/3_0_6_rc3.php @@ -11,7 +11,7 @@ class phpbb_db_migration_data_30x_3_0_6_rc3 extends phpbb_db_migration { public function effectively_installed() { - return version_compare($this->config['version'], '3.0.6-rc3', '>='); + return version_compare($this->config['version'], '3.0.6-RC3', '>='); } static public function depends_on() @@ -24,7 +24,7 @@ class phpbb_db_migration_data_30x_3_0_6_rc3 extends phpbb_db_migration return array( array('custom', array(array(&$this, 'update_cp_fields'))), - array('config.update', array('version', '3.0.6-rc3')), + array('config.update', array('version', '3.0.6-RC3')), ); } diff --git a/phpBB/phpbb/db/migration/data/30x/3_0_6_rc4.php b/phpBB/phpbb/db/migration/data/30x/3_0_6_rc4.php index fc2923f99b..6138ef351d 100644 --- a/phpBB/phpbb/db/migration/data/30x/3_0_6_rc4.php +++ b/phpBB/phpbb/db/migration/data/30x/3_0_6_rc4.php @@ -11,7 +11,7 @@ class phpbb_db_migration_data_30x_3_0_6_rc4 extends phpbb_db_migration { public function effectively_installed() { - return version_compare($this->config['version'], '3.0.6-rc4', '>='); + return version_compare($this->config['version'], '3.0.6-RC4', '>='); } static public function depends_on() @@ -22,7 +22,7 @@ class phpbb_db_migration_data_30x_3_0_6_rc4 extends phpbb_db_migration public function update_data() { return array( - array('config.update', array('version', '3.0.6-rc4')), + array('config.update', array('version', '3.0.6-RC4')), ); } } diff --git a/phpBB/phpbb/db/migration/data/30x/3_0_7_rc1.php b/phpBB/phpbb/db/migration/data/30x/3_0_7_rc1.php index ffebf66f2d..be8f9045f4 100644 --- a/phpBB/phpbb/db/migration/data/30x/3_0_7_rc1.php +++ b/phpBB/phpbb/db/migration/data/30x/3_0_7_rc1.php @@ -11,7 +11,7 @@ class phpbb_db_migration_data_30x_3_0_7_rc1 extends phpbb_db_migration { public function effectively_installed() { - return version_compare($this->config['version'], '3.0.7-rc1', '>='); + return version_compare($this->config['version'], '3.0.7-RC1', '>='); } static public function depends_on() @@ -62,7 +62,7 @@ class phpbb_db_migration_data_30x_3_0_7_rc1 extends phpbb_db_migration array('config.add', array('feed_topics_active', $this->config['feed_overall_topics'])), array('custom', array(array(&$this, 'delete_text_templates'))), - array('config.update', array('version', '3.0.7-rc1')), + array('config.update', array('version', '3.0.7-RC1')), ); } diff --git a/phpBB/phpbb/db/migration/data/30x/3_0_7_rc2.php b/phpBB/phpbb/db/migration/data/30x/3_0_7_rc2.php index 55bc2bc679..0e43229f13 100644 --- a/phpBB/phpbb/db/migration/data/30x/3_0_7_rc2.php +++ b/phpBB/phpbb/db/migration/data/30x/3_0_7_rc2.php @@ -11,7 +11,7 @@ class phpbb_db_migration_data_30x_3_0_7_rc2 extends phpbb_db_migration { public function effectively_installed() { - return version_compare($this->config['version'], '3.0.7-rc2', '>='); + return version_compare($this->config['version'], '3.0.7-RC2', '>='); } static public function depends_on() @@ -24,7 +24,7 @@ class phpbb_db_migration_data_30x_3_0_7_rc2 extends phpbb_db_migration return array( array('custom', array(array(&$this, 'update_email_hash'))), - array('config.update', array('version', '3.0.7-rc2')), + array('config.update', array('version', '3.0.7-RC2')), ); } diff --git a/phpBB/phpbb/db/migration/data/30x/3_0_8_rc1.php b/phpBB/phpbb/db/migration/data/30x/3_0_8_rc1.php index aeff35333e..ff7824fa3b 100644 --- a/phpBB/phpbb/db/migration/data/30x/3_0_8_rc1.php +++ b/phpBB/phpbb/db/migration/data/30x/3_0_8_rc1.php @@ -11,7 +11,7 @@ class phpbb_db_migration_data_30x_3_0_8_rc1 extends phpbb_db_migration { public function effectively_installed() { - return version_compare($this->config['version'], '3.0.8-rc1', '>='); + return version_compare($this->config['version'], '3.0.8-RC1', '>='); } static public function depends_on() @@ -38,7 +38,7 @@ class phpbb_db_migration_data_30x_3_0_8_rc1 extends phpbb_db_migration array('config.update_if_equals', array(600, 'queue_interval', 60)), array('config.update_if_equals', array(50, 'email_package_size', 20)), - array('config.update', array('version', '3.0.8-rc1')), + array('config.update', array('version', '3.0.8-RC1')), ); } diff --git a/phpBB/phpbb/db/migration/data/30x/3_0_9_rc1.php b/phpBB/phpbb/db/migration/data/30x/3_0_9_rc1.php index 4c345b429b..d3beda63b7 100644 --- a/phpBB/phpbb/db/migration/data/30x/3_0_9_rc1.php +++ b/phpBB/phpbb/db/migration/data/30x/3_0_9_rc1.php @@ -11,7 +11,7 @@ class phpbb_db_migration_data_30x_3_0_9_rc1 extends phpbb_db_migration { public function effectively_installed() { - return version_compare($this->config['version'], '3.0.9-rc1', '>='); + return version_compare($this->config['version'], '3.0.9-RC1', '>='); } static public function depends_on() @@ -74,7 +74,7 @@ class phpbb_db_migration_data_30x_3_0_9_rc1 extends phpbb_db_migration array('custom', array(array(&$this, 'update_file_extension_group_names'))), array('custom', array(array(&$this, 'fix_firebird_qa_captcha'))), - array('config.update', array('version', '3.0.9-rc1')), + array('config.update', array('version', '3.0.9-RC1')), ); } diff --git a/phpBB/phpbb/db/migration/data/30x/3_0_9_rc2.php b/phpBB/phpbb/db/migration/data/30x/3_0_9_rc2.php index c0e662aa45..beb8873da7 100644 --- a/phpBB/phpbb/db/migration/data/30x/3_0_9_rc2.php +++ b/phpBB/phpbb/db/migration/data/30x/3_0_9_rc2.php @@ -11,7 +11,7 @@ class phpbb_db_migration_data_30x_3_0_9_rc2 extends phpbb_db_migration { public function effectively_installed() { - return version_compare($this->config['version'], '3.0.9-rc2', '>='); + return version_compare($this->config['version'], '3.0.9-RC2', '>='); } static public function depends_on() @@ -22,7 +22,7 @@ class phpbb_db_migration_data_30x_3_0_9_rc2 extends phpbb_db_migration public function update_data() { return array( - array('config.update', array('version', '3.0.9-rc2')), + array('config.update', array('version', '3.0.9-RC2')), ); } } diff --git a/phpBB/phpbb/db/migration/data/30x/3_0_9_rc3.php b/phpBB/phpbb/db/migration/data/30x/3_0_9_rc3.php index d6d1f14b2e..56e04e7235 100644 --- a/phpBB/phpbb/db/migration/data/30x/3_0_9_rc3.php +++ b/phpBB/phpbb/db/migration/data/30x/3_0_9_rc3.php @@ -11,7 +11,7 @@ class phpbb_db_migration_data_30x_3_0_9_rc3 extends phpbb_db_migration { public function effectively_installed() { - return version_compare($this->config['version'], '3.0.9-rc3', '>='); + return version_compare($this->config['version'], '3.0.9-RC3', '>='); } static public function depends_on() @@ -22,7 +22,7 @@ class phpbb_db_migration_data_30x_3_0_9_rc3 extends phpbb_db_migration public function update_data() { return array( - array('config.update', array('version', '3.0.9-rc3')), + array('config.update', array('version', '3.0.9-RC3')), ); } } diff --git a/phpBB/phpbb/db/migration/data/30x/3_0_9_rc4.php b/phpBB/phpbb/db/migration/data/30x/3_0_9_rc4.php index e673249343..5be1124287 100644 --- a/phpBB/phpbb/db/migration/data/30x/3_0_9_rc4.php +++ b/phpBB/phpbb/db/migration/data/30x/3_0_9_rc4.php @@ -11,7 +11,7 @@ class phpbb_db_migration_data_30x_3_0_9_rc4 extends phpbb_db_migration { public function effectively_installed() { - return version_compare($this->config['version'], '3.0.9-rc4', '>='); + return version_compare($this->config['version'], '3.0.9-RC4', '>='); } static public function depends_on() @@ -22,7 +22,7 @@ class phpbb_db_migration_data_30x_3_0_9_rc4 extends phpbb_db_migration public function update_data() { return array( - array('config.update', array('version', '3.0.9-rc4')), + array('config.update', array('version', '3.0.9-RC4')), ); } } From e667481c6c3d98808ac412531f562d68fad10ae5 Mon Sep 17 00:00:00 2001 From: Oliver Schramm Date: Fri, 2 Aug 2013 03:28:32 +0200 Subject: [PATCH 2408/2494] [ticket/11760] Use phpbb_version_compare() wrapper PHPBB3-11760 --- phpBB/phpbb/db/migration/data/30x/3_0_1.php | 2 +- phpBB/phpbb/db/migration/data/30x/3_0_10.php | 2 +- phpBB/phpbb/db/migration/data/30x/3_0_10_rc1.php | 2 +- phpBB/phpbb/db/migration/data/30x/3_0_10_rc2.php | 2 +- phpBB/phpbb/db/migration/data/30x/3_0_10_rc3.php | 2 +- phpBB/phpbb/db/migration/data/30x/3_0_11.php | 2 +- phpBB/phpbb/db/migration/data/30x/3_0_11_rc1.php | 2 +- phpBB/phpbb/db/migration/data/30x/3_0_11_rc2.php | 2 +- phpBB/phpbb/db/migration/data/30x/3_0_12_rc1.php | 2 +- phpBB/phpbb/db/migration/data/30x/3_0_1_rc1.php | 2 +- phpBB/phpbb/db/migration/data/30x/3_0_2.php | 2 +- phpBB/phpbb/db/migration/data/30x/3_0_2_rc1.php | 2 +- phpBB/phpbb/db/migration/data/30x/3_0_2_rc2.php | 2 +- phpBB/phpbb/db/migration/data/30x/3_0_3.php | 2 +- phpBB/phpbb/db/migration/data/30x/3_0_3_rc1.php | 2 +- phpBB/phpbb/db/migration/data/30x/3_0_4.php | 2 +- phpBB/phpbb/db/migration/data/30x/3_0_4_rc1.php | 2 +- phpBB/phpbb/db/migration/data/30x/3_0_5.php | 2 +- phpBB/phpbb/db/migration/data/30x/3_0_5_rc1.php | 2 +- phpBB/phpbb/db/migration/data/30x/3_0_5_rc1part2.php | 2 +- phpBB/phpbb/db/migration/data/30x/3_0_6.php | 2 +- phpBB/phpbb/db/migration/data/30x/3_0_6_rc1.php | 2 +- phpBB/phpbb/db/migration/data/30x/3_0_6_rc2.php | 2 +- phpBB/phpbb/db/migration/data/30x/3_0_6_rc3.php | 2 +- phpBB/phpbb/db/migration/data/30x/3_0_6_rc4.php | 2 +- phpBB/phpbb/db/migration/data/30x/3_0_7.php | 2 +- phpBB/phpbb/db/migration/data/30x/3_0_7_pl1.php | 2 +- phpBB/phpbb/db/migration/data/30x/3_0_7_rc1.php | 2 +- phpBB/phpbb/db/migration/data/30x/3_0_7_rc2.php | 2 +- phpBB/phpbb/db/migration/data/30x/3_0_8.php | 2 +- phpBB/phpbb/db/migration/data/30x/3_0_8_rc1.php | 2 +- phpBB/phpbb/db/migration/data/30x/3_0_9.php | 2 +- phpBB/phpbb/db/migration/data/30x/3_0_9_rc1.php | 2 +- phpBB/phpbb/db/migration/data/30x/3_0_9_rc2.php | 2 +- phpBB/phpbb/db/migration/data/30x/3_0_9_rc3.php | 2 +- phpBB/phpbb/db/migration/data/30x/3_0_9_rc4.php | 2 +- 36 files changed, 36 insertions(+), 36 deletions(-) diff --git a/phpBB/phpbb/db/migration/data/30x/3_0_1.php b/phpBB/phpbb/db/migration/data/30x/3_0_1.php index c996a0138a..c5b1681d96 100644 --- a/phpBB/phpbb/db/migration/data/30x/3_0_1.php +++ b/phpBB/phpbb/db/migration/data/30x/3_0_1.php @@ -11,7 +11,7 @@ class phpbb_db_migration_data_30x_3_0_1 extends phpbb_db_migration { public function effectively_installed() { - return version_compare($this->config['version'], '3.0.1', '>='); + return phpbb_version_compare($this->config['version'], '3.0.1', '>='); } static public function depends_on() diff --git a/phpBB/phpbb/db/migration/data/30x/3_0_10.php b/phpBB/phpbb/db/migration/data/30x/3_0_10.php index 122f93d6b4..640fcbc16f 100644 --- a/phpBB/phpbb/db/migration/data/30x/3_0_10.php +++ b/phpBB/phpbb/db/migration/data/30x/3_0_10.php @@ -11,7 +11,7 @@ class phpbb_db_migration_data_30x_3_0_10 extends phpbb_db_migration { public function effectively_installed() { - return version_compare($this->config['version'], '3.0.10', '>='); + return phpbb_version_compare($this->config['version'], '3.0.10', '>='); } static public function depends_on() diff --git a/phpBB/phpbb/db/migration/data/30x/3_0_10_rc1.php b/phpBB/phpbb/db/migration/data/30x/3_0_10_rc1.php index 459b423736..e0aca09c3a 100644 --- a/phpBB/phpbb/db/migration/data/30x/3_0_10_rc1.php +++ b/phpBB/phpbb/db/migration/data/30x/3_0_10_rc1.php @@ -11,7 +11,7 @@ class phpbb_db_migration_data_30x_3_0_10_rc1 extends phpbb_db_migration { public function effectively_installed() { - return version_compare($this->config['version'], '3.0.10-RC1', '>='); + return phpbb_version_compare($this->config['version'], '3.0.10-RC1', '>='); } static public function depends_on() diff --git a/phpBB/phpbb/db/migration/data/30x/3_0_10_rc2.php b/phpBB/phpbb/db/migration/data/30x/3_0_10_rc2.php index 8d21cab45d..394e030acf 100644 --- a/phpBB/phpbb/db/migration/data/30x/3_0_10_rc2.php +++ b/phpBB/phpbb/db/migration/data/30x/3_0_10_rc2.php @@ -11,7 +11,7 @@ class phpbb_db_migration_data_30x_3_0_10_rc2 extends phpbb_db_migration { public function effectively_installed() { - return version_compare($this->config['version'], '3.0.10-RC2', '>='); + return phpbb_version_compare($this->config['version'], '3.0.10-RC2', '>='); } static public function depends_on() diff --git a/phpBB/phpbb/db/migration/data/30x/3_0_10_rc3.php b/phpBB/phpbb/db/migration/data/30x/3_0_10_rc3.php index 296c3c40af..92900e3aed 100644 --- a/phpBB/phpbb/db/migration/data/30x/3_0_10_rc3.php +++ b/phpBB/phpbb/db/migration/data/30x/3_0_10_rc3.php @@ -11,7 +11,7 @@ class phpbb_db_migration_data_30x_3_0_10_rc3 extends phpbb_db_migration { public function effectively_installed() { - return version_compare($this->config['version'], '3.0.10-RC3', '>='); + return phpbb_version_compare($this->config['version'], '3.0.10-RC3', '>='); } static public function depends_on() diff --git a/phpBB/phpbb/db/migration/data/30x/3_0_11.php b/phpBB/phpbb/db/migration/data/30x/3_0_11.php index e063c699cc..3be03cec40 100644 --- a/phpBB/phpbb/db/migration/data/30x/3_0_11.php +++ b/phpBB/phpbb/db/migration/data/30x/3_0_11.php @@ -11,7 +11,7 @@ class phpbb_db_migration_data_30x_3_0_11 extends phpbb_db_migration { public function effectively_installed() { - return version_compare($this->config['version'], '3.0.11', '>='); + return phpbb_version_compare($this->config['version'], '3.0.11', '>='); } static public function depends_on() diff --git a/phpBB/phpbb/db/migration/data/30x/3_0_11_rc1.php b/phpBB/phpbb/db/migration/data/30x/3_0_11_rc1.php index 3a3908258f..f7b0247fdb 100644 --- a/phpBB/phpbb/db/migration/data/30x/3_0_11_rc1.php +++ b/phpBB/phpbb/db/migration/data/30x/3_0_11_rc1.php @@ -11,7 +11,7 @@ class phpbb_db_migration_data_30x_3_0_11_rc1 extends phpbb_db_migration { public function effectively_installed() { - return version_compare($this->config['version'], '3.0.11-RC1', '>='); + return phpbb_version_compare($this->config['version'], '3.0.11-RC1', '>='); } static public function depends_on() diff --git a/phpBB/phpbb/db/migration/data/30x/3_0_11_rc2.php b/phpBB/phpbb/db/migration/data/30x/3_0_11_rc2.php index 4b1b5642ce..204aa314ac 100644 --- a/phpBB/phpbb/db/migration/data/30x/3_0_11_rc2.php +++ b/phpBB/phpbb/db/migration/data/30x/3_0_11_rc2.php @@ -11,7 +11,7 @@ class phpbb_db_migration_data_30x_3_0_11_rc2 extends phpbb_db_migration { public function effectively_installed() { - return version_compare($this->config['version'], '3.0.11-RC2', '>='); + return phpbb_version_compare($this->config['version'], '3.0.11-RC2', '>='); } static public function depends_on() diff --git a/phpBB/phpbb/db/migration/data/30x/3_0_12_rc1.php b/phpBB/phpbb/db/migration/data/30x/3_0_12_rc1.php index 97331e9bb2..28ee84469a 100644 --- a/phpBB/phpbb/db/migration/data/30x/3_0_12_rc1.php +++ b/phpBB/phpbb/db/migration/data/30x/3_0_12_rc1.php @@ -13,7 +13,7 @@ class phpbb_db_migration_data_30x_3_0_12_rc1 extends phpbb_db_migration { public function effectively_installed() { - return version_compare($this->config['version'], '3.0.12-RC1', '>='); + return phpbb_version_compare($this->config['version'], '3.0.12-RC1', '>='); } static public function depends_on() diff --git a/phpBB/phpbb/db/migration/data/30x/3_0_1_rc1.php b/phpBB/phpbb/db/migration/data/30x/3_0_1_rc1.php index 761ed5d2ec..984b8fb37e 100644 --- a/phpBB/phpbb/db/migration/data/30x/3_0_1_rc1.php +++ b/phpBB/phpbb/db/migration/data/30x/3_0_1_rc1.php @@ -11,7 +11,7 @@ class phpbb_db_migration_data_30x_3_0_1_rc1 extends phpbb_db_migration { public function effectively_installed() { - return version_compare($this->config['version'], '3.0.1-RC1', '>='); + return phpbb_version_compare($this->config['version'], '3.0.1-RC1', '>='); } public function update_schema() diff --git a/phpBB/phpbb/db/migration/data/30x/3_0_2.php b/phpBB/phpbb/db/migration/data/30x/3_0_2.php index eed5acef82..6e11e5a145 100644 --- a/phpBB/phpbb/db/migration/data/30x/3_0_2.php +++ b/phpBB/phpbb/db/migration/data/30x/3_0_2.php @@ -11,7 +11,7 @@ class phpbb_db_migration_data_30x_3_0_2 extends phpbb_db_migration { public function effectively_installed() { - return version_compare($this->config['version'], '3.0.2', '>='); + return phpbb_version_compare($this->config['version'], '3.0.2', '>='); } static public function depends_on() diff --git a/phpBB/phpbb/db/migration/data/30x/3_0_2_rc1.php b/phpBB/phpbb/db/migration/data/30x/3_0_2_rc1.php index a84f3c2d92..9a25628f25 100644 --- a/phpBB/phpbb/db/migration/data/30x/3_0_2_rc1.php +++ b/phpBB/phpbb/db/migration/data/30x/3_0_2_rc1.php @@ -11,7 +11,7 @@ class phpbb_db_migration_data_30x_3_0_2_rc1 extends phpbb_db_migration { public function effectively_installed() { - return version_compare($this->config['version'], '3.0.2-RC1', '>='); + return phpbb_version_compare($this->config['version'], '3.0.2-RC1', '>='); } static public function depends_on() diff --git a/phpBB/phpbb/db/migration/data/30x/3_0_2_rc2.php b/phpBB/phpbb/db/migration/data/30x/3_0_2_rc2.php index 33bacc077f..6c37d6701b 100644 --- a/phpBB/phpbb/db/migration/data/30x/3_0_2_rc2.php +++ b/phpBB/phpbb/db/migration/data/30x/3_0_2_rc2.php @@ -11,7 +11,7 @@ class phpbb_db_migration_data_30x_3_0_2_rc2 extends phpbb_db_migration { public function effectively_installed() { - return version_compare($this->config['version'], '3.0.2-RC2', '>='); + return phpbb_version_compare($this->config['version'], '3.0.2-RC2', '>='); } static public function depends_on() diff --git a/phpBB/phpbb/db/migration/data/30x/3_0_3.php b/phpBB/phpbb/db/migration/data/30x/3_0_3.php index 8984cf7b76..11fd2a2e80 100644 --- a/phpBB/phpbb/db/migration/data/30x/3_0_3.php +++ b/phpBB/phpbb/db/migration/data/30x/3_0_3.php @@ -11,7 +11,7 @@ class phpbb_db_migration_data_30x_3_0_3 extends phpbb_db_migration { public function effectively_installed() { - return version_compare($this->config['version'], '3.0.3', '>='); + return phpbb_version_compare($this->config['version'], '3.0.3', '>='); } static public function depends_on() diff --git a/phpBB/phpbb/db/migration/data/30x/3_0_3_rc1.php b/phpBB/phpbb/db/migration/data/30x/3_0_3_rc1.php index 69433f386e..cbeb00499a 100644 --- a/phpBB/phpbb/db/migration/data/30x/3_0_3_rc1.php +++ b/phpBB/phpbb/db/migration/data/30x/3_0_3_rc1.php @@ -11,7 +11,7 @@ class phpbb_db_migration_data_30x_3_0_3_rc1 extends phpbb_db_migration { public function effectively_installed() { - return version_compare($this->config['version'], '3.0.3-RC1', '>='); + return phpbb_version_compare($this->config['version'], '3.0.3-RC1', '>='); } static public function depends_on() diff --git a/phpBB/phpbb/db/migration/data/30x/3_0_4.php b/phpBB/phpbb/db/migration/data/30x/3_0_4.php index 9a0c132e78..4375a96dac 100644 --- a/phpBB/phpbb/db/migration/data/30x/3_0_4.php +++ b/phpBB/phpbb/db/migration/data/30x/3_0_4.php @@ -11,7 +11,7 @@ class phpbb_db_migration_data_30x_3_0_4 extends phpbb_db_migration { public function effectively_installed() { - return version_compare($this->config['version'], '3.0.4', '>='); + return phpbb_version_compare($this->config['version'], '3.0.4', '>='); } static public function depends_on() diff --git a/phpBB/phpbb/db/migration/data/30x/3_0_4_rc1.php b/phpBB/phpbb/db/migration/data/30x/3_0_4_rc1.php index e45bd3eeee..73334dcc6f 100644 --- a/phpBB/phpbb/db/migration/data/30x/3_0_4_rc1.php +++ b/phpBB/phpbb/db/migration/data/30x/3_0_4_rc1.php @@ -11,7 +11,7 @@ class phpbb_db_migration_data_30x_3_0_4_rc1 extends phpbb_db_migration { public function effectively_installed() { - return version_compare($this->config['version'], '3.0.4-RC1', '>='); + return phpbb_version_compare($this->config['version'], '3.0.4-RC1', '>='); } static public function depends_on() diff --git a/phpBB/phpbb/db/migration/data/30x/3_0_5.php b/phpBB/phpbb/db/migration/data/30x/3_0_5.php index 16d2dee457..2700274f35 100644 --- a/phpBB/phpbb/db/migration/data/30x/3_0_5.php +++ b/phpBB/phpbb/db/migration/data/30x/3_0_5.php @@ -11,7 +11,7 @@ class phpbb_db_migration_data_30x_3_0_5 extends phpbb_db_migration { public function effectively_installed() { - return version_compare($this->config['version'], '3.0.5', '>='); + return phpbb_version_compare($this->config['version'], '3.0.5', '>='); } static public function depends_on() diff --git a/phpBB/phpbb/db/migration/data/30x/3_0_5_rc1.php b/phpBB/phpbb/db/migration/data/30x/3_0_5_rc1.php index 62ae7bff1a..90c6b3b46a 100644 --- a/phpBB/phpbb/db/migration/data/30x/3_0_5_rc1.php +++ b/phpBB/phpbb/db/migration/data/30x/3_0_5_rc1.php @@ -11,7 +11,7 @@ class phpbb_db_migration_data_30x_3_0_5_rc1 extends phpbb_db_migration { public function effectively_installed() { - return version_compare($this->config['version'], '3.0.5-RC1', '>='); + return phpbb_version_compare($this->config['version'], '3.0.5-RC1', '>='); } static public function depends_on() diff --git a/phpBB/phpbb/db/migration/data/30x/3_0_5_rc1part2.php b/phpBB/phpbb/db/migration/data/30x/3_0_5_rc1part2.php index d72176489b..2d1e5cfed8 100644 --- a/phpBB/phpbb/db/migration/data/30x/3_0_5_rc1part2.php +++ b/phpBB/phpbb/db/migration/data/30x/3_0_5_rc1part2.php @@ -11,7 +11,7 @@ class phpbb_db_migration_data_30x_3_0_5_rc1part2 extends phpbb_db_migration { public function effectively_installed() { - return version_compare($this->config['version'], '3.0.5-RC1', '>='); + return phpbb_version_compare($this->config['version'], '3.0.5-RC1', '>='); } static public function depends_on() diff --git a/phpBB/phpbb/db/migration/data/30x/3_0_6.php b/phpBB/phpbb/db/migration/data/30x/3_0_6.php index bb651dc7cd..1877b0c5a1 100644 --- a/phpBB/phpbb/db/migration/data/30x/3_0_6.php +++ b/phpBB/phpbb/db/migration/data/30x/3_0_6.php @@ -11,7 +11,7 @@ class phpbb_db_migration_data_30x_3_0_6 extends phpbb_db_migration { public function effectively_installed() { - return version_compare($this->config['version'], '3.0.6', '>='); + return phpbb_version_compare($this->config['version'], '3.0.6', '>='); } static public function depends_on() diff --git a/phpBB/phpbb/db/migration/data/30x/3_0_6_rc1.php b/phpBB/phpbb/db/migration/data/30x/3_0_6_rc1.php index 25f4995b0e..3e2a9544c7 100644 --- a/phpBB/phpbb/db/migration/data/30x/3_0_6_rc1.php +++ b/phpBB/phpbb/db/migration/data/30x/3_0_6_rc1.php @@ -11,7 +11,7 @@ class phpbb_db_migration_data_30x_3_0_6_rc1 extends phpbb_db_migration { public function effectively_installed() { - return version_compare($this->config['version'], '3.0.6-RC1', '>='); + return phpbb_version_compare($this->config['version'], '3.0.6-RC1', '>='); } static public function depends_on() diff --git a/phpBB/phpbb/db/migration/data/30x/3_0_6_rc2.php b/phpBB/phpbb/db/migration/data/30x/3_0_6_rc2.php index d5d14ab05d..439e25b100 100644 --- a/phpBB/phpbb/db/migration/data/30x/3_0_6_rc2.php +++ b/phpBB/phpbb/db/migration/data/30x/3_0_6_rc2.php @@ -11,7 +11,7 @@ class phpbb_db_migration_data_30x_3_0_6_rc2 extends phpbb_db_migration { public function effectively_installed() { - return version_compare($this->config['version'], '3.0.6-RC2', '>='); + return phpbb_version_compare($this->config['version'], '3.0.6-RC2', '>='); } static public function depends_on() diff --git a/phpBB/phpbb/db/migration/data/30x/3_0_6_rc3.php b/phpBB/phpbb/db/migration/data/30x/3_0_6_rc3.php index f3f1fb42f4..77b62d7fc7 100644 --- a/phpBB/phpbb/db/migration/data/30x/3_0_6_rc3.php +++ b/phpBB/phpbb/db/migration/data/30x/3_0_6_rc3.php @@ -11,7 +11,7 @@ class phpbb_db_migration_data_30x_3_0_6_rc3 extends phpbb_db_migration { public function effectively_installed() { - return version_compare($this->config['version'], '3.0.6-RC3', '>='); + return phpbb_version_compare($this->config['version'], '3.0.6-RC3', '>='); } static public function depends_on() diff --git a/phpBB/phpbb/db/migration/data/30x/3_0_6_rc4.php b/phpBB/phpbb/db/migration/data/30x/3_0_6_rc4.php index 6138ef351d..61a31d09e6 100644 --- a/phpBB/phpbb/db/migration/data/30x/3_0_6_rc4.php +++ b/phpBB/phpbb/db/migration/data/30x/3_0_6_rc4.php @@ -11,7 +11,7 @@ class phpbb_db_migration_data_30x_3_0_6_rc4 extends phpbb_db_migration { public function effectively_installed() { - return version_compare($this->config['version'], '3.0.6-RC4', '>='); + return phpbb_version_compare($this->config['version'], '3.0.6-RC4', '>='); } static public function depends_on() diff --git a/phpBB/phpbb/db/migration/data/30x/3_0_7.php b/phpBB/phpbb/db/migration/data/30x/3_0_7.php index 9ff2e9e4ab..3eb1caddbc 100644 --- a/phpBB/phpbb/db/migration/data/30x/3_0_7.php +++ b/phpBB/phpbb/db/migration/data/30x/3_0_7.php @@ -11,7 +11,7 @@ class phpbb_db_migration_data_30x_3_0_7 extends phpbb_db_migration { public function effectively_installed() { - return version_compare($this->config['version'], '3.0.7', '>='); + return phpbb_version_compare($this->config['version'], '3.0.7', '>='); } static public function depends_on() diff --git a/phpBB/phpbb/db/migration/data/30x/3_0_7_pl1.php b/phpBB/phpbb/db/migration/data/30x/3_0_7_pl1.php index c9cc9d19ac..c7b5c584ac 100644 --- a/phpBB/phpbb/db/migration/data/30x/3_0_7_pl1.php +++ b/phpBB/phpbb/db/migration/data/30x/3_0_7_pl1.php @@ -11,7 +11,7 @@ class phpbb_db_migration_data_30x_3_0_7_pl1 extends phpbb_db_migration { public function effectively_installed() { - return version_compare($this->config['version'], '3.0.7-pl1', '>='); + return phpbb_version_compare($this->config['version'], '3.0.7-pl1', '>='); } static public function depends_on() diff --git a/phpBB/phpbb/db/migration/data/30x/3_0_7_rc1.php b/phpBB/phpbb/db/migration/data/30x/3_0_7_rc1.php index be8f9045f4..e0fd313834 100644 --- a/phpBB/phpbb/db/migration/data/30x/3_0_7_rc1.php +++ b/phpBB/phpbb/db/migration/data/30x/3_0_7_rc1.php @@ -11,7 +11,7 @@ class phpbb_db_migration_data_30x_3_0_7_rc1 extends phpbb_db_migration { public function effectively_installed() { - return version_compare($this->config['version'], '3.0.7-RC1', '>='); + return phpbb_version_compare($this->config['version'], '3.0.7-RC1', '>='); } static public function depends_on() diff --git a/phpBB/phpbb/db/migration/data/30x/3_0_7_rc2.php b/phpBB/phpbb/db/migration/data/30x/3_0_7_rc2.php index 0e43229f13..f4f3327385 100644 --- a/phpBB/phpbb/db/migration/data/30x/3_0_7_rc2.php +++ b/phpBB/phpbb/db/migration/data/30x/3_0_7_rc2.php @@ -11,7 +11,7 @@ class phpbb_db_migration_data_30x_3_0_7_rc2 extends phpbb_db_migration { public function effectively_installed() { - return version_compare($this->config['version'], '3.0.7-RC2', '>='); + return phpbb_version_compare($this->config['version'], '3.0.7-RC2', '>='); } static public function depends_on() diff --git a/phpBB/phpbb/db/migration/data/30x/3_0_8.php b/phpBB/phpbb/db/migration/data/30x/3_0_8.php index 8998ef9627..77771a9acd 100644 --- a/phpBB/phpbb/db/migration/data/30x/3_0_8.php +++ b/phpBB/phpbb/db/migration/data/30x/3_0_8.php @@ -11,7 +11,7 @@ class phpbb_db_migration_data_30x_3_0_8 extends phpbb_db_migration { public function effectively_installed() { - return version_compare($this->config['version'], '3.0.8', '>='); + return phpbb_version_compare($this->config['version'], '3.0.8', '>='); } static public function depends_on() diff --git a/phpBB/phpbb/db/migration/data/30x/3_0_8_rc1.php b/phpBB/phpbb/db/migration/data/30x/3_0_8_rc1.php index ff7824fa3b..c534cabb6c 100644 --- a/phpBB/phpbb/db/migration/data/30x/3_0_8_rc1.php +++ b/phpBB/phpbb/db/migration/data/30x/3_0_8_rc1.php @@ -11,7 +11,7 @@ class phpbb_db_migration_data_30x_3_0_8_rc1 extends phpbb_db_migration { public function effectively_installed() { - return version_compare($this->config['version'], '3.0.8-RC1', '>='); + return phpbb_version_compare($this->config['version'], '3.0.8-RC1', '>='); } static public function depends_on() diff --git a/phpBB/phpbb/db/migration/data/30x/3_0_9.php b/phpBB/phpbb/db/migration/data/30x/3_0_9.php index d5269ea6f0..6a38793269 100644 --- a/phpBB/phpbb/db/migration/data/30x/3_0_9.php +++ b/phpBB/phpbb/db/migration/data/30x/3_0_9.php @@ -11,7 +11,7 @@ class phpbb_db_migration_data_30x_3_0_9 extends phpbb_db_migration { public function effectively_installed() { - return version_compare($this->config['version'], '3.0.9', '>='); + return phpbb_version_compare($this->config['version'], '3.0.9', '>='); } static public function depends_on() diff --git a/phpBB/phpbb/db/migration/data/30x/3_0_9_rc1.php b/phpBB/phpbb/db/migration/data/30x/3_0_9_rc1.php index d3beda63b7..81c67550bd 100644 --- a/phpBB/phpbb/db/migration/data/30x/3_0_9_rc1.php +++ b/phpBB/phpbb/db/migration/data/30x/3_0_9_rc1.php @@ -11,7 +11,7 @@ class phpbb_db_migration_data_30x_3_0_9_rc1 extends phpbb_db_migration { public function effectively_installed() { - return version_compare($this->config['version'], '3.0.9-RC1', '>='); + return phpbb_version_compare($this->config['version'], '3.0.9-RC1', '>='); } static public function depends_on() diff --git a/phpBB/phpbb/db/migration/data/30x/3_0_9_rc2.php b/phpBB/phpbb/db/migration/data/30x/3_0_9_rc2.php index beb8873da7..1531f408b7 100644 --- a/phpBB/phpbb/db/migration/data/30x/3_0_9_rc2.php +++ b/phpBB/phpbb/db/migration/data/30x/3_0_9_rc2.php @@ -11,7 +11,7 @@ class phpbb_db_migration_data_30x_3_0_9_rc2 extends phpbb_db_migration { public function effectively_installed() { - return version_compare($this->config['version'], '3.0.9-RC2', '>='); + return phpbb_version_compare($this->config['version'], '3.0.9-RC2', '>='); } static public function depends_on() diff --git a/phpBB/phpbb/db/migration/data/30x/3_0_9_rc3.php b/phpBB/phpbb/db/migration/data/30x/3_0_9_rc3.php index 56e04e7235..851680b093 100644 --- a/phpBB/phpbb/db/migration/data/30x/3_0_9_rc3.php +++ b/phpBB/phpbb/db/migration/data/30x/3_0_9_rc3.php @@ -11,7 +11,7 @@ class phpbb_db_migration_data_30x_3_0_9_rc3 extends phpbb_db_migration { public function effectively_installed() { - return version_compare($this->config['version'], '3.0.9-RC3', '>='); + return phpbb_version_compare($this->config['version'], '3.0.9-RC3', '>='); } static public function depends_on() diff --git a/phpBB/phpbb/db/migration/data/30x/3_0_9_rc4.php b/phpBB/phpbb/db/migration/data/30x/3_0_9_rc4.php index 5be1124287..879538c341 100644 --- a/phpBB/phpbb/db/migration/data/30x/3_0_9_rc4.php +++ b/phpBB/phpbb/db/migration/data/30x/3_0_9_rc4.php @@ -11,7 +11,7 @@ class phpbb_db_migration_data_30x_3_0_9_rc4 extends phpbb_db_migration { public function effectively_installed() { - return version_compare($this->config['version'], '3.0.9-RC4', '>='); + return phpbb_version_compare($this->config['version'], '3.0.9-RC4', '>='); } static public function depends_on() From d7e048da10d17beeda85e67bc6fcf8649716441a Mon Sep 17 00:00:00 2001 From: rechosen Date: Sun, 14 Jul 2013 21:30:14 +0200 Subject: [PATCH 2409/2494] [ticket/9550] Add template event memberlist_view_user_statistics_before Adds a template event required for the karma extension. It allows adding entries to the user statistics part of any user profile. Explanation from http://area51.phpbb.com/phpBB/viewtopic.php?f=111&t=44379: Used by the karma extension to add a karma score indication that allows other users to see how respected this user is. Prepend because karma score is often a more meaningful statistic than the bottom statistics (like "Most active topic"), and should therefore be more prominent. PHPBB3-9550 --- phpBB/styles/prosilver/template/memberlist_view.html | 1 + phpBB/styles/subsilver2/template/memberlist_view.html | 1 + 2 files changed, 2 insertions(+) diff --git a/phpBB/styles/prosilver/template/memberlist_view.html b/phpBB/styles/prosilver/template/memberlist_view.html index 57cfcb86d9..b339e07d37 100644 --- a/phpBB/styles/prosilver/template/memberlist_view.html +++ b/phpBB/styles/prosilver/template/memberlist_view.html @@ -77,6 +77,7 @@

    {L_USER_FORUM}

    +
    {L_JOINED}{L_COLON}
    {JOINED}
    {L_VISITED}{L_COLON}
    {VISITED}
    diff --git a/phpBB/styles/subsilver2/template/memberlist_view.html b/phpBB/styles/subsilver2/template/memberlist_view.html index 464369a7a8..e097e09565 100644 --- a/phpBB/styles/subsilver2/template/memberlist_view.html +++ b/phpBB/styles/subsilver2/template/memberlist_view.html @@ -66,6 +66,7 @@
    From ef7861bffc557e5f979ec91704d4a4da398484bc Mon Sep 17 00:00:00 2001 From: rechosen Date: Sun, 14 Jul 2013 22:06:41 +0200 Subject: [PATCH 2411/2494] [ticket/9550] Add template event viewtopic_body_post_buttons_after Adds a template event required for the karma extension. It allows adding post buttons to posts (next to the quote and edit buttons). Explanation from http://area51.phpbb.com/phpBB/viewtopic.php?f=111&t=44379: Used by the karma extension to add thumbs up/down icons that allow users to give karma on posts. PHPBB3-9550 --- phpBB/styles/prosilver/template/viewtopic_body.html | 1 + phpBB/styles/subsilver2/template/viewtopic_body.html | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/phpBB/styles/prosilver/template/viewtopic_body.html b/phpBB/styles/prosilver/template/viewtopic_body.html index a8bac42842..54f0b27c4d 100644 --- a/phpBB/styles/prosilver/template/viewtopic_body.html +++ b/phpBB/styles/prosilver/template/viewtopic_body.html @@ -142,6 +142,7 @@
  • {L_WARN_USER}
  • {L_INFORMATION}
  • {L_REPLY_WITH_QUOTE}
  • + diff --git a/phpBB/styles/subsilver2/template/viewtopic_body.html b/phpBB/styles/subsilver2/template/viewtopic_body.html index 299b8219eb..9398953532 100644 --- a/phpBB/styles/subsilver2/template/viewtopic_body.html +++ b/phpBB/styles/subsilver2/template/viewtopic_body.html @@ -315,7 +315,7 @@
    - + From fd8ab9255981f9e613a0f0419c3115e4c470c5a7 Mon Sep 17 00:00:00 2001 From: rechosen Date: Sun, 14 Jul 2013 22:19:37 +0200 Subject: [PATCH 2412/2494] [ticket/9550] Add template event viewtopic_body_post_buttons_before Adds the prepend counterpart of a template event required for the karma extension. It allows adding post buttons to posts (next to the quote and edit buttons). Explanation from http://area51.phpbb.com/phpBB/viewtopic.php?f=111&t=44379: Per suggestion of nickvergessen, add a counterpart for every append or prepend event. PHPBB3-9550 --- phpBB/styles/prosilver/template/viewtopic_body.html | 1 + phpBB/styles/subsilver2/template/viewtopic_body.html | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/phpBB/styles/prosilver/template/viewtopic_body.html b/phpBB/styles/prosilver/template/viewtopic_body.html index 54f0b27c4d..bc8a71c9bf 100644 --- a/phpBB/styles/prosilver/template/viewtopic_body.html +++ b/phpBB/styles/prosilver/template/viewtopic_body.html @@ -136,6 +136,7 @@
      +
    • {L_EDIT_POST}
    • {L_DELETE_POST}
    • {L_REPORT_POST}
    • diff --git a/phpBB/styles/subsilver2/template/viewtopic_body.html b/phpBB/styles/subsilver2/template/viewtopic_body.html index 9398953532..38847d0805 100644 --- a/phpBB/styles/subsilver2/template/viewtopic_body.html +++ b/phpBB/styles/subsilver2/template/viewtopic_body.html @@ -315,7 +315,7 @@
    - + From c049c8d6f0aea53e39de64c82a72ca4a724cb17d Mon Sep 17 00:00:00 2001 From: rechosen Date: Sun, 14 Jul 2013 22:25:49 +0200 Subject: [PATCH 2413/2494] [ticket/9550] Add template event viewtopic_body_postrow_custom_fields_before Adds a template event required for the karma extension. It allows adding data before the custom fields, under the username and avatar next to every post. Explanation from http://area51.phpbb.com/phpBB/viewtopic.php?f=111&t=44379: Used by the karma extension to add a karma score indication that allows users to see how respected the post author is. PHPBB3-9550 --- phpBB/styles/prosilver/template/viewtopic_body.html | 1 + phpBB/styles/subsilver2/template/viewtopic_body.html | 1 + 2 files changed, 2 insertions(+) diff --git a/phpBB/styles/prosilver/template/viewtopic_body.html b/phpBB/styles/prosilver/template/viewtopic_body.html index bc8a71c9bf..3260ae8b92 100644 --- a/phpBB/styles/prosilver/template/viewtopic_body.html +++ b/phpBB/styles/prosilver/template/viewtopic_body.html @@ -239,6 +239,7 @@
    {postrow.PROFILE_FIELD1_NAME}{L_COLON} {postrow.PROFILE_FIELD1_VALUE}
    +
    {postrow.custom_fields.PROFILE_FIELD_NAME}{L_COLON} {postrow.custom_fields.PROFILE_FIELD_VALUE}
    diff --git a/phpBB/styles/subsilver2/template/viewtopic_body.html b/phpBB/styles/subsilver2/template/viewtopic_body.html index 38847d0805..787f67275b 100644 --- a/phpBB/styles/subsilver2/template/viewtopic_body.html +++ b/phpBB/styles/subsilver2/template/viewtopic_body.html @@ -208,6 +208,7 @@
    {postrow.PROFILE_FIELD1_NAME}{L_COLON} {postrow.PROFILE_FIELD1_VALUE} +
    {postrow.custom_fields.PROFILE_FIELD_NAME}{L_COLON} {postrow.custom_fields.PROFILE_FIELD_VALUE} From 84689680143f6e2b02dfb41d019419dce91a47ec Mon Sep 17 00:00:00 2001 From: rechosen Date: Sun, 14 Jul 2013 22:33:45 +0200 Subject: [PATCH 2414/2494] [ticket/9550] Add template event viewtopic_body_postrow_custom_fields_after Adds the append counterpart of a template event required for the karma extension. It allows adding data after the custom fields under the username and avatar next to every post. Explanation from http://area51.phpbb.com/phpBB/viewtopic.php?f=111&t=44379: Per suggestion of nickvergessen, add a counterpart for every append or prepend event. PHPBB3-9550 --- phpBB/styles/prosilver/template/viewtopic_body.html | 1 + phpBB/styles/subsilver2/template/viewtopic_body.html | 1 + 2 files changed, 2 insertions(+) diff --git a/phpBB/styles/prosilver/template/viewtopic_body.html b/phpBB/styles/prosilver/template/viewtopic_body.html index 3260ae8b92..c8a99b18e4 100644 --- a/phpBB/styles/prosilver/template/viewtopic_body.html +++ b/phpBB/styles/prosilver/template/viewtopic_body.html @@ -243,6 +243,7 @@
    {postrow.custom_fields.PROFILE_FIELD_NAME}{L_COLON} {postrow.custom_fields.PROFILE_FIELD_VALUE}
    + diff --git a/phpBB/styles/subsilver2/template/viewtopic_body.html b/phpBB/styles/subsilver2/template/viewtopic_body.html index 787f67275b..51ab702b51 100644 --- a/phpBB/styles/subsilver2/template/viewtopic_body.html +++ b/phpBB/styles/subsilver2/template/viewtopic_body.html @@ -212,6 +212,7 @@
    {postrow.custom_fields.PROFILE_FIELD_NAME}{L_COLON} {postrow.custom_fields.PROFILE_FIELD_VALUE} + From 2f1635116cbaaee3645044022f883f075f5ded69 Mon Sep 17 00:00:00 2001 From: rechosen Date: Sun, 14 Jul 2013 23:31:41 +0200 Subject: [PATCH 2415/2494] [ticket/9550] Add template event ucp_pm_viewmessage_custom_fields_before Adds a template event required for the karma extension. It allows adding data before the custom fields under the username and avatar next to every private message in prosilver. Explanation from http://area51.phpbb.com/phpBB/viewtopic.php?f=111&t=44379: Used by the karma extension to add a karma score indication that allows users to see how respected the pm sender is. PHPBB3-9550 --- phpBB/styles/prosilver/template/ucp_pm_viewmessage.html | 1 + 1 file changed, 1 insertion(+) diff --git a/phpBB/styles/prosilver/template/ucp_pm_viewmessage.html b/phpBB/styles/prosilver/template/ucp_pm_viewmessage.html index 22149c8b80..accea4d3dd 100644 --- a/phpBB/styles/prosilver/template/ucp_pm_viewmessage.html +++ b/phpBB/styles/prosilver/template/ucp_pm_viewmessage.html @@ -85,6 +85,7 @@
    {L_JOINED}{L_COLON} {AUTHOR_JOINED}
    {L_LOCATION}{L_COLON} {AUTHOR_FROM}
    +
    {custom_fields.PROFILE_FIELD_NAME}{L_COLON} {custom_fields.PROFILE_FIELD_VALUE}
    From cd0b1be2082f11a80b42f7f25841d0e432ff5912 Mon Sep 17 00:00:00 2001 From: rechosen Date: Sun, 14 Jul 2013 23:36:00 +0200 Subject: [PATCH 2416/2494] [ticket/9550] Add template event ucp_pm_viewmessage_custom_fields_after Adds the append counterpart of a template event required for the karma extension. It allows adding data after the custom fields under the username and avatar next to every private message in prosilver. Explanation from http://area51.phpbb.com/phpBB/viewtopic.php?f=111&t=44379: Per suggestion of nickvergessen, add a counterpart for every append or prepend event. PHPBB3-9550 --- phpBB/styles/prosilver/template/ucp_pm_viewmessage.html | 1 + 1 file changed, 1 insertion(+) diff --git a/phpBB/styles/prosilver/template/ucp_pm_viewmessage.html b/phpBB/styles/prosilver/template/ucp_pm_viewmessage.html index accea4d3dd..4f2531d3a6 100644 --- a/phpBB/styles/prosilver/template/ucp_pm_viewmessage.html +++ b/phpBB/styles/prosilver/template/ucp_pm_viewmessage.html @@ -89,6 +89,7 @@
    {custom_fields.PROFILE_FIELD_NAME}{L_COLON} {custom_fields.PROFILE_FIELD_VALUE}
    + From ee251fe45b6fb27900df91a3909e28aa8c785543 Mon Sep 17 00:00:00 2001 From: rechosen Date: Wed, 17 Jul 2013 13:44:27 +0200 Subject: [PATCH 2417/2494] [ticket/9550] Add template event memberlist_body_username_append Adds a template event required for the karma extension. It allows adding information after every username in the memberlist. Explanation from http://area51.phpbb.com/phpBB/viewtopic.php?f=111&t=44379: Used by the karma extension to add a karma score indication that allows other users to see how respected every listed user is. PHPBB3-9550 --- phpBB/styles/prosilver/template/memberlist_body.html | 2 +- phpBB/styles/subsilver2/template/memberlist_body.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/phpBB/styles/prosilver/template/memberlist_body.html b/phpBB/styles/prosilver/template/memberlist_body.html index 07a7e2e182..4c5c576eb1 100644 --- a/phpBB/styles/prosilver/template/memberlist_body.html +++ b/phpBB/styles/prosilver/template/memberlist_body.html @@ -109,7 +109,7 @@
    - + diff --git a/phpBB/styles/subsilver2/template/memberlist_body.html b/phpBB/styles/subsilver2/template/memberlist_body.html index 09336fb8a3..8fd7451b55 100644 --- a/phpBB/styles/subsilver2/template/memberlist_body.html +++ b/phpBB/styles/subsilver2/template/memberlist_body.html @@ -66,7 +66,7 @@ - + From 075f491cb868119bf7de2f3dc6e0f0f79db7156e Mon Sep 17 00:00:00 2001 From: rechosen Date: Wed, 17 Jul 2013 13:49:12 +0200 Subject: [PATCH 2418/2494] [ticket/9550] Add template event memberlist_body_username_prepend Adds the prepend counterpart of a template event required for the karma extension. It allows adding information before every username in the memberlist. Explanation from http://area51.phpbb.com/phpBB/viewtopic.php?f=111&t=44379: Per suggestion of nickvergessen, add a counterpart for every append or prepend event. PHPBB3-9550 --- phpBB/styles/prosilver/template/memberlist_body.html | 2 +- phpBB/styles/subsilver2/template/memberlist_body.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/phpBB/styles/prosilver/template/memberlist_body.html b/phpBB/styles/prosilver/template/memberlist_body.html index 4c5c576eb1..459c3f6bc6 100644 --- a/phpBB/styles/prosilver/template/memberlist_body.html +++ b/phpBB/styles/prosilver/template/memberlist_body.html @@ -109,7 +109,7 @@ - + diff --git a/phpBB/styles/subsilver2/template/memberlist_body.html b/phpBB/styles/subsilver2/template/memberlist_body.html index 8fd7451b55..7c4d301de7 100644 --- a/phpBB/styles/subsilver2/template/memberlist_body.html +++ b/phpBB/styles/subsilver2/template/memberlist_body.html @@ -66,7 +66,7 @@ - + From 8c565ea1a642ab7b72d22eaf6c83236cef9444a1 Mon Sep 17 00:00:00 2001 From: rechosen Date: Wed, 17 Jul 2013 15:06:53 +0200 Subject: [PATCH 2419/2494] [ticket/9550] Add the new template events to phpBB/docs/events.md The newly added template events weren't listed and described yet in events.md. Fixed now. PHPBB3-9550 --- phpBB/docs/events.md | 76 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) diff --git a/phpBB/docs/events.md b/phpBB/docs/events.md index 855f238653..d037237b34 100644 --- a/phpBB/docs/events.md +++ b/phpBB/docs/events.md @@ -52,6 +52,38 @@ index_body_stat_blocks_before + styles/subsilver2/template/index_body.html * Purpose: Add new statistic blocks above the Who Is Online and Board Statistics blocks +memberlist_body_username_append +=== +* Locations: + + styles/prosilver/template/memberlist_body.html + + styles/subsilver2/template/memberlist_body.html +* Purpose: Add information after every username in the memberlist. Works in +all display modes (leader, group and normal memberlist). + +memberlist_body_username_prepend +=== +* Locations: + + styles/prosilver/template/memberlist_body.html + + styles/subsilver2/template/memberlist_body.html +* Purpose: Add information before every username in the memberlist. Works in +all display modes (leader, group and normal memberlist). + +memberlist_view_user_statistics_after +=== +* Locations: + + styles/prosilver/template/memberlist_view.html + + styles/subsilver2/template/memberlist_view.html +* Purpose: Add entries to the bottom of the user statistics part of any user +profile + +memberlist_view_user_statistics_before +=== +* Locations: + + styles/prosilver/template/memberlist_view.html + + styles/subsilver2/template/memberlist_view.html +* Purpose: Add entries to the top of the user statistics part of any user +profile + overall_footer_after === * Locations: @@ -132,6 +164,18 @@ topiclist_row_append + styles/subsilver2/template/viewforum_body.html * Purpose: Add content into topic rows (inside the elements containing topic titles) +ucp_pm_viewmessage_custom_fields_after +=== +* Location: styles/prosilver/template/ucp_pm_viewmessage.html +* Purpose: Add data after the custom fields, under the username and avatar +next to every private message in prosilver + +ucp_pm_viewmessage_custom_fields_before +=== +* Location: styles/prosilver/template/ucp_pm_viewmessage.html +* Purpose: Add data before the custom fields, under the username and avatar +next to every private message in prosilver + ucp_pm_viewmessage_print_head_append === * Location: styles/prosilver/template/ucp_pm_viewmessage_print.html @@ -151,6 +195,38 @@ viewtopic_body_footer_before and quick reply, directly before the jumpbox in Prosilver, breadcrumbs in Subsilver2. +viewtopic_body_post_buttons_after +=== +* Locations: + + styles/prosilver/template/viewtopic_body.html + + styles/subsilver2/template/viewtopic_body.html +* Purpose: Add post button to posts (next to edit, quote etc), at the end of +the list. + +viewtopic_body_post_buttons_before +=== +* Locations: + + styles/prosilver/template/viewtopic_body.html + + styles/subsilver2/template/viewtopic_body.html +* Purpose: Add post button to posts (next to edit, quote etc), at the start of +the list. + +viewtopic_body_postrow_custom_fields_after +=== +* Locations: + + styles/prosilver/template/viewtopic_body.html + + styles/subsilver2/template/viewtopic_body.html +* Purpose: Add data after the postrow custom fields, under the username and +avatar next to every post. + +viewtopic_body_postrow_custom_fields_before +=== +* Locations: + + styles/prosilver/template/viewtopic_body.html + + styles/subsilver2/template/viewtopic_body.html +* Purpose: Add data before the postrow custom fields, under the username and +avatar next to every post. + viewtopic_topic_title_prepend === * Locations: From f61910c3f83fd4de16ca946232bab1bd3c679341 Mon Sep 17 00:00:00 2001 From: rechosen Date: Fri, 2 Aug 2013 11:38:25 +0200 Subject: [PATCH 2420/2494] [ticket/9550] Improve template event descriptions in phpBB/docs/events.md Per suggestion of nickvergessen, stick to "before" and "after" in the template event descriptions instead of "at the top of" and "at the bottom of". PHPBB3-9550 --- phpBB/docs/events.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/phpBB/docs/events.md b/phpBB/docs/events.md index d037237b34..b1e8c7ad05 100644 --- a/phpBB/docs/events.md +++ b/phpBB/docs/events.md @@ -73,16 +73,14 @@ memberlist_view_user_statistics_after * Locations: + styles/prosilver/template/memberlist_view.html + styles/subsilver2/template/memberlist_view.html -* Purpose: Add entries to the bottom of the user statistics part of any user -profile +* Purpose: Add entries after the user statistics part of any user profile memberlist_view_user_statistics_before === * Locations: + styles/prosilver/template/memberlist_view.html + styles/subsilver2/template/memberlist_view.html -* Purpose: Add entries to the top of the user statistics part of any user -profile +* Purpose: Add entries before the user statistics part of any user profile overall_footer_after === From 61fd61692b5c93eee560424717d272d84d710cd4 Mon Sep 17 00:00:00 2001 From: rechosen Date: Fri, 2 Aug 2013 11:44:07 +0200 Subject: [PATCH 2421/2494] [ticket/9550] Improve template event descriptions in phpBB/docs/events.md Update the custom_fields template events descriptions according to nickvergessen's suggestions. PHPBB3-9550 --- phpBB/docs/events.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/phpBB/docs/events.md b/phpBB/docs/events.md index b1e8c7ad05..af6e6bdb1c 100644 --- a/phpBB/docs/events.md +++ b/phpBB/docs/events.md @@ -165,14 +165,14 @@ topiclist_row_append ucp_pm_viewmessage_custom_fields_after === * Location: styles/prosilver/template/ucp_pm_viewmessage.html -* Purpose: Add data after the custom fields, under the username and avatar -next to every private message in prosilver +* Purpose: Add data after the custom fields on the user profile when viewing +a private message ucp_pm_viewmessage_custom_fields_before === * Location: styles/prosilver/template/ucp_pm_viewmessage.html -* Purpose: Add data before the custom fields, under the username and avatar -next to every private message in prosilver +* Purpose: Add data before the custom fields on the user profile when viewing +a private message ucp_pm_viewmessage_print_head_append === @@ -214,16 +214,16 @@ viewtopic_body_postrow_custom_fields_after * Locations: + styles/prosilver/template/viewtopic_body.html + styles/subsilver2/template/viewtopic_body.html -* Purpose: Add data after the postrow custom fields, under the username and -avatar next to every post. +* Purpose: Add data after the custom fields on the user profile when viewing +a post viewtopic_body_postrow_custom_fields_before === * Locations: + styles/prosilver/template/viewtopic_body.html + styles/subsilver2/template/viewtopic_body.html -* Purpose: Add data before the postrow custom fields, under the username and -avatar next to every post. +* Purpose: Add data before the custom fields on the user profile when viewing +a post viewtopic_topic_title_prepend === From 351abf38830ddb8d6466f39ec6a173ce688b0206 Mon Sep 17 00:00:00 2001 From: rechosen Date: Fri, 2 Aug 2013 14:07:49 +0200 Subject: [PATCH 2422/2494] [ticket/9550] Break up a long ugly line in subsilver2 viewtopic_body.html Per request of nickvergessen, break up the long post buttons line in viewtopic_body.html of subsilver2 into nicely indented parent and child elements. Keep the whitespace in such a way that browsers display the buttons pixel-perfectly equal to the old code. In the process, move the viewtopic_body_post_buttons_before event to a more logical (though possibly less intuitive) place (only in subsilver2). PHPBB3-9550 --- .../subsilver2/template/viewtopic_body.html | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/phpBB/styles/subsilver2/template/viewtopic_body.html b/phpBB/styles/subsilver2/template/viewtopic_body.html index 51ab702b51..26e74b8c38 100644 --- a/phpBB/styles/subsilver2/template/viewtopic_body.html +++ b/phpBB/styles/subsilver2/template/viewtopic_body.html @@ -317,7 +317,21 @@ - + From 8a02db317ef3c2d3c4e3dcfc5f8b85397f7ebb4a Mon Sep 17 00:00:00 2001 From: s9e Date: Sat, 3 Aug 2013 12:20:52 +0200 Subject: [PATCH 2423/2494] [ticket/11762] Use the === operator to distinguish "0" from "" PHPBB3-11762 --- phpBB/includes/functions_content.php | 4 +-- .../generate_text_for_display.php | 36 +++++++++++++++++++ 2 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 tests/text_processing/generate_text_for_display.php diff --git a/phpBB/includes/functions_content.php b/phpBB/includes/functions_content.php index b7650ecd6a..6213d2fd24 100644 --- a/phpBB/includes/functions_content.php +++ b/phpBB/includes/functions_content.php @@ -413,7 +413,7 @@ function generate_text_for_display($text, $uid, $bitfield, $flags) { static $bbcode; - if (!$text) + if ($text === '') { return ''; } @@ -459,7 +459,7 @@ function generate_text_for_storage(&$text, &$uid, &$bitfield, &$flags, $allow_bb $uid = $bitfield = ''; $flags = (($allow_bbcode) ? OPTION_FLAG_BBCODE : 0) + (($allow_smilies) ? OPTION_FLAG_SMILIES : 0) + (($allow_urls) ? OPTION_FLAG_LINKS : 0); - if (!$text) + if ($text === '') { return; } diff --git a/tests/text_processing/generate_text_for_display.php b/tests/text_processing/generate_text_for_display.php new file mode 100644 index 0000000000..4088e33f30 --- /dev/null +++ b/tests/text_processing/generate_text_for_display.php @@ -0,0 +1,36 @@ +optionset('viewcensors', false); + } + + public function test_empty_string() + { + $this->assertSame('', generate_text_for_display('', '', '', 0)); + } + + public function test_zero_string() + { + $this->assertSame('0', generate_text_for_display('0', '', '', 0)); + } +} From 68aa974a207b444199fabe9d754f403d27d700ad Mon Sep 17 00:00:00 2001 From: s9e Date: Sat, 3 Aug 2013 12:29:23 +0200 Subject: [PATCH 2424/2494] [ticket/11762] Fixed test's filename PHPBB3-11762 --- ...te_text_for_display.php => generate_text_for_display_test.php} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename tests/text_processing/{generate_text_for_display.php => generate_text_for_display_test.php} (100%) diff --git a/tests/text_processing/generate_text_for_display.php b/tests/text_processing/generate_text_for_display_test.php similarity index 100% rename from tests/text_processing/generate_text_for_display.php rename to tests/text_processing/generate_text_for_display_test.php From 9db1728b4b976c99f5811e578619e37c69e306cd Mon Sep 17 00:00:00 2001 From: s9e Date: Sat, 3 Aug 2013 14:05:40 +0200 Subject: [PATCH 2425/2494] [ticket/11762] Added call to test class's parent::setUp(). Added call to test class's parent::setUp(). Updated copyright year. PHPBB3-11762 --- tests/text_processing/generate_text_for_display_test.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/text_processing/generate_text_for_display_test.php b/tests/text_processing/generate_text_for_display_test.php index 4088e33f30..a157fe7d9a 100644 --- a/tests/text_processing/generate_text_for_display_test.php +++ b/tests/text_processing/generate_text_for_display_test.php @@ -2,7 +2,7 @@ /** * * @package testing -* @copyright (c) 2011 phpBB Group +* @copyright (c) 2013 phpBB Group * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 * */ @@ -18,6 +18,8 @@ class phpbb_text_processing_generate_text_for_display_test extends phpbb_test_ca { global $cache, $user; + parent::setUp(); + $cache = new phpbb_mock_cache; $user = new phpbb_mock_user; From 71ababe6fb1648c9cb286c8c84e939a36a35cbbf Mon Sep 17 00:00:00 2001 From: Oliver Schramm Date: Sat, 3 Aug 2013 17:30:28 +0200 Subject: [PATCH 2426/2494] [ticket/11763] Add missing variable when reporting a PM to avoid SQL Error PHPBB3-11763 --- phpBB/report.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/phpBB/report.php b/phpBB/report.php index c9ca57ecbe..5081f90ad1 100644 --- a/phpBB/report.php +++ b/phpBB/report.php @@ -139,9 +139,10 @@ else $reported_post_text = $report_data['message_text']; $reported_post_bitfield = $report_data['bbcode_bitfield']; - $reported_post_enable_bbcode = $report_data['reported_post_enable_bbcode']; - $reported_post_enable_smilies = $report_data['reported_post_enable_smilies']; - $reported_post_enable_magic_url = $report_data['reported_post_enable_magic_url']; + $reported_post_uid = $report_data['bbcode_uid']; + $reported_post_enable_bbcode = $report_data['enable_bbcode']; + $reported_post_enable_smilies = $report_data['enable_smilies']; + $reported_post_enable_magic_url = $report_data['enable_magic_url']; } if ($config['enable_post_confirm'] && !$user->data['is_registered']) From 28a0a9e0b1cf77f1be64934f98e4c607d6098362 Mon Sep 17 00:00:00 2001 From: brunoais Date: Sat, 3 Aug 2013 21:46:06 +0100 Subject: [PATCH 2427/2494] [ticket/11639] Changing how censorship is handled. sub-task of ticket PHPBB3-11635: find and fix all bypasses of generate_text_for_* PHPBB3-11639 --- phpBB/includes/functions_posting.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index acf0cc874b..c528d36fef 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -1093,13 +1093,12 @@ function topic_review($topic_id, $forum_id, $mode = 'topic_review', $cur_post_id $poster_id = $row['user_id']; $post_subject = $row['post_subject']; - $message = censor_text($row['post_text']); $decoded_message = false; if ($show_quote_button && $auth->acl_get('f_reply', $forum_id)) { - $decoded_message = $message; + $decoded_message = censor_text($row['post_text']); decode_message($decoded_message, $row['bbcode_uid']); $decoded_message = bbcode_nl2br($decoded_message); @@ -1107,8 +1106,7 @@ function topic_review($topic_id, $forum_id, $mode = 'topic_review', $cur_post_id $parse_flags = ($row['bbcode_bitfield'] ? OPTION_FLAG_BBCODE : 0); $parse_flags |= ($row['enable_smilies'] ? OPTION_FLAG_SMILIES : 0); - // Do not censor text because it has already been censored before - $message = generate_text_for_display($message, $row['bbcode_uid'], $row['bbcode_bitfield'], $parse_flags, false); + $message = generate_text_for_display($row['post_text'], $row['bbcode_uid'], $row['bbcode_bitfield'], $parse_flags, true); if (!empty($attachments[$row['post_id']])) { From 3713ff71eafa575fc78f788085803ec6488c8fcd Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Tue, 6 Aug 2013 21:47:35 +0300 Subject: [PATCH 2428/2494] [ticket/11770] Fix class name for pm list PHPBB3-11770 --- phpBB/styles/prosilver/template/ucp_pm_viewfolder.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/styles/prosilver/template/ucp_pm_viewfolder.html b/phpBB/styles/prosilver/template/ucp_pm_viewfolder.html index c5078df268..9cbff64a6a 100644 --- a/phpBB/styles/prosilver/template/ucp_pm_viewfolder.html +++ b/phpBB/styles/prosilver/template/ucp_pm_viewfolder.html @@ -53,7 +53,7 @@ -
      +
      • From 2508439b02f5115e0557b2eee467e5ec5737d350 Mon Sep 17 00:00:00 2001 From: Andy Chase Date: Mon, 5 Aug 2013 10:35:39 -0700 Subject: [PATCH 2429/2494] [ticket/11761] Serve blank file locally in functional test Example.org no longer serves blank responses, failing functional tests. this patch creates a blank file and serve it locally during the test, instead of hitting the http://example.org servers kindly provided by IANA. PHPBB3-11761 --- phpBB/develop/blank.gif | 0 phpBB/develop/blank.jpg | 0 tests/functional/fileupload_remote_test.php | 6 +++--- 3 files changed, 3 insertions(+), 3 deletions(-) create mode 100644 phpBB/develop/blank.gif create mode 100644 phpBB/develop/blank.jpg diff --git a/phpBB/develop/blank.gif b/phpBB/develop/blank.gif new file mode 100644 index 0000000000..e69de29bb2 diff --git a/phpBB/develop/blank.jpg b/phpBB/develop/blank.jpg new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/functional/fileupload_remote_test.php b/tests/functional/fileupload_remote_test.php index 8e361ab77b..65c4b6b7c4 100644 --- a/tests/functional/fileupload_remote_test.php +++ b/tests/functional/fileupload_remote_test.php @@ -44,14 +44,14 @@ class phpbb_functional_fileupload_remote_test extends phpbb_functional_test_case public function test_invalid_extension() { $upload = new fileupload('', array('jpg'), 100); - $file = $upload->remote_upload('http://example.com/image.gif'); + $file = $upload->remote_upload(self::$root_url . 'develop/blank.gif'); $this->assertEquals('URL_INVALID', $file->error[0]); } - public function test_non_existant() + public function test_empty_file() { $upload = new fileupload('', array('jpg'), 100); - $file = $upload->remote_upload('http://example.com/image.jpg'); + $file = $upload->remote_upload(self::$root_url . 'develop/blank.jpg'); $this->assertEquals('EMPTY_REMOTE_DATA', $file->error[0]); } From 91eccc708bb0ca4143ad670be6ecddef818b9316 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 8 Aug 2013 13:42:51 +0200 Subject: [PATCH 2430/2494] [ticket/11775] Fix error when moving the last post to another topic PHPBB3-11775 --- phpBB/includes/mcp/mcp_topic.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/mcp/mcp_topic.php b/phpBB/includes/mcp/mcp_topic.php index 76985488b7..8e0e89e3da 100644 --- a/phpBB/includes/mcp/mcp_topic.php +++ b/phpBB/includes/mcp/mcp_topic.php @@ -668,10 +668,10 @@ function merge_posts($topic_id, $to_topic_id) } // If the topic no longer exist, we will update the topic watch table. - phpbb_update_rows_avoiding_duplicates_notify_status($db, TOPICS_WATCH_TABLE, 'topic_id', $topic_ids, $to_topic_id); + phpbb_update_rows_avoiding_duplicates_notify_status($db, TOPICS_WATCH_TABLE, 'topic_id', array($topic_id), $to_topic_id); // If the topic no longer exist, we will update the bookmarks table. - phpbb_update_rows_avoiding_duplicates($db, BOOKMARKS_TABLE, 'topic_id', $topic_id, $to_topic_id); + phpbb_update_rows_avoiding_duplicates($db, BOOKMARKS_TABLE, 'topic_id', array($topic_id), $to_topic_id); } // Link to the new topic From 74559eb0d59d9b97d6769ef5d57a3b375a6b8507 Mon Sep 17 00:00:00 2001 From: Oliver Schramm Date: Thu, 8 Aug 2013 15:50:20 +0200 Subject: [PATCH 2431/2494] [ticket/11774] Fix constant to avoid PHP errors PHPBB3-11774 --- phpBB/includes/mcp/mcp_reports.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/mcp/mcp_reports.php b/phpBB/includes/mcp/mcp_reports.php index 72400ce623..3f48c58073 100644 --- a/phpBB/includes/mcp/mcp_reports.php +++ b/phpBB/includes/mcp/mcp_reports.php @@ -187,7 +187,7 @@ class mcp_reports 'S_CLOSE_ACTION' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=reports&mode=report_details&f=' . $post_info['forum_id'] . '&p=' . $post_id), 'S_CAN_VIEWIP' => $auth->acl_get('m_info', $post_info['forum_id']), 'S_POST_REPORTED' => $post_info['post_reported'], - 'S_POST_UNAPPROVED' => ($post_info['post_visibility'] == POST_UNAPPROVED), + 'S_POST_UNAPPROVED' => ($post_info['post_visibility'] == ITEM_UNAPPROVED), 'S_POST_LOCKED' => $post_info['post_edit_locked'], 'S_USER_NOTES' => true, From a6e69f377bb436fe59eed9fdedc0cd735d8d8ce9 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 8 Aug 2013 23:33:26 +0200 Subject: [PATCH 2432/2494] [ticket/11775] Backport moving of the posting functions to 3.0 PHPBB3-11775 --- tests/functional/posting_test.php | 101 -------------- .../phpbb_functional_test_case.php | 131 ++++++++++++++++++ 2 files changed, 131 insertions(+), 101 deletions(-) diff --git a/tests/functional/posting_test.php b/tests/functional/posting_test.php index 9bcfcc2fda..7fd1e4fdcf 100644 --- a/tests/functional/posting_test.php +++ b/tests/functional/posting_test.php @@ -32,105 +32,4 @@ class phpbb_functional_posting_test extends phpbb_functional_test_case $crawler = self::request('GET', "posting.php?mode=quote&f=2&t={$post2['topic_id']}&p={$post2['post_id']}&sid={$this->sid}"); $this->assertContains('This is a test post posted by the testing framework.', $crawler->filter('html')->text()); } - - /** - * Creates a topic - * - * Be sure to login before creating - * - * @param int $forum_id - * @param string $subject - * @param string $message - * @param array $additional_form_data Any additional form data to be sent in the request - * @return array post_id, topic_id - */ - public function create_topic($forum_id, $subject, $message, $additional_form_data = array()) - { - $posting_url = "posting.php?mode=post&f={$forum_id}&sid={$this->sid}"; - - $form_data = array_merge(array( - 'subject' => $subject, - 'message' => $message, - 'post' => true, - ), $additional_form_data); - - return self::submit_post($posting_url, 'POST_TOPIC', $form_data); - } - - /** - * Creates a post - * - * Be sure to login before creating - * - * @param int $forum_id - * @param string $subject - * @param string $message - * @param array $additional_form_data Any additional form data to be sent in the request - * @return array post_id, topic_id - */ - public function create_post($forum_id, $topic_id, $subject, $message, $additional_form_data = array()) - { - $posting_url = "posting.php?mode=reply&f={$forum_id}&t={$topic_id}&sid={$this->sid}"; - - $form_data = array_merge(array( - 'subject' => $subject, - 'message' => $message, - 'post' => true, - ), $additional_form_data); - - return self::submit_post($posting_url, 'POST_REPLY', $form_data); - } - - /** - * Helper for submitting posts - * - * @param string $posting_url - * @param string $posting_contains - * @param array $form_data - * @return array post_id, topic_id - */ - protected function submit_post($posting_url, $posting_contains, $form_data) - { - $this->add_lang('posting'); - - $crawler = self::request('GET', $posting_url); - $this->assertContains($this->lang($posting_contains), $crawler->filter('html')->text()); - - $hidden_fields = array( - $crawler->filter('[type="hidden"]')->each(function ($node, $i) { - return array('name' => $node->getAttribute('name'), 'value' => $node->getAttribute('value')); - }), - ); - - foreach ($hidden_fields as $fields) - { - foreach($fields as $field) - { - $form_data[$field['name']] = $field['value']; - } - } - - // Bypass time restriction that said that if the lastclick time (i.e. time when the form was opened) - // is not at least 2 seconds before submission, cancel the form - $form_data['lastclick'] = 0; - - // I use a request because the form submission method does not allow you to send data that is not - // contained in one of the actual form fields that the browser sees (i.e. it ignores "hidden" inputs) - // Instead, I send it as a request with the submit button "post" set to true. - $crawler = self::request('POST', $posting_url, $form_data); - $this->assertContains($this->lang('POST_STORED'), $crawler->filter('html')->text()); - - $url = $crawler->selectLink($this->lang('VIEW_MESSAGE', '', ''))->link()->getUri(); - - $matches = $topic_id = $post_id = false; - preg_match_all('#&t=([0-9]+)(&p=([0-9]+))?#', $url, $matches); - - $topic_id = (int) (isset($matches[1][0])) ? $matches[1][0] : 0; - $post_id = (int) (isset($matches[3][0])) ? $matches[3][0] : 0; - - return array( - 'topic_id' => $topic_id, - 'post_id' => $post_id, - ); - } } diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index 684d7a84cb..15f7814800 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -593,4 +593,135 @@ class phpbb_functional_test_case extends phpbb_test_case { self::assertEquals($status_code, self::$client->getResponse()->getStatus()); } + + /** + * Creates a topic + * + * Be sure to login before creating + * + * @param int $forum_id + * @param string $subject + * @param string $message + * @param array $additional_form_data Any additional form data to be sent in the request + * @return array post_id, topic_id + */ + public function create_topic($forum_id, $subject, $message, $additional_form_data = array()) + { + $posting_url = "posting.php?mode=post&f={$forum_id}&sid={$this->sid}"; + + $form_data = array_merge(array( + 'subject' => $subject, + 'message' => $message, + 'post' => true, + ), $additional_form_data); + + return self::submit_post($posting_url, 'POST_TOPIC', $form_data); + } + + /** + * Creates a post + * + * Be sure to login before creating + * + * @param int $forum_id + * @param int $topic_id + * @param string $subject + * @param string $message + * @param array $additional_form_data Any additional form data to be sent in the request + * @return array post_id, topic_id + */ + public function create_post($forum_id, $topic_id, $subject, $message, $additional_form_data = array()) + { + $posting_url = "posting.php?mode=reply&f={$forum_id}&t={$topic_id}&sid={$this->sid}"; + + $form_data = array_merge(array( + 'subject' => $subject, + 'message' => $message, + 'post' => true, + ), $additional_form_data); + + return self::submit_post($posting_url, 'POST_REPLY', $form_data); + } + + /** + * Helper for submitting posts + * + * @param string $posting_url + * @param string $posting_contains + * @param array $form_data + * @return array post_id, topic_id + */ + protected function submit_post($posting_url, $posting_contains, $form_data) + { + $this->add_lang('posting'); + + $crawler = self::request('GET', $posting_url); + $this->assertContains($this->lang($posting_contains), $crawler->filter('html')->text()); + + $hidden_fields = array( + $crawler->filter('[type="hidden"]')->each(function ($node, $i) { + return array('name' => $node->getAttribute('name'), 'value' => $node->getAttribute('value')); + }), + ); + + foreach ($hidden_fields as $fields) + { + foreach($fields as $field) + { + $form_data[$field['name']] = $field['value']; + } + } + + // Bypass time restriction that said that if the lastclick time (i.e. time when the form was opened) + // is not at least 2 seconds before submission, cancel the form + $form_data['lastclick'] = 0; + + // I use a request because the form submission method does not allow you to send data that is not + // contained in one of the actual form fields that the browser sees (i.e. it ignores "hidden" inputs) + // Instead, I send it as a request with the submit button "post" set to true. + $crawler = self::request('POST', $posting_url, $form_data); + $this->assertContains($this->lang('POST_STORED'), $crawler->filter('html')->text()); + $url = $crawler->selectLink($this->lang('VIEW_MESSAGE', '', ''))->link()->getUri(); + + return array( + 'topic_id' => $this->get_parameter_from_link($url, 't'), + 'post_id' => $this->get_parameter_from_link($url, 'p'), + ); + } + + /* + * Returns the requested parameter from a URL + * + * @param string $url + * @param string $parameter + * @return string Value of the parameter in the URL, null if not set + */ + public function get_parameter_from_link($url, $parameter) + { + if (strpos($url, '?') === false) + { + return null; + } + + $url_parts = explode('?', $url); + if (isset($url_parts[1])) + { + $url_parameters = $url_parts[1]; + if (strpos($url_parameters, '#') !== false) + { + $url_parameters = explode('#', $url_parameters); + $url_parameters = $url_parameters[0]; + } + + foreach (explode('&', $url_parameters) as $url_param) + { + list($param, $value) = explode('=', $url_param); + if ($param == $parameter) + { + return $value; + } + } + } + return null; + } } From a9b5e77e684043924f8c34c8782b32a0f146228c Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 9 Aug 2013 00:41:28 +0200 Subject: [PATCH 2433/2494] [ticket/11775] Add functional test for moving the last post PHPBB3-11775 --- tests/functional/mcp_test.php | 43 +++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 tests/functional/mcp_test.php diff --git a/tests/functional/mcp_test.php b/tests/functional/mcp_test.php new file mode 100644 index 0000000000..f7e15de853 --- /dev/null +++ b/tests/functional/mcp_test.php @@ -0,0 +1,43 @@ +login(); + + // Test creating topic + $post = $this->create_topic(2, 'Test Topic 2', 'Testing move post with "Move posts" option from Quick-Moderator Tools.'); + + $crawler = self::request('GET', "viewtopic.php?t={$post['topic_id']}&sid={$this->sid}"); + $this->assertContains('Testing move post with "Move posts" option from Quick-Moderator Tools.', $crawler->filter('html')->text()); + + // Test moving a post + $this->add_lang('mcp'); + $form = $crawler->selectButton('Go')->eq(1)->form(); + $form['action']->select('merge'); + $crawler = self::submit($form); + + // Select the post in MCP + $form = $crawler->selectButton($this->lang('SUBMIT'))->form(array( + 'to_topic_id' => 1, + )); + $form['post_id_list'][0]->tick(); + $crawler = self::submit($form); + $this->assertContains($this->lang('MERGE_POSTS'), $crawler->filter('html')->text()); + + $form = $crawler->selectButton('Yes')->form(); + $crawler = self::submit($form); + $this->assertContains($this->lang('POSTS_MERGED_SUCCESS'), $crawler->text()); + } +} From 0aea5e48d8ad3505fc957d67131eece477d84947 Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Sun, 11 Aug 2013 10:37:29 +0300 Subject: [PATCH 2434/2494] [ticket/11779] Fix unapproved messages class name PHPBB3-11779 --- phpBB/styles/prosilver/template/mcp_front.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpBB/styles/prosilver/template/mcp_front.html b/phpBB/styles/prosilver/template/mcp_front.html index e88b7c62df..402cfe029a 100644 --- a/phpBB/styles/prosilver/template/mcp_front.html +++ b/phpBB/styles/prosilver/template/mcp_front.html @@ -13,7 +13,7 @@

        {L_UNAPPROVED_TOTAL}

        -
          +
          • {L_VIEW_DETAILS}
            @@ -21,7 +21,7 @@
          -
            +
            • From fe3b57a1416fbc70779aebe6ff15fd6f1733f269 Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Sun, 11 Aug 2013 10:51:16 +0300 Subject: [PATCH 2435/2494] [ticket/11780] Remove unused images PHPBB3-11780 --- .../prosilver/theme/en/button_pm_forward.gif | Bin 2168 -> 0 bytes .../styles/prosilver/theme/en/button_pm_new.gif | Bin 2005 -> 0 bytes .../prosilver/theme/en/button_pm_reply.gif | Bin 2126 -> 0 bytes .../prosilver/theme/en/button_topic_locked.gif | Bin 1923 -> 0 bytes .../prosilver/theme/en/button_topic_new.gif | Bin 2737 -> 0 bytes .../prosilver/theme/en/button_topic_reply.gif | Bin 2135 -> 0 bytes 6 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 phpBB/styles/prosilver/theme/en/button_pm_forward.gif delete mode 100644 phpBB/styles/prosilver/theme/en/button_pm_new.gif delete mode 100644 phpBB/styles/prosilver/theme/en/button_pm_reply.gif delete mode 100644 phpBB/styles/prosilver/theme/en/button_topic_locked.gif delete mode 100644 phpBB/styles/prosilver/theme/en/button_topic_new.gif delete mode 100644 phpBB/styles/prosilver/theme/en/button_topic_reply.gif diff --git a/phpBB/styles/prosilver/theme/en/button_pm_forward.gif b/phpBB/styles/prosilver/theme/en/button_pm_forward.gif deleted file mode 100644 index 3384df34be5926db98693854fd66da017ec9d013..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2168 zcmV-;2#5DaNk%w1VPF6<0OkMy@7&<_5e393Gl+=cq)`*+e ziJaSwpxBh8*OQ~$m#5m6rr?~c-lMVHp|9JZuH>q?-mSUmxWwnc%HzDo?Z(jL$Ik1{ z)#=RB?b+Vw)!Osv?DFXA-rnKf-{IZf-~ejI085R;*5b(6ASma<|%v$mop9>5$Co<@5UM_WSwy_{qk?$HTwo2?O!PL^x)6vlX|Ns8}{{8*^{QUg;`}_L(`uX|!`1ttu_xJYp_VxAk^z`)e^YilZ z^6~NU@bK{O@9*yJ?(OaE?Ck98>+9<3>gnm}=;-K=kB?+zWZ~lFA^8LW004ggEC2ui z0AK(z000O7fPY0}VO)lXh>41ejE#n}-l1 zI+#ciKpOxdB18xw^9AdNgSZ2N|*^O`*{T zQ8sJ;{K%c_XHC(f{@&=_%hy2%zHd%A_@VcQgBEY7_WdivL4r3GA~*o@Cc@vq4n#!Q z>vwMk2Z=!!&b*h6+&-vNvjM!cr*#6>(A5Wepi8u}nkT>8U4ttOn8i;>jU^$Qr z9~%FNvz$hQ^y1Ovzz*)UHy(TB#qmZPr=iwHg5&u!$AlDC=)eUpWVpi|wpG|62M*LA zB8W9i_`w4xTrdX;51cq5h%eM|fdfIzaiNGWIKaUiAXa!?g>blWnj5IOQDKGt(4pl2 zl1w^40F!i-;D7>3D&W8hbP(Xck^?wUf|4~%^d$}xfj~zP0=__plS^uu<(5@CV5X7^ zo~D-{eY^qXlK#};=bwN&31}SyKmfrCD;PRJ9a;tof}dzQfCHfu*-!@zlKR=@1a%1N zr<4O|2?Goz7^=XZaGVB*9I5sJ$Dn`uW5=wt*6P3pwayxZ2ZnkO#H=1nQ0oN3&N_hu z1I&s6jdn}`L9J5uFo6fOV!FcyAZ^e?t#icDM;vq55r-e(=1QwScciQCy6m>=?z`~D zD=)m=&XI1t@cM(tzWny<@4o;CEbzbt7i=&d{^X(X!VEX;@WT*CEb+t?SDc6cKYC=W z@x~l??D5AShb;2QBs^2#i??DESn$1L;AG}C;?GOU!5a?L#V?DNky`$EPg zUG!th(MTt)bSZ0ep~@ddkikqOR99{F)sSpKh7o`Ku>=)SG$HobWS4FB*=VP&_S$T# z9R(Fj{Go&sRba97-FW9c3Kms3p~Mtc=nVAWgcmOJ9c5TC#S>ZJ!N=o}M=tr~lvi%~ z<(OxlIUZR&(L@<~7%uwgg_|rk=q0DF`s%EUT*m1Z$1eNqv{U^0=K{C!NgH^~v4$CD ztT6{3a&ojyJZL%fExjf zAb|uU2;hbq2Y@7j3IdoRfd*;F!Gi-MtntPS4&Z?t&OiYNEWlpn1IYmb06zsTzzyqa z$S2r9zSEiOTn?bX3^q6e0SI7yE^xv61kgYZ#?J)}6aX7k-~b7jA%$_+p956D20N5b zgEMe}12lk!_-#-H>sx>vX4McR81aZmD8mJ9csf|c$^i#R15wt%!UX_i0S<6M8sb-m zp_DI*0OSDyCE$Pn*e{Ay(8dXEF^=&A2?YcYhcj|A02CMj03XQ78wdc3+z=2CZdnFf zajAP2=rfkcXjk@35MIK#ta`G3Z{}@IeWLaD?~NOZi5C2J}rN z2W&W|CDj1H9E3819({vC9UuT7&H#uKu%b@=$&Hkj0j8hTJl$RJ0>v{FMWgCtUjWj8 zh7nM}3_~$PH_@tArncb>a5N(YTsV}aE+CjaC29b3IgtY_K#Fz!r!(B3$H8uuu%`n` zM69O_psWE6z&mIg9?QIkqyczoNT?agfQB{*gR_^d>}0J6S;@A6w7uX&V;9TWhmcmW z5D_0kW=q@J+EyXrFNCZ{Jbhn3Xagn!@v3Y`TF|$`}_O&`1tDT z>g((4?Ck9A?d|vX_x1Jl_V)JZ=;-k9@b2#J@9*#Q^z`xZ@$>WZ{r&yLMrGuxxZs?u z^3>b@{{Fx?SpaIq$yIU3Qf|XVV~>xI(s78+ZG^u!SoY)R^78WApsvnid;ms+9hK7A zm8NaA+TPyb!$f0dW@g`{veVMh+l`>*$j{e_o5|Va>CDsW_4~=j!sX-P-J`Ml@$<@G zdF{r~>dn;Hl%&^xl+t^UV42F6mX-ipst}RU+Lou=m#2uS#nREy=E>0QDJne%IUPUw0U`Xwawzi#l`8k#G<02+}zyDV0wgvgznqlyVvlL%<6Qt+`hiPxVX3x zbI9%4-o)18=fKMO`S^**=*q^!Zf$lhjEvpp?wP~r&CSh-x#Y~41ejE#E{3m`1$(#{Qds_0RI`#W*}e!dkzvRTu5es422CH z$QVG8Vu%4l68agCB;iB{6)Bcr;6MaLAPKin6tQsOffzAnBxp&~9)z1Xb50zv<>o{P zNd^EJ3S>)(5I2Vm$a3>21d29nlo(K=B*i2*gANdp6GB1=24alBqOfaDdk@m8T{|&E zh_n;`A0Qd9RxaHKA}*%&VB-NrwIMv#WBOjIzLWi{2Unju_4Go^@FIa6Y2Nl-eoy$i^b zE9ZQnMQ7&DL)y4tq6H5T7erVefE=n+s@VrPZ!vzW@&{5zsMoT-2p9>-<^o2y#fF?mHSj0~8e0Kv5GEG(k}fQ&LprlrK_{WeODNxTXYb z#4yDdRn##;6&9>nr9Be_DyX0hJTbtaJ{+25MIi(_p`aHDO3|Q!zUZh4f$B)91ahEp z1p^jbF#;GCP&%kR4Wz2-s;su^>Z`EE>Z%1;urZ|qd`#x8DE9|hu7CUSM z6Zo2JvGy$B?6c5DEA6z@R%`9G*g9*E0^D}%?YH2DEAF`DmTNAz*YMIn0PMEw?z`~D zEAPDY)@yGA#>|k)y7u<#@4o=Q+dwW$yx@cy28^Qc!VEXui2-VyBFGZQKw|O##TaLt zhzZ zL>E196fUrk0|OB>?ex=7M=kZ#R99{F)ePhyG5`t`?e*9HDgeO9T%T+9*=VQj?brkW zknP)W$1QiXYy(iN0{}SSE8YolfK>`h6J^%n3I0(W3LL_j36$5PWKn0-#;2;S-V2}Yt9Q1htMHyh=DgZ02Km`i2 z)@`bw4}?Cz32C*y!2ldI&%p^KfFM8uLJXk70R}|x`T#W0K*9hd$WGD!1~)A~K<(iJ1Sj(3QDj;`?xTNHLL*w^`k)DpoAg_gpLELGl23wrwId~@CUa;;qwOYg9IjE zfeoCU3Yd4h@8vE<1|UKlj6j4He83HTSiu_vK*G9}s6Gx@AqQ3%5*iqA0~*L(2C&FN zigfRL;hWv^HZaEXVW2(0UOxMoB(qLZfJu5i0}a-AmE)hsT)levN!=Gq!*7{ z+$M^FfDRPH0T{KYMlGt4jy|rV9YDb1QrZ#$=z$B^n*$sKV1SACjcf+VsZMt)kOSlc z0RgESJ%&ouq8gPQbt{Kbm&(+pc4KTxi(oaTO4X`bRT%;@(Av*bF^sNy^{cGFMHgIf ngCley2RTctT0@b8E*xPDe;7m3T1MBp+V!p{V}T3c8VCS89tP2U diff --git a/phpBB/styles/prosilver/theme/en/button_pm_reply.gif b/phpBB/styles/prosilver/theme/en/button_pm_reply.gif deleted file mode 100644 index 3275b06d525af8176c4d76059a11d1e6916cb68d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2126 zcmV-U2(kA^Nk%w1VPF6<0OkMy?%Ut!)!Fvr=lk*V?c?RnV|><#n%Ih*;kv`-zsTdf z#q!kK@8;<3Fn|6>fYYr-rwQf-rxXg#sEu=#Ma`-*yGCCwApXA+H$wriOA@T%IT2I>gDtL>-PKk`S{7k!pFnE=H%k#+9<3>gnm}=;-K=kB?+zWZ~lFA^8LW004ggEC2ui z0AK(z000O7fPX|{U|WWVh>41ejE#n}-l@ zTyWrkLy(6QGdciJF`|PuFEUE_08yiZ3q9JHbZ|hWMvE>XPMq;@hJy+hAFffeMkh~* z5B<3rI+Wvw9ycmz80vsTkEcD{P@FL|q#G3up3bPyfoW3`9ULsBNTMtWs${`B=t_~O z%?d;RXA)(z#?KlzbnUVs>c-!jzkfplP7vX*0~LS`M~EQgjbN;RZTfga5pd~SX;TsD2GslG&D$qcN2I??}10(1l z;twCTFvkWJoZ!G5Dq`4x12lXHBMl!oaDt2@}_kur^-* zkQe$x$CFPw00WeCNLl3xR8~190T4{!039kq34;R!RQY9;6PTH$npsk`rkh#5fn*x}n2N1ZhgAE1-P=^B{>|p2)gSwEX3>4LYf&+%S0Ko@&Hd^TfgAy9TrZQxz zr=ApTx~ZU+ehSB&NuCDBr~cUC>Z>9^Kv4!fxVjP$4j}Mq1`gQaLPijX@G3>GPB4KT zD+x>NtG1dX1G2p`YeyWY_R&Wib1>`A9o%;7?YH2DEAF`DmTT@D3Ys^^xBlSa?z`~D zEAPDY)@$#*_~wg;KY8@)@4o;CEbzbt7i{ps2rT z%pH4l?D5AShb;2QB$sUR$tT~j3@c@DjPlDc$1HQozKn4R7i5^C^Ugf?Yzi4%sPab< zV=xoR(MTt)G$dM#QN$mAC@}>TOjK?4)mUe(_10W>?e*7PLotOCeZ z-WgXtImVoK?)m2xm!WyWq?c~`=?9B0xx8_3Q^p!|;L*k>v%~K0>_Kf}MjLdBn1IG_L{Bw-0^kU|rBzufO|1Wg9j*JNJGW}4vJ*q1#18TT&9qO5!6Wb?023wc+UX>pwM|j zX#`TLAzjiV4NiR5QNVuT$YS|6kp_R3FC1^M zA8+U>%1x+&Jeo^P8bHv>2Ac4i60D#FU8#ot9n^yh2qXx&p~Z~)@0=^N-)ktM!V;jg ze3{{BJ=s`>*JzF}Y)C^1BtVe@EP$pa@m>!0a)wo!Pb4L)NP|Sn;07~L;Grv#pBDMT zO9zN^h-7`E5!Sj^XOLBMKv7K^j_3+Cv>}?Fh$b2yB8)P?!jD?L>n8R(S2N(X6Myw9 zP!7w9#O`&mpm;1qq{ooTTK2M-RfzQX!P(Aw_Otqs9y>-$+R~a<9isai8n(gO*1Gn! z*FXd0=H?1y*!H%#4nouG*Ghg(e{34@ii@6TrsY<~sMeV0%IojvEL7 EJ6a7+7XSbN diff --git a/phpBB/styles/prosilver/theme/en/button_topic_locked.gif b/phpBB/styles/prosilver/theme/en/button_topic_locked.gif deleted file mode 100644 index b08918a24f3c8d82d357b6abecef1a016f54488a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1923 zcmV-}2YmQPNk%w1VORh%0Oo%H|NsB#>FK;GP5k`)3Xagn!@v6a`uX|!`}_O&`1tDT z>g((4?Ck9A?d|vX_wn)Z=;-M5^z`%d^YHNS_4W1k_V(`X?(gsK+l`H zgviZogMop8If2InNUbj~FM@)C*MF45MPuo>!~#XD?Be9e;qZflgX`??GBPsq)Z5Q) zg&rP1$yIUHhnlRctn%pV&1-|@-PKk`S{$SuMm;Z+Lov4*4rMJ)X{p6 z%*e#UL}KKsxX8r8?b_dc!{*R#hIzr|-L1Iz`1i`<@y=s>*p#H}&eg<4WXfN7>g?{* zdywO^zKqK0;_~^(Q*V&W>fP`7;osfm$j{Bm#>~mZ_xJYt`T6hM;Nafe=H%k%)Y*y1 z=p>reA(_41ejE#Wbx8o5oSmMZprN9pq@|llbyHbr zMF1ZIu(7hUw6(UkxVgHp9{@#YPzJBN#Kp$Pv>ygg1po-o(9zP<)YaD4*xAznh5!cN z;Njxq600RmfNU)&6emoK;G`P=!!-o(Z z2oMm_fg39&N?398aEKKzCA^4vIMHF3jAACL6tG94N)2DSRCJ(2hme~!XFl9lp{LKE z6(#~5QbK?a9|B4YsW7CB(J)1s^b|^^s1lbcvZfFdR6tgzCAt8uU~`9AAv(tX+()6U z+qV?|Cc;I^q%9KxVJL+0+Lnp{FKs7MaauR70Jw(TrZ9?Fg$c7eOsGKoc3*_cm@`M1 zsJVuKBbSc|s1d<4Xw91i+!4SBGiS}OBZwY>TEz@7xM!$9oq3;x-@t=Qm?)e$aN@>= z4_6sw$nTZLlP?!8*|CZ0CX@r;_n^D??++$|_uQm=lhF^zd*>3Q`@|cGKfM4EVkGI3MDGI&jmErXyXMFg`i^ydVE+Rgd^Z^0S-}A_ymYb&^QtQ zjYyz{KtvQH zM3JVL6OBoP0DD3gf|)9f@I@MBTCk#vETT~8nEN!~=%bKED(R$@R%+>`FUX+jrZT)x z={^jED(a}DmTKy$sHUpws-^C;z^kyvD(kGY)@tjmxaK#x8DE9|hu7HjOW z!EzH!0|7Ma?6c5DEA6z@R%`9G&o;0OD*!Ny?YH2DD{i*F_;CpwZJ46&y6m>=NgHrX z(Z?Tbys<_k_~xtczKN{y1{;6;VT2uX5Mc1Z2q&!Y!VEX;@WT)rJck`d{6WV55^@;f z?#3K-5u5M?LJ)L+fhw)mUe3E7bs`>cA!rkov#@B8YIn1EP*SfCvLn z5bD-M6Y-TMEEL-9B0Y2ODUh!3G>u&_DzvYyg4=AlQ(A z1%nF!Km|Q0Zo`=vWImAwTlC;~q&M6E!|JIE&h(;;5))nFGLq?NVfp!SWc`pgab@YtX|9WvZUT^)TE3yO>;m2`1q+8jw5x3*WFH01XGw zAOHpi9KeA9AoMa32fwqBK=J-Wfd2p(+-|^)8Gym{asY!2c&|oWi;;{7r=SmjKmZ&# z!3o|MzXwKe0tax#*Cz5i44kcaoX8*pC#X9SFen2n(1HqAkO2iIh-(Hq5aGO2yzUfl zh7UMFKO`VJ_>n+=XW9e~Yv>&hWFP|`Na7Ja5JMX>O*`8m9B>>6!M0G4iX5PT1Ps6e z4`z-A>Z5@Hp0~U)N|6Fr3=R@kz(zJ25sExy8gDRDJa8aje9ti72JX1NXY@b-K#-s2 zYA1l?5e^*pJ0$;Zhk(o=F^P~g;vDtIG|ISzj2PemA#tZW5+s1&1P|Om@CqqH%^5%n zoty~sn)kdd=#B#kcncC^KucO0(UKJ4np%9)!-?1c0fW(zW~OX4w2Ck`3FCkEhv1FVg02Y84%%O(N@gmV+*G$#PW z=?PfiO&Jx5!4da)#2A2+YX=FaKnF@tfpRS$2u-L$7g`UlspFv#ji^M;u{4+sKpPm% zs75zRjR6FWWUfGlNJmOiUI4%hSGbrN^5C(Sx|9@oFvAkg@P{*8fesPNsZMvw(}dCC J3N#G_06Tv4yea?y diff --git a/phpBB/styles/prosilver/theme/en/button_topic_new.gif b/phpBB/styles/prosilver/theme/en/button_topic_new.gif deleted file mode 100644 index 5b7b1e0e605dd5aed90d5c0067c15c3b480c6d37..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2737 zcmcIl=~vPT8~uTpxMVI+S>~Wwxi*%jHdbSZrMZj?nL0HRnwgfiIF;r2D(<-9GH#Iv z#T1uN(MrovNK`N|4Y$Ara0wN0&Aoh^5AUDw-g7_QbMAefFZbMwju)&?U&jC^fi(b- z3C5-e_>%t5tK(m`7MG>siCNKjw}0e7QsEGuIGFrwy~lKoUAGiUJ7@Nlg<;742moW~)C+3tn+6S)x~cvN!$nm5ly(-J=}-)X40bbY)BSb!%aD zOR}^%v%D!=UfbAMUteEaTU!;44RhG-92T>)t#xWbJUK3!5DUe^QPJ3laCDfTU-@kwR_HBE6duwZJbMuG%zo6CCuV25etgI|AFE1@EEiNuDEG*2= z&&y=8xw$#1R6095J2NvgJv}XvNT#NyCMPFFBGJgm$nfy6Kp+?z8X6oNlF8(vq9P)Zn46oMot>SLk&&F7oS2vx8yg!H z6%`Q?@#xW`hYufyhK7cOgaicz1qKHG_!;;=Lw5rL0)R2VrDT z+-KGgW|%&~=%cQ=ZvPBBHc)!WD5qjt_^rN*ayRm&=a*hp_E&k=2cJFFB{V=|+VF>* zURQsv58_o`OQ{Uuq3@1&J$HIT9eMY7d1mBU*POxSXgOsa=f+x5Tau=+tGp!~+ghdP zlrBYqHQ0Y&(aoe6EGsDftY=Q>IlMFld2VyeJN^jc%O1sAl&h(3{O#_ny3!%H>vFN| zO!tUoOK123JIcq6 z)8HCj4SC&4e?@A+^%uNb@RyCkc<8!!?M=|GY4FLTyK2`{he#_Up9%2L4q-%FIt+N-mKF;Pw8@r-l3bQv&> zbs?TWT}OZjRJCbaxSguv3%OtKuO3#=KrbH7(Qd@P$k1^XPG(Ut6-TnG&Dzo|IY49T zsnGzkQZ{w{YuEF~qqpK9H4_LB{OPLWL2!*TAy!?x`8}gJQp_$Ory)0$ZbA_x9K^_( zFCj;avM*T-Ih(sscvtOQESefWRru94%mh~<9d>#u6?B*fQdBi;i;ZFG%==))V@x$C z6@9fWqnlLht@tW02l{!FhUY!Tv^s;?N>xiHIK{YnKQEQS+s{)rrZ)2{{b;3Cp>Hob z5JCYMMtGb$Tb5!h@5G|TLH0{(kKddrL7Z2fd5r)m(SWNp@4-BROim+?blil2@l2zz znmuaXMsdZ9ojQAT8J&6=&9M;oQtf!49>wqh)x+pMFvNq^d!R!OJ)qsE9|84T#7A&A zXsJX9me)`b)tS7()Tf!VlP)=%oPR3aXX<@3?N2$4ptHz9RL=lt0G68eXSXl!eZj!4 zzMcoWcVYf{$bZ1YMl0@fyUPIkbnYxUTlGo7DHc3iIVZmN*5wc4R4du~IN{>)jfos5 zS0|G$ZM#=y+#x;XiKx$do08JJ(9LN|IdyZU>Z!>urnDa1TfaAbp<8o}U#MHM<~7;Y zJbg^O?>KW`*!CjpSk3kl$7+6ixiK7$Hf=(Oefv6ev*z3C@T2)}Yh!~nm=oD;&-V>U zc}>(hIU32f&yT}?+Flt9YjrHfEF~L^Ie&6IqOM2+6ddSD=n~EB^$x53y3lh&q8PPQ z66BZzL& zT^O;Lf>9ZtZ)BnRUSeTY`$x16kE>Iwk$Ycz`#V;pw=kL`%#zAsOcwdwUnCu3=gF?h;QN-{cqoU?3QgRVTTWZi5 zM$l+ES3IBqp=jRmwvBebTNX)00LmvZF)9}4;SE8<2K=5~C_3_fI!fErx7blpMQB^7 zEw82z!~`QTfQed+A^L=zqBa1pU;OImJJ5Q9Q$d(}Wb0OPQdX!BY5fuC3#5g`a-+=r5=x*!x{l*RrkF-5p(P zs3Y!4up(gn(=D!4dAXy52Tq-`rW>f`06Z1xtD-t#5GHKeD7{5fVUhU7RKCiT-VBC6 zwUyIiA$(2}i&aA1n6`eCEY}f7c&|x36y7m_mUiKa|X;$rSpJHs>12&z4F2F~ilB0BT%rPK0;IW(o>RG;*d*r*2q=zI90 z95JjT*}Op1oO$+O7A*QHAr7 zr(K`={+u3=Lb>QN<53l#a@wNZ%ZoeX^={Ls%nhr24VU99*c>>cWv}}dK-yV| z$Ww30RdLH;dd+Kt&~Ap#ZG_Kmh0<||(t3~Af0WdQnbwG#)rXqbiJaSwpxKqC*p#H# zlcU;}r{J8d+n}!Bq_X6yxZbU~>A1w=yT$Fs(B;U_>(15c&D814)9B06?b+Vy*4yXQ z+4Je_^62aF=js4z#sEu===A#vj?fU1(H@u7A(_-9n$>y1<$c5EfW_yD$mop9>5t3l zk<9Ad@A&2O`s?=l;_~_V`S|$w_xJbq%*n;f$i&CPzvkrP<>TSx;^5-o-r?Wf;NINL z$;QaU!TS06`1kk!|Ns8}{{8*^{QUg;`}_L(`uX|!`1ttu_xJYp_VxAk^z`)e^YilZ z^6~NU@bK{O@9*yJ?(OaE?Ck98>+9<3>gnm}=;-K=kB?+zWdHyFA^8LW004ggEC2ui z0AK(z000O7fPYn9VOoZVh>41ejE#n}-l1 zNQ^)s21ErMB!U3&@COKq9B?q0IFUjdk`Y3lM44jcL=Zn#Ld>Y(p@Ik)Vm@4>X3fr? z5Fh$;L$qjw6ghH`h!DU{jH5Xic%T5p4F?Vk7>J;nG)07@O(mvCAtHhYH)6-8P=NL* z*$5*4+7`Wufhf(QY}WW$<0kK3Hbvd|dqcQz1Q&#ZM2Mj{Md3FXM7%kin1T+%E+RaZ zXjn7n$CEV^=0G9zCort3U z8?*H>TY4yd=noxKRv7^cRZnbx35wrY6jg zDW!pa%BcxHd>U#UaMA4<7Kw zEAPDY)@$#*_~xtczIgbP$G-pvEbzbt7i{ps2q&y?9{%Xz@WT*CEb+t?S8VbB#TaL- zM>oOTvB$?Chb;2QB$sUR$tb6s@*T^tQijJW$1L;AG_UN-7nf`?hABMv?DNm2jIo6n zWc+aj7+6H2^wLZ>9SIg-T=B;rQZSK35m;xf_10W>?e*7Shb=bPNiZSBA5<98gcLxx z?e^QFNYR85R4n1d%Qfe%_uePpQHB#s95DqRd=zf@;fN=$_~MK=?)c-6<1xh%MU8Pi!dcvhwK5rYHnBhjead1<{8gsxqM?cP7_=y>? zcanzho(Rd+K|==;jUYh(dIO9gQ3np# zfM5mKlZ1ZzB&h&@_ye^6avI>%@CF<-L~y|XcJNk1xYxaZxT|x|!k!8o;D8cDKmcrz zK?D|P0|QiG0BGny2W()25nPagDu@6B1<*bfsK9&%D4_{eKm!$;Zv^(U!yEc{fmh_u z4X|p+5XxW&9sYw`oeLHAUf>2f3?KqBIHC&JAO|>{;Q}y>zzf&_hXGW;0djD|3nEYk zIn2R+4Uq^K0RjgwW{`bi2n}*niI2=(1{S$y3 zsKf>pRKN@tWT61ezy>^^wha1DUg8<6aXYa#0E$Xpac~-p95ku%P*qjfAbTg3nLIkE`n$cA&fu?a0jAO zrt*%=Y-Z;=gc2F3A&?x312QjY12vdo05rHj4c7ok_Oy=%G;rVxRA|C>pkxH~6JvYc zAOML7Ae-j2qYzZ7hILiXIz!}y8s4BpHT1;{P*fiT-9Sz*Hna@50VDP0wWkC8Z1(yXYE{2+JJ^Kpkb~L5ymFa;FC72p{`{x179Cf*SpenuWd+! z83g+YSRfW6fbE21?K;=UN_MW*V~A!q%h}E6pRpsKSV(ZNEn-Rr%T=H NjtvP)Xl@_?06RStF?j$0 From fe97611eacb913a93b8c604d2ceb97e3fd42d744 Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Sun, 11 Aug 2013 10:51:37 +0300 Subject: [PATCH 2436/2494] [ticket/11780] Remove references to unused images PHPBB3-11780 --- .../styles/prosilver/theme/en/stylesheet.css | 30 ------------------- phpBB/styles/prosilver/theme/imageset.css | 30 ------------------- 2 files changed, 60 deletions(-) diff --git a/phpBB/styles/prosilver/theme/en/stylesheet.css b/phpBB/styles/prosilver/theme/en/stylesheet.css index 1a3d0acb4b..82b7df0830 100644 --- a/phpBB/styles/prosilver/theme/en/stylesheet.css +++ b/phpBB/styles/prosilver/theme/en/stylesheet.css @@ -32,33 +32,3 @@ ul.profile-icons li.edit-icon { width: 42px; height: 20px; } padding-left: 58px; padding-top: 58px; } -.imageset.button_pm_forward { - background-image: url("./button_pm_forward.gif"); - padding-left: 96px; - padding-top: 25px; -} -.imageset.button_pm_new { - background-image: url("./button_pm_new.gif"); - padding-left: 84px; - padding-top: 25px; -} -.imageset.button_pm_reply { - background-image: url("./button_pm_reply.gif"); - padding-left: 96px; - padding-top: 25px; -} -.imageset.button_topic_locked { - background-image: url("./button_topic_locked.gif"); - padding-left: 88px; - padding-top: 25px; -} -.imageset.button_topic_new { - background-image: url("./button_topic_new.gif"); - padding-left: 96px; - padding-top: 25px; -} -.imageset.button_topic_reply { - background-image: url("./button_topic_reply.gif"); - padding-left: 96px; - padding-top: 25px; -} diff --git a/phpBB/styles/prosilver/theme/imageset.css b/phpBB/styles/prosilver/theme/imageset.css index 296c617f17..7aa19df06e 100644 --- a/phpBB/styles/prosilver/theme/imageset.css +++ b/phpBB/styles/prosilver/theme/imageset.css @@ -378,33 +378,3 @@ span.imageset { padding-left: 58px; padding-top: 58px; } -.imageset.button_pm_forward { - background-image: url("./en/button_pm_forward.gif"); - padding-left: 96px; - padding-top: 25px; -} -.imageset.button_pm_new { - background-image: url("./en/button_pm_new.gif"); - padding-left: 84px; - padding-top: 25px; -} -.imageset.button_pm_reply { - background-image: url("./en/button_pm_reply.gif"); - padding-left: 96px; - padding-top: 25px; -} -.imageset.button_topic_locked { - background-image: url("./en/button_topic_locked.gif"); - padding-left: 88px; - padding-top: 25px; -} -.imageset.button_topic_new { - background-image: url("./en/button_topic_new.gif"); - padding-left: 96px; - padding-top: 25px; -} -.imageset.button_topic_reply { - background-image: url("./en/button_topic_reply.gif"); - padding-left: 96px; - padding-top: 25px; -} From a0206a61bcc174d04f80a6e172f37b25f5b84694 Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Sun, 11 Aug 2013 11:31:02 +0300 Subject: [PATCH 2437/2494] [ticket/11781] Include func update_post_information() Include functions_posting before using functions defined in that file PHPBB3-11781 --- phpBB/phpbb/content_visibility.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/phpBB/phpbb/content_visibility.php b/phpBB/phpbb/content_visibility.php index 4ad5f6793e..fb8ece0e8c 100644 --- a/phpBB/phpbb/content_visibility.php +++ b/phpBB/phpbb/content_visibility.php @@ -360,6 +360,11 @@ class phpbb_content_visibility // Sync the first/last topic information if needed if (!$is_starter && $is_latest) { + if (!function_exists('update_post_information')) + { + include($this->phpbb_root_path . 'includes/functions_posting.' . $this->php_ext); + } + // update_post_information can only update the last post info ... if ($topic_id) { From 9a5363462b54cf137a1ec0149c0fa6cfbeca5e7c Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Sun, 11 Aug 2013 19:57:34 +0300 Subject: [PATCH 2438/2494] [ticket/11782] Change p.rules to p.post-notice in templates PHPBB3-11782 --- phpBB/styles/prosilver/template/mcp_post.html | 8 ++-- .../styles/prosilver/template/mcp_topic.html | 20 ++++++--- .../template/ucp_pm_viewmessage.html | 2 +- .../prosilver/template/viewtopic_body.html | 43 ++++++++++--------- 4 files changed, 43 insertions(+), 30 deletions(-) diff --git a/phpBB/styles/prosilver/template/mcp_post.html b/phpBB/styles/prosilver/template/mcp_post.html index 4cdd62957c..7b2ace6792 100644 --- a/phpBB/styles/prosilver/template/mcp_post.html +++ b/phpBB/styles/prosilver/template/mcp_post.html @@ -14,7 +14,7 @@

              {L_REPORT_REASON}{L_COLON} {REPORT_REASON_TITLE}

              {L_REPORTED} {L_POST_BY_AUTHOR} {REPORTER_FULL} « {REPORT_DATE}

              -

              {L_REPORT_CLOSED}

              +

              {L_REPORT_CLOSED}

              @@ -71,7 +71,7 @@
              -

              +

                @@ -82,7 +82,7 @@ -

              +

                @@ -93,7 +93,7 @@ -

              +

              {REPORTED_IMG} {L_MESSAGE_REPORTED}

              diff --git a/phpBB/styles/prosilver/template/mcp_topic.html b/phpBB/styles/prosilver/template/mcp_topic.html index 0fd5a9455f..bfe18579a6 100644 --- a/phpBB/styles/prosilver/template/mcp_topic.html +++ b/phpBB/styles/prosilver/template/mcp_topic.html @@ -101,11 +101,21 @@

              {postrow.POST_SUBJECT}

              {postrow.MINI_POST_IMG} {L_POSTED} {postrow.POST_DATE} {L_POST_BY_AUTHOR} {postrow.POST_AUTHOR_FULL} [ {L_POST_DETAILS} ]

              - -

              - {UNAPPROVED_IMG} {L_POST_UNAPPROVED}
              - {DELETED_IMG} {L_POST_DELETED}
              - {REPORTED_IMG} {L_POST_REPORTED} + +

              + {L_POST_UNAPPROVED} +

              + + + +

              + {L_POST_DELETED} +

              + + + +

              + {L_POST_REPORTED}

              diff --git a/phpBB/styles/prosilver/template/ucp_pm_viewmessage.html b/phpBB/styles/prosilver/template/ucp_pm_viewmessage.html index 4f2531d3a6..50e76f5b75 100644 --- a/phpBB/styles/prosilver/template/ucp_pm_viewmessage.html +++ b/phpBB/styles/prosilver/template/ucp_pm_viewmessage.html @@ -62,7 +62,7 @@ -
              {L_DOWNLOAD_NOTICE}
              +
              {L_DOWNLOAD_NOTICE}
              diff --git a/phpBB/styles/prosilver/template/viewtopic_body.html b/phpBB/styles/prosilver/template/viewtopic_body.html index c8a99b18e4..0f0961eba2 100644 --- a/phpBB/styles/prosilver/template/viewtopic_body.html +++ b/phpBB/styles/prosilver/template/viewtopic_body.html @@ -151,29 +151,32 @@

              class="first"> {postrow.POST_SUBJECT}

              {postrow.MINI_POST_IMG}{postrow.MINI_POST_IMG}{L_POST_BY_AUTHOR} {postrow.POST_AUTHOR_FULL} » {postrow.POST_DATE}

              - + -

              - - {UNAPPROVED_IMG} {L_POST_UNAPPROVED} - - - - {S_FORM_TOKEN} -
              - - {DELETED_IMG} {L_POST_DELETED} - - - - {S_FORM_TOKEN} -
              - - - {REPORTED_IMG} {L_POST_REPORTED} - +

              + {L_POST_UNAPPROVED} + + + + {S_FORM_TOKEN}

              + +
              +

              + {L_POST_DELETED} + + + + {S_FORM_TOKEN} +

              + + + + +

              + {L_POST_REPORTED} +

              {postrow.MESSAGE}
              From 788238d7a989951747307b15eaa2192253e81535 Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Sun, 11 Aug 2013 20:00:41 +0300 Subject: [PATCH 2439/2494] [ticket/11782] Change p.rules to p.post-notice in CSS PHPBB3-11782 --- phpBB/styles/prosilver/theme/colours.css | 15 +++++++++++- phpBB/styles/prosilver/theme/common.css | 29 ++++++++++++++---------- 2 files changed, 31 insertions(+), 13 deletions(-) diff --git a/phpBB/styles/prosilver/theme/colours.css b/phpBB/styles/prosilver/theme/colours.css index 5548905ede..7736371460 100644 --- a/phpBB/styles/prosilver/theme/colours.css +++ b/phpBB/styles/prosilver/theme/colours.css @@ -214,11 +214,24 @@ div.rules { color: #BC2A4D; } -p.rules { +p.post-notice { background-color: #ECD5D8; background-image: none; } +p.post-notice.deleted:before { + background-image: url("./images/icon_topic_deleted.png"); +} + +p.post-notice.unapproved:before { + background-image: url("./images/icon_topic_unapproved.gif"); +} + +p.post-notice.reported:before, p.post-notice.error:before { + background-image: url("./images/icon_topic_reported.gif"); +} + + /* -------------------------------------------------------------- Colours and backgrounds for links.css diff --git a/phpBB/styles/prosilver/theme/common.css b/phpBB/styles/prosilver/theme/common.css index a2b8034187..cdafc706df 100644 --- a/phpBB/styles/prosilver/theme/common.css +++ b/phpBB/styles/prosilver/theme/common.css @@ -685,23 +685,28 @@ div.rules ul, div.rules ol { margin-left: 20px; } -p.rules { - background-image: none; +p.post-notice { + position: relative; padding: 5px; + padding-left: 26px; + min-height: 14px; + margin-bottom: 1em; } -p.rules img { - vertical-align: middle; +p.post-notice:before { + content: ''; + display: block; + position: absolute; + top: 0; + bottom: 0; + left: 0; + width: 28px; + background: transparent none 50% 50% no-repeat; + pointer-events: none; } -p.rules strong { - vertical-align: middle; - padding-top: 5px; -} - -p.rules a { - vertical-align: middle; - clear: both; +form p.post-notice strong { + line-height: 20px; } #top { From c63901fcb59f3795023dc9ea2b35c616fa08b756 Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Sun, 11 Aug 2013 20:01:15 +0300 Subject: [PATCH 2440/2494] [ticket/11782] RTL support for post notices PHPBB3-11782 --- phpBB/styles/prosilver/theme/bidi.css | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/phpBB/styles/prosilver/theme/bidi.css b/phpBB/styles/prosilver/theme/bidi.css index a921805327..41a9874a18 100644 --- a/phpBB/styles/prosilver/theme/bidi.css +++ b/phpBB/styles/prosilver/theme/bidi.css @@ -371,6 +371,13 @@ float: right; } +.rtl p.post-notice:before { + left: auto; + right: 0; + padding-left: 5px; + padding-right: 26px; +} + /* Topic review panel ----------------------------------------*/ .rtl #topicreview { From 0b32a97c4711afccc77ff74b32cc0d0ff6b7d6bc Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Sun, 11 Aug 2013 20:10:33 +0300 Subject: [PATCH 2441/2494] [ticket/11782] Apply line-height correctly Apply line-height only to bolded elements inside post notices that are direct child elements of forms. PHPBB3-11782 --- phpBB/styles/prosilver/theme/common.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/styles/prosilver/theme/common.css b/phpBB/styles/prosilver/theme/common.css index cdafc706df..4a77dc78d0 100644 --- a/phpBB/styles/prosilver/theme/common.css +++ b/phpBB/styles/prosilver/theme/common.css @@ -705,7 +705,7 @@ p.post-notice:before { pointer-events: none; } -form p.post-notice strong { +form > p.post-notice strong { line-height: 20px; } From 49824a0fd33df6b9da4e413ccd189379fb7f728b Mon Sep 17 00:00:00 2001 From: rechosen Date: Thu, 8 Aug 2013 11:31:06 +0200 Subject: [PATCH 2442/2494] [ticket/11777] Add subdirectory 'events/' to the template event search path Makes the twig template engine look in the events/ subdirectory instead of the main styles/[style]/template/ directory for extension template events. Note that it does _not_ look recursively! PHPBB3-11777 --- phpBB/phpbb/template/twig/node/event.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/phpBB/phpbb/template/twig/node/event.php b/phpBB/phpbb/template/twig/node/event.php index 971dea14fa..30a9963a77 100644 --- a/phpBB/phpbb/template/twig/node/event.php +++ b/phpBB/phpbb/template/twig/node/event.php @@ -18,6 +18,11 @@ if (!defined('IN_PHPBB')) class phpbb_template_twig_node_event extends Twig_Node { + /** + * The subdirectory in which all template event files must be placed + */ + const TEMPLATE_EVENTS_SUBDIRECTORY = 'events/'; + /** @var Twig_Environment */ protected $environment; @@ -50,19 +55,19 @@ class phpbb_template_twig_node_event extends Twig_Node // slower, but makes developing extensions easier (no need to // purge the cache when a new event template file is added) $compiler - ->write("if (\$this->env->getLoader()->exists('@{$ext_namespace}/{$location}.html')) {\n") + ->write("if (\$this->env->getLoader()->exists('@{$ext_namespace}/" . self::TEMPLATE_EVENTS_SUBDIRECTORY . "{$location}.html')) {\n") ->indent() ; } - if (defined('DEBUG') || $this->environment->getLoader()->exists('@' . $ext_namespace . '/' . $location . '.html')) + if (defined('DEBUG') || $this->environment->getLoader()->exists('@' . $ext_namespace . '/' . self::TEMPLATE_EVENTS_SUBDIRECTORY . $location . '.html')) { $compiler ->write("\$previous_look_up_order = \$this->env->getNamespaceLookUpOrder();\n") // We set the namespace lookup order to be this extension first, then the main path ->write("\$this->env->setNamespaceLookUpOrder(array('{$ext_namespace}', '__main__'));\n") - ->write("\$this->env->loadTemplate('@{$ext_namespace}/{$location}.html')->display(\$context);\n") + ->write("\$this->env->loadTemplate('@{$ext_namespace}/" . self::TEMPLATE_EVENTS_SUBDIRECTORY . "{$location}.html')->display(\$context);\n") ->write("\$this->env->setNamespaceLookUpOrder(\$previous_look_up_order);\n") ; } From e1c9a875867953f6bfd4e442ae804c85377f8360 Mon Sep 17 00:00:00 2001 From: rechosen Date: Thu, 8 Aug 2013 14:00:44 +0200 Subject: [PATCH 2443/2494] [ticket/11777] Move the testing template events to 'events/' subdirectories The tests written for extension template events did not follow the convention and documentation of placing template event files in the events/ subdirectory. Moved the files to this subdirectory so the tests succeed again. PHPBB3-11777 --- .../ext/kappa/styles/all/template/{ => events}/test.html | 0 .../ext/kappa/styles/silver/template/{ => events}/test.html | 0 .../kappa/styles/silver_inherit/template/{ => events}/test.html | 0 .../ext/omega/styles/all/template/{ => events}/test.html | 0 .../ext/omega/styles/silver/template/{ => events}/test.html | 0 .../ext/omega/styles/silver/template/{ => events}/two.html | 0 .../ext/zeta/styles/all/template/{ => events}/test.html | 0 .../styles/all/template/{ => events}/event_variable_spacing.html | 0 .../ext/trivial/styles/all/template/{ => events}/universal.html | 0 .../ext/trivial/styles/silver/template/{ => events}/simple.html | 0 10 files changed, 0 insertions(+), 0 deletions(-) rename tests/template/datasets/event_inheritance/ext/kappa/styles/all/template/{ => events}/test.html (100%) rename tests/template/datasets/event_inheritance/ext/kappa/styles/silver/template/{ => events}/test.html (100%) rename tests/template/datasets/event_inheritance/ext/kappa/styles/silver_inherit/template/{ => events}/test.html (100%) rename tests/template/datasets/event_inheritance/ext/omega/styles/all/template/{ => events}/test.html (100%) rename tests/template/datasets/event_inheritance/ext/omega/styles/silver/template/{ => events}/test.html (100%) rename tests/template/datasets/event_inheritance/ext/omega/styles/silver/template/{ => events}/two.html (100%) rename tests/template/datasets/event_inheritance/ext/zeta/styles/all/template/{ => events}/test.html (100%) rename tests/template/datasets/ext_trivial/ext/trivial/styles/all/template/{ => events}/event_variable_spacing.html (100%) rename tests/template/datasets/ext_trivial/ext/trivial/styles/all/template/{ => events}/universal.html (100%) rename tests/template/datasets/ext_trivial/ext/trivial/styles/silver/template/{ => events}/simple.html (100%) diff --git a/tests/template/datasets/event_inheritance/ext/kappa/styles/all/template/test.html b/tests/template/datasets/event_inheritance/ext/kappa/styles/all/template/events/test.html similarity index 100% rename from tests/template/datasets/event_inheritance/ext/kappa/styles/all/template/test.html rename to tests/template/datasets/event_inheritance/ext/kappa/styles/all/template/events/test.html diff --git a/tests/template/datasets/event_inheritance/ext/kappa/styles/silver/template/test.html b/tests/template/datasets/event_inheritance/ext/kappa/styles/silver/template/events/test.html similarity index 100% rename from tests/template/datasets/event_inheritance/ext/kappa/styles/silver/template/test.html rename to tests/template/datasets/event_inheritance/ext/kappa/styles/silver/template/events/test.html diff --git a/tests/template/datasets/event_inheritance/ext/kappa/styles/silver_inherit/template/test.html b/tests/template/datasets/event_inheritance/ext/kappa/styles/silver_inherit/template/events/test.html similarity index 100% rename from tests/template/datasets/event_inheritance/ext/kappa/styles/silver_inherit/template/test.html rename to tests/template/datasets/event_inheritance/ext/kappa/styles/silver_inherit/template/events/test.html diff --git a/tests/template/datasets/event_inheritance/ext/omega/styles/all/template/test.html b/tests/template/datasets/event_inheritance/ext/omega/styles/all/template/events/test.html similarity index 100% rename from tests/template/datasets/event_inheritance/ext/omega/styles/all/template/test.html rename to tests/template/datasets/event_inheritance/ext/omega/styles/all/template/events/test.html diff --git a/tests/template/datasets/event_inheritance/ext/omega/styles/silver/template/test.html b/tests/template/datasets/event_inheritance/ext/omega/styles/silver/template/events/test.html similarity index 100% rename from tests/template/datasets/event_inheritance/ext/omega/styles/silver/template/test.html rename to tests/template/datasets/event_inheritance/ext/omega/styles/silver/template/events/test.html diff --git a/tests/template/datasets/event_inheritance/ext/omega/styles/silver/template/two.html b/tests/template/datasets/event_inheritance/ext/omega/styles/silver/template/events/two.html similarity index 100% rename from tests/template/datasets/event_inheritance/ext/omega/styles/silver/template/two.html rename to tests/template/datasets/event_inheritance/ext/omega/styles/silver/template/events/two.html diff --git a/tests/template/datasets/event_inheritance/ext/zeta/styles/all/template/test.html b/tests/template/datasets/event_inheritance/ext/zeta/styles/all/template/events/test.html similarity index 100% rename from tests/template/datasets/event_inheritance/ext/zeta/styles/all/template/test.html rename to tests/template/datasets/event_inheritance/ext/zeta/styles/all/template/events/test.html diff --git a/tests/template/datasets/ext_trivial/ext/trivial/styles/all/template/event_variable_spacing.html b/tests/template/datasets/ext_trivial/ext/trivial/styles/all/template/events/event_variable_spacing.html similarity index 100% rename from tests/template/datasets/ext_trivial/ext/trivial/styles/all/template/event_variable_spacing.html rename to tests/template/datasets/ext_trivial/ext/trivial/styles/all/template/events/event_variable_spacing.html diff --git a/tests/template/datasets/ext_trivial/ext/trivial/styles/all/template/universal.html b/tests/template/datasets/ext_trivial/ext/trivial/styles/all/template/events/universal.html similarity index 100% rename from tests/template/datasets/ext_trivial/ext/trivial/styles/all/template/universal.html rename to tests/template/datasets/ext_trivial/ext/trivial/styles/all/template/events/universal.html diff --git a/tests/template/datasets/ext_trivial/ext/trivial/styles/silver/template/simple.html b/tests/template/datasets/ext_trivial/ext/trivial/styles/silver/template/events/simple.html similarity index 100% rename from tests/template/datasets/ext_trivial/ext/trivial/styles/silver/template/simple.html rename to tests/template/datasets/ext_trivial/ext/trivial/styles/silver/template/events/simple.html From 7f76c9f9c7d9014f313f150a9596bec030f39915 Mon Sep 17 00:00:00 2001 From: rechosen Date: Fri, 9 Aug 2013 11:33:24 +0200 Subject: [PATCH 2444/2494] [ticket/11777] Rename the extension template listener subdirectory to 'event/' Per suggestion of EXreaction and nickvergessen, do not look for extension template event listeners in styles/[style]/template/events/ but in styles/[style]/template/event/ (without the trailing 's') to match the way phpBB looks for php template event listeners. PHPBB3-11777 --- phpBB/phpbb/template/twig/node/event.php | 13 +++++++------ .../styles/all/template/{events => event}/test.html | 0 .../silver/template/{events => event}/test.html | 0 .../template/{events => event}/test.html | 0 .../styles/all/template/{events => event}/test.html | 0 .../silver/template/{events => event}/test.html | 0 .../silver/template/{events => event}/two.html | 0 .../styles/all/template/{events => event}/test.html | 0 .../{events => event}/event_variable_spacing.html | 0 .../all/template/{events => event}/universal.html | 0 .../silver/template/{events => event}/simple.html | 0 11 files changed, 7 insertions(+), 6 deletions(-) rename tests/template/datasets/event_inheritance/ext/kappa/styles/all/template/{events => event}/test.html (100%) rename tests/template/datasets/event_inheritance/ext/kappa/styles/silver/template/{events => event}/test.html (100%) rename tests/template/datasets/event_inheritance/ext/kappa/styles/silver_inherit/template/{events => event}/test.html (100%) rename tests/template/datasets/event_inheritance/ext/omega/styles/all/template/{events => event}/test.html (100%) rename tests/template/datasets/event_inheritance/ext/omega/styles/silver/template/{events => event}/test.html (100%) rename tests/template/datasets/event_inheritance/ext/omega/styles/silver/template/{events => event}/two.html (100%) rename tests/template/datasets/event_inheritance/ext/zeta/styles/all/template/{events => event}/test.html (100%) rename tests/template/datasets/ext_trivial/ext/trivial/styles/all/template/{events => event}/event_variable_spacing.html (100%) rename tests/template/datasets/ext_trivial/ext/trivial/styles/all/template/{events => event}/universal.html (100%) rename tests/template/datasets/ext_trivial/ext/trivial/styles/silver/template/{events => event}/simple.html (100%) diff --git a/phpBB/phpbb/template/twig/node/event.php b/phpBB/phpbb/template/twig/node/event.php index 30a9963a77..c94e5fdf20 100644 --- a/phpBB/phpbb/template/twig/node/event.php +++ b/phpBB/phpbb/template/twig/node/event.php @@ -19,9 +19,10 @@ if (!defined('IN_PHPBB')) class phpbb_template_twig_node_event extends Twig_Node { /** - * The subdirectory in which all template event files must be placed + * The subdirectory in which all template listener files must be placed + * @var string */ - const TEMPLATE_EVENTS_SUBDIRECTORY = 'events/'; + protected $listener_directory = 'event/'; /** @var Twig_Environment */ protected $environment; @@ -42,7 +43,7 @@ class phpbb_template_twig_node_event extends Twig_Node { $compiler->addDebugInfo($this); - $location = $this->getNode('expr')->getAttribute('name'); + $location = $this->listener_directory . $this->getNode('expr')->getAttribute('name'); foreach ($this->environment->get_phpbb_extensions() as $ext_namespace => $ext_path) { @@ -55,19 +56,19 @@ class phpbb_template_twig_node_event extends Twig_Node // slower, but makes developing extensions easier (no need to // purge the cache when a new event template file is added) $compiler - ->write("if (\$this->env->getLoader()->exists('@{$ext_namespace}/" . self::TEMPLATE_EVENTS_SUBDIRECTORY . "{$location}.html')) {\n") + ->write("if (\$this->env->getLoader()->exists('@{$ext_namespace}/{$location}.html')) {\n") ->indent() ; } - if (defined('DEBUG') || $this->environment->getLoader()->exists('@' . $ext_namespace . '/' . self::TEMPLATE_EVENTS_SUBDIRECTORY . $location . '.html')) + if (defined('DEBUG') || $this->environment->getLoader()->exists('@' . $ext_namespace . '/' . $location . '.html')) { $compiler ->write("\$previous_look_up_order = \$this->env->getNamespaceLookUpOrder();\n") // We set the namespace lookup order to be this extension first, then the main path ->write("\$this->env->setNamespaceLookUpOrder(array('{$ext_namespace}', '__main__'));\n") - ->write("\$this->env->loadTemplate('@{$ext_namespace}/" . self::TEMPLATE_EVENTS_SUBDIRECTORY . "{$location}.html')->display(\$context);\n") + ->write("\$this->env->loadTemplate('@{$ext_namespace}/{$location}.html')->display(\$context);\n") ->write("\$this->env->setNamespaceLookUpOrder(\$previous_look_up_order);\n") ; } diff --git a/tests/template/datasets/event_inheritance/ext/kappa/styles/all/template/events/test.html b/tests/template/datasets/event_inheritance/ext/kappa/styles/all/template/event/test.html similarity index 100% rename from tests/template/datasets/event_inheritance/ext/kappa/styles/all/template/events/test.html rename to tests/template/datasets/event_inheritance/ext/kappa/styles/all/template/event/test.html diff --git a/tests/template/datasets/event_inheritance/ext/kappa/styles/silver/template/events/test.html b/tests/template/datasets/event_inheritance/ext/kappa/styles/silver/template/event/test.html similarity index 100% rename from tests/template/datasets/event_inheritance/ext/kappa/styles/silver/template/events/test.html rename to tests/template/datasets/event_inheritance/ext/kappa/styles/silver/template/event/test.html diff --git a/tests/template/datasets/event_inheritance/ext/kappa/styles/silver_inherit/template/events/test.html b/tests/template/datasets/event_inheritance/ext/kappa/styles/silver_inherit/template/event/test.html similarity index 100% rename from tests/template/datasets/event_inheritance/ext/kappa/styles/silver_inherit/template/events/test.html rename to tests/template/datasets/event_inheritance/ext/kappa/styles/silver_inherit/template/event/test.html diff --git a/tests/template/datasets/event_inheritance/ext/omega/styles/all/template/events/test.html b/tests/template/datasets/event_inheritance/ext/omega/styles/all/template/event/test.html similarity index 100% rename from tests/template/datasets/event_inheritance/ext/omega/styles/all/template/events/test.html rename to tests/template/datasets/event_inheritance/ext/omega/styles/all/template/event/test.html diff --git a/tests/template/datasets/event_inheritance/ext/omega/styles/silver/template/events/test.html b/tests/template/datasets/event_inheritance/ext/omega/styles/silver/template/event/test.html similarity index 100% rename from tests/template/datasets/event_inheritance/ext/omega/styles/silver/template/events/test.html rename to tests/template/datasets/event_inheritance/ext/omega/styles/silver/template/event/test.html diff --git a/tests/template/datasets/event_inheritance/ext/omega/styles/silver/template/events/two.html b/tests/template/datasets/event_inheritance/ext/omega/styles/silver/template/event/two.html similarity index 100% rename from tests/template/datasets/event_inheritance/ext/omega/styles/silver/template/events/two.html rename to tests/template/datasets/event_inheritance/ext/omega/styles/silver/template/event/two.html diff --git a/tests/template/datasets/event_inheritance/ext/zeta/styles/all/template/events/test.html b/tests/template/datasets/event_inheritance/ext/zeta/styles/all/template/event/test.html similarity index 100% rename from tests/template/datasets/event_inheritance/ext/zeta/styles/all/template/events/test.html rename to tests/template/datasets/event_inheritance/ext/zeta/styles/all/template/event/test.html diff --git a/tests/template/datasets/ext_trivial/ext/trivial/styles/all/template/events/event_variable_spacing.html b/tests/template/datasets/ext_trivial/ext/trivial/styles/all/template/event/event_variable_spacing.html similarity index 100% rename from tests/template/datasets/ext_trivial/ext/trivial/styles/all/template/events/event_variable_spacing.html rename to tests/template/datasets/ext_trivial/ext/trivial/styles/all/template/event/event_variable_spacing.html diff --git a/tests/template/datasets/ext_trivial/ext/trivial/styles/all/template/events/universal.html b/tests/template/datasets/ext_trivial/ext/trivial/styles/all/template/event/universal.html similarity index 100% rename from tests/template/datasets/ext_trivial/ext/trivial/styles/all/template/events/universal.html rename to tests/template/datasets/ext_trivial/ext/trivial/styles/all/template/event/universal.html diff --git a/tests/template/datasets/ext_trivial/ext/trivial/styles/silver/template/events/simple.html b/tests/template/datasets/ext_trivial/ext/trivial/styles/silver/template/event/simple.html similarity index 100% rename from tests/template/datasets/ext_trivial/ext/trivial/styles/silver/template/events/simple.html rename to tests/template/datasets/ext_trivial/ext/trivial/styles/silver/template/event/simple.html From 08e6c6118036700f5d4196aa09d9d1a34b840514 Mon Sep 17 00:00:00 2001 From: rechosen Date: Fri, 9 Aug 2013 11:39:43 +0200 Subject: [PATCH 2445/2494] [ticket/11777] Require a suffix of '_listener' on extension template listeners To further mirror the file name and location requirements for php template event listeners, require extension template event listener files to follow the '_listener.html' naming format. PHPBB3-11777 --- phpBB/phpbb/template/twig/node/event.php | 2 +- .../styles/all/template/event/{test.html => test_listener.html} | 0 .../silver/template/event/{test.html => test_listener.html} | 0 .../template/event/{test.html => test_listener.html} | 0 .../styles/all/template/event/{test.html => test_listener.html} | 0 .../silver/template/event/{test.html => test_listener.html} | 0 .../silver/template/event/{two.html => two_listener.html} | 0 .../styles/all/template/event/{test.html => test_listener.html} | 0 ...riable_spacing.html => event_variable_spacing_listener.html} | 0 .../template/event/{universal.html => universal_listener.html} | 0 .../silver/template/event/{simple.html => simple_listener.html} | 0 11 files changed, 1 insertion(+), 1 deletion(-) rename tests/template/datasets/event_inheritance/ext/kappa/styles/all/template/event/{test.html => test_listener.html} (100%) rename tests/template/datasets/event_inheritance/ext/kappa/styles/silver/template/event/{test.html => test_listener.html} (100%) rename tests/template/datasets/event_inheritance/ext/kappa/styles/silver_inherit/template/event/{test.html => test_listener.html} (100%) rename tests/template/datasets/event_inheritance/ext/omega/styles/all/template/event/{test.html => test_listener.html} (100%) rename tests/template/datasets/event_inheritance/ext/omega/styles/silver/template/event/{test.html => test_listener.html} (100%) rename tests/template/datasets/event_inheritance/ext/omega/styles/silver/template/event/{two.html => two_listener.html} (100%) rename tests/template/datasets/event_inheritance/ext/zeta/styles/all/template/event/{test.html => test_listener.html} (100%) rename tests/template/datasets/ext_trivial/ext/trivial/styles/all/template/event/{event_variable_spacing.html => event_variable_spacing_listener.html} (100%) rename tests/template/datasets/ext_trivial/ext/trivial/styles/all/template/event/{universal.html => universal_listener.html} (100%) rename tests/template/datasets/ext_trivial/ext/trivial/styles/silver/template/event/{simple.html => simple_listener.html} (100%) diff --git a/phpBB/phpbb/template/twig/node/event.php b/phpBB/phpbb/template/twig/node/event.php index c94e5fdf20..4533151d05 100644 --- a/phpBB/phpbb/template/twig/node/event.php +++ b/phpBB/phpbb/template/twig/node/event.php @@ -43,7 +43,7 @@ class phpbb_template_twig_node_event extends Twig_Node { $compiler->addDebugInfo($this); - $location = $this->listener_directory . $this->getNode('expr')->getAttribute('name'); + $location = $this->listener_directory . $this->getNode('expr')->getAttribute('name') . '_listener'; foreach ($this->environment->get_phpbb_extensions() as $ext_namespace => $ext_path) { diff --git a/tests/template/datasets/event_inheritance/ext/kappa/styles/all/template/event/test.html b/tests/template/datasets/event_inheritance/ext/kappa/styles/all/template/event/test_listener.html similarity index 100% rename from tests/template/datasets/event_inheritance/ext/kappa/styles/all/template/event/test.html rename to tests/template/datasets/event_inheritance/ext/kappa/styles/all/template/event/test_listener.html diff --git a/tests/template/datasets/event_inheritance/ext/kappa/styles/silver/template/event/test.html b/tests/template/datasets/event_inheritance/ext/kappa/styles/silver/template/event/test_listener.html similarity index 100% rename from tests/template/datasets/event_inheritance/ext/kappa/styles/silver/template/event/test.html rename to tests/template/datasets/event_inheritance/ext/kappa/styles/silver/template/event/test_listener.html diff --git a/tests/template/datasets/event_inheritance/ext/kappa/styles/silver_inherit/template/event/test.html b/tests/template/datasets/event_inheritance/ext/kappa/styles/silver_inherit/template/event/test_listener.html similarity index 100% rename from tests/template/datasets/event_inheritance/ext/kappa/styles/silver_inherit/template/event/test.html rename to tests/template/datasets/event_inheritance/ext/kappa/styles/silver_inherit/template/event/test_listener.html diff --git a/tests/template/datasets/event_inheritance/ext/omega/styles/all/template/event/test.html b/tests/template/datasets/event_inheritance/ext/omega/styles/all/template/event/test_listener.html similarity index 100% rename from tests/template/datasets/event_inheritance/ext/omega/styles/all/template/event/test.html rename to tests/template/datasets/event_inheritance/ext/omega/styles/all/template/event/test_listener.html diff --git a/tests/template/datasets/event_inheritance/ext/omega/styles/silver/template/event/test.html b/tests/template/datasets/event_inheritance/ext/omega/styles/silver/template/event/test_listener.html similarity index 100% rename from tests/template/datasets/event_inheritance/ext/omega/styles/silver/template/event/test.html rename to tests/template/datasets/event_inheritance/ext/omega/styles/silver/template/event/test_listener.html diff --git a/tests/template/datasets/event_inheritance/ext/omega/styles/silver/template/event/two.html b/tests/template/datasets/event_inheritance/ext/omega/styles/silver/template/event/two_listener.html similarity index 100% rename from tests/template/datasets/event_inheritance/ext/omega/styles/silver/template/event/two.html rename to tests/template/datasets/event_inheritance/ext/omega/styles/silver/template/event/two_listener.html diff --git a/tests/template/datasets/event_inheritance/ext/zeta/styles/all/template/event/test.html b/tests/template/datasets/event_inheritance/ext/zeta/styles/all/template/event/test_listener.html similarity index 100% rename from tests/template/datasets/event_inheritance/ext/zeta/styles/all/template/event/test.html rename to tests/template/datasets/event_inheritance/ext/zeta/styles/all/template/event/test_listener.html diff --git a/tests/template/datasets/ext_trivial/ext/trivial/styles/all/template/event/event_variable_spacing.html b/tests/template/datasets/ext_trivial/ext/trivial/styles/all/template/event/event_variable_spacing_listener.html similarity index 100% rename from tests/template/datasets/ext_trivial/ext/trivial/styles/all/template/event/event_variable_spacing.html rename to tests/template/datasets/ext_trivial/ext/trivial/styles/all/template/event/event_variable_spacing_listener.html diff --git a/tests/template/datasets/ext_trivial/ext/trivial/styles/all/template/event/universal.html b/tests/template/datasets/ext_trivial/ext/trivial/styles/all/template/event/universal_listener.html similarity index 100% rename from tests/template/datasets/ext_trivial/ext/trivial/styles/all/template/event/universal.html rename to tests/template/datasets/ext_trivial/ext/trivial/styles/all/template/event/universal_listener.html diff --git a/tests/template/datasets/ext_trivial/ext/trivial/styles/silver/template/event/simple.html b/tests/template/datasets/ext_trivial/ext/trivial/styles/silver/template/event/simple_listener.html similarity index 100% rename from tests/template/datasets/ext_trivial/ext/trivial/styles/silver/template/event/simple.html rename to tests/template/datasets/ext_trivial/ext/trivial/styles/silver/template/event/simple_listener.html From 4b1c5879eb64006c57d94bf534d4a382d9ba5c41 Mon Sep 17 00:00:00 2001 From: rechosen Date: Mon, 12 Aug 2013 10:21:40 +0200 Subject: [PATCH 2446/2494] [ticket/11777] Fix new test for loop variables in extension template listeners With the merge of https://github.com/phpbb/phpbb3/pull/1564 a new test has been added. Renamed and moved the template listener file of that test to comply with the new requirements. PHPBB3-11777 --- .../{test_event_loop.html => event/test_event_loop_listener.html} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename tests/template/datasets/ext_trivial/ext/trivial/styles/all/template/{test_event_loop.html => event/test_event_loop_listener.html} (100%) diff --git a/tests/template/datasets/ext_trivial/ext/trivial/styles/all/template/test_event_loop.html b/tests/template/datasets/ext_trivial/ext/trivial/styles/all/template/event/test_event_loop_listener.html similarity index 100% rename from tests/template/datasets/ext_trivial/ext/trivial/styles/all/template/test_event_loop.html rename to tests/template/datasets/ext_trivial/ext/trivial/styles/all/template/event/test_event_loop_listener.html From 63535b196dd5d4dcdc9a8fb6af03663638f8d8ce Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 12 Aug 2013 15:31:19 +0200 Subject: [PATCH 2447/2494] [ticket/11775] Split test into multiple steps PHPBB3-11775 --- tests/functional/mcp_test.php | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/tests/functional/mcp_test.php b/tests/functional/mcp_test.php index f7e15de853..f65a7d0784 100644 --- a/tests/functional/mcp_test.php +++ b/tests/functional/mcp_test.php @@ -22,12 +22,27 @@ class phpbb_functional_mcp_test extends phpbb_functional_test_case $crawler = self::request('GET', "viewtopic.php?t={$post['topic_id']}&sid={$this->sid}"); $this->assertContains('Testing move post with "Move posts" option from Quick-Moderator Tools.', $crawler->filter('html')->text()); + return $crawler; + } + + /** + * @depends test_post_new_topic + */ + public function test_handle_quickmod($crawler) + { // Test moving a post - $this->add_lang('mcp'); $form = $crawler->selectButton('Go')->eq(1)->form(); $form['action']->select('merge'); $crawler = self::submit($form); + return $crawler; + } + + /** + * @depends test_handle_quickmod + */ + public function test_move_post_to_topic($crawler) + { // Select the post in MCP $form = $crawler->selectButton($this->lang('SUBMIT'))->form(array( 'to_topic_id' => 1, @@ -36,6 +51,15 @@ class phpbb_functional_mcp_test extends phpbb_functional_test_case $crawler = self::submit($form); $this->assertContains($this->lang('MERGE_POSTS'), $crawler->filter('html')->text()); + return $crawler; + } + + /** + * @depends test_move_post_to_topic + */ + public function test_confirm_result($crawler) + { + $this->add_lang('mcp'); $form = $crawler->selectButton('Yes')->form(); $crawler = self::submit($form); $this->assertContains($this->lang('POSTS_MERGED_SUCCESS'), $crawler->text()); From 65d8cd63022d688fe618f128768b78a6214db166 Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Tue, 13 Aug 2013 02:14:22 -0700 Subject: [PATCH 2448/2494] [ticket/11784] Remove naming redundancy for event listeners PHPBB3-11784 --- phpBB/phpbb/event/extension_subscriber_loader.php | 1 - phpBB/phpbb/template/twig/node/event.php | 2 +- .../foo/bar/event/{permission_listener.php => permission.php} | 2 +- .../styles/all/template/event/{test_listener.html => test.html} | 0 .../silver/template/event/{test_listener.html => test.html} | 0 .../template/event/{test_listener.html => test.html} | 0 .../styles/all/template/event/{test_listener.html => test.html} | 0 .../silver/template/event/{test_listener.html => test.html} | 0 .../silver/template/event/{two_listener.html => two.html} | 0 .../styles/all/template/event/{test_listener.html => test.html} | 0 ...riable_spacing_listener.html => event_variable_spacing.html} | 0 .../{test_event_loop_listener.html => test_event_loop.html} | 0 .../template/event/{universal_listener.html => universal.html} | 0 .../silver/template/event/{simple_listener.html => simple.html} | 0 14 files changed, 2 insertions(+), 3 deletions(-) rename tests/functional/fixtures/ext/foo/bar/event/{permission_listener.php => permission.php} (87%) rename tests/template/datasets/event_inheritance/ext/kappa/styles/all/template/event/{test_listener.html => test.html} (100%) rename tests/template/datasets/event_inheritance/ext/kappa/styles/silver/template/event/{test_listener.html => test.html} (100%) rename tests/template/datasets/event_inheritance/ext/kappa/styles/silver_inherit/template/event/{test_listener.html => test.html} (100%) rename tests/template/datasets/event_inheritance/ext/omega/styles/all/template/event/{test_listener.html => test.html} (100%) rename tests/template/datasets/event_inheritance/ext/omega/styles/silver/template/event/{test_listener.html => test.html} (100%) rename tests/template/datasets/event_inheritance/ext/omega/styles/silver/template/event/{two_listener.html => two.html} (100%) rename tests/template/datasets/event_inheritance/ext/zeta/styles/all/template/event/{test_listener.html => test.html} (100%) rename tests/template/datasets/ext_trivial/ext/trivial/styles/all/template/event/{event_variable_spacing_listener.html => event_variable_spacing.html} (100%) rename tests/template/datasets/ext_trivial/ext/trivial/styles/all/template/event/{test_event_loop_listener.html => test_event_loop.html} (100%) rename tests/template/datasets/ext_trivial/ext/trivial/styles/all/template/event/{universal_listener.html => universal.html} (100%) rename tests/template/datasets/ext_trivial/ext/trivial/styles/silver/template/event/{simple_listener.html => simple.html} (100%) diff --git a/phpBB/phpbb/event/extension_subscriber_loader.php b/phpBB/phpbb/event/extension_subscriber_loader.php index d933b943d7..d6284a52fb 100644 --- a/phpBB/phpbb/event/extension_subscriber_loader.php +++ b/phpBB/phpbb/event/extension_subscriber_loader.php @@ -33,7 +33,6 @@ class phpbb_event_extension_subscriber_loader $finder = $this->extension_manager->get_finder(); $subscriber_classes = $finder ->extension_directory('/event') - ->suffix('listener') ->core_path('event/') ->get_classes(); diff --git a/phpBB/phpbb/template/twig/node/event.php b/phpBB/phpbb/template/twig/node/event.php index 4533151d05..c94e5fdf20 100644 --- a/phpBB/phpbb/template/twig/node/event.php +++ b/phpBB/phpbb/template/twig/node/event.php @@ -43,7 +43,7 @@ class phpbb_template_twig_node_event extends Twig_Node { $compiler->addDebugInfo($this); - $location = $this->listener_directory . $this->getNode('expr')->getAttribute('name') . '_listener'; + $location = $this->listener_directory . $this->getNode('expr')->getAttribute('name'); foreach ($this->environment->get_phpbb_extensions() as $ext_namespace => $ext_path) { diff --git a/tests/functional/fixtures/ext/foo/bar/event/permission_listener.php b/tests/functional/fixtures/ext/foo/bar/event/permission.php similarity index 87% rename from tests/functional/fixtures/ext/foo/bar/event/permission_listener.php rename to tests/functional/fixtures/ext/foo/bar/event/permission.php index 6986755f71..48688a586a 100644 --- a/tests/functional/fixtures/ext/foo/bar/event/permission_listener.php +++ b/tests/functional/fixtures/ext/foo/bar/event/permission.php @@ -22,7 +22,7 @@ if (!defined('IN_PHPBB')) */ use Symfony\Component\EventDispatcher\EventSubscriberInterface; -class phpbb_ext_foo_bar_event_permission_listener implements EventSubscriberInterface +class phpbb_ext_foo_bar_event_permission implements EventSubscriberInterface { static public function getSubscribedEvents() { diff --git a/tests/template/datasets/event_inheritance/ext/kappa/styles/all/template/event/test_listener.html b/tests/template/datasets/event_inheritance/ext/kappa/styles/all/template/event/test.html similarity index 100% rename from tests/template/datasets/event_inheritance/ext/kappa/styles/all/template/event/test_listener.html rename to tests/template/datasets/event_inheritance/ext/kappa/styles/all/template/event/test.html diff --git a/tests/template/datasets/event_inheritance/ext/kappa/styles/silver/template/event/test_listener.html b/tests/template/datasets/event_inheritance/ext/kappa/styles/silver/template/event/test.html similarity index 100% rename from tests/template/datasets/event_inheritance/ext/kappa/styles/silver/template/event/test_listener.html rename to tests/template/datasets/event_inheritance/ext/kappa/styles/silver/template/event/test.html diff --git a/tests/template/datasets/event_inheritance/ext/kappa/styles/silver_inherit/template/event/test_listener.html b/tests/template/datasets/event_inheritance/ext/kappa/styles/silver_inherit/template/event/test.html similarity index 100% rename from tests/template/datasets/event_inheritance/ext/kappa/styles/silver_inherit/template/event/test_listener.html rename to tests/template/datasets/event_inheritance/ext/kappa/styles/silver_inherit/template/event/test.html diff --git a/tests/template/datasets/event_inheritance/ext/omega/styles/all/template/event/test_listener.html b/tests/template/datasets/event_inheritance/ext/omega/styles/all/template/event/test.html similarity index 100% rename from tests/template/datasets/event_inheritance/ext/omega/styles/all/template/event/test_listener.html rename to tests/template/datasets/event_inheritance/ext/omega/styles/all/template/event/test.html diff --git a/tests/template/datasets/event_inheritance/ext/omega/styles/silver/template/event/test_listener.html b/tests/template/datasets/event_inheritance/ext/omega/styles/silver/template/event/test.html similarity index 100% rename from tests/template/datasets/event_inheritance/ext/omega/styles/silver/template/event/test_listener.html rename to tests/template/datasets/event_inheritance/ext/omega/styles/silver/template/event/test.html diff --git a/tests/template/datasets/event_inheritance/ext/omega/styles/silver/template/event/two_listener.html b/tests/template/datasets/event_inheritance/ext/omega/styles/silver/template/event/two.html similarity index 100% rename from tests/template/datasets/event_inheritance/ext/omega/styles/silver/template/event/two_listener.html rename to tests/template/datasets/event_inheritance/ext/omega/styles/silver/template/event/two.html diff --git a/tests/template/datasets/event_inheritance/ext/zeta/styles/all/template/event/test_listener.html b/tests/template/datasets/event_inheritance/ext/zeta/styles/all/template/event/test.html similarity index 100% rename from tests/template/datasets/event_inheritance/ext/zeta/styles/all/template/event/test_listener.html rename to tests/template/datasets/event_inheritance/ext/zeta/styles/all/template/event/test.html diff --git a/tests/template/datasets/ext_trivial/ext/trivial/styles/all/template/event/event_variable_spacing_listener.html b/tests/template/datasets/ext_trivial/ext/trivial/styles/all/template/event/event_variable_spacing.html similarity index 100% rename from tests/template/datasets/ext_trivial/ext/trivial/styles/all/template/event/event_variable_spacing_listener.html rename to tests/template/datasets/ext_trivial/ext/trivial/styles/all/template/event/event_variable_spacing.html diff --git a/tests/template/datasets/ext_trivial/ext/trivial/styles/all/template/event/test_event_loop_listener.html b/tests/template/datasets/ext_trivial/ext/trivial/styles/all/template/event/test_event_loop.html similarity index 100% rename from tests/template/datasets/ext_trivial/ext/trivial/styles/all/template/event/test_event_loop_listener.html rename to tests/template/datasets/ext_trivial/ext/trivial/styles/all/template/event/test_event_loop.html diff --git a/tests/template/datasets/ext_trivial/ext/trivial/styles/all/template/event/universal_listener.html b/tests/template/datasets/ext_trivial/ext/trivial/styles/all/template/event/universal.html similarity index 100% rename from tests/template/datasets/ext_trivial/ext/trivial/styles/all/template/event/universal_listener.html rename to tests/template/datasets/ext_trivial/ext/trivial/styles/all/template/event/universal.html diff --git a/tests/template/datasets/ext_trivial/ext/trivial/styles/silver/template/event/simple_listener.html b/tests/template/datasets/ext_trivial/ext/trivial/styles/silver/template/event/simple.html similarity index 100% rename from tests/template/datasets/ext_trivial/ext/trivial/styles/silver/template/event/simple_listener.html rename to tests/template/datasets/ext_trivial/ext/trivial/styles/silver/template/event/simple.html From 9c299b0e8367ec8f9bb631e637b2492483ab3b8a Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Wed, 14 Aug 2013 19:09:27 +0300 Subject: [PATCH 2449/2494] [ticket/11789] Remove colors from HTML code PHPBB3-11789 --- phpBB/styles/subsilver2/template/overall_header.html | 2 +- phpBB/styles/subsilver2/template/ucp_header.html | 4 ++-- phpBB/styles/subsilver2/template/ucp_pm_history.html | 2 +- phpBB/styles/subsilver2/theme/stylesheet.css | 10 +++++++++- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/phpBB/styles/subsilver2/template/overall_header.html b/phpBB/styles/subsilver2/template/overall_header.html index 62ed79ed39..7eb736aa32 100644 --- a/phpBB/styles/subsilver2/template/overall_header.html +++ b/phpBB/styles/subsilver2/template/overall_header.html @@ -160,7 +160,7 @@ function marklist(id, name, state)
    - - - - - + - -
    - {L_SIGNATURE_EXPLAIN} - - + + -
    + {L_SIGNATURE_EXPLAIN} + @@ -47,11 +44,13 @@ -
    {L_SMILIES}
    {L_MORE_SMILIES}
    - -
    - +
    +
    + + + + @@ -75,11 +74,6 @@
    - -
    -
    + From a10ab3e7d94061d264ee285359565f651e7b9671 Mon Sep 17 00:00:00 2001 From: rechosen Date: Sun, 14 Jul 2013 21:50:22 +0200 Subject: [PATCH 2410/2494] [ticket/9550] Add template event memberlist_view_user_statistics_after Adds the append counterpart of a template event required for the karma extension. It allows adding entries to the user statistics part of any user profile. Explanation from http://area51.phpbb.com/phpBB/viewtopic.php?f=111&t=44379: Per suggestion of nickvergessen, add a counterpart for every append or prepend event. PHPBB3-9550 --- phpBB/styles/prosilver/template/memberlist_view.html | 1 + phpBB/styles/subsilver2/template/memberlist_view.html | 1 + 2 files changed, 2 insertions(+) diff --git a/phpBB/styles/prosilver/template/memberlist_view.html b/phpBB/styles/prosilver/template/memberlist_view.html index b339e07d37..0d103b5914 100644 --- a/phpBB/styles/prosilver/template/memberlist_view.html +++ b/phpBB/styles/prosilver/template/memberlist_view.html @@ -93,6 +93,7 @@
    {L_ACTIVE_IN_FORUM}{L_COLON}
    {ACTIVE_FORUM}
    ({ACTIVE_FORUM_POSTS} / {ACTIVE_FORUM_PCT}) -
    {L_ACTIVE_IN_TOPIC}{L_COLON}
    {ACTIVE_TOPIC}
    ({ACTIVE_TOPIC_POSTS} / {ACTIVE_TOPIC_PCT}) -
    + diff --git a/phpBB/styles/subsilver2/template/memberlist_view.html b/phpBB/styles/subsilver2/template/memberlist_view.html index e097e09565..3ffdb1ce70 100644 --- a/phpBB/styles/subsilver2/template/memberlist_view.html +++ b/phpBB/styles/subsilver2/template/memberlist_view.html @@ -97,6 +97,7 @@
    +
    {L_JOINED}{L_COLON} {JOINED}{ACTIVE_TOPIC}
    [ {ACTIVE_TOPIC_POSTS} / {ACTIVE_TOPIC_PCT} ]-
    {L_BACK_TO_TOP}
    {L_BACK_TO_TOP}
    {memberrow.RANK_IMG}{memberrow.RANK_TITLE} {memberrow.USERNAME_FULL}
    {L_SELECT} ]
    {memberrow.RANK_IMG}{memberrow.RANK_TITLE} {memberrow.USERNAME_FULL}
    {L_SELECT} ]
    {memberrow.POSTS}{memberrow.POSTS}
    {memberrow.LOCATION}
     
    {memberrow.JOINED}
     {memberrow.ROW_NUMBER} {memberrow.USERNAME_FULL}{L_SELECT} ]{memberrow.USERNAME_FULL}{L_SELECT} ]  {memberrow.JOINED}  {memberrow.POSTS} {memberrow.RANK_IMG}{memberrow.RANK_TITLE}
    {memberrow.RANK_IMG}{memberrow.RANK_TITLE} {memberrow.USERNAME_FULL}
    {L_SELECT} ]
    {memberrow.RANK_IMG}{memberrow.RANK_TITLE} {memberrow.USERNAME_FULL}
    {L_SELECT} ]
    {memberrow.POSTS}{memberrow.POSTS}
    {memberrow.LOCATION}
     
    {memberrow.JOINED}
     {memberrow.ROW_NUMBER} {memberrow.USERNAME_FULL}{L_SELECT} ]{memberrow.USERNAME_FULL}{L_SELECT} ]  {memberrow.JOINED}  {memberrow.POSTS} {memberrow.RANK_IMG}{memberrow.RANK_TITLE}
    {L_BACK_TO_TOP} + +
    + + + {EDIT_IMG} + {QUOTE_IMG} + + +  
    +
    * {L_LOGIN_LOGOUT}   * {L_RESTORE_PERMISSIONS} -  {L_BOARD_DISABLED} +  {L_BOARD_DISABLED}  * {PRIVATE_MESSAGE_INFO}, {PRIVATE_MESSAGE_INFO_UNREAD} diff --git a/phpBB/styles/subsilver2/template/ucp_header.html b/phpBB/styles/subsilver2/template/ucp_header.html index 1566a15929..4ad27738fa 100644 --- a/phpBB/styles/subsilver2/template/ucp_header.html +++ b/phpBB/styles/subsilver2/template/ucp_header.html @@ -123,7 +123,7 @@
    - {L_FRIENDS_ONLINE} + {L_FRIENDS_ONLINE}
    - style="background-color:lightblue"> + class="current">
    {L_PM_SUBJECT}: {history_row.SUBJECT}
    {L_FOLDER}: {history_row.FOLDER}
    diff --git a/phpBB/styles/subsilver2/theme/stylesheet.css b/phpBB/styles/subsilver2/theme/stylesheet.css index 177a988e93..29db8f2d47 100644 --- a/phpBB/styles/subsilver2/theme/stylesheet.css +++ b/phpBB/styles/subsilver2/theme/stylesheet.css @@ -292,7 +292,11 @@ p.topicdetails { text-decoration: none; } -.error { +.online { + color: green; +} + +.offline, .error { color: red; } @@ -360,6 +364,10 @@ td.profile { background-color: #D1D7DC; } +.current { + background-color: lightblue; +} + hr { height: 1px; border-width: 0; From 4b0adfcff54f9ebd3261e4673f689eb2c4c066df Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 15 Aug 2013 01:35:02 +0200 Subject: [PATCH 2450/2494] [ticket/11775] Remove spaces at line ends PHPBB3-11775 --- tests/test_framework/phpbb_functional_test_case.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index 15f7814800..72990d3a21 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -596,9 +596,9 @@ class phpbb_functional_test_case extends phpbb_test_case /** * Creates a topic - * + * * Be sure to login before creating - * + * * @param int $forum_id * @param string $subject * @param string $message @@ -620,9 +620,9 @@ class phpbb_functional_test_case extends phpbb_test_case /** * Creates a post - * + * * Be sure to login before creating - * + * * @param int $forum_id * @param int $topic_id * @param string $subject From c30d4025d2976db3f55a8d477e27ca5598f83f69 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 15 Aug 2013 01:36:38 +0200 Subject: [PATCH 2451/2494] [ticket/11775] Fix doc blocks syntax PHPBB3-11775 --- tests/test_framework/phpbb_functional_test_case.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index 72990d3a21..7d8b4a3144 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -689,7 +689,7 @@ class phpbb_functional_test_case extends phpbb_test_case ); } - /* + /** * Returns the requested parameter from a URL * * @param string $url From 48f6f4559c9d3df49b56f0831a89b516f0f2f34f Mon Sep 17 00:00:00 2001 From: rechosen Date: Fri, 16 Aug 2013 17:48:36 +0200 Subject: [PATCH 2452/2494] [ticket/11794] Add missing array element commas to docs/coding-guidelines.html Even though the coding guidelines document prescribes "commas after every array element", it contains several example code fragments with array elements not terminated by a comma. This commit fixes that. PHPBB3-11794 --- phpBB/docs/coding-guidelines.html | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/phpBB/docs/coding-guidelines.html b/phpBB/docs/coding-guidelines.html index a541fe8866..f3d161589b 100644 --- a/phpBB/docs/coding-guidelines.html +++ b/phpBB/docs/coding-guidelines.html @@ -728,7 +728,7 @@ $sql = 'SELECT * $sql_ary = array( 'somedata' => $my_string, 'otherdata' => $an_int, - 'moredata' => $another_int + 'moredata' => $another_int, ); $db->sql_query('INSERT INTO ' . SOME_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary)); @@ -740,7 +740,7 @@ $db->sql_query('INSERT INTO ' . SOME_TABLE . ' ' . $db->sql_build_array('I $sql_ary = array( 'somedata' => $my_string, 'otherdata' => $an_int, - 'moredata' => $another_int + 'moredata' => $another_int, ); $sql = 'UPDATE ' . SOME_TABLE . ' @@ -833,20 +833,20 @@ $sql_array = array( 'FROM' => array( FORUMS_WATCH_TABLE => 'fw', - FORUMS_TABLE => 'f' + FORUMS_TABLE => 'f', ), 'LEFT_JOIN' => array( array( 'FROM' => array(FORUMS_TRACK_TABLE => 'ft'), - 'ON' => 'ft.user_id = ' . $user->data['user_id'] . ' AND ft.forum_id = f.forum_id' - ) + 'ON' => 'ft.user_id = ' . $user->data['user_id'] . ' AND ft.forum_id = f.forum_id', + ), ), 'WHERE' => 'fw.user_id = ' . $user->data['user_id'] . ' AND f.forum_id = fw.forum_id', - 'ORDER_BY' => 'left_id' + 'ORDER_BY' => 'left_id', ); $sql = $db->sql_build_query('SELECT', $sql_array); @@ -860,13 +860,13 @@ $sql_array = array( 'FROM' => array( FORUMS_WATCH_TABLE => 'fw', - FORUMS_TABLE => 'f' + FORUMS_TABLE => 'f', ), 'WHERE' => 'fw.user_id = ' . $user->data['user_id'] . ' AND f.forum_id = fw.forum_id', - 'ORDER_BY' => 'left_id' + 'ORDER_BY' => 'left_id', ); if ($config['load_db_lastread']) @@ -874,8 +874,8 @@ if ($config['load_db_lastread']) $sql_array['LEFT_JOIN'] = array( array( 'FROM' => array(FORUMS_TRACK_TABLE => 'ft'), - 'ON' => 'ft.user_id = ' . $user->data['user_id'] . ' AND ft.forum_id = f.forum_id' - ) + 'ON' => 'ft.user_id = ' . $user->data['user_id'] . ' AND ft.forum_id = f.forum_id', + ), ); $sql_array['SELECT'] .= ', ft.mark_time '; From 87dd739a84375958af618605e580127f3d0e1784 Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Fri, 16 Aug 2013 18:51:31 +0300 Subject: [PATCH 2453/2494] [ticket/11796] Replace pagination with pagination.html PHPBB3-11796 --- phpBB/styles/prosilver/template/mcp_forum.html | 15 +-------------- .../styles/prosilver/template/mcp_warn_list.html | 15 +-------------- .../styles/prosilver/template/search_results.html | 15 +-------------- .../styles/prosilver/template/viewtopic_body.html | 12 +----------- 4 files changed, 4 insertions(+), 53 deletions(-) diff --git a/phpBB/styles/prosilver/template/mcp_forum.html b/phpBB/styles/prosilver/template/mcp_forum.html index 45e6c10d46..e5dcb94855 100644 --- a/phpBB/styles/prosilver/template/mcp_forum.html +++ b/phpBB/styles/prosilver/template/mcp_forum.html @@ -100,20 +100,7 @@