Exemplo n.º 1
0
 function setUp()
 {
     parent::setUp();
     require_code('ecommerce');
     require_code('catalogues');
     require_code('catalogues2');
     require_code('shopping');
     require_lang('catalogues');
     require_lang('shopping');
     require_lang('ecommerce');
     if (!is_null($GLOBALS['SITE_DB']->query_value_null_ok('catalogues', 'c_name', array('c_name' => 'storetesting' . strval(get_member()))))) {
         actual_delete_catalogue('storetesting' . strval(get_member()));
     }
     $this->access_mapping = array(db_get_first_id() => 4);
     // Creating cms catalogues object
     require_code('cms/pages/modules/cms_catalogues.php');
     $this->cms_cat = new Module_cms_catalogues();
     //Creating Shopping cart object
     require_code('site/pages/modules/shopping.php');
     $this->shopping_cart = new Module_shopping();
     $username = $GLOBALS['FORUM_DRIVER']->get_username(get_member());
     $this->category_id = actual_add_catalogue('storetesting' . strval(get_member()), insert_lang(do_lang('DEFAULT_CATALOGUE_PRODUCTS_TITLE'), 2), '', 0, 1, '', 0, 1);
     $fields = array(array('ECOM_CAT_product_title', 'DESCRIPTION_TITLE', 'short_trans', 1, 1, 1, 1), array('ECOM_CAT_item_code', 'ECOM_CATD_item_code', 'random', 0, 1, 1, 1), array('ECOM_CAT_price_pre_tax', 'ECOM_CATD_price_pre_tax', 'float', 0, 1, 1, 1), array('ECOM_CAT_stock_level', 'ECOM_CATD_stock_level', 'integer', 0, 0, 1, 0), array('ECOM_CAT_stock_level_warn_at', 'ECOM_CATD_stock_level_warn_at', 'integer', 0, 0, 0, 0), array('ECOM_CAT_stock_level_maintain', 'ECOM_CATD_stock_level_maintain', 'tick', 0, 1, 0, 0), array('ECOM_CAT_tax_type', 'ECOM_CATD_tax_type', 'list', 0, 1, 0, 0, "0%|5%|17.5%", 0), array('ECOM_CAT_image', 'ECOM_CATD_image', 'picture', 0, 0, 1, 1), array('ECOM_CAT_weight', 'ECOM_CATD_weight', 'float', 0, 1, 0, 0), array('ECOM_CAT_description', 'DESCRIPTION_DESCRIPTION', 'long_trans', 0, 1, 1, 1));
     foreach ($fields as $i => $field) {
         actual_add_catalogue_field('storetesting' . strval(get_member()), lang_code_to_default_content($field[0], false, 3), lang_code_to_default_content($field[1], true, 3), $field[2] == 'tick' ? 'list' : $field[2], $i, $field[3], $field[5], $field[6], $field[2] == 'tick' ? do_lang('NO') . '|' . do_lang('YES') : (array_key_exists(7, $field) ? $field[7] : ''), $field[4], array_key_exists(5, $field) ? $field[5] : 0, array_key_exists(5, $field) ? $field[5] : 0);
     }
     $catalogue_name = 'storetesting' . strval(get_member());
     //Set Sample post values
     $fields = $GLOBALS['SITE_DB']->query_select('catalogue_fields', array('*'), array('c_name' => $catalogue_name));
     foreach ($fields as $key => $val) {
         $type = $val['cf_type'];
         $id = $val['id'];
         switch ($type) {
             case 'integer':
                 $_POST['field_' . strval($id)] = 4;
                 break;
             case 'short_trans':
                 $_POST['field_' . strval($id)] = 'Test field value';
                 break;
             case 'long_trans':
                 $_POST['field_' . strval($id)] = 'Test field value';
                 break;
             case 'float':
                 $_POST['field_' . strval($id)] = 68.34999999999999;
                 break;
             case 'list':
                 if ($val['cf_order'] = 6) {
                     //Order 6 is tax
                     $_POST['field_' . strval($id)] = 'Arizona=7.8%';
                 } elseif ($val['cf_order'] = 5) {
                     //Order 5 yes keep stock "yes/no"
                     $_POST['field_' . strval($id)] = 'yes';
                 }
                 break;
         }
     }
     $map = $this->cms_cat->get_set_field_map($catalogue_name);
     $this->product_id = actual_add_catalogue_entry($this->category_id, $validated = 0, $notes = 'test note', $allow_rating = 1, $allow_comments = 1, $allow_trackbacks = 1, $map);
 }
Exemplo n.º 2
0
 /**
  * Standard modular install function.
  *
  * @param  ?integer	What version we're upgrading from (NULL: new install)
  * @param  ?integer	What hack version we're upgrading from (NULL: new-install/not-upgrading-from-a-hacked-version)
  */
 function install($upgrade_from = NULL, $upgrade_from_hack = NULL)
 {
     if (is_null($upgrade_from)) {
         require_lang('downloads');
         $GLOBALS['SITE_DB']->create_table('download_categories', array('id' => '*AUTO', 'category' => 'SHORT_TRANS', 'parent_id' => '?AUTO_LINK', 'add_date' => 'TIME', 'notes' => 'LONG_TEXT', 'description' => 'LONG_TRANS', 'rep_image' => 'URLPATH'));
         $lang_key = lang_code_to_default_content('DOWNLOADS_HOME');
         $id = $GLOBALS['SITE_DB']->query_insert('download_categories', array('rep_image' => '', 'parent_id' => NULL, 'add_date' => time(), 'notes' => '', 'description' => insert_lang_comcode('', 3), 'category' => $lang_key), true);
         $groups = $GLOBALS['FORUM_DRIVER']->get_usergroup_list(false, true);
         foreach (array_keys($groups) as $group_id) {
             $GLOBALS['SITE_DB']->query_insert('group_category_access', array('module_the_name' => 'downloads', 'category_name' => strval($id), 'group_id' => $group_id));
         }
         $GLOBALS['SITE_DB']->create_index('download_categories', 'child_find', array('parent_id'));
         $GLOBALS['SITE_DB']->create_table('download_downloads', array('id' => '*AUTO', 'category_id' => 'AUTO_LINK', 'name' => 'SHORT_TRANS', 'url' => 'URLPATH', 'description' => 'LONG_TRANS', 'author' => 'ID_TEXT', 'comments' => 'LONG_TRANS', 'num_downloads' => 'INTEGER', 'out_mode_id' => '?AUTO_LINK', 'add_date' => 'TIME', 'edit_date' => '?TIME', 'validated' => 'BINARY', 'default_pic' => 'INTEGER', 'file_size' => '?INTEGER', 'allow_rating' => 'BINARY', 'allow_comments' => 'SHORT_INTEGER', 'allow_trackbacks' => 'BINARY', 'notes' => 'LONG_TEXT', 'download_views' => 'INTEGER', 'download_cost' => 'INTEGER', 'download_submitter_gets_points' => 'BINARY', 'submitter' => 'USER', 'original_filename' => 'SHORT_TEXT', 'rep_image' => 'URLPATH', 'download_licence' => '?AUTO_LINK', 'download_data_mash' => 'LONG_TEXT'));
         $GLOBALS['SITE_DB']->create_index('download_downloads', 'download_views', array('download_views'));
         $GLOBALS['SITE_DB']->create_index('download_downloads', 'category_list', array('category_id'));
         $GLOBALS['SITE_DB']->create_index('download_downloads', 'recent_downloads', array('add_date'));
         $GLOBALS['SITE_DB']->create_index('download_downloads', 'top_downloads', array('num_downloads'));
         $GLOBALS['SITE_DB']->create_index('download_downloads', 'downloadauthor', array('author'));
         $GLOBALS['SITE_DB']->create_index('download_downloads', 'dds', array('submitter'));
         $GLOBALS['SITE_DB']->create_index('download_downloads', 'ddl', array('download_licence'));
         // For when deleting a download license
         $GLOBALS['SITE_DB']->create_index('download_downloads', 'dvalidated', array('validated'));
         $GLOBALS['SITE_DB']->create_table('download_logging', array('id' => '*AUTO_LINK', 'the_user' => '*USER', 'ip' => 'IP', 'date_and_time' => 'TIME'));
         $GLOBALS['SITE_DB']->create_index('download_logging', 'calculate_bandwidth', array('date_and_time'));
         add_config_option('MAXIMUM_DOWNLOAD', 'maximum_download', 'integer', 'return \'15\';', 'SITE', 'CLOSED_SITE');
         add_config_option('SHOW_DLOAD_TREES', 'show_dload_trees', 'tick', 'return \'0\';', 'FEATURE', 'SECTION_DOWNLOADS', 1);
         add_config_option('ADD_DOWNLOAD', 'points_ADD_DOWNLOAD', 'integer', 'return addon_installed(\'points\')?\'150\':NULL;', 'POINTS', 'COUNT_POINTS_GIVEN');
         require_lang('downloads');
         add_menu_item_simple('main_content', NULL, 'SECTION_DOWNLOADS', '_SEARCH:downloads:type=misc');
         $GLOBALS['SITE_DB']->create_index('download_downloads', 'ftjoin_dname', array('name'));
         $GLOBALS['SITE_DB']->create_index('download_downloads', 'ftjoin_ddescrip', array('description'));
         $GLOBALS['SITE_DB']->create_index('download_downloads', 'ftjoin_dcomments', array('comments'));
         $GLOBALS['SITE_DB']->create_index('download_categories', 'ftjoin_dccat', array('category'));
         $GLOBALS['SITE_DB']->create_index('download_categories', 'ftjoin_dcdescrip', array('description'));
     }
     if (!is_null($upgrade_from) && $upgrade_from < 3) {
         $GLOBALS['SITE_DB']->add_table_field('download_downloads', 'allow_trackbacks', 'BINARY', 1);
         $GLOBALS['SITE_DB']->add_table_field('download_categories', 'rep_image', 'URLPATH');
     }
     if (!is_null($upgrade_from) && $upgrade_from < 5) {
         $GLOBALS['SITE_DB']->add_table_field('download_downloads', 'download_licence', '?AUTO_LINK', NULL);
         $GLOBALS['SITE_DB']->add_table_field('download_downloads', 'download_data_mash', 'LONG_TEXT');
         delete_config_option('is_on_downloads');
     }
     if (is_null($upgrade_from) || $upgrade_from < 5) {
         $GLOBALS['SITE_DB']->create_index('download_downloads', '#download_data_mash', array('download_data_mash'));
         $GLOBALS['SITE_DB']->create_index('download_downloads', '#original_filename', array('original_filename'));
         $GLOBALS['SITE_DB']->create_table('download_licences', array('id' => '*AUTO', 'l_title' => 'SHORT_TEXT', 'l_text' => 'LONG_TEXT'));
         add_config_option('_SECTION_DOWNLOADS', 'downloads_show_stats_count_total', 'tick', 'return addon_installed(\'stats_block\')?\'0\':NULL;', 'BLOCKS', 'STATISTICS');
         add_config_option('TOTAL_DOWNLOADS_IN_ARCHIVE', 'downloads_show_stats_count_archive', 'tick', 'return addon_installed(\'stats_block\')?\'0\':NULL;', 'BLOCKS', 'STATISTICS');
         add_config_option('_COUNT_DOWNLOADS', 'downloads_show_stats_count_downloads', 'tick', 'return addon_installed(\'stats_block\')?\'0\':NULL;', 'BLOCKS', 'STATISTICS');
         add_config_option('_COUNT_BANDWIDTH', 'downloads_show_stats_count_bandwidth', 'tick', 'return addon_installed(\'stats_block\')?\'0\':NULL;', 'BLOCKS', 'STATISTICS');
         add_config_option('IMMEDIATE_DOWNLOADS', 'immediate_downloads', 'tick', 'return \'0\';', 'FEATURE', 'SECTION_DOWNLOADS');
     }
     if (is_null($upgrade_from) || $upgrade_from < 6) {
         add_config_option('DOWNLOAD_GALLERY_ROOT', 'download_gallery_root', 'line', 'return is_null($old=get_value(\'download_gallery_root\'))?(addon_installed(\'galleries\')?\'root\':NULL):$old;', 'FEATURE', 'SECTION_DOWNLOADS');
     }
 }
