plugins/staticpages/sql/mysql_updates.php
author Dirk Haun <dirk@haun-online.de>
Fri, 30 Oct 2009 13:49:11 +0100
branchHEAD
changeset 7405 9ac31db1c2a3
parent 7404 3dde94a085fe
child 7495 5efbfc846ad1
permissions -rw-r--r--
Move Default Permissions fieldset during update
     1 <?php
     2 
     3 /* Reminder: always indent with 4 spaces (no tabs). */
     4 // +---------------------------------------------------------------------------+
     5 // | Static Pages Plugin 1.6                                                   |
     6 // +---------------------------------------------------------------------------+
     7 // | Upgrade SQL                                                               |
     8 // +---------------------------------------------------------------------------+
     9 // | Copyright (C) 2009 by the following authors:                              |
    10 // |                                                                           |
    11 // | Authors: Tom Homer        - websitemaster AT cogeco DOT net               |
    12 // +---------------------------------------------------------------------------+
    13 // |                                                                           |
    14 // | This program is licensed under the terms of the GNU General Public License|
    15 // | as published by the Free Software Foundation; either version 2            |
    16 // | of the License, or (at your option) any later version.                    |
    17 // |                                                                           |
    18 // | This program is distributed in the hope that it will be useful,           |
    19 // | but WITHOUT ANY WARRANTY; without even the implied warranty of            |
    20 // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                      |
    21 // | See the GNU General Public License for more details.                      |
    22 // |                                                                           |
    23 // | You should have received a copy of the GNU General Public License         |
    24 // | along with this program; if not, write to the Free Software Foundation,   |
    25 // | Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.           |
    26 // |                                                                           |
    27 // +---------------------------------------------------------------------------+
    28 
    29 /**
    30 * MySQL updates
    31 *
    32 * @package StaticPages
    33 */
    34 
    35 $_UPDATES = array(
    36 
    37     '1.6.0' => array(
    38         "ALTER TABLE {$_TABLES['staticpage']} ADD meta_description TEXT NULL AFTER commentcode",
    39         "ALTER TABLE {$_TABLES['staticpage']} ADD meta_keywords TEXT NULL AFTER meta_description"
    40     )
    41 
    42 );
    43 
    44 /**
    45 * Handle update to plugin version 1.6.0: introduce meta tags option
    46 *
    47 */
    48 function update_ConfValues_1_6_0()
    49 {
    50     global $_CONF, $_TABLES, $_SP_DEFAULT;
    51 
    52     require_once $_CONF['path_system'] . 'classes/config.class.php';
    53 
    54     $c = config::get_instance();
    55 
    56     require_once $_CONF['path'] . 'plugins/staticpages/install_defaults.php';
    57 
    58     // meta tag config options.
    59     $c->add('meta_tags', $_SP_DEFAULT['meta_tags'], 'select', 0, 0, 0, 120, true, 'staticpages');
    60 
    61     // check for wrong Admin group name
    62     $wrong_id = DB_getItem($_TABLES['groups'], 'grp_id',
    63                            "grp_name = 'Static Pages Admin'"); // wrong name
    64     if (! empty($wrong_id)) {
    65         $grp_id = DB_getItem($_TABLES['groups'], 'grp_id',
    66                              "grp_name = 'Static Page Admin'"); // correct name
    67         if (empty($grp_id)) {
    68             // correct name not found - probably a fresh install: rename
    69             DB_query("UPDATE {$_TABLES['groups']} SET grp_name = 'Static Page Admin' WHERE grp_name = 'Static Pages Admin'");
    70         } else {
    71             // both names exist: delete wrong group & assignments
    72             DB_delete($_TABLES['access'], 'acc_grp_id', $wrong_id);
    73             DB_delete($_TABLES['group_assignments'], 'ug_grp_id', $wrong_id);
    74             DB_delete($_TABLES['group_assignments'], 'ug_main_grp_id', $wrong_id);
    75             DB_delete($_TABLES['groups'], 'grp_name', 'Static Pages Admin');
    76         }
    77     }
    78 
    79     // move Default Permissions fieldset
    80     DB_query("UPDATE {$_TABLES['conf_values']} SET fieldset = 3 WHERE (group_name = 'staticpages') AND (fieldset = 1)");
    81 
    82     // What's New Block
    83     $c->add('fs_whatsnew', NULL, 'fieldset', 0, 1, NULL, 0, true, 'staticpages');
    84     $c->add('newstaticpagesinterval',$_SP_DEFAULT['new_staticpages_interval'],'text', 0, 1, NULL, 10, TRUE, 'staticpages');
    85     $c->add('hidenewstaticpages',$_SP_DEFAULT['hide_new_staticpages'],'select', 0, 1, 0, 20, TRUE, 'staticpages');
    86     $c->add('title_trim_length',$_SP_DEFAULT['title_trim_length'],'text', 0, 1, NULL, 30, TRUE, 'staticpages');
    87     $c->add('includecenterblocks',$_SP_DEFAULT['include_centerblocks'],'select', 0, 1, 0, 40, TRUE, 'staticpages');
    88     $c->add('includephp',$_SP_DEFAULT['include_PHP'],'select', 0, 1, 0, 50, TRUE, 'staticpages');        
    89     
    90     // Search Results
    91     $c->add('fs_search', NULL, 'fieldset', 0, 2, NULL, 0, true, 'staticpages');
    92     $c->add('includesearch', $_SP_DEFAULT['include_search'], 'select', 0, 2, 0, 10, true, 'staticpages');
    93     $c->add('includesearchcenterblocks',$_SP_DEFAULT['include_search_centerblocks'],'select', 0, 2, 0, 20, TRUE, 'staticpages');
    94     $c->add('includesearchphp',$_SP_DEFAULT['include_search_PHP'],'select', 0, 2, 0, 30, TRUE, 'staticpages');   
    95 
    96     return true;
    97 }
    98 
    99 ?>