[ 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\v310; 15 16 class notifications_use_full_name extends \phpbb\db\migration\migration 17 { 18 protected $notification_types = array( 19 'admin_activate_user', 20 'approve_post', 21 'approve_topic', 22 'bookmark', 23 'disapprove_post', 24 'disapprove_topic', 25 'group_request', 26 'group_request_approved', 27 'pm', 28 'post', 29 'post_in_queue', 30 'quote', 31 'report_pm', 32 'report_pm_closed', 33 'report_post', 34 'report_post_closed', 35 'topic', 36 'topic_in_queue'); 37 38 protected $notification_methods = array( 39 'email', 40 'jabber', 41 ); 42 43 static public function depends_on() 44 { 45 return array('\phpbb\db\migration\data\v310\rc3'); 46 } 47 48 public function update_data() 49 { 50 return array( 51 array('custom', array(array($this, 'update_notifications_name'))), 52 array('custom', array(array($this, 'update_notifications_method_name'))), 53 ); 54 } 55 56 public function revert_data() 57 { 58 return array( 59 array('custom', array(array($this, 'revert_notifications_name'))), 60 array('custom', array(array($this, 'revert_notifications_method_name'))), 61 ); 62 } 63 64 public function update_notifications_method_name() 65 { 66 foreach ($this->notification_methods as $notification_method) 67 { 68 $sql = 'UPDATE ' . USER_NOTIFICATIONS_TABLE . " 69 SET method = 'notification.method.{$notification_method}' 70 WHERE method = '{$notification_method}'"; 71 $this->db->sql_query($sql); 72 } 73 } 74 75 public function revert_notifications_method_name() 76 { 77 foreach ($this->notification_methods as $notification_method) 78 { 79 $sql = 'UPDATE ' . USER_NOTIFICATIONS_TABLE . " 80 SET method = '{$notification_method}' 81 WHERE method = 'notification.method.{$notification_method}'"; 82 $this->db->sql_query($sql); 83 } 84 } 85 86 public function update_notifications_name() 87 { 88 $sql = 'UPDATE ' . NOTIFICATION_TYPES_TABLE . ' 89 SET notification_type_enabled = 0 90 WHERE ' . $this->db->sql_in_set('notification_type_name', $this->notification_types, true); 91 $this->db->sql_query($sql); 92 93 foreach ($this->notification_types as $notification_type) 94 { 95 $sql = 'SELECT notification_type_id 96 FROM ' . NOTIFICATION_TYPES_TABLE . " 97 WHERE notification_type_name = 'notification.type.{$notification_type}'"; 98 $result = $this->db->sql_query($sql); 99 $new_type_id = (int) $this->db->sql_fetchfield('notification_type_id'); 100 $this->db->sql_freeresult($result); 101 102 if ($new_type_id) 103 { 104 // New type name already exists, 105 // so we delete the old type and update the type id of existing entries. 106 $sql = 'SELECT notification_type_id 107 FROM ' . NOTIFICATION_TYPES_TABLE . " 108 WHERE notification_type_name = '{$notification_type}'"; 109 $result = $this->db->sql_query($sql); 110 $old_type_id = (int) $this->db->sql_fetchfield('notification_type_id'); 111 $this->db->sql_freeresult($result); 112 113 $sql = 'UPDATE ' . NOTIFICATIONS_TABLE . ' 114 SET notification_type_id = ' . (int) $new_type_id . ' 115 WHERE notification_type_id = ' . (int) $old_type_id; 116 $this->db->sql_query($sql); 117 118 $sql = 'DELETE FROM ' . NOTIFICATION_TYPES_TABLE . " 119 WHERE notification_type_name = '{$notification_type}'"; 120 $this->db->sql_query($sql); 121 } 122 else 123 { 124 // Otherwise we just update the name 125 $sql = 'UPDATE ' . NOTIFICATION_TYPES_TABLE . " 126 SET notification_type_name = 'notification.type.{$notification_type}' 127 WHERE notification_type_name = '{$notification_type}'"; 128 $this->db->sql_query($sql); 129 } 130 131 $sql = 'UPDATE ' . USER_NOTIFICATIONS_TABLE . " 132 SET item_type = 'notification.type.{$notification_type}' 133 WHERE item_type = '{$notification_type}'"; 134 $this->db->sql_query($sql); 135 } 136 } 137 138 public function revert_notifications_name() 139 { 140 foreach ($this->notification_types as $notification_type) 141 { 142 $sql = 'SELECT notification_type_id 143 FROM ' . NOTIFICATION_TYPES_TABLE . " 144 WHERE notification_type_name = '{$notification_type}'"; 145 $result = $this->db->sql_query($sql); 146 $new_type_id = (int) $this->db->sql_fetchfield('notification_type_id'); 147 $this->db->sql_freeresult($result); 148 149 if ($new_type_id) 150 { 151 // New type name already exists, 152 // so we delete the old type and update the type id of existing entries. 153 $sql = 'SELECT notification_type_id 154 FROM ' . NOTIFICATION_TYPES_TABLE . " 155 WHERE notification_type_name = 'notification.type.{$notification_type}'"; 156 $result = $this->db->sql_query($sql); 157 $old_type_id = (int) $this->db->sql_fetchfield('notification_type_id'); 158 $this->db->sql_freeresult($result); 159 160 $sql = 'UPDATE ' . NOTIFICATIONS_TABLE . ' 161 SET notification_type_id = ' . (int) $new_type_id . ' 162 WHERE notification_type_id = ' . (int) $old_type_id; 163 $this->db->sql_query($sql); 164 165 $sql = 'DELETE FROM ' . NOTIFICATION_TYPES_TABLE . " 166 WHERE notification_type_name = 'notification.type.{$notification_type}'"; 167 $this->db->sql_query($sql); 168 } 169 else 170 { 171 // Otherwise we just update the name 172 $sql = 'UPDATE ' . NOTIFICATION_TYPES_TABLE . " 173 SET notification_type_name = '{$notification_type}' 174 WHERE notification_type_name = 'notification.type.{$notification_type}'"; 175 $this->db->sql_query($sql); 176 } 177 178 $sql = 'UPDATE ' . USER_NOTIFICATIONS_TABLE . " 179 SET item_type = '{$notification_type}' 180 WHERE item_type = 'notification.type.{$notification_type}'"; 181 $this->db->sql_query($sql); 182 } 183 } 184 }
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 |