Advertisement
Guest User

Untitled

a guest
Sep 29th, 2021
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.91 KB | None | 0 0
  1. if(isset($_GET['migrate'])) {
  2.     $result = database()->query("SELECT * FROM `links` WHERE `type` = 'biolink'");
  3.     while($row = $result->fetch_object()) {
  4.         $row->settings = json_decode($row->settings);
  5.  
  6.         /* Migrate the avatar */
  7.         $settings = json_encode([
  8.             'image' => $row->settings->image,
  9.             'size' => '125',
  10.             'border_radius' => 'straight',
  11.         ]);
  12.  
  13.         /* Database query */
  14.         db()->insert('biolinks_blocks', [
  15.             'user_id' => $row->user_id,
  16.             'link_id' => $row->link_id,
  17.             'type' => 'avatar',
  18.             'settings' => $settings,
  19.             'datetime' => \Altum\Date::$date,
  20.             'order' => -5,
  21.         ]);
  22.  
  23.         /* Migrate the socials */
  24.         $settings = json_encode([
  25.             'color' => $row->settings->socials_color,
  26.             'socials' => $row->settings->socials
  27.         ]);
  28.  
  29.         /* Database query */
  30.         db()->insert('biolinks_blocks', [
  31.             'user_id' => $row->user_id,
  32.             'link_id' => $row->link_id,
  33.             'type' => 'socials',
  34.             'settings' => $settings,
  35.             'datetime' => \Altum\Date::$date,
  36.             'order' => 999,
  37.         ]);
  38.  
  39.         /* Migrate the Heading */
  40.         $settings = json_encode([
  41.             'heading_type' => 'h1',
  42.             'text' => $row->settings->title,
  43.             'text_color' => $row->settings->text_color,
  44.         ]);
  45.  
  46.         /* Database query */
  47.         db()->insert('biolinks_blocks', [
  48.             'user_id' => $row->user_id,
  49.             'link_id' => $row->link_id,
  50.             'type' => 'heading',
  51.             'settings' => $settings,
  52.             'datetime' => \Altum\Date::$date,
  53.             'order' => -4,
  54.         ]);
  55.  
  56.         /* Migrate the paragraph */
  57.         $settings = json_encode([
  58.             'text' => $row->settings->description,
  59.             'text_color' => $row->settings->text_color,
  60.         ]);
  61.  
  62.         /* Database query */
  63.         db()->insert('biolinks_blocks', [
  64.             'user_id' => $row->user_id,
  65.             'link_id' => $row->link_id,
  66.             'type' => 'paragraph',
  67.             'settings' => $settings,
  68.             'datetime' => \Altum\Date::$date,
  69.             'order' => -3,
  70.         ]);
  71.  
  72.         /* Clear the cache */
  73.         \Altum\Cache::$adapter->deleteItemsByTag('biolinks_links_user_' . $row->user_id);
  74.     }
  75. }
  76.  
  77.  
  78. if(isset($_GET['migrate'])) {
  79.     $result = database()->query("SELECT * FROM `biolinks_blocks` WHERE `type` = 'text'");
  80.     while($row = $result->fetch_object()) {
  81.         $row->settings = json_decode($row->settings);
  82.  
  83.         /* Migrate the Heading */
  84.         $settings = json_encode([
  85.             'heading_type' => 'h1',
  86.             'text' => $row->settings->title,
  87.             'text_color' => $row->settings->title_text_color,
  88.         ]);
  89.  
  90.         /* Database query */
  91.         db()->insert('biolinks_blocks', [
  92.             'user_id' => $row->user_id,
  93.             'link_id' => $row->link_id,
  94.             'type' => 'heading',
  95.             'settings' => $settings,
  96.             'datetime' => \Altum\Date::$date,
  97.             'order' => $row->order,
  98.         ]);
  99.  
  100.         /* Migrate the paragraph */
  101.         $settings = json_encode([
  102.             'text' => $row->settings->description,
  103.             'text_color' => $row->settings->description_text_color,
  104.         ]);
  105.  
  106.         /* Database query */
  107.         db()->insert('biolinks_blocks', [
  108.             'user_id' => $row->user_id,
  109.             'link_id' => $row->link_id,
  110.             'type' => 'paragraph',
  111.             'settings' => $settings,
  112.             'datetime' => \Altum\Date::$date,
  113.             'order' => $row->order+1,
  114.         ]);
  115.  
  116.         db()->where('biolink_block_id', $row->biolink_block_id)->delete('biolinks_blocks');
  117.  
  118.         /* Clear the cache */
  119.         \Altum\Cache::$adapter->deleteItemsByTag('biolinks_links_user_' . $row->user_id);
  120.     }
  121. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement