Textpattern PHP Cross Reference Content Management Systems

Source: /textpattern/update/_to_4.2.0.php - 106 lines - 4395 bytes - Text - Print

   1  <?php
   2  
   3  /*
   4   * Textpattern Content Management System
   5   * http://textpattern.com
   6   *
   7   * Copyright (C) 2016 The Textpattern Development Team
   8   *
   9   * This file is part of Textpattern.
  10   *
  11   * Textpattern is free software; you can redistribute it and/or
  12   * modify it under the terms of the GNU General Public License
  13   * as published by the Free Software Foundation, version 2.
  14   *
  15   * Textpattern is distributed in the hope that it will be useful,
  16   * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18   * GNU General Public License for more details.
  19   *
  20   * You should have received a copy of the GNU General Public License
  21   * along with Textpattern. If not, see <http://www.gnu.org/licenses/>.
  22   */
  23  
  24  if (!defined('TXP_UPDATE')) {
  25      exit("Nothing here. You can't access this file directly.");
  26  }
  27  
  28  // Support for per-user private prefs.
  29  $cols = getThings("DESCRIBE `".PFX."txp_prefs`");
  30  if (!in_array('user_name', $cols)) {
  31      safe_alter('txp_prefs', "ADD user_name VARCHAR(64) NOT NULL DEFAULT ''");
  32      safe_drop_index('txp_prefs', 'prefs_idx');
  33      safe_alter('txp_prefs', "ADD UNIQUE prefs_idx (prefs_id, name, user_name)");
  34      safe_create_index('txp_prefs', 'user_name', 'user_name');
  35  }
  36  
  37  // Remove a few global prefs in favour of future private ones.
  38  safe_delete('txp_prefs', "user_name = '' AND name IN ('article_list_pageby', 'author_list_pageby', 'comment_list_pageby', 'file_list_pageby', 'image_list_pageby', 'link_list_pageby', 'log_list_pageby')");
  39  
  40  // Use dedicated prefs function for setting custom fields.
  41  safe_update('txp_prefs', "html = 'custom_set'", "name IN ('custom_1_set', 'custom_2_set', 'custom_3_set', 'custom_4_set', 'custom_5_set', 'custom_6_set', 'custom_7_set', 'custom_8_set', 'custom_9_set', 'custom_10_set') AND html = 'text_input'");
  42  
  43  // Send comments prefs.
  44  safe_update('txp_prefs', "html = 'commentsendmail'", "name = 'comments_sendmail' AND html = 'yesnoradio'");
  45  
  46  // Timezone prefs.
  47  safe_update('txp_prefs', "html = 'is_dst'", "name = 'is_dst' AND html = 'yesnoradio'");
  48  
  49  if (!safe_field("name", 'txp_prefs', "name = 'auto_dst'")) {
  50      safe_insert('txp_prefs', "prefs_id = 1, name = 'auto_dst', val = '0', type = '0', event = 'publish', html = 'yesnoradio', position = '115'");
  51  }
  52  
  53  if (!safe_field("name", 'txp_prefs', "name = 'timezone_key'")) {
  54      $tz = new timezone;
  55      $tz = $tz->key($gmtoffset);
  56      safe_insert('txp_prefs', "prefs_id = 1, name = 'timezone_key', val = '$tz', type = '2', event = 'publish', html = 'textinput', position = '0'");
  57  }
  58  
  59  // Default event admin pref.
  60  if (!safe_field("name", 'txp_prefs', "name = 'default_event'")) {
  61      safe_insert('txp_prefs', "prefs_id = 1, name = 'default_event', val = 'article', type = '1', event = 'admin', html = 'default_event', position = '150'");
  62  }
  63  
  64  // Add columns for thumbnail dimensions.
  65  $cols = getThings("DESCRIBE `".PFX."txp_image`");
  66  
  67  if (!in_array('thumb_w', $cols)) {
  68      safe_alter('txp_image', "ADD thumb_w int(8) NOT NULL DEFAULT 0");
  69  }
  70  
  71  if (!in_array('thumb_h', $cols)) {
  72      safe_alter('txp_image', "ADD thumb_h int(8) NOT NULL DEFAULT 0");
  73  }
  74  
  75  // Plugin flags.
  76  $cols = getThings('DESCRIBE `'.PFX.'txp_plugin`');
  77  
  78  if (!in_array('flags', $cols)) {
  79      safe_alter('txp_plugin', "ADD flags SMALLINT UNSIGNED NOT NULL DEFAULT 0");
  80  }
  81  
  82  // Default theme.
  83  if (!safe_field("name", 'txp_prefs', "name = 'theme_name'")) {
  84      safe_insert('txp_prefs', "prefs_id = 1, name = 'theme_name', val = 'classic', type = '1', event = 'admin', html = 'themename', position = '160'");
  85  }
  86  
  87  safe_alter('txp_plugin', "MODIFY code         MEDIUMTEXT NOT NULL");
  88  safe_alter('txp_plugin', "MODIFY code_restore MEDIUMTEXT NOT NULL");
  89  
  90  safe_alter('txp_prefs', "MODIFY val TEXT NOT NULL");
  91  
  92  // Add author column to files and links, boldy assuming that the publisher in
  93  // charge of updating this site is the author of any existing content items.
  94  foreach (array('txp_file', 'txp_link') as $table) {
  95      $cols = getThings("DESCRIBE `".PFX.$table."`");
  96  
  97      if (!in_array('author', $cols)) {
  98          safe_alter($table, "ADD author varchar(64) NOT NULL DEFAULT ''");
  99          safe_create_index($table, 'author', 'author_idx');
 100          safe_update($table, "author = '".doSlash($txp_user)."'", "1 = 1");
 101      }
 102  }
 103  
 104  // Add indices on author columns.
 105  safe_create_index('textpattern', 'AuthorID', 'author_idx');
 106  safe_create_index('txp_image', 'author', 'author_idx');

title

Description

title

Description

title

Description

title

title

Body