/** * 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 ($upgrade_from == 2) { set_option('supermembers_text', '[html]' . get_option('supermembers_text') . '[/html]'); return; } add_config_option('PAGE_TEXT', 'supermembers_text', 'transtext', 'return do_lang(\'SUPERMEMBERS_TEXT\');', 'SECURITY', 'SUPER_MEMBERS'); require_lang('supermembers'); add_menu_item_simple('collab_website', NULL, 'SUPER_MEMBERS', '_SEARCH:supermembers'); }
/** * 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('searches_saved', array('id' => '*AUTO', 's_title' => 'SHORT_TEXT', 's_member_id' => 'USER', 's_time' => 'TIME', 's_primary' => 'SHORT_TEXT', 's_auxillary' => 'LONG_TEXT')); $GLOBALS['SITE_DB']->create_table('searches_logged', array('id' => '*AUTO', 's_member_id' => 'USER', 's_time' => 'TIME', 's_primary' => 'SHORT_TEXT', 's_auxillary' => 'LONG_TEXT', 's_num_results' => 'INTEGER')); $GLOBALS['SITE_DB']->create_index('searches_logged', 'past_search', array('s_primary')); add_menu_item_simple('forum_features', NULL, 'SEARCH', '_SEARCH:search:type=misc:id=ocf_posts', 0, 0, true, do_lang('ZONE_BETWEEN')); } if (is_null($upgrade_from) || $upgrade_from < 4) { $GLOBALS['SITE_DB']->create_index('searches_logged', '#past_search_ft', array('s_primary')); } }
/** * 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('authors', array('author' => '*ID_TEXT', 'url' => 'URLPATH', 'forum_handle' => '?USER', 'description' => 'LONG_TRANS', 'skills' => 'LONG_TRANS')); $GLOBALS['SITE_DB']->create_index('authors', 'findmemberlink', array('forum_handle')); } if (!is_null($upgrade_from) && $upgrade_from < 3) { $GLOBALS['SITE_DB']->alter_table_field('authors', 'forum_handle', '?USER'); } // collab_features require_lang('authors'); add_menu_item_simple('collab_features', NULL, 'VIEW_MY_AUTHOR_PROFILE', '_SELF:authors:type=misc'); add_menu_item_simple('collab_features', NULL, 'EDIT_MY_AUTHOR_PROFILE', '_SEARCH:cms_authors:type=_ad', 0, 0, true, do_lang('ZONE_BETWEEN'), 1); }
/** * 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('recommend'); if (is_null($upgrade_from)) { add_config_option('RECOMMEND_SITE', 'points_RECOMMEND_SITE', 'integer', 'return addon_installed(\'points\')?\'350\':NULL;', 'POINTS', 'COUNT_POINTS_GIVEN'); } if (!is_null($upgrade_from) && $upgrade_from < 3) { delete_menu_item_simple('_SEARCH:recommend:from={$REPLACE&,:,%3A,{$SELF_URL}}'); delete_menu_item_simple('_SEARCH:recommend:from={$REPLACE,:,%3A,{$SELF_URL&,0,0,0,from=<null>}}'); } if (is_null($upgrade_from) || $upgrade_from < 3) { add_menu_item_simple('root_website', NULL, 'RECOMMEND_SITE', '_SEARCH:recommend:from={$SELF_URL&,0,0,0,from=<null>}'); } }
/** * 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('filedump', array('id' => '*AUTO', 'name' => 'ID_TEXT', 'path' => 'URLPATH', 'description' => 'SHORT_TRANS', 'the_member' => 'USER')); add_specific_permission('FILE_DUMP', 'upload_anything_filedump', false); add_specific_permission('FILE_DUMP', 'upload_filedump', true); add_specific_permission('FILE_DUMP', 'delete_anything_filedump', false); require_lang('filedump'); if (addon_installed('collaboration_zone')) { add_menu_item_simple('collab_features', NULL, 'FILE_DUMP', '_SEARCH:filedump:type=misc'); } } if (is_null($upgrade_from) || $upgrade_from < 3) { add_config_option('FILEDUMP_COUNT_FILES', 'filedump_show_stats_count_total_files', 'tick', 'return addon_installed(\'stats_block\')?\'0\':NULL;', 'BLOCKS', 'STATISTICS'); add_config_option('FILEDUMP_DISK_USAGE', 'filedump_show_stats_count_total_space', 'tick', 'return addon_installed(\'stats_block\')?\'0\':NULL;', 'BLOCKS', 'STATISTICS'); } if (addon_installed('redirects_editor')) { $GLOBALS['SITE_DB']->query_delete('redirects', array('r_from_page' => 'filedump', 'r_from_zone' => 'collaboration', 'r_to_page' => 'filedump', 'r_to_zone' => 'cms', 'r_is_transparent' => 1)); } }
/** * 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('staff'); add_menu_item_simple('main_website', NULL, 'STAFF', '_SEARCH:staff:type=misc'); }
/** * Standard code module initialisation function. */ function init__site() { if (defined('BREADCRUMB_CROP_LENGTH')) { return; } global $HELPER_PANEL_TEXT, $HELPER_PANEL_HTML, $HELPER_PANEL_PIC, $HELPER_PANEL_TUTORIAL; $HELPER_PANEL_TEXT = ''; $HELPER_PANEL_HTML = ''; $HELPER_PANEL_PIC = ''; $HELPER_PANEL_TUTORIAL = ''; global $REQUEST_PAGE_NEST_LEVEL; $REQUEST_PAGE_NEST_LEVEL = 0; global $REDIRECT_CACHE; $REDIRECT_CACHE = array(); global $REDIRECTED_TO; $REDIRECTED_TO = NULL; global $REFRESH_URL, $FORCE_META_REFRESH, $EXTRA_HEAD, $EXTRA_FOOT, $QUICK_REDIRECT; $REFRESH_URL[0] = ''; $REFRESH_URL[1] = 0; $FORCE_META_REFRESH = false; if (!isset($EXTRA_HEAD)) { $EXTRA_HEAD = new ocp_tempcode(); } if (!isset($EXTRA_FOOT)) { $EXTRA_FOOT = new ocp_tempcode(); } $QUICK_REDIRECT = false; global $FEED_URL, $FEED_URL_2; $FEED_URL = NULL; $FEED_URL_2 = NULL; global $NON_CANONICAL_PARAMS; // We only bother listing ones the software itself may inject - otherwise admin responsible for their own curation of canonical settings $NON_CANONICAL_PARAMS = array('wide_high', 'wide', 'wide_print', 'root', 'filtered', 'utheme', 'active_filter', 'redirected', 'redirect_url', 'redirect', 'redirect_passon'); $canonical_keep_params = explode(',', is_null(get_value('canonical_keep_params')) ? '' : get_value('canonical_keep_params')); foreach (array_keys($_GET) as $key) { if (substr($key, 0, 5) == 'keep_' && !@in_array($key, $canonical_keep_params)) { $NON_CANONICAL_PARAMS[] = $key; } } global $ATTACHED_MESSAGES, $ATTACHED_MESSAGES_RAW, $FAILED_TO_ATTACH_ALL_ERRORS; $ATTACHED_MESSAGES = new ocp_tempcode(); $ATTACHED_MESSAGES_RAW = array(); $FAILED_TO_ATTACH_ALL_ERRORS = false; global $DONE_HEADER; $DONE_HEADER = false; // We may fill these in from the code, or we may not global $SEO_KEYWORDS, $SEO_DESCRIPTION, $SEO_TITLE; $SEO_KEYWORDS = NULL; $SEO_DESCRIPTION = NULL; $SEO_TITLE = NULL; global $PAGE_STRING, $LAST_COMCODE_PARSED_TITLE; $PAGE_STRING = NULL; $LAST_COMCODE_PARSED_TITLE = ''; global $BREADCRUMBS, $BREADCRUMB_SET_PARENTS, $BREADCRUMB_EXTRA_SEGMENTS, $DISPLAYED_TITLE, $BREADCRUMB_SET_SELF; $BREADCRUMBS = NULL; $BREADCRUMB_SET_PARENTS = array(); $BREADCRUMB_EXTRA_SEGMENTS = new ocp_tempcode(); $DISPLAYED_TITLE = NULL; $BREADCRUMB_SET_SELF = NULL; $bcl = get_value('breadcrumb_crop_length'); define('BREADCRUMB_CROP_LENGTH', is_null($bcl) ? 26 : intval($bcl)); global $PT_PAIR_CACHE_CP; $PT_PAIR_CACHE_CP = array(); global $ATTACH_MESSAGE_CALLED; $ATTACH_MESSAGE_CALLED = 0; global $ZONE, $RELATIVE_PATH; $zone = get_zone_name(); $real_zone = $RELATIVE_PATH == '_tests' || $RELATIVE_PATH == 'data' || $RELATIVE_PATH == 'data_custom' ? get_param('zone', '') : $zone; $ZONE = persistant_cache_get(array('ZONE', $real_zone)); if ($ZONE === NULL) { $zones = $GLOBALS['SITE_DB']->query_select('zones', array('*'), array('zone_name' => $real_zone), '', 1); if (!array_key_exists(0, $zones) && is_dir(get_file_base() . '/' . $real_zone . '/' . 'pages')) { $GLOBALS['SITE_DB']->query_insert('zones', array('zone_name' => $real_zone, 'zone_title' => insert_lang($real_zone, 1), 'zone_default_page' => 'start', 'zone_header_text' => insert_lang($real_zone, 1), 'zone_theme' => 'default', 'zone_wide' => 0, 'zone_require_session' => 0, 'zone_displayed_in_menu' => 0)); require_code('menus2'); add_menu_item_simple('zone_menu', NULL, $real_zone, $real_zone . ':', 0, 1); $zones = $GLOBALS['SITE_DB']->query_select('zones z LEFT JOIN ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'translate t ON ' . db_string_equal_to('language', user_lang()) . ' AND z.zone_header_text=t.id', array('z.*', 'text_original AS zone_header_text_trans'), array('zone_name' => $real_zone), '', 1); } if (array_key_exists(0, $zones)) { $ZONE = $zones[0]; $ZONE['zone_header_text_trans'] = get_translated_text($ZONE['zone_header_text']); persistant_cache_set(array('ZONE', $real_zone), $ZONE); } if ($ZONE === NULL) { $zones = $GLOBALS['SITE_DB']->query_select('zones', array('*'), array('zone_name' => ''), '', 1); $ZONE = $zones[0]; $ZONE['zone_header_text_trans'] = get_translated_text($ZONE['zone_header_text']); warn_exit(do_lang_tempcode('BAD_ZONE', escape_html($real_zone))); } unset($zones); } if ($ZONE !== NULL && $ZONE['zone_wide'] === NULL) { $ZONE['zone_wide'] = get_forum_type() == 'ocf' ? $GLOBALS['FORUM_DRIVER']->get_member_row_field(get_member(), 'm_zone_wide') : 1; } if ($ZONE['zone_name'] == 'adminzone' || $ZONE['zone_name'] == 'cms') { require_css('adminzone'); } $_zone = get_zone_name(); $REDIRECT_CACHE = array($_zone => array()); if (addon_installed('redirects_editor')) { $redirect = persistant_cache_get(array('REDIRECT', $_zone)); if ($redirect === NULL) { $redirect = $GLOBALS['SITE_DB']->query_select('redirects', array('*')); persistant_cache_set(array('REDIRECT', $_zone), $redirect); } foreach ($redirect as $r) { if ($r['r_from_zone'] == $r['r_to_zone'] && $r['r_from_page'] == $r['r_to_page']) { continue; } $REDIRECT_CACHE[$r['r_from_zone']][$r['r_from_page']] = $r; } } // SEO redirection require_code('urls'); if (can_try_mod_rewrite()) { $ruri = ocp_srv('REQUEST_URI'); $old_style = get_option('htm_short_urls') != '1'; if (!headers_sent() && running_script('index') && isset($_SERVER['HTTP_HOST']) && count($_POST) == 0 && (strpos($ruri, '/pg/') === false || !$old_style) && (strpos($ruri, '.htm') === false || $old_style)) { $GLOBALS['HTTP_STATUS_CODE'] = '301'; header('HTTP/1.0 301 Moved Permanently'); header('Location: ' . get_self_url(true)); exit; } } // Search engine having session in URL, we don't like this if (get_bot_type() !== NULL && isset($_SERVER['HTTP_HOST']) && count($_POST) == 0 && get_param_integer('keep_session', NULL) !== NULL) { $GLOBALS['HTTP_STATUS_CODE'] = '301'; header('HTTP/1.0 301 Moved Permanently'); header('Location: ' . get_self_url(true, false, array('keep_session' => NULL, 'keep_print' => NULL))); exit; } // Detect bad access domain global $SITE_INFO; $access_host = preg_replace('#:.*#', '', ocp_srv('HTTP_HOST')); if ($access_host != '' && isset($_SERVER['HTTP_HOST'])) { $parsed_base_url = parse_url(get_base_url()); if (array_key_exists('host', $parsed_base_url) && strtolower($parsed_base_url['host']) != strtolower($access_host)) { if (!array_key_exists('ZONE_MAPPING_' . get_zone_name(), $SITE_INFO)) { if ($GLOBALS['FORUM_DRIVER']->is_super_admin(get_member())) { attach_message(do_lang_tempcode('BAD_ACCESS_DOMAIN', escape_html($parsed_base_url['host']), escape_html($access_host)), 'warn'); } header('Location: ' . str_replace(chr(13), '', str_replace(chr(10), '', str_replace($access_host, $parsed_base_url['host'], get_self_url_easy())))); exit; } } } // The most important security check global $SESSION_CONFIRMED; get_member(); // Make sure we've loaded our backdoor if installed require_code('permissions'); if ($ZONE['zone_require_session'] == 1) { header('X-Frame-Options: SAMEORIGIN'); } // Clickjacking protection if ($ZONE['zone_name'] != '' && !is_httpauth_login() && (get_session_id() == -1 || $SESSION_CONFIRMED == 0) && $ZONE['zone_require_session'] == 1 && get_page_name() != 'login') { access_denied($real_zone == 'data' || has_zone_access(get_member(), $ZONE['zone_name']) ? 'ZONE_ACCESS_SESSION' : 'ZONE_ACCESS', $ZONE['zone_name'], true); } else { if ($real_zone == 'data' || has_zone_access(get_member(), $ZONE['zone_name'])) { global $NON_PAGE_SCRIPT; if ($NON_PAGE_SCRIPT == 0 && !has_page_access(get_member(), get_page_name(), $ZONE['zone_name'], true)) { access_denied('PAGE_ACCESS'); } } else { /* if ($ZONE['zone_name']=='adminzone') GoogleAds will pick up on ANY URL any go and CRAWL IT. So don't use with googleads unless you want googlead-triggering-heart-attacks ;) log_hack_attack_and_exit('ADMINZONE_ACCESS_DENIED');*/ if (get_page_name() != 'login') { access_denied('ZONE_ACCESS', $ZONE['zone_name'], true); } } } }
/** * 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'); } }
/** * 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 < 5) { $GLOBALS['SITE_DB']->delete_table_field('ticket_types', 'send_sms_to'); } if (!is_null($upgrade_from) && $upgrade_from < 4) { $GLOBALS['SITE_DB']->add_table_field('ticket_types', 'guest_emails_mandatory', 'BINARY', 0); $GLOBALS['SITE_DB']->add_table_field('ticket_types', 'search_faq', 'BINARY', 0); $GLOBALS['SITE_DB']->add_table_field('ticket_types', 'cache_lead_time', '?TIME'); } if ($upgrade_from < 3 || is_null($upgrade_from)) { add_specific_permission('SUPPORT_TICKETS', 'support_operator', false); } if (is_null($upgrade_from) || $upgrade_from < 4) { add_config_option('TICKET_MEMBER_FORUMS', 'ticket_member_forums', 'tick', 'return \'0\';', 'FEATURE', 'SUPPORT_TICKETS'); add_config_option('TICKET_TYPE_FORUMS', 'ticket_type_forums', 'tick', 'return \'0\';', 'FEATURE', 'SUPPORT_TICKETS'); $GLOBALS['SITE_DB']->create_table('tickets', array('ticket_id' => '*SHORT_TEXT', 'topic_id' => 'AUTO_LINK', 'forum_id' => 'AUTO_LINK', 'ticket_type' => 'SHORT_TRANS')); } if (!is_null($upgrade_from) && $upgrade_from < 2) { $GLOBALS['SITE_DB']->query_update('config', array('eval' => 'return do_lang(\'NEW_TICKET_WELCOME\');'), array('the_name' => 'ticket_text'), '', 1); if ($GLOBALS['OPTIONS']['ticket_text']['c_set'] == 1) { set_option('ticket_text', '[html]' . get_option('ticket_text') . '[/html]'); } else { set_option('ticket_text', do_lang('NEW_TICKET_WELCOME')); } return; } require_lang('tickets'); if (is_null($upgrade_from)) { $GLOBALS['SITE_DB']->create_table('ticket_types', array('ticket_type' => '*SHORT_TRANS', 'guest_emails_mandatory' => 'BINARY', 'search_faq' => 'BINARY', 'cache_lead_time' => '?TIME')); $groups = $GLOBALS['FORUM_DRIVER']->get_usergroup_list(false, true); $default_types = array('TT_OTHER', 'TT_COMPLAINT'); foreach ($default_types as $type) { $GLOBALS['SITE_DB']->query_insert('ticket_types', array('ticket_type' => insert_lang(do_lang($type), 1), 'guest_emails_mandatory' => 0, 'search_faq' => 0, 'cache_lead_time' => NULL)); foreach (array_keys($groups) as $id) { $GLOBALS['SITE_DB']->query_insert('group_category_access', array('module_the_name' => 'tickets', 'category_name' => do_lang($type), 'group_id' => $id)); } } add_config_option('PAGE_TEXT', 'ticket_text', 'transtext', 'return do_lang(\'NEW_TICKET_WELCOME\');', 'FEATURE', 'SUPPORT_TICKETS'); add_config_option('TICKET_FORUM_NAME', 'ticket_forum_name', 'forum', 'require_lang(\'tickets\'); return do_lang(\'TICKET_FORUM_NAME\',\'\',\'\',\'\',get_site_default_lang());', 'FEATURE', 'SUPPORT_TICKETS'); add_specific_permission('SUPPORT_TICKETS', 'view_others_tickets', false); add_menu_item_simple('main_website', NULL, 'SUPPORT_TICKETS', '_SEARCH:tickets:type=misc'); } }
/** * 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']->table_exists('shopping_order')) { $GLOBALS['SITE_DB']->create_table('shopping_order', array('id' => '*AUTO', 'c_member' => 'INTEGER', 'session_id' => 'INTEGER', 'add_date' => 'TIME', 'tot_price' => 'REAL', 'order_status' => 'ID_TEXT', 'notes' => 'LONG_TEXT', 'transaction_id' => 'SHORT_TEXT', 'purchase_through' => 'SHORT_TEXT', 'tax_opted_out' => 'BINARY')); $GLOBALS['SITE_DB']->create_index('shopping_order', 'finddispatchable', array('order_status')); $GLOBALS['SITE_DB']->create_index('shopping_order', 'soc_member', array('c_member')); $GLOBALS['SITE_DB']->create_index('shopping_order', 'sosession_id', array('session_id')); $GLOBALS['SITE_DB']->create_index('shopping_order', 'soadd_date', array('add_date')); } else { if (is_null($GLOBALS['SITE_DB']->query('SELECT COUNT(DISTINCT tax_opted_out) FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'shopping_order', NULL, NULL, true))) { $GLOBALS['SITE_DB']->add_table_field('shopping_order', 'tax_opted_out', 'BINARY', 0); } // This was badly versioned } if (is_null($upgrade_from)) { $GLOBALS['SITE_DB']->create_table('shopping_cart', array('id' => '*AUTO', 'session_id' => 'INTEGER', 'ordered_by' => '*USER', 'product_id' => '*AUTO_LINK', 'product_name' => 'SHORT_TEXT', 'product_code' => 'SHORT_TEXT', 'quantity' => 'INTEGER', 'price_pre_tax' => 'REAL', 'price' => 'REAL', 'product_description' => 'LONG_TEXT', 'product_type' => 'SHORT_TEXT', 'product_weight' => 'REAL', 'is_deleted' => 'BINARY')); $GLOBALS['SITE_DB']->create_index('shopping_cart', 'ordered_by', array('ordered_by')); $GLOBALS['SITE_DB']->create_index('shopping_cart', 'session_id', array('session_id')); $GLOBALS['SITE_DB']->create_index('shopping_cart', 'product_id', array('product_id')); $GLOBALS['SITE_DB']->create_table('shopping_order_details', array('id' => '*AUTO', 'order_id' => '?AUTO_LINK', 'p_id' => '?AUTO_LINK', 'p_name' => 'SHORT_TEXT', 'p_code' => 'SHORT_TEXT', 'p_type' => 'SHORT_TEXT', 'p_quantity' => 'INTEGER', 'p_price' => 'REAL', 'included_tax' => 'REAL', 'dispatch_status' => 'SHORT_TEXT')); $GLOBALS['SITE_DB']->create_index('shopping_order_details', 'p_id', array('p_id')); $GLOBALS['SITE_DB']->create_index('shopping_order_details', 'order_id', array('order_id')); $GLOBALS['SITE_DB']->create_table('shopping_logging', array('id' => '*AUTO', 'e_member_id' => '*USER', 'session_id' => 'INTEGER', 'ip' => 'IP', 'last_action' => 'SHORT_TEXT', 'date_and_time' => 'TIME')); $GLOBALS['SITE_DB']->create_table('shopping_order_addresses', array('id' => '*AUTO', 'order_id' => '?AUTO_LINK', 'address_name' => 'SHORT_TEXT', 'address_street' => 'LONG_TEXT', 'address_city' => 'SHORT_TEXT', 'address_zip' => 'SHORT_TEXT', 'address_country' => 'SHORT_TEXT', 'receiver_email' => 'SHORT_TEXT')); $GLOBALS['SITE_DB']->create_index('shopping_order_addresses', 'order_id', array('order_id')); require_lang('shopping'); $GLOBALS['SITE_DB']->create_index('shopping_order', 'recent_shopped', array('add_date')); $GLOBALS['SITE_DB']->create_index('shopping_logging', 'calculate_bandwidth', array('date_and_time')); add_config_option('SHIPPING_COST_FACTOR', 'shipping_cost_factor', 'float', 'return \'0\';', 'ECOMMERCE', 'ECOMMERCE', 1); add_config_option('ALLOW_OPTING_OUT_OF_TAX', 'allow_opting_out_of_tax', 'tick', 'return \'1\';', 'ECOMMERCE', 'ECOMMERCE'); add_menu_item_simple('ecommerce_features', NULL, 'ORDERS', '_SEARCH:shopping:type=my_orders'); //CPFs for ecommerce purchase $GLOBALS['FORUM_DRIVER']->install_create_custom_field('firstname', 20, 1, 0, 0, 0, '', 'short_text'); $GLOBALS['FORUM_DRIVER']->install_create_custom_field('lastname', 20, 1, 0, 0, 0, '', 'short_text'); $GLOBALS['FORUM_DRIVER']->install_create_custom_field('building_name_or_number', 100, 1, 0, 0, 0, '', 'long_text'); $GLOBALS['FORUM_DRIVER']->install_create_custom_field('city', 20, 1, 0, 0, 0, '', 'short_text'); $GLOBALS['FORUM_DRIVER']->install_create_custom_field('state', 100, 1, 0, 0, 0, '', 'short_text'); $GLOBALS['FORUM_DRIVER']->install_create_custom_field('post_code', 20, 1, 0, 0, 0, '', 'short_text'); require_code('currency'); $currencies = get_currency_map(); $_countries = array(); foreach ($currencies as $c) { $_countries = array_merge($_countries, $c); } $_countries = array_unique($_countries); sort($_countries); $countries = '|' . implode('|', $_countries); $GLOBALS['FORUM_DRIVER']->install_create_custom_field('country', 100, 1, 0, 0, 0, '', 'list', 0, $countries); } }
/** * The UI to edit a page. * * @return tempcode The UI */ function _ed() { $GLOBALS['HELPER_PANEL_PIC'] = 'pagepics/comcode_page_edit'; require_lang('menus'); $GLOBALS['HELPER_PANEL_TEXT'] = comcode_lang_string('DOC_WRITING'); $GLOBALS['HELPER_PANEL_TUTORIAL'] = 'tut_comcode_pages'; $simple_add = get_param_integer('simple_add', 0) == 1; $lang = choose_language(get_page_title($simple_add ? 'COMCODE_PAGE_ADD' : 'COMCODE_PAGE_EDIT'), true); if (is_object($lang)) { return $lang; } if (addon_installed('page_management')) { // Add to menu if (get_param('menu', STRING_MAGIC_NULL) != STRING_MAGIC_NULL && has_actual_page_access(get_member(), 'admin_sitetree')) { require_code('menus2'); add_menu_item_simple(get_param('menu'), NULL, get_param('title'), get_param('page_link'), 0, 0, false); } } // Work out what we're editing, and where it's coming from (support for two pagelink specifying parameters for destination, with addition of restore_from to override source if different from destination) $page_link = filter_naughty(get_param('page_link', '')); if ($page_link == '') { $page_link = get_param('page_link_2'); } if (strpos($page_link, ':') === false) { $page_link = ':' . $page_link; } $page_link_parts = explode(':', $page_link); if (count($page_link_parts) != 2) { warn_exit(do_lang_tempcode('ZONE_COLON_FILE')); } $zone = $page_link_parts[0]; if ($zone != '' && !file_exists(get_file_base() . '/' . $zone . '/pages')) { warn_exit(do_lang_tempcode('NO_SUCH_ZONE')); } $file = $page_link_parts[1]; require_code('type_validation'); if (!is_alphanumeric($file, true)) { warn_exit(do_lang_tempcode('BAD_CODENAME')); } $resource_owner = $GLOBALS['SITE_DB']->query_value_null_ok('comcode_pages', 'p_submitter', array('the_zone' => $zone, 'the_page' => $file)); check_edit_permission('high', $resource_owner); if (is_null($resource_owner)) { check_submit_permission('high'); } $restore_from = $this->find_comcode_page($lang, $file, $zone); // Check no redirects in our way if (addon_installed('redirects_editor')) { $test = $GLOBALS['SITE_DB']->query_value_null_ok('redirects', 'r_to_zone', array('r_from_page' => $file, 'r_from_zone' => $zone)); if (!is_null($test)) { $redirect_url = build_url(array('page' => 'admin_redirects'), get_module_zone('admin_redirects')); attach_message(do_lang_tempcode('BLOCKING_REDIRECT_IN_PLACE', escape_html($redirect_url->evaluate())), 'notice'); } } $title = get_page_title($simple_add || $file == '' ? 'COMCODE_PAGE_ADD' : '_COMCODE_PAGE_EDIT', true, array(escape_html($zone), escape_html($file))); if (!$simple_add && $file != '') { breadcrumb_set_self(do_lang_tempcode('COMCODE_PAGE_EDIT')); } if (!has_actual_page_access(get_member(), $file, $zone)) { access_denied('PAGE_ACCESS'); } // Default file contents $contents = post_param('new', ''); $parsed = NULL; if ($contents == '') { $file_base = strpos($restore_from, 'comcode_custom/') ? get_custom_file_base() : get_file_base(); if (!is_file($file_base . '/' . $restore_from)) { $file_base = get_file_base(); } if (is_file($file_base . '/' . $restore_from)) { $contents = file_get_contents($file_base . '/' . $restore_from, FILE_TEXT); if (is_null(get_param('restore_from', NULL))) { $string_index = $GLOBALS['SITE_DB']->query_value_null_ok('cached_comcode_pages', 'string_index', array('the_zone' => $zone, 'the_page' => $file)); if (!is_null($string_index)) { $parsed = get_translated_tempcode($string_index, NULL, $lang); } } $new = false; } elseif (get_param('title', '') != '') { $page_pretty_title = get_param('title', ''); $contents = '[title]' . $page_pretty_title . "[/title]\n\n" . do_lang('PAGE_DEFAULT_TEXT'); $new = true; } else { $contents = '[title]' . do_lang('PAGE_DEFAULT_TITLE') . "[/title]\n\n"; $new = true; } if ($new && get_option('is_on_comcode_page_children') == '1') { $contents .= chr(10) . chr(10) . '[block]main_comcode_page_children[/block]'; } } else { $new = false; } $map = array('page' => '_SELF', 'type' => '__ed', 'wide' => 1); if ($simple_add) { $map['simple_add'] = '1'; } $post_url = build_url($map, '_SELF'); // Revision history $filesarray = $this->get_comcode_revisions($zone, 'comcode_custom/' . $lang, $file . '.txt'); rsort($filesarray); $i = 0; $revision_history = new ocp_tempcode(); $max = intval(get_option('number_revisions_show')); $last_path = $file_base . '/' . $restore_from; if (is_file($last_path)) { foreach ($filesarray as $iterator => $stuff) { list($filepath, $time) = $stuff; // Find who did the revision $editor = $GLOBALS['SITE_DB']->query_value_null_ok('adminlogs', 'the_user', array('date_and_time' => $time, 'the_type' => 'COMCODE_PAGE_EDIT', 'param_a' => $file)); if (has_specific_permission(get_member(), 'view_revision_history') || $editor == get_member()) { if (is_null($editor)) { $editor = do_lang('UNKNOWN'); } else { $editor = $GLOBALS['FORUM_DRIVER']->get_username($editor); if (is_null($editor)) { $editor = do_lang('UNKNOWN'); } } $old_file = (strpos($filepath, '_custom/') ? get_custom_file_base() : get_file_base()) . '/' . $filepath; $size = filesize($old_file); $date = get_timezoned_date($time); $url = get_custom_base_url() . '/' . $zone . '/' . 'pages/comcode_custom/' . $lang . '/' . $file . '.txt.' . strval($time); $restore_url = build_url(array('page' => '_SELF', 'type' => '_ed', 'page_link' => $zone . ':' . $file, 'restore_from' => zone_black_magic_filterer($zone . ($zone != '' ? '/' : '') . 'pages/comcode_custom/' . $lang . '/' . $file . '.txt.' . strval($time), true)), '_SELF'); require_code('diff'); if (function_exists('diff_simple')) { $rendered_diff = diff_simple($old_file, $last_path); $last_path = $old_file; if ($rendered_diff == '' && $iterator == 0) { continue; } // the version records are often saved on create not replace $revision_history->attach(do_template('REVISION_HISTORY_LINE', array('_GUID' => '57e2c81fd621d1c8d6e283a5a4991001', 'REFERENCE_POINT_EXACT' => true, 'RENDERED_DIFF' => $rendered_diff, 'EDITOR' => $editor, 'DATE' => $date, 'DATE_RAW' => strval($time), 'RESTORE_URL' => $restore_url, 'URL' => $url, 'SIZE' => clean_file_size($size)))); $i++; } if ($i == $max) { break; } } } if (strpos($restore_from, '/comcode_custom/') !== false && zone_black_magic_filterer($zone . '/' . 'pages/comcode/' . $lang . '/' . $file . '.txt', true) != $restore_from && is_file(zone_black_magic_filterer(get_file_base() . '/' . $zone . '/' . 'pages/comcode/' . $lang . '/' . $file . '.txt'))) { $url = get_base_url() . '/' . $zone . '/' . 'pages/comcode/' . $lang . '/' . $file . '.txt'; $size = filesize(zone_black_magic_filterer(get_file_base() . '/' . $zone . '/' . 'pages/comcode/' . $lang . '/' . $file . '.txt')); $restore_url = build_url(array('page' => '_SELF', 'type' => '_ed', 'page_link' => $zone . ':' . $file, 'restore_from' => $zone . ($zone == '' ? '' : '/') . 'pages/comcode/' . $lang . '/' . $file . '.txt'), '_SELF'); require_code('diff'); if (function_exists('diff_simple')) { $rendered_diff = diff_simple(zone_black_magic_filterer(get_file_base() . '/' . $zone . '/' . 'pages/comcode/' . $lang . '/' . $file . '.txt'), $last_path); $revision_history->attach(do_template('REVISION_HISTORY_LINE', array('_GUID' => 'ed0b29f26cf93d4d6e0348a7e75d259d', 'REFERENCE_POINT_EXACT' => true, 'RENDERED_DIFF' => $rendered_diff, 'RESTORE_URL' => $restore_url, 'URL' => $url, 'SIZE' => clean_file_size($size)))); $i++; } } } if (!$revision_history->is_empty() && get_param('restore_from', '') == '') { $revision_history = do_template('REVISION_HISTORY_WRAP', array('_GUID' => '2349ee62cae037ec3cf1766403c92b39', 'CONTENT' => $revision_history)); } elseif (!$revision_history->is_empty()) { $revision_history = do_template('REVISION_RESTORE'); } $meta_keywords = post_param('meta_keywords', ''); $meta_description = post_param('meta_description', ''); if ($meta_keywords == '' && $meta_description == '') { list($meta_keywords, $meta_description) = seo_meta_get_for('comcode_page', $zone . ':' . $file); } $hidden_fields = new ocp_tempcode(); if (addon_installed('page_management') && has_actual_page_access(get_member(), 'adminzone')) { $delete_url = build_url(array('page' => 'admin_sitetree', 'type' => '_delete', 'page__' . $file => 1, 'zone' => $zone), get_module_zone('admin_sitetree')); } else { $delete_url = new ocp_tempcode(); } $fields = new ocp_tempcode(); $fields2 = new ocp_tempcode(); require_code('form_templates'); if (addon_installed('page_management')) { if (has_actual_page_access(get_member(), 'admin_sitetree')) { if ($simple_add) { $hidden_fields->attach(form_input_hidden('title', $file)); } else { $fields->attach(form_input_codename(do_lang_tempcode('CODENAME'), do_lang_tempcode('DESCRIPTION_CODENAME'), 'title', $file, true)); } } } $rows = $GLOBALS['SITE_DB']->query_select('comcode_pages', array('*'), array('the_zone' => $zone, 'the_page' => $file)); if (array_key_exists(0, $rows)) { $validated = $rows[0]['p_validated'] == 1; $parent_page = $rows[0]['p_parent_page']; $show_as_edit = $rows[0]['p_show_as_edit'] == 1; $owner = $rows[0]['p_submitter']; } else { global $NON_CANONICAL_PARAMS; $NON_CANONICAL_PARAMS[] = 'parent_page'; $validated = true; $parent_page = get_param('parent_page', ''); $show_as_edit = false; $owner = get_member(); } $_pages = find_all_pages($zone, 'comcode/' . $lang, 'txt', false, NULL, FIND_ALL_PAGES__NEWEST); $_pages += find_all_pages($zone, 'comcode_custom/' . $lang, 'txt', false, NULL, FIND_ALL_PAGES__NEWEST); $_pages += find_all_pages($zone, 'comcode/' . get_site_default_lang(), 'txt', false, NULL, FIND_ALL_PAGES__NEWEST); $_pages += find_all_pages($zone, 'comcode_custom/' . get_site_default_lang(), 'txt', false, NULL, FIND_ALL_PAGES__NEWEST); ksort($_pages); $pages = form_input_list_entry('', false, do_lang_tempcode('NA_EM')); foreach (array_keys($_pages) as $page) { if (!is_string($page)) { $page = strval($page); } if ($page != $file) { $pages->attach(form_input_list_entry($page, $parent_page == $page)); } } if (!$simple_add) { if (!$validated) { $validated = get_param_integer('validated', 0) == 1; } if (has_specific_permission(get_member(), 'bypass_validation_highrange_content')) { if (addon_installed('unvalidated')) { $fields2->attach(form_input_tick(do_lang_tempcode('VALIDATED'), do_lang_tempcode('DESCRIPTION_VALIDATED'), 'validated', $validated)); } } if (!$new) { if ($delete_url->is_empty()) { $fields2->attach(form_input_tick(do_lang_tempcode('DELETE'), do_lang_tempcode('DESCRIPTION_DELETE'), 'delete', false)); } } } else { $hidden_fields->attach(form_input_hidden('validated', '1')); } if (get_option('is_on_comcode_page_children') == '1') { $fields2->attach(form_input_list(do_lang_tempcode('PARENT_PAGE'), do_lang_tempcode('DESCRIPTION_PARENT_PAGE'), 'parent_page', $pages, NULL, false, false)); } if (!$simple_add) { $fields2->attach(form_input_tick(do_lang_tempcode('SHOW_AS_EDITED'), do_lang_tempcode('DESCRIPTION_SHOW_AS_EDITED'), 'show_as_edit', $show_as_edit)); if ($GLOBALS['FORUM_DRIVER']->is_super_admin(get_member())) { $fields2->attach(form_input_username(do_lang_tempcode('OWNER'), do_lang_tempcode('DESCRIPTION_OWNER'), 'owner', $GLOBALS['FORUM_DRIVER']->get_username($owner), true)); } $fields2->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => do_lang_tempcode('SEO'), 'SECTION_HIDDEN' => true, 'HELP' => get_option('show_docs') == '0' ? NULL : protect_from_escaping(symbol_tempcode('URLISE_LANG', array(do_lang('TUTORIAL_ON_THIS'), brand_base_url() . '/docs' . strval(ocp_version()) . '/pg/tut_seo', 'tut_seo', '1')))))); $fields2->attach(form_input_line_multi(do_lang_tempcode('KEYWORDS'), do_lang_tempcode('DESCRIPTION_META_KEYWORDS'), 'meta_keywords[]', array_map('trim', explode(',', preg_replace('#,+#', ',', $meta_keywords))), 0)); $fields2->attach(form_input_line(do_lang_tempcode('META_DESCRIPTION'), do_lang_tempcode('DESCRIPTION_META_DESCRIPTION'), 'meta_description', $meta_description, false)); } // Awards? if (addon_installed('awards')) { require_code('awards'); $fields2->attach(get_award_fields('comcode_page', $zone . ':' . $file)); } require_code('permissions2'); $fields2->attach(get_page_permissions_for_environment($zone, $file)); $hidden_fields->attach(form_input_hidden('file', $file)); $hidden_fields->attach(form_input_hidden('lang', $lang)); $hidden_fields->attach(form_input_hidden('zone', $zone)); $hidden_fields->attach(form_input_hidden('redirect', get_param('redirect', ''))); $posting_form = get_posting_form(do_lang($simple_add ? 'COMCODE_PAGE_ADD' : 'SAVE'), $contents, $post_url, $hidden_fields, $fields, do_lang_tempcode('COMCODE_PAGE'), '', $fields2, $parsed, NULL, NULL, false); $export_url = build_url(array('page' => '_SELF', 'type' => 'export', 'page_link' => $page_link, 'export' => $restore_from, 'lang' => $lang), '_SELF'); $text = new ocp_tempcode(); if (addon_installed('points')) { $login_url = build_url(array('page' => 'login', 'type' => 'misc', 'redirect' => get_self_url(true, true)), get_module_zone('login')); $_login_url = escape_html($login_url->evaluate()); if (is_guest() && (get_forum_type() != 'ocf' || has_actual_page_access(get_member(), 'join'))) { $text->attach(paragraph(do_lang_tempcode('NOT_LOGGED_IN_NO_CREDIT', $_login_url))); } } list($warning_details, $ping_url) = handle_conflict_resolution($page_link); if (!$simple_add) { breadcrumb_set_parents(array(array('_SELF:_SELF:misc:lang=' . $lang, do_lang_tempcode('CHOOSE')))); } return do_template('COMCODE_EDIT_SCREEN', array('_GUID' => 'ec1d773684757f5bf6f39cf931555bf2', 'NEW' => $new, 'PING_URL' => $ping_url, 'WARNING_DETAILS' => $warning_details, 'TEXT' => $text, 'TITLE' => $title, 'DELETE_URL' => $delete_url, 'ZONE' => $zone, 'FILE' => $file, 'EXPORT_URL' => $export_url, 'POSTING_FORM' => $posting_form, 'REVISION_HISTORY' => $revision_history)); }
/** * Standard aed_module add actualiser. * * @return ID_TEXT The entry added */ function add_actualisation() { require_code('catalogues2'); $name = post_param('name'); $title = post_param('title'); $description = post_param('description'); $display_type = post_param_integer('display_type'); $is_tree = post_param_integer('is_tree', 0); $this->is_tree_catalogue = $is_tree == 1; $notes = post_param('notes', ''); $submit_points = post_param_integer('submit_points', 0); $cat_tab = post_param_integer('cat_tab', 0); $ecommerce = post_param_integer('ecommerce', 0); $send_view_reports = post_param('send_view_reports'); // What fields do we have? $new = array(); foreach ($_POST as $key => $val) { if (!is_string($val) && !is_integer($val)) { continue; } if (get_magic_quotes_gpc()) { $val = stripslashes($val); } $matches = array(); if (preg_match('#new_field_(\\d*)_(.*)#A', $key, $matches) != 0) { $new[$matches[1]][$matches[2]] = $val; } } $num_fields = 0; foreach ($new as $field) { if ($field['name'] != '') { $num_fields++; } } if ($num_fields == 0) { warn_exit(do_lang_tempcode('NO_FIELDS')); } $category_id = actual_add_catalogue($name, $title, $description, $display_type, $is_tree, $notes, $submit_points, $ecommerce, $send_view_reports); $this->set_permissions($name); if (!is_null($category_id)) { $GLOBALS['MODULE_CMS_CATALOGUES']->cat_aed_module->set_permissions(strval($category_id)); } // Now onto the fields foreach ($new as $field) { if (!array_key_exists('default', $field)) { warn_exit(do_lang_tempcode('IMPROPERLY_FILLED_IN')); } if (!array_key_exists('description', $field)) { warn_exit(do_lang_tempcode('IMPROPERLY_FILLED_IN')); } if (!array_key_exists('name', $field)) { warn_exit(do_lang_tempcode('IMPROPERLY_FILLED_IN')); } if (!array_key_exists('order', $field)) { warn_exit(do_lang_tempcode('IMPROPERLY_FILLED_IN')); } if (!array_key_exists('type', $field) || $field['type'] == '') { warn_exit(do_lang_tempcode('IMPROPERLY_FILLED_IN')); } if ($field['order'] == '') { $field['order'] = 0; } else { $field['order'] = intval($field['order']); } $defines_order = array_key_exists('defines_order', $field) ? intval($field['defines_order']) : 0; $visible = array_key_exists('visible', $field) ? intval($field['visible']) : 0; $searchable = array_key_exists('searchable', $field) ? intval($field['searchable']) : 0; $required = array_key_exists('required', $field) ? intval($field['required']) : 0; $put_in_category = array_key_exists('put_in_category', $field) ? intval($field['put_in_category']) : 0; $put_in_search = array_key_exists('put_in_search', $field) ? intval($field['put_in_search']) : 0; if ($field['name'] != '') { actual_add_catalogue_field($name, $field['name'], $field['description'], $field['type'], $field['order'], $defines_order, $visible, $searchable, $field['default'], $required, $put_in_category, $put_in_search); } } $add_to_menu = post_param_integer('add_to_menu', 0); if ($add_to_menu == 1) { require_code('menus2'); if ($is_tree == 1) { add_menu_item_simple('main_content', NULL, $title, '_SEARCH:catalogues:type=category:catalogue_name=' . $name); } else { add_menu_item_simple('main_content', NULL, $title, '_SEARCH:catalogues:type=index:' . $name); } } // Auto-fill feature $auto_fill = post_param('auto_fill'); if ($auto_fill != '') { $categories = array(); if (strpos($auto_fill, '|') === false) { $to_do = explode(',', $auto_fill); } else { $to_do = explode('|', $auto_fill); } foreach ($to_do as $doing) { if (trim($doing) == '') { continue; } $bits = explode('\\', $doing); $parent_id = $category_id; foreach ($bits as $bit) { $bit = trim($bit); if (array_key_exists($bit, $categories)) { if (!is_null($parent_id)) { $parent_id = $categories[$bit]; } } else { $_parent_id = actual_add_catalogue_category($name, $bit, '', '', $parent_id, ''); if (!is_null($parent_id)) { $parent_id = $_parent_id; } require_code('permissions2'); if (get_value('disable_cat_cat_perms') !== '1') { set_category_permissions_from_environment('catalogues_category', strval($parent_id), $this->permission_page); } $categories[$bit] = $parent_id; } } } } if ($is_tree == 0 && substr($name, 0, 1) != '_') { $this->do_next_description = paragraph(do_lang_tempcode('SUGGEST_ADD_CATEGORY_NEXT')); } return $name; }
/** * Add a zone. * * @param ID_TEXT Name of the zone * @param SHORT_TEXT The zone title * @param ID_TEXT The zones default page * @param SHORT_TEXT The header text * @param ID_TEXT The theme * @param BINARY Whether the zone is wide * @param BINARY Whether the zone requires a session for pages to be used * @param BINARY Whether the zone in displayed in the menu coded into some themes */ function actual_add_zone($zone, $title, $default_page = 'start', $header_text = '', $theme = 'default', $wide = 0, $require_session = 0, $displayed_in_menu = 1) { require_code('type_validation'); if (!is_alphanumeric($zone, true)) { warn_exit(do_lang_tempcode('BAD_CODENAME')); } if (get_file_base() != get_custom_file_base()) { warn_exit(do_lang_tempcode('SHARED_INSTALL_PROHIBIT')); } // Check doesn't already exist $test = $GLOBALS['SITE_DB']->query_value_null_ok('zones', 'zone_header_text', array('zone_name' => $zone)); if (!is_null($test)) { if (file_exists(get_file_base() . '/' . $zone)) { warn_exit(do_lang_tempcode('ALREADY_EXISTS', escape_html($zone))); } else { persistant_cache_delete(array('ZONE', $zone)); $GLOBALS['SITE_DB']->query_delete('zones', array('zone_name' => $zone), '', 1); } } if (!file_exists(get_file_base() . '/' . $zone)) { // Create structure afm_make_directory($zone . '/pages/minimodules_custom', true, true); afm_make_directory($zone . '/pages/minimodules', false, true); afm_make_directory($zone . '/pages/modules_custom', true, true); afm_make_directory($zone . '/pages/modules', false, true); $langs = array_keys(find_all_langs(true)); foreach ($langs as $lang) { afm_make_directory($zone . '/pages/comcode_custom/' . $lang, true, true); afm_make_directory($zone . '/pages/comcode/' . $lang, false, true); afm_make_directory($zone . '/pages/html_custom/' . $lang, true, true); afm_make_directory($zone . '/pages/html/' . $lang, false, true); } afm_make_file($zone . '/index.php', file_get_contents(get_file_base() . '/site/index.php'), false); if (file_exists(get_file_base() . '/pages/.htaccess')) { afm_make_file($zone . '/pages/.htaccess', file_get_contents(get_file_base() . '/pages/.htaccess'), false); } $index_php = array('pages/comcode', 'pages/comcode/EN', 'pages/comcode_custom', 'pages/comcode_custom/EN', 'pages/html', 'pages/html/EN', 'pages/html_custom', 'pages/html_custom/EN', 'pages/modules', 'pages/modules_custom', 'pages'); foreach ($index_php as $i) { afm_make_file($zone . '/' . $i . '/index.html', '', false); } $default_menu = <<<END [block="zone_{$zone}_menu" type="tree" caption="Menu"]side_stored_menu[/block] [block failsafe="1"]side_users_online[/block] [block failsafe="1"]side_stats[/block] [block]side_personal_stats[/block] END; afm_make_file($zone . '/pages/comcode_custom/EN/panel_left.txt', $default_menu, true); } afm_make_file($zone . '/pages/comcode_custom/EN/' . filter_naughty($default_page) . '.txt', '[title]' . do_lang('YOUR_NEW_ZONE') . '[/title]' . chr(10) . chr(10) . do_lang('YOUR_NEW_ZONE_PAGE', $zone . ':' . $default_page) . chr(10) . chr(10) . '[block]main_comcode_page_children[/block]', true); $GLOBALS['SITE_DB']->query_insert('zones', array('zone_name' => $zone, 'zone_title' => insert_lang($title, 1), 'zone_default_page' => $default_page, 'zone_header_text' => insert_lang($header_text, 1), 'zone_theme' => $theme, 'zone_wide' => $wide, 'zone_require_session' => $require_session, 'zone_displayed_in_menu' => $displayed_in_menu)); require_code('menus2'); $menu_item_count = $GLOBALS['SITE_DB']->query_value('menu_items', 'COUNT(*)', array('i_menu' => 'zone_menu')); if ($menu_item_count < 40) { add_menu_item_simple('zone_menu', NULL, $title, $zone . ':', 0, 1); } log_it('ADD_ZONE', $zone); persistant_cache_delete('ALL_ZONES'); decache('main_sitemap'); decache('side_stored_menu'); decache('side_zone_jump'); }
/** * Uninstall an addon. * * @param string Name of the addon * @param ?array The files to install (NULL: all) */ function install_addon($file, $files = NULL) { $full = get_custom_file_base() . '/imports/mods/' . $file; require_code('zones2'); require_code('zones3'); require_code('tar'); $tar = tar_open($full, 'rb'); $info_file = tar_get_file($tar, 'mod.inf'); if (is_null($info_file)) { warn_exit(do_lang_tempcode('NOT_ADDON')); } $info = better_parse_ini_file(NULL, $info_file['data']); $directory = tar_get_directory($tar); tar_extract_to_folder($tar, '', true, $files, true); $addon = $info['name']; $author = $info['author']; $organisation = $info['organisation']; $version = $info['version']; if ($version == '(version-synched)') { $version = float_to_raw_string(ocp_version_number()); } $dependencies = explode(',', array_key_exists('dependencies', $info) ? $info['dependencies'] : ''); $incompatibilities = explode(',', array_key_exists('incompatibilities', $info) ? $info['incompatibilities'] : ''); $description = $info['description']; $GLOBALS['SITE_DB']->query_delete('addons', array('addon_name' => $addon), '', 1); $GLOBALS['SITE_DB']->query_insert('addons', array('addon_name' => $addon, 'addon_author' => $author, 'addon_organisation' => $organisation, 'addon_version' => $version, 'addon_description' => $description, 'addon_install_time' => time())); foreach ($dependencies as $dependency) { $GLOBALS['SITE_DB']->query_insert('addons_dependencies', array('addon_name' => $addon, 'addon_name_dependant_upon' => trim($dependency), 'addon_name_incompatibility' => 0)); } foreach ($incompatibilities as $dependency) { $GLOBALS['SITE_DB']->query_insert('addons_dependencies', array('addon_name' => $addon, 'addon_name_dependant_upon' => trim($dependency), 'addon_name_incompatibility' => 1)); } foreach ($directory as $dir) { $addon_file = $dir['path']; if (substr($addon_file, -1) == '/') { continue; } if (is_null($files) || in_array($addon_file, $files)) { $GLOBALS['SITE_DB']->query_insert('addons_files', array('addon_name' => $addon, 'filename' => $addon_file)); } } // Install new zones $zones = array(''); foreach ($directory as $dir) { $addon_file = $dir['path']; if (is_null($files) || in_array($addon_file, $files)) { $matches = array(); if (preg_match('#(\\w*)/index.php#', $addon_file, $matches) != 0) { $zone = $matches[1]; $test = $GLOBALS['SITE_DB']->query_value_null_ok('zones', 'zone_name', array('zone_name' => $zone)); if (is_null($test)) { require_code('menus2'); add_menu_item_simple('zone_menu', NULL, $zone, $zone . ':', 0, 1); $GLOBALS['SITE_DB']->query_insert('zones', array('zone_name' => $zone, 'zone_title' => insert_lang($zone, 1), 'zone_default_page' => 'start', 'zone_header_text' => insert_lang('???', 2), 'zone_theme' => 'default', 'zone_wide' => 0, 'zone_require_session' => 0, 'zone_displayed_in_menu' => 1)); $groups = $GLOBALS['FORUM_DRIVER']->get_usergroup_list(false, true); foreach (array_keys($groups) as $group_id) { $GLOBALS['SITE_DB']->query_insert('group_zone_access', array('zone_name' => $zone, 'group_id' => $group_id)); } } $zones[] = $zone; } } } // Install new modules $zones = array_unique(array_merge(find_all_zones(), $zones)); if (get_option('collapse_user_zones') == '1') { $zones[] = 'site'; } foreach ($zones as $zone) { $prefix = $zone == '' ? '' : $zone . '/'; foreach ($directory as $dir) { $addon_file = $dir['path']; if (is_null($files) || in_array($addon_file, $files)) { if (preg_match('#^' . $prefix . 'pages/(modules|modules\\_custom)/([^/]*)\\.php$#', $addon_file, $matches) != 0) { if (!module_installed($matches[2])) { reinstall_module($zone, $matches[2]); } } } } } // Install new blocks foreach ($directory as $dir) { $addon_file = $dir['path']; if (is_null($files) || in_array($addon_file, $files)) { if (preg_match('#^(sources|sources\\_custom)/blocks/([^/]*)\\.php$#', $addon_file, $matches) != 0) { if (!block_installed($matches[2])) { reinstall_block($matches[2]); } } } } // Clear some cacheing require_code('view_modes'); require_code('zones2'); require_code('zones3'); erase_comcode_page_cache(); erase_tempcode_cache(); persistant_cache_empty(); erase_cached_templates(); erase_cached_language(); // Load mod.php if it exists $_modphp_file = tar_get_file($tar, 'mod.php'); if (!is_null($_modphp_file)) { $modphp_file = trim($_modphp_file['data']); if (!defined('HIPHOP_PHP')) { if (substr($modphp_file, 0, 5) == '<' . '?php') { $modphp_file = substr($modphp_file, 5); } if (substr($modphp_file, -2) == '?' . '>') { $modphp_file = substr($modphp_file, 0, strlen($modphp_file) - 2); } if (eval($modphp_file) === false) { fatal_exit(@strval($php_errormsg)); } } else { $matches = array(); $num_matches = preg_match_all('#\\$GLOBALS[\'SITE_DB\']->query_insert(\'theme_images\',array(\'id\'=>\'([^\']*)\',\'theme\'=>\'([^\']*)\',\'path\'=>\'([^\']*)\',\'lang\'=>\'([^\']*)\'),false,true);#', $modphp_file, $matches); for ($i = 0; $i < $num_matches; $i++) { $GLOBALS['SITE_DB']->query_insert('theme_images', array('id' => $matches[1][$i], 'theme' => $matches[2][$i], 'path' => $matches[3][$i], 'lang' => $matches[4][$i]), false, true); } } } tar_close($tar); // Call install script, if it exists $path = '/data_custom/' . strtolower(basename($file, '.tar')) . '_install.php'; if (file_exists(get_file_base() . $path)) { require_code('files'); http_download_file(get_base_url() . $path); } log_it('INSTALL_ADDON', $addon); }
/** * 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) { $GLOBALS['SITE_DB']->alter_table_field('transactions', 'currency', 'ID_TEXT', 't_currency'); } if (!is_null($upgrade_from) && $upgrade_from < 4) { $GLOBALS['SITE_DB']->add_table_field('transactions', 't_via', 'ID_TEXT', 'paypal'); } if (is_null($upgrade_from) || $upgrade_from < 4) { add_config_option('PAYMENT_GATEWAY', 'payment_gateway', 'line', 'return \'paypal\';', 'ECOMMERCE', 'ECOMMERCE'); add_config_option('USE_LOCAL_PAYMENT', 'use_local_payment', 'tick', 'return \'0\';', 'ECOMMERCE', 'ECOMMERCE'); add_config_option('IPN_PASSWORD', 'ipn_password', 'line', 'return \'\';', 'ECOMMERCE', 'ECOMMERCE'); // SecPay test account: 'secpay'/'secpay' add_config_option('IPN_DIGEST', 'ipn_digest', 'line', 'return \'\';', 'ECOMMERCE', 'ECOMMERCE'); add_config_option('VPN_USERNAME', 'vpn_username', 'line', 'return \'\';', 'ECOMMERCE', 'ECOMMERCE'); // SecPay: not needed add_config_option('VPN_PASSWORD', 'vpn_password', 'line', 'return \'\';', 'ECOMMERCE', 'ECOMMERCE'); // SecPay test account: 'secpay'/'secpay' add_config_option('CALLBACK_PASSWORD', 'callback_password', 'line', 'return \'\';', 'ECOMMERCE', 'ECOMMERCE'); // SecPay: not needed add_config_option('POSTAL_ADDRESS', 'pd_address', 'text', 'return \'\';', 'ECOMMERCE', 'ECOMMERCE'); // SecPay: not needed add_config_option('EMAIL_ADDRESS', 'pd_email', 'line', 'return get_option(\'staff_address\');', 'ECOMMERCE', 'ECOMMERCE'); // SecPay: not needed add_config_option('PHONE_NUMBER', 'pd_number', 'line', 'return \'\';', 'ECOMMERCE', 'ECOMMERCE'); // SecPay: not needed add_specific_permission('ECOMMERCE', 'access_ecommerce_in_test_mode', false); $GLOBALS['SITE_DB']->create_table('trans_expecting', array('id' => '*ID_TEXT', 'e_purchase_id' => 'ID_TEXT', 'e_item_name' => 'SHORT_TEXT', 'e_member_id' => 'USER', 'e_amount' => 'SHORT_TEXT', 'e_ip_address' => 'IP', 'e_session_id' => 'INTEGER', 'e_time' => 'TIME', 'e_length' => '?INTEGER', 'e_length_units' => 'ID_TEXT')); require_code('currency'); $cpf = array('currency' => array(3, 'list', implode('|', array_keys(get_currency_map())))); foreach ($cpf as $f => $l) { $GLOBALS['FORUM_DRIVER']->install_create_custom_field($f, $l[0], 1, 0, 1, 0, '', $l[1], 0, $l[2]); } $cpf = array('payment_cardholder_name' => array(100, 'short_text', ''), 'payment_type' => array(26, 'list', 'American Express|Delta|Diners Card|JCB|Master Card|Solo|Switch|Visa'), 'payment_card_number' => array(20, 'integer', ''), 'payment_card_start_date' => array(5, 'short_text', 'mm/yy'), 'payment_card_expiry_date' => array(5, 'short_text', 'mm/yy'), 'payment_card_issue_number' => array(2, 'short_text', ''), 'payment_card_cv2' => array(4, 'short_text', '')); foreach ($cpf as $f => $l) { $GLOBALS['FORUM_DRIVER']->install_create_custom_field($f, $l[0], 1, 0, 1, 0, '', $l[1], 1, $l[2]); } require_lang('ecommerce'); add_menu_item_simple('ecommerce_features', NULL, 'PURCHASING', '_SEARCH:purchase:type=misc'); add_menu_item_simple('ecommerce_features', NULL, 'INVOICES', '_SEARCH:invoices:type=misc'); add_menu_item_simple('ecommerce_features', NULL, 'MODULE_TRANS_NAME_subscriptions', '_SEARCH:subscriptions:type=misc'); } if (is_null($upgrade_from) || $upgrade_from < 3) { add_config_option('CURRENCY', 'currency', 'line', 'return \'GBP\';', 'ECOMMERCE', 'ECOMMERCE'); add_config_option('ECOMMERCE_TEST_MODE', 'ecommerce_test_mode', 'tick', 'return \'0\';', 'ECOMMERCE', 'ECOMMERCE'); add_config_option('IPN_ADDRESS_TEST', 'ipn_test', 'line', 'return get_option(\'staff_address\');', 'ECOMMERCE', 'ECOMMERCE'); add_config_option('IPN_ADDRESS', 'ipn', 'line', 'return get_option(\'staff_address\');', 'ECOMMERCE', 'ECOMMERCE'); } if (is_null($upgrade_from)) { $GLOBALS['SITE_DB']->create_table('transactions', array('id' => '*ID_TEXT', 'purchase_id' => 'ID_TEXT', 'status' => 'SHORT_TEXT', 'reason' => 'SHORT_TEXT', 'amount' => 'SHORT_TEXT', 't_currency' => 'ID_TEXT', 'linked' => 'ID_TEXT', 't_time' => '*TIME', 'item' => 'SHORT_TEXT', 'pending_reason' => 'SHORT_TEXT', 't_memo' => 'LONG_TEXT', 't_via' => 'ID_TEXT')); } }
/** * Special import-esque function to aid switching to OCF after importing forum previously served by a forum driver. * * @return tempcode Information about progress */ function ocf_switch() { $out = new ocp_tempcode(); $todos = array('USER' => array('member', db_get_first_id(), NULL), 'GROUP' => array('group', NULL, 'group_id')); foreach ($todos as $db_abstraction => $definition) { list($import_code, $default_id, $field_name_also) = $definition; $count = 0; $extra = is_null($field_name_also) ? '' : ' OR ' . db_string_equal_to('m_name', $field_name_also); $fields = $GLOBALS['SITE_DB']->query('SELECT m_table,m_name FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'db_meta WHERE (NOT (m_table LIKE \'' . db_encode_like('f_%') . '\')) AND (' . db_string_equal_to('m_type', $db_abstraction) . ' OR ' . db_string_equal_to('m_type', '*' . $db_abstraction) . ' OR ' . db_string_equal_to('m_type', '?' . $db_abstraction) . $extra . ')'); foreach ($fields as $field) { if ($field['m_table'] == 'stats') { continue; } // Lots of data and it's not important //echo '(working) '.$field['m_table'].'/'.$field['m_name'].'<br />'; $values = $GLOBALS['SITE_DB']->query_select($field['m_table'], array('*')); foreach ($values as $value) { $current = $value[$field['m_name']]; $remapped = import_id_remap_get($import_code, $current, true); if (is_null($remapped)) { $remapped = $default_id; } if (!is_null($remapped)) { $value2 = $value; $value2[$field['m_name']] = -$remapped; $c = $GLOBALS['SITE_DB']->query_update($field['m_table'], $value2, $value, '', NULL, NULL, true, true); if (is_null($c)) { $GLOBALS['SITE_DB']->query_delete($field['m_table'], $value); } else { $count += $c; } } else { $GLOBALS['SITE_DB']->query_delete($field['m_table'], $value); } } $GLOBALS['SITE_DB']->query('UPDATE ' . $GLOBALS['SITE_DB']->get_table_prefix() . $field['m_table'] . ' SET ' . $field['m_name'] . '=-' . $field['m_name'] . ' WHERE ' . $field['m_name'] . '<0'); } $out->attach(paragraph(do_lang_tempcode('OCF_CONVERTED_' . $db_abstraction, $count == 0 ? '?' : strval($count)))); } // info.php global $FILE_BASE; $info_file = (file_exists('use_comp_name') ? array_key_exists('COMPUTERNAME', $_ENV) ? $_ENV['COMPUTERNAME'] : $_SERVER['SERVER_NAME'] : 'info') . '.php'; $info = @fopen($FILE_BASE . '/' . $info_file, 'wt') or intelligent_write_error($FILE_BASE . '/' . $info_file); fwrite($info, "<" . "?php\n"); global $SITE_INFO; $SITE_INFO['forum_type'] = 'ocf'; $SITE_INFO['ocf_table_prefix'] = $SITE_INFO['table_prefix']; $SITE_INFO['db_forums'] = $SITE_INFO['db_site']; $SITE_INFO['db_forums_host'] = array_key_exists('db_site_host', $SITE_INFO) ? $SITE_INFO['db_site_host'] : 'localhost'; $SITE_INFO['db_forums_user'] = $SITE_INFO['db_site_user']; $SITE_INFO['db_forums_password'] = $SITE_INFO['db_site_password']; $SITE_INFO['board_prefix'] = get_base_url(); foreach ($SITE_INFO as $key => $val) { $_val = str_replace('\\', '\\\\', $val); fwrite($info, '$SITE_INFO[\'' . $key . '\']=\'' . $_val . "';\n"); } fwrite($info, "?" . ">\n"); fclose($info); fix_permissions($FILE_BASE . '/' . $info_file); sync_file($FILE_BASE . '/' . $info_file); $out->attach(paragraph(do_lang_tempcode('OCF_CONVERTED_INFO'))); $LANG = get_site_default_lang(); $trans5 = insert_lang(do_lang('FORUM'), 1, NULL, false, NULL, $LANG); $GLOBALS['SITE_DB']->query_insert('zones', array('zone_name' => 'forum', 'zone_title' => insert_lang(do_lang('SECTION_FORUMS'), 1), 'zone_default_page' => 'forumview', 'zone_header_text' => $trans5, 'zone_theme' => '-1', 'zone_wide' => NULL, 'zone_require_session' => 0, 'zone_displayed_in_menu' => 1)); require_code('menus2'); add_menu_item_simple('zone_menu', NULL, 'SECTION_FORUMS', 'forum' . ':forumview', 0, 1); return $out; }
/** * 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 ($upgrade_from < 4 && !is_null($upgrade_from)) { delete_config_option('is_on_shop'); } if ($upgrade_from < 3 || is_null($upgrade_from)) { // Highlighted names add_config_option('ENABLE_PURCHASE', 'is_on_highlight_name_buy', 'tick', 'return (get_forum_type()!=\'ocf\')?NULL:\'1\';', 'POINTSTORE', 'NAME_HIGHLIGHTING'); add_config_option('COST_highlight_name', 'highlight_name', 'integer', 'return (get_forum_type()!=\'ocf\')?NULL:\'2000\';', 'POINTSTORE', 'NAME_HIGHLIGHTING'); // Topic pinning add_config_option('ENABLE_PURCHASE', 'is_on_topic_pin_buy', 'tick', 'return (!addon_installed(\'ocf_forum\'))?NULL:\'1\';', 'POINTSTORE', 'TOPIC_PINNING'); add_config_option('COST_topic_pin', 'topic_pin', 'integer', 'return (!addon_installed(\'ocf_forum\'))?NULL:\'180\';', 'POINTSTORE', 'TOPIC_PINNING'); // Gambling add_config_option('ENABLE_PURCHASE', 'is_on_gambling_buy', 'tick', 'return \'1\';', 'POINTSTORE', 'GAMBLING'); add_config_option('MINIMUM_GAMBLE_AMOUNT', 'minimum_gamble_amount', 'integer', 'return \'6\';', 'POINTSTORE', 'GAMBLING'); add_config_option('MAXIMUM_GAMBLE_AMOUNT', 'maximum_gamble_amount', 'integer', 'return \'200\';', 'POINTSTORE', 'GAMBLING'); add_config_option('MAXIMUM_GAMBLE_MULTIPLIER', 'maximum_gamble_multiplier', 'integer', 'return \'200\';', 'POINTSTORE', 'GAMBLING'); add_config_option('AVERAGE_GAMBLE_MULTIPLIER', 'average_gamble_multiplier', 'integer', 'return \'85\';', 'POINTSTORE', 'GAMBLING'); // Banners add_config_option('COST_banner_setup', 'banner_setup', 'integer', 'return (!addon_installed(\'banners\'))?NULL:\'750\';', 'POINTSTORE', 'BANNERS'); add_config_option('COST_banner_imp', 'banner_imp', 'integer', 'return (!addon_installed(\'banners\'))?NULL:\'700\';', 'POINTSTORE', 'BANNERS'); add_config_option('COST_banner_hit', 'banner_hit', 'integer', 'return (!addon_installed(\'banners\'))?NULL:\'20\';', 'POINTSTORE', 'BANNERS'); // POP3 add_config_option('COST_quota', 'quota', 'integer', 'return \'2\';', 'POINTSTORE', 'POP3'); // Flagrant add_config_option('COST_text', 'text', 'integer', 'return (!addon_installed(\'flagrant\'))?NULL:\'700\';', 'POINTSTORE', 'FLAGRANT_MESSAGE'); // Custom $GLOBALS['SITE_DB']->create_table('pstore_customs', array('id' => '*AUTO', 'c_title' => 'SHORT_TRANS', 'c_description' => 'LONG_TRANS', 'c_enabled' => 'BINARY', 'c_cost' => 'INTEGER', 'c_one_per_member' => 'BINARY')); // Permissions $GLOBALS['SITE_DB']->create_table('pstore_permissions', array('id' => '*AUTO', 'p_title' => 'SHORT_TRANS', 'p_description' => 'LONG_TRANS', 'p_enabled' => 'BINARY', 'p_cost' => 'INTEGER', 'p_hours' => 'INTEGER', 'p_type' => 'ID_TEXT', 'p_specific_permission' => 'ID_TEXT', 'p_zone' => 'ID_TEXT', 'p_page' => 'ID_TEXT', 'p_module' => 'ID_TEXT', 'p_category' => 'ID_TEXT')); } if (is_null($upgrade_from)) { $GLOBALS['SITE_DB']->create_table('prices', array('name' => '*ID_TEXT', 'price' => 'INTEGER')); $GLOBALS['SITE_DB']->create_table('sales', array('id' => '*AUTO', 'date_and_time' => 'TIME', 'memberid' => 'USER', 'purchasetype' => 'ID_TEXT', 'details' => 'SHORT_TEXT', 'details2' => 'SHORT_TEXT')); // Pointstore Options // Banners add_config_option('ENABLE_PURCHASE', 'is_on_banner_buy', 'tick', 'return (!addon_installed(\'banners\'))?NULL:\'1\';', 'POINTSTORE', 'BANNERS'); add_config_option('HITS_ALLOCATED', 'initial_banner_hits', 'integer', 'return (!addon_installed(\'banners\'))?NULL:\'100\';', 'POINTSTORE', 'BANNERS'); // POP3 add_config_option('ENABLE_PURCHASE', 'is_on_pop3_buy', 'tick', 'return \'0\';', 'POINTSTORE', 'POP3', 1); add_config_option('QUOTA', 'initial_quota', 'integer', 'return \'200\';', 'POINTSTORE', 'POP3', 1); add_config_option('MAX_QUOTA', 'max_quota', 'integer', 'return \'10000\';', 'POINTSTORE', 'POP3', 1); add_config_option('MAIL_SERVER', 'mail_server', 'line', 'return \'mail.\'.get_domain();', 'POINTSTORE', 'POP3', 1); add_config_option('POP3_MAINTAIN_URL', 'pop_url', 'line', 'return \'http://\'.get_domain().\':2082/frontend/x/mail/addpop2.html\';', 'POINTSTORE', 'POP3', 1); add_config_option('QUOTA_MAINTAIN_URL', 'quota_url', 'line', 'return \'http://\'.get_domain().\':2082/frontend/x/mail/pops.html\';', 'POINTSTORE', 'POP3', 1); // Forwarding add_config_option('ENABLE_PURCHASE', 'is_on_forw_buy', 'tick', 'return \'0\';', 'POINTSTORE', 'FORWARDING', 1); add_config_option('FORW_MAINTAIN_URL', 'forw_url', 'line', 'return \'http://\'.get_domain().\':2082/frontend/x/mail/addfwd.html\';', 'POINTSTORE', 'FORWARDING', 1); // Flagrant add_config_option('ENABLE_PURCHASE', 'is_on_flagrant_buy', 'tick', 'return (!addon_installed(\'flagrant\'))?NULL:\'1\';', 'POINTSTORE', 'FLAGRANT_MESSAGE'); require_lang('pointstore'); add_menu_item_simple('main_community', NULL, 'POINT_STORE', '_SEARCH:pointstore:type=misc'); } }
/** * 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) { $GLOBALS['SITE_DB']->add_table_field('quizzes', 'q_points_for_passing', 'INTEGER', 0); $GLOBALS['SITE_DB']->add_table_field('quizzes', 'q_tied_newsletter', '?AUTO_LINK', NULL); } if (!is_null($upgrade_from) && $upgrade_from < 2) { $GLOBALS['SITE_DB']->add_table_field('quizzes', 'q_add_date', 'TIME', time()); $GLOBALS['SITE_DB']->add_table_field('quizzes', 'q_validated', 'BINARY', 1); $GLOBALS['SITE_DB']->add_table_field('quizzes', 'q_submitter', 'BINARY', $GLOBALS['FORUM_DRIVER']->get_guest_id()); $GLOBALS['SITE_DB']->promote_text_field_to_comcode('quizzes', 'q_name'); } if (is_null($upgrade_from) || $upgrade_from < 2) { $GLOBALS['SITE_DB']->create_table('quiz_member_last_visit', array('id' => '*AUTO', 'v_time' => 'TIME', 'v_member_id' => 'USER', 'v_quiz_id' => 'AUTO_LINK')); } if (is_null($upgrade_from) || $upgrade_from < 3) { add_config_option('QUIZZES', 'quiz_show_stats_count_total_open', 'tick', 'return addon_installed(\'stats_block\')?\'0\':NULL;', 'BLOCKS', 'STATISTICS'); add_specific_permission('QUIZZES', 'bypass_quiz_repeat_time_restriction', false); } if (!is_null($upgrade_from) && $upgrade_from < 4) { $GLOBALS['SITE_DB']->add_table_field('quiz_questions', 'q_order', 'INTEGER'); $GLOBALS['SITE_DB']->add_table_field('quiz_question_answers', 'q_order', 'INTEGER'); $GLOBALS['SITE_DB']->add_table_field('quiz_member_last_visit', 'v_quiz_id', 'AUTO_LINK'); $GLOBALS['SITE_DB']->add_table_field('quizzes', 'q_end_text_fail', 'LONG_TRANS', ''); $GLOBALS['SITE_DB']->add_table_field('quiz_question_answers', 'q_explanation', 'LONG_TRANS', ''); } if (!is_null($upgrade_from) && $upgrade_from < 5) { $GLOBALS['SITE_DB']->add_table_field('quiz_questions', 'q_required', 'BINARY'); } if (is_null($upgrade_from) || $upgrade_from < 5) { require_lang('quiz'); add_menu_item_simple('main_website', NULL, 'QUIZZES', '_SEARCH:quiz:type=misc'); } if (is_null($upgrade_from)) { add_config_option('ADD_QUIZ', 'points_ADD_QUIZ', 'integer', 'return addon_installed(\'points\')?\'0\':NULL;', 'POINTS', 'COUNT_POINTS_GIVEN'); $GLOBALS['SITE_DB']->create_table('quizzes', array('id' => '*AUTO', 'q_timeout' => '?INTEGER', 'q_name' => 'SHORT_TRANS', 'q_start_text' => 'LONG_TRANS', 'q_end_text' => 'LONG_TRANS', 'q_notes' => 'LONG_TEXT', 'q_percentage' => 'INTEGER', 'q_open_time' => 'TIME', 'q_close_time' => '?TIME', 'q_num_winners' => 'INTEGER', 'q_redo_time' => '?INTEGER', 'q_type' => 'ID_TEXT', 'q_add_date' => 'TIME', 'q_validated' => 'BINARY', 'q_submitter' => 'USER', 'q_points_for_passing' => 'INTEGER', 'q_tied_newsletter' => '?AUTO_LINK', 'q_end_text_fail' => 'LONG_TRANS')); $GLOBALS['SITE_DB']->create_index('quizzes', 'q_validated', array('q_validated')); $GLOBALS['SITE_DB']->create_table('quiz_questions', array('id' => '*AUTO', 'q_long_input_field' => 'BINARY', 'q_num_choosable_answers' => 'INTEGER', 'q_quiz' => 'AUTO_LINK', 'q_question_text' => 'LONG_TRANS', 'q_order' => 'INTEGER', 'q_required' => 'BINARY')); $GLOBALS['SITE_DB']->create_table('quiz_question_answers', array('id' => '*AUTO', 'q_question' => 'AUTO_LINK', 'q_answer_text' => 'SHORT_TRANS', 'q_is_correct' => 'BINARY', 'q_order' => 'INTEGER', 'q_explanation' => 'LONG_TRANS')); $GLOBALS['SITE_DB']->create_table('quiz_winner', array('q_quiz' => '*AUTO_LINK', 'q_entry' => '*AUTO_LINK', 'q_winner_level' => 'INTEGER')); $GLOBALS['SITE_DB']->create_table('quiz_entries', array('id' => '*AUTO', 'q_time' => 'TIME', 'q_member' => 'USER', 'q_quiz' => 'AUTO_LINK', 'q_results' => 'INTEGER')); $GLOBALS['SITE_DB']->create_table('quiz_entry_answer', array('id' => '*AUTO', 'q_entry' => 'AUTO_LINK', 'q_question' => 'AUTO_LINK', 'q_answer' => 'LONG_TEXT')); $GLOBALS['SITE_DB']->create_index('quizzes', 'ftjoin_qstarttext', array('q_start_text')); } }
/** * 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_code('menus'); require_all_lang(); /* Our idealised choice of installed links is built for minimalism by assuming we also have: zone menu tailored menus in non-site/welcome zones NO panel_top (if there is that's fine, it's just a supplementary source of navigation) footer menu donate/hosting/advertise linked to by banners side_personal_stats/side_search/main_newsletter_signup/main_leaderboard/main_poll/main_iotd/main_news/side_news_categories/side_calendar blocks implicit links to authors/awards/member-actions/onlinemembers (not all links defined here, various modules also install them) */ // root_website add_menu_item_simple('root_website', NULL, 'FRONT_PAGE', ':'); add_menu_item_simple('root_website', NULL, 'RULES', '_SEARCH:rules'); //add_menu_item_simple('root_website',NULL,'FEEDBACK','_SEARCH:feedback'); if (!in_array(get_forum_type(), array('ocf', 'none'))) { add_menu_item_simple('root_website', NULL, 'SECTION_FORUMS', get_forum_base_url(true)); } // main_features add_menu_item_simple('main_features', NULL, 'FRONT_PAGE', 'site:'); add_menu_item_simple('main_features', NULL, 'GUIDE', '_SEARCH:help'); add_menu_item_simple('main_features', NULL, 'RULES', '_SEARCH:rules'); // main_content // main_community if (!in_array(get_forum_type(), array('ocf', 'none'))) { add_menu_item_simple('main_community', NULL, 'SECTION_FORUMS', get_forum_base_url(true)); } if (get_forum_type() == 'ocf') { add_menu_item_simple('main_community', NULL, 'MEMBERS', '_SEARCH:members:type=misc'); } if (get_forum_type() == 'ocf') { add_menu_item_simple('main_community', NULL, 'USERGROUPS', '_SEARCH:groups:type=misc'); } // member_features add_menu_item_simple('member_features', NULL, '_JOIN', '_SEARCH:join:type=misc', 0, 1); add_menu_item_simple('member_features', NULL, 'RESET_PASSWORD', '_SEARCH:lostpassword:type=misc'); // collab_website add_menu_item_simple('collab_website', NULL, 'FRONT_PAGE', 'collaboration:'); add_menu_item_simple('collab_website', NULL, 'ABOUT', 'collaboration:about'); // forum_features add_menu_item_simple('forum_features', NULL, 'RULES', '_SEARCH:rules'); add_menu_item_simple('forum_features', NULL, 'MEMBERS', '_SEARCH:members:type=misc'); // Zones add_menu_item_simple('zone_menu', NULL, 'SITE', 'site' . ':', 0, 1); if (get_forum_type() == 'ocf') { add_menu_item_simple('zone_menu', NULL, 'SECTION_FORUMS', 'forum' . ':', 0, 1); } else { add_menu_item_simple('zone_menu', NULL, 'SECTION_FORUMS', get_forum_base_url(), 0, 1); } if (file_exists(get_file_base() . '/collaboration')) { add_menu_item_simple('zone_menu', NULL, 'COLLABORATION', 'collaboration' . ':', 0, 1); } add_menu_item_simple('zone_menu', NULL, 'CMS', 'cms' . ':', 0, 1); add_menu_item_simple('zone_menu', NULL, 'ADMIN_ZONE', 'adminzone' . ':', 0, 1); //add_menu_item_simple('zone_menu',NULL,'GUIDES','docs'.':userguide',0,1); }
/** * 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_zones($db, $table_prefix, $file_base) { $rows = $db->query('SELECT * FROM ' . $table_prefix . 'zones'); foreach ($rows as $row) { $test = $GLOBALS['SITE_DB']->query_value_null_ok('zones', 'zone_name', array('zone_name' => $row['zone_name'])); if (is_null($test) && $test != 'seedy' && $test != 'supermembercentre' && $test != 'admincentre' && $test != 'membersonly' && $test != 'personalcentre' && $test != 'membercentre') { if (!array_key_exists('zone_displayed_in_menu', $row)) { $row['zone_displayed_in_menu'] = 1; } $old_title = $this->get_lang_string($db, $row['zone_title']); $row['zone_title'] = array_key_exists('zone_title', $row) ? insert_lang($old_title, 1) : insert_lang($row['zone_name'], 1); $row['zone_header_text'] = insert_lang($this->get_lang_string($db, $row['zone_header_text']), 1); unset($row['access_denied_counter']); // Just to support old-version compatibility a little $GLOBALS['SITE_DB']->query_insert('zones', $row); require_code('menus2'); add_menu_item_simple('zone_menu', NULL, $old_title, $row['zone_name'] . ':' . $row['zone_default_page'], 0, 1); } } }
/** * 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_reviews($db, $table_prefix, $old_base_dir) { require_code('menus2'); //check is the comment forum configured in ocPortal $this->test_for_comments_forum(); //include calatogue lib require_code('catalogues2'); // Can we comment the news? $com = 1; //get comments forum name $forum_name = get_option('comments_forum_name'); ocf_over_msn(); //used to fixed the correct forum prefix $forum_id = $GLOBALS['FORUM_DRIVER']->forum_id_from_name($forum_name); ocf_over_local(); //used to fixed the correct forum prefix //get specific reviews fields $catalogues = $db->query('SELECT * FROM ' . $table_prefix . 'reviews_sections'); $include_reviews_link = false; //include reviews link only once //go through all of the reviews sections foreach ($catalogues as $catalogue) { //make catalogue lang string $catalogue_name = strtoupper(preg_replace('#^[\\_\\.\\-]#', 'x', preg_replace('#[^\\w\\.\\-]#', '_', 'review_' . $catalogue['title']))); $catalogue['title'] = @html_entity_decode($catalogue['title'], ENT_QUOTES, get_charset()); $specific_fields = array(); // Add reviews catalogue if it doesn't already exist $current_review_catalogue = $GLOBALS['SITE_DB']->query_value_null_ok('catalogues', 'c_name', array('c_name' => strtolower($catalogue_name))); if (is_null($current_review_catalogue)) { $current_review_catalogue = actual_add_catalogue(strtolower($catalogue_name), $catalogue['title'], '', 0, 0, '', 30); $fields = array(array(do_lang('REVIEW_TITLE'), '', 'short_trans', 0, 1), array(do_lang('REVIEW_DESCRIPTION'), '', 'long_trans', 1, 1), array(do_lang('REVIEW_IMAGE'), '', 'picture', 0, 1), array(do_lang('REVIEW_REVIEW'), '', 'long_trans', 0, 1)); $specific_fields = array(); //add review/catalogue specific fields for ($i = 1; $i < 7; $i++) { if (strlen($catalogue['field' . strval($i)]) > 0) { //make lang string $lang_string = strtoupper(preg_replace('#^[\\_\\.\\-]#', 'x', preg_replace('#[^\\w\\.\\-]#', '_', $catalogue['field' . strval($i)]))); $lang_string = do_lang($lang_string, NULL, NULL, NULL, NULL, false); if (is_null($lang_string)) { $lang_string = $catalogue['field' . strval($i)]; } $fields[] = array($lang_string, '', 'long_trans', 0, 1); $specific_fields[] = $i; } } //add fields to catalogue foreach ($fields as $i => $field) { actual_add_catalogue_field(strtolower($catalogue_name), $field[0], '', $field[2], $i, $field[3], 1, 1, '', $field[4]); } } //import current reviews category $review_category_id = actual_add_catalogue_category(strtolower($catalogue_name), $catalogue['title'], '', '', NULL, ''); //include reviews link in main features menu if (!$include_reviews_link) { add_menu_item_simple('main_features', NULL, 'REVIEWS', 'site:catalogues:category:' . strval($review_category_id)); add_menu_item_simple('main_features', NULL, 'REVIEWS', 'site:catalogues:index:' . strtolower($catalogue_name)); $include_reviews_link = true; } $remappped_fields = collapse_1d_complexity('id', $GLOBALS['SITE_DB']->query_select('catalogue_fields', array('id'), array('c_name' => strtolower($catalogue_name)))); //select all reviews for current review catalogue $rows = $db->query('SELECT r.id AS review_id, r.title AS review_title, r.description AS review_description, r.field1 AS rf1, r.field2 AS rf2, r.field3 AS rf3, r.field4 AS rf4, r.field5 AS rf5, r.field6 AS rf6, r.field7 AS rf7, r.*, rc.title AS rc_title, rc.description AS rc_description, rc.field1 AS rcf1, rc.field2 AS rcf2, rc.field3 AS rcf3, rc.field4 AS rcf4, rc.field5 AS rcf5, rc.field6 AS rcf6, rc.field7 AS rcf7, rc.* FROM ' . $table_prefix . 'reviews r LEFT JOIN ' . $table_prefix . 'reviews_sections rc ON r.id_cat=rc.id WHERE r.id_cat=' . strval($catalogue['id'])); foreach ($rows as $row) { ocf_over_msn(); //used to fixed the correct forum prefix $map = array($remappped_fields[0] => html_to_comcode($row['review_title']), $remappped_fields[1] => html_to_comcode($row['review_description']), $remappped_fields[2] => $row['image'], $remappped_fields[3] => html_to_comcode($row['review'])); $map_next_ind = count($map); foreach ($specific_fields as $field_num) { if (!isset($remappped_fields[$map_next_ind])) { break; } // Don't want to import non-used fields $map[$remappped_fields[$map_next_ind]] = html_to_comcode($row['rf' . strval($field_num + 1)]); $map_next_ind++; } $new_id = actual_add_catalogue_entry($review_category_id, $row['validate'], '', 0, 0, 0, $map, $row['date'], $GLOBALS['FORUM_DRIVER']->get_member_from_username($row['author']), NULL, $row['click']); ocf_over_local(); //used to fixed the correct forum prefix //import rating too $this->_import_ratings($db, 'catalogues', $row['id'], $new_id, $row['rate'], $table_prefix); // Comments $comments = $db->query('SELECT * FROM ' . $table_prefix . 'reviews_comments WHERE id=' . strval($row['review_id']) . ' ORDER BY data'); if (!is_null($forum_id)) { foreach ($comments as $comment) { $member = $comment['id_autore']; //$GLOBALS['FORUM_DRIVER']->get_member_from_username($comment['userid']); ocf_over_msn(); //used to fixed the correct forum prefix if (is_null($member)) { $member = $GLOBALS['FORUM_DRIVER']->get_guest_id(); } ocf_over_local(); //used to fixed the correct forum prefix $title = $row['review_title']; $post = $comment['testo']; $content_url = build_url(array('page' => 'catalogues', 'id' => $new_id, 'type' => 'view'), get_module_zone('catalogues')); ocf_over_msn(); //used to fixed the correct forum prefix $GLOBALS['FORUM_DRIVER']->make_post_forum_topic($forum_name, 'reviews_' . strval($new_id), $member, $title, html_to_comcode($post), $row['review_title'], do_lang('COMMENT'), $content_url->evaluate()); ocf_over_local(); //used to fixed the correct forum prefix } } } } }
/** * 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('chat'); if (is_null($upgrade_from)) { $GLOBALS['SITE_DB']->create_table('chat_rooms', array('id' => '*AUTO', 'room_name' => 'SHORT_TEXT', 'room_owner' => '?INTEGER', 'allow_list' => 'LONG_TEXT', 'allow_list_groups' => 'LONG_TEXT', 'disallow_list' => 'LONG_TEXT', 'disallow_list_groups' => 'LONG_TEXT', 'room_language' => 'LANGUAGE_NAME', 'c_welcome' => 'LONG_TRANS', 'is_im' => 'BINARY')); $GLOBALS['SITE_DB']->create_index('chat_rooms', 'room_name', array('room_name')); $GLOBALS['SITE_DB']->create_index('chat_rooms', 'is_im', array('is_im', 'room_name')); $GLOBALS['SITE_DB']->create_index('chat_rooms', 'first_public', array('is_im', 'id')); $GLOBALS['SITE_DB']->create_index('chat_rooms', 'allow_list', array('allow_list(30)')); // Create our default chat room. By default, this will be as the shoutbox $GLOBALS['SITE_DB']->query_insert('chat_rooms', array('is_im' => 0, 'allow_list_groups' => '', 'disallow_list_groups' => '', 'allow_list' => '', 'disallow_list' => '', 'room_name' => do_lang('DEFAULT_ROOM_GENERAL_CHAT'), 'room_language' => get_site_default_lang(), 'room_owner' => NULL, 'c_welcome' => insert_lang('', 2))); $GLOBALS['SITE_DB']->create_table('chat_messages', array('id' => '*AUTO', 'system_message' => 'BINARY', 'ip_address' => 'IP', 'room_id' => 'AUTO_LINK', 'user_id' => 'USER', 'date_and_time' => 'TIME', 'the_message' => 'LONG_TRANS', 'text_colour' => 'SHORT_TEXT', 'font_name' => 'SHORT_TEXT')); $GLOBALS['SITE_DB']->create_index('chat_messages', 'ordering', array('date_and_time')); $GLOBALS['SITE_DB']->create_index('chat_messages', 'room_id', array('room_id')); add_config_option('FLOOD_TIMELIMIT', 'chat_flood_timelimit', 'integer', 'return \'5\';', 'FEATURE', 'SECTION_CHAT'); $GLOBALS['FORUM_DRIVER']->install_create_custom_field('points_gained_chat', 20, 1, 0, 0, 0, '', 'integer'); require_lang('chat'); add_menu_item_simple('main_community', NULL, 'CHAT_LOBBY', '_SEARCH:chat:type=misc'); } if ($upgrade_from < 3 || is_null($upgrade_from)) { add_config_option('CHAT_OPTIONS_COLOUR_NAME', 'chat_default_post_colour', 'colour', 'return \'inherit\';', 'FEATURE', 'SECTION_CHAT'); // NB: compressed up due to 256 character limit add_config_option('CHAT_OPTIONS_TEXT_NAME', 'chat_default_post_font', 'list', 'return \'Verdana\';', 'FEATURE', 'SECTION_CHAT', 0, 'Arial|Courier|Georgia|Impact|Times| Trebuchet|Verdana|Tahoma|Geneva|Helvetica'); add_config_option('PRIVATE_ROOM_DELETION_TIME', 'chat_private_room_deletion_time', 'integer', 'return \'1440\';', 'FEATURE', 'SECTION_CHAT'); } if (!is_null($upgrade_from) && $upgrade_from < 4) { $GLOBALS['SITE_DB']->add_table_field('chat_rooms', 'allow_list_groups', 'LONG_TEXT'); $GLOBALS['SITE_DB']->add_table_field('chat_rooms', 'disallow_list', 'LONG_TEXT'); $GLOBALS['SITE_DB']->add_table_field('chat_rooms', 'disallow_list_groups', 'LONG_TEXT'); $GLOBALS['SITE_DB']->add_table_field('chat_rooms', 'c_welcome', 'LONG_TRANS'); $GLOBALS['SITE_DB']->add_table_field('chat_messages', 'ip_address', 'IP', '127.0.0.1'); $GLOBALS['SITE_DB']->query_update('chat_rooms', array('allow_list' => ''), array('allow_list' => NULL)); $GLOBALS['SITE_DB']->alter_table_field('chat_rooms', 'allow_list', 'LONG_TEXT'); } if (is_null($upgrade_from) || $upgrade_from < 5) { $usergroups = $GLOBALS['FORUM_DRIVER']->get_usergroup_list(false, true); foreach (array_keys($usergroups) as $id) { $GLOBALS['SITE_DB']->query_insert('group_page_access', array('page_name' => 'cms_chat', 'zone_name' => 'cms', 'group_id' => $id)); // Don't want to let anyone do chat room moderation just because we let them manage content } } if (is_null($upgrade_from) || $upgrade_from < 6) { add_specific_permission('SECTION_CHAT', 'create_private_room', true); add_specific_permission('SECTION_CHAT', 'start_im', true); add_config_option('USERNAME_CLICK_IM', 'username_click_im', 'tick', 'return \'0\';', 'FEATURE', 'SECTION_CHAT'); $GLOBALS['SITE_DB']->create_table('chat_blocking', array('member_blocker' => '*USER', 'member_blocked' => '*USER', 'date_and_time' => 'TIME')); $GLOBALS['SITE_DB']->create_table('chat_buddies', array('member_likes' => '*USER', 'member_liked' => '*USER', 'date_and_time' => 'TIME')); $GLOBALS['SITE_DB']->create_table('chat_events', array('id' => '*AUTO', 'e_type_code' => 'ID_TEXT', 'e_member_id' => 'USER', 'e_room_id' => '?AUTO_LINK', 'e_date_and_time' => 'TIME')); $GLOBALS['SITE_DB']->create_index('chat_events', 'event_ordering', array('e_date_and_time')); } if (!is_null($upgrade_from) && $upgrade_from < 6) { $GLOBALS['SITE_DB']->add_table_field('chat_rooms', 'is_im', 'BINARY'); } if (!is_null($upgrade_from) && $upgrade_from < 7) { $GLOBALS['SITE_DB']->query_delete('db_meta_indices', array('i_table' => 'chat_active', 'i_name' => 'member_active_select', 'i_fields' => 'member_id')); $GLOBALS['SITE_DB']->query('DROP INDEX member_active_select ON ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'chat_active'); } if (is_null($upgrade_from) || $upgrade_from < 8) { add_config_option('CHATTING', 'points_chat', 'integer', 'return addon_installed(\'points\')?\'1\':NULL;', 'POINTS', 'COUNT_POINTS_GIVEN'); add_config_option('COUNT_CHATTERS', 'chat_show_stats_count_users', 'tick', 'return addon_installed(\'stats_block\')?\'0\':NULL;', 'BLOCKS', 'STATISTICS'); add_config_option('ROOMS', 'chat_show_stats_count_rooms', 'tick', 'return addon_installed(\'stats_block\')?\'0\':NULL;', 'BLOCKS', 'STATISTICS'); add_config_option('COUNT_CHATPOSTS', 'chat_show_stats_count_messages', 'tick', 'return addon_installed(\'stats_block\')?\'0\':NULL;', 'BLOCKS', 'STATISTICS'); } if (!is_null($upgrade_from) && $upgrade_from < 9) { $GLOBALS['SITE_DB']->promote_text_field_to_comcode('chat_messages', 'the_message', 'id', 4, true); $GLOBALS['SITE_DB']->query_delete('chat_messages'); delete_config_option('is_on_chat'); $GLOBALS['SITE_DB']->add_table_field('chat_messages', 'system_message', 'BINARY'); } if (is_null($upgrade_from) || $upgrade_from < 10) { $GLOBALS['SITE_DB']->drop_if_exists('chat_active'); $GLOBALS['SITE_DB']->create_table('chat_active', array('id' => '*AUTO', 'member_id' => 'USER', 'room_id' => '?AUTO_LINK', 'date_and_time' => 'TIME')); $GLOBALS['SITE_DB']->create_index('chat_active', 'active_ordering', array('date_and_time')); $GLOBALS['SITE_DB']->create_index('chat_active', 'member_select', array('member_id')); $GLOBALS['SITE_DB']->create_index('chat_active', 'room_select', array('room_id')); $GLOBALS['SITE_DB']->create_table('chat_sound_effects', array('s_member' => '*USER', 's_effect_id' => '*ID_TEXT', 's_url' => 'URLPATH')); $rooms = $GLOBALS['SITE_DB']->query_select('chat_rooms', array('id')); foreach ($rooms as $room) { // Set access $admin_groups = $GLOBALS['FORUM_DRIVER']->get_super_admin_groups(); $groups = $GLOBALS['FORUM_DRIVER']->get_usergroup_list(false, true); 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' => 'chat', 'category_name' => strval($room['id']), 'group_id' => $group_id)); } } add_specific_permission('SECTION_CHAT', 'moderate_my_private_rooms', true); add_specific_permission('SECTION_CHAT', 'ban_chatters_from_rooms', false); // NB: edit_lowrange_content may be overridden for the chat module also, allowing editing messages in rooms add_config_option('SITEWIDE_IM', 'sitewide_im', 'tick', 'return \'0\';', 'FEATURE', 'SECTION_CHAT'); } if (is_null($upgrade_from) || $upgrade_from < 11) { add_config_option('GROUP_PRIVATE_CHATROOMS', 'group_private_chatrooms', 'tick', 'return is_null($old=get_value(\'no_group_private_chatrooms\'))?\'1\':invert_value($old);', 'FEATURE', 'SECTION_CHAT'); } }
/** * 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('ocf'); add_menu_item_simple('forum_features', NULL, 'ROOT_FORUM', '_SEARCH:forumview:type=misc'); add_menu_item_simple('forum_features', NULL, 'PERSONAL_TOPICS', '_SEARCH:forumview:type=pt'); add_menu_item_simple('forum_features', NULL, 'POSTS_SINCE_LAST_VISIT', '_SEARCH:vforums:type=misc'); add_menu_item_simple('forum_features', NULL, 'TOPICS_UNREAD', '_SEARCH:vforums:type=unread'); add_menu_item_simple('forum_features', NULL, 'RECENTLY_READ', '_SEARCH:vforums:type=recently_read'); }
/** * 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_code('galleries'); require_lang('galleries'); require_code('galleries2'); if (is_null($upgrade_from)) { $GLOBALS['SITE_DB']->create_table('galleries', array('name' => '*ID_TEXT', 'description' => 'LONG_TRANS', 'teaser' => 'SHORT_TRANS', 'fullname' => 'SHORT_TRANS', 'add_date' => 'TIME', 'rep_image' => 'URLPATH', 'parent_id' => 'ID_TEXT', 'watermark_top_left' => 'URLPATH', 'watermark_top_right' => 'URLPATH', 'watermark_bottom_left' => 'URLPATH', 'watermark_bottom_right' => 'URLPATH', 'accept_images' => 'BINARY', 'accept_videos' => 'BINARY', 'allow_rating' => 'BINARY', 'allow_comments' => 'SHORT_INTEGER', 'notes' => 'LONG_TEXT', 'is_member_synched' => 'BINARY', 'flow_mode_interface' => 'BINARY', 'gallery_views' => 'INTEGER', 'g_owner' => '?AUTO_LINK')); $GLOBALS['SITE_DB']->create_index('galleries', 'watermark_top_left', array('watermark_top_left')); $GLOBALS['SITE_DB']->create_index('galleries', 'watermark_top_right', array('watermark_top_right')); $GLOBALS['SITE_DB']->create_index('galleries', 'watermark_bottom_left', array('watermark_bottom_left')); $GLOBALS['SITE_DB']->create_index('galleries', 'watermark_bottom_right', array('watermark_bottom_right')); $GLOBALS['SITE_DB']->create_index('galleries', 'gadd_date', array('add_date')); $GLOBALS['SITE_DB']->create_index('galleries', 'parent_id', array('parent_id')); $GLOBALS['SITE_DB']->create_table('images', array('id' => '*AUTO', 'cat' => 'ID_TEXT', 'url' => 'URLPATH', 'thumb_url' => 'URLPATH', 'comments' => 'LONG_TRANS', 'allow_rating' => 'BINARY', 'allow_comments' => 'SHORT_INTEGER', 'allow_trackbacks' => 'BINARY', 'notes' => 'LONG_TEXT', 'submitter' => 'USER', 'validated' => 'BINARY', 'add_date' => 'TIME', 'edit_date' => '?TIME', 'image_views' => 'INTEGER', 'title' => 'SHORT_TRANS')); $GLOBALS['SITE_DB']->create_index('images', 'image_views', array('image_views')); $GLOBALS['SITE_DB']->create_index('images', 'category_list', array('cat')); $GLOBALS['SITE_DB']->create_index('images', 'i_validated', array('validated')); $GLOBALS['SITE_DB']->create_index('images', 'xis', array('submitter')); $GLOBALS['SITE_DB']->create_index('images', 'iadd_date', array('add_date')); add_config_option('ADD_IMAGE', 'points_ADD_IMAGE', 'integer', 'return addon_installed(\'points\')?\'100\':NULL;', 'POINTS', 'COUNT_POINTS_GIVEN'); add_config_option('ADD_VIDEO', 'points_ADD_VIDEO', 'integer', 'return addon_installed(\'points\')?\'100\':NULL;', 'POINTS', 'COUNT_POINTS_GIVEN'); require_lang('galleries'); add_menu_item_simple('main_content', NULL, 'GALLERIES', '_SEARCH:galleries:type=misc'); } if (!is_null($upgrade_from) && $upgrade_from < 3) { $GLOBALS['SITE_DB']->add_table_field('galleries', 'teaser', 'SHORT_TRANS', 2); $GLOBALS['SITE_DB']->add_table_field('galleries', 'rep_image', 'URLPATH'); $GLOBALS['SITE_DB']->add_table_field('galleries', 'parent_id', 'ID_TEXT', 'root'); $GLOBALS['SITE_DB']->add_table_field('galleries', 'accept_images', 'BINARY', 1); $GLOBALS['SITE_DB']->add_table_field('galleries', 'accept_videos', 'BINARY', 1); $GLOBALS['SITE_DB']->add_table_field('galleries', 'watermark_top_left', 'URLPATH'); $GLOBALS['SITE_DB']->add_table_field('galleries', 'watermark_top_right', 'URLPATH'); $GLOBALS['SITE_DB']->add_table_field('galleries', 'watermark_bottom_left', 'URLPATH'); $GLOBALS['SITE_DB']->add_table_field('galleries', 'watermark_bottom_right', 'URLPATH'); $GLOBALS['SITE_DB']->add_table_field('galleries', 'is_member_synched', 'BINARY'); $GLOBALS['SITE_DB']->add_table_field('galleries', 'flow_mode_interface', 'BINARY'); $GLOBALS['SITE_DB']->add_table_field('galleries', 'allow_rating', 'BINARY', 1); $GLOBALS['SITE_DB']->add_table_field('galleries', 'allow_comments', 'SHORT_INTEGER', 1); $GLOBALS['SITE_DB']->add_table_field('images', 'allow_trackbacks', 'BINARY', 1); } if (is_null($upgrade_from) || $upgrade_from < 3) { add_specific_permission('GALLERIES', 'may_download_gallery', false); $GLOBALS['SITE_DB']->create_table('videos', array('id' => '*AUTO', 'cat' => 'ID_TEXT', 'url' => 'URLPATH', 'thumb_url' => 'URLPATH', 'comments' => 'LONG_TRANS', 'allow_rating' => 'BINARY', 'allow_comments' => 'SHORT_INTEGER', 'allow_trackbacks' => 'BINARY', 'notes' => 'LONG_TEXT', 'submitter' => 'USER', 'validated' => 'BINARY', 'add_date' => 'TIME', 'edit_date' => '?TIME', 'video_views' => 'INTEGER', 'video_width' => 'INTEGER', 'video_height' => 'INTEGER', 'video_length' => 'INTEGER', 'title' => 'SHORT_TRANS')); $GLOBALS['SITE_DB']->create_index('videos', 'video_views', array('video_views')); $GLOBALS['SITE_DB']->create_index('videos', 'vs', array('submitter')); $GLOBALS['SITE_DB']->create_index('videos', 'v_validated', array('validated')); $GLOBALS['SITE_DB']->create_index('videos', 'category_list', array('cat')); $GLOBALS['SITE_DB']->create_index('videos', 'vadd_date', array('add_date')); add_config_option('DEFAULT_VIDEO_WIDTH', 'default_video_width', 'integer', 'return \'320\';', 'FEATURE', 'GALLERIES'); add_config_option('DEFAULT_VIDEO_HEIGHT', 'default_video_height', 'integer', 'return \'240\';', 'FEATURE', 'GALLERIES'); add_config_option('MAXIMUM_IMAGE_SIZE', 'maximum_image_size', 'integer', 'return \'1024\';', 'FEATURE', 'GALLERIES'); add_config_option('GALLERY_IMAGE_LIMIT_LOW', 'max_personal_gallery_images_low', 'integer', 'return \'5\';', 'FEATURE', 'GALLERIES'); add_config_option('GALLERY_IMAGE_LIMIT_HIGH', 'max_personal_gallery_images_high', 'integer', 'return \'10\';', 'FEATURE', 'GALLERIES'); add_config_option('GALLERY_VIDEO_LIMIT_LOW', 'max_personal_gallery_videos_low', 'integer', 'return \'2\';', 'FEATURE', 'GALLERIES'); add_config_option('GALLERY_VIDEO_LIMIT_HIGH', 'max_personal_gallery_videos_high', 'integer', 'return \'5\';', 'FEATURE', 'GALLERIES'); add_specific_permission('GALLERIES', 'high_personal_gallery_limit', false); add_specific_permission('GALLERIES', 'no_personal_gallery_limit', false); // Add root gallery add_gallery('root', do_lang('GALLERIES_HOME'), '', '', '', '', 1, 1, 0, 1); $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' => 'galleries', 'category_name' => 'root', 'group_id' => $group_id)); } } if (is_null($upgrade_from) || $upgrade_from < 4) { add_config_option('GALLERIES', 'galleries_show_stats_count_galleries', 'tick', 'return addon_installed(\'stats_block\')?\'0\':NULL;', 'BLOCKS', 'STATISTICS'); add_config_option('IMAGES', 'galleries_show_stats_count_images', 'tick', 'return addon_installed(\'stats_block\')?\'0\':NULL;', 'BLOCKS', 'STATISTICS'); add_config_option('VIDEOS', 'galleries_show_stats_count_videos', 'tick', 'return addon_installed(\'stats_block\')?\'0\':NULL;', 'BLOCKS', 'STATISTICS'); add_config_option('SHOW_EMPTY_GALLERIES', 'show_empty_galleries', 'tick', 'return \'1\';', 'FEATURE', 'GALLERIES'); add_config_option('GALLERY_NAME_ORDER', 'gallery_name_order', 'tick', 'return \'0\';', 'FEATURE', 'GALLERIES'); } if (is_null($upgrade_from) || $upgrade_from < 5) { add_config_option('GALLERY_SELECTORS', 'gallery_selectors', 'line', 'return is_null($old=get_value(\'gallery_selectors\'))?\'12,24,36,64,128\':$old;', 'FEATURE', 'GALLERIES'); add_config_option('REVERSE_THUMB_ORDER', 'reverse_thumb_order', 'tick', 'return is_null($old=get_value(\'reverse_thumb_order\'))?\'0\':$old;', 'FEATURE', 'GALLERIES'); add_config_option('SHOW_GALLERY_COUNTS', 'show_gallery_counts', 'tick', 'return is_null($old=get_value(\'show_gallery_counts\'))?((get_forum_type()==\'ocf\')?\'0\':NULL):$old;', 'FEATURE', 'GALLERIES'); } if (is_null($upgrade_from) || $upgrade_from < 6) { add_config_option('VIDEO_BITRATE', 'video_bitrate', 'integer', 'return \'1000\';', 'FEATURE', 'TRANSCODING'); add_config_option('AUDIO_BITRATE', 'audio_bitrate', 'integer', 'return \'192\';', 'FEATURE', 'TRANSCODING'); add_config_option('VIDEO_WIDTH_SETTING', 'video_width_setting', 'integer', 'return \'720\';', 'FEATURE', 'TRANSCODING'); add_config_option('VIDEO_HEIGHT_SETTING', 'video_height_setting', 'integer', 'return \'480\';', 'FEATURE', 'TRANSCODING'); $GLOBALS['SITE_DB']->create_index('videos', 'ftjoin_vcomments', array('comments')); $GLOBALS['SITE_DB']->create_index('images', 'ftjoin_icomments', array('comments')); $GLOBALS['SITE_DB']->create_index('galleries', 'ftjoin_gfullname', array('fullname')); $GLOBALS['SITE_DB']->create_index('galleries', 'ftjoin_gdescrip', array('description')); } if (is_null($upgrade_from) || $upgrade_from < 7) { $old_option = get_option('ffmpeg_path', true); if (is_null($old_option)) { $old_option = ''; } delete_config_option('ffmpeg_path'); add_config_option('TRANSCODING_ZENCODER_API_KEY', 'transcoding_zencoder_api_key', 'line', 'return \'\';', 'FEATURE', 'TRANSCODING'); add_config_option('TRANSCODING_ZENCODER_FTP_PATH', 'transcoding_zencoder_ftp_path', 'line', 'return \'\';', 'FEATURE', 'TRANSCODING'); add_config_option('TRANSCODING_SERVER', 'transcoding_server', 'line', 'return \'\';', 'FEATURE', 'TRANSCODING'); add_config_option('FFMPEG_PATH', 'ffmpeg_path', 'line', 'return \'' . addslashes($old_option) . '\';', 'FEATURE', 'TRANSCODING'); $GLOBALS['SITE_DB']->create_table('video_transcoding', array('t_id' => '*ID_TEXT', 't_error' => 'LONG_TEXT', 't_url' => 'URLPATH', 't_table' => 'ID_TEXT', 't_url_field' => 'ID_TEXT', 't_orig_filename_field' => 'ID_TEXT', 't_width_field' => 'ID_TEXT', 't_height_field' => 'ID_TEXT', 't_output_filename' => 'ID_TEXT')); } if (!is_null($upgrade_from) && $upgrade_from < 7) { $GLOBALS['SITE_DB']->add_table_field('videos', 'title', 'SHORT_TRANS'); $GLOBALS['SITE_DB']->add_table_field('images', 'title', 'SHORT_TRANS'); $GLOBALS['SITE_DB']->create_index('images', 'ftjoin_dtitle', array('title')); $GLOBALS['SITE_DB']->create_index('videos', 'ftjoin_dtitle', array('title')); $GLOBALS['SITE_DB']->add_table_field('galleries', 'gallery_views', 'INTEGER'); $GLOBALS['SITE_DB']->add_table_field('galleries', 'g_owner', '?USER'); } }
/** * 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); } } } }