[ Index ] |
PHP Cross Reference of phpBB-3.1.12-deutsch |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * 4 * This file is part of the phpBB Forum Software package. 5 * 6 * @copyright (c) phpBB Limited <https://www.phpbb.com> 7 * @license GNU General Public License, version 2 (GPL-2.0) 8 * 9 * For full copyright and license information, please see 10 * the docs/CREDITS.txt file. 11 * 12 */ 13 14 namespace phpbb\db\migration\data\v30x; 15 16 class release_3_0_6_rc1 extends \phpbb\db\migration\migration 17 { 18 public function effectively_installed() 19 { 20 return phpbb_version_compare($this->config['version'], '3.0.6-RC1', '>='); 21 } 22 23 static public function depends_on() 24 { 25 return array('\phpbb\db\migration\data\v30x\release_3_0_5'); 26 } 27 28 public function update_schema() 29 { 30 return array( 31 'add_columns' => array( 32 $this->table_prefix . 'confirm' => array( 33 'attempts' => array('UINT', 0), 34 ), 35 $this->table_prefix . 'users' => array( 36 'user_new' => array('BOOL', 1), 37 'user_reminded' => array('TINT:4', 0), 38 'user_reminded_time' => array('TIMESTAMP', 0), 39 ), 40 $this->table_prefix . 'groups' => array( 41 'group_skip_auth' => array('BOOL', 0, 'after' => 'group_founder_manage'), 42 ), 43 $this->table_prefix . 'privmsgs' => array( 44 'message_reported' => array('BOOL', 0), 45 ), 46 $this->table_prefix . 'reports' => array( 47 'pm_id' => array('UINT', 0), 48 ), 49 $this->table_prefix . 'profile_fields' => array( 50 'field_show_on_vt' => array('BOOL', 0), 51 ), 52 $this->table_prefix . 'forums' => array( 53 'forum_options' => array('UINT:20', 0), 54 ), 55 ), 56 'change_columns' => array( 57 $this->table_prefix . 'users' => array( 58 'user_options' => array('UINT:11', 230271), 59 ), 60 ), 61 'add_index' => array( 62 $this->table_prefix . 'reports' => array( 63 'post_id' => array('post_id'), 64 'pm_id' => array('pm_id'), 65 ), 66 $this->table_prefix . 'posts' => array( 67 'post_username' => array('post_username:255'), 68 ), 69 ), 70 ); 71 } 72 73 public function revert_schema() 74 { 75 return array( 76 'drop_columns' => array( 77 $this->table_prefix . 'confirm' => array( 78 'attempts', 79 ), 80 $this->table_prefix . 'users' => array( 81 'user_new', 82 'user_reminded', 83 'user_reminded_time', 84 ), 85 $this->table_prefix . 'groups' => array( 86 'group_skip_auth', 87 ), 88 $this->table_prefix . 'privmsgs' => array( 89 'message_reported', 90 ), 91 $this->table_prefix . 'reports' => array( 92 'pm_id', 93 ), 94 $this->table_prefix . 'profile_fields' => array( 95 'field_show_on_vt', 96 ), 97 $this->table_prefix . 'forums' => array( 98 'forum_options', 99 ), 100 ), 101 'drop_keys' => array( 102 $this->table_prefix . 'reports' => array( 103 'post_id', 104 'pm_id', 105 ), 106 $this->table_prefix . 'posts' => array( 107 'post_username', 108 ), 109 ), 110 ); 111 } 112 113 public function update_data() 114 { 115 return array( 116 array('config.add', array('captcha_plugin', 'phpbb_captcha_nogd')), 117 array('if', array( 118 ($this->config['captcha_gd']), 119 array('config.update', array('captcha_plugin', 'phpbb_captcha_gd')), 120 )), 121 122 array('config.add', array('feed_enable', 0)), 123 array('config.add', array('feed_limit', 10)), 124 array('config.add', array('feed_overall_forums', 1)), 125 array('config.add', array('feed_overall_forums_limit', 15)), 126 array('config.add', array('feed_overall_topics', 0)), 127 array('config.add', array('feed_overall_topics_limit', 15)), 128 array('config.add', array('feed_forum', 1)), 129 array('config.add', array('feed_topic', 1)), 130 array('config.add', array('feed_item_statistics', 1)), 131 132 array('config.add', array('smilies_per_page', 50)), 133 array('config.add', array('allow_pm_report', 1)), 134 array('config.add', array('min_post_chars', 1)), 135 array('config.add', array('allow_quick_reply', 1)), 136 array('config.add', array('new_member_post_limit', 0)), 137 array('config.add', array('new_member_group_default', 0)), 138 array('config.add', array('delete_time', $this->config['edit_time'])), 139 140 array('config.add', array('allow_avatar', 0)), 141 array('if', array( 142 ($this->config['allow_avatar_upload'] || $this->config['allow_avatar_local'] || $this->config['allow_avatar_remote']), 143 array('config.update', array('allow_avatar', 1)), 144 )), 145 array('config.add', array('allow_avatar_remote_upload', 0)), 146 array('if', array( 147 ($this->config['allow_avatar_remote'] && $this->config['allow_avatar_upload']), 148 array('config.update', array('allow_avatar_remote_upload', 1)), 149 )), 150 151 array('module.add', array( 152 'acp', 153 'ACP_BOARD_CONFIGURATION', 154 array( 155 'module_basename' => 'acp_board', 156 'modes' => array('feed'), 157 ), 158 )), 159 array('module.add', array( 160 'acp', 161 'ACP_CAT_USERS', 162 array( 163 'module_basename' => 'acp_users', 164 'modes' => array('warnings'), 165 ), 166 )), 167 array('module.add', array( 168 'acp', 169 'ACP_SERVER_CONFIGURATION', 170 array( 171 'module_basename' => 'acp_send_statistics', 172 'modes' => array('send_statistics'), 173 ), 174 )), 175 array('module.add', array( 176 'acp', 177 'ACP_FORUM_BASED_PERMISSIONS', 178 array( 179 'module_basename' => 'acp_permissions', 180 'modes' => array('setting_forum_copy'), 181 ), 182 )), 183 array('module.add', array( 184 'mcp', 185 'MCP_REPORTS', 186 array( 187 'module_basename' => 'mcp_pm_reports', 188 'modes' => array('pm_reports','pm_reports_closed','pm_report_details'), 189 ), 190 )), 191 array('custom', array(array(&$this, 'add_newly_registered_group'))), 192 array('custom', array(array(&$this, 'set_user_options_default'))), 193 194 array('config.update', array('version', '3.0.6-RC1')), 195 ); 196 } 197 198 public function set_user_options_default() 199 { 200 // 229376 is the added value to enable all three signature options 201 $sql = 'UPDATE ' . USERS_TABLE . ' SET user_options = user_options + 229376'; 202 $this->sql_query($sql); 203 } 204 205 public function add_newly_registered_group() 206 { 207 // Add newly_registered group... but check if it already exists (we always supported running the updater on any schema) 208 $sql = 'SELECT group_id 209 FROM ' . GROUPS_TABLE . " 210 WHERE group_name = 'NEWLY_REGISTERED'"; 211 $result = $this->db->sql_query($sql); 212 $group_id = (int) $this->db->sql_fetchfield('group_id'); 213 $this->db->sql_freeresult($result); 214 215 if (!$group_id) 216 { 217 $sql = 'INSERT INTO ' . GROUPS_TABLE . " (group_name, group_type, group_founder_manage, group_colour, group_legend, group_avatar, group_desc, group_desc_uid, group_max_recipients) VALUES ('NEWLY_REGISTERED', 3, 0, '', 0, '', '', '', 5)"; 218 $this->sql_query($sql); 219 220 $group_id = $this->db->sql_nextid(); 221 } 222 223 // Insert new user role... at the end of the chain 224 $sql = 'SELECT role_id 225 FROM ' . ACL_ROLES_TABLE . " 226 WHERE role_name = 'ROLE_USER_NEW_MEMBER' 227 AND role_type = 'u_'"; 228 $result = $this->db->sql_query($sql); 229 $u_role = (int) $this->db->sql_fetchfield('role_id'); 230 $this->db->sql_freeresult($result); 231 232 if (!$u_role) 233 { 234 $sql = 'SELECT MAX(role_order) as max_order_id 235 FROM ' . ACL_ROLES_TABLE . " 236 WHERE role_type = 'u_'"; 237 $result = $this->db->sql_query($sql); 238 $next_order_id = (int) $this->db->sql_fetchfield('max_order_id'); 239 $this->db->sql_freeresult($result); 240 241 $next_order_id++; 242 243 $sql = 'INSERT INTO ' . ACL_ROLES_TABLE . " (role_name, role_description, role_type, role_order) VALUES ('ROLE_USER_NEW_MEMBER', 'ROLE_DESCRIPTION_USER_NEW_MEMBER', 'u_', $next_order_id)"; 244 $this->sql_query($sql); 245 $u_role = $this->db->sql_nextid(); 246 247 // Now add the correct data to the roles... 248 // The standard role says that new users are not able to send a PM, Mass PM, are not able to PM groups 249 $sql = 'INSERT INTO ' . ACL_ROLES_DATA_TABLE . " (role_id, auth_option_id, auth_setting) SELECT $u_role, auth_option_id, 0 FROM " . ACL_OPTIONS_TABLE . " WHERE auth_option LIKE 'u_%' AND auth_option IN ('u_sendpm', 'u_masspm', 'u_masspm_group')"; 250 $this->sql_query($sql); 251 252 // Add user role to group 253 $sql = 'INSERT INTO ' . ACL_GROUPS_TABLE . " (group_id, forum_id, auth_option_id, auth_role_id, auth_setting) VALUES ($group_id, 0, 0, $u_role, 0)"; 254 $this->sql_query($sql); 255 } 256 257 // Insert new forum role 258 $sql = 'SELECT role_id 259 FROM ' . ACL_ROLES_TABLE . " 260 WHERE role_name = 'ROLE_FORUM_NEW_MEMBER' 261 AND role_type = 'f_'"; 262 $result = $this->db->sql_query($sql); 263 $f_role = (int) $this->db->sql_fetchfield('role_id'); 264 $this->db->sql_freeresult($result); 265 266 if (!$f_role) 267 { 268 $sql = 'SELECT MAX(role_order) as max_order_id 269 FROM ' . ACL_ROLES_TABLE . " 270 WHERE role_type = 'f_'"; 271 $result = $this->db->sql_query($sql); 272 $next_order_id = (int) $this->db->sql_fetchfield('max_order_id'); 273 $this->db->sql_freeresult($result); 274 275 $next_order_id++; 276 277 $sql = 'INSERT INTO ' . ACL_ROLES_TABLE . " (role_name, role_description, role_type, role_order) VALUES ('ROLE_FORUM_NEW_MEMBER', 'ROLE_DESCRIPTION_FORUM_NEW_MEMBER', 'f_', $next_order_id)"; 278 $this->sql_query($sql); 279 $f_role = $this->db->sql_nextid(); 280 281 $sql = 'INSERT INTO ' . ACL_ROLES_DATA_TABLE . " (role_id, auth_option_id, auth_setting) SELECT $f_role, auth_option_id, 0 FROM " . ACL_OPTIONS_TABLE . " WHERE auth_option LIKE 'f_%' AND auth_option IN ('f_noapprove')"; 282 $this->sql_query($sql); 283 } 284 285 // Set every members user_new column to 0 (old users) only if there is no one yet (this makes sure we do not execute this more than once) 286 $sql = 'SELECT 1 287 FROM ' . USERS_TABLE . ' 288 WHERE user_new = 0'; 289 $result = $this->db->sql_query_limit($sql, 1); 290 $row = $this->db->sql_fetchrow($result); 291 $this->db->sql_freeresult($result); 292 293 if (!$row) 294 { 295 $sql = 'UPDATE ' . USERS_TABLE . ' SET user_new = 0'; 296 $this->sql_query($sql); 297 } 298 299 // To mimick the old "feature" we will assign the forum role to every forum, regardless of the setting (this makes sure there are no "this does not work!!!! YUO!!!" posts... 300 // Check if the role is already assigned... 301 $sql = 'SELECT forum_id 302 FROM ' . ACL_GROUPS_TABLE . ' 303 WHERE group_id = ' . $group_id . ' 304 AND auth_role_id = ' . $f_role; 305 $result = $this->db->sql_query($sql); 306 $is_options = (int) $this->db->sql_fetchfield('forum_id'); 307 $this->db->sql_freeresult($result); 308 309 // Not assigned at all... :/ 310 if (!$is_options) 311 { 312 // Get postable forums 313 $sql = 'SELECT forum_id 314 FROM ' . FORUMS_TABLE . ' 315 WHERE forum_type != ' . FORUM_LINK; 316 $result = $this->db->sql_query($sql); 317 318 while ($row = $this->db->sql_fetchrow($result)) 319 { 320 $this->sql_query('INSERT INTO ' . ACL_GROUPS_TABLE . ' (group_id, forum_id, auth_option_id, auth_role_id, auth_setting) VALUES (' . $group_id . ', ' . (int) $row['forum_id'] . ', 0, ' . $f_role . ', 0)'); 321 } 322 $this->db->sql_freeresult($result); 323 } 324 325 // Clear permissions... 326 include_once($this->phpbb_root_path . 'includes/acp/auth.' . $this->php_ext); 327 $auth_admin = new \auth_admin(); 328 $auth_admin->acl_clear_prefetch(); 329 } 330 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Jan 11 00:25:41 2018 | Cross-referenced by PHPXref 0.7.1 |