Exemplo n.º 3
0
 /**
  * Standard modular install function.
  *
  * @param  ?integer	What version we're upgrading from (NULL: new install)
  * @param  ?integer	What hack version we're upgrading from (NULL: new-install/not-upgrading-from-a-hacked-version)
  */
 function install($upgrade_from = NULL, $upgrade_from_hack = NULL)
 {
     if (is_null($upgrade_from)) {
         $GLOBALS['SITE_DB']->create_table('banners', array('name' => '*ID_TEXT', 'expiry_date' => '?TIME', 'submitter' => 'USER', 'img_url' => 'URLPATH', 'b_title_text' => 'SHORT_TEXT', 'the_type' => 'SHORT_INTEGER', 'caption' => 'SHORT_TRANS', 'campaign_remaining' => 'INTEGER', 'site_url' => 'URLPATH', 'hits_from' => 'INTEGER', 'views_from' => 'INTEGER', 'hits_to' => 'INTEGER', 'views_to' => 'INTEGER', 'importance_modulus' => 'INTEGER', 'notes' => 'LONG_TEXT', 'validated' => 'BINARY', 'add_date' => 'TIME', 'edit_date' => '?TIME', 'b_type' => 'ID_TEXT'));
         $GLOBALS['SITE_DB']->create_index('banners', 'banner_child_find', array('b_type'));
         $GLOBALS['SITE_DB']->create_index('banners', 'the_type', array('the_type'));
         $GLOBALS['SITE_DB']->create_index('banners', 'expiry_date', array('expiry_date'));
         $GLOBALS['SITE_DB']->create_index('banners', 'badd_date', array('add_date'));
         $GLOBALS['SITE_DB']->create_index('banners', 'topsites', array('hits_from', 'hits_to'));
         $GLOBALS['SITE_DB']->create_index('banners', 'campaign_remaining', array('campaign_remaining'));
         $GLOBALS['SITE_DB']->create_index('banners', 'bvalidated', array('validated'));
         $GLOBALS['SITE_DB']->query_insert('banners', array('b_title_text' => '', 'name' => 'advertise_here', 'the_type' => 2, 'img_url' => 'data/images/advertise_here.png', 'caption' => lang_code_to_default_content('ADVERTISE_HERE', true, 1), 'campaign_remaining' => 0, 'site_url' => get_base_url() . '/site/index.php?page=advertise', 'hits_from' => 0, 'views_from' => 0, 'hits_to' => 0, 'views_to' => 0, 'importance_modulus' => 10, 'notes' => 'Provided as default. This is a default banner (it shows when others are not available).', 'validated' => 1, 'add_date' => time(), 'submitter' => $GLOBALS['FORUM_DRIVER']->get_guest_id(), 'b_type' => '', 'expiry_date' => NULL, 'edit_date' => NULL));
         $GLOBALS['SITE_DB']->query_insert('banners', array('b_title_text' => '', 'name' => 'donate', 'the_type' => 0, 'img_url' => 'data/images/donate.png', 'caption' => lang_code_to_default_content('DONATION', true, 1), 'campaign_remaining' => 0, 'site_url' => get_base_url() . '/site/index.php?page=donate', 'hits_from' => 0, 'views_from' => 0, 'hits_to' => 0, 'views_to' => 0, 'importance_modulus' => 30, 'notes' => 'Provided as default.', 'validated' => 1, 'add_date' => time(), 'submitter' => $GLOBALS['FORUM_DRIVER']->get_guest_id(), 'b_type' => '', 'expiry_date' => NULL, 'edit_date' => NULL));
         $banner_a = 'advertise_here';
         $banner_c = 'donate';
         $groups = $GLOBALS['FORUM_DRIVER']->get_usergroup_list(false, true);
         foreach (array_keys($groups) as $group_id) {
             $GLOBALS['SITE_DB']->query_insert('group_category_access', array('module_the_name' => 'banners', 'category_name' => $banner_a, 'group_id' => $group_id));
             $GLOBALS['SITE_DB']->query_insert('group_category_access', array('module_the_name' => 'banners', 'category_name' => $banner_c, 'group_id' => $group_id));
         }
         add_config_option('ENABLE_BANNERS', 'is_on_banners', 'tick', 'return \'1\';', 'FEATURE', 'BANNERS');
         add_config_option('MONEY_AD_CODE', 'money_ad_code', 'text', 'return \'\';', 'FEATURE', 'BANNERS', 1);
         add_config_option('ADVERT_CHANCE', 'advert_chance', 'float', 'return \'5\';', 'FEATURE', 'BANNERS', 1);
         add_specific_permission('BANNERS', 'full_banner_setup', false);
         add_specific_permission('BANNERS', 'view_anyones_banner_stats', false);
         add_config_option('ADD_BANNER', 'points_ADD_BANNER', 'integer', 'return addon_installed(\'points\')?\'0\':NULL;', 'POINTS', 'COUNT_POINTS_GIVEN');
         //add_menu_item_simple('main_website',NULL,'DONATE','_SEARCH:donate');
     }
     if (!is_null($upgrade_from) && $upgrade_from < 3) {
         $GLOBALS['SITE_DB']->add_table_field('banners', 'b_type', 'ID_TEXT');
     }
     if (is_null($upgrade_from) || $upgrade_from < 4) {
         $GLOBALS['SITE_DB']->create_table('banner_types', array('id' => '*ID_TEXT', 't_is_textual' => 'BINARY', 't_image_width' => 'INTEGER', 't_image_height' => 'INTEGER', 't_max_file_size' => 'INTEGER', 't_comcode_inline' => 'BINARY'));
         $GLOBALS['SITE_DB']->create_index('banner_types', 'hottext', array('t_comcode_inline'));
         $GLOBALS['SITE_DB']->query_insert('banner_types', array('id' => '', 't_is_textual' => 0, 't_image_width' => 468, 't_image_height' => 60, 't_max_file_size' => 80, 't_comcode_inline' => 0));
         $GLOBALS['SITE_DB']->create_table('banner_clicks', array('id' => '*AUTO', 'c_date_and_time' => 'TIME', 'c_member_id' => 'USER', 'c_ip_address' => 'IP', 'c_source' => 'ID_TEXT', 'c_banner_id' => 'ID_TEXT'));
         $GLOBALS['SITE_DB']->create_index('banner_clicks', 'clicker_ip', array('c_ip_address'));
         add_specific_permission('BANNERS', 'banner_free', false);
         add_config_option('PERMISSIONS', 'use_banner_permissions', 'tick', 'return \'0\';', 'FEATURE', 'BANNERS');
         $GLOBALS['SITE_DB']->query_update('banners', array('b_type' => 'BANNERS'), array('b_type' => '_BANNERS'));
     }
     if (!is_null($upgrade_from) && $upgrade_from < 4) {
         $GLOBALS['SITE_DB']->add_table_field('banners', 'b_title_text', 'SHORT_TEXT');
     }
     if (is_null($upgrade_from) || $upgrade_from < 5) {
         add_config_option('BANNER_AUTOSIZE', 'banner_autosize', 'tick', 'return is_null($old=get_value(\'banner_autosize\'))?\'0\':$old;', 'FEATURE', 'BANNERS');
         add_config_option('ADMIN_BANNERS', 'admin_banners', 'tick', 'return is_null($old=get_value(\'always_banners\'))?\'0\':$old;', 'FEATURE', 'BANNERS');
     }
 }
