Changeset 1165 in ExiteCMS
- Timestamp:
- 12/10/07 00:01:20 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
modules/common/wiki/php-files/modules/wiki/module_installer.php
r1161 r1165 19 19 +----------------------------------------------------*/ 20 20 $mod_title = "Wikka Wiki"; // title or name of this module 21 $mod_description = "ExiteCMS embedded implementation of Wikka Wakka Wiki "; // short description of it's purpose21 $mod_description = "ExiteCMS embedded implementation of Wikka Wakka Wiki v1.1.6.3"; // short description of it's purpose 22 22 $mod_version = "1.0.2"; // module version number 23 23 $mod_developer = "WanWizard"; // author's name … … 86 86 $localestrings['en']['420'] = "(only if IP address matches)"; 87 87 88 $localestrings = array();89 88 $localestrings['nl'] = array(); 90 89 $localestrings['nl']['400'] = "Wiki configuratie"; … … 231 230 ) ENGINE=MyISAM;"); 232 231 233 // add the Wiki config variables 234 $mod_install_cmds[] = array('type' => 'db', 'value' => "INSERT INTO ##PREFIX##CMSconfig (cfg_name, cfg_value) VALUES ('wiki_root_page', 'HomePage')"); 235 $mod_install_cmds[] = array('type' => 'db', 'value' => "INSERT INTO ##PREFIX##CMSconfig (cfg_name, cfg_value) VALUES ('wiki_wakka_name', 'ExiteCMS Wiki')"); 236 $mod_install_cmds[] = array('type' => 'db', 'value' => "INSERT INTO ##PREFIX##CMSconfig (cfg_name, cfg_value) VALUES ('wiki_navigation_links', '[[CategoryCategory Categories]] | PageIndex | RecentChanges | RecentlyCommented')"); 237 $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]]')"); 238 $mod_install_cmds[] = array('type' => 'db', 'value' => "INSERT INTO ##PREFIX##CMSconfig (cfg_name, cfg_value) VALUES ('wiki_hide_comments', '0')"); 239 $mod_install_cmds[] = array('type' => 'db', 'value' => "INSERT INTO ##PREFIX##CMSconfig (cfg_name, cfg_value) VALUES ('wiki_require_edit_note', '0')"); 240 $mod_install_cmds[] = array('type' => 'db', 'value' => "INSERT INTO ##PREFIX##CMSconfig (cfg_name, cfg_value) VALUES ('wiki_anony_delete_own_comments', '1')"); 241 $mod_install_cmds[] = array('type' => 'db', 'value' => "INSERT INTO ##PREFIX##CMSconfig (cfg_name, cfg_value) VALUES ('wiki_external_link_new_window', '1')"); 242 $mod_install_cmds[] = array('type' => 'db', 'value' => "INSERT INTO ##PREFIX##CMSconfig (cfg_name, cfg_value) VALUES ('wiki_default_read_acl', 'G0')"); 243 $mod_install_cmds[] = array('type' => 'db', 'value' => "INSERT INTO ##PREFIX##CMSconfig (cfg_name, cfg_value) VALUES ('wiki_default_write_acl', 'G101')"); 244 $mod_install_cmds[] = array('type' => 'db', 'value' => "INSERT INTO ##PREFIX##CMSconfig (cfg_name, cfg_value) VALUES ('wiki_default_comment_acl', 'G101')"); 245 $mod_install_cmds[] = array('type' => 'db', 'value' => "INSERT INTO ##PREFIX##CMSconfig (cfg_name, cfg_value) VALUES ('wiki_admin_group', 'G103')"); 232 // create the user groups for this module 233 $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')"); 234 $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')"); 246 235 247 236 // custom module install code … … 278 267 $mod_uninstall_cmds[] = array('type' => 'db', 'value' => "DELETE FROM ##PREFIX##CMSconfig WHERE cfg_name = 'wiki_admin_group'"); 279 268 280 // remove any reference to the wiki groups created at installation time by an other version 269 // delete the user groups 270 $mod_uninstall_cmds[] = array('type' => 'db', 'value' => "DELETE FROM ##PREFIX##user_groups WHERE group_ident = '".$mod_admin_rights."01'"); 271 $mod_uninstall_cmds[] = array('type' => 'db', 'value' => "DELETE FROM ##PREFIX##user_groups WHERE group_ident = '".$mod_admin_rights."02'"); 272 273 // custom module uninstall code 281 274 $mod_uninstall_cmds[] = array('type' => 'function', 'value' => "module_uninstall"); 282 275 … … 288 281 289 282 global $db_prefix, $mod_admin_rights; 283 284 // add the Wiki config variables 285 add_config_items(); 290 286 291 287 // update the default wiki pages with the name of the webmasters account … … 303 299 } 304 300 } 301 302 // add the Wiki config variables 303 if (!function_exists('add_config_items')) { 304 function add_config_items() { 305 global $db_prefix, $mod_admin_rights; 306 307 $result = dbquery("INSERT INTO ".$db_prefix."CMSconfig( cfg_name, cfg_value ) VALUES ('wiki_root_page', 'HomePage')"); 308 $result = dbquery("INSERT INTO ".$db_prefix."CMSconfig( cfg_name, cfg_value ) VALUES ('wiki_wakka_name', 'ExiteCMS Wiki')"); 309 $result = dbquery("INSERT INTO ".$db_prefix."CMSconfig( cfg_name, cfg_value ) VALUES ('wiki_navigation_links', '[[CategoryCategory Categories]] | PageIndex | RecentChanges | RecentlyCommented')"); 310 $result = dbquery("INSERT INTO ".$db_prefix."CMSconfig( cfg_name, cfg_value ) VALUES ('wiki_logged_in_navigation_links', '[[CategoryCategory Categories]] | PageIndex | RecentChanges | RecentlyCommented | [[UserSettings Change settings]]')"); 311 $result = dbquery("INSERT INTO ".$db_prefix."CMSconfig( cfg_name, cfg_value ) VALUES ('wiki_hide_comments', '0')"); 312 $result = dbquery("INSERT INTO ".$db_prefix."CMSconfig( cfg_name, cfg_value ) VALUES ('wiki_require_edit_note', '0')"); 313 $result = dbquery("INSERT INTO ".$db_prefix."CMSconfig( cfg_name, cfg_value ) VALUES ('wiki_anony_delete_own_comments', '1')"); 314 $result = dbquery("INSERT INTO ".$db_prefix."CMSconfig( cfg_name, cfg_value ) VALUES ('wiki_external_link_new_window', '1')"); 315 $result = dbquery("INSERT INTO ".$db_prefix."CMSconfig( cfg_name, cfg_value ) VALUES ('wiki_default_read_acl', 'G0');"); 316 // get the group_id of the Wiki Editors group 317 $result = dbquery("SELECT * FROM ".$db_prefix."user_groups WHERE group_ident = '".$mod_admin_rights."01'"); 318 if (dbrows($result)) { 319 $data = dbarray($result); 320 $result = dbquery("INSERT INTO ".$db_prefix."CMSconfig( cfg_name, cfg_value ) VALUES ('wiki_default_write_acl', 'G".$data['group_id']."')"); 321 $result = dbquery("INSERT INTO ".$db_prefix."CMSconfig( cfg_name, cfg_value ) VALUES ('wiki_default_comment_acl', 'G".$data['group_id']."')"); 322 } else { 323 // can't find it? default to all members 324 $result = dbquery("INSERT INTO ".$db_prefix."CMSconfig( cfg_name, cfg_value ) VALUES ('wiki_default_write_acl', 'G101')"); 325 $result = dbquery("INSERT INTO ".$db_prefix."CMSconfig( cfg_name, cfg_value ) VALUES ('wiki_default_comment_acl', 'G101')"); 326 } 327 // get the group_id of the Wiki Admins group 328 $result = dbquery("SELECT * FROM ".$db_prefix."user_groups WHERE group_ident = '".$mod_admin_rights."02'"); 329 if (dbrows($result)) { 330 $data = dbarray($result); 331 $result = dbquery("INSERT INTO ".$db_prefix."CMSconfig( cfg_name, cfg_value ) VALUES ('wiki_admin_group', 'G".$data['group_id']."')"); 332 } else { 333 // can't find it? default to all members 334 $result = dbquery("INSERT INTO ".$db_prefix."CMSconfig( cfg_name, cfg_value ) VALUES ('wiki_admin_group', 'G103')"); 335 } 336 } 337 } 338 305 339 /*---------------------------------------------------+ 306 340 | function for special de-installations | … … 309 343 function module_uninstall() { 310 344 311 // code to be executed when uninstalling this module 345 // code to be executed when uninstalling this module 312 346 } 313 347 } … … 325 359 326 360 case "1.0.1": 327 // no specific changes between this version and the new one 361 // add the defaults to the CMSconfig table 362 add_config_items(); 363 // migrate the wiki_acls 364 $result = dbquery("SELECT * FROM ".$db_prefix."wiki_acls"); 365 while ($data = dbarray($result)) { 366 $fieldarray = array('read_acl' => $data['read_acl'], 'write_acl' => $data['write_acl'], 'comment_acl' => $data['comment_acl']); 367 foreach($fieldarray as $fieldname => $value) { 368 $values = explode("\n", $value); 369 $newacl = ""; 370 foreach($values as $acl) { 371 // wiki rule: Any line starting with a + or * will be treated as only having a + or * on it. 372 if ($acl{0} == "*" || $acl{0} == "+") $acl = $acl{0}; 373 // process the ACL 374 switch ($acl) { 375 case "+": // authenticated users (members) 376 $newacl .= ($newacl == "" ? "" : "\n")."G101"; 377 break; 378 case "*": // everyone (public) 379 $newacl .= ($newacl == "" ? "" : "\n")."G0"; 380 break; 381 case "!+": // anonymous users (anonymous) 382 $newacl .= ($newacl == "" ? "" : "\n")."G100"; 383 break; 384 case "!*": // not everyone (none) 385 break; 386 default: 387 // check if it's a deny 388 $deny = ($acl{0} == "!"); 389 if ($deny) $acl = substr($acl, 1); 390 // check if this is the name of a valid user 391 $result2 = dbquery("SELECT * FROM ".$db_prefix."users WHERE user_name = '".trim($acl)."'"); 392 if (dbrows($result2)) { 393 $data2 = dbarray($result2); 394 $newacl .= ($newacl == "" ? "" : "\n").$data2['user_id']; 395 } else { 396 echo "=> ",$acl," not found<br>"; 397 } 398 break; 399 } 400 } 401 $fieldarray[$fieldname] = $newacl; 402 } 403 // update the wiki_acl 404 $result = dbquery("UPDATE ".$db_prefix."wiki_acls SET read_acl = '".$fieldarray['read_acl']."', write_acl = '".$fieldarray['write_acl']."', comment_acl = '".$fieldarray['comment_acl']."' WHERE page_tag = '".$data['page_tag']."'"); 405 } 328 406 329 407 default:
Note: See TracChangeset
for help on using the changeset viewer.
