Changeset 1058 in ExiteCMS


Ignore:
Timestamp:
11/04/07 23:02:51 (4 years ago)
Author:
hverton
Message:

Modified the module installer to use the CMSconfig table for Wiki configuration
Updated the wikka.config to read the config from the CMSconfig table

Location:
modules/common/wiki/php-files/modules/wiki
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • modules/common/wiki/php-files/modules/wiki/module_installer.php

    r986 r1058  
    11<?php 
    22/*---------------------------------------------------+ 
    3 | PLi-Fusion Content Management System               | 
     3| ExiteCMS Content Management System                 | 
    44+----------------------------------------------------+ 
    5 | Copyright 2007 WanWizard (wanwizard@gmail.com)     | 
    6 | http://www.pli-images.org/pli-fusion              | 
     5| Copyright 2007 Harro "WanWizard" Verton, Exite BV  | 
     6| for support, please visit http://exitecms.exite.eu | 
    77+----------------------------------------------------+ 
    8 | Some portions copyright ? 2002 - 2006 Nick Jones   | 
     8| Some portions copyright 2002 - 2006 Nick Jones     | 
    99| http://www.php-fusion.co.uk/                       | 
     10+----------------------------------------------------+ 
    1011| Released under the terms & conditions of v2 of the | 
    1112| GNU General Public License. For details refer to   | 
     
    2930$mod_title = $locale['wiki100'];                        // title or name of this module 
    3031$mod_description = $locale['wiki101'];                  // short description of it's purpose 
    31 $mod_version = $locale['wikiver'];                      // module version number 
     32$mod_version = "1.0.2";                                 // module version number 
    3233$mod_developer = "WanWizard";                           // author's name 
    3334$mod_email = "wanwizard@gmail.com"; 
     
    4041 
    4142$mod_folder = "wiki";                                   // sub-folder of the /modules folder 
    42 $mod_admin_image = "";                                  // icon to be used for the admin panel 
    43 $mod_admin_panel = "";                                  // name of the admin panel for this module 
    44 $mod_admin_rights = "wW";                               // admin rights code. This HAS to be assigned by PLi-Fusion to avoid duplicates! 
    45 $mod_admin_page = 1;                                    // admin page this panel has to be placed on 
     43$mod_admin_image = "wiki_admin.gif";                    // icon to be used for the admin panel 
     44$mod_admin_panel = "wiki_admin.php";                    // name of the admin panel for this module 
     45$mod_admin_rights = "wW";                               // admin rights code. This HAS to be assigned by the ExiteCMS team to avoid duplicates! 
     46$mod_admin_page = 4;                                    // admin page this panel has to be placed on 
    4647 
    4748/*---------------------------------------------------+ 
     
    7576$mod_install_cmds = array();                            // commands to execute when installing this module 
    7677 
    77 // wiki_acls 
     78// create the table: wiki_acls 
    7879$mod_install_cmds[] = array('type' => 'db', 'value' => "CREATE TABLE ##PREFIX##wiki_acls ( 
    7980  page_tag varchar(75) NOT NULL default '', 
     
    8485) ENGINE=MyISAM;"); 
    8586 
     87// and add initial record(s) to it 
    8688$mod_install_cmds[] = array('type' => 'db', 'value' => "INSERT INTO ##PREFIX##wiki_acls (page_tag, read_acl, write_acl, comment_acl) VALUES ('UserSettings', '*', '+', '+')"); 
    8789 
    88 // wiki_comments 
     90// create the table: wiki_comments 
    8991$mod_install_cmds[] = array('type' => 'db', 'value' => "CREATE TABLE ##PREFIX##wiki_comments ( 
    9092  id int(10) unsigned NOT NULL auto_increment, 
     
    98100) ENGINE=MyISAM;"); 
    99101 
    100 // wiki_links 
     102// create the table: wiki_links 
    101103$mod_install_cmds[] = array('type' => 'db', 'value' => "CREATE TABLE ##PREFIX##wiki_links ( 
    102104  from_tag varchar(75) NOT NULL default '', 
     
    107109) ENGINE=MyISAM;"); 
    108110 
    109 // wiki_pages 
     111// create the table: wiki_pages 
    110112$mod_install_cmds[] = array('type' => 'db', 'value' => "CREATE TABLE ##PREFIX##wiki_pages ( 
    111113  id int(10) unsigned NOT NULL auto_increment, 
     
    126128) ENGINE=MyISAM;"); 
    127129 
     130// and add initial record(s) to it 
    128131$mod_install_cmds[] = array('type' => 'db', 'value' => "INSERT INTO ##PREFIX##wiki_pages (id, tag, time, body, owner, user, latest, note, handler) VALUES (1, 'HomePage', now(), '{{image url=\"images/wikka_logo.jpg\" alt=\"wikka logo\" title=\"Welcome to this Wikka Wiki!\"}}\n\nThis site is running on version ##{{wikkaversion}}## (see WikkaReleaseNotes). \nYou need to double-click on any page or click on the \"Edit page\" link at the bottom to get started. \n\nFor more information, visit the [[Wikka:HomePage WikkaWiki website]]! \n\nUseful pages: FormattingRules, WikkaDocumentation, OrphanedPages, WantedPages, TextSearch.', '##WEBMASTER##', '##WEBMASTER##', 'Y', '', 'page')"); 
    129132$mod_install_cmds[] = array('type' => 'db', 'value' => "INSERT INTO ##PREFIX##wiki_pages (id, tag, time, body, owner, user, latest, note, handler) VALUES (2, 'RecentChanges', now(), '{{RecentChanges}}{{nocomments}}\n\n\n----\nCategoryWiki', '(Public)', '##WEBMASTER##', 'Y', '', 'page')"); 
     
    149152$mod_install_cmds[] = array('type' => 'db', 'value' => "INSERT INTO ##PREFIX##wiki_pages (id, tag, time, body, owner, user, latest, note, handler) VALUES (22, 'SysInfo', now(), '===== System Information =====\n\n~-Wikka version: ##{{wikkaversion}}##\n~-PHP version: ##{{phpversion}}##\n~-\"\"MySQL\"\" version: ##{{mysqlversion}}##\n~-\"\"GeSHi\"\" version: ##{{geshiversion}}##\n~-Server:\n~~-Host: ##{{system show=\"host\"}}##\n~~-Operative System: ##{{system show=\"os\"}}##\n~~-Machine: ##{{system show=\"machine\"}}##\n\n----\nCategoryWiki', '(Public)', '##WEBMASTER##', 'Y', '', 'page')"); 
    150153 
    151 // wiki_referrer_blacklist 
     154// create the table: wiki_referrer_blacklist 
    152155$mod_install_cmds[] = array('type' => 'db', 'value' => "CREATE TABLE ##PREFIX##wiki_referrer_blacklist ( 
    153156  spammer varchar(150) NOT NULL default '', 
     
    155158) ENGINE=MyISAM;"); 
    156159 
    157 // wiki_referrers 
     160// create the table: wiki_referrers 
    158161$mod_install_cmds[] = array('type' => 'db', 'value' => "CREATE TABLE ##PREFIX##wiki_referrers ( 
    159162  page_tag varchar(75) NOT NULL default '', 
     
    164167) ENGINE=MyISAM;"); 
    165168 
    166 // wiki_users 
     169// create the table: wiki_users 
    167170$mod_install_cmds[] = array('type' => 'db', 'value' => "CREATE TABLE ##PREFIX##wiki_users ( 
    168171  name varchar(75) NOT NULL default '', 
     
    178181) ENGINE=MyISAM;"); 
    179182 
    180 // wiki_images 
     183// create the table: wiki_images 
    181184$mod_install_cmds[] = array('type' => 'db', 'value' => "CREATE TABLE ##PREFIX##wiki_images ( 
    182185  image_id SMALLINT( 5 ) UNSIGNED NOT NULL , 
     
    187190) ENGINE=MyISAM;"); 
    188191 
    189 // add a user group for this module 
    190 $mod_install_cmds[] = array('type' => 'db', 'value' => "INSERT INTO ##PREFIX##user_groups (group_ident, group_name, group_description, group_forumname, group_visible) VALUES ('".$mod_admin_rights."01', 'Wiki Admins', 'Wiki Admins', 'Wiki Admin', '1')"); 
    191 $mod_install_cmds[] = array('type' => 'db', 'value' => "INSERT INTO ##PREFIX##user_groups (group_ident, group_name, group_description, group_forumname, group_visible) VALUES ('".$mod_admin_rights."02', 'Wiki Editors', 'Wiki Editors', 'Wiki Editor', '1')"); 
    192  
    193 $mod_install_cmds[] = array('type' => 'function', 'value' => "install_wiki"); 
     192// add the Wiki config variables 
     193$mod_install_cmds[] = array('type' => 'db', 'value' => "INSERT INTO ##PREFIX##CMSconfig (cfg_name, cfg_value) VALUES ('wiki_root_page', 'HomePage')"); 
     194$mod_install_cmds[] = array('type' => 'db', 'value' => "INSERT INTO ##PREFIX##CMSconfig (cfg_name, cfg_value) VALUES ('wiki_wakka_name', 'ExiteCMS Wiki')"); 
     195$mod_install_cmds[] = array('type' => 'db', 'value' => "INSERT INTO ##PREFIX##CMSconfig (cfg_name, cfg_value) VALUES ('wiki_navigation_links', '[[CategoryCategory Categories]] | PageIndex |  RecentChanges | RecentlyCommented')"); 
     196$mod_install_cmds[] = array('type' => 'db', 'value' => "INSERT INTO ##PREFIX##CMSconfig (cfg_name, cfg_value) VALUES ('wiki_logged_in_navigation_links', '[[CategoryCategory Categories]] | PageIndex | RecentChanges | RecentlyCommented | [[UserSettings Change settings]]')"); 
     197$mod_install_cmds[] = array('type' => 'db', 'value' => "INSERT INTO ##PREFIX##CMSconfig (cfg_name, cfg_value) VALUES ('wiki_hide_comments', '0')"); 
     198$mod_install_cmds[] = array('type' => 'db', 'value' => "INSERT INTO ##PREFIX##CMSconfig (cfg_name, cfg_value) VALUES ('wiki_require_edit_note', '0')"); 
     199$mod_install_cmds[] = array('type' => 'db', 'value' => "INSERT INTO ##PREFIX##CMSconfig (cfg_name, cfg_value) VALUES ('wiki_anony_delete_own_comments', '1')"); 
     200$mod_install_cmds[] = array('type' => 'db', 'value' => "INSERT INTO ##PREFIX##CMSconfig (cfg_name, cfg_value) VALUES ('wiki_external_link_new_window', '1')"); 
     201$mod_install_cmds[] = array('type' => 'db', 'value' => "INSERT INTO ##PREFIX##CMSconfig (cfg_name, cfg_value) VALUES ('wiki_default_write_acl', '101')"); 
     202$mod_install_cmds[] = array('type' => 'db', 'value' => "INSERT INTO ##PREFIX##CMSconfig (cfg_name, cfg_value) VALUES ('wiki_default_read_acl', '0')"); 
     203$mod_install_cmds[] = array('type' => 'db', 'value' => "INSERT INTO ##PREFIX##CMSconfig (cfg_name, cfg_value) VALUES ('wiki_default_comment_acl', '101')"); 
     204 
     205// custom module install code 
     206// $mod_install_cmds[] = array('type' => 'function', 'value' => "module_install"); 
    194207 
    195208/*---------------------------------------------------+ 
     
    199212$mod_uninstall_cmds = array();                          // commands to execute when uninstalling this module 
    200213 
    201 // delete the wiki tables 
     214// delete all the wiki tables 
    202215$mod_uninstall_cmds[] = array('type' => 'db', 'value' => "DROP TABLE ##PREFIX##wiki_acls"); 
    203216$mod_uninstall_cmds[] = array('type' => 'db', 'value' => "DROP TABLE ##PREFIX##wiki_comments"); 
     
    209222$mod_uninstall_cmds[] = array('type' => 'db', 'value' => "DROP TABLE ##PREFIX##wiki_images"); 
    210223 
    211 // delete the user groups 
    212 $mod_uninstall_cmds[] = array('type' => 'db', 'value' => "DELETE FROM ##PREFIX##user_groups WHERE group_ident = '".$mod_admin_rights."01'"); 
    213 $mod_uninstall_cmds[] = array('type' => 'db', 'value' => "DELETE FROM ##PREFIX##user_groups WHERE group_ident = '".$mod_admin_rights."02'"); 
    214  
    215 $mod_install_cmds[] = array('type' => 'function', 'value' => "uninstall_wiki"); 
     224// delete the wiki config variables 
     225$mod_uninstall_cmds[] = array('type' => 'db', 'value' => "DELETE FROM ##PREFIX##CMSconfig WHERE cfg_name = 'wiki_root_page'"); 
     226$mod_uninstall_cmds[] = array('type' => 'db', 'value' => "DELETE FROM ##PREFIX##CMSconfig WHERE cfg_name = 'wiki_wakka_name'"); 
     227$mod_uninstall_cmds[] = array('type' => 'db', 'value' => "DELETE FROM ##PREFIX##CMSconfig WHERE cfg_name = 'wiki_navigation_links'"); 
     228$mod_uninstall_cmds[] = array('type' => 'db', 'value' => "DELETE FROM ##PREFIX##CMSconfig WHERE cfg_name = 'wiki_logged_in_navigation_links'"); 
     229$mod_uninstall_cmds[] = array('type' => 'db', 'value' => "DELETE FROM ##PREFIX##CMSconfig WHERE cfg_name = 'wiki_hide_comments'"); 
     230$mod_uninstall_cmds[] = array('type' => 'db', 'value' => "DELETE FROM ##PREFIX##CMSconfig WHERE cfg_name = 'wiki_require_edit_note'"); 
     231$mod_uninstall_cmds[] = array('type' => 'db', 'value' => "DELETE FROM ##PREFIX##CMSconfig WHERE cfg_name = 'wiki_anony_delete_own_comments'"); 
     232$mod_uninstall_cmds[] = array('type' => 'db', 'value' => "DELETE FROM ##PREFIX##CMSconfig WHERE cfg_name = 'wiki_external_link_new_window'"); 
     233$mod_uninstall_cmds[] = array('type' => 'db', 'value' => "DELETE FROM ##PREFIX##CMSconfig WHERE cfg_name = 'wiki_default_write_acl'"); 
     234$mod_uninstall_cmds[] = array('type' => 'db', 'value' => "DELETE FROM ##PREFIX##CMSconfig WHERE cfg_name = 'wiki_default_read_acl'"); 
     235$mod_uninstall_cmds[] = array('type' => 'db', 'value' => "DELETE FROM ##PREFIX##CMSconfig WHERE cfg_name = 'wiki_default_comment_acl'"); 
     236 
     237// remove any reference to the wiki groups created at installation time by an other version 
     238$mod_uninstall_cmds[] = array('type' => 'function', 'value' => "module_uninstall"); 
    216239 
    217240/*---------------------------------------------------+ 
    218241| function for special installations                 | 
    219242+----------------------------------------------------*/ 
    220 if (!function_exists('install_wiki')) { 
    221     function install_wiki() { 
     243if (!function_exists('module_install')) { 
     244    function module_install() { 
     245         
     246        global $db_prefix; 
     247 
     248    } 
     249} 
     250/*---------------------------------------------------+ 
     251| function for special de-installations              | 
     252+----------------------------------------------------*/ 
     253if (!function_exists('module_uninstall')) { 
     254    function module_uninstall() { 
    222255         
    223256        global $db_prefix, $mod_admin_rights; 
    224257 
    225         // get the group_id of the Wiki Admins group 
    226         $admins = dbarray(dbquery("SELECT group_id FROM ".$db_prefix."user_groups WHERE group_ident = '".$mod_admin_rights."01'")); 
     258        // check if the old wiki groups still exist. If so, remove them 
    227259         
    228         // add all webmasters to the wiki user table 
    229         $result = dbquery("SELECT * FROM ".$db_prefix."users WHERE user_level = '103'"); 
    230         while ($data = dbarray($result)) { 
    231             $result2 = dbquery("INSERT INTO ".$db_prefix."wiki_users (name, email, revisioncount, changescount, doubleclickedit, signuptime, show_comments) VALUES ('".$data['user_name']."', '".$data['user_email']."', 20, 50, 'Y', now(), 'N')"); 
    232             // and update references to the webmaster 
    233             if ($data['user_id'] == 1) { 
    234                 $result2 = dbquery("UPDATE ".$db_prefix."wiki_pages SET owner = '".$data['user_name']."' WHERE owner = '##WEBMASTER##'"); 
    235                 $result2 = dbquery("UPDATE ".$db_prefix."wiki_pages SET user = '".$data['user_name']."' WHERE user = '##WEBMASTER##'"); 
    236             } 
    237             // add them to the Wiki Admins group 
    238             if (isset($admins['group_id'])) { 
    239                 $user_groups = $data['user_groups'].".".$admins['group_id']; 
    240                 $result2 = dbquery("UPDATE ".$db_prefix."users SET user_groups = '$user_groups' WHERE user_id = '".$data['user_id']."'"); 
    241             } 
     260        // get the group id of the Wiki Admin group 
     261        $result = dbquery("SELECT group_id FROM ".$db_prefix."user_groups WHERE group_ident = '".$mod_admin_rights."01'"); 
     262        if ($data = dbarray($result)) { 
     263            // get all groups with membership of this group, and remove the membership 
     264 
     265            // get all users with membership of this group, and remove the membership 
     266 
     267            // delete the user group 
     268            $result = dbquery("DELETE FROM ".$db_prefix."user_groups WHERE group_ident = '".$mod_admin_rights."01'"); 
    242269        } 
    243     } 
    244 } 
    245 /*---------------------------------------------------+ 
    246 | function for special de-installations              | 
    247 +----------------------------------------------------*/ 
    248 if (!function_exists('uninstall_wiki')) { 
    249     function uninstall_wiki() { 
     270 
     271 
     272        // get the group id of the Wiki Editors group 
     273        $result = dbquery("SELECT group_id FROM ".$db_prefix."user_groups WHERE group_ident = '".$mod_admin_rights."02'"); 
     274        if ($data = dbarray($result)) { 
     275            // get all groups with membership of this group, and remove the membership 
     276 
     277            // get all users with membership of this group, and remove the membership 
     278 
     279            // delete the user group 
     280            $result = dbquery("DELETE FROM ".$db_prefix."user_groups WHERE group_ident = '".$mod_admin_rights."02'"); 
     281        } 
     282 
    250283    } 
    251284} 
     
    259292 
    260293        switch($current_version) { 
    261             case "1.1.6.3": 
     294            case "1.0.0": 
     295                // changes between this version and the next one 
     296 
    262297                // create the wiki_images table 
    263298                $result = dbquery("CREATE TABLE ".$db_prefix."wiki_images ( 
     
    268303                PRIMARY KEY ( image_id ) 
    269304                ) ENGINE=MyISAM;");          
     305 
     306            case "1.0.1": 
     307                // changes between this version and the next one 
     308 
     309            default: 
     310                // commands to execute for every upgrade 
    270311        } 
    271312    } 
  • modules/common/wiki/php-files/modules/wiki/wikka.config.php

    r979 r1058  
    5252); 
    5353 
     54// get wiki config variables from the CMSconfig table. They override the default config 
     55$result = dbquery("SELECT * FROM ".$db_prefix."CMSconfig WHERE cfg_name LIKE 'wiki_%'"); 
     56while ($data = dbarray($result)) { 
     57    // extract the wakkaConfig key from the cfg_name 
     58    $cfgkey = substr($data['cfg_name'],5); 
     59    // if the wakkaConfig key exists, overwrite the value 
     60    if (isset($wakkaConfig[$cfgkey])) { 
     61        $wakkaConfig[$cfgkey] = $data['cfg_value']; 
     62    } 
     63} 
     64 
    5465// check if there is a stylesheet for the Wiki in the current theme 
    5566// if not, take the Wiki module default 
     
    5869} else { 
    5970    $wakkaConfig['stylesheet'] = 'css/wikka.css'; 
    60 } 
    61  
    62 // generate the admin users based on group membership 
    63 $result = dbquery("SELECT * FROM ".$db_prefix."user_groups WHERE group_name = 'Wiki Admins'"); 
    64 if ($data = dbarray($result)) { 
    65     $users = allusersingroup($data['group_id']); 
    66     $admins = ""; 
    67     foreach ($users as $user) { 
    68         $admins .= ($admins == "" ? "" : "\n") . $user['user_name']; 
    69     } 
    70     if ($admins != "") $wakkaConfig['admin_users'] = $admins; 
    7171} 
    7272 
Note: See TracChangeset for help on using the changeset viewer.