Exemplo n.º 4
0
 /**
  * Standard modular install function.
  *
  * @param  ?integer	What version we're upgrading from (NULL: new install)
  * @param  ?integer	What hack version we're upgrading from (NULL: new-install/not-upgrading-from-a-hacked-version)
  */
 function install($upgrade_from = NULL, $upgrade_from_hack = NULL)
 {
     if (is_null($upgrade_from)) {
         $GLOBALS['SITE_DB']->create_table('news', array('id' => '*AUTO', 'date_and_time' => 'TIME', 'title' => 'SHORT_TRANS', 'news' => 'LONG_TRANS', 'news_article' => 'LONG_TRANS', 'allow_rating' => 'BINARY', 'allow_comments' => 'SHORT_INTEGER', 'allow_trackbacks' => 'BINARY', 'notes' => 'LONG_TEXT', 'author' => 'ID_TEXT', 'submitter' => 'USER', 'validated' => 'BINARY', 'edit_date' => '?TIME', 'news_category' => 'AUTO_LINK', 'news_views' => 'INTEGER', 'news_image' => 'URLPATH'));
         $GLOBALS['SITE_DB']->create_index('news', 'news_views', array('news_views'));
         $GLOBALS['SITE_DB']->create_index('news', 'findnewscat', array('news_category'));
         $GLOBALS['SITE_DB']->create_index('news', 'newsauthor', array('author'));
         $GLOBALS['SITE_DB']->create_index('news', 'nes', array('submitter'));
         $GLOBALS['SITE_DB']->create_index('news', 'headlines', array('date_and_time', 'id'));
         $GLOBALS['SITE_DB']->create_index('news', 'nvalidated', array('validated'));
         $GLOBALS['SITE_DB']->create_table('news_categories', array('id' => '*AUTO', 'nc_title' => 'SHORT_TRANS', 'nc_owner' => '?USER', 'nc_img' => 'ID_TEXT', 'notes' => 'LONG_TEXT'));
         $GLOBALS['SITE_DB']->create_index('news_categories', 'ncs', array('nc_owner'));
         $default_categories = array('general', 'technology', 'difficulties', 'community', 'entertainment', 'business', 'art');
         require_lang('news');
         foreach ($default_categories as $category) {
             $GLOBALS['SITE_DB']->query_insert('news_categories', array('notes' => '', 'nc_img' => 'newscats/' . $category, 'nc_owner' => NULL, 'nc_title' => lang_code_to_default_content('NC_' . $category)));
         }
         $GLOBALS['SITE_DB']->create_table('news_rss_cloud', array('id' => '*AUTO', 'rem_procedure' => 'ID_TEXT', 'rem_port' => 'SHORT_INTEGER', 'rem_path' => 'SHORT_TEXT', 'rem_protocol' => 'ID_TEXT', 'rem_ip' => 'IP', 'watching_channel' => 'URLPATH', 'register_time' => 'TIME'));
         add_config_option('ADD_NEWS', 'points_ADD_NEWS', 'integer', 'return addon_installed(\'points\')?\'225\':NULL;', 'POINTS', 'COUNT_POINTS_GIVEN');
         add_config_option('NEWS_REGULARITY', 'news_update_time', 'integer', 'return \'168\';', 'ADMIN', 'CHECK_LIST');
         add_config_option('BLOG_REGULARITY', 'blog_update_time', 'integer', 'return \'168\';', 'ADMIN', 'CHECK_LIST');
     }
     if ($upgrade_from < 3 || is_null($upgrade_from)) {
         $GLOBALS['SITE_DB']->create_table('news_category_entries', array('news_entry' => '*AUTO_LINK', 'news_entry_category' => '*AUTO_LINK'));
         $GLOBALS['SITE_DB']->create_index('news_category_entries', 'news_entry_category', array('news_entry_category'));
         $groups = $GLOBALS['FORUM_DRIVER']->get_usergroup_list(false, true);
         $categories = $GLOBALS['SITE_DB']->query_select('news_categories', array('id'));
         foreach ($categories as $_id) {
             foreach (array_keys($groups) as $group_id) {
                 $GLOBALS['SITE_DB']->query_insert('group_category_access', array('module_the_name' => 'news', 'category_name' => strval($_id['id']), 'group_id' => $group_id));
             }
         }
     }
     if (!is_null($upgrade_from) && $upgrade_from < 3) {
         $GLOBALS['SITE_DB']->add_table_field('news', 'allow_trackbacks', 'BINARY', 1);
         $GLOBALS['SITE_DB']->add_table_field('news_categories', 'nc_owner', '?USER');
     }
     if (!is_null($upgrade_from) && $upgrade_from < 4) {
         $GLOBALS['SITE_DB']->add_table_field('news', 'news_image', 'URLPATH', '');
     }
     if (is_null($upgrade_from) || $upgrade_from < 4) {
         add_config_option('PING_URL', 'ping_url', 'text', 'return \'http://pingomatic.com/ping/?title={title}&blogurl={url}&rssurl={rss}&chk_feedburner=on&chk_newsgator=on&chk_myyahoo=on&chk_google=on\';', 'FEATURE', 'NEWS_AND_RSS');
         add_config_option('TOTAL_NEWS_ENTRIES', 'news_show_stats_count_total_posts', 'tick', 'return addon_installed(\'stats_block\')?\'0\':NULL;', 'BLOCKS', 'STATISTICS');
         add_config_option('BLOGS', 'news_show_stats_count_blogs', 'tick', 'return addon_installed(\'stats_block\')?\'0\':NULL;', 'BLOCKS', 'STATISTICS');
         $GLOBALS['SITE_DB']->create_index('news', 'ftjoin_ititle', array('title'));
         $GLOBALS['SITE_DB']->create_index('news', 'ftjoin_nnews', array('news'));
         $GLOBALS['SITE_DB']->create_index('news', 'ftjoin_nnewsa', array('news_article'));
     }
 }
Exemplo n.º 5
0
 /**
  * Standard modular install function.
  *
  * @param  ?integer	What version we're upgrading from (NULL: new install)
  * @param  ?integer	What hack version we're upgrading from (NULL: new-install/not-upgrading-from-a-hacked-version)
  */
 function install($upgrade_from = NULL, $upgrade_from_hack = NULL)
 {
     if (!is_null($upgrade_from) && $upgrade_from < 3) {
         delete_specific_permission('choose_dotw');
         delete_config_option('dotw_update_time');
         $GLOBALS['SITE_DB']->rename_table('dotw', 'award_archive');
         $GLOBALS['SITE_DB']->add_table_field('award_archive', 'a_type_id', 'AUTO_LINK', db_get_first_id());
         $GLOBALS['SITE_DB']->alter_table_field('award_archive', 'id', 'ID_TEXT', 'content_id');
         $GLOBALS['SITE_DB']->add_table_field('award_archive', 'member_id', 'USER', $GLOBALS['FORUM_DRIVER']->get_guest_id());
         $GLOBALS['SITE_DB']->change_primary_key('award_archive', array('a_type_id', 'date_and_time'));
     }
     if (is_null($upgrade_from)) {
         $GLOBALS['SITE_DB']->create_table('award_archive', array('a_type_id' => '*AUTO_LINK', 'date_and_time' => '*TIME', 'content_id' => 'ID_TEXT', 'member_id' => 'USER'));
     }
     $GLOBALS['SITE_DB']->create_index('award_archive', 'awardquicksearch', array('content_id'));
     if (!is_null($upgrade_from) && $upgrade_from < 3 || is_null($upgrade_from)) {
         $GLOBALS['SITE_DB']->create_table('award_types', array('id' => '*AUTO', 'a_title' => 'SHORT_TRANS', 'a_description' => 'LONG_TRANS', 'a_points' => 'INTEGER', 'a_content_type' => 'ID_TEXT', 'a_hide_awardee' => 'BINARY', 'a_update_time_hours' => 'INTEGER'));
         require_lang('awards');
         $GLOBALS['SITE_DB']->query_insert('award_types', array('a_title' => lang_code_to_default_content('DOTW'), 'a_description' => lang_code_to_default_content('DESCRIPTION_DOTW'), 'a_points' => 0, 'a_content_type' => 'download', 'a_hide_awardee' => 1, 'a_update_time_hours' => 168));
     }
 }
Exemplo n.º 6
0
 /**
  * Add a custom comcode field for this URL type.
  */
 function add_custom_comcode_field()
 {
     $GLOBALS['SITE_DB']->query_insert('custom_comcode', array('tag_tag' => 'facebook_video', 'tag_title' => lang_code_to_default_content('custom_comcode:FACEBOOK_TAG_TITLE'), 'tag_description' => lang_code_to_default_content('custom_comcode:FACEBOOK_TAG_DESCRIPTION'), 'tag_replace' => '{$SET,VIDEO,{$PREG_REPLACE,(http://.*\\?v=)?(\\w+)(.*)?,$\\{2\\},{content}}}<object width="640" height="385"><param name="movie" value="http://www.facebook.com/v/{$GET*,VIDEO};hl=en_US"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.facebook.com/v/{$GET*,VIDEO};hl=en_US" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="385"></embed></object>', 'tag_example' => '[facebook_video]http://www.facebook.com/video/video.php?v=10150307159560581[/facebook_video]', 'tag_parameters' => '', 'tag_enabled' => 1, 'tag_dangerous_tag' => 0, 'tag_block_tag' => 1, 'tag_textual_tag' => 0));
 }
