Verzeichnisstruktur phpBB-3.2.0
- Veröffentlicht
- 06.01.2017
So funktioniert es
|
Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück |
Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis. |
|
(Beispiel Datei-Icons)
|
Auf das Icon klicken um den Quellcode anzuzeigen |
notifications_use_full_name.php
001 <?php
002 /**
003 *
004 * This file is part of the phpBB Forum Software package.
005 *
006 * @copyright (c) phpBB Limited <https://www.phpbb.com>
007 * @license GNU General Public License, version 2 (GPL-2.0)
008 *
009 * For full copyright and license information, please see
010 * the docs/CREDITS.txt file.
011 *
012 */
013
014 namespace phpbb\db\migration\data\v310;
015
016 class notifications_use_full_name extends \phpbb\db\migration\migration
017 {
018 protected $notification_types = array(
019 'admin_activate_user',
020 'approve_post',
021 'approve_topic',
022 'bookmark',
023 'disapprove_post',
024 'disapprove_topic',
025 'group_request',
026 'group_request_approved',
027 'pm',
028 'post',
029 'post_in_queue',
030 'quote',
031 'report_pm',
032 'report_pm_closed',
033 'report_post',
034 'report_post_closed',
035 'topic',
036 'topic_in_queue');
037
038 protected $notification_methods = array(
039 'email',
040 'jabber',
041 );
042
043 static public function depends_on()
044 {
045 return array('\phpbb\db\migration\data\v310\rc3');
046 }
047
048 public function update_data()
049 {
050 return array(
051 array('custom', array(array($this, 'update_notifications_name'))),
052 array('custom', array(array($this, 'update_notifications_method_name'))),
053 );
054 }
055
056 public function revert_data()
057 {
058 return array(
059 array('custom', array(array($this, 'revert_notifications_name'))),
060 array('custom', array(array($this, 'revert_notifications_method_name'))),
061 );
062 }
063
064 public function update_notifications_method_name()
065 {
066 foreach ($this->notification_methods as $notification_method)
067 {
068 $sql = 'UPDATE ' . USER_NOTIFICATIONS_TABLE . "
069 SET method = 'notification.method.{$notification_method}'
070 WHERE method = '{$notification_method}'";
071 $this->db->sql_query($sql);
072 }
073 }
074
075 public function revert_notifications_method_name()
076 {
077 foreach ($this->notification_methods as $notification_method)
078 {
079 $sql = 'UPDATE ' . USER_NOTIFICATIONS_TABLE . "
080 SET method = '{$notification_method}'
081 WHERE method = 'notification.method.{$notification_method}'";
082 $this->db->sql_query($sql);
083 }
084 }
085
086 public function update_notifications_name()
087 {
088 $sql = 'UPDATE ' . NOTIFICATION_TYPES_TABLE . '
089 SET notification_type_enabled = 0
090 WHERE ' . $this->db->sql_in_set('notification_type_name', $this->notification_types, true);
091 $this->db->sql_query($sql);
092
093 foreach ($this->notification_types as $notification_type)
094 {
095 $sql = 'SELECT notification_type_id
096 FROM ' . NOTIFICATION_TYPES_TABLE . "
097 WHERE notification_type_name = 'notification.type.{$notification_type}'";
098 $result = $this->db->sql_query($sql);
099 $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 }
185