b2evolution PHP Cross Reference Blogging Systems

Source: /install/_functions_create.php - 2243 lines - 91234 bytes - Summary - Text - Print

Description: This file implements creation of DB tables b2evolution - {@link http://b2evolution.net/} Released under GNU GPL License - {@link http://b2evolution.net/about/license.html}

   1  <?php
   2  /**
   3   * This file implements creation of DB tables
   4   *
   5   * b2evolution - {@link http://b2evolution.net/}
   6   * Released under GNU GPL License - {@link http://b2evolution.net/about/license.html}
   7   * @copyright (c)2003-2014 by Francois Planque - {@link http://fplanque.com/}
   8   * Parts of this file are copyright (c)2004 by Vegar BERG GULDAL - {@link http://funky-m.com/}
   9   * Parts of this file are copyright (c)2005 by Jason EDGECOMBE
  10   *
  11   * @license http://b2evolution.net/about/license.html GNU General Public License (GPL)
  12   *
  13   * {@internal Open Source relicensing agreement:
  14   * Daniel HAHLER grants Francois PLANQUE the right to license
  15   * Daniel HAHLER's contributions to this file and the b2evolution project
  16   * under any OSI approved OSS license (http://www.opensource.org/licenses/).
  17   *
  18   * Vegar BERG GULDAL grants Francois PLANQUE the right to license
  19   * Vegar BERG GULDAL's contributions to this file and the b2evolution project
  20   * under any OSI approved OSS license (http://www.opensource.org/licenses/).
  21   *
  22   * Jason EDGECOMBE grants Francois PLANQUE the right to license
  23   * Jason EDGECOMBE's contributions to this file and the b2evolution project
  24   * under any OSI approved OSS license (http://www.opensource.org/licenses/).
  25   *
  26   * Matt FOLLETT grants Francois PLANQUE the right to license
  27   * Matt FOLLETT contributions to this file and the b2evolution project
  28   * under any OSI approved OSS license (http://www.opensource.org/licenses/).
  29   * }}
  30   *
  31   * @package install
  32   *
  33   * {@internal Below is a list of authors who have contributed to design/coding of this file: }}
  34   * @author blueyed: Daniel HAHLER.
  35   * @author fplanque: Francois PLANQUE.
  36   * @author vegarg: Vegar BERG GULDAL.
  37   * @author edgester: Jason EDGECOMBE.
  38   * @author mfollett: Matt Follett.
  39   *
  40   * @version $Id: _functions_create.php 6136 2014-03-08 07:59:48Z manuel $
  41   */
  42  if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
  43  
  44  load_class( 'users/model/_group.class.php', 'Group' );
  45  load_funcs( 'collections/model/_category.funcs.php' );
  46  
  47  /**
  48   * Used for fresh install
  49   */
  50  function create_tables()
  51  {
  52      global $inc_path;
  53  
  54      // Load DB schema from modules
  55      load_db_schema();
  56  
  57      load_funcs('_core/model/db/_upgrade.funcs.php');
  58  
  59      // Alter DB to match DB schema:
  60      install_make_db_schema_current( true );
  61  }
  62  
  63  
  64  /**
  65   * Insert all default data:
  66   */
  67  function create_default_data()
  68  {
  69      global $Group_Admins, $Group_Privileged, $Group_Bloggers, $Group_Users, $Group_Suspect, $Group_Spam;
  70      global $DB, $locales, $current_locale, $baseurl;
  71      // This will install all sorts of additional things... for testing purposes:
  72      global $test_install_all_features;
  73  
  74      // Inserting sample data triggers events: instead of checking if $Plugins is an object there, just use a fake one..
  75      load_class('plugins/model/_plugins_admin_no_db.class.php', 'Plugins_admin_no_DB' );
  76      global $Plugins;
  77      $Plugins = new Plugins_admin_no_DB(); // COPY
  78  
  79      // added in 0.8.7
  80      task_begin( 'Creating default blacklist entries... ' );
  81      // This string contains antispam information that is obfuscated because some hosting
  82      // companies prevent uploading PHP files containing "spam" strings.
  83      // pre_dump(get_antispam_query());
  84      $query = get_antispam_query();
  85      $DB->query( $query );
  86      task_end();
  87  
  88      task_begin( 'Creating default antispam IP ranges... ' );
  89      $DB->query( '
  90          INSERT INTO T_antispam__iprange ( aipr_IPv4start, aipr_IPv4end, aipr_status )
  91          VALUES ( '.$DB->quote( ip2int( '127.0.0.0' ) ).', '.$DB->quote( ip2int( '127.0.0.255' ) ).', "trusted" ),
  92              ( '.$DB->quote( ip2int( '10.0.0.0' ) ).', '.$DB->quote( ip2int( '10.255.255.255' ) ).', "trusted" ),
  93              ( '.$DB->quote( ip2int( '172.16.0.0' ) ).', '.$DB->quote( ip2int( '172.31.255.255' ) ).', "trusted" ),
  94              ( '.$DB->quote( ip2int( '192.168.0.0' ) ).', '.$DB->quote( ip2int( '192.168.255.255' ) ).', "trusted" )
  95          ' );
  96      task_end();
  97  
  98      // added in 0.8.9
  99      task_begin( 'Creating default groups... ' );
 100      $Group_Admins = new Group(); // COPY !
 101      $Group_Admins->set( 'name', 'Administrators' );
 102      $Group_Admins->set( 'perm_blogs', 'editall' );
 103      $Group_Admins->set( 'perm_stats', 'edit' );
 104      $Group_Admins->set( 'perm_xhtml_css_tweaks', 1 );
 105      $Group_Admins->dbinsert();
 106  
 107      $Group_Privileged = new Group(); // COPY !
 108      $Group_Privileged->set( 'name', 'Moderators' );
 109      $Group_Privileged->set( 'perm_blogs', 'viewall' );
 110      $Group_Privileged->set( 'perm_stats', 'user' );
 111      $Group_Privileged->set( 'perm_xhtml_css_tweaks', 1 );
 112      $Group_Privileged->dbinsert();
 113  
 114      $Group_Bloggers = new Group(); // COPY !
 115      $Group_Bloggers->set( 'name', 'Trusted Users' );
 116      $Group_Bloggers->set( 'perm_blogs', 'user' );
 117      $Group_Bloggers->set( 'perm_stats', 'none' );
 118      $Group_Bloggers->set( 'perm_xhtml_css_tweaks', 1 );
 119      $Group_Bloggers->dbinsert();
 120  
 121      $Group_Users = new Group(); // COPY !
 122      $Group_Users->set( 'name', 'Normal Users' );
 123      $Group_Users->set( 'perm_blogs', 'user' );
 124      $Group_Users->set( 'perm_stats', 'none' );
 125      $Group_Users->dbinsert();
 126  
 127      $Group_Suspect = new Group(); // COPY !
 128      $Group_Suspect->set( 'name', 'Misbehaving/Suspect Users' );
 129      $Group_Suspect->set( 'perm_blogs', 'user' );
 130      $Group_Suspect->set( 'perm_stats', 'none' );
 131      $Group_Suspect->dbinsert();
 132  
 133      $Group_Spam = new Group(); // COPY !
 134      $Group_Spam->set( 'name', 'Spammers/Restricted Users' );
 135      $Group_Spam->set( 'perm_blogs', 'user' );
 136      $Group_Spam->set( 'perm_stats', 'none' );
 137      $Group_Spam->dbinsert();
 138      task_end();
 139  
 140      task_begin( 'Creating groups for user field definitions... ' );
 141      $DB->query( "
 142          INSERT INTO T_users__fieldgroups ( ufgp_name, ufgp_order )
 143          VALUES ( 'Instant Messaging', '1' ),
 144                       ( 'Phone', '2' ),
 145                       ( 'Web', '3' ),
 146                       ( 'Organization', '4' ),
 147                       ( 'Address', '5' ),
 148                       ( 'Other', '6' )" );
 149      task_end();
 150  
 151      task_begin( 'Creating user field definitions... ' );
 152      // fp> Anyone, please add anything you can think of. It's better to start with a large list that update it progressively.
 153      $DB->query( "
 154          INSERT INTO T_users__fielddefs (ufdf_ufgp_ID, ufdf_type, ufdf_name, ufdf_options, ufdf_required, ufdf_duplicated, ufdf_order, ufdf_suggest)
 155           VALUES ( 1, 'email',  'MSN/Live IM',   '', 'optional',    'allowed',   '1',  '0'),
 156                          ( 1, 'word',   'Yahoo IM',      '', 'optional',    'allowed',   '2',  '0'),
 157                          ( 1, 'word',   'AOL AIM',       '', 'optional',    'allowed',   '3',  '0'),
 158                          ( 1, 'number', 'ICQ ID',        '', 'optional',    'allowed',   '4',  '0'),
 159                          ( 1, 'phone',  'Skype',         '', 'optional',    'allowed',   '5',  '0'),
 160                          ( 2, 'phone',  'Main phone',    '', 'optional',    'forbidden', '1',  '0'),
 161                          ( 2, 'phone',  'Cell phone',    '', 'optional',    'allowed',   '2',  '0'),
 162                          ( 2, 'phone',  'Office phone',  '', 'optional',    'allowed',   '3',  '0'),
 163                          ( 2, 'phone',  'Home phone',    '', 'optional',    'allowed',   '4',  '0'),
 164                          ( 2, 'phone',  'Office FAX',    '', 'optional',    'allowed',   '5',  '0'),
 165                          ( 2, 'phone',  'Home FAX',      '', 'optional',    'allowed',   '6',  '0'),
 166                          ( 3, 'url',    'Website',       '', 'recommended', 'allowed',   '1',  '0'),
 167                          ( 3, 'url',    'Blog',          '', 'optional',    'allowed',   '2',  '0'),
 168                          ( 3, 'url',    'Linkedin',      '', 'optional',    'forbidden', '3',  '0'),
 169                          ( 3, 'url',    'Twitter',       '', 'recommended', 'forbidden', '4',  '0'),
 170                          ( 3, 'url',    'Facebook',      '', 'recommended', 'forbidden', '5',  '0'),
 171                          ( 3, 'url',    'Myspace',       '', 'optional',    'forbidden', '6',  '0'),
 172                          ( 3, 'url',    'Flickr',        '', 'optional',    'forbidden', '7',  '0'),
 173                          ( 3, 'url',    'YouTube',       '', 'optional',    'forbidden', '8',  '0'),
 174                          ( 3, 'url',    'Digg',          '', 'optional',    'forbidden', '9',  '0'),
 175                          ( 3, 'url',    'StumbleUpon',   '', 'optional',    'forbidden', '10', '0'),
 176                          ( 4, 'word',   'Role',          '', 'optional',    'list',      '1',  '1'),
 177                          ( 4, 'word',   'Organization',  '', 'optional',    'forbidden', '2',  '1'),
 178                          ( 4, 'word',   'Division',      '', 'optional',    'forbidden', '3',  '1'),
 179                          ( 4, 'word',   'VAT ID',        '', 'optional',    'forbidden', '4',  '0'),
 180                          ( 5, 'text',   'Main address',  '', 'optional',    'forbidden', '1',  '0'),
 181                          ( 5, 'text',   'Home address',  '', 'optional',    'forbidden', '2',  '0'),
 182                          ( 6, 'text',   'About me',      '', 'recommended', 'forbidden', '1',  '0'),
 183                          ( 6, 'word',   'I like',        '', 'recommended', 'list',      '2',  '1'),
 184                          ( 6, 'word',   'I don\'t like', '', 'recommended', 'list',      '3',  '1');" );
 185      task_end();
 186  
 187  
 188      // don't change order of the following two functions as countries has relations to currencies
 189      create_default_currencies();
 190      create_default_countries();
 191  
 192      create_default_regions();
 193      create_default_subregions();
 194  
 195  
 196      task_begin( 'Creating admin user... ' );
 197      global $timestamp, $admin_email, $default_locale, $default_country, $install_password;
 198      global $random_password;
 199  
 200      // Set default country from locale code
 201      $country_code = explode( '-', $default_locale );
 202      if( isset( $country_code[1] ) )
 203      {
 204          $default_country = $DB->get_var( '
 205              SELECT ctry_ID
 206                FROM T_regional__country
 207               WHERE ctry_code = '.$DB->quote( strtolower( $country_code[1] ) ) );
 208      }
 209  
 210      if( !isset( $install_password ) )
 211      {
 212          $random_password = generate_random_passwd(); // no ambiguous chars
 213      }
 214      else
 215      {
 216          $random_password = $install_password;
 217      }
 218  
 219      create_user( array(
 220              'login'  => 'admin',
 221              'level'  => 10,
 222              'gender' => 'M',
 223              'Group'  => $Group_Admins,
 224          ) );
 225      task_end();
 226  
 227      // Activating multiple sessions and email message form for administrator, and set other user settings
 228      task_begin( 'Set settings for administrator user... ' );
 229      $DB->query( "
 230          INSERT INTO T_users__usersettings ( uset_user_ID, uset_name, uset_value )
 231          VALUES ( 1, 'login_multiple_sessions', '1' ),
 232                  ( 1, 'enable_email', '1' ),
 233                  ( 1, 'created_fromIPv4', '".ip2int( '127.0.0.1' )."' ),
 234                  ( 1, 'user_domain', 'localhost' )" );
 235      task_end();
 236  
 237      // Creating a default additional info for administrator
 238      task_begin( 'Creating default additional info for administrator... ' );
 239      $DB->query( "
 240          INSERT INTO T_users__fields ( uf_user_ID, uf_ufdf_ID, uf_varchar )
 241          VALUES ( 1, 22, 'Site administrator' ),
 242                       ( 1, 22, 'Moderator' ),
 243                       ( 1, 12, '".$baseurl."' )" );
 244      task_end();
 245  
 246  
 247      // added in Phoenix-Alpha
 248      task_begin( 'Creating default Post Types... ' );
 249      $DB->query( "
 250          INSERT INTO T_items__type ( ptyp_ID, ptyp_name )
 251          VALUES ( 1, 'Post' ),
 252                       ( 1000, 'Page' ),
 253                       ( 1500, 'Intro-Main' ),
 254                       ( 1520, 'Intro-Cat' ),
 255                       ( 1530, 'Intro-Tag' ),
 256                       ( 1570, 'Intro-Sub' ),
 257                       ( 1600, 'Intro-All' ),
 258                       ( 2000, 'Podcast' ),
 259                       ( 3000, 'Sidebar link' ),
 260                       ( 4000, 'Advertisement' ),
 261                       ( 5000, 'Reserved' ) " );
 262      task_end();
 263  
 264  
 265      // added in Phoenix-Beta
 266      task_begin( 'Creating default file types... ' );
 267      // Contribs: feel free to add more types here...
 268      // TODO: dh> shouldn't they get localized to the app's default locale? fp> ftyp_name, yes
 269      $DB->query( "INSERT INTO T_filetypes
 270              (ftyp_ID, ftyp_extensions, ftyp_name, ftyp_mimetype, ftyp_icon, ftyp_viewtype, ftyp_allowed)
 271          VALUES
 272              (1, 'gif', 'GIF image', 'image/gif', 'file_image', 'image', 'any'),
 273              (2, 'png', 'PNG image', 'image/png', 'file_image', 'image', 'any'),
 274              (3, 'jpg jpeg', 'JPEG image', 'image/jpeg', 'file_image', 'image', 'any'),
 275              (4, 'txt', 'Text file', 'text/plain', 'file_document', 'text', 'registered'),
 276              (5, 'htm html', 'HTML file', 'text/html', 'file_www', 'browser', 'admin'),
 277              (6, 'pdf', 'PDF file', 'application/pdf', 'file_pdf', 'browser', 'registered'),
 278              (7, 'doc docx', 'Microsoft Word file', 'application/msword', 'file_doc', 'external', 'registered'),
 279              (8, 'xls xlsx', 'Microsoft Excel file', 'application/vnd.ms-excel', 'file_xls', 'external', 'registered'),
 280              (9, 'ppt pptx', 'Powerpoint', 'application/vnd.ms-powerpoint', 'file_ppt', 'external', 'registered'),
 281              (10, 'pps', 'Slideshow', 'pps', 'file_pps', 'external', 'registered'),
 282              (11, 'zip', 'ZIP archive', 'application/zip', 'file_zip', 'external', 'registered'),
 283              (12, 'php php3 php4 php5 php6', 'PHP script', 'application/x-httpd-php', 'file_php', 'text', 'admin'),
 284              (13, 'css', 'Style sheet', 'text/css', '', 'text', 'registered'),
 285              (14, 'mp3', 'MPEG audio file', 'audio/mpeg', 'file_sound', 'browser', 'registered'),
 286              (15, 'm4a', 'MPEG audio file', 'audio/x-m4a', 'file_sound', 'browser', 'registered'),
 287              (16, 'mp4 f4v', 'MPEG video', 'video/mp4', 'file_video', 'browser', 'registered'),
 288              (17, 'mov', 'Quicktime video', 'video/quicktime', 'file_video', 'browser', 'registered'),
 289              (18, 'm4v', 'MPEG video file', 'video/x-m4v', 'file_video', 'browser', 'registered'),
 290              (19, 'flv', 'Flash video file', 'video/x-flv', 'file_video', 'browser', 'registered'),
 291              (20, 'swf', 'Flash video file', 'application/x-shockwave-flash', 'file_video', 'browser', 'registered')
 292          " );
 293      task_end();
 294  
 295      // Insert default locales into T_locales.
 296      create_default_locales();
 297  
 298      // Insert default settings into T_settings.
 299      create_default_settings();
 300  
 301      // create default scheduled jobs
 302      create_default_jobs();
 303  
 304      task_begin( 'Creating default "help" slug... ' );
 305      $DB->query( '
 306          INSERT INTO T_slug( slug_title, slug_type )
 307          VALUES( "help", "help" )', 'Add "help" slug' );
 308      task_end();
 309  
 310      install_basic_skins();
 311  
 312      install_basic_plugins();
 313  
 314      return true;
 315  }
 316  
 317  /**
 318   * Create default currencies
 319   *
 320   */
 321  function create_default_currencies( $table_name = 'T_regional__currency' )
 322  {
 323      global $DB;
 324  
 325      task_begin( 'Creating default currencies... ' );
 326      $DB->query( "
 327          INSERT INTO $table_name (curr_ID, curr_code, curr_shortcut, curr_name)
 328           VALUES
 329              (1, 'AFN', '&#x60b;', 'Afghani'),
 330              (2, 'EUR', '&euro;', 'Euro'),
 331              (3, 'ALL', 'Lek', 'Lek'),
 332              (4, 'DZD', 'DZD', 'Algerian Dinar'),
 333              (5, 'USD', '$', 'US Dollar'),
 334              (6, 'AOA', 'AOA', 'Kwanza'),
 335              (7, 'XCD', '$', 'East Caribbean Dollar'),
 336              (8, 'ARS', '$', 'Argentine Peso'),
 337              (9, 'AMD', 'AMD', 'Armenian Dram'),
 338              (10, 'AWG', '&fnof;', 'Aruban Guilder'),
 339              (11, 'AUD', '$', 'Australian Dollar'),
 340              (12, 'AZN', '&#x43c;&#x430;&#x43d;', 'Azerbaijanian Manat'),
 341              (13, 'BSD', '$', 'Bahamian Dollar'),
 342              (14, 'BHD', 'BHD', 'Bahraini Dinar'),
 343              (15, 'BDT', 'BDT', 'Taka'),
 344              (16, 'BBD', '$', 'Barbados Dollar'),
 345              (17, 'BYR', 'p.', 'Belarussian Ruble'),
 346              (18, 'BZD', 'BZ$', 'Belize Dollar'),
 347              (19, 'XOF', 'XOF', 'CFA Franc BCEAO'),
 348              (20, 'BMD', '$', 'Bermudian Dollar'),
 349              (21, 'BAM', 'KM', 'Convertible Marks'),
 350              (22, 'BWP', 'P', 'Pula'),
 351              (23, 'NOK', 'kr', 'Norwegian Krone'),
 352              (24, 'BRL', 'R$', 'Brazilian Real'),
 353              (25, 'BND', '$', 'Brunei Dollar'),
 354              (26, 'BGN', '&#x43b;&#x432;', 'Bulgarian Lev'),
 355              (27, 'BIF', 'BIF', 'Burundi Franc'),
 356              (28, 'KHR', '&#x17db;', 'Riel'),
 357              (29, 'XAF', 'XAF', 'CFA Franc BEAC'),
 358              (30, 'CAD', '$', 'Canadian Dollar'),
 359              (31, 'CVE', 'CVE', 'Cape Verde Escudo'),
 360              (32, 'KYD', '$', 'Cayman Islands Dollar'),
 361              (33, 'CNY', '&yen;', 'Yuan Renminbi'),
 362              (34, 'KMF', 'KMF', 'Comoro Franc'),
 363              (35, 'CDF', 'CDF', 'Congolese Franc'),
 364              (36, 'NZD', '$', 'New Zealand Dollar'),
 365              (37, 'CRC', '&#x20a1;', 'Costa Rican Colon'),
 366              (38, 'HRK', 'kn', 'Croatian Kuna'),
 367              (39, 'CZK', 'K&#x10d;', 'Czech Koruna'),
 368              (40, 'DKK', 'kr', 'Danish Krone'),
 369              (41, 'DJF', 'DJF', 'Djibouti Franc'),
 370              (42, 'DOP', 'RD$', 'Dominican Peso'),
 371              (43, 'EGP', '&pound;', 'Egyptian Pound'),
 372              (44, 'ERN', 'ERN', 'Nakfa'),
 373              (45, 'EEK', 'EEK', 'Kroon'),
 374              (46, 'ETB', 'ETB', 'Ethiopian Birr'),
 375              (47, 'FKP', '&pound;', 'Falkland Islands Pound'),
 376              (48, 'FJD', '$', 'Fiji Dollar'),
 377              (49, 'XPF', 'XPF', 'CFP Franc'),
 378              (50, 'GMD', 'GMD', 'Dalasi'),
 379              (51, 'GEL', 'GEL', 'Lari'),
 380              (52, 'GHS', 'GHS', 'Cedi'),
 381              (53, 'GIP', '&pound;', 'Gibraltar Pound'),
 382              (54, 'GTQ', 'Q', 'Quetzal'),
 383              (55, 'GBP', '&pound;', 'Pound Sterling'),
 384              (56, 'GNF', 'GNF', 'Guinea Franc'),
 385              (57, 'GYD', '$', 'Guyana Dollar'),
 386              (58, 'HNL', 'L', 'Lempira'),
 387              (59, 'HKD', '$', 'Hong Kong Dollar'),
 388              (60, 'HUF', 'Ft', 'Forint'),
 389              (61, 'ISK', 'kr', 'Iceland Krona'),
 390              (62, 'INR', 'Rs', 'Indian Rupee'),
 391              (63, 'IDR', 'Rp', 'Rupiah'),
 392              (64, 'IRR', '&#xfdfc;', 'Iranian Rial'),
 393              (65, 'IQD', 'IQD', 'Iraqi Dinar'),
 394              (66, 'ILS', '&#x20aa;', 'New Israeli Sheqel'),
 395              (67, 'JMD', 'J$', 'Jamaican Dollar'),
 396              (68, 'JPY', '&yen;', 'Yen'),
 397              (69, 'JOD', 'JOD', 'Jordanian Dinar'),
 398              (70, 'KZT', '&#x43b;&#x432;', 'Tenge'),
 399              (71, 'KES', 'KES', 'Kenyan Shilling'),
 400              (72, 'KPW', '&#x20a9;', 'North Korean Won'),
 401              (73, 'KRW', '&#x20a9;', 'Won'),
 402              (74, 'KWD', 'KWD', 'Kuwaiti Dinar'),
 403              (75, 'KGS', '&#x43b;&#x432;', 'Som'),
 404              (76, 'LAK', '&#x20ad;', 'Kip'),
 405              (77, 'LVL', 'Ls', 'Latvian Lats'),
 406              (78, 'LBP', '&pound;', 'Lebanese Pound'),
 407              (79, 'LRD', '$', 'Liberian Dollar'),
 408              (80, 'LYD', 'LYD', 'Libyan Dinar'),
 409              (81, 'CHF', 'CHF', 'Swiss Franc'),
 410              (82, 'LTL', 'Lt', 'Lithuanian Litas'),
 411              (83, 'MOP', 'MOP', 'Pataca'),
 412              (84, 'MKD', '&#x434;&#x435;&#x43d;', 'Denar'),
 413              (85, 'MGA', 'MGA', 'Malagasy Ariary'),
 414              (86, 'MWK', 'MWK', 'Kwacha'),
 415              (87, 'MYR', 'RM', 'Malaysian Ringgit'),
 416              (88, 'MVR', 'MVR', 'Rufiyaa'),
 417              (89, 'MRO', 'MRO', 'Ouguiya'),
 418              (90, 'MUR', 'Rs', 'Mauritius Rupee'),
 419              (91, 'MDL', 'MDL', 'Moldovan Leu'),
 420              (92, 'MNT', '&#x20ae;', 'Tugrik'),
 421              (93, 'MAD', 'MAD', 'Moroccan Dirham'),
 422              (94, 'MZN', 'MT', 'Metical'),
 423              (95, 'MMK', 'MMK', 'Kyat'),
 424              (96, 'NPR', 'Rs', 'Nepalese Rupee'),
 425              (97, 'ANG', '&fnof;', 'Netherlands Antillian Guilder'),
 426              (98, 'NIO', 'C$', 'Cordoba Oro'),
 427              (99, 'NGN', '&#x20a6;', 'Naira'),
 428              (100, 'OMR', '&#xfdfc;', 'Rial Omani'),
 429              (101, 'PKR', 'Rs', 'Pakistan Rupee'),
 430              (102, 'PGK', 'PGK', 'Kina'),
 431              (103, 'PYG', 'Gs', 'Guarani'),
 432              (104, 'PEN', 'S/.', 'Nuevo Sol'),
 433              (105, 'PHP', 'Php', 'Philippine Peso'),
 434              (106, 'PLN', 'z&#x142;', 'Zloty'),
 435              (107, 'QAR', '&#xfdfc;', 'Qatari Rial'),
 436              (108, 'RON', 'lei', 'New Leu'),
 437              (109, 'RUB', '&#x440;&#x443;&#x431;', 'Russian Ruble'),
 438              (110, 'RWF', 'RWF', 'Rwanda Franc'),
 439              (111, 'SHP', '&pound;', 'Saint Helena Pound'),
 440              (112, 'WST', 'WST', 'Tala'),
 441              (113, 'STD', 'STD', 'Dobra'),
 442              (114, 'SAR', '&#xfdfc;', 'Saudi Riyal'),
 443              (115, 'RSD', '&#x414;&#x438;&#x43d;.', 'Serbian Dinar'),
 444              (116, 'SCR', 'Rs', 'Seychelles Rupee'),
 445              (117, 'SLL', 'SLL', 'Leone'),
 446              (118, 'SGD', '$', 'Singapore Dollar'),
 447              (119, 'SBD', '$', 'Solomon Islands Dollar'),
 448              (120, 'SOS', 'S', 'Somali Shilling'),
 449              (121, 'ZAR', 'R', 'Rand'),
 450              (122, 'LKR', 'Rs', 'Sri Lanka Rupee'),
 451              (123, 'SDG', 'SDG', 'Sudanese Pound'),
 452              (124, 'SRD', '$', 'Surinam Dollar'),
 453              (125, 'SZL', 'SZL', 'Lilangeni'),
 454              (126, 'SEK', 'kr', 'Swedish Krona'),
 455              (127, 'SYP', '&pound;', 'Syrian Pound'),
 456              (128, 'TWD', '$', 'New Taiwan Dollar'),
 457              (129, 'TJS', 'TJS', 'Somoni'),
 458              (130, 'TZS', 'TZS', 'Tanzanian Shilling'),
 459              (131, 'THB', 'THB', 'Baht'),
 460              (132, 'TOP', 'TOP', 'Pa'),
 461              (133, 'TTD', 'TT$', 'Trinidad and Tobago Dollar'),
 462              (134, 'TND', 'TND', 'Tunisian Dinar'),
 463              (135, 'TRY', 'TL', 'Turkish Lira'),
 464              (136, 'TMT', 'TMT', 'Manat'),
 465              (137, 'UGX', 'UGX', 'Uganda Shilling'),
 466              (138, 'UAH', '&#x20b4;', 'Hryvnia'),
 467              (139, 'AED', 'AED', 'UAE Dirham'),
 468              (140, 'UZS', '&#x43b;&#x432;', 'Uzbekistan Sum'),
 469              (141, 'VUV', 'VUV', 'Vatu'),
 470              (142, 'VEF', 'Bs', 'Bolivar Fuerte'),
 471              (143, 'VND', '&#x20ab;', 'Dong'),
 472              (144, 'YER', '&#xfdfc;', 'Yemeni Rial'),
 473              (145, 'ZMK', 'ZMK', 'Zambian Kwacha'),
 474              (146, 'ZWL', 'Z$', 'Zimbabwe Dollar'),
 475              (147, 'XAU', 'XAU', 'Gold'),
 476              (148, 'XBA', 'XBA', 'EURCO'),
 477              (149, 'XBB', 'XBB', 'European Monetary Unit'),
 478              (150, 'XBC', 'XBC', 'European Unit of Account 9'),
 479              (151, 'XBD', 'XBD', 'European Unit of Account 17'),
 480              (152, 'XDR', 'XDR', 'SDR'),
 481              (153, 'XPD', 'XPD', 'Palladium'),
 482              (154, 'XPT', 'XPT', 'Platinum'),
 483              (155, 'XAG', 'XAG', 'Silver'),
 484              (156, 'COP', '$', 'Colombian peso'),
 485              (157, 'CUP', '$', 'Cuban peso'),
 486              (158, 'SVC', 'SVC', 'Salvadoran colon'),
 487              (159, 'CLP', '$', 'Chilean peso'),
 488              (160, 'HTG', 'G', 'Haitian gourde'),
 489              (161, 'MXN', '$', 'Mexican peso'),
 490              (162, 'PAB', 'PAB', 'Panamanian balboa'),
 491              (163, 'UYU', '$', 'Uruguayan peso')
 492              " );
 493      task_end();
 494  }
 495  
 496  /**
 497   * Create default countries with relations to currencies
 498   *
 499   */
 500  function create_default_countries( $table_name = 'T_regional__country', $set_preferred_country = true )
 501  {
 502      global $DB, $current_locale;
 503  
 504      task_begin( 'Creating default countries... ' );
 505      $DB->query( "
 506          INSERT INTO $table_name ( ctry_ID, ctry_code, ctry_name, ctry_curr_ID)
 507          VALUES
 508              (1, 'af', 'Afghanistan', 1),
 509              (2, 'ax', 'Aland Islands', 2),
 510              (3, 'al', 'Albania', 3),
 511              (4, 'dz', 'Algeria', 4),
 512              (5, 'as', 'American Samoa', 5),
 513              (6, 'ad', 'Andorra', 2),
 514              (7, 'ao', 'Angola', 6),
 515              (8, 'ai', 'Anguilla', 7),
 516              (9, 'aq', 'Antarctica', NULL),
 517              (10, 'ag', 'Antigua And Barbuda', 7),
 518              (11, 'ar', 'Argentina', 8),
 519              (12, 'am', 'Armenia', 9),
 520              (13, 'aw', 'Aruba', 10),
 521              (14, 'au', 'Australia', 11),
 522              (15, 'at', 'Austria', 2),
 523              (16, 'az', 'Azerbaijan', 12),
 524              (17, 'bs', 'Bahamas', 13),
 525              (18, 'bh', 'Bahrain', 14),
 526              (19, 'bd', 'Bangladesh', 15),
 527              (20, 'bb', 'Barbados', 16),
 528              (21, 'by', 'Belarus', 17),
 529              (22, 'be', 'Belgium', 2),
 530              (23, 'bz', 'Belize', 18),
 531              (24, 'bj', 'Benin', 19),
 532              (25, 'bm', 'Bermuda', 20),
 533              (26, 'bt', 'Bhutan', 62),
 534              (27, 'bo', 'Bolivia', NULL),
 535              (28, 'ba', 'Bosnia And Herzegovina', 21),
 536              (29, 'bw', 'Botswana', 22),
 537              (30, 'bv', 'Bouvet Island', 23),
 538              (31, 'br', 'Brazil', 24),
 539              (32, 'io', 'British Indian Ocean Territory', 5),
 540              (33, 'bn', 'Brunei Darussalam', 25),
 541              (34, 'bg', 'Bulgaria', 26),
 542              (35, 'bf', 'Burkina Faso', 19),
 543              (36, 'bi', 'Burundi', 27),
 544              (37, 'kh', 'Cambodia', 28),
 545              (38, 'cm', 'Cameroon', 29),
 546              (39, 'ca', 'Canada', 30),
 547              (40, 'cv', 'Cape Verde', 31),
 548              (41, 'ky', 'Cayman Islands', 32),
 549              (42, 'cf', 'Central African Republic', 29),
 550              (43, 'td', 'Chad', 29),
 551              (44, 'cl', 'Chile', 159),
 552              (45, 'cn', 'China', 33),
 553              (46, 'cx', 'Christmas Island', 11),
 554              (47, 'cc', 'Cocos Islands', 11),
 555              (48, 'co', 'Colombia', 156),
 556              (49, 'km', 'Comoros', 34),
 557              (50, 'cg', 'Congo', 29),
 558              (51, 'cd', 'Congo Republic', 35),
 559              (52, 'ck', 'Cook Islands', 36),
 560              (53, 'cr', 'Costa Rica', 37),
 561              (54, 'ci', 'Cote Divoire', 19),
 562              (55, 'hr', 'Croatia', 38),
 563              (56, 'cu', 'Cuba', 157),
 564              (57, 'cy', 'Cyprus', 2),
 565              (58, 'cz', 'Czech Republic', 39),
 566              (59, 'dk', 'Denmark', 40),
 567              (60, 'dj', 'Djibouti', 41),
 568              (61, 'dm', 'Dominica', 7),
 569              (62, 'do', 'Dominican Republic', 42),
 570              (63, 'ec', 'Ecuador', 5),
 571              (64, 'eg', 'Egypt', 43),
 572              (65, 'sv', 'El Salvador', 158),
 573              (66, 'gq', 'Equatorial Guinea', 29),
 574              (67, 'er', 'Eritrea', 44),
 575              (68, 'ee', 'Estonia', 45),
 576              (69, 'et', 'Ethiopia', 46),
 577              (70, 'fk', 'Falkland Islands (Malvinas)', 47),
 578              (71, 'fo', 'Faroe Islands', 40),
 579              (72, 'fj', 'Fiji', 48),
 580              (73, 'fi', 'Finland', 2),
 581              (74, 'fr', 'France', 2),
 582              (75, 'gf', 'French Guiana', 2),
 583              (76, 'pf', 'French Polynesia', 49),
 584              (77, 'tf', 'French Southern Territories', 2),
 585              (78, 'ga', 'Gabon', 29),
 586              (79, 'gm', 'Gambia', 50),
 587              (80, 'ge', 'Georgia', 51),
 588              (81, 'de', 'Germany', 2),
 589              (82, 'gh', 'Ghana', 52),
 590              (83, 'gi', 'Gibraltar', 53),
 591              (84, 'gr', 'Greece', 2),
 592              (85, 'gl', 'Greenland', 40),
 593              (86, 'gd', 'Grenada', 7),
 594              (87, 'gp', 'Guadeloupe', 2),
 595              (88, 'gu', 'Guam', 5),
 596              (89, 'gt', 'Guatemala', 54),
 597              (90, 'gg', 'Guernsey', 55),
 598              (91, 'gn', 'Guinea', 56),
 599              (92, 'gw', 'Guinea-bissau', 19),
 600              (93, 'gy', 'Guyana', 57),
 601              (94, 'ht', 'Haiti', 160),
 602              (95, 'hm', 'Heard Island And Mcdonald Islands', 11),
 603              (96, 'va', 'Holy See (vatican City State)', 2),
 604              (97, 'hn', 'Honduras', 58),
 605              (98, 'hk', 'Hong Kong', 59),
 606              (99, 'hu', 'Hungary', 60),
 607              (100, 'is', 'Iceland', 61),
 608              (101, 'in', 'India', 62),
 609              (102, 'id', 'Indonesia', 63),
 610              (103, 'ir', 'Iran', 64),
 611              (104, 'iq', 'Iraq', 65),
 612              (105, 'ie', 'Ireland', 2),
 613              (106, 'im', 'Isle Of Man', NULL),
 614              (107, 'il', 'Israel', 66),
 615              (108, 'it', 'Italy', 2),
 616              (109, 'jm', 'Jamaica', 67),
 617              (110, 'jp', 'Japan', 68),
 618              (111, 'je', 'Jersey', 55),
 619              (112, 'jo', 'Jordan', 69),
 620              (113, 'kz', 'Kazakhstan', 70),
 621              (114, 'ke', 'Kenya', 71),
 622              (115, 'ki', 'Kiribati', 11),
 623              (116, 'kp', 'Korea', 72),
 624              (117, 'kr', 'Korea', 73),
 625              (118, 'kw', 'Kuwait', 74),
 626              (119, 'kg', 'Kyrgyzstan', 75),
 627              (120, 'la', 'Lao', 76),
 628              (121, 'lv', 'Latvia', 77),
 629              (122, 'lb', 'Lebanon', 78),
 630              (123, 'ls', 'Lesotho', 121),
 631              (124, 'lr', 'Liberia', 79),
 632              (125, 'ly', 'Libyan Arab Jamahiriya', 80),
 633              (126, 'li', 'Liechtenstein', 81),
 634              (127, 'lt', 'Lithuania', 82),
 635              (128, 'lu', 'Luxembourg', 2),
 636              (129, 'mo', 'Macao', 83),
 637              (130, 'mk', 'Macedonia', 84),
 638              (131, 'mg', 'Madagascar', 85),
 639              (132, 'mw', 'Malawi', 86),
 640              (133, 'my', 'Malaysia', 87),
 641              (134, 'mv', 'Maldives', 88),
 642              (135, 'ml', 'Mali', 19),
 643              (136, 'mt', 'Malta', 2),
 644              (137, 'mh', 'Marshall Islands', 5),
 645              (138, 'mq', 'Martinique', 2),
 646              (139, 'mr', 'Mauritania', 89),
 647              (140, 'mu', 'Mauritius', 90),
 648              (141, 'yt', 'Mayotte', 2),
 649              (142, 'mx', 'Mexico', 161),
 650              (143, 'fm', 'Micronesia', 2),
 651              (144, 'md', 'Moldova', 91),
 652              (145, 'mc', 'Monaco', 2),
 653              (146, 'mn', 'Mongolia', 92),
 654              (147, 'me', 'Montenegro', 2),
 655              (148, 'ms', 'Montserrat', 7),
 656              (149, 'ma', 'Morocco', 93),
 657              (150, 'mz', 'Mozambique', 94),
 658              (151, 'mm', 'Myanmar', 95),
 659              (152, 'na', 'Namibia', 121),
 660              (153, 'nr', 'Nauru', 11),
 661              (154, 'np', 'Nepal', 96),
 662              (155, 'nl', 'Netherlands', 2),
 663              (156, 'an', 'Netherlands Antilles', 97),
 664              (157, 'nc', 'New Caledonia', 49),
 665              (158, 'nz', 'New Zealand', 36),
 666              (159, 'ni', 'Nicaragua', 98),
 667              (160, 'ne', 'Niger', 19),
 668              (161, 'ng', 'Nigeria', 99),
 669              (162, 'nu', 'Niue', 36),
 670              (163, 'nf', 'Norfolk Island', 11),
 671              (164, 'mp', 'Northern Mariana Islands', 5),
 672              (165, 'no', 'Norway', 23),
 673              (166, 'om', 'Oman', 100),
 674              (167, 'pk', 'Pakistan', 101),
 675              (168, 'pw', 'Palau', 5),
 676              (169, 'ps', 'Palestinian Territory', NULL),
 677              (170, 'pa', 'Panama', 162),
 678              (171, 'pg', 'Papua New Guinea', 102),
 679              (172, 'py', 'Paraguay', 103),
 680              (173, 'pe', 'Peru', 104),
 681              (174, 'ph', 'Philippines', 105),
 682              (175, 'pn', 'Pitcairn', 36),
 683              (176, 'pl', 'Poland', 106),
 684              (177, 'pt', 'Portugal', 2),
 685              (178, 'pr', 'Puerto Rico', 5),
 686              (179, 'qa', 'Qatar', 107),
 687              (180, 're', 'Reunion', 2),
 688              (181, 'ro', 'Romania', 108),
 689              (182, 'ru', 'Russian Federation', 109),
 690              (183, 'rw', 'Rwanda', 110),
 691              (184, 'bl', 'Saint Barthelemy', 2),
 692              (185, 'sh', 'Saint Helena', 111),
 693              (186, 'kn', 'Saint Kitts And Nevis', 7),
 694              (187, 'lc', 'Saint Lucia', 7),
 695              (188, 'mf', 'Saint Martin', 2),
 696              (189, 'pm', 'Saint Pierre And Miquelon', 2),
 697              (190, 'vc', 'Saint Vincent And The Grenadines', 7),
 698              (191, 'ws', 'Samoa', 112),
 699              (192, 'sm', 'San Marino', 2),
 700              (193, 'st', 'Sao Tome And Principe', 113),
 701              (194, 'sa', 'Saudi Arabia', 114),
 702              (195, 'sn', 'Senegal', 19),
 703              (196, 'rs', 'Serbia', 115),
 704              (197, 'sc', 'Seychelles', 116),
 705              (198, 'sl', 'Sierra Leone', 117),
 706              (199, 'sg', 'Singapore', 118),
 707              (200, 'sk', 'Slovakia', 2),
 708              (201, 'si', 'Slovenia', 2),
 709              (202, 'sb', 'Solomon Islands', 119),
 710              (203, 'so', 'Somalia', 120),
 711              (204, 'za', 'South Africa', 121),
 712              (205, 'gs', 'South Georgia', NULL),
 713              (206, 'es', 'Spain', 2),
 714              (207, 'lk', 'Sri Lanka', 122),
 715              (208, 'sd', 'Sudan', 123),
 716              (209, 'sr', 'Suriname', 124),
 717              (210, 'sj', 'Svalbard And Jan Mayen', 23),
 718              (211, 'sz', 'Swaziland', 125),
 719              (212, 'se', 'Sweden', 126),
 720              (213, 'ch', 'Switzerland', 81),
 721              (214, 'sy', 'Syrian Arab Republic', 127),
 722              (215, 'tw', 'Taiwan, Province Of China', 128),
 723              (216, 'tj', 'Tajikistan', 129),
 724              (217, 'tz', 'Tanzania', 130),
 725              (218, 'th', 'Thailand', 131),
 726              (219, 'tl', 'Timor-leste', 5),
 727              (220, 'tg', 'Togo', 19),
 728              (221, 'tk', 'Tokelau', 36),
 729              (222, 'to', 'Tonga', 132),
 730              (223, 'tt', 'Trinidad And Tobago', 133),
 731              (224, 'tn', 'Tunisia', 134),
 732              (225, 'tr', 'Turkey', 135),
 733              (226, 'tm', 'Turkmenistan', 136),
 734              (227, 'tc', 'Turks And Caicos Islands', 5),
 735              (228, 'tv', 'Tuvalu', 11),
 736              (229, 'ug', 'Uganda', 137),
 737              (230, 'ua', 'Ukraine', 138),
 738              (231, 'ae', 'United Arab Emirates', 139),
 739              (232, 'gb', 'United Kingdom', 55),
 740              (233, 'us', 'United States', 5),
 741              (234, 'um', 'United States Minor Outlying Islands', 5),
 742              (235, 'uy', 'Uruguay', 163),
 743              (236, 'uz', 'Uzbekistan', 140),
 744              (237, 'vu', 'Vanuatu', 141),
 745              (239, 've', 'Venezuela', 142),
 746              (240, 'vn', 'Viet Nam', 143),
 747              (241, 'vg', 'Virgin Islands, British', 5),
 748              (242, 'vi', 'Virgin Islands, U.s.', 5),
 749              (243, 'wf', 'Wallis And Futuna', 49),
 750              (244, 'eh', 'Western Sahara', 93),
 751              (245, 'ye', 'Yemen', 144),
 752              (246, 'zm', 'Zambia', 145),
 753              (247, 'zw', 'Zimbabwe', 146),
 754              (248, 'ct', 'Catalonia', 2)" );
 755  
 756      if( $set_preferred_country && !empty( $current_locale ) )
 757      {    // Set default preferred country from current locale
 758          $result = array();
 759          preg_match('#.*?-(.*)#', strtolower($current_locale),$result);
 760  
 761          $DB->query( "UPDATE $table_name
 762                                          SET ctry_preferred = 1
 763                                      WHERE ctry_code = '".$DB->escape($result[1])."'");
 764      }
 765      task_end();
 766  }
 767  
 768  /**
 769   * Create default regions
 770   *
 771   */
 772  function create_default_regions()
 773  {
 774      global $DB, $current_charset;
 775  
 776      task_begin( 'Creating default regions... ' );
 777      $DB->query( convert_charset("
 778          INSERT INTO T_regional__region ( rgn_ID, rgn_ctry_ID, rgn_code, rgn_name )
 779          VALUES".
 780              /* United States */"
 781              (1, 233, 'AL', 'Alabama'),
 782              (2, 233, 'AK', 'Alaska'),
 783              (3, 233, 'AZ', 'Arizona'),
 784              (4, 233, 'AR', 'Arkansas'),
 785              (5, 233, 'CA', 'California'),
 786              (6, 233, 'CO', 'Colorado'),
 787              (7, 233, 'CT', 'Connecticut'),
 788              (8, 233, 'DE', 'Delaware'),
 789              (9, 233, 'FL', 'Florida'),
 790              (10, 233, 'GA', 'Georgia'),
 791              (11, 233, 'HI', 'Hawaii'),
 792              (12, 233, 'ID', 'Idaho'),
 793              (13, 233, 'IL', 'Illinois'),
 794              (14, 233, 'IN', 'Indiana'),
 795              (15, 233, 'IA', 'Iowa'),
 796              (16, 233, 'KS', 'Kansas'),
 797              (17, 233, 'KY', 'Kentucky'),
 798              (18, 233, 'LA', 'Louisiana'),
 799              (19, 233, 'ME', 'Maine'),
 800              (20, 233, 'MD', 'Maryland'),
 801              (21, 233, 'MA', 'Massachusetts'),
 802              (22, 233, 'MI', 'Michigan'),
 803              (23, 233, 'MN', 'Minnesota'),
 804              (24, 233, 'MS', 'Mississippi'),
 805              (25, 233, 'MO', 'Missouri'),
 806              (26, 233, 'MT', 'Montana'),
 807              (27, 233, 'NE', 'Nebraska'),
 808              (28, 233, 'NV', 'Nevada'),
 809              (29, 233, 'NH', 'New Hampshire'),
 810              (30, 233, 'NJ', 'New Jersey'),
 811              (31, 233, 'NM', 'New Mexico'),
 812              (32, 233, 'NY', 'New York'),
 813              (33, 233, 'NC', 'North Carolina'),
 814              (34, 233, 'ND', 'North Dakota'),
 815              (35, 233, 'OH', 'Ohio'),
 816              (36, 233, 'OK', 'Oklahoma'),
 817              (37, 233, 'OR', 'Oregon'),
 818              (38, 233, 'PA', 'Pennsylvania'),
 819              (39, 233, 'RI', 'Rhode Island'),
 820              (40, 233, 'SC', 'South Carolina'),
 821              (41, 233, 'SD', 'South Dakota'),
 822              (42, 233, 'TN', 'Tennessee'),
 823              (43, 233, 'TX', 'Texas'),
 824              (44, 233, 'UT', 'Utah'),
 825              (45, 233, 'VT', 'Vermont'),
 826              (46, 233, 'VA', 'Virginia'),
 827              (47, 233, 'WA', 'Washington'),
 828              (48, 233, 'WV', 'West Virginia'),
 829              (49, 233, 'WI', 'Wisconsin'),
 830              (50, 233, 'WY', 'Wyoming'),".
 831              /* France */"
 832              (51, 74, '42', 'Alsace'),
 833              (52, 74, '72', 'Aquitaine'),
 834              (53, 74, '83', 'Auvergne'),
 835              (54, 74, '26', 'Bourgogne'),
 836              (55, 74, '53', 'Bretagne'),
 837              (56, 74, '24', 'Centre'),
 838              (57, 74, '21', 'Champagne-Ardenne'),
 839              (58, 74, '94', 'Corse'),
 840              (59, 74, '43', 'Franche-Comt\xE9'),
 841              (60, 74, '11', '\xCEle-de-France'),
 842              (61, 74, '91', 'Languedoc-Roussillon'),
 843              (62, 74, '74', 'Limousin'),
 844              (63, 74, '41', 'Lorraine'),
 845              (64, 74, '73', 'Midi-Pyr\xE9n\xE9es'),
 846              (65, 74, '31', 'Nord-Pas-de-Calais'),
 847              (66, 74, '25', 'Basse-Normandie'),
 848              (67, 74, '23', 'Haute-Normandie'),
 849              (68, 74, '52', 'Pays de la Loire'),
 850              (69, 74, '22', 'Picardie'),
 851              (70, 74, '54', 'Poitou-Charentes'),
 852              (71, 74, '93', 'Provence-Alpes-C\xF4te d\'Azur'),
 853              (72, 74, '82', 'Rh\xF4ne-Alpes'),
 854              (73, 74, '01', 'Guadeloupe'),
 855              (74, 74, '02', 'Martinique'),
 856              (75, 74, '03', 'Guyane'),
 857              (76, 74, '04', 'La R\xE9union'),
 858              (77, 74, '05', 'Mayotte'),
 859              (78, 74, '09', 'Outre-Mer'),
 860              (79, 74, '99', 'Monaco')", $current_charset, 'iso-8859-1' ) );
 861  
 862      task_end();
 863  }
 864  
 865  /**
 866   * Create default sub-regions
 867   *
 868   */
 869  function create_default_subregions()
 870  {
 871      global $DB, $current_charset;
 872  
 873      task_begin( 'Creating default sub-regions... ' );
 874      $DB->query( convert_charset("
 875          INSERT INTO T_regional__subregion ( subrg_ID, subrg_rgn_ID, subrg_code, subrg_name )
 876          VALUES".
 877              /* France */"
 878              (1, 72, '01', 'Ain'),
 879              (2, 69, '02', 'Aisne'),
 880              (3, 53, '03', 'Allier'),
 881              (4, 71, '04', 'Alpes-de-Haute-Provence'),
 882              (5, 71, '05', 'Hautes-Alpes'),
 883              (6, 71, '06', 'Alpes-Maritimes'),
 884              (7, 72, '07', 'Ard\xE8che'),
 885              (8, 57, '08', 'Ardennes'),
 886              (9, 64, '09', 'Ari\xE8ge'),
 887              (10, 57, '10', 'Aube'),
 888              (11, 61, '11', 'Aude'),
 889              (12, 64, '12', 'Aveyron'),
 890              (13, 71, '13', 'Bouches-du-Rh\xF4ne'),
 891              (14, 66, '14', 'Calvados'),
 892              (15, 53, '15', 'Cantal'),
 893              (16, 70, '16', 'Charente'),
 894              (17, 70, '17', 'Charente-Maritime'),
 895              (18, 56, '18', 'Cher'),
 896              (19, 62, '19', 'Corr\xE8ze'),
 897              (20, 58, '2A', 'Corse-du-Sud'),
 898              (21, 58, '2B', 'Haute-Corse'),
 899              (22, 54, '21', 'C\xF4te-d\'Or'),
 900              (23, 55, '22', 'C\xF4tes-d\'Armor'),
 901              (24, 62, '23', 'Creuse'),
 902              (25, 52, '24', 'Dordogne'),
 903              (26, 59, '25', 'Doubs'),
 904              (27, 72, '26', 'Dr\xF4me'),
 905              (28, 67, '27', 'Eure'),
 906              (29, 56, '28', 'Eure-et-Loir'),
 907              (30, 55, '29', 'Finist\xE8re'),
 908              (31, 61, '30', 'Gard'),
 909              (32, 64, '31', 'Haute-Garonne'),
 910              (33, 64, '32', 'Gers'),
 911              (34, 52, '33', 'Gironde'),
 912              (35, 61, '34', 'H\xE9rault'),
 913              (36, 55, '35', 'Ille-et-Vilaine'),
 914              (37, 56, '36', 'Indre'),
 915              (38, 56, '37', 'Indre-et-Loire'),
 916              (39, 72, '38', 'Is\xE8re'),
 917              (40, 59, '39', 'Jura'),
 918              (41, 52, '40', 'Landes'),
 919              (42, 56, '41', 'Loir-et-Cher'),
 920              (43, 72, '42', 'Loire'),
 921              (44, 53, '43', 'Haute-Loire'),
 922              (45, 68, '44', 'Loire-Atlantique'),
 923              (46, 56, '45', 'Loiret'),
 924              (47, 64, '46', 'Lot'),
 925              (48, 52, '47', 'Lot-et-Garonne'),
 926              (49, 61, '48', 'Loz\xE8re'),
 927              (50, 68, '49', 'Maine-et-Loire'),
 928              (51, 66, '50', 'Manche'),
 929              (52, 57, '51', 'Marne'),
 930              (53, 57, '52', 'Haute-Marne'),
 931              (54, 68, '53', 'Mayenne'),
 932              (55, 63, '54', 'Meurthe-et-Moselle'),
 933              (56, 63, '55', 'Meuse'),
 934              (57, 55, '56', 'Morbihan'),
 935              (58, 63, '57', 'Moselle'),
 936              (59, 54, '58', 'Ni\xE8vre'),
 937              (60, 65, '59', 'Nord'),
 938              (61, 69, '60', 'Oise'),
 939              (62, 66, '61', 'Orne'),
 940              (63, 65, '62', 'Pas-de-Calais'),
 941              (64, 53, '63', 'Puy-de-D\xF4me'),
 942              (65, 52, '64', 'Pyr\xE9n\xE9es-Atlantiques'),
 943              (66, 64, '65', 'Hautes-Pyr\xE9n\xE9es'),
 944              (67, 61, '66', 'Pyr\xE9n\xE9es-Orientales'),
 945              (68, 51, '67', 'Bas-Rhin'),
 946              (69, 51, '68', 'Haut-Rhin'),
 947              (70, 72, '69', 'Rh\xF4ne'),
 948              (71, 59, '70', 'Haute-Sa\xF4ne'),
 949              (72, 54, '71', 'Sa\xF4ne-et-Loire'),
 950              (73, 68, '72', 'Sarthe'),
 951              (74, 72, '73', 'Savoie'),
 952              (75, 72, '74', 'Haute-Savoie'),
 953              (76, 60, '75', 'Paris'),
 954              (77, 67, '76', 'Seine-Maritime'),
 955              (78, 60, '77', 'Seine-et-Marne'),
 956              (79, 60, '78', 'Yvelines'),
 957              (80, 70, '79', 'Deux-S\xE8vres'),
 958              (81, 69, '80', 'Somme'),
 959              (82, 64, '81', 'Tarn'),
 960              (83, 64, '82', 'Tarn-et-Garonne'),
 961              (84, 71, '83', 'Var'),
 962              (85, 71, '84', 'Vaucluse'),
 963              (86, 68, '85', 'Vend\xE9e'),
 964              (87, 70, '86', 'Vienne'),
 965              (88, 62, '87', 'Haute-Vienne'),
 966              (89, 63, '88', 'Vosges'),
 967              (90, 54, '89', 'Yonne'),
 968              (91, 59, '90', 'Territoire de Belfort'),
 969              (92, 60, '91', 'Essonne'),
 970              (93, 60, '92', 'Hauts-de-Seine'),
 971              (94, 60, '93', 'Seine-Saint-Denis'),
 972              (95, 60, '94', 'Val-de-Marne'),
 973              (96, 60, '95', 'Val-d\'Oise'),
 974              (97, 73, '971', 'Guadeloupe'),
 975              (98, 74, '972', 'Martinique'),
 976              (99, 75, '973', 'Guyane'),
 977              (100, 76, '974', 'La R\xE9union'),
 978              (101, 77, '976', 'Mayotte'),
 979              (102, 78, '975', 'Saint-Pierre-et-Miquelon'),
 980              (103, 78, '986', 'Wallis-et-Futuna'),
 981              (104, 78, '987', 'Polyn\xE9sie fran\xE7aise'),
 982              (105, 78, '988', 'Nouvelle-Cal\xE9donie'),
 983              (106, 79, '99', 'Monaco')", $current_charset, 'iso-8859-1') );
 984  
 985      task_end();
 986  }
 987  
 988  /**
 989   * Create default scheduled jobs that don't exist yet:
 990   * - Prune page cache
 991   * - Prune hit log & session log from stats
 992   * - Poll antispam blacklist
 993   *
 994   * @param boolean true if it's called from the ugrade script, false if it's called from the install script
 995   */
 996  function create_default_jobs( $is_upgrade = false )
 997  {
 998      global $DB, $localtimenow;
 999  
1000      // get tomorrow date
1001      $date = date2mysql( $localtimenow + 86400 );
1002      $ctsk_params = $DB->quote( 'N;' );
1003  
1004      $prune_pagecache_ctrl = 'cron/jobs/_prune_page_cache.job.php';
1005      $prune_sessions_ctrl = 'cron/jobs/_prune_hits_sessions.job.php';
1006      $poll_antispam_ctrl = 'cron/jobs/_antispam_poll.job.php';
1007      $process_hitlog_ctrl = 'cron/jobs/_process_hitlog.job.php';
1008      $messages_reminder_ctrl = 'cron/jobs/_unread_message_reminder.job.php';
1009      $activate_reminder_ctrl = 'cron/jobs/_activate_account_reminder.job.php';
1010      $moderation_reminder_ctrl = 'cron/jobs/_comment_moderation_reminder.job.php';
1011      $light_db_maintenance_ctrl = 'cron/jobs/_light_db_maintenance.job.php';
1012      $heavy_db_maintenance_ctrl = 'cron/jobs/_heavy_db_maintenance.job.php';
1013  
1014      // init insert values
1015      // run unread messages reminder in every 29 minutes
1016      $messages_reminder = "( ".$DB->quote( form_date( $date, '01:00:00' ) ).", 1740, ".$DB->quote( T_( 'Send reminders about unread messages' ) ).", ".$DB->quote( $messages_reminder_ctrl ).", ".$ctsk_params." )";
1017      // run activate account reminder in every 31 minutes
1018      $activate_reminder = "( ".$DB->quote( form_date( $date, '01:30:00' ) ).", 1860, ".$DB->quote( T_( 'Send reminders about not activated accounts' ) ).", ".$DB->quote( $activate_reminder_ctrl ).", ".$ctsk_params." )";
1019      $prune_pagecache = "( ".$DB->quote( form_date( $date, '02:00:00' ) ).", 86400, ".$DB->quote( T_( 'Prune old files from page cache' ) ).", ".$DB->quote( $prune_pagecache_ctrl ).", ".$ctsk_params." )";
1020      $process_hitlog = "( ".$DB->quote( form_date( $date, '02:30:00' ) ).", 86400, ".$DB->quote( T_( 'Process hit log' ) ).", ".$DB->quote( $process_hitlog_ctrl ).", ".$ctsk_params." )";
1021      $prune_sessions = "( ".$DB->quote( form_date( $date, '03:00:00' ) ).", 86400, ".$DB->quote( T_( 'Prune old hits & sessions (includes OPTIMIZE)' ) ).", ".$DB->quote( $prune_sessions_ctrl ).", ".$ctsk_params." )";
1022      $poll_antispam = "( ".$DB->quote( form_date( $date, '04:00:00' ) ).", 86400, ".$DB->quote( T_( 'Poll the antispam blacklist' ) ).", ".$DB->quote( $poll_antispam_ctrl ).", ".$ctsk_params." )";
1023      $moderation_reminder = "( ".$DB->quote( form_date( $date, '04:30:00' ) ).", 86400, ".$DB->quote( T_( 'Send reminders about comments awaiting moderation' ) ).", ".$DB->quote( $moderation_reminder_ctrl ).", ".$ctsk_params." )";
1024      $light_db_maintenance = "( ".$DB->quote( form_date( $date, '06:00:00' ) ).", 86400, ".$DB->quote( T_('Light DB maintenance (ANALYZE)') ).", ".$DB->quote( $light_db_maintenance_ctrl ).", ".$ctsk_params." )";
1025      $next_sunday = date2mysql( strtotime( 'next Sunday',  $localtimenow + 86400 ) );
1026      $heavy_db_maintenance = "( ".$DB->quote( form_date( $next_sunday, '06:30:00' ) ).", 604800, ".$DB->quote( T_('Heavy DB maintenance (CHECK & OPTIMIZE)') ).", ".$DB->quote( $heavy_db_maintenance_ctrl ).", ".$ctsk_params." )";
1027      $insert_values = array(
1028          $messages_reminder_ctrl => $messages_reminder,
1029          $activate_reminder_ctrl => $activate_reminder,
1030          $prune_pagecache_ctrl => $prune_pagecache,
1031          $process_hitlog_ctrl => $process_hitlog,
1032          $prune_sessions_ctrl => $prune_sessions,
1033          $poll_antispam_ctrl => $poll_antispam,
1034          $moderation_reminder_ctrl => $moderation_reminder,
1035          $light_db_maintenance_ctrl => $light_db_maintenance,
1036          $heavy_db_maintenance_ctrl => $heavy_db_maintenance );
1037      if( $is_upgrade )
1038      { // Check if these jobs already exist, and don't create another
1039          $SQL = new SQL();
1040          $SQL->SELECT( 'count(ctsk_ID) as job_number, ctsk_controller' );
1041          $SQL->FROM( 'T_cron__task' );
1042          $SQL->FROM_add( 'LEFT JOIN T_cron__log ON ctsk_ID = clog_ctsk_ID' );
1043          $SQL->WHERE( 'clog_status IS NULL' );
1044          $SQL->WHERE_and( 'ctsk_controller IN ( '.$DB->quote( array_keys( $insert_values ) ).' )' );
1045          $SQL->GROUP_BY( 'ctsk_controller' );
1046          $result = $DB->get_results( $SQL->get() );
1047          foreach( $result as $row )
1048          { // clear existing jobs insert values
1049              unset( $insert_values[$row->ctsk_controller] );
1050          }
1051      }
1052  
1053      $values = implode( ', ', $insert_values );
1054      if( empty( $values ) )
1055      { // nothing to create
1056          return;
1057      }
1058  
1059      task_begin( T_( 'Creating default scheduled jobs... ' ) );
1060      $DB->query( '
1061          INSERT INTO T_cron__task ( ctsk_start_datetime, ctsk_repeat_after, ctsk_name, ctsk_controller, ctsk_params )
1062          VALUES '.$values, T_( 'Create default scheduled jobs' ) );
1063      task_end();
1064  }
1065  
1066  /**
1067   * Create a new blog
1068   * This funtion has to handle all needed DB dependencies!
1069   *
1070   * @todo move this to Blog object (only half done here)
1071   */
1072  function create_blog(
1073      $blog_name,
1074      $blog_shortname,
1075      $blog_urlname,
1076      $blog_tagline = '',
1077      $blog_longdesc = '',
1078      $blog_skin_ID = 1,
1079      $kind = 'std', // standard blog; notorious variations: "photo", "group", "forum"
1080      $allow_rating_items = '',
1081      $use_inskin_login = 0,
1082      $blog_access_type = 'relative',
1083      $allow_html = true,
1084      $owner_user_ID = 1 )
1085  {
1086      global $default_locale, $test_install_all_features, $local_installation;
1087  
1088      $Blog = new Blog( NULL );
1089  
1090      $Blog->init_by_kind( $kind, $blog_name, $blog_shortname, $blog_urlname );
1091  
1092      $Blog->set( 'tagline', $blog_tagline );
1093      $Blog->set( 'longdesc', $blog_longdesc );
1094      $Blog->set( 'locale', $default_locale );
1095      $Blog->set( 'owner_user_ID', $owner_user_ID );
1096      $Blog->set_setting( 'normal_skin_ID', $blog_skin_ID );
1097      if( $local_installation )
1098      { // Turn off all ping plugins if the installation is local/test/intranet
1099          $Blog->set_setting( 'ping_plugins', '' );
1100      }
1101  
1102      $Blog->dbinsert();
1103  
1104      $Blog->set( 'access_type', $blog_access_type );
1105      if( $blog_access_type == 'relative' )
1106      {
1107          $Blog->set( 'siteurl', 'blog'.$Blog->ID.'.php' );
1108      }
1109      if( $test_install_all_features )
1110      {
1111          $allow_rating_items = 'any';
1112          $Blog->set_setting( 'skin'.$blog_skin_ID.'_bubbletip', '1' );
1113          $Blog->set_setting( 'skin'.$blog_skin_ID.'_gender_colored', '1' );
1114          $Blog->set_setting( 'in_skin_editing', '1' );
1115          $Blog->set_setting( 'location_country', 'required' );
1116          $Blog->set_setting( 'location_region', 'required' );
1117          $Blog->set_setting( 'location_subregion', 'required' );
1118          $Blog->set_setting( 'location_city', 'required' );
1119  
1120          if( $kind == 'manual' )
1121          {    // Set a posts ordering by 'post_order ASC'
1122              $Blog->set_setting( 'orderby', 'order' );
1123              $Blog->set_setting( 'orderdir', 'ASC' );
1124          }
1125      }
1126      if( $allow_rating_items != '' )
1127      {
1128          $Blog->set_setting( 'allow_rating_items', $allow_rating_items );
1129      }
1130      if( $use_inskin_login || $test_install_all_features )
1131      {
1132          $Blog->set_setting( 'in_skin_login', 1 );
1133      }
1134  
1135      if( !$allow_html )
1136      {
1137          $Blog->set_setting( 'allow_html_post', 0 );
1138          $Blog->set_setting( 'allow_html_comment', 0 );
1139      }
1140  
1141      $Blog->dbupdate();
1142  
1143      return $Blog->ID;
1144  }
1145  
1146  /**
1147   * Create a new User
1148   *
1149   * @param array Params
1150   * @return integer User ID
1151   */
1152  function create_user( $params = array() )
1153  {
1154      global $timestamp;
1155      global $random_password, $admin_email;
1156      global $default_locale, $default_country;
1157  
1158      $params = array_merge( array(
1159              'login'   => '',
1160              'pass'    => $random_password, // random
1161              'email'   => $admin_email,
1162              'status'  => 'autoactivated', // assume it's active
1163              'level'   => 0,
1164              'locale'  => $default_locale,
1165              'ctry_ID' => $default_country,
1166              'gender'  => 'M',
1167              'Group'   => NULL,
1168          ), $params );
1169  
1170      $User = new User();
1171      $User->set( 'login', $params['login'] );
1172      $User->set( 'pass', md5( $params['pass'] ) );
1173      $User->set_email( $params['email'] );
1174      $User->set( 'status', $params['status'] );
1175      $User->set( 'level', $params['level'] );
1176      $User->set( 'locale', $params['locale'] );
1177      if( !empty( $params['ctry_ID'] ) )
1178      { // Set country
1179          $User->set( 'ctry_ID', $params['ctry_ID'] );
1180      }
1181      $User->set( 'gender', $params['gender'] );
1182      $User->set_datecreated( $timestamp++ );
1183      $User->set_Group( $params['Group'] );
1184      $User->dbinsert( false );
1185  
1186      return $User->ID;
1187  }
1188  
1189  
1190  /**
1191   * This is called only for fresh installs and fills the tables with
1192   * demo/tutorial things.
1193   */
1194  function create_demo_contents()
1195  {
1196      global $baseurl, $new_db_version;
1197      global $random_password, $query;
1198      global $timestamp, $admin_email;
1199      global $Group_Admins, $Group_Privileged, $Group_Bloggers, $Group_Users, $Group_Suspect;
1200      global $blog_all_ID, $blog_a_ID, $blog_b_ID, $blog_linkblog_ID;
1201      global $DB;
1202      global $default_locale, $default_country;
1203      global $Plugins;
1204      global $test_install_all_features;
1205  
1206      /**
1207       * @var FileRootCache
1208       */
1209      global $FileRootCache;
1210  
1211      load_class( 'collections/model/_blog.class.php', 'Blog' );
1212      load_class( 'files/model/_file.class.php', 'File' );
1213      load_class( 'files/model/_filetype.class.php', 'FileType' );
1214      load_class( 'links/model/_link.class.php', 'Link' );
1215  
1216      task_begin('Assigning avatar to Admin... ');
1217      $UserCache = & get_UserCache();
1218      $User_Admin = & $UserCache->get_by_ID( 1 );
1219      if( $User_Admin->get( 'gender' ) == 'F' )
1220      { // Set girl avatar if user has female gender
1221          $edit_File = new File( 'user', 1, 'faceyourmanga_admin_girl.png' );
1222      }
1223      else
1224      { // Set boy avatar if user has male gender
1225          $edit_File = new File( 'user', 1, 'faceyourmanga_admin_boy.png' );
1226      }
1227      // Load meta data AND MAKE SURE IT IS CREATED IN DB:
1228      $edit_File->load_meta( true );
1229      $User_Admin->set( 'avatar_file_ID', $edit_File->ID );
1230      $User_Admin->dbupdate();
1231      task_end();
1232  
1233      task_begin('Creating demo amoderator user... ');
1234      $amoderator_ID = create_user( array(
1235              'login'  => 'amoderator',
1236              'level'  => 2,
1237              'gender' => 'M',
1238              'Group'  => $Group_Privileged,
1239          ) );
1240      task_end();
1241  
1242      task_begin('Creating demo bmoderator user... ');
1243      $bmoderator_ID = create_user( array(
1244              'login'  => 'bmoderator',
1245              'level'  => 2,
1246              'gender' => 'F',
1247              'Group'  => $Group_Privileged,
1248          ) );
1249      task_end();
1250  
1251      task_begin('Creating demo ablogger user... ');
1252      $ablogger_ID = create_user( array(
1253              'login'  => 'ablogger',
1254              'level'  => 1,
1255              'gender' => 'M',
1256              'Group'  => $Group_Bloggers,
1257          ) );
1258      task_end();
1259  
1260      task_begin('Creating demo bblogger user... ');
1261      $bblogger_ID = create_user( array(
1262              'login'  => 'bblogger',
1263              'level'  => 1,
1264              'gender' => 'F',
1265              'Group'  => $Group_Bloggers,
1266          ) );
1267      task_end();
1268  
1269      task_begin('Creating demo auser user... ');
1270      $auser_ID = create_user( array(
1271              'login'  => 'auser',
1272              'level'  => 0,
1273              'gender' => 'M',
1274              'Group'  => $Group_Users,
1275          ) );
1276      task_end();
1277  
1278      task_begin('Creating demo buser user... ');
1279      $buser_ID = create_user( array(
1280              'login'  => 'buser',
1281              'level'  => 0,
1282              'gender' => 'F',
1283              'Group'  => $Group_Users,
1284          ) );
1285      task_end();
1286  
1287      task_begin( 'Set settings for demo users... ' );
1288      $DB->query( "
1289          INSERT INTO T_users__usersettings ( uset_user_ID, uset_name, uset_value )
1290          VALUES ( 2, 'created_fromIPv4', '".ip2int( '127.0.0.1' )."' ),
1291                  ( 2, 'user_domain', 'localhost' ),
1292                  ( 3, 'created_fromIPv4', '".ip2int( '127.0.0.1' )."' ),
1293                  ( 3, 'user_domain', 'localhost' ),
1294                  ( 4, 'created_fromIPv4', '".ip2int( '127.0.0.1' )."' ),
1295                  ( 4, 'user_domain', 'localhost' ),
1296                  ( 5, 'created_fromIPv4', '".ip2int( '127.0.0.1' )."' ),
1297                  ( 5, 'user_domain', 'localhost' ),
1298                  ( 6, 'created_fromIPv4', '".ip2int( '127.0.0.1' )."' ),
1299                  ( 6, 'user_domain', 'localhost' ),
1300                  ( 7, 'created_fromIPv4', '".ip2int( '127.0.0.1' )."' ),
1301                  ( 7, 'user_domain', 'localhost' )" );
1302      task_end();
1303  
1304      global $default_locale, $query, $timestamp;
1305      global $blog_all_ID, $blog_a_ID, $blog_b_ID, $blog_linkblog_ID;
1306  
1307      $default_blog_longdesc = T_("This is the long description for the blog named '%s'. %s");
1308      $default_blog_access_type = 'relative';
1309  
1310      task_begin( 'Creating default blogs... ' );
1311  
1312      $blog_shortname = 'Blog A';
1313      $blog_a_long = sprintf( T_('%s Title'), $blog_shortname );
1314      $blog_a_access_type = ( $test_install_all_features ) ? 'default' : $default_blog_access_type;
1315      $blog_stub = 'a';
1316      $blog_a_ID = create_blog(
1317          $blog_a_long,
1318          $blog_shortname,
1319          $blog_stub,
1320          sprintf( T_('Tagline for %s'), $blog_shortname ),
1321          sprintf( $default_blog_longdesc, $blog_shortname, '' ),
1322          1, // Skin ID
1323          'std',
1324          'any',
1325          1,
1326          $blog_a_access_type,
1327          true,
1328          $ablogger_ID );
1329  
1330      $blog_shortname = 'Blog B';
1331      $blog_b_access_type = ( $test_install_all_features ) ? 'index.php' : $default_blog_access_type;
1332      $blog_stub = 'b';
1333      $blog_b_ID = create_blog(
1334          sprintf( T_('%s Title'), $blog_shortname ),
1335          $blog_shortname,
1336          $blog_stub,
1337          sprintf( T_('Tagline for %s'), $blog_shortname ),
1338          sprintf( $default_blog_longdesc, $blog_shortname, '' ),
1339          2, // Skin ID
1340          'std',
1341          '',
1342          0,
1343          $blog_b_access_type,
1344          true,
1345          $bblogger_ID );
1346  
1347      $blog_shortname = 'Linkblog';
1348      $blog_linkblog_access_type = ( $test_install_all_features ) ? 'extrapath' : $default_blog_access_type;
1349      $blog_stub = 'links';
1350      $blog_more_longdesc = '<br />
1351  <br />
1352  <strong>'.T_("The main purpose for this blog is to be included as a side item to other blogs where it will display your favorite/related links.").'</strong>';
1353      $blog_linkblog_ID = create_blog(
1354          'Linkblog',
1355          $blog_shortname,
1356          $blog_stub,
1357          T_('Some interesting links...'),
1358          sprintf( $default_blog_longdesc, $blog_shortname, $blog_more_longdesc ),
1359          3, // SKin ID
1360          'std',
1361          'any',
1362          0,
1363          $blog_linkblog_access_type,
1364          true,
1365          $ablogger_ID );
1366  
1367      $blog_shortname = 'Photoblog';
1368      $blog_stub = 'photos';
1369      $blog_more_longdesc = '<br />
1370  <br />
1371  <strong>'.T_("This is a photoblog, optimized for displaying photos.").'</strong>';
1372      $blog_photoblog_ID = create_blog(
1373          'Photoblog',
1374          $blog_shortname,
1375          $blog_stub,
1376          T_('This blog shows photos...'),
1377          sprintf( $default_blog_longdesc, $blog_shortname, $blog_more_longdesc ),
1378          4, // SKin ID
1379          'photo', '', 0, 'relative', true,
1380          $ablogger_ID );
1381  
1382      $blog_shortname = 'Forums';
1383      $blog_forums_long = sprintf( T_('%s Title'), $blog_shortname );
1384      $blog_stub = 'forums';
1385      $blog_forums_ID = create_blog(
1386          $blog_forums_long,
1387          $blog_shortname,
1388          $blog_stub,
1389          sprintf( T_('Tagline for %s'), $blog_shortname ),
1390          sprintf( $default_blog_longdesc, $blog_shortname, '' ),
1391          5, // Skin ID
1392          'forum', 'any', 1, 'relative', false,
1393          $ablogger_ID );
1394  
1395      $blog_shortname = 'Manual';
1396      $blog_manual_long = sprintf( T_('%s Title'), $blog_shortname );
1397      $blog_stub = 'manual';
1398      $blog_manual_ID = create_blog(
1399          $blog_manual_long,
1400          $blog_shortname,
1401          $blog_stub,
1402          sprintf( T_('Tagline for %s'), $blog_shortname ),
1403          sprintf( $default_blog_longdesc, $blog_shortname, '' ),
1404          6, // Skin ID
1405          'manual', 'any', 1, $default_blog_access_type, true,
1406          $ablogger_ID );
1407  
1408      task_end();
1409  
1410      global $query, $timestamp;
1411  
1412      task_begin( 'Creating sample categories... ' );
1413  
1414      // Create categories for blog A
1415      $cat_ann_a = cat_create( T_('Welcome'), 'NULL', $blog_a_ID );
1416      $cat_news = cat_create( T_('News'), 'NULL', $blog_a_ID );
1417      $cat_bg = cat_create( T_('Background'), 'NULL', $blog_a_ID );
1418      $cat_fun = cat_create( T_('Fun'), 'NULL', $blog_a_ID );
1419      $cat_life = cat_create( T_('In real life'), $cat_fun, $blog_a_ID );
1420      $cat_web = cat_create( T_('On the web'), $cat_fun, $blog_a_ID );
1421      $cat_sports = cat_create( T_('Sports'), $cat_life, $blog_a_ID );
1422      $cat_movies = cat_create( T_('Movies'), $cat_life, $blog_a_ID );
1423      $cat_music = cat_create( T_('Music'), $cat_life, $blog_a_ID );
1424  
1425      // Create categories for blog B
1426      $cat_ann_b = cat_create( T_('Announcements'), 'NULL', $blog_b_ID );
1427      $cat_b2evo = cat_create( T_('b2evolution Tips'), 'NULL', $blog_b_ID );
1428      $cat_additional_skins = cat_create( T_('Get additional skins'), 'NULL', $blog_b_ID );
1429  
1430      // Create categories for linkblog
1431      $cat_linkblog_b2evo = cat_create( 'b2evolution', 'NULL', $blog_linkblog_ID );
1432      $cat_linkblog_contrib = cat_create( T_('Contributors'), 'NULL', $blog_linkblog_ID );
1433  
1434      // Create categories for photoblog
1435      $cat_photo_album = cat_create( T_('Monument Valley'), 'NULL', $blog_photoblog_ID );
1436  
1437      // Create categories for forums
1438      $cat_forums_ann = cat_create( T_('Welcome'), 'NULL', $blog_forums_ID, 'Welcome description' );
1439      $cat_forums_news = cat_create( T_('News'), 'NULL', $blog_forums_ID, 'News description' );
1440      $cat_forums_bg = cat_create( T_('Background'), 'NULL', $blog_forums_ID, 'Background description' );
1441      $cat_forums_fun = cat_create( T_('Fun'), 'NULL', $blog_forums_ID, 'Fun description' );
1442      $cat_forums_life = cat_create( T_('In real life'), $cat_forums_fun, $blog_forums_ID );
1443      $cat_forums_web = cat_create( T_('On the web'), $cat_forums_fun, $blog_forums_ID );
1444      $cat_forums_sports = cat_create( T_('Sports'), $cat_forums_life, $blog_forums_ID );
1445      $cat_forums_movies = cat_create( T_('Movies'), $cat_forums_life, $blog_forums_ID );
1446      $cat_forums_music = cat_create( T_('Music'), $cat_forums_life, $blog_forums_ID );
1447  
1448      // Create categories for manual
1449      $cat_manual_ann = cat_create( T_('Welcome'), 'NULL', $blog_manual_ID, 'Welcome description', false, 15 );
1450      $cat_manual_news = cat_create( T_('News'), 'NULL', $blog_manual_ID, 'News description', false, 5 );
1451      $cat_manual_bg = cat_create( T_('Background'), 'NULL', $blog_manual_ID, 'Background description', false, 35 );
1452      $cat_manual_fun = cat_create( T_('Cat with intro post'), 'NULL', $blog_manual_ID, 'Description of cat with intro post', false, 25 );
1453      $cat_manual_life = cat_create( T_('In real life'), $cat_manual_fun, $blog_manual_ID, NULL, false, 10 );
1454      $cat_manual_web = cat_create( T_('On the web'), $cat_manual_fun, $blog_manual_ID, NULL, false, 5 );
1455      $cat_manual_sports = cat_create( T_('Sports'), $cat_manual_life, $blog_manual_ID, NULL, false, 35 );
1456      $cat_manual_movies = cat_create( T_('Movies'), $cat_manual_life, $blog_manual_ID, NULL, false, 25 );
1457      $cat_manual_music = cat_create( T_('Music'), $cat_manual_life, $blog_manual_ID, NULL, false, 5 );
1458  
1459      task_end();
1460  
1461  
1462      task_begin( 'Creating sample posts... ' );
1463  
1464      // Define here all categories which should have the advertisement banners
1465      $adv_cats = array(
1466              'blogA'     => $cat_bg, // Background
1467              'blogB'     => $cat_ann_b, // Announcements
1468              'linkblog'  => $cat_linkblog_b2evo, // b2evolution
1469              'photoblog' => $cat_photo_album, // Monument Valley
1470              'forums'    => $cat_forums_bg, // Background
1471              'manual'    => $cat_manual_bg, // Background
1472          );
1473      foreach( $adv_cats as $adv_cat_ID )
1474      {    // Insert three ADVERTISEMENTS for each blog:
1475          $now = date('Y-m-d H:i:s',$timestamp++);
1476          $edited_Item = new Item();
1477          $edited_Item->insert( 1, /* TRANS: sample ad content */ T_('b2evo : The software for blog pros!'), /* TRANS: sample ad content */ T_('The software for blog pros!'), $now, $adv_cat_ID,
1478              array(), 'published', '#', '', 'http://b2evolution.net', 'open', array('default'), 4000 );
1479          $edit_File = new File( 'shared', 0, 'banners/b2evo-125-pros.png' );
1480          $LinkOwner = new LinkItem( $edited_Item );
1481          $edit_File->link_to_Object( $LinkOwner );
1482  
1483          $now = date('Y-m-d H:i:s',$timestamp++);
1484          $edited_Item = new Item();
1485          $edited_Item->insert( 1, /* TRANS: sample ad content */ T_('b2evo : Better Blog Software!'), /* TRANS: sample ad content */ T_('Better Blog Software!'), $now, $adv_cat_ID,
1486              array(), 'published', '#', '', 'http://b2evolution.net', 'open', array('default'), 4000 );
1487          $edit_File = new File( 'shared', 0, 'banners/b2evo-125-better.png' );
1488          $LinkOwner = new LinkItem( $edited_Item );
1489          $edit_File->link_to_Object( $LinkOwner );
1490  
1491          $now = date('Y-m-d H:i:s',$timestamp++);
1492          $edited_Item = new Item();
1493          $edited_Item->insert( 1, /* TRANS: sample ad content */ T_('b2evo : The other blog tool!'), /* TRANS: sample ad content */ T_('The other blog tool!'), $now, $adv_cat_ID,
1494              array(), 'published', '#', '', 'http://b2evolution.net', 'open', array('default'), 4000 );
1495          $edit_File = new File( 'shared', 0, 'banners/b2evo-125-other.png' );
1496          $LinkOwner = new LinkItem( $edited_Item );
1497          $edit_File->link_to_Object( $LinkOwner );
1498      }
1499  
1500      // Insert a post:
1501      $now = date('Y-m-d H:i:s',$timestamp++);
1502      $edited_Item = new Item();
1503      $edited_Item->insert( 1, T_('First Post'), T_('<p>This is the first post.</p>
1504  
1505  <p>It appears in a single category.</p>'), $now, $cat_ann_a );
1506  
1507      // Insert a post:
1508      $now = date('Y-m-d H:i:s',$timestamp++);
1509      $edited_Item = new Item();
1510      $edited_Item->insert( 1, T_('Second post'), T_('<p>This is the second post.</p>
1511  
1512  <p>It appears in multiple categories.</p>'), $now, $cat_news, array( $cat_ann_a ) );
1513  
1514      // Insert sidebar links into Blog B
1515      $now = date('Y-m-d H:i:s',$timestamp++);
1516      $edited_Item = new Item();
1517      $edited_Item->insert( 1, 'Skin Faktory', '', $now, $cat_additional_skins, array(), 'published', 'en-US', '', 'http://www.skinfaktory.com/', 'open', array('default'), 3000 );
1518  
1519      $now = date('Y-m-d H:i:s',$timestamp++);
1520      $edited_Item = new Item();
1521      $edited_Item->insert( 1, T_('b2evo skins repository'), '', $now, $cat_additional_skins, array(), 'published', 'en-US', '', 'http://skins.b2evolution.net/', 'open', array('default'), 3000 );
1522  
1523      // PHOTOBLOG:
1524      /**
1525       * @var FileRootCache
1526       */
1527      // $FileRootCache = & get_FileRootCache();
1528      // $FileRoot = & $FileRootCache->get_by_type_and_ID( 'collection', $blog_photoblog_ID, true );
1529  
1530      // Insert a post into photoblog:
1531      $now = date('Y-m-d H:i:s',$timestamp++);
1532      $edited_Item = new Item();
1533      $edited_Item->insert( 1, T_('Bus Stop Ahead'), 'In the middle of nowhere: a school bus stop where you wouldn\'t really expect it!',
1534                       $now, $cat_photo_album, array(), 'published','en-US', '', 'http://fplanque.com/photo/monument-valley' );
1535      $edit_File = new File( 'shared', 0, 'monument-valley/bus-stop-ahead.jpg' );
1536      $LinkOwner = new LinkItem( $edited_Item );
1537      $edit_File->link_to_Object( $LinkOwner );
1538  
1539      // Insert a post into photoblog:
1540      $now = date('Y-m-d H:i:s',$timestamp++);
1541      $edited_Item = new Item();
1542      $edited_Item->insert( 1, T_('John Ford Point'), 'Does this scene look familiar? You\'ve probably seen it in a couple of John Ford westerns!',
1543                       $now, $cat_photo_album, array(), 'published','en-US', '', 'http://fplanque.com/photo/monument-valley' );
1544      $edit_File = new File( 'shared', 0, 'monument-valley/john-ford-point.jpg' );
1545      $LinkOwner = new LinkItem( $edited_Item );
1546      $edit_File->link_to_Object( $LinkOwner );
1547  
1548      // Insert a post into photoblog:
1549      $now = date('Y-m-d H:i:s',$timestamp++);
1550      $edited_Item = new Item();
1551      $edited_Item->insert( 1, T_('Monuments'), 'This is one of the most famous views in Monument Valley. I like to frame it with the dirt road in order to give a better idea of the size of those things!',
1552                       $now, $cat_photo_album, array(), 'published','en-US', '', 'http://fplanque.com/photo/monument-valley' );
1553      $edit_File = new File( 'shared', 0, 'monument-valley/monuments.jpg' );
1554      $LinkOwner = new LinkItem( $edited_Item );
1555      $edit_File->link_to_Object( $LinkOwner );
1556  
1557      // Insert a post into photoblog:
1558      $now = date('Y-m-d H:i:s',$timestamp++);
1559      $edited_Item = new Item();
1560      $edited_Item->insert( 1, T_('Road to Monument Valley'), 'This gives a pretty good idea of the Monuments you\'re about to drive into...',
1561                       $now, $cat_photo_album, array(), 'published','en-US', '', 'http://fplanque.com/photo/monument-valley' );
1562      $edit_File = new File( 'shared', 0, 'monument-valley/monument-valley-road.jpg' );
1563      $LinkOwner = new LinkItem( $edited_Item );
1564      $edit_File->link_to_Object( $LinkOwner );
1565  
1566      // Insert a post into photoblog:
1567      $now = date('Y-m-d H:i:s',$timestamp++);
1568      $edited_Item = new Item();
1569      $edited_Item->insert( 1, T_('Monument Valley'), T_('This is a short photo album demo. Use the arrows to navigate between photos. Click on "Index" to see a thumbnail index.'),
1570                       $now, $cat_photo_album, array(), 'published','en-US', '', 'http://fplanque.com/photo/monument-valley' );
1571      $edit_File = new File( 'shared', 0, 'monument-valley/monument-valley.jpg' );
1572      $LinkOwner = new LinkItem( $edited_Item );
1573      $edit_File->link_to_Object( $LinkOwner );
1574  
1575  
1576      // POPULATE THE LINKBLOG:
1577  
1578      // Insert a post into linkblog:
1579      // walter : a weird line of code to create a post in the linkblog a minute after the others.
1580      // It will show a bug on linkblog agregation by category
1581      $timestamp++;
1582      $now = date('Y-m-d H:i:s',$timestamp + 59);
1583      $edited_Item = new Item();
1584      $edited_Item->insert( 1, 'Evo Factory', '', $now, $cat_linkblog_contrib, array(), 'published', 'en-US', '', 'http://evofactory.com/', 'disabled', array() );
1585  
1586      // Insert a post into linkblog:
1587      $now = date('Y-m-d H:i:s',$timestamp++);
1588      $edited_Item = new Item();
1589      $edited_Item->insert( 1, 'Alex', '', $now, $cat_linkblog_contrib, array(), 'published', 'ru-RU', '', 'http://b2evo.sonorth.com/', 'disabled', array() );
1590  
1591      // Insert a post into linkblog:
1592      $now = date('Y-m-d H:i:s',$timestamp++);
1593      $edited_Item = new Item();
1594      $edited_Item->insert( 1, 'Francois', '', $now, $cat_linkblog_contrib, array(), 'published', 'fr-FR', '', 'http://fplanque.com/', 'disabled', array() );
1595  
1596  
1597      // Insert a post into linkblog:
1598      $now = date('Y-m-d H:i:s',$timestamp++);
1599      $edited_Item = new Item();
1600      $edited_Item->insert( 1, 'Blog news', '', $now, $cat_linkblog_b2evo, array(), 'published', 'en-US', '', 'http://b2evolution.net/news.php', 'disabled', array() );
1601  
1602      // Insert a post into linkblog:
1603      $now = date('Y-m-d H:i:s',$timestamp++);
1604      $edited_Item = new Item();
1605      $edited_Item->insert( 1, 'Web hosting', '', $now, $cat_linkblog_b2evo, array(), 'published', 'en-US', '', 'http://b2evolution.net/web-hosting/blog/', 'disabled', array() );
1606  
1607      // Insert a post into linkblog:
1608      $now = date('Y-m-d H:i:s',$timestamp++);
1609      $edited_Item = new Item();
1610      $edited_Item->insert( 1, 'Manual', '', $now, $cat_linkblog_b2evo, array(), 'published',    'en-US', '', 'http://b2evolution.net/man/', 'disabled', array() );
1611  
1612      // Insert a post into linkblog:
1613      $now = date('Y-m-d H:i:s',$timestamp++);
1614      $edited_Item = new Item();
1615      $edited_Item->insert( 1, 'Support', '', $now, $cat_linkblog_b2evo, array(), 'published', 'en-US', '', 'http://forums.b2evolution.net/', 'disabled', array() );
1616  
1617  
1618  
1619      $info_page = T_("<p>This blog is powered by b2evolution.</p>
1620  
1621  <p>You are currently looking at an info page about %s.</p>
1622  
1623  <p>Info pages are very much like regular posts, except that they do not appear in the regular flow of posts. They appear as info pages in the sidebar instead.</p>
1624  
1625  <p>If needed, an evoskin can format info pages differently from regular posts.</p>");
1626  
1627      // Insert a PAGE:
1628      $now = date('Y-m-d H:i:s',$timestamp++);
1629      $edited_Item = new Item();
1630      $edited_Item->insert( 1, T_("About Blog B"), sprintf( $info_page, T_('Blog B') ), $now, $cat_ann_b,
1631          array(), 'published', '#', '', '', 'open', array('default'), 1000 );
1632  
1633      // Insert a PAGE:
1634      $now = date('Y-m-d H:i:s',$timestamp++);
1635      $edited_Item = new Item();
1636      $edited_Item->insert( 1, T_("About Blog A"), sprintf( $info_page, T_('Blog A') ), $now, $cat_ann_a,
1637          array(), 'published', '#', '', '', 'open', array('default'), 1000 );
1638  
1639      // Insert a PAGE:
1640      $now = date('Y-m-d H:i:s',$timestamp++);
1641      $edited_Item = new Item();
1642      $edited_Item->insert( 1, T_("About this system"), T_("<p>This blog platform is powered by b2evolution.</p>
1643  
1644  <p>You are currently looking at an info page about this system. It is cross-posted among the demo blogs. Thus, this page will be linked on each of these blogs.</p>
1645  
1646  <p>Info pages are very much like regular posts, except that they do not appear in the regular flow of posts. They appear as info pages in the sidebar instead.</p>
1647  
1648  <p>If needed, an evoskin can format info pages differently from regular posts.</p>"), $now, $cat_ann_a,
1649          array( $cat_ann_a, $cat_ann_b, $cat_linkblog_b2evo, $cat_forums_ann ), 'published', '#', '', '', 'open', array('default'), 1000 );
1650      $edit_File = new File( 'shared', 0, 'logos/b2evolution8.png' );
1651      $LinkOwner = new LinkItem( $edited_Item );
1652      $edit_File->link_to_Object( $LinkOwner );
1653  
1654  
1655      /*
1656      // Insert a post:
1657      $now = date('Y-m-d H:i:s',$timestamp++);
1658      $edited_Item = new Item();
1659      $edited_Item->insert( 1, T_("Default Intro post"), T_("This uses post type \"Intro-All\"."),
1660                                                  $now, $cat_b2evo, array( $cat_ann_b ), 'published', '#', '', '', 'open', array('default'), 1600 );
1661      */
1662  
1663      // Insert a post:
1664      $now = date('Y-m-d H:i:s', ($timestamp++ - 31536000) ); // A year ago
1665      $edited_Item = new Item();
1666      $edited_Item->insert( 1, T_("Main Intro post"), T_("This is the main intro post. It appears on the homepage only."),
1667                                                  $now, $cat_b2evo, array(), 'published', '#', '', '', 'open', array('default'), 1500 );
1668  
1669      // Insert a post:
1670      $now = date('Y-m-d H:i:s', ($timestamp++ - 31536000) ); // A year ago
1671      $edited_Item = new Item();
1672      $edited_Item->insert( 1, T_("b2evolution tips category &ndash; Sub Intro post"), T_("This uses post type \"Intro-Cat\" and is attached to the desired Category(ies)."),
1673                                                  $now, $cat_b2evo, array(), 'published', '#', '', '', 'open', array('default'), 1520 );
1674  
1675      // Insert a post:
1676      $now = date('Y-m-d H:i:s', ($timestamp++ - 31536000) ); // A year ago
1677      $edited_Item = new Item();
1678      $edited_Item->insert( 1, T_("Widgets tag &ndash; Sub Intro post"), T_("This uses post type \"Intro-Tag\" and is tagged with the desired Tag(s)."),
1679                                                  $now, $cat_b2evo, array(), 'published', '#', '', '', 'open', array('default'), 1530 );
1680      $edited_Item->set_tags_from_string( 'widgets' );
1681      //$edited_Item->dbsave();
1682      $edited_Item->insert_update_tags( 'update' );
1683  
1684      // Insert a post:
1685      // TODO: move to Blog A
1686      $now = date('Y-m-d H:i:s', $timestamp++);
1687      $edited_Item = new Item();
1688      $edited_Item->insert( 1, T_("Featured post"), T_("<p>This is a demo of a featured post.</p>
1689  
1690  <p>It will be featured whenever we have no specific \"Intro\" post to display for the current request. To see it in action, try displaying the \"Announcements\" category.</p>
1691  
1692  <p>Also note that when the post is featured, it does not appear in the regular post flow.</p>"),
1693      $now, $cat_b2evo, array( $cat_ann_b ) );
1694      $edited_Item->set( 'featured', 1 );
1695      $edited_Item->dbsave();
1696  
1697      // Insert a post:
1698      $now = date('Y-m-d H:i:s',$timestamp++);
1699      $edited_Item = new Item();
1700      $edited_Item->insert( 1, T_("Apache optimization..."), sprintf( T_("<p>b2evolution comes with an <code>.htaccess</code> file destined to optimize the way b2evolution is handled by your webseerver (if you are using Apache). In some circumstances, that file may not be automatically activated at setup. Please se the man page about <a %s>Tricky Stuff</a> for more information.</p>
1701  
1702  <p>For further optimization, please review the manual page about <a %s>Performance optimization</a>. Depending on your current configuration and on what your <a %s>web hosting</a> company allows you to do, you may increase the speed of b2evolution by up to a factor of 10!</p>"),
1703  'href="http://b2evolution.net/man/tricky-stuff"',
1704  'href="http://b2evolution.net/man/performance-optimization"',
1705  'href="http://b2evolution.net/web-hosting/"' ),
1706                                                  $now, $cat_b2evo, array( $cat_ann_b ) );
1707  
1708      // Insert a post:
1709      $now = date('Y-m-d H:i:s',$timestamp++);
1710      $edited_Item = new Item();
1711      $edited_Item->insert( 1, T_("Skins, Stubs, Templates &amp; website integration..."), T_("<p>By default, blogs are displayed using an evoskin. (More on skins in another post.)</p>
1712  
1713  <p>This means, blogs are accessed through '<code>index.php</code>', which loads default parameters from the database and then passes on the display job to a skin.</p>
1714  
1715  <p>Alternatively, if you don't want to use the default DB parameters and want to, say, force a skin, a category or a specific linkblog, you can create a stub file like the provided '<code>a_stub.php</code>' and call your blog through this stub instead of index.php .</p>
1716  
1717  <p>Finally, if you need to do some very specific customizations to your blog, you may use plain templates instead of skins. In this case, call your blog through a full template, like the provided '<code>a_noskin.php</code>'.</p>
1718  
1719  <p>If you want to integrate a b2evolution blog into a complex website, you'll probably want to do it by copy/pasting code from <code>a_noskin.php</code> into a page of your website.</p>
1720  
1721  <p>You will find more information in the stub/template files themselves. Open them in a text editor and read the comments in there.</p>
1722  
1723  <p>Either way, make sure you go to the blogs admin and set the correct access method/URL for your blog. Otherwise, the permalinks will not function properly.</p>"), $now, $cat_b2evo );
1724      $edited_Item->set_tags_from_string( 'skins' );
1725      //$edited_Item->dbsave();
1726      $edited_Item->insert_update_tags( 'update' );
1727  
1728      // Insert a post:
1729      $now = date('Y-m-d H:i:s',$timestamp++);
1730      $edited_Item = new Item();
1731      $edited_Item->insert( 1, T_("About widgets..."), T_('<p>b2evolution blogs are installed with a default selection of Widgets. For example, the sidebar of this blog includes widgets like a calendar, a search field, a list of categories, a list of XML feeds, etc.</p>
1732  
1733  <p>You can add, remove and reorder widgets from the Blog Settings tab in the admin interface.</p>
1734  
1735  <p>Note: in order to be displayed, widgets are placed in containers. Each container appears in a specific place in an evoskin. If you change your blog skin, the new skin may not use the same containers as the previous one. Make sure you place your widgets in containers that exist in the specific skin you are using.</p>'), $now, $cat_b2evo );
1736      $edited_Item->set_tags_from_string( 'widgets' );
1737      //$edited_Item->dbsave();
1738      $edited_Item->insert_update_tags( 'update' );
1739  
1740      // Insert a post:
1741      $now = date('Y-m-d H:i:s',$timestamp++);
1742      $edited_Item = new Item();
1743      $edited_Item->insert( 1, T_("About skins..."), T_('<p>By default, b2evolution blogs are displayed using an evoskin.</p>
1744  
1745  <p>You can change the skin used by any blog by editing the blog settings in the admin interface.</p>
1746  
1747  <p>You can download additional skins from the <a href="http://skins.b2evolution.net/" target="_blank">skin site</a>. To install them, unzip them in the /blogs/skins directory, then go to General Settings &gt; Skins in the admin interface and click on "Install new".</p>
1748  
1749  <p>You can also create your own skins by duplicating, renaming and customizing any existing skin folder from the /blogs/skins directory.</p>
1750  
1751  <p>To start customizing a skin, open its "<code>index.main.php</code>" file in an editor and read the comments in there. Note: you can also edit skins in the "Files" tab of the admin interface.</p>
1752  
1753  <p>And, of course, read the <a href="http://b2evolution.net/man/skin-structure" target="_blank">manual on skins</a>!</p>'), $now, $cat_b2evo );
1754      $edited_Item->set_tags_from_string( 'skins' );
1755      $edited_Item->set( 'featured', 1 );
1756      $edited_Item->dbsave();
1757      // $edited_Item->insert_update_tags( 'update' );
1758  
1759  
1760      // Insert a post:
1761      $now = date('Y-m-d H:i:s',$timestamp++);
1762      $edited_Item = new Item();
1763      $edited_Item->insert( 1, T_('Image post'), T_('<p>This post has an image attached to it. The image is automatically resized to fit the current blog skin. You can zoom in by clicking on the thumbnail.</p>
1764  
1765  <p>Check out the photoblog (accessible through the links at the top) to see a completely different skin focused more on the photos than on the blog text.</p>'), $now, $cat_bg );
1766      $edit_File = new File( 'shared', 0, 'monument-valley/monuments.jpg' );
1767      $LinkOwner = new LinkItem( $edited_Item );
1768      $edit_File->link_to_Object( $LinkOwner );
1769  
1770  
1771      // Insert a post:
1772      $now = date('Y-m-d H:i:s',$timestamp++);
1773      $edited_Item = new Item();
1774      $edited_Item->insert( 1, T_('This is a multipage post'), T_('<p>This is page 1 of a multipage post.</p>
1775  
1776  <p>You can see the other pages by clicking on the links below the text.</p>
1777  
1778  <!--nextpage-->
1779  
1780  <p>This is page 2.</p>
1781  
1782  <!--nextpage-->
1783  
1784  <p>This is page 3.</p>
1785  
1786  <!--nextpage-->
1787  
1788  <p>This is page 4.</p>
1789  
1790  <p>It is the last page.</p>'), $now, $cat_bg );
1791  
1792  
1793      // Insert a post:
1794      $now = date('Y-m-d H:i:s',$timestamp++);
1795      $edited_Item = new Item();
1796      $edited_Item->insert( 1, T_('Extended post with no teaser'), T_('<p>This is an extended post with no teaser. This means that you won\'t see this teaser any more when you click the "more" link.</p>
1797  
1798  <!--more-->
1799  
1800  <p>This is the extended text. You only see it when you have clicked the "more" link.</p>'), $now, $cat_bg );
1801      $edited_Item->set_setting( 'hide_teaser', '1' );
1802      $edited_Item->dbsave();
1803  
1804  
1805      // Insert a post:
1806      $now = date('Y-m-d H:i:s',$timestamp++);
1807      $edited_Item = new Item();
1808      $edited_Item->insert( 1, T_('Extended post'), T_('<p>This is an extended post. This means you only see this small teaser by default and you must click on the link below to see more.</p>
1809  
1810  <!--more-->
1811  
1812  <p>This is the extended text. You only see it when you have clicked the "more" link.</p>'), $now, $cat_bg );
1813  
1814  
1815      // Insert a post:
1816      $now = date('Y-m-d H:i:s',$timestamp++);
1817      $edited_Item = new Item();
1818      $Item_BlogA_welcome_ID = $edited_Item->insert( 1, T_("Welcome to b2evolution!"), T_("<p>Four blogs have been created with sample contents:</p>
1819  
1820  <ul>
1821      <li><strong>Blog A</strong>: You are currently looking at it. It contains a few sample posts, using simple features of b2evolution.</li>
1822      <li><strong>Blog B</strong>: You can access it from a link at the top of the page. It contains information about more advanced features.</li>
1823      <li><strong>Linkblog</strong>: By default, the linkblog is included as a \"Blogroll\" in the sidebar of both Blog A &amp; Blog B.</li>
1824      <li><strong>Photoblog</strong>: This blog is an example of how you can use b2evolution to showcase photos, with one photo per page as well as a thumbnail index.</li>
1825  </ul>
1826  
1827  <p>You can add new blogs, delete unwanted blogs and customize existing blogs (title, sidebar, blog skin, widgets, etc.) from the Blog Settings tab in the admin interface.</p>"), $now, $cat_ann_a );
1828      $edit_File = new File( 'shared', 0, 'logos/b2evolution8.png' );
1829      $LinkOwner = new LinkItem( $edited_Item );
1830      $edit_File->link_to_Object( $LinkOwner );
1831  
1832      // FORUMS:
1833  
1834      // Insert a PAGE:
1835      $now = date('Y-m-d H:i:s',$timestamp++);
1836      $edited_Item = new Item();
1837      $edited_Item->insert( 1, T_("About Forums"), sprintf( $info_page, T_('Forums') ), $now, $cat_forums_ann,
1838          array(), 'published', '#', '', '', 'open', array('default'), 1000 );
1839  
1840      // Insert a post:
1841      $now = date('Y-m-d H:i:s',$timestamp++);
1842      $edited_Item = new Item();
1843      $edited_Item->insert( 1, T_('First Topic'), T_('<p>This is the first topic.</p>
1844  
1845  <p>It appears in a single category.</p>'), $now, $cat_forums_ann );
1846  
1847      // Insert a post:
1848      $now = date('Y-m-d H:i:s',$timestamp++);
1849      $edited_Item = new Item();
1850      $edited_Item->insert( 1, T_('Second topic'), T_('<p>This is the second topic.</p>
1851  
1852  <p>It appears in multiple categories.</p>'), $now, $cat_forums_news, array( $cat_forums_ann ) );
1853  
1854  
1855      // Insert a post:
1856      $now = date('Y-m-d H:i:s',$timestamp++);
1857      $edited_Item = new Item();
1858      $edited_Item->insert( 1, T_('Image topic'), T_('<p>This topic has an image attached to it. The image is automatically resized to fit the current blog skin. You can zoom in by clicking on the thumbnail.</p>
1859  
1860  <p>Check out the photoblog (accessible through the links at the top) to see a completely different skin focused more on the photos than on the blog text.</p>'), $now, $cat_forums_bg );
1861      $edit_File = new File( 'shared', 0, 'monument-valley/monuments.jpg' );
1862      $LinkOwner = new LinkItem( $edited_Item );
1863      $edit_File->link_to_Object( $LinkOwner );
1864  
1865  
1866      // Insert a post:
1867      $now = date('Y-m-d H:i:s',$timestamp++);
1868      $edited_Item = new Item();
1869      $edited_Item->insert( 1, T_('This is a multipage topic'), T_('<p>This is page 1 of a multipage topic.</p>
1870  
1871  <p>You can see the other pages by clicking on the links below the text.</p>
1872  
1873  <!--nextpage-->
1874  
1875  <p>This is page 2.</p>
1876  
1877  <!--nextpage-->
1878  
1879  <p>This is page 3.</p>
1880  
1881  <!--nextpage-->
1882  
1883  <p>This is page 4.</p>
1884  
1885  <p>It is the last page.</p>'), $now, $cat_forums_bg );
1886  
1887  
1888      // Insert a post:
1889      $now = date('Y-m-d H:i:s',$timestamp++);
1890      $edited_Item = new Item();
1891      $edited_Item->insert( 1, T_('Extended topic with no teaser'), T_('<p>This is an extended topic with no teaser. This means that you won\'t see this teaser any more when you click the "more" link.</p>
1892  
1893  <!--more-->
1894  
1895  <p>This is the extended text. You only see it when you have clicked the "more" link.</p>'), $now, $cat_forums_bg );
1896      $edited_Item->set_setting( 'hide_teaser', '1' );
1897      $edited_Item->dbsave();
1898  
1899  
1900      // Insert a post:
1901      $now = date('Y-m-d H:i:s',$timestamp++);
1902      $edited_Item = new Item();
1903      $edited_Item->insert( 1, T_('Extended topic'), T_('<p>This is an extended topic. This means you only see this small teaser by default and you must click on the link below to see more.</p>
1904  
1905  <!--more-->
1906  
1907  <p>This is the extended text. You only see it when you have clicked the "more" link.</p>'), $now, $cat_forums_bg );
1908  
1909  
1910      // Insert a post:
1911      $now = date('Y-m-d H:i:s',$timestamp++);
1912      $edited_Item = new Item();
1913      $Item_Forum_welcome_ID = $edited_Item->insert( 1, T_("Welcome to b2evolution!"), T_("<p>Four blogs have been created with sample contents:</p>
1914  
1915  <ul>
1916      <li><strong>Blog A</strong>: You are currently looking at it. It contains a few sample posts, using simple features of b2evolution.</li>
1917      <li><strong>Blog B</strong>: You can access it from a link at the top of the page. It contains information about more advanced features.</li>
1918      <li><strong>Linkblog</strong>: By default, the linkblog is included as a \"Blogroll\" in the sidebar of both Blog A &amp; Blog B.</li>
1919      <li><strong>Photoblog</strong>: This blog is an example of how you can use b2evolution to showcase photos, with one photo per page as well as a thumbnail index.</li>
1920  </ul>
1921  
1922  <p>You can add new blogs, delete unwanted blogs and customize existing blogs (title, sidebar, blog skin, widgets, etc.) from the Blog Settings tab in the admin interface.</p>"), $now, $cat_forums_ann );
1923      $edit_File = new File( 'shared', 0, 'logos/b2evolution8.png' );
1924      $LinkOwner = new LinkItem( $edited_Item );
1925      $edit_File->link_to_Object( $LinkOwner );
1926  
1927      // MANUAL:
1928  
1929      // Insert a main intro:
1930      $now = date('Y-m-d H:i:s',$timestamp++);
1931      $edited_Item = new Item();
1932      $edited_Item->insert( 1, T_("Manual main intro"), T_('This is the main introduction for the manual'), $now, $cat_manual_ann,
1933          array(), 'published', '#', '', '', 'open', array('default'), 1500 );
1934  
1935      // Insert a cat intro:
1936      $now = date('Y-m-d H:i:s',$timestamp++);
1937      $edited_Item = new Item();
1938      $edited_Item->insert( 1, T_("Cat intro post"), T_('This is an intro-cat post for the category with intro post'), $now, $cat_manual_fun,
1939          array(), 'published', '#', '', '', 'open', array('default'), 1520 );
1940  
1941      // Insert a PAGE:
1942      $now = date('Y-m-d H:i:s',$timestamp++);
1943      $edited_Item = new Item();
1944      $edited_Item->insert( 1, T_("About Manual"), sprintf( $info_page, T_('Manual') ), $now, $cat_manual_ann,
1945          array(), 'published', '#', '', '', 'open', array('default'), 1000 );
1946  
1947      // Insert a post:
1948      $now = date('Y-m-d H:i:s',$timestamp++);
1949      $edited_Item = new Item();
1950      $edited_Item->insert( 1, T_('First Topic'), T_('<p>This is the first topic.</p>
1951  
1952  <p>It appears in a single category.</p>'), $now, $cat_manual_ann, array( $cat_manual_news, $cat_manual_movies ),
1953          'published', '#', '', '', 'open', array('default'), 1, NULL, 10 );
1954  
1955      // Insert a post:
1956      $now = date('Y-m-d H:i:s',$timestamp++);
1957      $edited_Item = new Item();
1958      $edited_Item->insert( 1, T_('Second topic'), T_('<p>This is the second topic.</p>
1959  
1960  <p>It appears in multiple categories.</p>'), $now, $cat_manual_news, array( $cat_manual_ann ),
1961          'published', '#', '', '', 'open', array('default'), 1, NULL, 3 );
1962  
1963  
1964      // Insert a post:
1965      $now = date('Y-m-d H:i:s',$timestamp++);
1966      $edited_Item = new Item();
1967      $edited_Item->insert( 1, T_('Image topic'), T_('<p>This topic has an image attached to it. The image is automatically resized to fit the current blog skin. You can zoom in by clicking on the thumbnail.</p>
1968  
1969  <p>Check out the photoblog (accessible through the links at the top) to see a completely different skin focused more on the photos than on the blog text.</p>'), $now, $cat_manual_bg, array( $cat_manual_sports ),
1970          'published', '#', '', '', 'open', array('default'), 1, NULL, 20 );
1971      $edit_File = new File( 'shared', 0, 'monument-valley/monuments.jpg' );
1972      $LinkOwner = new LinkItem( $edited_Item );
1973      $edit_File->link_to_Object( $LinkOwner );
1974  
1975  
1976      // Insert a post:
1977      $now = date('Y-m-d H:i:s',$timestamp++);
1978      $edited_Item = new Item();
1979      $edited_Item->insert( 1, T_('This is a multipage topic'), T_('<p>This is page 1 of a multipage topic.</p>
1980  
1981  <p>You can see the other pages by clicking on the links below the text.</p>
1982  
1983  <!--nextpage-->
1984  
1985  <p>This is page 2.</p>
1986  
1987  <!--nextpage-->
1988  
1989  <p>This is page 3.</p>
1990  
1991  <!--nextpage-->
1992  
1993  <p>This is page 4.</p>
1994  
1995  <p>It is the last page.</p>'), $now, $cat_manual_fun, array(),
1996          'published', '#', '', '', 'open', array('default'), 1, NULL, 8 );
1997  
1998  
1999      // Insert a post:
2000      $now = date('Y-m-d H:i:s',$timestamp++);
2001      $edited_Item = new Item();
2002      $edited_Item->insert( 1, T_('Extended topic with no teaser'), T_('<p>This is an extended topic with no teaser. This means that you won\'t see this teaser any more when you click the "more" link.</p>
2003  
2004  <!--more-->
2005  
2006  <p>This is the extended text. You only see it when you have clicked the "more" link.</p>'), $now, $cat_manual_bg, array(),
2007          'published', '#', '', '', 'open', array('default'), 1, NULL, 5 );
2008      $edited_Item->set_setting( 'hide_teaser', '1' );
2009      $edited_Item->dbsave();
2010  
2011  
2012      // Insert a post:
2013      $now = date('Y-m-d H:i:s',$timestamp++);
2014      $edited_Item = new Item();
2015      $edited_Item->insert( 1, T_('Extended topic'), T_('<p>This is an extended topic. This means you only see this small teaser by default and you must click on the link below to see more.</p>
2016  
2017  <!--more-->
2018  
2019  <p>This is the extended text. You only see it when you have clicked the "more" link.</p>'), $now, $cat_manual_life, array(),
2020          'published', '#', '', '', 'open', array('default'), 1, NULL, 10 );
2021  
2022  
2023      // Insert a post:
2024      $now = date('Y-m-d H:i:s',$timestamp++);
2025      $edited_Item = new Item();
2026      $Item_Manual_welcome_ID = $edited_Item->insert( 1, T_("Welcome to b2evolution!"), T_("<p>Four blogs have been created with sample contents:</p>
2027  
2028  <ul>
2029      <li><strong>Blog A</strong>: You are currently looking at it. It contains a few sample posts, using simple features of b2evolution.</li>
2030      <li><strong>Blog B</strong>: You can access it from a link at the top of the page. It contains information about more advanced features.</li>
2031      <li><strong>Linkblog</strong>: By default, the linkblog is included as a \"Blogroll\" in the sidebar of both Blog A &amp; Blog B.</li>
2032      <li><strong>Photoblog</strong>: This blog is an example of how you can use b2evolution to showcase photos, with one photo per page as well as a thumbnail index.</li>
2033  </ul>
2034  
2035  <p>You can add new blogs, delete unwanted blogs and customize existing blogs (title, sidebar, blog skin, widgets, etc.) from the Blog Settings tab in the admin interface.</p>"), $now, $cat_manual_ann, array( $cat_manual_life ),
2036          'published', '#', '', '', 'open', array('default'), 1, NULL, 5 );
2037      $edit_File = new File( 'shared', 0, 'logos/b2evolution8.png' );
2038      $LinkOwner = new LinkItem( $edited_Item );
2039      $edit_File->link_to_Object( $LinkOwner );
2040  
2041      // Insert a post:
2042      $now = date('Y-m-d H:i:s',$timestamp++);
2043      $edited_Item = new Item();
2044      $edited_Item->insert( 1, T_('Sports post'), T_('<p>This is the sports post.</p>
2045  
2046  <p>It appears in sports category.</p>'), $now, $cat_manual_sports, array(),
2047          'published', '#', '', '', 'open', array('default'), 1, NULL, 15 );
2048  
2049      // Insert a post:
2050      $now = date('Y-m-d H:i:s',$timestamp++);
2051      $edited_Item = new Item();
2052      $edited_Item->insert( 1, T_('Second sports post'), T_('<p>This is the second sports post.</p>
2053  
2054  <p>It appears in sports category.</p>'), $now, $cat_manual_sports, array(),
2055          'published', '#', '', '', 'open', array('default'), 1, NULL, 5 );
2056  
2057      task_end();
2058  
2059  
2060  
2061      task_begin( 'Creating sample comments... ' );
2062  
2063      // Comments for Blog A:
2064      $now = date('Y-m-d H:i:s');
2065      $query = "INSERT INTO T_comments( comment_post_ID, comment_type, comment_author,
2066                                                                                  comment_author_email, comment_author_url, comment_author_IP,
2067                                                                                  comment_date, comment_content, comment_renderers, comment_karma)
2068                          VALUES( '".$Item_BlogA_welcome_ID."', 'comment', 'miss b2', 'missb2@example.com', 'http://example.com', '127.0.0.1',
2069                                       '$now', '".
2070                                       $DB->escape(T_('Hi, this is a comment.<br />To delete a comment, just log in, and view the posts\' comments, there you will have the option to edit or delete them.'))."', 'default', 0)";
2071      $DB->query( $query );
2072  
2073      if( $test_install_all_features )
2074      { // Insert the comments from each user
2075          for( $i_user_ID = 1; $i_user_ID <= 7; $i_user_ID++ )
2076          {
2077              $now = date('Y-m-d H:i:s');
2078              $query = "INSERT INTO T_comments( comment_post_ID, comment_type, comment_author_ID, comment_author_IP,
2079                                                                                  comment_date, comment_content, comment_renderers, comment_karma, comment_notif_status)
2080                                  VALUES( '".$Item_BlogA_welcome_ID."', 'comment', '$i_user_ID', '127.0.0.1', '$now', '".
2081                                               $DB->escape( T_('Hi, this is my comment.') ). "', 'default', 0, 'finished')";
2082              $DB->query( $query );
2083          }
2084      }
2085  
2086      // Comments for Forums:
2087      $now = date('Y-m-d H:i:s');
2088      $query = "INSERT INTO T_comments( comment_post_ID, comment_type, comment_author,
2089                                                                                  comment_author_email, comment_author_url, comment_author_IP,
2090                                                                                  comment_date, comment_content, comment_renderers, comment_karma)
2091                          VALUES( '".$Item_Forum_welcome_ID."', 'comment', 'miss b2', 'missb2@example.com', 'http://example.com', '127.0.0.1',
2092                                       '$now', '".
2093                                       $DB->escape(T_('Hi, this is a comment.<br />To delete a comment, just log in, and view the posts\' comments, there you will have the option to edit or delete them.')). "', 'default', 0)";
2094      $DB->query( $query );
2095  
2096      if( $test_install_all_features )
2097      { // Insert the comments from each user
2098          for( $i_user_ID = 1; $i_user_ID <= 7; $i_user_ID++ )
2099          {
2100              $now = date('Y-m-d H:i:s');
2101              $query = "INSERT INTO T_comments( comment_post_ID, comment_type, comment_author_ID, comment_author_IP,
2102                                                                                  comment_date, comment_content, comment_renderers, comment_karma, comment_notif_status)
2103                                  VALUES( '".$Item_Forum_welcome_ID."', 'comment', '$i_user_ID', '127.0.0.1', '$now', '".
2104                                               $DB->escape( T_('Hi, this is my comment.') ). "', 'default', 0, 'finished')";
2105              $DB->query( $query );
2106          }
2107      }
2108  
2109      // Comments for Manual:
2110      $now = date('Y-m-d H:i:s');
2111      $query = "INSERT INTO T_comments( comment_post_ID, comment_type, comment_author,
2112                                                                                  comment_author_email, comment_author_url, comment_author_IP,
2113                                                                                  comment_date, comment_content, comment_renderers, comment_karma)
2114                          VALUES( '".$Item_Manual_welcome_ID."', 'comment', 'miss b2', 'missb2@example.com', 'http://example.com', '127.0.0.1',
2115                                       '$now', '".
2116                                       $DB->escape(T_('Hi, this is a comment.<br />To delete a comment, just log in, and view the posts\' comments, there you will have the option to edit or delete them.')). "', 'default', 0)";
2117      $DB->query( $query );
2118  
2119      if( $test_install_all_features )
2120      { // Insert the comments from each user
2121          for( $i_user_ID = 1; $i_user_ID <= 7; $i_user_ID++ )
2122          {
2123              $now = date('Y-m-d H:i:s');
2124              $query = "INSERT INTO T_comments( comment_post_ID, comment_type, comment_author_ID, comment_author_IP,
2125                                                                                  comment_date, comment_content, comment_renderers, comment_karma, comment_notif_status)
2126                                  VALUES( '".$Item_Manual_welcome_ID."', 'comment', '$i_user_ID', '127.0.0.1', '$now', '".
2127                                               $DB->escape( T_('Hi, this is my comment.') ). "', 'default', 0, 'finished')";
2128              $DB->query( $query );
2129          }
2130      }
2131  
2132      task_end();
2133  
2134  
2135      if( $test_install_all_features )
2136      {
2137          task_begin( 'Creating fake hit statistics... ' );
2138          load_funcs('sessions/model/_hitlog.funcs.php');
2139          load_funcs('_core/_url.funcs.php');
2140          $insert_data_count = generate_hit_stat(10, 0, 5000);
2141          echo sprintf( '%d test hits are added.', $insert_data_count );
2142          task_end();
2143      }
2144  
2145      task_begin( 'Creating default group/blog permissions... ' );
2146      $query = "
2147          INSERT INTO T_coll_group_perms( bloggroup_blog_ID, bloggroup_group_ID, bloggroup_ismember,
2148              bloggroup_perm_poststatuses, bloggroup_perm_edit, bloggroup_perm_delpost, bloggroup_perm_edit_ts,
2149              bloggroup_perm_delcmts, bloggroup_perm_recycle_owncmts, bloggroup_perm_vote_spam_cmts, bloggroup_perm_cmtstatuses, bloggroup_perm_edit_cmt,
2150              bloggroup_perm_cats, bloggroup_perm_properties,
2151              bloggroup_perm_media_upload, bloggroup_perm_media_browse, bloggroup_perm_media_change )
2152          VALUES ";
2153  
2154      $gp_blogs_IDs = array( $blog_a_ID, $blog_b_ID, $blog_linkblog_ID, $blog_photoblog_ID, $blog_forums_ID, $blog_manual_ID );
2155  
2156      // Init the permissions for all blogs
2157      $all_statuses = "'published,community,deprecated,protected,private,review,draft'";
2158      $gp_user_groups = array(
2159              'admins'     => $Group_Admins->ID.",     1, $all_statuses, 'all', 1, 1, 1, 1, 1, $all_statuses, 'all', 1, 1, 1, 1, 1",
2160              'privileged' => $Group_Privileged->ID.", 1, $all_statuses, 'le', 1, 0, 1, 1, 1, $all_statuses, 'le', 0, 0, 1, 1, 1",
2161              'bloggers'   => $Group_Bloggers->ID.",   1, '', 'no', 0, 0, 0, 0, 1, '', 'no', 0, 0, 1, 1, 0",
2162          );
2163  
2164      // Init the special permissions for Forums
2165      $gp_user_groups_forums = array(
2166              'bloggers'   => $Group_Bloggers->ID.",   1, 'community,draft', 'no', 0, 0, 0, 0, 1, 'community,draft', 'no', 0, 0, 1, 1, 0",
2167              'users'      => $Group_Users->ID.",      1, 'community,draft', 'no', 0, 0, 0, 0, 0, 'community,draft', 'no', 0, 0, 0, 0, 0",
2168              'suspect'    => $Group_Suspect->ID.",    1, 'review,draft', 'no', 0, 0, 0, 0, 0, 'review,draft', 'no', 0, 0, 0, 0, 0"
2169          );
2170      $gp_user_groups_forums = array_merge( $gp_user_groups, $gp_user_groups_forums );
2171  
2172      $query_values = array();
2173      foreach( $gp_blogs_IDs as $gp_blog_ID )
2174      {
2175          if( $gp_blog_ID == $blog_forums_ID )
2176          {    // Permission for forums blogs
2177              foreach( $gp_user_groups_forums as $gp_user_group_perms )
2178              {
2179                  $query_values[] = "( $gp_blog_ID, ".$gp_user_group_perms.")";
2180              }
2181          }
2182          else
2183          {    // Permission for other blogs
2184              foreach( $gp_user_groups as $gp_user_group_perms )
2185              {
2186                  $query_values[] = "( $gp_blog_ID, ".$gp_user_group_perms.")";
2187              }
2188          }
2189      }
2190      $query .= implode( ',', $query_values );
2191      $DB->query( $query );
2192      task_end();
2193  
2194      /*
2195      // Note: we don't really need this any longer, but we might use it for a better default setup later...
2196      echo 'Creating default user/blog permissions... ';
2197      // Admin for blog A:
2198      $query = "INSERT INTO T_coll_user_perms( bloguser_blog_ID, bloguser_user_ID, bloguser_ismember,
2199                              bloguser_perm_poststatuses, bloguser_perm_delpost, bloguser_perm_comments,
2200                              bloguser_perm_cats, bloguser_perm_properties,
2201                              bloguser_perm_media_upload, bloguser_perm_media_browse, bloguser_perm_media_change )
2202                          VALUES
2203                              ( $blog_a_ID, ".$User_Demo->ID.", 1,
2204                              'published,deprecated,protected,private,draft', 1, 1, 0, 0, 1, 1, 1 )";
2205      $DB->query( $query );
2206      echo "OK.<br />\n";
2207      */
2208  
2209      // Allow all modules to create their own demo contents:
2210      modules_call_method( 'create_demo_contents' );
2211  
2212      // Set default locations for each post in test mode installation
2213      create_default_posts_location();
2214  
2215      install_basic_widgets( $new_db_version );
2216  
2217      load_funcs( 'tools/model/_system.funcs.php' );
2218      if( !system_init_caches() )
2219      {
2220          echo "<strong>".T_('The /cache folder could not be created/written to. b2evolution will still work but without caching, which will make it operate slower than optimal.')."</strong><br />\n";
2221      }
2222  }
2223  
2224  
2225  /**
2226   * Create default location for all posts
2227   */
2228  function create_default_posts_location()
2229  {
2230      global $test_install_all_features;
2231  
2232      if( $test_install_all_features )
2233      {    // Set default location in test mode installation
2234          global $DB;
2235  
2236          $DB->query( 'UPDATE T_items__item SET
2237              post_ctry_ID = '.$DB->quote( '74'/* France */ ).',
2238              post_rgn_ID = '.$DB->quote( '60'/* Īle-de-France */ ).',
2239              post_subrg_ID = '.$DB->quote( '76'/* Paris */ ) );
2240      }
2241  }
2242  
2243  ?>

title

Description

title

Description

title

Description

title

title

Body