Exemplo n.º 7
0
 /**
  * Standard modular install function.
  *
  * @param  ?integer	What version we're upgrading from (NULL: new install)
  * @param  ?integer	What hack version we're upgrading from (NULL: new-install/not-upgrading-from-a-hacked-version)
  */
 function install($upgrade_from = NULL, $upgrade_from_hack = NULL)
 {
     require_lang('calendar');
     if (is_null($upgrade_from)) {
         add_specific_permission('CALENDAR', 'view_calendar', true);
         add_specific_permission('CALENDAR', 'add_public_events', true);
         add_specific_permission('CALENDAR', 'view_personal_events', false, true);
         add_specific_permission('CALENDAR', 'sense_personal_conflicts', false);
         add_specific_permission('CALENDAR', 'view_event_subscriptions', false);
         $GLOBALS['SITE_DB']->create_table('calendar_events', array('id' => '*AUTO', 'e_submitter' => 'USER', 'e_views' => 'INTEGER', 'e_title' => 'SHORT_TRANS', 'e_content' => 'LONG_TRANS', 'e_add_date' => 'TIME', 'e_edit_date' => '?TIME', 'e_recurrence' => 'ID_TEXT', 'e_recurrences' => '?INTEGER', 'e_seg_recurrences' => 'BINARY', 'e_start_year' => 'INTEGER', 'e_start_month' => 'INTEGER', 'e_start_day' => 'INTEGER', 'e_start_hour' => '?INTEGER', 'e_start_minute' => '?INTEGER', 'e_end_year' => '?INTEGER', 'e_end_month' => '?INTEGER', 'e_end_day' => '?INTEGER', 'e_end_hour' => '?INTEGER', 'e_end_minute' => '?INTEGER', 'e_timezone' => 'ID_TEXT', 'e_do_timezone_conv' => 'BINARY', 'e_is_public' => 'BINARY', 'e_priority' => 'INTEGER', 'allow_rating' => 'BINARY', 'allow_comments' => 'SHORT_INTEGER', 'allow_trackbacks' => 'BINARY', 'notes' => 'LONG_TEXT', 'e_type' => 'AUTO_LINK', 'validated' => 'BINARY'));
         $GLOBALS['SITE_DB']->create_index('calendar_events', 'e_views', array('e_views'));
         $GLOBALS['SITE_DB']->create_index('calendar_events', 'ces', array('e_submitter'));
         $GLOBALS['SITE_DB']->create_index('calendar_events', 'publicevents', array('e_is_public'));
         $GLOBALS['SITE_DB']->create_index('calendar_events', 'e_type', array('e_type'));
         $GLOBALS['SITE_DB']->create_index('calendar_events', 'eventat', array('e_start_year', 'e_start_month', 'e_start_day', 'e_start_hour', 'e_start_minute'));
         $GLOBALS['SITE_DB']->create_index('calendar_events', 'e_add_date', array('e_add_date'));
         $GLOBALS['SITE_DB']->create_index('calendar_events', 'validated', array('validated'));
         $GLOBALS['SITE_DB']->create_table('calendar_types', array('id' => '*AUTO', 't_title' => 'SHORT_TRANS', 't_logo' => 'SHORT_TEXT', 't_external_feed' => 'URLPATH'));
         $default_types = array('system_command', 'general', 'birthday', 'public_holiday', 'vacation', 'appointment', 'commitment', 'anniversary');
         foreach ($default_types as $type) {
             $GLOBALS['SITE_DB']->query_insert('calendar_types', array('t_external_feed' => '', 't_title' => lang_code_to_default_content('DEFAULT_CALENDAR_TYPE__' . $type), 't_logo' => 'calendar/' . $type));
         }
         $GLOBALS['SITE_DB']->create_table('calendar_reminders', array('id' => '*AUTO', 'e_id' => 'AUTO_LINK', 'n_member_id' => 'USER', 'n_seconds_before' => 'INTEGER'));
         $GLOBALS['SITE_DB']->create_table('calendar_interests', array('i_member_id' => '*USER', 't_type' => '*AUTO_LINK'));
     }
     if (is_null($upgrade_from) || $upgrade_from < 3) {
         $GLOBALS['SITE_DB']->create_table('calendar_jobs', array('id' => '*AUTO', 'j_time' => 'TIME', 'j_reminder_id' => '?AUTO_LINK', 'j_member_id' => '?USER', 'j_event_id' => 'AUTO_LINK'));
         $GLOBALS['SITE_DB']->create_index('calendar_jobs', 'applicablejobs', array('j_time'));
     }
     if (!is_null($upgrade_from) && $upgrade_from < 3) {
         $GLOBALS['SITE_DB']->alter_table_field('calendar_events', 'e_edit_date', '?TIME');
         $GLOBALS['SITE_DB']->alter_table_field('calendar_events', 'e_end_minute', '?INTEGER');
         $GLOBALS['SITE_DB']->alter_table_field('calendar_events', 'e_end_hour', '?INTEGER');
         $GLOBALS['SITE_DB']->alter_table_field('calendar_events', 'e_end_day', '?INTEGER');
         $GLOBALS['SITE_DB']->alter_table_field('calendar_events', 'e_end_month', '?INTEGER');
         $GLOBALS['SITE_DB']->alter_table_field('calendar_events', 'e_end_year', '?INTEGER');
     }
     if (!is_null($upgrade_from) && $upgrade_from < 4) {
         $GLOBALS['SITE_DB']->add_table_field('calendar_events', 'allow_rating', 'BINARY', 0);
         $GLOBALS['SITE_DB']->add_table_field('calendar_events', 'allow_comments', 'SHORT_INTEGER', 0);
         $GLOBALS['SITE_DB']->add_table_field('calendar_events', 'allow_trackbacks', 'BINARY', 0);
         $GLOBALS['SITE_DB']->add_table_field('calendar_events', 'notes', 'LONG_TEXT');
         $GLOBALS['SITE_DB']->add_table_field('calendar_events', 'validated', 'BINARY', 1);
         delete_specific_permission('edit_owned_events');
         delete_specific_permission('edit_viewable_events');
         add_config_option('ADD_CALENDAR_EVENT', 'points_ADD_CALENDAR_EVENT', 'integer', 'return addon_installed(\'points\')?\'2\':NULL;', 'POINTS', 'COUNT_POINTS_GIVEN');
         $GLOBALS['SITE_DB']->rename_table('calendar_declarations_of_interest', 'calendar_interests');
     }
     if (!is_null($upgrade_from) && $upgrade_from < 5) {
         $GLOBALS['SITE_DB']->add_table_field('calendar_events', 'e_seg_recurrences', 'BINARY', 0);
     }
     if (is_null($upgrade_from) || $upgrade_from < 5) {
         add_config_option('EVENTS', 'calendar_show_stats_count_events', 'tick', 'return addon_installed(\'stats_block\')?\'0\':NULL;', 'BLOCKS', 'STATISTICS');
         add_config_option('_EVENTS_THIS_WEEK', 'calendar_show_stats_count_events_this_week', 'tick', 'return addon_installed(\'stats_block\')?\'0\':NULL;', 'BLOCKS', 'STATISTICS');
         add_config_option('_EVENTS_THIS_MONTH', 'calendar_show_stats_count_events_this_month', 'tick', 'return addon_installed(\'stats_block\')?\'0\':NULL;', 'BLOCKS', 'STATISTICS');
         add_config_option('_EVENTS_THIS_YEAR', 'calendar_show_stats_count_events_this_year', 'tick', 'return addon_installed(\'stats_block\')?\'0\':NULL;', 'BLOCKS', 'STATISTICS');
         $GLOBALS['SITE_DB']->create_index('calendar_events', 'ftjoin_etitle', array('e_title'));
         $GLOBALS['SITE_DB']->create_index('calendar_events', 'ftjoin_econtent', array('e_content'));
     }
     if (!is_null($upgrade_from) && $upgrade_from < 6) {
         $GLOBALS['SITE_DB']->delete_table_field('calendar_events', 'e_geo_position');
         $GLOBALS['SITE_DB']->delete_table_field('calendar_events', 'e_groups_access');
         $GLOBALS['SITE_DB']->delete_table_field('calendar_events', 'e_groups_modify');
         $GLOBALS['SITE_DB']->add_table_field('calendar_events', 'e_timezone', 'ID_TEXT');
         $GLOBALS['SITE_DB']->add_table_field('calendar_events', 'e_do_timezone_conv', 'BINARY');
         $GLOBALS['SITE_DB']->alter_table_field('calendar_events', 'e_start_hour', '?INTEGER');
         $GLOBALS['SITE_DB']->alter_table_field('calendar_events', 'e_start_minute', '?INTEGER');
         $GLOBALS['SITE_DB']->add_table_field('calendar_types', 't_external_feed', 'URLPATH');
     }
     if (is_null($upgrade_from) || $upgrade_from < 6) {
         $admin_groups = $GLOBALS['FORUM_DRIVER']->get_super_admin_groups();
         $groups = $GLOBALS['FORUM_DRIVER']->get_usergroup_list(false, true);
         // Save in permissions for event type
         $types = $GLOBALS['SITE_DB']->query_select('calendar_types');
         foreach ($types as $type) {
             foreach (array_keys($groups) as $group_id) {
                 if (in_array($group_id, $admin_groups)) {
                     continue;
                 }
                 $GLOBALS['SITE_DB']->query_insert('group_category_access', array('module_the_name' => 'calendar', 'category_name' => strval($type['id']), 'group_id' => $group_id));
             }
         }
     }
 }
Exemplo n.º 8
0
 /**
  * Standard import function.
  *
  * @param  object			The DB connection to import from
  * @param  string			The table prefix the target prefix is using
  * @param  PATH			The base directory we are importing from
  */
 function import_contacts($db, $table_prefix, $old_base_dir)
 {
     require_code('catalogues2');
     require_code('catalogues');
     // Add contacts catalogue if it doesn't already exist
     $test = $GLOBALS['SITE_DB']->query_value_null_ok('catalogues', 'c_name', array('c_name' => 'contacts'));
     if (is_null($test)) {
         actual_add_catalogue('contacts', lang_code_to_default_content('CONTACTS', false, 2), insert_lang('', 2), 0, 0, '', 30);
         $fields = array(array('CONTACT_FIRST_NAME', '', 'short_text', 0, 1), array('CONTACT_LAST_NAME', '', 'short_text', 1, 1), array('EMAIL_ADDRESS', '', 'short_text', 0, 1), array('CONTACT_COMPANY', '', 'short_text', 0, 1), array('CONTACT_HOMEADDRESS', '', 'short_text', 0, 1), array('CONTACT_CITY', '', 'short_text', 0, 1), array('CONTACT_HOMEPHONE', '', 'short_text', 0, 1), array('CONTACT_WORKPHONE', '', 'short_text', 0, 1), array('CONTACT_HOMEPAGE', '', 'short_text', 0, 1), array('CONTACT_IM', '', 'short_text', 0, 1), array('CONTACT_EVENTS', '', 'long_text', 0, 1), array('CONTACT_NOTES', '', 'long_text', 0, 1));
         foreach ($fields as $i => $field) {
             actual_add_catalogue_field('contacts', lang_code_to_default_content($field[0], false, 3), insert_lang('', 2), $field[2], $i, $field[3], 1, 1, '', $field[4]);
         }
     }
     $id = actual_add_catalogue_category('contacts', 'ex-phpNuke', '', '', NULL, '');
     $fields = collapse_1d_complexity('id', $GLOBALS['SITE_DB']->query_select('catalogue_fields', array('id'), array('c_name' => 'contacts')));
     $contacts = $db->query('SELECT * FROM ' . $table_prefix . 'contactbook');
     foreach ($contacts as $row) {
         $map = array($fields[0] => $row['firstname'], $fields[1] => $row['lastname'], $fields[2] => $row['email'], $fields[3] => $row['company'], $fields[4] => $row['homeaddress'], $fields[5] => $row['city'], $fields[6] => $row['homephone'], $fields[7] => $row['workphone'], $fields[8] => $row['homepage'], $fields[9] => $row['IM'], $fields[10] => $row['events'], $fields[11] => $row['notes']);
         actual_add_catalogue_entry($id, 1, '', 0, 0, 0, $map);
     }
 }
