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 |
remove_profilefield_wlm.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\v320;
015
016 class remove_profilefield_wlm extends \phpbb\db\migration\migration
017 {
018 static public function depends_on()
019 {
020 return array(
021 '\phpbb\db\migration\data\v320\dev',
022 );
023 }
024
025 public function update_schema()
026 {
027 return array(
028 'drop_columns' => array(
029 $this->table_prefix . 'profile_fields_data' => array(
030 'pf_phpbb_wlm',
031 ),
032 ),
033 );
034 }
035
036 public function revert_schema()
037 {
038 return array(
039 'add_columns' => array(
040 $this->table_prefix . 'profile_fields_data' => array(
041 'pf_phpbb_wlm' => array('VCHAR', ''),
042 ),
043 ),
044 );
045 }
046
047 public function update_data()
048 {
049 return array(
050 array('custom', array(array($this, 'delete_custom_profile_field_data'))),
051 );
052 }
053
054 public function revert_data()
055 {
056 return array(
057 array('custom', array(array($this, 'create_custom_field'))),
058 );
059 }
060
061 public function delete_custom_profile_field_data()
062 {
063 $field_id = $this->get_custom_profile_field_id();
064
065 $sql = 'DELETE FROM ' . PROFILE_FIELDS_TABLE . '
066 WHERE field_id = ' . (int) $field_id;
067 $this->db->sql_query($sql);
068
069 $sql = 'DELETE FROM ' . PROFILE_LANG_TABLE . '
070 WHERE field_id = ' . (int) $field_id;
071 $this->db->sql_query($sql);
072
073 $sql = 'DELETE FROM ' . PROFILE_FIELDS_LANG_TABLE . '
074 WHERE field_id = ' . (int) $field_id;
075 $this->db->sql_query($sql);
076 }
077
078 /**
079 * Get custom profile field id
080 * @return int custom profile filed id
081 */
082 public function get_custom_profile_field_id()
083 {
084 $sql = 'SELECT field_id
085 FROM ' . PROFILE_FIELDS_TABLE . "
086 WHERE field_name = 'phpbb_wlm'";
087 $result = $this->db->sql_query($sql);
088 $field_id = (int) $this->db->sql_fetchfield('field_id');
089 $this->db->sql_freeresult($result);
090
091 return $field_id;
092 }
093
094 public function create_custom_field()
095 {
096 $sql = 'SELECT MAX(field_order) as max_field_order
097 FROM ' . PROFILE_FIELDS_TABLE;
098 $result = $this->db->sql_query($sql);
099 $max_field_order = (int) $this->db->sql_fetchfield('max_field_order');
100 $this->db->sql_freeresult($result);
101
102 $sql_ary = array(
103 'field_name' => 'phpbb_wlm',
104 'field_type' => 'profilefields.type.string',
105 'field_ident' => 'phpbb_wlm',
106 'field_length' => '40',
107 'field_minlen' => '5',
108 'field_maxlen' => '255',
109 'field_novalue' => '',
110 'field_default_value' => '',
111 'field_validation' => '.*',
112 'field_required' => 0,
113 'field_show_novalue' => 0,
114 'field_show_on_reg' => 0,
115 'field_show_on_pm' => 1,
116 'field_show_on_vt' => 1,
117 'field_show_on_ml' => 0,
118 'field_show_profile' => 1,
119 'field_hide' => 0,
120 'field_no_view' => 0,
121 'field_active' => 1,
122 'field_is_contact' => 1,
123 'field_contact_desc' => '',
124 'field_contact_url' => '',
125 'field_order' => $max_field_order + 1,
126 );
127
128 $sql = 'INSERT INTO ' . PROFILE_FIELDS_TABLE . ' ' . $this->db->sql_build_array('INSERT', $sql_ary);
129 $this->db->sql_query($sql);
130 $field_id = (int) $this->db->sql_nextid();
131
132 $insert_buffer = new \phpbb\db\sql_insert_buffer($this->db, PROFILE_LANG_TABLE);
133
134 $sql = 'SELECT lang_id
135 FROM ' . LANG_TABLE;
136 $result = $this->db->sql_query($sql);
137 $lang_name = 'WLM';
138 while ($lang_id = (int) $this->db->sql_fetchfield('lang_id'))
139 {
140 $insert_buffer->insert(array(
141 'field_id' => (int) $field_id,
142 'lang_id' => (int) $lang_id,
143 'lang_name' => $lang_name,
144 'lang_explain' => '',
145 'lang_default_value' => '',
146 ));
147 }
148 $this->db->sql_freeresult($result);
149
150 $insert_buffer->flush();
151 }
152 }
153