[ Index ] |
PHP Cross Reference of phpBB-3.3.14-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\v320; 15 16 class remove_outdated_media extends \phpbb\db\migration\migration 17 { 18 // Following constants were deprecated in 3.2 19 // and moved from constants.php to compatibility_globals.php, 20 // thus define them as class constants 21 const ATTACHMENT_CATEGORY_WM = 2; 22 const ATTACHMENT_CATEGORY_RM = 3; 23 const ATTACHMENT_CATEGORY_QUICKTIME = 6; 24 25 protected $cat_id = array( 26 self::ATTACHMENT_CATEGORY_WM, 27 self::ATTACHMENT_CATEGORY_RM, 28 self::ATTACHMENT_CATEGORY_QUICKTIME, 29 ); 30 31 static public function depends_on() 32 { 33 return array( 34 '\phpbb\db\migration\data\v320\dev', 35 ); 36 } 37 38 public function update_data() 39 { 40 return array( 41 array('custom', array(array($this, 'change_extension_group'))), 42 ); 43 } 44 45 public function change_extension_group() 46 { 47 // select group ids of outdated media 48 $sql = 'SELECT group_id 49 FROM ' . EXTENSION_GROUPS_TABLE . ' 50 WHERE ' . $this->db->sql_in_set('cat_id', $this->cat_id); 51 $result = $this->db->sql_query($sql); 52 53 $group_ids = array(); 54 while ($group_id = (int) $this->db->sql_fetchfield('group_id')) 55 { 56 $group_ids[] = $group_id; 57 } 58 $this->db->sql_freeresult($result); 59 60 // nothing to do, admin has removed all the outdated media extension groups 61 if (empty($group_ids)) 62 { 63 return true; 64 } 65 66 // get the group id of downloadable files 67 $sql = 'SELECT group_id 68 FROM ' . EXTENSION_GROUPS_TABLE . " 69 WHERE group_name = 'DOWNLOADABLE_FILES'"; 70 $result = $this->db->sql_query($sql); 71 $download_id = (int) $this->db->sql_fetchfield('group_id'); 72 $this->db->sql_freeresult($result); 73 74 if (empty($download_id)) 75 { 76 $sql = 'UPDATE ' . EXTENSIONS_TABLE . ' 77 SET group_id = 0 78 WHERE ' . $this->db->sql_in_set('group_id', $group_ids); 79 } 80 else 81 { 82 // move outdated media extensions to downloadable files 83 $sql = 'UPDATE ' . EXTENSIONS_TABLE . " 84 SET group_id = $download_id" . ' 85 WHERE ' . $this->db->sql_in_set('group_id', $group_ids); 86 } 87 88 $this->db->sql_query($sql); 89 90 // delete the now empty, outdated media extension groups 91 $sql = 'DELETE FROM ' . EXTENSION_GROUPS_TABLE . ' 92 WHERE ' . $this->db->sql_in_set('group_id', $group_ids); 93 $this->db->sql_query($sql); 94 } 95 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Mon Nov 25 19:05:08 2024 | Cross-referenced by PHPXref 0.7.1 |