Exemplo n.º 9
0
 /**
  * Add a custom comcode field for this URL type.
  */
 function add_custom_comcode_field()
 {
     $GLOBALS['SITE_DB']->query_insert('custom_comcode', array('tag_tag' => 'youtube', 'tag_title' => lang_code_to_default_content('custom_comcode:YOUTUBE_TAG_TITLE'), 'tag_description' => lang_code_to_default_content('custom_comcode:YOUTUBE_TAG_DESCRIPTION'), 'tag_replace' => '{$SET,VIDEO,{$PREG_REPLACE,(https?://.*\\?v=)?(https?://youtu.be/)?([\\w\\-]+)(.*)?,$\\{3\\},{$STRIP_TAGS,{content}}}}<object width="480" height="385"><param name="movie" value="https://www.youtube.com/v/{$GET*,VIDEO}?fs=1&amp;hl=en_US"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="https://www.youtube.com/v/{$GET*,VIDEO}?fs=1&amp;hl=en_US" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385"></embed></object>', 'tag_example' => '[youtube]http://www.youtube.com/watch?v=ZDFFHaz9GsY[/youtube]', 'tag_parameters' => '', 'tag_enabled' => 1, 'tag_dangerous_tag' => 0, 'tag_block_tag' => 1, 'tag_textual_tag' => 0));
 }
Exemplo n.º 10
0
 /**
  * Standard modular install function.
  *
  * @param  ?integer	What version we're upgrading from (NULL: new install)
  * @param  ?integer	What hack version we're upgrading from (NULL: new-install/not-upgrading-from-a-hacked-version)
  */
 function install($upgrade_from = NULL, $upgrade_from_hack = NULL)
 {
     if (is_null($upgrade_from)) {
         $GLOBALS['SITE_DB']->create_table('newsletter', array('id' => '*AUTO', 'email' => 'SHORT_TEXT', 'join_time' => 'TIME', 'code_confirm' => 'INTEGER', 'the_password' => 'MD5', 'pass_salt' => 'ID_TEXT', 'language' => 'ID_TEXT', 'n_forename' => 'SHORT_TEXT', 'n_surname' => 'SHORT_TEXT'));
         $GLOBALS['SITE_DB']->create_index('newsletter', 'welcomemails', array('join_time'));
         $GLOBALS['SITE_DB']->create_index('newsletter', 'code_confirm', array('code_confirm'));
         $GLOBALS['SITE_DB']->create_table('newsletter_archive', array('id' => '*AUTO', 'date_and_time' => 'INTEGER', 'subject' => 'SHORT_TEXT', 'newsletter' => 'LONG_TEXT', 'language' => 'ID_TEXT', 'importance_level' => 'INTEGER'));
         add_config_option('PAGE_TEXT', 'newsletter_text', 'transtext', 'return \'\';', 'FEATURE', 'NEWSLETTER');
         add_config_option('TITLE', 'newsletter_title', 'line', 'return get_option(\'site_name\').\' \'.ocp_mb_strtolower(do_lang(\'NEWSLETTER\'));', 'FEATURE', 'NEWSLETTER');
         add_specific_permission('NEWSLETTER', 'change_newsletter_subscriptions', false);
         require_lang('newsletter');
         //add_menu_item_simple('main_website',NULL,'NEWSLETTER','_SEARCH:newsletter:type=misc');
     }
     if (!is_null($upgrade_from) && $upgrade_from < 3) {
         $GLOBALS['SITE_DB']->add_table_field('newsletter', 'pass_salt', 'ID_TEXT', '');
     }
     if (!is_null($upgrade_from) && $upgrade_from < 4) {
         $GLOBALS['SITE_DB']->add_table_field('newsletter', 'join_time', 'TIME');
     }
     if (!is_null($upgrade_from) && $upgrade_from < 5) {
         set_option('newsletter_text', '[html]' . get_option('newsletter_text') . '[/html]');
     }
     if (is_null($upgrade_from) || $upgrade_from < 6) {
         require_lang('newsletter');
         $GLOBALS['SITE_DB']->create_table('newsletters', array('id' => '*AUTO', 'title' => 'SHORT_TRANS', 'description' => 'LONG_TRANS'));
         $GLOBALS['SITE_DB']->query_insert('newsletters', array('title' => lang_code_to_default_content('GENERAL'), 'description' => lang_code_to_default_content('NEWSLETTER_GENERAL')));
         $GLOBALS['SITE_DB']->create_table('newsletter_subscribe', array('newsletter_id' => '*AUTO_LINK', 'the_level' => 'SHORT_INTEGER', 'email' => '*SHORT_TEXT'));
         $GLOBALS['SITE_DB']->create_index('newsletter_subscribe', 'peopletosendto', array('the_level'));
     }
     if (!is_null($upgrade_from) && $upgrade_from < 6) {
         $GLOBALS['SITE_DB']->alter_table_field('newsletter', 'email', 'SHORT_TEXT');
         $subscribes = $GLOBALS['SITE_DB']->query_select('newsletter', array('the_level', 'email'));
         foreach ($subscribes as $subscribe) {
             $subscribe['newsletter_id'] = db_get_first_id();
             $GLOBALS['SITE_DB']->query_insert('newsletter_subscribe', $subscribe);
         }
         $GLOBALS['SITE_DB']->delete_table_field('newsletter', 'the_level');
     }
     if (is_null($upgrade_from) || $upgrade_from < 7) {
         add_config_option('USE_INTEREST_LEVELS', 'interest_levels', 'tick', 'return \'0\';', 'FEATURE', 'NEWSLETTER');
     }
     if (!is_null($upgrade_from) && $upgrade_from < 7) {
         // THIS STUFF DONE BECAUSE WE NEED A NUMERIC ID FOR IMPORT/EXPORT OF NEWSLETTER SUBSCRIBERS
         /*$GLOBALS['SITE_DB']->add_table_field('newsletter','id','INTEGER'); // can't handle more than one row when it tries to become a key, as not sequential
         		$GLOBALS['SITE_DB']->change_primary_key('newsletter',array('id'));
         		$GLOBALS['SITE_DB']->alter_table_field('newsletter','id','AUTO');*/
         // Works with mySQL only, but it's okay because before v4 of ocPortal (which this upgrades to), there's only mySQL support
         $GLOBALS['SITE_DB']->query('ALTER TABLE ' . get_table_prefix() . 'newsletter DROP PRIMARY KEY');
         $GLOBALS['SITE_DB']->query('ALTER TABLE ' . get_table_prefix() . 'newsletter ADD id INT NOT NULL AUTO_INCREMENT PRIMARY KEY');
         $GLOBALS['SITE_DB']->query_insert('db_meta', array('m_table' => 'newsletter', 'm_name' => 'id', 'm_type' => 'AUTO*'));
         // Add some extra data...
         $GLOBALS['SITE_DB']->add_table_field('newsletter', 'n_forename', 'SHORT_TEXT');
         $GLOBALS['SITE_DB']->add_table_field('newsletter', 'n_surname', 'SHORT_TEXT');
     }
     if (is_null($upgrade_from) || $upgrade_from < 8) {
         $GLOBALS['SITE_DB']->create_table('newsletter_drip_send', array('id' => '*AUTO', 'd_inject_time' => 'TIME', 'd_subject' => 'SHORT_TEXT', 'd_message' => 'LONG_TEXT', 'd_html_only' => 'BINARY', 'd_to_email' => 'SHORT_TEXT', 'd_to_name' => 'SHORT_TEXT', 'd_from_email' => 'SHORT_TEXT', 'd_from_name' => 'SHORT_TEXT', 'd_priority' => 'SHORT_INTEGER', 'd_template' => 'ID_TEXT'));
         $GLOBALS['SITE_DB']->create_index('newsletter_drip_send', 'd_inject_time', array('d_inject_time'));
     }
     if (is_null($upgrade_from) || $upgrade_from < 9) {
         $GLOBALS['SITE_DB']->create_table('newsletter_periodic', array('id' => '*AUTO', 'np_message' => 'LONG_TEXT', 'np_subject' => 'LONG_TEXT', 'np_lang' => 'LANGUAGE_NAME', 'np_send_details' => 'LONG_TEXT', 'np_html_only' => 'BINARY', 'np_from_email' => 'SHORT_TEXT', 'np_from_name' => 'SHORT_TEXT', 'np_priority' => 'SHORT_INTEGER', 'np_csv_data' => 'LONG_TEXT', 'np_frequency' => 'SHORT_TEXT', 'np_day' => 'SHORT_INTEGER', 'np_in_full' => 'BINARY', 'np_template' => 'ID_TEXT', 'np_last_sent' => 'TIME'));
     }
     if (!is_null($upgrade_from) && $upgrade_from >= 8 && $upgrade_from < 9) {
         $GLOBALS['SITE_DB']->add_table_field('newsletter_drip_send', 'd_template', 'ID_TEXT');
     }
 }
