| Total Complexity | 6 |
| Total Lines | 51 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 15 | class m7_update_settings_data extends \phpbb\db\migration\migration |
||
| 16 | { |
||
| 17 | /** |
||
| 18 | * @inheritdoc |
||
| 19 | */ |
||
| 20 | public static function depends_on() |
||
| 21 | { |
||
| 22 | return array( |
||
| 23 | '\blitze\sitemaker\migrations\v20x\m1_initial_schema', |
||
| 24 | '\blitze\sitemaker\migrations\v20x\m6_add_block_settings_field', |
||
| 25 | ); |
||
| 26 | } |
||
| 27 | |||
| 28 | /** |
||
| 29 | * Skip this migration if the module_dir column does not exist |
||
| 30 | * |
||
| 31 | * @return bool True to skip this migration, false to run it |
||
| 32 | * @access public |
||
| 33 | */ |
||
| 34 | public function effectively_installed() |
||
| 35 | { |
||
| 36 | return !$this->db_tools->sql_table_exists($this->table_prefix . 'sm_blocks_config'); |
||
| 37 | } |
||
| 38 | |||
| 39 | /** |
||
| 40 | * @inheritdoc |
||
| 41 | */ |
||
| 42 | public function update_data() |
||
| 43 | { |
||
| 44 | return array( |
||
| 45 | array('custom', array(array($this, 'update_blocks_settings'))), |
||
| 46 | ); |
||
| 47 | } |
||
| 48 | |||
| 49 | public function update_blocks_settings() |
||
| 50 | { |
||
| 51 | $result = $this->db->sql_query('SELECT * FROM ' . $this->table_prefix . 'sm_blocks_config'); |
||
| 52 | |||
| 53 | $bconfig = array(); |
||
| 54 | while ($row = $this->db->sql_fetchrow($result)) |
||
| 55 | { |
||
| 56 | $bconfig[$row['bid']][$row['bvar']] = $row['bval']; |
||
| 57 | } |
||
| 58 | $this->db->sql_freeresult($result); |
||
| 59 | |||
| 60 | foreach ($bconfig as $bid => $settings) |
||
| 61 | { |
||
| 62 | $sql_data = array( |
||
| 63 | 'settings' => serialize($settings) |
||
| 64 | ); |
||
| 65 | $this->db->sql_query('UPDATE ' . $this->table_prefix . 'sm_blocks SET ' . $this->db->sql_build_array('UPDATE', $sql_data) .' WHERE bid = ' . (int) $bid); |
||
| 66 | } |
||
| 69 |