Exemplo n.º 11
0
 /**
  * Standard modular install function.
  *
  * @param  ?integer	What version we're upgrading from (NULL: new install)
  * @param  ?integer	What hack version we're upgrading from (NULL: new-install/not-upgrading-from-a-hacked-version)
  */
 function install($upgrade_from = NULL, $upgrade_from_hack = NULL)
 {
     require_lang('catalogues');
     require_code('catalogues');
     require_code('catalogues2');
     if (is_null($upgrade_from)) {
         $GLOBALS['SITE_DB']->create_table('catalogues', array('c_name' => '*ID_TEXT', 'c_title' => 'SHORT_TRANS', 'c_description' => 'LONG_TRANS', 'c_display_type' => 'SHORT_INTEGER', 'c_is_tree' => 'BINARY', 'c_notes' => 'LONG_TEXT', 'c_add_date' => 'TIME', 'c_submit_points' => 'INTEGER', 'c_ecommerce' => 'BINARY', 'c_send_view_reports' => 'ID_TEXT'));
         $GLOBALS['SITE_DB']->create_table('catalogue_categories', array('id' => '*AUTO', 'c_name' => 'ID_TEXT', 'cc_title' => 'SHORT_TRANS', 'cc_description' => 'LONG_TRANS', 'rep_image' => 'URLPATH', 'cc_notes' => 'LONG_TEXT', 'cc_add_date' => 'TIME', 'cc_parent_id' => '?AUTO_LINK', 'cc_move_target' => '?AUTO_LINK', 'cc_move_days_lower' => 'INTEGER', 'cc_move_days_higher' => 'INTEGER'));
         $GLOBALS['SITE_DB']->create_index('catalogue_categories', 'catstoclean', array('cc_move_target'));
         $GLOBALS['SITE_DB']->create_index('catalogue_categories', 'cataloguefind', array('c_name'));
     }
     if (is_null($upgrade_from) || $upgrade_from < 6) {
         $GLOBALS['SITE_DB']->create_index('catalogue_categories', 'cc_parent_id', array('cc_parent_id'));
     }
     if (is_null($upgrade_from)) {
         $GLOBALS['SITE_DB']->create_table('catalogue_fields', array('id' => '*AUTO', 'c_name' => 'ID_TEXT', 'cf_name' => 'SHORT_TRANS', 'cf_description' => 'LONG_TRANS', 'cf_type' => 'ID_TEXT', 'cf_order' => 'INTEGER', 'cf_defines_order' => 'SHORT_INTEGER', 'cf_visible' => 'BINARY', 'cf_searchable' => 'BINARY', 'cf_default' => 'LONG_TEXT', 'cf_required' => 'BINARY', 'cf_put_in_category' => 'BINARY', 'cf_put_in_search' => 'BINARY'));
         $GLOBALS['SITE_DB']->create_table('catalogue_entries', array('id' => '*AUTO', 'c_name' => 'ID_TEXT', 'cc_id' => 'AUTO_LINK', 'ce_submitter' => 'USER', 'ce_add_date' => 'TIME', 'ce_edit_date' => '?TIME', 'ce_views' => 'INTEGER', 'ce_views_prior' => 'INTEGER', 'ce_validated' => 'BINARY', 'notes' => 'LONG_TEXT', 'allow_rating' => 'BINARY', 'allow_comments' => 'SHORT_INTEGER', 'allow_trackbacks' => 'BINARY', 'ce_last_moved' => 'INTEGER'));
         $GLOBALS['SITE_DB']->create_index('catalogue_entries', 'ce_views', array('ce_views'));
         $GLOBALS['SITE_DB']->create_index('catalogue_entries', 'ces', array('ce_submitter'));
         $GLOBALS['SITE_DB']->create_index('catalogue_entries', 'ce_validated', array('ce_validated'));
         $GLOBALS['SITE_DB']->create_table('catalogue_efv_long_trans', array('id' => '*AUTO', 'cf_id' => 'AUTO_LINK', 'ce_id' => 'AUTO_LINK', 'cv_value' => 'LONG_TRANS'));
         $GLOBALS['SITE_DB']->create_table('catalogue_efv_long', array('id' => '*AUTO', 'cf_id' => 'AUTO_LINK', 'ce_id' => 'AUTO_LINK', 'cv_value' => 'LONG_TEXT'));
         $GLOBALS['SITE_DB']->create_table('catalogue_efv_short_trans', array('id' => '*AUTO', 'cf_id' => 'AUTO_LINK', 'ce_id' => 'AUTO_LINK', 'cv_value' => 'SHORT_TRANS'));
         $GLOBALS['SITE_DB']->create_table('catalogue_efv_short', array('id' => '*AUTO', 'cf_id' => 'AUTO_LINK', 'ce_id' => 'AUTO_LINK', 'cv_value' => 'SHORT_TEXT'));
     }
     if (is_null($upgrade_from) || $upgrade_from < 6) {
         $GLOBALS['SITE_DB']->create_table('catalogue_entry_linkage', array('catalogue_entry_id' => '*AUTO_LINK', 'content_type' => 'ID_TEXT', 'content_id' => 'ID_TEXT'));
         $GLOBALS['SITE_DB']->create_index('catalogue_entry_linkage', 'custom_fields', array('content_type', 'content_id'));
         // This caches ancestor relationships. It is redundant to doing tree traversals on catalogue_categories.cc_id, allowing normal efficient SQL joins to be done instead
         // Note that self relationships (cc_id=cc_ancestor_id) are stored too, so that a single join covers that too.
         $GLOBALS['SITE_DB']->create_table('catalogue_cat_treecache', array('cc_id' => '*AUTO_LINK', 'cc_ancestor_id' => '*AUTO_LINK'));
         $GLOBALS['SITE_DB']->create_table('catalogue_childcountcache', array('cc_id' => '*AUTO_LINK', 'c_num_rec_children' => 'INTEGER', 'c_num_rec_entries' => 'INTEGER'));
         $GLOBALS['SITE_DB']->create_index('catalogue_cat_treecache', 'cc_ancestor_id', array('cc_ancestor_id'));
         $GLOBALS['SITE_DB']->create_table('catalogue_efv_float', array('id' => '*AUTO', 'cf_id' => 'AUTO_LINK', 'ce_id' => 'AUTO_LINK', 'cv_value' => '?REAL'));
         $GLOBALS['SITE_DB']->create_table('catalogue_efv_integer', array('id' => '*AUTO', 'cf_id' => 'AUTO_LINK', 'ce_id' => 'AUTO_LINK', 'cv_value' => '?INTEGER'));
         $GLOBALS['SITE_DB']->create_index('catalogue_efv_float', 'fcv_value', array('cv_value'));
         $GLOBALS['SITE_DB']->create_index('catalogue_efv_integer', 'itv_value', array('cv_value'));
         $GLOBALS['SITE_DB']->create_index('catalogue_efv_float', 'fcf_id', array('cf_id'), 'id');
         $GLOBALS['SITE_DB']->create_index('catalogue_efv_integer', 'icf_id', array('cf_id'), 'id');
         $GLOBALS['SITE_DB']->create_index('catalogue_efv_float', 'fce_id', array('ce_id'), 'id');
         $GLOBALS['SITE_DB']->create_index('catalogue_efv_integer', 'ice_id', array('ce_id'), 'id');
         $GLOBALS['SITE_DB']->create_index('catalogue_efv_float', 'cefv_f_combo', array('ce_id', 'cf_id'), 'id');
         $GLOBALS['SITE_DB']->create_index('catalogue_efv_integer', 'cefv_i_combo', array('ce_id', 'cf_id'), 'id');
         $GLOBALS['SITE_DB']->create_index('catalogue_efv_long', 'cefv_l_combo', array('ce_id', 'cf_id'), 'id');
         $GLOBALS['SITE_DB']->create_index('catalogue_efv_short', 'cefv_s_combo', array('ce_id', 'cf_id'), 'id');
         $GLOBALS['SITE_DB']->create_index('catalogue_efv_long_trans', 'cefv_lt_combo', array('ce_id', 'cf_id'), 'id');
         $GLOBALS['SITE_DB']->create_index('catalogue_efv_short_trans', 'cefv_st_combo', array('ce_id', 'cf_id'), 'id');
     }
     if (is_null($upgrade_from)) {
         // Add the default catalogues
         // ==========================
         $groups = $GLOBALS['FORUM_DRIVER']->get_usergroup_list(false, true);
         // Projects
         actual_add_catalogue('projects', lang_code_to_default_content('DEFAULT_CATALOGUE_PROJECTS_TITLE', false, 2), lang_code_to_default_content('DEFAULT_CATALOGUE_PROJECTS_DESCRIPTION', true, 3), 0, 0, '', 30);
         $fields = array(array('NAME', 'DESCRIPTION_NAME', 'short_trans', 1, 1), array('MAINTAINER', 'DESCRIPTION_MAINTAINER', 'user', 0, 1), array('DESCRIPTION', 'DESCRIPTION_DESCRIPTION', 'long_trans', 0, 1), array('PROJECT_PROGRESS', 'DESCRIPTION_PROJECT_PROGRESS', 'integer', 0, 1));
         foreach ($fields as $i => $field) {
             actual_add_catalogue_field('projects', lang_code_to_default_content($field[0], false, 3), lang_code_to_default_content($field[1], true, 3), $field[2], $i, $field[3], 1, 1, '', $field[4]);
         }
         $cat_id = actual_add_catalogue_category('projects', lang_code_to_default_content('DEFAULT_CATALOGUE_PROJECTS_TITLE', false, 2), lang_code_to_default_content('DEFAULT_CATALOGUE_PROJECTS_DESCRIPTION', true, 3), '', NULL, '');
         foreach (array_keys($groups) as $group_id) {
             $GLOBALS['SITE_DB']->query_insert('group_category_access', array('module_the_name' => 'catalogues_category', 'category_name' => strval($cat_id), 'group_id' => $group_id));
             $GLOBALS['SITE_DB']->query_insert('group_category_access', array('module_the_name' => 'catalogues_catalogue', 'category_name' => 'projects', 'group_id' => $group_id));
         }
         add_menu_item_simple('main_content', NULL, 'DEFAULT_CATALOGUE_PROJECTS_TITLE', '_SEARCH:catalogues:type=index:id=projects');
         // Modifications
         actual_add_catalogue('modifications', lang_code_to_default_content('DEFAULT_CATALOGUE_MODIFICATIONS_TITLE', false, 2), lang_code_to_default_content('DEFAULT_CATALOGUE_MODIFICATIONS_DESCRIPTION', true, 3), 1, 0, '', 60);
         $fields = array(array('NAME', 'DESCRIPTION_NAME', 'short_trans', 1, 1), array('IMAGE', 'DESCRIPTION_MODIFICATION_IMAGE_URL', 'picture', 0, 0), array('STATUS', 'DESCRIPTION_MODIFICATION_STATUS', 'short_trans', 0, 1), array('URL', 'DESCRIPTION_URL', 'url', 0, 0), array('DESCRIPTION', 'DESCRIPTION_DESCRIPTION', 'long_trans', 0, 1), array('AUTHOR', 'DESCRIPTION_AUTHOR', 'short_text', 0, 1));
         foreach ($fields as $i => $field) {
             actual_add_catalogue_field('modifications', lang_code_to_default_content($field[0], false, 3), lang_code_to_default_content($field[1], true, 3), $field[2], $i, $field[3], 1, 1, '', $field[4]);
         }
         foreach (array_keys($groups) as $group_id) {
             $GLOBALS['SITE_DB']->query_insert('group_category_access', array('module_the_name' => 'catalogues_catalogue', 'category_name' => 'modifications', 'group_id' => $group_id));
         }
         add_menu_item_simple('main_content', NULL, 'DEFAULT_CATALOGUE_MODIFICATIONS_TITLE', '_SEARCH:catalogues:type=index:id=modifications');
         // Hosted-sites
         actual_add_catalogue('hosted', lang_code_to_default_content('DEFAULT_CATALOGUE_HOSTED_TITLE', false, 2), lang_code_to_default_content('DEFAULT_CATALOGUE_HOSTED_DESCRIPTION', true, 3), 0, 0, '', 0);
         $fields = array(array('NAME', 'DESCRIPTION_NAME', 'short_trans', 1, 1), array('URL', 'DESCRIPTION_URL', 'url', 0, 0), array('DESCRIPTION', 'DESCRIPTION_DESCRIPTION', 'long_trans', 0, 0));
         foreach ($fields as $i => $field) {
             actual_add_catalogue_field('hosted', lang_code_to_default_content($field[0], false, 2), lang_code_to_default_content($field[1], true, 3), $field[2], $i, $field[3], 1, 1, '', $field[4]);
         }
         $cat_id = actual_add_catalogue_category('hosted', lang_code_to_default_content('DEFAULT_CATALOGUE_HOSTED_TITLE', false, 2), lang_code_to_default_content('DEFAULT_CATALOGUE_HOSTED_DESCRIPTION', true, 3), '', NULL, '');
         foreach (array_keys($groups) as $group_id) {
             $GLOBALS['SITE_DB']->query_insert('group_category_access', array('module_the_name' => 'catalogues_category', 'category_name' => strval($cat_id), 'group_id' => $group_id));
             $GLOBALS['SITE_DB']->query_insert('group_category_access', array('module_the_name' => 'catalogues_catalogue', 'category_name' => 'hosted', 'group_id' => $group_id));
         }
         add_menu_item_simple('main_content', NULL, 'DEFAULT_CATALOGUE_HOSTED_TITLE', '_SEARCH:catalogues:type=index:id=hosted');
         // Links
         $links_category = actual_add_catalogue('links', lang_code_to_default_content('DEFAULT_CATALOGUE_LINKS_TITLE', false, 2), lang_code_to_default_content('DEFAULT_CATALOGUE_LINKS_DESCRIPTION', true, 3), 2, 1, '', 0);
         $fields = array(array('TITLE', 'DESCRIPTION_TITLE', 'short_trans', 1, 1, 1), array('URL', 'DESCRIPTION_URL', 'url', 0, 1, 0), array('DESCRIPTION', 'DESCRIPTION_DESCRIPTION', 'long_trans', 0, 0, 1));
         foreach ($fields as $i => $field) {
             actual_add_catalogue_field('links', lang_code_to_default_content($field[0], false, 2), lang_code_to_default_content($field[1], true, 3), $field[2], $i, $field[3], 1, 1, '', $field[4], $field[5]);
         }
         foreach (array_keys($groups) as $group_id) {
             $GLOBALS['SITE_DB']->query_insert('group_category_access', array('module_the_name' => 'catalogues_category', 'category_name' => strval($links_category), 'group_id' => $group_id));
             $GLOBALS['SITE_DB']->query_insert('group_category_access', array('module_the_name' => 'catalogues_catalogue', 'category_name' => 'links', 'group_id' => $group_id));
         }
         add_menu_item_simple('main_content', NULL, 'DEFAULT_CATALOGUE_LINKS_TITLE', '_SEARCH:catalogues:type=index:id=links');
         // FAQs
         actual_add_catalogue('faqs', lang_code_to_default_content('DEFAULT_CATALOGUE_FAQS_TITLE', false, 2), lang_code_to_default_content('DEFAULT_CATALOGUE_FAQS_DESCRIPTION', true, 3), 0, 0, '', 0);
         $fields = array(array('QUESTION', 'DESCRIPTON_QUESTION', 'short_trans', 0, 1, 1), array('ANSWER', '_DESCRIPTION_ANSWER', 'long_trans', 0, 1, 1), array('ORDER', 'DESCRIPTION_ORDER', 'auto_increment', 1, 0, 0));
         foreach ($fields as $i => $field) {
             actual_add_catalogue_field('faqs', lang_code_to_default_content($field[0], false, 2), lang_code_to_default_content($field[1], true, 3), $field[2], $i, $field[3], $field[5], 1, '', $field[4]);
         }
         $cat_id = actual_add_catalogue_category('faqs', lang_code_to_default_content('DEFAULT_CATALOGUE_FAQS_TITLE', false, 2), lang_code_to_default_content('DEFAULT_CATALOGUE_FAQS_DESCRIPTION', true, 3), '', NULL, '');
         foreach (array_keys($groups) as $group_id) {
             $GLOBALS['SITE_DB']->query_insert('group_category_access', array('module_the_name' => 'catalogues_category', 'category_name' => strval($cat_id), 'group_id' => $group_id));
             $GLOBALS['SITE_DB']->query_insert('group_category_access', array('module_the_name' => 'catalogues_catalogue', 'category_name' => 'faqs', 'group_id' => $group_id));
         }
         add_menu_item_simple('main_content', NULL, 'DEFAULT_CATALOGUE_FAQS_TITLE', '_SEARCH:catalogues:type=index:id=faqs');
         // Contacts
         actual_add_catalogue('contacts', lang_code_to_default_content('CONTACTS', false, 2), lang_code_to_default_content('DEFAULT_CATALOGUE_CONTACTS_DESCRIPTION', true, 3), 0, 0, '', 30);
         $fields = array(array('CONTACT_FIRST_NAME', '', 'short_text', 0, 1), array('CONTACT_LAST_NAME', '', 'short_text', 1, 1), array('EMAIL_ADDRESS', '', 'short_text', 0, 1), array('CONTACT_COMPANY', '', 'short_text', 0, 1), array('CONTACT_HOMEADDRESS', '', 'short_text', 0, 1), array('CONTACT_CITY', '', 'short_text', 0, 1), array('CONTACT_HOMEPHONE', '', 'short_text', 0, 1), array('CONTACT_WORKPHONE', '', 'short_text', 0, 1), array('CONTACT_HOMEPAGE', '', 'short_text', 0, 1), array('CONTACT_IM', '', 'short_text', 0, 1), array('CONTACT_EVENTS', '', 'long_text', 0, 1), array('CONTACT_NOTES', '', 'long_text', 0, 1), array('CONTACT_PHOTO', '', 'picture', 0, 1));
         foreach ($fields as $i => $field) {
             actual_add_catalogue_field('contacts', lang_code_to_default_content($field[0], false, 3), insert_lang('', 2), $field[2], $i, $field[3], 1, 1, '', $field[4]);
         }
         actual_add_catalogue_category('contacts', lang_code_to_default_content('CONTACTS', false, 2), '', '', NULL, '');
         add_menu_item_simple('main_content', NULL, 'CONTACTS', '_SEARCH:catalogues:type=index:id=contacts');
         $projects = add_menu_item_simple('collab_features', NULL, 'DEFAULT_CATALOGUE_PROJECTS_TITLE');
         add_menu_item_simple('collab_features', $projects, 'VIEW', '_SEARCH:catalogues:id=projects:type=index', 0, 0, true, do_lang('ZONE_BETWEEN'), 1);
         add_menu_item_simple('collab_features', $projects, 'ADD', '_SEARCH:cms_catalogues:catalogue_name=projects:type=add_entry', 0, 0, true, do_lang('ZONE_BETWEEN'), 1);
     }
     if (is_null($upgrade_from) || $upgrade_from < 6) {
         $GLOBALS['SITE_DB']->create_index('catalogue_entries', 'ce_add_date', array('ce_add_date'), 'id');
         $GLOBALS['SITE_DB']->create_index('catalogue_entries', 'ce_c_name', array('c_name'), 'id');
     }
     if (!is_null($upgrade_from) && $upgrade_from < 4) {
         $GLOBALS['SITE_DB']->delete_table_field('catalogues', 'c_own_template');
         $GLOBALS['SITE_DB']->add_table_field('catalogues', 'c_cat_tab', 'BINARY', 0);
         $GLOBALS['SITE_DB']->add_table_field('catalogues', 'c_ecommerce', 'BINARY', 0);
         $GLOBALS['SITE_DB']->add_table_field('catalogue_entries', 'ce_views_prior', 'INTEGER');
         $GLOBALS['SITE_DB']->add_table_field('catalogues', 'c_send_view_reports', 'ID_TEXT', 'never');
         $GLOBALS['SITE_DB']->add_table_field('catalogue_categories', 'cc_move_target', '?AUTO_LINK', NULL);
         $GLOBALS['SITE_DB']->add_table_field('catalogue_categories', 'cc_move_days_lower', 'INTEGER', 30);
         $GLOBALS['SITE_DB']->add_table_field('catalogue_categories', 'cc_move_days_higher', 'INTEGER', 60);
         $GLOBALS['SITE_DB']->add_table_field('catalogue_entries', 'ce_last_moved', 'INTEGER', 0);
         $GLOBALS['SITE_DB']->query('UPDATE ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'catalogue_entries SET ce_last_moved=ce_add_date');
     }
     if (is_null($upgrade_from) || $upgrade_from < 3) {
         $cat_id = actual_add_catalogue('products', lang_code_to_default_content('DEFAULT_CATALOGUE_PRODUCTS_TITLE', false, 2), lang_code_to_default_content('DEFAULT_CATALOGUE_PRODUCTS_DESCRIPTION', false, 2), 1, 1, '', 0, 1);
         $fields = array(array('ECOM_CAT_product_title', 'DESCRIPTION_TITLE', 'short_trans', 1, 1, 1, 1), array('ECOM_CAT_item_code', 'ECOM_CATD_item_code', 'random', 0, 1, 1, 1), array('ECOM_CAT_price_pre_tax', 'ECOM_CATD_price_pre_tax', 'float', 0, 1, 1, 1), array('ECOM_CAT_stock_level', 'ECOM_CATD_stock_level', 'integer', 0, 0, 1, 0), array('ECOM_CAT_stock_level_warn_at', 'ECOM_CATD_stock_level_warn_at', 'integer', 0, 0, 0, 0), array('ECOM_CAT_stock_level_maintain', 'ECOM_CATD_stock_level_maintain', 'tick', 0, 1, 0, 0), array('ECOM_CAT_tax_type', 'ECOM_CATD_tax_type', 'list', 0, 1, 0, 0, "0%|5%|17.5%", 0), array('ECOM_CAT_image', 'ECOM_CATD_image', 'picture', 0, 0, 1, 1), array('ECOM_CAT_weight', 'ECOM_CATD_weight', 'float', 0, 1, 0, 0), array('ECOM_CAT_description', 'DESCRIPTION_DESCRIPTION', 'long_trans', 0, 1, 1, 1));
         foreach ($fields as $i => $field) {
             actual_add_catalogue_field('products', lang_code_to_default_content($field[0], false, 3), lang_code_to_default_content($field[1], true, 3), $field[2] == 'tick' ? 'list' : $field[2], $i, $field[3], $field[5], $field[6], $field[2] == 'tick' ? do_lang('NO') . '|' . do_lang('YES') : (array_key_exists(7, $field) ? $field[7] : ''), $field[4], array_key_exists(5, $field) ? $field[5] : 0, array_key_exists(5, $field) ? $field[5] : 0);
         }
         foreach (array_keys($groups) as $group_id) {
             $GLOBALS['SITE_DB']->query_insert('group_category_access', array('module_the_name' => 'catalogues_category', 'category_name' => strval($cat_id), 'group_id' => $group_id));
             $GLOBALS['SITE_DB']->query_insert('group_category_access', array('module_the_name' => 'catalogues_catalogue', 'category_name' => 'products', 'group_id' => $group_id));
         }
         add_menu_item_simple('main_content', NULL, 'DEFAULT_CATALOGUE_PRODUCTS_TITLE', '_SEARCH:catalogues:type=category:catalogue_name=products');
         add_specific_permission('CATALOGUES', 'high_catalogue_entry_timeout', false);
     }
     if (is_null($upgrade_from) || $upgrade_from < 3) {
         $GLOBALS['SITE_DB']->create_index('catalogue_efv_long', '#lcv_value', array('cv_value'), 'id');
         $GLOBALS['SITE_DB']->create_index('catalogue_efv_short', '#scv_value', array('cv_value'), 'id');
     }
     if (!is_null($upgrade_from) && $upgrade_from < 3) {
         $GLOBALS['SITE_DB']->add_table_field('catalogue_entries', 'allow_trackbacks', 'BINARY', 1);
         $GLOBALS['SITE_DB']->add_table_field('catalogue_entries', 'c_name', 'ID_TEXT');
         $GLOBALS['SITE_DB']->add_table_field('catalogue_categories', 'rep_image', 'URLPATH');
         $GLOBALS['SITE_DB']->add_table_field('catalogue_fields', 'cf_default', 'LONG_TEXT');
         $GLOBALS['SITE_DB']->add_table_field('catalogue_fields', 'cf_searchable', 'BINARY', 1);
         $entries = $GLOBALS['SITE_DB']->query_select('catalogue_entries e LEFT JOIN ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'catalogue_categories c ON e.cc_id=c.id', array('e.id', 'c.c_name'));
         foreach ($entries as $entry) {
             $GLOBALS['SITE_DB']->query_update('catalogue_entries', array('c_name' => $entry['c_name']), array('id' => $entry['id']), '', 1);
         }
     }
     if (!is_null($upgrade_from) && $upgrade_from < 4) {
         $GLOBALS['SITE_DB']->alter_table_field('catalogues', 'c_own_pages', 'SHORT_INTEGER', 'c_display_type');
         $GLOBALS['SITE_DB']->add_table_field('catalogue_fields', 'cf_put_in_category', 'BINARY', 1);
         $GLOBALS['SITE_DB']->add_table_field('catalogue_fields', 'cf_put_in_search', 'BINARY', 1);
     }
     if (is_null($upgrade_from) || $upgrade_from < 5) {
         //$GLOBALS['SITE_DB']->create_index('catalogue_efv_long','ilcv_value',array('cv_value'),'id');	Not allowed, LONG_TEXT can not be in key. People shouldn't order by this anyway
         $GLOBALS['SITE_DB']->create_index('catalogue_efv_short', 'iscv_value', array('cv_value'), 'id');
         $GLOBALS['SITE_DB']->create_index('catalogue_efv_long', 'lcf_id', array('cf_id'), 'id');
         $GLOBALS['SITE_DB']->create_index('catalogue_efv_short', 'scf_id', array('cf_id'), 'id');
         $GLOBALS['SITE_DB']->create_index('catalogue_efv_long_trans', 'ltcf_id', array('cf_id'), 'id');
         $GLOBALS['SITE_DB']->create_index('catalogue_efv_short_trans', 'stcf_id', array('cf_id'), 'id');
         $GLOBALS['SITE_DB']->create_index('catalogue_efv_long', 'lce_id', array('ce_id'), 'id');
         $GLOBALS['SITE_DB']->create_index('catalogue_efv_short', 'sce_id', array('ce_id'), 'id');
         $GLOBALS['SITE_DB']->create_index('catalogue_efv_long_trans', 'ltce_id', array('ce_id'), 'id');
         $GLOBALS['SITE_DB']->create_index('catalogue_efv_short_trans', 'stce_id', array('ce_id'), 'id');
         $GLOBALS['SITE_DB']->create_index('catalogue_entries', 'ce_cc_id', array('cc_id'), 'id');
         $GLOBALS['SITE_DB']->create_index('catalogue_categories', 'ftjoin_cctitle', array('cc_title'));
         $GLOBALS['SITE_DB']->create_index('catalogue_categories', 'ftjoin_ccdescrip', array('cc_description'));
         $GLOBALS['SITE_DB']->create_index('catalogue_efv_long_trans', 'ltcv_value', array('cv_value'));
         $GLOBALS['SITE_DB']->create_index('catalogue_efv_short_trans', 'stcv_value', array('cv_value'));
     }
     if (!is_null($upgrade_from) && $upgrade_from < 6) {
         require_code('catalogues2');
         rebuild_catalogue_cat_treecache();
         // Move floats and integers into their own new tables
         if (function_exists('set_time_limit')) {
             @set_time_limit(0);
         }
         $sql_integer = db_string_equal_to('cf_type', 'integer') . ' OR ' . db_string_equal_to('cf_type', 'auto_increment') . ' OR ' . db_string_equal_to('cf_type', 'random') . ' OR ' . db_string_equal_to('cf_type', 'user') . ' OR ' . db_string_equal_to('cf_type', 'tick');
         $sql_float = db_string_equal_to('cf_type', 'float');
         foreach (array($sql_float => 'float', $sql_integer => 'integer') as $where => $new_type) {
             $fields = $GLOBALS['SITE_DB']->query('SELECT id FROM ' . get_table_prefix() . 'catalogue_fields WHERE ' . $where);
             foreach ($fields as $field) {
                 do {
                     $or_list = '';
                     $rows = $GLOBALS['SITE_DB']->query_select('catalogue_efv_short', array('*'), array('cf_id' => $field['id']), '', 100);
                     foreach ($rows as $row) {
                         if ($or_list != '') {
                             $or_list .= ' OR ';
                         }
                         $or_list .= 'ce_id=' . strval($row['ce_id']) . ' AND cf_id=' . strval($row['cf_id']);
                         unset($row['id']);
                         if ($new_type == 'float') {
                             $row['cv_value'] = $row['cv_value'] == '' ? NULL : floatval($row['cv_value']);
                         } elseif ($new_type == 'integer') {
                             $row['cv_value'] = $row['cv_value'] == '' ? NULL : intval($row['cv_value']);
                         }
                         $GLOBALS['SITE_DB']->query_insert('catalogue_efv_' . $new_type, $row);
                     }
                     if ($or_list != '') {
                         $GLOBALS['SITE_DB']->query('DELETE FROM ' . get_table_prefix() . 'catalogue_efv_short WHERE ' . $or_list);
                     }
                 } while (count($rows) != 0);
             }
         }
     }
 }