Beispiel #1
0
 /**
  * Standard modular install function.
  *
  * @param  ?integer	What version we're upgrading from (NULL: new install)
  * @param  ?integer	What hack version we're upgrading from (NULL: new-install/not-upgrading-from-a-hacked-version)
  */
 function install($upgrade_from = NULL, $upgrade_from_hack = NULL)
 {
     if (is_null($upgrade_from) || $upgrade_from < 3) {
         add_specific_permission('OCWORLD', 'administer_ocworld');
     }
     if (!is_null($upgrade_from) && $upgrade_from < 3) {
         $GLOBALS['SITE_DB']->alter_table_field('w_attempts', 'datetime', 'TIME', 'a_datetime');
         $GLOBALS['SITE_DB']->alter_table_field('w_items', 'count', 'INTEGER', 'i_count');
         $GLOBALS['SITE_DB']->alter_table_field('w_messages', 'message', 'SHORT_TEXT', 'm_message');
         $GLOBALS['SITE_DB']->alter_table_field('w_messages', 'datetime', 'TIME', 'm_datetime');
         $GLOBALS['SITE_DB']->alter_table_field('w_portals', 'text', 'ID_TEXT', 'p_text');
         $GLOBALS['SITE_DB']->alter_table_field('w_rooms', 'text', 'LONG_TEXT', 'r_text');
         $GLOBALS['SITE_DB']->alter_table_field('w_realms', 'private', 'BINARY', 'r_private');
     }
     if (is_null($upgrade_from)) {
         $GLOBALS['SITE_DB']->create_table('w_attempts', array('id' => '*AUTO', 'a_datetime' => 'TIME', 'attempt' => 'SHORT_TEXT', 'x' => 'INTEGER', 'y' => 'INTEGER', 'realm' => 'INTEGER'));
         $GLOBALS['SITE_DB']->create_table('w_inventory', array('item_name' => '*SHORT_TEXT', 'item_count' => 'INTEGER', 'item_owner' => '*USER'));
         $GLOBALS['SITE_DB']->create_table('w_itemdef', array('name' => '*ID_TEXT', 'bribable' => 'BINARY', 'healthy' => 'BINARY', 'picture_url' => 'URLPATH', 'owner' => 'USER', 'replicateable' => 'BINARY', 'max_per_player' => 'INTEGER', 'description' => 'SHORT_TEXT'));
         $GLOBALS['SITE_DB']->create_table('w_items', array('name' => '*ID_TEXT', 'location_realm' => '*INTEGER', 'location_x' => '*INTEGER', 'location_y' => '*INTEGER', 'not_infinite' => 'BINARY', 'cost' => 'INTEGER', 'i_count' => 'INTEGER', 'copy_owner' => '*USER'));
         $GLOBALS['SITE_DB']->create_table('w_members', array('id' => '*INTEGER', 'location_realm' => 'INTEGER', 'location_x' => 'INTEGER', 'location_y' => 'INTEGER', 'banned' => 'BINARY', 'health' => 'INTEGER', 'trolled' => 'INTEGER', 'lastactive' => 'TIME'));
         $GLOBALS['SITE_DB']->create_table('w_messages', array('location_realm' => '*INTEGER', 'location_x' => '*INTEGER', 'location_y' => '*INTEGER', 'm_message' => '*SHORT_TEXT', 'originator_id' => '*USER', 'm_datetime' => '*TIME', 'destination' => 'USER'));
         $GLOBALS['SITE_DB']->create_table('w_portals', array('name' => 'ID_TEXT', 'p_text' => 'ID_TEXT', 'start_location_realm' => '*INTEGER', 'start_location_x' => '*INTEGER', 'start_location_y' => '*INTEGER', 'end_location_realm' => '*INTEGER', 'end_location_x' => 'INTEGER', 'end_location_y' => 'INTEGER', 'owner' => '?USER'));
         $GLOBALS['SITE_DB']->create_table('w_rooms', array('name' => 'ID_TEXT', 'location_realm' => '*INTEGER', 'location_x' => '*INTEGER', 'location_y' => '*INTEGER', 'r_text' => 'LONG_TEXT', 'password_question' => 'LONG_TEXT', 'password_answer' => 'SHORT_TEXT', 'password_fail_message' => 'SHORT_TEXT', 'required_item' => 'SHORT_TEXT', 'locked_up' => 'BINARY', 'locked_down' => 'BINARY', 'locked_right' => 'BINARY', 'locked_left' => 'BINARY', 'picture_url' => 'URLPATH', 'owner' => '?USER', 'allow_portal' => 'BINARY'));
         $GLOBALS['SITE_DB']->create_table('w_travelhistory', array('member_id' => '*USER', 'x' => '*INTEGER', 'y' => '*INTEGER', 'realm' => '*INTEGER'));
         $GLOBALS['SITE_DB']->create_table('w_realms', array('id' => '*INTEGER', 'name' => 'SHORT_TEXT', 'troll_name' => 'SHORT_TEXT', 'owner' => '?USER', 'r_private' => 'BINARY', 'q1' => 'LONG_TEXT', 'q2' => 'LONG_TEXT', 'q3' => 'LONG_TEXT', 'q4' => 'LONG_TEXT', 'q5' => 'LONG_TEXT', 'q6' => 'LONG_TEXT', 'q7' => 'LONG_TEXT', 'q8' => 'LONG_TEXT', 'q9' => 'LONG_TEXT', 'q10' => 'LONG_TEXT', 'q11' => 'LONG_TEXT', 'q12' => 'LONG_TEXT', 'q13' => 'LONG_TEXT', 'q14' => 'LONG_TEXT', 'q15' => 'LONG_TEXT', 'q16' => 'LONG_TEXT', 'q17' => 'LONG_TEXT', 'q18' => 'LONG_TEXT', 'q19' => 'LONG_TEXT', 'q20' => 'LONG_TEXT', 'q21' => 'LONG_TEXT', 'q22' => 'LONG_TEXT', 'q23' => 'LONG_TEXT', 'q24' => 'LONG_TEXT', 'q25' => 'LONG_TEXT', 'q26' => 'LONG_TEXT', 'q27' => 'LONG_TEXT', 'q28' => 'LONG_TEXT', 'q29' => 'LONG_TEXT', 'q30' => 'LONG_TEXT', 'a1' => 'SHORT_TEXT', 'a2' => 'SHORT_TEXT', 'a3' => 'SHORT_TEXT', 'a4' => 'SHORT_TEXT', 'a5' => 'SHORT_TEXT', 'a6' => 'SHORT_TEXT', 'a7' => 'SHORT_TEXT', 'a8' => 'SHORT_TEXT', 'a9' => 'SHORT_TEXT', 'a10' => 'SHORT_TEXT', 'a11' => 'SHORT_TEXT', 'a12' => 'SHORT_TEXT', 'a13' => 'SHORT_TEXT', 'a14' => 'SHORT_TEXT', 'a15' => 'SHORT_TEXT', 'a16' => 'SHORT_TEXT', 'a17' => 'SHORT_TEXT', 'a18' => 'SHORT_TEXT', 'a19' => 'SHORT_TEXT', 'a20' => 'SHORT_TEXT', 'a21' => 'SHORT_TEXT', 'a22' => 'SHORT_TEXT', 'a23' => 'SHORT_TEXT', 'a24' => 'SHORT_TEXT', 'a25' => 'SHORT_TEXT', 'a26' => 'SHORT_TEXT', 'a27' => 'SHORT_TEXT', 'a28' => 'SHORT_TEXT', 'a29' => 'SHORT_TEXT', 'a30' => 'SHORT_TEXT'), true);
         require_code('ocworld');
         $prices = get_ocworld_prices_default();
         foreach ($prices as $name => $price) {
             $GLOBALS['SITE_DB']->query_insert('prices', array('name' => $name, 'price' => $price));
         }
         require_code('ocworld_action');
         add_realm_wrap(NULL, do_lang('W_DEFAULT_REALM'), do_lang('W_DEFAULT_TROLL'), do_lang('W_DEFAULT_JAIL'), do_lang('W_DEFAULT_IN_JAIL'), '', do_lang('W_DEFAULT_JAIL_HOUSE'), do_lang('W_DEFAULT_IN_JAIL_HOUSE'), '', do_lang('W_DEFAULT_LOBBY'), do_lang('W_DEFAULT_LOBBY_TEXT'), '', array(), 0, false);
     }
 }
Beispiel #2
0
 /**
  * Standard modular install function.
  *
  * @param  ?integer	What version we're upgrading from (NULL: new install)
  * @param  ?integer	What hack version we're upgrading from (NULL: new-install/not-upgrading-from-a-hacked-version)
  */
 function install($upgrade_from = NULL, $upgrade_from_hack = NULL)
 {
     $GLOBALS['SITE_DB']->create_table('activities', array('id' => '*AUTO', 'a_member_id' => '*USER', 'a_also_involving' => '?USER', 'a_language_string_code' => '*ID_TEXT', 'a_label_1' => 'SHORT_TEXT', 'a_label_2' => 'SHORT_TEXT', 'a_label_3' => 'SHORT_TEXT', 'a_pagelink_1' => 'SHORT_TEXT', 'a_pagelink_2' => 'SHORT_TEXT', 'a_pagelink_3' => 'SHORT_TEXT', 'a_time' => 'TIME', 'a_addon' => 'ID_TEXT', 'a_is_public' => 'BINARY'));
     $GLOBALS['SITE_DB']->create_index('activities', 'a_member_id', array('a_member_id'));
     $GLOBALS['SITE_DB']->create_index('activities', 'a_time', array('a_time'));
     $GLOBALS['SITE_DB']->create_index('activities', 'a_filtered_ordered', array('a_member_id', 'a_time'));
     require_code('activities_submission');
     log_newest_activity(0, 1000, true);
     add_specific_permission('SUBMISSION', 'syndicate_site_activity', false);
 }
Beispiel #3
0
 /**
  * Standard modular install function.
  *
  * @param  ?integer	What version we're upgrading from (NULL: new install)
  * @param  ?integer	What hack version we're upgrading from (NULL: new-install/not-upgrading-from-a-hacked-version)
  */
 function install($upgrade_from = NULL, $upgrade_from_hack = NULL)
 {
     $GLOBALS['SITE_DB']->create_table('test_sections', array('id' => '*AUTO', 's_section' => 'SHORT_TEXT', 's_notes' => 'LONG_TEXT', 's_inheritable' => 'BINARY', 's_assigned_to' => '?USER'));
     $GLOBALS['SITE_DB']->create_table('tests', array('id' => '*AUTO', 't_section' => 'AUTO_LINK', 't_test' => 'LONG_TEXT', 't_assigned_to' => '?USER', 't_enabled' => 'BINARY', 't_status' => 'INTEGER', 't_inherit_section' => '?AUTO_LINK'));
     add_specific_permission('TESTER', 'perform_tests', false);
     add_specific_permission('TESTER', 'add_tests', true);
     add_specific_permission('TESTER', 'edit_own_tests', true);
     add_config_option('TESTER_FORUM_NAME', 'tester_forum_name', 'forum', 'return do_lang(\'DEFAULT_TESTER_FORUM\');', 'FEATURE', 'TESTER');
     add_config_option('BUG_REPORT_TEXT', 'bug_report_text', 'text', 'return do_lang(\'DEFAULT_BUG_REPORT_TEMPLATE\');', 'FEATURE', 'TESTER');
 }
Beispiel #4
0
 /**
  * Standard modular install function.
  *
  * @param  ?integer	What version we're upgrading from (NULL: new install)
  * @param  ?integer	What hack version we're upgrading from (NULL: new-install/not-upgrading-from-a-hacked-version)
  */
 function install($upgrade_from = NULL, $upgrade_from_hack = NULL)
 {
     if (is_null($upgrade_from)) {
         $GLOBALS['SITE_DB']->create_table('poll', array('id' => '*AUTO', 'question' => 'SHORT_TRANS', 'option1' => 'SHORT_TRANS', 'option2' => 'SHORT_TRANS', 'option3' => '?SHORT_TRANS', 'option4' => '?SHORT_TRANS', 'option5' => '?SHORT_TRANS', 'option6' => '?SHORT_TRANS', 'option7' => '?SHORT_TRANS', 'option8' => '?SHORT_TRANS', 'option9' => '?SHORT_TRANS', 'option10' => '?SHORT_TRANS', 'votes1' => 'INTEGER', 'votes2' => 'INTEGER', 'votes3' => 'INTEGER', 'votes4' => 'INTEGER', 'votes5' => 'INTEGER', 'votes6' => 'INTEGER', 'votes7' => 'INTEGER', 'votes8' => 'INTEGER', 'votes9' => 'INTEGER', 'votes10' => 'INTEGER', 'allow_rating' => 'BINARY', 'allow_comments' => 'SHORT_INTEGER', 'allow_trackbacks' => 'BINARY', 'notes' => 'LONG_TEXT', 'num_options' => 'SHORT_INTEGER', 'is_current' => 'BINARY', 'date_and_time' => '?TIME', 'submitter' => 'USER', 'add_time' => 'INTEGER', 'poll_views' => 'INTEGER', 'edit_date' => '?TIME'));
         $GLOBALS['SITE_DB']->create_index('poll', 'poll_views', array('poll_views'));
         $GLOBALS['SITE_DB']->create_index('poll', 'get_current', array('is_current'));
         $GLOBALS['SITE_DB']->create_index('poll', 'ps', array('submitter'));
         $GLOBALS['SITE_DB']->create_index('poll', 'padd_time', array('add_time'));
         $GLOBALS['SITE_DB']->create_index('poll', 'date_and_time', array('date_and_time'));
         add_specific_permission('POLLS', 'choose_poll', false);
         add_config_option('ADD_POLL', 'points_ADD_POLL', 'integer', 'return addon_installed(\'points\')?\'150\':NULL;', 'POINTS', 'COUNT_POINTS_GIVEN');
         add_config_option('CHOOSE_POLL', 'points_CHOOSE_POLL', 'integer', 'return addon_installed(\'points\')?\'35\':NULL;', 'POINTS', 'COUNT_POINTS_GIVEN');
         add_config_option('POLL_REGULARITY', 'poll_update_time', 'integer', 'return \'168\';', 'ADMIN', 'CHECK_LIST');
         $GLOBALS['SITE_DB']->create_index('poll', 'ftjoin_pq', array('question'));
         $GLOBALS['SITE_DB']->create_index('poll', 'ftjoin_po1', array('option1'));
         $GLOBALS['SITE_DB']->create_index('poll', 'ftjoin_po2', array('option2'));
         $GLOBALS['SITE_DB']->create_index('poll', 'ftjoin_po3', array('option3'));
         $GLOBALS['SITE_DB']->create_index('poll', 'ftjoin_po4', array('option4'));
         $GLOBALS['SITE_DB']->create_index('poll', 'ftjoin_po5', array('option5'));
     }
     if (!is_null($upgrade_from) && $upgrade_from < 3) {
         $GLOBALS['SITE_DB']->add_table_field('poll', 'allow_trackbacks', 'BINARY', 1);
     }
     if (!is_null($upgrade_from) && $upgrade_from < 4) {
         $GLOBALS['SITE_DB']->add_table_field('poll', 'option6', 'SHORT_TRANS');
         $GLOBALS['SITE_DB']->add_table_field('poll', 'option7', 'SHORT_TRANS');
         $GLOBALS['SITE_DB']->add_table_field('poll', 'option8', 'SHORT_TRANS');
         $GLOBALS['SITE_DB']->add_table_field('poll', 'option9', 'SHORT_TRANS');
         $GLOBALS['SITE_DB']->add_table_field('poll', 'option10', 'SHORT_TRANS');
         $GLOBALS['SITE_DB']->add_table_field('poll', 'votes6', 'INTEGER', 0);
         $GLOBALS['SITE_DB']->add_table_field('poll', 'votes7', 'INTEGER', 0);
         $GLOBALS['SITE_DB']->add_table_field('poll', 'votes8', 'INTEGER', 0);
         $GLOBALS['SITE_DB']->add_table_field('poll', 'votes9', 'INTEGER', 0);
         $GLOBALS['SITE_DB']->add_table_field('poll', 'votes10', 'INTEGER', 0);
     }
     if (is_null($upgrade_from) || $upgrade_from < 5) {
         $GLOBALS['SITE_DB']->create_table('poll_votes', array('id' => '*AUTO', 'v_poll_id' => 'AUTO_LINK', 'v_voter_id' => '?USER', 'v_voter_ip' => 'IP', 'v_vote_for' => '?SHORT_INTEGER'));
         $GLOBALS['SITE_DB']->create_index('poll_votes', 'v_voter_id', array('v_voter_id'));
         $GLOBALS['SITE_DB']->create_index('poll_votes', 'v_voter_ip', array('v_voter_ip'));
         $GLOBALS['SITE_DB']->create_index('poll_votes', 'v_vote_for', array('v_vote_for'));
     }
     if (!is_null($upgrade_from) && $upgrade_from < 5) {
         $polls = $GLOBALS['SITE_DB']->query_select('poll', array('id', 'ip'));
         foreach ($polls as $poll) {
             $voters = explode('-', $poll['ip']);
             foreach ($voters as $voter) {
                 $GLOBALS['SITE_DB']->query_insert('poll_votes', array('v_poll_id' => $poll['id'], 'v_voter_id' => is_numeric($voter) ? intval($voter) : NULL, 'v_voter_ip' => is_numeric($voter) ? '' : $voter, 'v_vote_for' => NULL));
             }
         }
         $GLOBALS['SITE_DB']->delete_table_field('poll', 'ip');
     }
 }
Beispiel #5
0
 /**
  * Standard modular install function.
  *
  * @param  ?integer	What version we're upgrading from (NULL: new install)
  * @param  ?integer	What hack version we're upgrading from (NULL: new-install/not-upgrading-from-a-hacked-version)
  */
 function install($upgrade_from = NULL, $upgrade_from_hack = NULL)
 {
     if (!is_null($upgrade_from) && $upgrade_from < 3) {
         $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'));
     }
 }
Beispiel #6
0
 /**
  * Standard modular install function.
  *
  * @param  ?integer	What version we're upgrading from (NULL: new install)
  * @param  ?integer	What hack version we're upgrading from (NULL: new-install/not-upgrading-from-a-hacked-version)
  */
 function install($upgrade_from = NULL, $upgrade_from_hack = NULL)
 {
     if (is_null($upgrade_from)) {
         $GLOBALS['SITE_DB']->create_table('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));
     }
 }
Beispiel #7
0
 /**
  * Standard modular install function.
  *
  * @param  ?integer	What version we're upgrading from (NULL: new install)
  * @param  ?integer	What hack version we're upgrading from (NULL: new-install/not-upgrading-from-a-hacked-version)
  */
 function install($upgrade_from = NULL, $upgrade_from_hack = NULL)
 {
     if (is_null($upgrade_from)) {
         $GLOBALS['SITE_DB']->create_table('iotd', array('id' => '*AUTO', 'url' => 'URLPATH', 'i_title' => 'SHORT_TRANS', 'caption' => 'LONG_TRANS', 'thumb_url' => 'URLPATH', 'is_current' => 'BINARY', 'allow_rating' => 'BINARY', 'allow_comments' => 'SHORT_INTEGER', 'allow_trackbacks' => 'BINARY', 'notes' => 'LONG_TEXT', 'used' => 'BINARY', 'date_and_time' => '?TIME', 'iotd_views' => 'INTEGER', 'submitter' => 'USER', 'add_date' => 'TIME', 'edit_date' => '?TIME'));
         $GLOBALS['SITE_DB']->create_index('iotd', 'iotd_views', array('iotd_views'));
         $GLOBALS['SITE_DB']->create_index('iotd', 'get_current', array('is_current'));
         $GLOBALS['SITE_DB']->create_index('iotd', 'ios', array('submitter'));
         $GLOBALS['SITE_DB']->create_index('iotd', 'iadd_date', array('add_date'));
         $GLOBALS['SITE_DB']->create_index('iotd', 'date_and_time', array('date_and_time'));
         add_specific_permission('IOTDS', 'choose_iotd', false);
         add_config_option('CHOOSE_IOTD', 'points_CHOOSE_IOTD', 'integer', 'return addon_installed(\'points\')?\'35\':NULL;', 'POINTS', 'COUNT_POINTS_GIVEN');
         add_config_option('ADD_IOTD', 'points_ADD_IOTD', 'integer', 'return addon_installed(\'points\')?\'150\':NULL;', 'POINTS', 'COUNT_POINTS_GIVEN');
         add_config_option('IOTD_REGULARITY', 'iotd_update_time', 'integer', 'return \'24\';', 'ADMIN', 'CHECK_LIST');
         $GLOBALS['SITE_DB']->create_index('iotd', 'ftjoin_icap', array('caption'));
     }
     if (!is_null($upgrade_from) && $upgrade_from < 3) {
         $GLOBALS['SITE_DB']->add_table_field('iotd', 'allow_trackbacks', 'BINARY', 1);
     }
     if (!is_null($upgrade_from) && $upgrade_from < 4) {
         $GLOBALS['SITE_DB']->add_table_field('iotd', 'i_title', 'SHORT_TRANS', '');
     }
 }
Beispiel #8
0
 /**
  * Standard modular install function.
  *
  * @param  ?integer	What version we're upgrading from (NULL: new install)
  * @param  ?integer	What hack version we're upgrading from (NULL: new-install/not-upgrading-from-a-hacked-version)
  */
 function install($upgrade_from = NULL, $upgrade_from_hack = NULL)
 {
     if (!is_null($upgrade_from) && $upgrade_from < 3) {
         $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'));
     }
 }
Beispiel #9
0
 /**
  * Standard modular install function.
  *
  * @param  ?integer	What version we're upgrading from (NULL: new install)
  * @param  ?integer	What hack version we're upgrading from (NULL: new-install/not-upgrading-from-a-hacked-version)
  */
 function install($upgrade_from = NULL, $upgrade_from_hack = NULL)
 {
     require_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');
     }
 }
Beispiel #10
0
 /**
  * Standard modular install function.
  *
  * @param  ?integer	What version we're upgrading from (NULL: new install)
  * @param  ?integer	What hack version we're upgrading from (NULL: new-install/not-upgrading-from-a-hacked-version)
  */
 function install($upgrade_from = NULL, $upgrade_from_hack = NULL)
 {
     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);
             }
         }
     }
 }
Beispiel #11
0
 /**
  * Standard modular install function.
  *
  * @param  ?integer	What version we're upgrading from (NULL: new install)
  * @param  ?integer	What hack version we're upgrading from (NULL: new-install/not-upgrading-from-a-hacked-version)
  */
 function install($upgrade_from = NULL, $upgrade_from_hack = NULL)
 {
     if (is_null($upgrade_from)) {
         $GLOBALS['SITE_DB']->create_table('newsletter', array('id' => '*AUTO', 'email' => 'SHORT_TEXT', 'join_time' => 'TIME', 'code_confirm' => 'INTEGER', 'the_password' => 'MD5', 'pass_salt' => 'ID_TEXT', 'language' => 'ID_TEXT', 'n_forename' => 'SHORT_TEXT', 'n_surname' => 'SHORT_TEXT'));
         $GLOBALS['SITE_DB']->create_index('newsletter', 'welcomemails', array('join_time'));
         $GLOBALS['SITE_DB']->create_index('newsletter', 'code_confirm', array('code_confirm'));
         $GLOBALS['SITE_DB']->create_table('newsletter_archive', array('id' => '*AUTO', 'date_and_time' => 'INTEGER', 'subject' => 'SHORT_TEXT', 'newsletter' => 'LONG_TEXT', 'language' => 'ID_TEXT', 'importance_level' => 'INTEGER'));
         add_config_option('PAGE_TEXT', 'newsletter_text', 'transtext', 'return \'\';', 'FEATURE', 'NEWSLETTER');
         add_config_option('TITLE', 'newsletter_title', 'line', 'return get_option(\'site_name\').\' \'.ocp_mb_strtolower(do_lang(\'NEWSLETTER\'));', 'FEATURE', 'NEWSLETTER');
         add_specific_permission('NEWSLETTER', 'change_newsletter_subscriptions', false);
         require_lang('newsletter');
         //add_menu_item_simple('main_website',NULL,'NEWSLETTER','_SEARCH:newsletter:type=misc');
     }
     if (!is_null($upgrade_from) && $upgrade_from < 3) {
         $GLOBALS['SITE_DB']->add_table_field('newsletter', 'pass_salt', 'ID_TEXT', '');
     }
     if (!is_null($upgrade_from) && $upgrade_from < 4) {
         $GLOBALS['SITE_DB']->add_table_field('newsletter', 'join_time', 'TIME');
     }
     if (!is_null($upgrade_from) && $upgrade_from < 5) {
         set_option('newsletter_text', '[html]' . get_option('newsletter_text') . '[/html]');
     }
     if (is_null($upgrade_from) || $upgrade_from < 6) {
         require_lang('newsletter');
         $GLOBALS['SITE_DB']->create_table('newsletters', array('id' => '*AUTO', 'title' => 'SHORT_TRANS', 'description' => 'LONG_TRANS'));
         $GLOBALS['SITE_DB']->query_insert('newsletters', array('title' => lang_code_to_default_content('GENERAL'), 'description' => lang_code_to_default_content('NEWSLETTER_GENERAL')));
         $GLOBALS['SITE_DB']->create_table('newsletter_subscribe', array('newsletter_id' => '*AUTO_LINK', 'the_level' => 'SHORT_INTEGER', 'email' => '*SHORT_TEXT'));
         $GLOBALS['SITE_DB']->create_index('newsletter_subscribe', 'peopletosendto', array('the_level'));
     }
     if (!is_null($upgrade_from) && $upgrade_from < 6) {
         $GLOBALS['SITE_DB']->alter_table_field('newsletter', 'email', 'SHORT_TEXT');
         $subscribes = $GLOBALS['SITE_DB']->query_select('newsletter', array('the_level', 'email'));
         foreach ($subscribes as $subscribe) {
             $subscribe['newsletter_id'] = db_get_first_id();
             $GLOBALS['SITE_DB']->query_insert('newsletter_subscribe', $subscribe);
         }
         $GLOBALS['SITE_DB']->delete_table_field('newsletter', 'the_level');
     }
     if (is_null($upgrade_from) || $upgrade_from < 7) {
         add_config_option('USE_INTEREST_LEVELS', 'interest_levels', 'tick', 'return \'0\';', 'FEATURE', 'NEWSLETTER');
     }
     if (!is_null($upgrade_from) && $upgrade_from < 7) {
         // THIS STUFF DONE BECAUSE WE NEED A NUMERIC ID FOR IMPORT/EXPORT OF NEWSLETTER SUBSCRIBERS
         /*$GLOBALS['SITE_DB']->add_table_field('newsletter','id','INTEGER'); // can't handle more than one row when it tries to become a key, as not sequential
         		$GLOBALS['SITE_DB']->change_primary_key('newsletter',array('id'));
         		$GLOBALS['SITE_DB']->alter_table_field('newsletter','id','AUTO');*/
         // Works with mySQL only, but it's okay because before v4 of ocPortal (which this upgrades to), there's only mySQL support
         $GLOBALS['SITE_DB']->query('ALTER TABLE ' . get_table_prefix() . 'newsletter DROP PRIMARY KEY');
         $GLOBALS['SITE_DB']->query('ALTER TABLE ' . get_table_prefix() . 'newsletter ADD id INT NOT NULL AUTO_INCREMENT PRIMARY KEY');
         $GLOBALS['SITE_DB']->query_insert('db_meta', array('m_table' => 'newsletter', 'm_name' => 'id', 'm_type' => 'AUTO*'));
         // Add some extra data...
         $GLOBALS['SITE_DB']->add_table_field('newsletter', 'n_forename', 'SHORT_TEXT');
         $GLOBALS['SITE_DB']->add_table_field('newsletter', 'n_surname', 'SHORT_TEXT');
     }
     if (is_null($upgrade_from) || $upgrade_from < 8) {
         $GLOBALS['SITE_DB']->create_table('newsletter_drip_send', array('id' => '*AUTO', 'd_inject_time' => 'TIME', 'd_subject' => 'SHORT_TEXT', 'd_message' => 'LONG_TEXT', 'd_html_only' => 'BINARY', 'd_to_email' => 'SHORT_TEXT', 'd_to_name' => 'SHORT_TEXT', 'd_from_email' => 'SHORT_TEXT', 'd_from_name' => 'SHORT_TEXT', 'd_priority' => 'SHORT_INTEGER', 'd_template' => 'ID_TEXT'));
         $GLOBALS['SITE_DB']->create_index('newsletter_drip_send', 'd_inject_time', array('d_inject_time'));
     }
     if (is_null($upgrade_from) || $upgrade_from < 9) {
         $GLOBALS['SITE_DB']->create_table('newsletter_periodic', array('id' => '*AUTO', 'np_message' => 'LONG_TEXT', 'np_subject' => 'LONG_TEXT', 'np_lang' => 'LANGUAGE_NAME', 'np_send_details' => 'LONG_TEXT', 'np_html_only' => 'BINARY', 'np_from_email' => 'SHORT_TEXT', 'np_from_name' => 'SHORT_TEXT', 'np_priority' => 'SHORT_INTEGER', 'np_csv_data' => 'LONG_TEXT', 'np_frequency' => 'SHORT_TEXT', 'np_day' => 'SHORT_INTEGER', 'np_in_full' => 'BINARY', 'np_template' => 'ID_TEXT', 'np_last_sent' => 'TIME'));
     }
     if (!is_null($upgrade_from) && $upgrade_from >= 8 && $upgrade_from < 9) {
         $GLOBALS['SITE_DB']->add_table_field('newsletter_drip_send', 'd_template', 'ID_TEXT');
     }
 }
Beispiel #12
0
 /**
  * Standard modular install function.
  *
  * @param  ?integer	What version we're upgrading from (NULL: new install)
  * @param  ?integer	What hack version we're upgrading from (NULL: new-install/not-upgrading-from-a-hacked-version)
  */
 function install($upgrade_from = NULL, $upgrade_from_hack = NULL)
 {
     // A lot of "peripheral architectural" tables are defined here. Central ones are defined in the installer -- as they need to be installed before any module.
     // This is always the first module to be installed.
     if ($upgrade_from < 3 && !is_null($upgrade_from)) {
         $GLOBALS['SITE_DB']->create_table('seo_meta', array('id' => '*AUTO', 'meta_for_type' => 'ID_TEXT', 'meta_for_id' => 'ID_TEXT', 'meta_keywords' => 'LONG_TRANS', 'meta_description' => 'LONG_TRANS'));
         $GLOBALS['SITE_DB']->create_index('seo_meta', 'alt_key', array('meta_for_type', 'meta_for_id'));
         $GLOBALS['SITE_DB']->create_index('seo_meta', 'ftjoin_keywords', array('meta_keywords'));
     }
     if ($upgrade_from < 4 && !is_null($upgrade_from)) {
         // The sessions table isn't defined in this module... this is a throwback from before upgrader.php was fully developed
         $GLOBALS['SITE_DB']->add_table_field('sessions', 'session_confirmed', 'BINARY', 0);
         $GLOBALS['SITE_DB']->add_table_field('sessions', 'cache_username', 'SHORT_TEXT');
         $GLOBALS['SITE_DB']->create_table('https_pages', array('https_page_name' => '*ID_TEXT'));
         $GLOBALS['SITE_DB']->create_table('attachments', array('id' => '*AUTO', 'a_member_id' => 'USER', 'a_file_size' => '?INTEGER', 'a_url' => 'URLPATH', 'a_description' => 'SHORT_TEXT', 'a_thumb_url' => 'SHORT_TEXT', 'a_original_filename' => 'SHORT_TEXT', 'a_num_downloads' => 'INTEGER', 'a_last_downloaded_time' => '?INTEGER', 'a_add_time' => 'INTEGER'));
         $GLOBALS['SITE_DB']->create_index('attachments', 'a_add_time', array('a_member_id', 'a_add_time'));
         $GLOBALS['SITE_DB']->create_table('attachment_refs', array('id' => '*AUTO', 'r_referer_type' => 'ID_TEXT', 'r_referer_id' => 'ID_TEXT', 'a_id' => 'INTEGER'));
     }
     if ($upgrade_from < 4 || is_null($upgrade_from)) {
         add_specific_permission('_COMCODE', 'reuse_others_attachments', true);
     }
     if ($upgrade_from < 5 || is_null($upgrade_from)) {
         $GLOBALS['SITE_DB']->create_table('menu_items', array('id' => '*AUTO', 'i_menu' => 'ID_TEXT', 'i_order' => 'INTEGER', 'i_parent' => '?AUTO_LINK', 'i_caption' => 'SHORT_TRANS', 'i_caption_long' => 'SHORT_TRANS', 'i_url' => 'SHORT_TEXT', 'i_check_permissions' => 'BINARY', 'i_expanded' => 'BINARY', 'i_new_window' => 'BINARY', 'i_page_only' => 'ID_TEXT', 'i_theme_img_code' => 'ID_TEXT'));
         $GLOBALS['SITE_DB']->create_index('menu_items', 'menu_extraction', array('i_menu'));
         $GLOBALS['SITE_DB']->create_table('trackbacks', array('id' => '*AUTO', 'trackback_for_type' => 'ID_TEXT', 'trackback_for_id' => 'ID_TEXT', 'trackback_ip' => 'IP', 'trackback_time' => 'TIME', 'trackback_url' => 'SHORT_TEXT', 'trackback_title' => 'SHORT_TEXT', 'trackback_excerpt' => 'LONG_TEXT', 'trackback_name' => 'SHORT_TEXT'));
         $GLOBALS['SITE_DB']->create_index('trackbacks', 'trackback_for_type', array('trackback_for_type'));
         $GLOBALS['SITE_DB']->create_index('trackbacks', 'trackback_for_id', array('trackback_for_id'));
         $GLOBALS['SITE_DB']->create_index('trackbacks', 'trackback_time', array('trackback_time'));
         $GLOBALS['SITE_DB']->create_table('security_images', array('si_session_id' => '*INTEGER', 'si_time' => 'TIME', 'si_code' => 'INTEGER'));
         $GLOBALS['SITE_DB']->create_index('security_images', 'si_time', array('si_time'));
         $GLOBALS['SITE_DB']->create_table('member_tracking', array('mt_member_id' => '*USER', 'mt_cache_username' => 'ID_TEXT', 'mt_time' => '*TIME', 'mt_page' => '*ID_TEXT', 'mt_type' => '*ID_TEXT', 'mt_id' => '*ID_TEXT'));
         $GLOBALS['SITE_DB']->create_index('member_tracking', 'mt_page', array('mt_page'));
         $GLOBALS['SITE_DB']->create_index('member_tracking', 'mt_id', array('mt_page', 'mt_id', 'mt_type'));
         $GLOBALS['SITE_DB']->create_table('cache_on', array('cached_for' => '*ID_TEXT', 'cache_on' => 'LONG_TEXT', 'cache_ttl' => 'INTEGER'));
     }
     if ($upgrade_from < 6 && !is_null($upgrade_from)) {
         $GLOBALS['SITE_DB']->add_table_field('config', 'shared_hosting_restricted', 'BINARY', 0);
         $GLOBALS['SITE_DB']->add_table_field('zones', 'zone_title', 'SHORT_TRANS', '');
         $rows = $GLOBALS['SITE_DB']->query_select('zones', array('zone_name', 'zone_title'));
         foreach ($rows as $row) {
             $zone = $row['zone_name'];
             $st = $row['zone_title'];
             $_zone = ucfirst($zone);
             switch ($zone) {
                 case 'docs':
                     $_zone = do_lang('GUIDES');
                     break;
                 case 'forum':
                     $_zone = do_lang('SECTION_FORUMS');
                     break;
                 case '':
                     $_zone = do_lang('_WELCOME');
                     break;
                 case 'site':
                     $_zone = do_lang('SITE');
                     break;
                 case 'cms':
                     $_zone = do_lang('CMS');
                     break;
                 case 'collaboration':
                     $_zone = do_lang('collaboration');
                     break;
                 case 'adminzone':
                     $_zone = do_lang('ADMIN_ZONE');
                     break;
             }
             $_lang2 = do_lang('ZONE_' . $zone, NULL, NULL, NULL, NULL, false);
             if (!is_null($_lang2)) {
                 $_zone = $_lang2;
             }
             lang_remap($st, $_zone);
         }
     }
     if ($upgrade_from < 7 && !is_null($upgrade_from)) {
         $GLOBALS['SITE_DB']->add_table_field('gsp', 'the_page', 'ID_TEXT');
         $GLOBALS['SITE_DB']->add_table_field('gsp', 'module_the_name', 'ID_TEXT');
         $GLOBALS['SITE_DB']->add_table_field('gsp', 'category_name', 'ID_TEXT');
         $GLOBALS['SITE_DB']->change_primary_key('gsp', array('group_id', 'specific_permission', 'the_page', 'module_the_name', 'category_name'));
         $GLOBALS['SITE_DB']->add_table_field('gsp', 'the_value', 'BINARY');
         $GLOBALS['SITE_DB']->query_update('gsp', array('the_value' => 1));
         $GLOBALS['SITE_DB']->add_table_field('sessions', 'session_invisible', 'BINARY');
         $GLOBALS['SITE_DB']->add_table_field('sessions', 'the_zone', 'ID_TEXT');
         $GLOBALS['SITE_DB']->add_table_field('sessions', 'the_page', 'ID_TEXT');
         $GLOBALS['SITE_DB']->add_table_field('sessions', 'the_type', 'ID_TEXT');
         $GLOBALS['SITE_DB']->add_table_field('sessions', 'the_id', 'ID_TEXT');
         $GLOBALS['SITE_DB']->add_table_field('sessions', 'the_title', 'SHORT_TEXT');
         $GLOBALS['SITE_DB']->add_table_field('menu_items', 'i_caption_long', 'SHORT_TRANS');
         $GLOBALS['SITE_DB']->add_table_field('attachments', 'a_description', 'SHORT_TEXT');
         $GLOBALS['SITE_DB']->alter_table_field('attachments', 'a_url', 'URLPATH');
         $GLOBALS['SITE_DB']->query('UPDATE ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'menu_items SET i_url=replace(i_url,\':type=gui\',\':type=misc\')');
         $GLOBALS['SITE_DB']->query('UPDATE ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'menu_items SET i_url=replace(i_url,\':type=choose\',\':type=misc\')');
         $GLOBALS['SITE_DB']->query_update('menu_items', array('i_url' => '_SEARCH:seedy_page:type=misc'), array('i_url' => '_SEARCH:seedy_page:type=page'), '', 1);
         $GLOBALS['SITE_DB']->query_update('menu_items', array('i_url' => '_SEARCH:staff:type=misc'), array('i_url' => '_SEARCH:staff:type=directory'), '', 1);
         $GLOBALS['SITE_DB']->query_update('menu_items', array('i_url' => '_SEARCH:points:type=misc'), array('i_url' => '_SEARCH:points:type=search'), '', 1);
         $GLOBALS['SITE_DB']->query_update('menu_items', array('i_url' => '_SEARCH:members:type=misc'), array('i_url' => '_SEARCH:members:type=directory'), '', 1);
         $GLOBALS['SITE_DB']->query_update('menu_items', array('i_url' => '_SEARCH:galleries:type=misc'), array('i_url' => '_SEARCH:galleries:type=list'), '', 1);
         $GLOBALS['SITE_DB']->query_update('menu_items', array('i_url' => '_SEARCH:downloads:type=misc'), array('i_url' => '_SEARCH:downloads:type=cat'), '', 1);
         $GLOBALS['SITE_DB']->query_update('menu_items', array('i_url' => '_SEARCH:catalogues:type=misc'), array('i_url' => '_SEARCH:catalogues:type=list'), '', 1);
         $GLOBALS['SITE_DB']->query_update('menu_items', array('i_url' => '_SEARCH:calendar:type=misc'), array('i_url' => '_SEARCH:calendar:type=calendar'), '', 1);
         $GLOBALS['SITE_DB']->query_update('menu_items', array('i_url' => '_SEARCH:news:type=misc'), array('i_url' => '_SEARCH:news:type=list'), '', 1);
     }
     if ($upgrade_from < 7 || is_null($upgrade_from)) {
         $GLOBALS['SITE_DB']->create_table('validated_once', array('hash' => '*MD5'));
         $GLOBALS['SITE_DB']->create_table('edit_pings', array('id' => '*AUTO', 'the_page' => 'ID_TEXT', 'the_type' => 'ID_TEXT', 'the_id' => 'ID_TEXT', 'the_time' => 'TIME', 'the_member' => 'USER'));
         $GLOBALS['SITE_DB']->create_table('translate_history', array('id' => '*AUTO', 'lang_id' => 'AUTO_LINK', 'language' => '*LANGUAGE_NAME', 'text_original' => 'LONG_TEXT', 'broken' => 'BINARY', 'action_member' => 'USER', 'action_time' => 'TIME'));
         $GLOBALS['SITE_DB']->create_table('long_values', array('the_name' => '*ID_TEXT', 'the_value' => 'LONG_TEXT', 'date_and_time' => 'TIME'));
         $GLOBALS['SITE_DB']->create_table('tutorial_links', array('the_name' => '*ID_TEXT', 'the_value' => 'LONG_TEXT'));
     }
     if ($upgrade_from < 9 && !is_null($upgrade_from)) {
         $GLOBALS['SITE_DB']->add_table_field('zones', 'zone_displayed_in_menu', 'BINARY', 1);
         $GLOBALS['SITE_DB']->add_table_field('config', 'c_set', 'BINARY', 1);
         $options = $GLOBALS['SITE_DB']->query_select('config', array('the_name'), array('config_value' => NULL));
         foreach ($options as $o) {
             $GLOBALS['SITE_DB']->query_update('config', array('config_value' => '', 'c_set' => 0), array('the_name' => $o['the_name']), '', 1);
         }
         $GLOBALS['SITE_DB']->add_table_field('config', 'c_data', 'SHORT_TEXT');
         $GLOBALS['SITE_DB']->add_table_field('menu_items', 'i_theme_img_code', 'ID_TEXT');
     }
     if ($upgrade_from < 8 || is_null($upgrade_from)) {
         $GLOBALS['SITE_DB']->create_table('msp', array('active_until' => '*TIME', 'member_id' => '*INTEGER', 'specific_permission' => '*ID_TEXT', 'the_page' => '*ID_TEXT', 'module_the_name' => '*ID_TEXT', 'category_name' => '*ID_TEXT', 'the_value' => 'BINARY'));
         $GLOBALS['SITE_DB']->create_index('msp', 'mspname', array('specific_permission', 'the_page', 'module_the_name', 'category_name'));
         $GLOBALS['SITE_DB']->create_index('msp', 'mspmember_id', array('member_id'));
         $GLOBALS['SITE_DB']->create_table('member_zone_access', array('active_until' => '*TIME', 'zone_name' => '*ID_TEXT', 'member_id' => '*USER'));
         $GLOBALS['SITE_DB']->create_index('member_zone_access', 'mzazone_name', array('zone_name'));
         $GLOBALS['SITE_DB']->create_index('member_zone_access', 'mzamember_id', array('member_id'));
         $GLOBALS['SITE_DB']->create_table('member_page_access', array('active_until' => '*TIME', 'page_name' => '*ID_TEXT', 'zone_name' => '*ID_TEXT', 'member_id' => '*USER'));
         $GLOBALS['SITE_DB']->create_index('member_page_access', 'mzaname', array('page_name', 'zone_name'));
         $GLOBALS['SITE_DB']->create_index('member_page_access', 'mzamember_id', array('member_id'));
         $GLOBALS['SITE_DB']->create_table('member_category_access', array('active_until' => '*TIME', 'module_the_name' => '*ID_TEXT', 'category_name' => '*ID_TEXT', 'member_id' => '*USER'));
         $GLOBALS['SITE_DB']->create_index('member_category_access', 'mcaname', array('module_the_name', 'category_name'));
         $GLOBALS['SITE_DB']->create_index('member_category_access', 'mcamember_id', array('member_id'));
     }
     if ($upgrade_from < 9 || is_null($upgrade_from)) {
         /*$GLOBALS['SITE_DB']->create_table('confirmed_mobiles',array(
         			'm_phone_number'=>'*SHORT_TEXT',
         			'm_member_id'=>'USER',
         			'm_time'=>'TIME',
         			'm_confirm_code'=>'IP'
         		));*/
         /*$GLOBALS['SITE_DB']->create_index('confirmed_mobiles','confirmed_numbers',array('m_confirm_code'));*/
         add_specific_permission('STAFF_ACTIONS', 'assume_any_member', false, true);
         $GLOBALS['SITE_DB']->create_table('autosave', array('id' => '*AUTO', 'a_member_id' => 'USER', 'a_key' => 'LONG_TEXT', 'a_value' => 'LONG_TEXT', 'a_time' => 'TIME'));
         $GLOBALS['SITE_DB']->create_index('autosave', 'myautosaves', array('a_member_id'));
         $GLOBALS['SITE_DB']->create_table('messages_to_render', array('id' => '*AUTO', 'r_session_id' => 'AUTO_LINK', 'r_message' => 'LONG_TEXT', 'r_type' => 'ID_TEXT', 'r_time' => 'TIME'));
         $GLOBALS['SITE_DB']->create_index('messages_to_render', 'forsession', array('r_session_id'));
         $GLOBALS['SITE_DB']->create_table('url_title_cache', array('id' => '*AUTO', 't_url' => 'URLPATH', 't_title' => 'SHORT_TEXT'));
     }
     if ($upgrade_from < 10 && !is_null($upgrade_from)) {
         $GLOBALS['SITE_DB']->query('UPDATE ' . get_table_prefix() . 'db_meta SET m_type=\'SHORT_INTEGER\' WHERE m_name LIKE \'' . db_encode_like('%allow\\_comments') . '\'');
     }
     if ($upgrade_from < 10 || is_null($upgrade_from)) {
         add_config_option('URL_MONIKERS_ENABLED', 'url_monikers_enabled', 'tick', 'return \'1\';', 'SITE', 'ADVANCED');
         $GLOBALS['SITE_DB']->create_table('url_id_monikers', array('id' => '*AUTO', 'm_resource_page' => 'ID_TEXT', 'm_resource_type' => 'ID_TEXT', 'm_resource_id' => 'ID_TEXT', 'm_moniker' => 'SHORT_TEXT', 'm_deprecated' => 'BINARY'));
         $GLOBALS['SITE_DB']->create_index('url_id_monikers', 'uim_pagelink', array('m_resource_page', 'm_resource_type', 'm_resource_id'));
         $GLOBALS['SITE_DB']->create_index('url_id_monikers', 'uim_moniker', array('m_moniker'));
         $GLOBALS['SITE_DB']->create_table('review_supplement', array('r_post_id' => '*AUTO_LINK', 'r_rating_type' => '*ID_TEXT', 'r_rating' => 'SHORT_INTEGER', 'r_topic_id' => 'AUTO_LINK', 'r_rating_for_id' => 'ID_TEXT', 'r_rating_for_type' => 'ID_TEXT'));
         $GLOBALS['SITE_DB']->create_index('review_supplement', 'rating_for_id', array('r_rating_for_id'));
         // TODO: Move these into sms addon_registry hook, once these hooks support installation
         $GLOBALS['SITE_DB']->create_table('sms_log', array('id' => '*AUTO', 's_member_id' => 'USER', 's_time' => 'TIME', 's_trigger_ip' => 'IP'));
         $GLOBALS['SITE_DB']->create_index('sms_log', 'sms_log_for', array('s_member_id', 's_time'));
         $GLOBALS['SITE_DB']->create_index('sms_log', 'sms_trigger_ip', array('s_trigger_ip'));
         require_lang('ocf');
         $GLOBALS['FORUM_DRIVER']->install_create_custom_field('mobile_phone_number', 20, 1, 0, 1, 0, do_lang('SPECIAL_CPF__ocp_mobile_phone_number_DESCRIPTION'), 'short_text');
         add_specific_permission('GENERAL_SETTINGS', 'use_sms', false);
         add_specific_permission('GENERAL_SETTINGS', 'sms_higher_limit', false);
         add_specific_permission('GENERAL_SETTINGS', 'sms_higher_trigger_limit', false);
         $GLOBALS['SITE_DB']->create_table('logged_mail_messages', array('id' => '*AUTO', 'm_subject' => 'LONG_TEXT', 'm_message' => 'LONG_TEXT', 'm_to_email' => 'LONG_TEXT', 'm_to_name' => 'LONG_TEXT', 'm_from_email' => 'SHORT_TEXT', 'm_from_name' => 'SHORT_TEXT', 'm_priority' => 'SHORT_INTEGER', 'm_attachments' => 'LONG_TEXT', 'm_no_cc' => 'BINARY', 'm_as' => 'USER', 'm_as_admin' => 'BINARY', 'm_in_html' => 'BINARY', 'm_date_and_time' => 'TIME', 'm_member_id' => 'USER', 'm_url' => 'LONG_TEXT', 'm_queued' => 'BINARY', 'm_template' => 'ID_TEXT'));
         $GLOBALS['SITE_DB']->create_index('logged_mail_messages', 'recentmessages', array('m_date_and_time'));
         $GLOBALS['SITE_DB']->create_index('logged_mail_messages', 'queued', array('m_queued'));
         $GLOBALS['SITE_DB']->create_table('link_tracker', array('id' => '*AUTO', 'c_date_and_time' => 'TIME', 'c_member_id' => 'USER', 'c_ip_address' => 'IP', 'c_url' => 'URLPATH'));
         $GLOBALS['SITE_DB']->create_index('url_title_cache', 't_url', array('t_url'));
         $GLOBALS['SITE_DB']->create_table('incoming_uploads', array('id' => '*AUTO', 'i_submitter' => 'USER', 'i_date_and_time' => 'TIME', 'i_orig_filename' => 'URLPATH', 'i_save_url' => 'URLPATH'));
     }
     if ($upgrade_from < 11 && !is_null($upgrade_from)) {
         $GLOBALS['SITE_DB']->query('UPDATE ' . get_table_prefix() . 'comcode_pages SET p_submitter=2 WHERE p_submitter=' . strval($GLOBALS['FORUM_DRIVER']->get_guest_id()));
     }
     if (is_null($upgrade_from) || $upgrade_from < 12) {
         $GLOBALS['SITE_DB']->drop_if_exists('cache');
         $GLOBALS['SITE_DB']->create_table('cache', array('cached_for' => '*ID_TEXT', 'identifier' => '*MINIID_TEXT', 'the_value' => 'LONG_TEXT', 'date_and_time' => 'TIME', 'the_theme' => '*ID_TEXT', 'lang' => '*LANGUAGE_NAME', 'langs_required' => 'LONG_TEXT'));
         $GLOBALS['SITE_DB']->create_index('cache', 'cached_ford', array('date_and_time'));
         $GLOBALS['SITE_DB']->create_index('cache', 'cached_fore', array('cached_for'));
         $GLOBALS['SITE_DB']->create_index('cache', 'cached_forf', array('lang'));
         $GLOBALS['SITE_DB']->create_index('cache', 'cached_forg', array('identifier'));
         $GLOBALS['SITE_DB']->create_index('cache', 'cached_forh', array('the_theme'));
     }
     if (is_null($upgrade_from) || $upgrade_from < 13) {
         if (!$GLOBALS['SITE_DB']->table_exists('f_group_member_timeouts')) {
             $GLOBALS['SITE_DB']->create_table('f_group_member_timeouts', array('member_id' => '*USER', 'group_id' => '*GROUP', 'timeout' => 'TIME'));
         }
     }
     if (!is_null($upgrade_from) && $upgrade_from < 13) {
         if (substr(get_db_type(), 0, 5) == 'mysql') {
             $GLOBALS['SITE_DB']->create_index('translate', 'equiv_lang', array('text_original(4)'));
             $GLOBALS['SITE_DB']->create_index('translate', 'decache', array('text_parsed(2)'));
         }
     }
     if (!is_null($upgrade_from) && $upgrade_from >= 10 && $upgrade_from < 14) {
         $GLOBALS['SITE_DB']->drop_if_exists('tracking');
         $GLOBALS['SITE_DB']->add_table_field('logged_mail_messages', 'm_template', 'ID_TEXT');
     }
     if (!is_null($upgrade_from) && $upgrade_from == 14) {
         $GLOBALS['SITE_DB']->alter_table_field('digestives_tin', 'd_from_member_id', '?USER');
     }
     if (is_null($upgrade_from) || $upgrade_from < 14) {
         $GLOBALS['SITE_DB']->create_table('temp_block_permissions', array('id' => '*AUTO', 'p_session_id' => 'AUTO_LINK', 'p_block_constraints' => 'LONG_TEXT', 'p_time' => 'TIME'));
         $GLOBALS['SITE_DB']->create_table('cron_caching_requests', array('id' => '*AUTO', 'c_codename' => 'ID_TEXT', 'c_map' => 'LONG_TEXT', 'c_timezone' => 'ID_TEXT', 'c_is_bot' => 'BINARY', 'c_in_panel' => 'BINARY', 'c_interlock' => 'BINARY', 'c_store_as_tempcode' => 'BINARY', 'c_lang' => 'LANGUAGE_NAME', 'c_theme' => 'ID_TEXT'));
         $GLOBALS['SITE_DB']->create_index('cron_caching_requests', 'c_compound', array('c_codename', 'c_theme', 'c_lang', 'c_timezone'));
         $GLOBALS['SITE_DB']->create_index('cron_caching_requests', 'c_is_bot', array('c_is_bot'));
         $GLOBALS['SITE_DB']->create_index('cron_caching_requests', 'c_in_panel', array('c_in_panel'));
         $GLOBALS['SITE_DB']->create_index('cron_caching_requests', 'c_interlock', array('c_interlock'));
         $GLOBALS['SITE_DB']->create_index('cron_caching_requests', 'c_store_as_tempcode', array('c_store_as_tempcode'));
         $GLOBALS['SITE_DB']->create_table('notifications_enabled', array('id' => '*AUTO', 'l_member_id' => 'USER', 'l_notification_code' => 'ID_TEXT', 'l_code_category' => 'SHORT_TEXT', 'l_setting' => 'INTEGER'));
         $GLOBALS['SITE_DB']->create_index('notifications_enabled', 'l_member_id', array('l_member_id', 'l_notification_code'));
         $GLOBALS['SITE_DB']->create_index('notifications_enabled', 'l_code_category', array('l_code_category'));
         $GLOBALS['SITE_DB']->create_table('digestives_tin', array('id' => '*AUTO', 'd_subject' => 'LONG_TEXT', 'd_message' => 'LONG_TEXT', 'd_from_member_id' => '?USER', 'd_to_member_id' => 'USER', 'd_priority' => 'SHORT_INTEGER', 'd_no_cc' => 'BINARY', 'd_date_and_time' => 'TIME', 'd_notification_code' => 'ID_TEXT', 'd_code_category' => 'SHORT_TEXT', 'd_frequency' => 'INTEGER'));
         $GLOBALS['SITE_DB']->create_index('digestives_tin', 'd_date_and_time', array('d_date_and_time'));
         $GLOBALS['SITE_DB']->create_index('digestives_tin', 'd_frequency', array('d_frequency'));
         $GLOBALS['SITE_DB']->create_index('digestives_tin', 'd_to_member_id', array('d_to_member_id'));
         $GLOBALS['SITE_DB']->create_table('digestives_consumed', array('c_member_id' => '*USER', 'c_frequency' => '*INTEGER', 'c_time' => 'TIME'));
     }
     if (is_null($upgrade_from)) {
         $GLOBALS['SITE_DB']->create_table('rating', array('id' => '*AUTO', 'rating_for_type' => 'ID_TEXT', 'rating_for_id' => 'ID_TEXT', 'rating_member' => 'USER', 'rating_ip' => 'IP', 'rating_time' => 'TIME', 'rating' => 'SHORT_INTEGER'));
         $GLOBALS['SITE_DB']->create_index('rating', 'alt_key', array('rating_for_type', 'rating_for_id'));
         $GLOBALS['SITE_DB']->create_index('rating', 'rating_for_id', array('rating_for_id'));
     }
 }
Beispiel #13
0
 /**
  * Standard modular install function.
  *
  * @param  ?integer	What version we're upgrading from (NULL: new install)
  * @param  ?integer	What hack version we're upgrading from (NULL: new-install/not-upgrading-from-a-hacked-version)
  */
 function install($upgrade_from = NULL, $upgrade_from_hack = NULL)
 {
     if (!is_null($upgrade_from) && $upgrade_from < 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');
     }
 }
Beispiel #14
0
 /**
  * Standard modular install function.
  *
  * @param  ?integer	What version we're upgrading from (NULL: new install)
  * @param  ?integer	What hack version we're upgrading from (NULL: new-install/not-upgrading-from-a-hacked-version)
  */
 function install($upgrade_from = NULL, $upgrade_from_hack = NULL)
 {
     if (is_null($upgrade_from) || $upgrade_from < 3) {
         add_specific_permission('POINTS', 'use_points', true);
     }
     if (is_null($upgrade_from)) {
         $GLOBALS['SITE_DB']->create_table('chargelog', array('id' => '*AUTO', 'user_id' => 'USER', 'amount' => 'INTEGER', 'reason' => 'SHORT_TRANS', 'date_and_time' => 'TIME'));
         $GLOBALS['SITE_DB']->create_table('gifts', array('id' => '*AUTO', 'date_and_time' => 'TIME', 'amount' => 'INTEGER', 'gift_from' => 'USER', 'gift_to' => 'USER', 'reason' => 'SHORT_TRANS', 'anonymous' => 'BINARY'));
         $GLOBALS['SITE_DB']->create_index('gifts', 'giftsgiven', array('gift_from'));
         $GLOBALS['SITE_DB']->create_index('gifts', 'giftsreceived', array('gift_to'));
         add_config_option('JOINING', 'points_joining', 'integer', 'return \'40\';', 'POINTS', 'COUNT_POINTS_GIVEN');
         add_config_option('MAKE_POST', 'points_posting', 'integer', 'return \'5\';', 'POINTS', 'COUNT_POINTS_GIVEN');
         add_config_option('RATING', 'points_rating', 'integer', 'return \'5\';', 'POINTS', 'COUNT_POINTS_GIVEN');
         add_config_option('VOTING', 'points_voting', 'integer', 'return \'5\';', 'POINTS', 'COUNT_POINTS_GIVEN');
         add_specific_permission('POINTS', 'give_points_self', false);
         add_specific_permission('POINTS', 'have_negative_gift_points', false);
         add_specific_permission('POINTS', 'give_negative_points', false);
         add_specific_permission('POINTS', 'view_charge_log', false);
     }
     if (!is_null($upgrade_from) && $upgrade_from < 5) {
         delete_config_option('is_on_points');
     }
     if (!is_null($upgrade_from) && $upgrade_from < 6) {
         delete_config_option('points_show_personal_profile_link');
     }
     if (is_null($upgrade_from) || $upgrade_from < 7) {
         add_config_option('POINTS_IF_LIKED', 'points_if_liked', 'integer', 'return \'5\';', 'POINTS', 'COUNT_POINTS_GIVEN');
     }
     if (is_null($upgrade_from) || $upgrade_from < 5) {
         add_config_option('COUNT_POINTS_LEFT', 'points_show_personal_stats_points_left', 'tick', 'return \'0\';', 'BLOCKS', 'PERSONAL_BLOCK');
         add_config_option('COUNT_POINTS_USED', 'points_show_personal_stats_points_used', 'tick', 'return \'0\';', 'BLOCKS', 'PERSONAL_BLOCK');
         add_config_option('COUNT_GIFT_POINTS_LEFT', 'points_show_personal_stats_gift_points_left', 'tick', 'return \'0\';', 'BLOCKS', 'PERSONAL_BLOCK');
         add_config_option('COUNT_GIFT_POINTS_USED', 'points_show_personal_stats_gift_points_used', 'tick', 'return \'0\';', 'BLOCKS', 'PERSONAL_BLOCK');
         add_config_option('COUNT_POINTS_EVER', 'points_show_personal_stats_total_points', 'tick', 'return \'0\';', 'BLOCKS', 'PERSONAL_BLOCK');
         add_specific_permission('POINTS', 'trace_anonymous_gifts', false);
     }
     if (is_null($upgrade_from) || $upgrade_from < 4) {
         add_config_option('POINTS_PER_DAY', 'points_per_day', 'integer', 'return \'0\';', 'POINTS', 'COUNT_POINTS_GIVEN');
         add_config_option('POINTS_PER_DAILY_VISIT', 'points_per_daily_visit', 'integer', 'return \'0\';', 'POINTS', 'COUNT_POINTS_GIVEN');
     }
 }
Beispiel #15
0
/**
 * Install/upgrade OCF.
 *
 * @param  ?float	The version to upgrade from (NULL: fresh install).
 */
function install_ocf($upgrade_from = NULL)
{
    require_code('ocf_members');
    require_code('ocf_topics');
    require_code('ocf_groups');
    require_code('ocf_forums');
    require_lang('ocf');
    require_lang('ocf_config');
    require_code('ocf_moderation_action');
    require_code('ocf_posts_action');
    require_code('ocf_members_action');
    require_code('ocf_groups_action');
    require_code('ocf_general_action');
    require_code('ocf_forums_action');
    require_code('ocf_topics_action');
    require_code('database_action');
    if (is_null($upgrade_from)) {
        uninstall_ocf_everytime();
        uninstall_ocf();
    }
    $test = $GLOBALS['FORUM_DB']->query('SELECT id FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_forums', NULL, NULL, true);
    $not_installed = is_null($test);
    if ($not_installed) {
        $upgrade_from = NULL;
    }
    if (is_null($upgrade_from) || $upgrade_from < 4.2) {
        add_config_option('ENCRYPTION_KEY', 'encryption_key', 'line', 'require_code(\'encryption\');return is_encryption_available()?\'\':NULL;', 'PRIVACY', 'ADVANCED');
        add_config_option('DECRYPTION_KEY', 'decryption_key', 'line', 'require_code(\'encryption\');return is_encryption_available()?\'\':NULL;', 'PRIVACY', 'ADVANCED');
        add_config_option('IS_ON_POST_TITLES', 'is_on_post_titles', 'tick', 'return is_null($old=get_value(\'no_post_titles\'))?\'0\':invert_value($old);', 'SECTION_FORUMS', 'GENERAL');
        add_config_option('IS_ON_ANONYMOUS_POSTS', 'is_on_anonymous_posts', 'tick', 'return is_null($old=get_value(\'ocf_no_anonymous_post\'))?\'0\':invert_value($old);', 'SECTION_FORUMS', 'GENERAL');
        add_config_option('IS_ON_TIMEZONE_DETECTION', 'is_on_timezone_detection', 'tick', 'return is_null($old=get_value(\'no_js_timezone_detect\'))?\'0\':invert_value($old);', 'SECTION_FORUMS', 'GENERAL');
        add_config_option('IS_ON_TOPIC_DESCRIPTIONS', 'is_on_topic_descriptions', 'tick', 'return is_null($old=get_value(\'no_topic_descriptions\'))?\'1\':invert_value($old);', 'SECTION_FORUMS', 'GENERAL');
        add_config_option('IS_ON_TOPIC_EMOTICONS', 'is_on_topic_emoticons', 'tick', 'return is_null($old=get_value(\'ocf_no_topic_emoticons\'))?\'1\':invert_value($old);', 'SECTION_FORUMS', 'GENERAL');
        add_config_option('DEFAULT_PREVIEW_GUESTS', 'default_preview_guests', 'tick', 'return is_null($old=get_value(\'no_default_preview_guests\'))?\'0\':invert_value($old);', 'SECTION_FORUMS', 'GENERAL');
        add_config_option('FORCED_PREVIEW_OPTION', 'forced_preview_option', 'tick', 'return is_null($old=get_value(\'no_forced_preview_option\'))?\'0\':invert_value($old);', 'SECTION_FORUMS', 'GENERAL');
        add_config_option('OVERT_WHISPER_SUGGESTION', 'overt_whisper_suggestion', 'tick', 'return is_null($old=get_value(\'disable_overt_whispering\'))?\'1\':invert_value($old);', 'SECTION_FORUMS', 'GENERAL');
        add_config_option('IS_ON_INVISIBILITY', 'is_on_invisibility', 'tick', 'return is_null($old=get_value(\'no_invisible_option\'))?\'0\':invert_value($old);', 'SECTION_FORUMS', 'GENERAL');
        add_config_option('ALLOW_ALPHA_SEARCH', 'allow_alpha_search', 'tick', 'return is_null($old=get_value(\'allow_alpha_search\'))?\'0\':$old;', 'SECTION_FORUMS', 'GENERAL');
        add_config_option('ALLOW_EMAIL_DISABLE', 'allow_email_disable', 'tick', 'return is_null($old=get_value(\'disable_allow_emails_field\'))?\'1\':invert_value($old);', 'SECTION_FORUMS', 'GENERAL');
        add_config_option('MAX_MEMBER_TITLE_LENGTH', 'max_member_title_length', 'integer', 'return addon_installed(\'ocf_member_titles\')?\'20\':NULL;', 'SECTION_FORUMS', 'GENERAL');
        $GLOBALS['FORUM_DB']->drop_if_exists('f_member_cpf_perms');
        $GLOBALS['FORUM_DB']->create_table('f_member_cpf_perms', array('member_id' => '*USER', 'field_id' => '*AUTO_LINK', 'guest_view' => 'BINARY', 'member_view' => 'BINARY', 'friend_view' => 'BINARY', 'group_view' => 'SHORT_TEXT'));
    }
    if (is_null($upgrade_from) || $upgrade_from < 2.5) {
        add_config_option('HTTPAUTH_IS_ENABLED', 'httpauth_is_enabled', 'tick', 'return \'0\';', 'SECTION_FORUMS', 'ADVANCED', 1);
        add_config_option('POST_HISTORY_DAYS', 'post_history_days', 'integer', 'return \'21\';', 'SECTION_FORUMS', 'GENERAL', 1);
    }
    if (is_null($upgrade_from)) {
        // Add config options
        add_config_option('FORUM_POSTS_PER_PAGE', 'forum_posts_per_page', 'integer', 'return has_no_forum()?NULL:\'20\';', 'SECTION_FORUMS', 'GENERAL');
        add_config_option('FORUM_TOPICS_PER_PAGE', 'forum_topics_per_page', 'integer', 'return has_no_forum()?NULL:\'30\';', 'SECTION_FORUMS', 'GENERAL');
        add_config_option('PREVENT_SHOUTING', 'prevent_shouting', 'tick', 'return has_no_forum()?NULL:\'1\';', 'SECTION_FORUMS', 'GENERAL');
        add_config_option('RESTRICTED_USERNAMES', 'restricted_usernames', 'line', 'return do_lang(\'GUEST\').\', \'.do_lang(\'STAFF\').\', \'.do_lang(\'ADMIN\').\', \'.do_lang(\'MODERATOR\').\', googlebot\';', 'SECTION_FORUMS', 'GENERAL');
        add_config_option('REQUIRE_NEW_MEMBER_VALIDATION', 'require_new_member_validation', 'tick', 'return \'0\';', 'SECTION_FORUMS', 'USERNAMES_AND_PASSWORDS');
        add_config_option('REPORTED_POSTS_FORUM', 'reported_posts_forum', 'forum', 'return (has_no_forum()||(!addon_installed(\'ocf_reported_posts\')))?NULL:do_lang(\'ocf:REPORTED_POSTS_FORUM\');', 'SECTION_FORUMS', 'GENERAL');
        add_config_option('ONE_PER_EMAIL_ADDRESS', 'one_per_email_address', 'tick', 'return \'1\';', 'SECTION_FORUMS', 'GENERAL');
        add_config_option('HOT_TOPIC_DEFINITION', 'hot_topic_definition', 'integer', 'return has_no_forum()?NULL:\'20\';', 'SECTION_FORUMS', 'GENERAL');
    }
    if (!is_null($upgrade_from) && $upgrade_from < 7.2) {
        $rows = $GLOBALS['FORUM_DB']->query('SELECT m_name FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'db_meta WHERE (' . db_string_equal_to('m_type', '?INTEGER') . ' OR ' . db_string_equal_to('m_type', 'BINARY') . ') AND ' . db_string_equal_to('m_table', 'f_member_custom_fields'));
        foreach ($rows as $row) {
            $GLOBALS['FORUM_DB']->alter_table_field('f_member_custom_fields', $row['m_name'], 'SHORT_TEXT');
        }
        $i = 0;
        do {
            $rows = $GLOBALS['FORUM_DB']->query_select('f_member_custom_fields', array('*'), NULL, '', 100, $i);
            foreach ($rows as $j => $row) {
                foreach ($row as $key => $val) {
                    if (substr($key, 0, 6) == 'field_') {
                        $val = str_replace('|', chr(10), $val);
                        $row[$key] = $val;
                    }
                }
                if ($rows[$j] != $row) {
                    $GLOBALS['FORUM_DB']->query_update('f_member_custom_fields', array('mf_member_id' => $row['mf_member_id']), $row, '', 1);
                }
            }
            $i += 100;
        } while (count($rows) != 0);
        $GLOBALS['FORUM_DB']->alter_table_field('f_members', 'm_track_contributed_topics', 'BINARY', 'm_auto_monitor_contrib_content');
    }
    if (!is_null($upgrade_from) && $upgrade_from < 4.0) {
        $GLOBALS['FORUM_DB']->alter_table_field('f_members', 'm_password_compatibility_scheme', 'ID_TEXT', 'm_password_compat_scheme');
        $GLOBALS['FORUM_DB']->delete_table_field('f_members', 'm_track_all_forums');
    }
    if (!is_null($upgrade_from) && $upgrade_from < 3.1) {
        $GLOBALS['FORUM_DB']->add_table_field('f_emoticons', 'e_is_special', 'BINARY', 0);
        $GLOBALS['FORUM_DB']->add_table_field('f_members', 'm_highlighted_name', 'BINARY', 0);
    }
    if (!is_null($upgrade_from) && $upgrade_from < 3.0) {
        $rows = $GLOBALS['FORUM_DB']->query_select('f_forum_group_access', array('*'));
        foreach ($rows as $row) {
            if ($row['a_level'] > 1) {
                $GLOBALS['SITE_DB']->query_insert('group_category_access', array('module_the_name' => 'forums', 'category_name' => strval($row['a_forum_id']), 'group_id' => $row['a_group_id']));
            }
        }
        $GLOBALS['FORUM_DB']->drop_if_exists('f_forum_group_access');
        delete_specific_permission('allow_deletive_moderation');
        $GLOBALS['FORUM_DB']->delete_table_field('f_post_templates', 't_minimum_access_level');
        $GLOBALS['FORUM_DB']->add_table_field('f_groups', 'g_is_presented_at_install', 'BINARY', 0);
        $GLOBALS['FORUM_DB']->alter_table_field('f_custom_fields', 'cf_name', 'SHORT_TRANS');
        $GLOBALS['FORUM_DB']->alter_table_field('f_groups', 'g_rank_image', 'ID_TEXT');
    }
    if (!is_null($upgrade_from) && $upgrade_from < 2.6) {
        $GLOBALS['FORUM_DB']->add_table_field('f_groups', 'g_is_default', 'BINARY');
    }
    if (is_null($upgrade_from) || $upgrade_from < 4.0) {
        add_config_option('MINIMUM_PASSWORD_LENGTH', 'minimum_password_length', 'integer', 'return \'4\';', 'SECTION_FORUMS', 'USERNAMES_AND_PASSWORDS');
        add_config_option('MAXIMUM_PASSWORD_LENGTH', 'maximum_password_length', 'integer', 'return \'20\';', 'SECTION_FORUMS', 'USERNAMES_AND_PASSWORDS');
        add_config_option('MINIMUM_USERNAME_LENGTH', 'minimum_username_length', 'integer', 'return \'1\';', 'SECTION_FORUMS', 'USERNAMES_AND_PASSWORDS');
        add_config_option('MAXIMUM_USERNAME_LENGTH', 'maximum_username_length', 'integer', 'return \'20\';', 'SECTION_FORUMS', 'USERNAMES_AND_PASSWORDS');
        add_config_option('PROHIBIT_PASSWORD_WHITESPACE', 'prohibit_password_whitespace', 'tick', 'return \'1\';', 'SECTION_FORUMS', 'USERNAMES_AND_PASSWORDS');
        //add_config_option('PROHIBIT_PASSWORD_DICTIONARY','prohibit_password_dictionary','tick','return \'0\';','SECTION_FORUMS','USERNAMES_AND_PASSWORDS');
        add_config_option('PROHIBIT_USERNAME_WHITESPACE', 'prohibit_username_whitespace', 'tick', 'return \'0\';', 'SECTION_FORUMS', 'USERNAMES_AND_PASSWORDS');
        add_config_option('ASSIGN_RANDOM_AVATARS', 'random_avatars', 'tick', 'return addon_installed(\'ocf_member_avatars\')?\'1\':NULL;', 'SECTION_FORUMS', 'GENERAL');
        add_config_option('CLUB_FORUM_PARENT_FORUM', 'club_forum_parent_forum', 'forum', 'return has_no_forum()?NULL:strval(db_get_first_id());', 'SECTION_FORUMS', 'GENERAL');
        add_config_option('CLUB_FORUM_PARENT_CATEGORY', 'club_forum_parent_category', 'category', 'return has_no_forum()?NULL:strval(db_get_first_id());', 'SECTION_FORUMS', 'GENERAL');
        add_config_option('DELETE_TRASHED_PTS', 'delete_trashed_pts', 'tick', 'return has_no_forum()?NULL:\'0\';', 'SECTION_FORUMS', 'GENERAL');
        //add_config_option('ALLOW_MEMBER_INTEGRATION','allow_member_integration','list','return \'off\';','SECTION_FORUMS','USERNAMES_AND_PASSWORDS',0,'strict|on|hidden|off');
        add_config_option('PROBATION_USERGROUP', 'probation_usergroup', 'usergroup', 'return do_lang(\'PROBATION\');', 'SECTION_FORUMS', 'USERNAMES_AND_PASSWORDS');
        add_config_option('SHOW_FIRST_JOIN_PAGE', 'show_first_join_page', 'tick', 'return \'1\';', 'SECTION_FORUMS', 'USERNAMES_AND_PASSWORDS');
        add_config_option('SKIP_EMAIL_CONFIRM_JOIN', 'skip_email_confirm_join', 'tick', 'return \'1\';', 'SECTION_FORUMS', 'USERNAMES_AND_PASSWORDS');
        add_config_option('NO_DOB_ASK', 'no_dob_ask', 'list', 'return \'0\';', 'SECTION_FORUMS', 'USERNAMES_AND_PASSWORDS', 0, '0|1|2');
        add_config_option('ALLOW_INTERNATIONAL', 'allow_international', 'tick', 'return \'1\';', 'SECTION_FORUMS', 'USERNAMES_AND_PASSWORDS');
    }
    if (is_null($upgrade_from) || $upgrade_from < 8.0) {
        add_config_option('ALLOW_EMAIL_FROM_STAFF_DISABLE', 'allow_email_from_staff_disable', 'tick', 'return \'0\';', 'SECTION_FORUMS', 'GENERAL');
        add_config_option('INTRO_FORUM_ID', 'intro_forum_id', '?forum', 'return \'\';', 'SECTION_FORUMS', 'USERNAMES_AND_PASSWORDS');
        add_config_option('SIGNUP_FULLNAME', 'signup_fullname', 'tick', 'return \'0\';', 'SECTION_FORUMS', 'USERNAMES_AND_PASSWORDS');
    }
    if (!is_null($upgrade_from) && $upgrade_from < 8.1) {
        delete_config_option('no_dob_ask');
        add_config_option('NO_DOB_ASK', 'no_dob_ask', 'list', 'return \'0\';', 'SECTION_FORUMS', 'USERNAMES_AND_PASSWORDS', 0, '0|1|2');
        // Recreate option
    }
    if (!is_null($upgrade_from) && $upgrade_from < 8.0) {
        $GLOBALS['FORUM_DB']->add_table_field('f_members', 'm_allow_emails_from_staff', 'BINARY');
        $GLOBALS['FORUM_DB']->add_table_field('f_custom_fields', 'cf_show_on_join_form', 'BINARY');
        $GLOBALS['FORUM_DB']->add_table_field('f_forums', 'f_is_threaded', 'BINARY', 0);
        $GLOBALS['FORUM_DB']->add_table_field('f_posts', 'p_parent_id', '?AUTO_LINK', NULL);
        $GLOBALS['FORUM_DB']->query('UPDATE ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_custom_fields SET cf_show_on_join_form=cf_required');
        delete_config_option('send_staff_message_post_validation');
        require_code('notifications');
        $start = 0;
        do {
            $rows = $GLOBALS['FORUM_DB']->query_select('f_forum_tracking', array('r_forum_id', 'r_member_id'), NULL, '', 100, $start);
            foreach ($rows as $row) {
                enable_notifications('ocf_topic', 'forum:' . strval($row['r_forum_id']), $row['r_member_id']);
            }
            $start += 100;
        } while (count($rows) == 100);
        $start = 0;
        do {
            $rows = $GLOBALS['FORUM_DB']->query_select('f_topic_tracking', array('r_topic_id', 'r_member_id'), NULL, '', 100, $start);
            foreach ($rows as $row) {
                enable_notifications('ocf_topic', strval($row['r_topic_id']), $row['r_member_id']);
            }
            $start += 100;
        } while (count($rows) == 100);
        $GLOBALS['FORUM_DB']->drop_if_exists('f_forum_tracking');
        $GLOBALS['FORUM_DB']->drop_if_exists('f_topic_tracking');
    }
    if (!is_null($upgrade_from) && $upgrade_from < 4.2) {
        $GLOBALS['FORUM_DB']->add_table_field('f_topics', 't_description_link', 'SHORT_TEXT');
        $GLOBALS['FORUM_DB']->add_table_field('f_custom_fields', 'cf_encrypted', 'BINARY', 0);
    }
    if (!is_null($upgrade_from) && $upgrade_from < 4.0) {
        $GLOBALS['FORUM_DB']->add_table_field('f_members', 'm_on_probation_until', '?TIME', time());
        $GLOBALS['FORUM_DB']->add_table_field('f_members', 'm_pt_rules_text', 'LONG_TRANS', '');
        $GLOBALS['FORUM_DB']->add_table_field('f_members', 'm_pt_allow', 'SHORT_TEXT', '*');
        $GLOBALS['FORUM_DB']->add_table_field('f_forums', 'f_order', 'ID_TEXT', 'last_post');
        // last_post,first_post,title
        $GLOBALS['FORUM_DB']->add_table_field('f_groups', 'g_hidden', 'BINARY', 0);
        $GLOBALS['FORUM_DB']->add_table_field('f_groups', 'g_order', 'INTEGER');
        $GLOBALS['FORUM_DB']->add_table_field('f_groups', 'g_rank_image_pri_only', 'BINARY', 1);
        $GLOBALS['FORUM_DB']->add_table_field('f_groups', 'g_open_membership', 'BINARY', 0);
        $GLOBALS['FORUM_DB']->add_table_field('f_groups', 'g_is_private_club', 'BINARY', 0);
        $GLOBALS['FORUM_DB']->add_table_field('f_posts', 'p_skip_sig', 'BINARY', 0);
        $GLOBALS['FORUM_DB']->add_table_field('f_topics', 't_sunk', 'BINARY', 0);
        $GLOBALS['FORUM_DB']->add_table_field('f_multi_moderations', 'mm_sink_state', '?BINARY', NULL);
        $GLOBALS['FORUM_DB']->add_table_field('f_multi_moderations', 'mm_title_suffix', 'SHORT_TEXT');
        $GLOBALS['FORUM_DB']->add_table_field('f_warnings', 'w_is_warning', 'BINARY', 1);
        $GLOBALS['FORUM_DB']->add_table_field('f_warnings', 'p_silence_from_topic', '?AUTO_LINK');
        $GLOBALS['FORUM_DB']->add_table_field('f_warnings', 'p_silence_from_forum', '?AUTO_LINK');
        $GLOBALS['FORUM_DB']->add_table_field('f_warnings', 'p_probation', 'INTEGER', 0);
        $GLOBALS['FORUM_DB']->add_table_field('f_warnings', 'p_banned_ip', 'IP');
        $GLOBALS['FORUM_DB']->add_table_field('f_warnings', 'p_charged_points', 'INTEGER', 0);
        $GLOBALS['FORUM_DB']->add_table_field('f_warnings', 'p_banned_member', 'BINARY', 0);
        $GLOBALS['FORUM_DB']->add_table_field('f_warnings', 'p_changed_usergroup_from', '?GROUP');
    }
    if (is_null($upgrade_from) || $upgrade_from < 3.0) {
        add_config_option('COPPA_ENABLED', 'is_on_coppa', 'tick', 'return \'0\';', 'PRIVACY', 'GENERAL');
        add_config_option('FAX_NUMBER', 'privacy_fax', 'line', 'return \'\';', 'PRIVACY', 'GENERAL');
        add_config_option('ADDRESS', 'privacy_postal_address', 'text', 'return \'\';', 'PRIVACY', 'GENERAL');
    }
    if (is_null($upgrade_from) || $upgrade_from < 2.6) {
        add_config_option('INVITES_ENABLED', 'is_on_invites', 'tick', 'return \'0\';', 'SECTION_FORUMS', 'GENERAL');
        add_config_option('INVITES_PER_DAY', 'invites_per_day', 'float', 'return \'1\';', 'SECTION_FORUMS', 'GENERAL');
    }
    if (!is_null($upgrade_from) && $upgrade_from < 2.5) {
        $GLOBALS['FORUM_DB']->add_table_field('f_forums', 'f_redirection', 'SHORT_TEXT');
        $GLOBALS['FORUM_DB']->add_table_field('f_forums', 'f_order_sub_alpha', 'BINARY');
        $GLOBALS['FORUM_DB']->add_table_field('f_forums', 'f_intro_question', 'LONG_TRANS');
        $GLOBALS['FORUM_DB']->add_table_field('f_forums', 'f_intro_answer', 'SHORT_TEXT');
        $GLOBALS['FORUM_DB']->add_table_field('f_members', 'm_max_email_attach_size_mb', 'INTEGER', 3);
        $GLOBALS['FORUM_DB']->add_table_field('f_members', 'm_zone_wide', 'BINARY', 1);
        $GLOBALS['FORUM_DB']->add_table_field('f_members', 'm_notes', 'LONG_TEXT');
        // TODO: remove
        $GLOBALS['FORUM_DB']->add_table_field('f_emoticons', 'e_use_topics', 'BINARY', 1);
        $GLOBALS['FORUM_DB']->add_table_field('f_topics', 't_pt_from_category', 'SHORT_TEXT');
        $GLOBALS['FORUM_DB']->add_table_field('f_topics', 't_pt_to_category', 'SHORT_TEXT');
        $GLOBALS['FORUM_DB']->add_table_field('f_custom_fields', 'cf_show_in_post_previews', 'BINARY', 1);
        $GLOBALS['FORUM_DB']->add_table_field('f_custom_fields', 'cf_order', 'INTEGER');
        $GLOBALS['FORUM_DB']->add_table_field('f_custom_fields', 'cf_only_group', '?GROUP');
        $GLOBALS['FORUM_DB']->add_table_field('f_multi_moderations', 'mm_forum_multi_code', 'SHORT_TEXT');
        $GLOBALS['FORUM_DB']->alter_table_field('f_topics', 't_emoticon', 'SHORT_TEXT');
        $GLOBALS['FORUM_DB']->alter_table_field('f_emoticons', 'e_theme_img_code', 'SHORT_TEXT');
        $GLOBALS['FORUM_DB']->promote_text_field_to_comcode('f_forums', 'f_description');
        $GLOBALS['FORUM_DB']->alter_table_field('f_members', 'm_pass_hash_salted', 'SHORT_TEXT');
        $GLOBALS['FORUM_DB']->drop_if_exists('f_groups');
        $GLOBALS['FORUM_DB']->query_delete('f_emoticons');
    }
    if (!is_null($upgrade_from) && $upgrade_from < 3.1) {
        $GLOBALS['FORUM_DB']->alter_table_field('f_custom_fields', 'cf_only_group', 'LONG_TEXT');
    }
    // If we have the forum installed to this db already, leave
    if (is_null($upgrade_from) && $not_installed) {
        uninstall_ocf();
        $GLOBALS['FORUM_DB']->create_table('f_emoticons', array('e_code' => '*ID_TEXT', 'e_theme_img_code' => 'SHORT_TEXT', 'e_relevance_level' => 'INTEGER', 'e_use_topics' => 'BINARY', 'e_is_special' => 'BINARY'));
        $GLOBALS['FORUM_DB']->create_index('f_emoticons', 'relevantemoticons', array('e_relevance_level'));
        $GLOBALS['FORUM_DB']->create_index('f_emoticons', 'topicemos', array('e_use_topics'));
        $GLOBALS['FORUM_DB']->create_table('f_custom_fields', array('id' => '*AUTO', 'cf_locked' => 'BINARY', 'cf_name' => 'SHORT_TRANS', 'cf_description' => 'SHORT_TRANS', 'cf_default' => 'LONG_TEXT', 'cf_public_view' => 'BINARY', 'cf_owner_view' => 'BINARY', 'cf_owner_set' => 'BINARY', 'cf_type' => 'ID_TEXT', 'cf_required' => 'BINARY', 'cf_show_in_posts' => 'BINARY', 'cf_show_in_post_previews' => 'BINARY', 'cf_order' => 'INTEGER', 'cf_only_group' => 'LONG_TEXT', 'cf_encrypted' => 'BINARY', 'cf_show_on_join_form' => 'BINARY'));
        // These don't need to be filled in. We just use default from custom field if they aren't
        $GLOBALS['FORUM_DB']->create_table('f_member_custom_fields', array('mf_member_id' => '*USER'));
        //$GLOBALS['FORUM_DB']->create_index('f_member_custom_fields','fields_for_member',array('mf_member_id'));
        ocf_make_boiler_custom_field('SELF_DESCRIPTION');
        //ocf_make_boiler_custom_field('im_aim');
        //ocf_make_boiler_custom_field('im_msn');
        //ocf_make_boiler_custom_field('im_yahoo');
        //ocf_make_boiler_custom_field('im_icq');
        //ocf_make_boiler_custom_field('im_jabber');
        ocf_make_boiler_custom_field('im_skype');
        ocf_make_boiler_custom_field('sn_facebook');
        ocf_make_boiler_custom_field('sn_google');
        ocf_make_boiler_custom_field('sn_twitter');
        ocf_make_boiler_custom_field('interests');
        ocf_make_boiler_custom_field('location');
        ocf_make_boiler_custom_field('occupation');
        ocf_make_boiler_custom_field('staff_notes');
    }
    if (is_null($upgrade_from) || $upgrade_from < 2.6) {
        $GLOBALS['FORUM_DB']->create_table('f_invites', array('id' => '*AUTO', 'i_inviter' => 'USER', 'i_email_address' => 'SHORT_TEXT', 'i_time' => 'TIME', 'i_taken' => 'BINARY'));
    }
    if (is_null($upgrade_from) && $not_installed) {
        $GLOBALS['FORUM_DB']->create_table('f_group_members', array('gm_group_id' => '*GROUP', 'gm_member_id' => '*USER', 'gm_validated' => 'BINARY'));
        $GLOBALS['FORUM_DB']->create_index('f_group_members', 'gm_validated', array('gm_validated'));
        $GLOBALS['FORUM_DB']->create_index('f_group_members', 'gm_member_id', array('gm_member_id'));
        $GLOBALS['FORUM_DB']->create_index('f_group_members', 'gm_group_id', array('gm_group_id'));
        $GLOBALS['FORUM_DB']->create_table('f_members', array('id' => '*AUTO', 'm_username' => 'ID_TEXT', 'm_pass_hash_salted' => 'SHORT_TEXT', 'm_pass_salt' => 'SHORT_TEXT', 'm_theme' => 'ID_TEXT', 'm_avatar_url' => 'URLPATH', 'm_validated' => 'BINARY', 'm_validated_email_confirm_code' => 'SHORT_TEXT', 'm_cache_num_posts' => 'INTEGER', 'm_cache_warnings' => 'INTEGER', 'm_join_time' => 'TIME', 'm_timezone_offset' => 'SHORT_TEXT', 'm_primary_group' => 'GROUP', 'm_last_visit_time' => 'TIME', 'm_last_submit_time' => 'TIME', 'm_signature' => 'LONG_TRANS', 'm_is_perm_banned' => 'BINARY', 'm_preview_posts' => 'BINARY', 'm_dob_day' => '?INTEGER', 'm_dob_month' => '?INTEGER', 'm_dob_year' => '?INTEGER', 'm_reveal_age' => 'BINARY', 'm_email_address' => 'SHORT_TEXT', 'm_title' => 'SHORT_TEXT', 'm_photo_url' => 'URLPATH', 'm_photo_thumb_url' => 'URLPATH', 'm_views_signatures' => 'BINARY', 'm_auto_monitor_contrib_content' => 'BINARY', 'm_language' => 'ID_TEXT', 'm_ip_address' => 'IP', 'm_allow_emails' => 'BINARY', 'm_allow_emails_from_staff' => 'BINARY', 'm_notes' => 'LONG_TEXT', 'm_zone_wide' => 'BINARY', 'm_highlighted_name' => 'BINARY', 'm_pt_allow' => 'SHORT_TEXT', 'm_pt_rules_text' => 'LONG_TRANS', 'm_max_email_attach_size_mb' => 'INTEGER', 'm_password_change_code' => 'SHORT_TEXT', 'm_password_compat_scheme' => 'ID_TEXT', 'm_on_probation_until' => '?TIME'));
        $GLOBALS['FORUM_DB']->create_index('f_members', '#search_user', array('m_username'));
        $GLOBALS['FORUM_DB']->create_index('f_members', 'user_list', array('m_username'));
        $GLOBALS['FORUM_DB']->create_index('f_members', 'menail', array('m_email_address'));
        $GLOBALS['FORUM_DB']->create_index('f_members', 'external_auth_lookup', array('m_pass_hash_salted'));
        $GLOBALS['FORUM_DB']->create_index('f_members', 'sort_post_count', array('m_cache_num_posts'));
        $GLOBALS['FORUM_DB']->create_index('f_members', 'm_join_time', array('m_join_time'));
        $GLOBALS['FORUM_DB']->create_index('f_members', 'whos_validated', array('m_validated'));
        $GLOBALS['FORUM_DB']->create_index('f_members', 'birthdays', array('m_dob_day', 'm_dob_month'));
        $GLOBALS['FORUM_DB']->create_index('f_members', 'ftjoin_msig', array('m_signature'));
        $GLOBALS['FORUM_DB']->create_index('f_members', 'primary_group', array('m_primary_group'));
        $GLOBALS['FORUM_DB']->create_index('f_members', 'avatar_url', array('m_avatar_url'));
        // Used for uniform avatar randomisation
    }
    if (is_null($upgrade_from) || $upgrade_from < 2.5) {
        $no_use_topics = array('party' => 1, 'christmas' => 1, 'offtopic' => 1, 'rockon' => 1, 'guitar' => 1, 'sinner' => 1, 'wink' => 1, 'kiss' => 1, 'nod' => 1, 'smile' => 1, 'mellow' => 1, 'whistle' => 1, 'shutup' => 1, 'cyborg' => 1);
        $core_emoticons = array(':P' => 'cheeky', ":'(" => 'cry', ':dry:' => 'dry', ':$' => 'blush', ';)' => 'wink', 'O_o' => 'blink', ':wub:' => 'wub', ':cool:' => 'cool', ':lol:' => 'lol', ':(' => 'sad', ':)' => 'smile', ':thumbs:' => 'thumbs', ':offtopic:' => 'offtopic', ':|' => 'mellow', ':ninja:' => 'ph34r', ':o' => 'shocked');
        $supported_emoticons = array(':rolleyes:' => 'rolleyes', ':D' => 'grin', '^_^' => 'glee', '(K)' => 'kiss', ':S' => 'confused', ':@' => 'angry', ':shake:' => 'shake', ':hand:' => 'hand', ':drool:' => 'drool', ':devil:' => 'devil', ':party:' => 'party', ':constipated:' => 'constipated', ':depressed:' => 'depressed', ':zzz:' => 'zzz', ':whistle:' => 'whistle', ':upsidedown:' => 'upsidedown', ':sick:' => 'sick', ':shutup:' => 'shutup', ':sarcy:' => 'sarcy', ':puppyeyes:' => 'puppyeyes', ':nod:' => 'nod', ':nerd:' => 'nerd', ':king:' => 'king', ':birthday:' => 'birthday', ':cyborg:' => 'cyborg', ':hippie:' => 'hippie', ':ninja2:' => 'ninja2', ':rockon:' => 'rockon', ':sinner:' => 'sinner', ':guitar:' => 'guitar');
        $unused_emoticons = array(':christmas:' => 'christmas');
        foreach ($core_emoticons as $a => $b) {
            ocf_make_emoticon($a, 'ocf_emoticons/' . $b, 0, array_key_exists($b, $no_use_topics) ? 0 : 1);
        }
        foreach ($supported_emoticons as $a => $b) {
            ocf_make_emoticon($a, 'ocf_emoticons/' . $b, 1, array_key_exists($b, $no_use_topics) ? 0 : 1);
        }
        foreach ($unused_emoticons as $a => $b) {
            ocf_make_emoticon($a, 'ocf_emoticons/' . $b, 1, array_key_exists($b, $no_use_topics) ? 0 : 1);
        }
        $GLOBALS['FORUM_DB']->create_table('f_groups', array('id' => '*AUTO', 'g_name' => 'SHORT_TRANS', 'g_is_default' => 'BINARY', 'g_is_presented_at_install' => 'BINARY', 'g_is_super_admin' => 'BINARY', 'g_is_super_moderator' => 'BINARY', 'g_group_leader' => '?USER', 'g_title' => 'SHORT_TRANS', 'g_promotion_target' => '?GROUP', 'g_promotion_threshold' => '?INTEGER', 'g_flood_control_submit_secs' => 'INTEGER', 'g_flood_control_access_secs' => 'INTEGER', 'g_gift_points_base' => 'INTEGER', 'g_gift_points_per_day' => 'INTEGER', 'g_max_daily_upload_mb' => 'INTEGER', 'g_max_attachments_per_post' => 'INTEGER', 'g_max_avatar_width' => 'INTEGER', 'g_max_avatar_height' => 'INTEGER', 'g_max_post_length_comcode' => 'INTEGER', 'g_max_sig_length_comcode' => 'INTEGER', 'g_enquire_on_new_ips' => 'BINARY', 'g_rank_image' => 'ID_TEXT', 'g_hidden' => 'BINARY', 'g_order' => 'INTEGER', 'g_rank_image_pri_only' => 'BINARY', 'g_open_membership' => 'BINARY', 'g_is_private_club' => 'BINARY'));
        $GLOBALS['FORUM_DB']->create_index('f_groups', 'ftjoin_gname', array('g_name'));
        $GLOBALS['FORUM_DB']->create_index('f_groups', 'ftjoin_gtitle', array('g_title'));
        $GLOBALS['FORUM_DB']->create_index('f_groups', 'is_private_club', array('g_is_private_club'));
        $GLOBALS['FORUM_DB']->create_index('f_groups', 'is_super_admin', array('g_is_super_admin'));
        $GLOBALS['FORUM_DB']->create_index('f_groups', 'is_super_moderator', array('g_is_super_moderator'));
        $GLOBALS['FORUM_DB']->create_index('f_groups', 'is_default', array('g_is_default'));
        $GLOBALS['FORUM_DB']->create_index('f_groups', 'hidden', array('g_hidden'));
        $GLOBALS['FORUM_DB']->create_index('f_groups', 'is_presented_at_install', array('g_is_presented_at_install'));
        $GLOBALS['FORUM_DB']->create_index('f_groups', 'gorder', array('g_order', 'id'));
        // For the_zone_access table
        require_code('zones2');
        reinstall_module('adminzone', 'admin_permissions');
        // Make guest
        $guest_group = ocf_make_group(do_lang('GUESTS'), 0, 0, 0, do_lang('DESCRIPTION_GUESTS'));
        // Make admin
        $administrator_group = ocf_make_group(do_lang('ADMINISTRATORS'), 0, 1, 0, do_lang('DESCRIPTION_ADMINISTRATORS'), 'ocf_rank_images/admin', NULL, NULL, NULL, 0);
        // Make mod
        $super_moderator_group = ocf_make_group(do_lang('SUPER_MODERATORS'), 0, 0, 1, do_lang('DESCRIPTION_SUPER_MODERATORS'), 'ocf_rank_images/mod', NULL, NULL, NULL, 0);
        // Make supermember
        $super_member_group = ocf_make_group(do_lang('SUPER_MEMBERS'), 0, 0, 0, do_lang('DESCRIPTION_SUPER_MEMBERS'), '', NULL, NULL, NULL, 0);
        // Make member
        $member_group_4 = ocf_make_group(do_lang('DEFAULT_RANK_4'), 0, 0, 0, do_lang('DESCRIPTION_MEMBERS'), 'ocf_rank_images/4');
        $member_group_3 = ocf_make_group(do_lang('DEFAULT_RANK_3'), 0, 0, 0, do_lang('DESCRIPTION_MEMBERS'), 'ocf_rank_images/3', $member_group_4, 10000);
        $member_group_2 = ocf_make_group(do_lang('DEFAULT_RANK_2'), 0, 0, 0, do_lang('DESCRIPTION_MEMBERS'), 'ocf_rank_images/2', $member_group_3, 2500);
        $member_group_1 = ocf_make_group(do_lang('DEFAULT_RANK_1'), 0, 0, 0, do_lang('DESCRIPTION_MEMBERS'), 'ocf_rank_images/1', $member_group_2, 400);
        $member_group_0 = ocf_make_group(do_lang('DEFAULT_RANK_0'), 0, 0, 0, do_lang('DESCRIPTION_MEMBERS'), 'ocf_rank_images/0', $member_group_1, 100);
        // Not default because primary is always defaulted to this one
        // Make probation
        $probation_group = ocf_make_group(do_lang('PROBATION'), 0, 0, 0, do_lang('DESCRIPTION_PROBATION'), '', NULL, NULL, NULL, 0);
    }
    if (is_null($upgrade_from) && $not_installed) {
        $GLOBALS['FORUM_DB']->create_table('f_categories', array('id' => '*AUTO', 'c_title' => 'SHORT_TEXT', 'c_description' => 'LONG_TEXT', 'c_expanded_by_default' => 'BINARY'));
        $category_id = ocf_make_category(do_lang('DEFAULT_CATEGORY_TITLE'), '');
        $category_id_staff = ocf_make_category(do_lang('STAFF'), '');
        $GLOBALS['FORUM_DB']->create_table('f_forums', array('id' => '*AUTO', 'f_name' => 'SHORT_TEXT', 'f_description' => 'LONG_TRANS', 'f_category_id' => '?AUTO_LINK', 'f_parent_forum' => '?AUTO_LINK', 'f_position' => 'INTEGER', 'f_order_sub_alpha' => 'BINARY', 'f_post_count_increment' => 'BINARY', 'f_intro_question' => 'LONG_TRANS', 'f_intro_answer' => 'SHORT_TEXT', 'f_cache_num_topics' => 'INTEGER', 'f_cache_num_posts' => 'INTEGER', 'f_cache_last_topic_id' => '?AUTO_LINK', 'f_cache_last_title' => 'SHORT_TEXT', 'f_cache_last_time' => '?TIME', 'f_cache_last_username' => 'SHORT_TEXT', 'f_cache_last_member_id' => '?USER', 'f_cache_last_forum_id' => '?AUTO_LINK', 'f_redirection' => 'SHORT_TEXT', 'f_order' => 'ID_TEXT', 'f_is_threaded' => 'BINARY'));
        $GLOBALS['FORUM_DB']->create_index('f_forums', 'cache_num_posts', array('f_cache_num_posts'));
        // Used to find active forums
        $GLOBALS['FORUM_DB']->create_index('f_forums', 'subforum_parenting', array('f_parent_forum'));
        $GLOBALS['FORUM_DB']->create_index('f_forums', 'findnamedforum', array('f_name'));
        $GLOBALS['FORUM_DB']->create_index('f_forums', 'f_position', array('f_position'));
        $typical_access = array($guest_group => 4, $administrator_group => 5, $super_moderator_group => 5, $probation_group => 2, $super_member_group => 4, $member_group_0 => 4, $member_group_1 => 4, $member_group_2 => 4, $member_group_3 => 4, $member_group_4 => 4);
        $staff_post_access = array($guest_group => 1, $administrator_group => 5, $super_moderator_group => 5, $probation_group => 1, $super_member_group => 2, $member_group_0 => 1, $member_group_1 => 1, $member_group_2 => 1, $member_group_3 => 1, $member_group_4 => 1);
        $staff_access = array($administrator_group => 5, $super_moderator_group => 5);
        $root_forum = ocf_make_forum(do_lang('ROOT_FORUM'), '', NULL, $staff_post_access, NULL);
        //ocf_make_forum(do_lang('NEWS'),'',$category_id,$staff_post_access,$root_forum);
        ocf_make_forum(do_lang('DEFAULT_FORUM_TITLE'), '', $category_id, $typical_access, $root_forum);
        //ocf_make_forum(do_lang('_FEEDBACK'),'',$category_id,$typical_access,$root_forum);	We already have a feedback page
        ocf_make_forum(do_lang('REPORTED_POSTS_FORUM'), '', $category_id_staff, $staff_access, $root_forum);
        $trash_forum_id = ocf_make_forum(do_lang('TRASH'), '', $category_id_staff, $staff_access, $root_forum);
        ocf_make_forum(do_lang('COMMENT_FORUM_NAME'), '', $category_id, $typical_access, $root_forum, 1, 1, 0, '', '', '', 'last_post', 1);
        if (addon_installed('tickets')) {
            require_lang('tickets');
            ocf_make_forum(do_lang('TICKET_FORUM_NAME'), '', $category_id_staff, $staff_access, $root_forum);
        }
        $staff_forum_id = ocf_make_forum(do_lang('STAFF'), '', $category_id_staff, $staff_access, $root_forum);
        $GLOBALS['FORUM_DB']->create_table('f_topics', array('id' => '*AUTO', 't_pinned' => 'BINARY', 't_sunk' => 'BINARY', 't_cascading' => 'BINARY', 't_forum_id' => '?AUTO_LINK', 't_pt_from' => '?USER', 't_pt_to' => '?USER', 't_pt_from_category' => 'SHORT_TEXT', 't_pt_to_category' => 'SHORT_TEXT', 't_description' => 'SHORT_TEXT', 't_description_link' => 'SHORT_TEXT', 't_emoticon' => 'SHORT_TEXT', 't_num_views' => 'INTEGER', 't_validated' => 'BINARY', 't_is_open' => 'BINARY', 't_poll_id' => '?AUTO_LINK', 't_cache_first_post_id' => '?AUTO_LINK', 't_cache_first_time' => '?TIME', 't_cache_first_title' => 'SHORT_TEXT', 't_cache_first_post' => '?LONG_TRANS', 't_cache_first_username' => 'ID_TEXT', 't_cache_first_member_id' => '?USER', 't_cache_last_post_id' => '?AUTO_LINK', 't_cache_last_time' => '?TIME', 't_cache_last_title' => 'SHORT_TEXT', 't_cache_last_username' => 'ID_TEXT', 't_cache_last_member_id' => '?USER', 't_cache_num_posts' => 'INTEGER'));
        $GLOBALS['FORUM_DB']->create_index('f_topics', 't_num_views', array('t_num_views'));
        $GLOBALS['FORUM_DB']->create_index('f_topics', 't_pt_to', array('t_pt_to'));
        $GLOBALS['FORUM_DB']->create_index('f_topics', 't_pt_from', array('t_pt_from'));
        $GLOBALS['FORUM_DB']->create_index('f_topics', 't_validated', array('t_validated'));
        $GLOBALS['FORUM_DB']->create_index('f_topics', 'in_forum', array('t_forum_id'));
        $GLOBALS['FORUM_DB']->create_index('f_topics', 'topic_order_time', array('t_cache_last_time'));
        $GLOBALS['FORUM_DB']->create_index('f_topics', 'topic_order_time_2', array('t_cache_first_time'));
        $GLOBALS['FORUM_DB']->create_index('f_topics', '#t_description', array('t_description'));
        $GLOBALS['FORUM_DB']->create_index('f_topics', 'descriptionsearch', array('t_description'));
        $GLOBALS['FORUM_DB']->create_index('f_topics', 'forumlayer', array('t_cache_first_title'));
        $GLOBALS['FORUM_DB']->create_index('f_topics', 't_cascading', array('t_cascading'));
        $GLOBALS['FORUM_DB']->create_index('f_topics', 't_cascading_or_forum', array('t_cascading', 't_forum_id'));
        $GLOBALS['FORUM_DB']->create_index('f_topics', 'topic_order', array('t_cascading', 't_pinned', 't_cache_last_time'));
        // Ordering for forumview, is picked up over topic_order_3 for just the ordering bit (it seems)
        $GLOBALS['FORUM_DB']->create_index('f_topics', 'topic_order_2', array('t_forum_id', 't_cascading', 't_pinned', 't_sunk', 't_cache_last_time'));
        // Total index for forumview, including ordering. Doesn't work on current MySQL.
        $GLOBALS['FORUM_DB']->create_index('f_topics', 'topic_order_3', array('t_forum_id', 't_cascading', 't_pinned', 't_cache_last_time'));
        // Total index for forumview, including ordering. Works if disable_sunk is turned on.
        $GLOBALS['FORUM_DB']->create_index('f_topics', 'ownedtopics', array('t_cache_first_member_id'));
        // Welcome topic
        $topic_id = ocf_make_topic($staff_forum_id, '', '', 1, 1, 0, 0, 0, NULL, NULL, false);
        $GLOBALS['FORUM_DB']->create_table('f_posts', array('id' => '*AUTO', 'p_title' => 'SHORT_TEXT', 'p_post' => 'LONG_TRANS', 'p_ip_address' => 'IP', 'p_time' => 'TIME', 'p_poster' => 'USER', 'p_intended_solely_for' => '?USER', 'p_poster_name_if_guest' => 'ID_TEXT', 'p_validated' => 'BINARY', 'p_topic_id' => 'AUTO_LINK', 'p_cache_forum_id' => '?AUTO_LINK', 'p_last_edit_time' => '?TIME', 'p_last_edit_by' => '?USER', 'p_is_emphasised' => 'BINARY', 'p_skip_sig' => 'BINARY', 'p_parent_id' => '?AUTO_LINK'));
        $GLOBALS['FORUM_DB']->create_index('f_posts', 'p_validated', array('p_validated'));
        $GLOBALS['FORUM_DB']->create_index('f_posts', 'in_topic', array('p_topic_id', 'p_time', 'id'));
        $GLOBALS['FORUM_DB']->create_index('f_posts', 'post_order_time', array('p_time', 'id'));
        $GLOBALS['FORUM_DB']->create_index('f_posts', 'p_last_edit_time', array('p_last_edit_time'));
        $GLOBALS['FORUM_DB']->create_index('f_posts', 'posts_by', array('p_poster'));
        $GLOBALS['FORUM_DB']->create_index('f_posts', 'find_pp', array('p_intended_solely_for'));
        $GLOBALS['FORUM_DB']->create_index('f_posts', 'search_join', array('p_post'));
        $GLOBALS['FORUM_DB']->create_index('f_posts', 'postsinforum', array('p_cache_forum_id'));
        $GLOBALS['FORUM_DB']->create_index('f_posts', 'deletebyip', array('p_ip_address'));
    }
    if (is_null($upgrade_from) && $not_installed || !is_null($upgrade_from) && $upgrade_from < 4.0) {
        $GLOBALS['FORUM_DB']->create_table('f_special_pt_access', array('s_member_id' => '*USER', 's_topic_id' => '*AUTO_LINK'));
        $GLOBALS['FORUM_DB']->create_table('f_saved_warnings', array('s_title' => '*SHORT_TEXT', 's_explanation' => 'LONG_TEXT', 's_message' => 'LONG_TEXT'));
    }
    if (is_null($upgrade_from) && $not_installed || $upgrade_from < 2.5) {
        $GLOBALS['FORUM_DB']->create_table('f_post_history', array('id' => '*AUTO', 'h_create_date_and_time' => 'TIME', 'h_action_date_and_time' => 'TIME', 'h_owner_member_id' => 'USER', 'h_alterer_member_id' => 'USER', 'h_post_id' => 'AUTO_LINK', 'h_topic_id' => 'AUTO_LINK', 'h_before' => 'LONG_TEXT', 'h_action' => 'ID_TEXT'));
        $GLOBALS['FORUM_DB']->create_index('f_post_history', 'phistorylookup', array('h_post_id'));
        $GLOBALS['FORUM_DB']->create_table('f_forum_intro_ip', array('i_forum_id' => '*AUTO_LINK', 'i_ip' => '*IP'));
        $GLOBALS['FORUM_DB']->create_table('f_forum_intro_member', array('i_forum_id' => '*AUTO_LINK', 'i_member_id' => '*USER'));
        $GLOBALS['FORUM_DB']->create_table('f_post_templates', array('id' => '*AUTO', 't_title' => 'SHORT_TEXT', 't_text' => 'LONG_TEXT', 't_forum_multi_code' => 'SHORT_TEXT', 't_use_default_forums' => 'BINARY'));
        ocf_make_post_template(do_lang('DEFAULT_POST_TEMPLATE_bug_title'), do_lang('DEFAULT_POST_TEMPLATE_bug_text'), '', 0);
        ocf_make_post_template(do_lang('DEFAULT_POST_TEMPLATE_task_title'), do_lang('DEFAULT_POST_TEMPLATE_task_text'), '', 0);
        ocf_make_post_template(do_lang('DEFAULT_POST_TEMPLATE_fault_title'), do_lang('DEFAULT_POST_TEMPLATE_fault_text'), '', 0);
        $GLOBALS['FORUM_DB']->create_index('f_posts', '#p_title', array('p_title'));
    }
    if (is_null($upgrade_from) && $not_installed) {
        $GLOBALS['FORUM_DB']->create_table('f_polls', array('id' => '*AUTO', 'po_question' => 'SHORT_TEXT', 'po_cache_total_votes' => 'INTEGER', 'po_is_private' => 'BINARY', 'po_is_open' => 'BINARY', 'po_minimum_selections' => 'INTEGER', 'po_maximum_selections' => 'INTEGER', 'po_requires_reply' => 'BINARY'));
        $GLOBALS['FORUM_DB']->create_table('f_poll_answers', array('id' => '*AUTO', 'pa_poll_id' => 'AUTO_LINK', 'pa_answer' => 'SHORT_TEXT', 'pa_cache_num_votes' => 'INTEGER'));
        $GLOBALS['FORUM_DB']->create_table('f_poll_votes', array('pv_poll_id' => '*AUTO_LINK', 'pv_member_id' => '*USER', 'pv_answer_id' => '*AUTO_LINK'));
        $GLOBALS['FORUM_DB']->create_table('f_multi_moderations', array('id' => '*AUTO', 'mm_name' => 'SHORT_TRANS', 'mm_post_text' => 'LONG_TEXT', 'mm_move_to' => '?INTEGER', 'mm_pin_state' => '?BINARY', 'mm_sink_state' => '?BINARY', 'mm_open_state' => '?BINARY', 'mm_forum_multi_code' => 'SHORT_TEXT', 'mm_title_suffix' => 'SHORT_TEXT'));
        ocf_make_multi_moderation(do_lang('TRASH'), '', $trash_forum_id, 0, 0, 0);
        $GLOBALS['FORUM_DB']->create_table('f_warnings', array('id' => '*AUTO', 'w_member_id' => 'USER', 'w_time' => 'TIME', 'w_explanation' => 'LONG_TEXT', 'w_by' => 'USER', 'w_is_warning' => 'BINARY', 'p_silence_from_topic' => '?AUTO_LINK', 'p_silence_from_forum' => '?AUTO_LINK', 'p_probation' => 'INTEGER', 'p_banned_ip' => 'IP', 'p_charged_points' => 'INTEGER', 'p_banned_member' => 'BINARY', 'p_changed_usergroup_from' => '?GROUP'));
        $GLOBALS['FORUM_DB']->create_index('f_warnings', 'warningsmemberid', array('w_member_id'));
        $GLOBALS['FORUM_DB']->create_table('f_moderator_logs', array('id' => '*AUTO', 'l_the_type' => 'ID_TEXT', 'l_param_a' => 'SHORT_TEXT', 'l_param_b' => 'SHORT_TEXT', 'l_date_and_time' => 'TIME', 'l_reason' => 'LONG_TEXT', 'l_by' => 'USER'));
        $GLOBALS['FORUM_DB']->create_table('f_member_known_login_ips', array('i_member_id' => '*USER', 'i_ip' => '*IP', 'i_val_code' => 'SHORT_TEXT'));
        if (strtoupper(ocp_srv('REQUEST_METHOD')) != 'POST') {
            exit;
        }
        // Needed as YSlow can load as GET's in background and cause horrible results
        // NB: post_param's will return default's if OCF is being installed but not used yet (e.g. IPB forum driver chosen at installation)
        // Make guest
        ocf_make_member(do_lang('GUEST'), '', '', NULL, NULL, NULL, NULL, array(), NULL, $guest_group, 1, time(), time(), '', NULL, '', 0, 1, 1, '', '', '', 1, 0, '', 1, 1, '', NULL, '', false);
        // Make admin user
        ocf_make_member(post_param('admin_username', 'admin'), post_param('ocf_admin_password', 'admin'), '', NULL, NULL, NULL, NULL, array(), NULL, $administrator_group, 1, time(), time(), '', 'themes/default/images/ocf_default_avatars/default_set/cool_flare.png', '', 0, 0, 1, '', '', '', 1, 1, '', 1, 1, '', NULL, '', false);
        // Make test user
        ocf_make_member('test', post_param('ocf_admin_password', 'admin'), '', NULL, NULL, NULL, NULL, array(), NULL, $member_group_0, 1, time(), time(), '', NULL, '', 0, 0, 1, '', '', '', 1, 0, '', 1, 1, '', NULL, '', false);
        $GLOBALS['FORUM_DB']->create_table('f_read_logs', array('l_member_id' => '*USER', 'l_topic_id' => '*AUTO_LINK', 'l_time' => 'TIME'));
        $GLOBALS['FORUM_DB']->create_index('f_read_logs', 'erase_old_read_logs', array('l_time'));
        ocf_make_post($topic_id, do_lang('DEFAULT_POST_TITLE'), do_lang('DEFAULT_POST_CONTENT'), 0, true, 1, 0, do_lang('SYSTEM'), '127.0.0.1', time(), $GLOBALS['OCF_DRIVER']->get_guest_id(), NULL, NULL, NULL, false, true);
    }
    // Permissions have to be done after usergroups
    if (is_null($upgrade_from)) {
        // Add privileges
        global $OCF_TRUE_PERMISSIONS, $OCF_FALSE_PERMISSIONS;
        foreach ($OCF_TRUE_PERMISSIONS as $permission) {
            add_specific_permission('SECTION_FORUMS', $permission, true);
        }
        foreach ($OCF_FALSE_PERMISSIONS as $permission) {
            add_specific_permission('SECTION_FORUMS', $permission, false, $permission == 'view_other_pt');
        }
    }
    if (!is_null($upgrade_from) && $upgrade_from < 3.1) {
        add_specific_permission('SECTION_FORUMS', 'use_special_emoticons', false);
    }
    if (!is_null($upgrade_from) && $upgrade_from < 4.0) {
        add_specific_permission('SECTION_FORUMS', 'member_maintenance', false);
        add_specific_permission('SECTION_FORUMS', 'probate_members', false);
        add_specific_permission('SECTION_FORUMS', 'own_avatars', true);
        //add_specific_permission('SECTION_FORUMS','decide_comment_type',true); if we add threads
        add_specific_permission('SECTION_FORUMS', 'control_usergroups', false, true);
        add_specific_permission('SECTION_FORUMS', 'edit_personal_topic_posts', true);
        add_specific_permission('SECTION_FORUMS', 'multi_delete_topics', false);
        add_specific_permission('SECTION_FORUMS', 'show_user_browsing', false);
        add_specific_permission('SECTION_FORUMS', 'see_hidden_groups', false);
        add_specific_permission('SECTION_FORUMS', 'pt_anyone', false);
    }
    if (!is_null($upgrade_from) && $upgrade_from < 3.0) {
        add_specific_permission('SECTION_FORUMS', 'view_profiles', true);
    }
    if (!is_null($upgrade_from) && $upgrade_from < 2.5) {
        add_specific_permission('SECTION_FORUMS', 'moderate_personal_topic', false);
        add_specific_permission('SECTION_FORUMS', 'disable_lost_passwords', false);
        add_specific_permission('SECTION_FORUMS', 'view_any_profile_field', false);
        add_specific_permission('SECTION_FORUMS', 'rename_self', true);
        add_specific_permission('SECTION_FORUMS', 'double_post', false);
        add_specific_permission('SECTION_FORUMS', 'close_own_topics', false);
        add_specific_permission('SECTION_FORUMS', 'edit_own_polls', true);
        add_specific_permission('SECTION_FORUMS', 'warn_members', false);
        add_specific_permission('SECTION_FORUMS', 'see_warnings', false);
        add_specific_permission('SECTION_FORUMS', 'see_ip', false);
        add_specific_permission('SECTION_FORUMS', 'may_choose_custom_title', false);
        add_specific_permission('SECTION_FORUMS', 'delete_account', false);
        add_specific_permission('SECTION_FORUMS', 'view_other_pt', false);
        add_specific_permission('SECTION_FORUMS', 'view_poll_results_before_voting', false);
        add_specific_permission('SECTION_FORUMS', 'may_unblind_own_poll', true);
        delete_specific_permission('enquire_on_new_ips');
    }
}
 /**
  * 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 < 6) {
         $GLOBALS['SITE_DB']->create_table('match_key_messages', array('id' => '*AUTO', 'k_message' => 'LONG_TRANS', 'k_match_key' => 'SHORT_TEXT'));
     }
     if (is_null($upgrade_from) || $upgrade_from < 7) {
         add_specific_permission('STAFF_ACTIONS', 'may_enable_staff_notifications', false);
     }
     if (!is_null($upgrade_from) && $upgrade_from < 5) {
         $new_false_permissions = array('allow_html', 'remove_page_split', 'submit_cat_highrange_content', 'submit_cat_midrange_content', 'submit_cat_lowrange_content', 'edit_cat_highrange_content', 'edit_cat_midrange_content', 'edit_cat_lowrange_content', 'delete_cat_highrange_content', 'delete_cat_midrange_content', 'delete_cat_lowrange_content', 'edit_own_cat_highrange_content', 'edit_own_cat_midrange_content', 'edit_own_cat_lowrange_content', 'delete_own_cat_highrange_content', 'delete_own_cat_midrange_content', 'delete_own_cat_lowrange_content', 'mass_import');
         $false_permissions = get_false_permissions();
         foreach ($false_permissions as $permission) {
             if (in_array($permission[1], $new_false_permissions)) {
                 add_specific_permission($permission[0], $permission[1], false);
             }
         }
     }
     if (is_null($upgrade_from) || $upgrade_from < 4) {
         add_specific_permission('SUBMISSION', 'draw_to_server', false);
     }
     if (is_null($upgrade_from) || $upgrade_from < 3) {
         add_specific_permission('GENERAL_SETTINGS', 'see_unvalidated', false);
     }
     if (is_null($upgrade_from) || $upgrade_from < 2) {
         add_specific_permission('GENERAL_SETTINGS', 'jump_to_unvalidated', true);
     }
     if (!is_null($upgrade_from) && $upgrade_from < 3) {
         $GLOBALS['SITE_DB']->add_table_field('sp_list', 'p_section', 'ID_TEXT');
         // Best to do this here, although permissions table not defined here
         add_specific_permission('SUBMISSION', 'can_submit_to_others_categories', false);
         add_specific_permission('_COMCODE', 'search_engine_links', false);
         add_specific_permission('SUBMISSION', 'have_personal_category', true);
         add_specific_permission('SUBMISSION', 'feature', false);
         add_specific_permission('GENERAL_SETTINGS', 'see_unvalidated', false);
         // Ergh - we need to update every kind of permission that existed before. If they have changed since this jump, they get remapped more than once. One clean step at a time.
         $GLOBALS['SITE_DB']->query('UPDATE ' . get_table_prefix() . 'sp_list SET p_section=\'_COMCODE\' WHERE the_name IN (\'comcode_nuisance\',\'comcode_dangerous\',\'reuse_others_attachments\')');
         $GLOBALS['SITE_DB']->query('UPDATE ' . get_table_prefix() . 'sp_list SET p_section=\'BANNERS\' WHERE the_name IN (\'full_banner_setup\',\'view_anyones_banner_stats\')');
         $GLOBALS['SITE_DB']->query('UPDATE ' . get_table_prefix() . 'sp_list SET p_section=\'IOTDS\' WHERE the_name IN (\'choose_iotd\')');
         $GLOBALS['SITE_DB']->query('UPDATE ' . get_table_prefix() . 'sp_list SET p_section=\'NEWSLETTER\' WHERE the_name IN (\'change_newsletter_subscriptions\')');
         $GLOBALS['SITE_DB']->query('UPDATE ' . get_table_prefix() . 'sp_list SET p_section=\'POINTS\' WHERE the_name IN (\'view_charge_log\',\'give_negative_points\',\'have_negative_gift_points\',\'give_points_self\')');
         $GLOBALS['SITE_DB']->query('UPDATE ' . get_table_prefix() . 'sp_list SET p_section=\'POLLS\' WHERE the_name IN (\'choose_poll\')');
         $GLOBALS['SITE_DB']->query('UPDATE ' . get_table_prefix() . 'sp_list SET p_section=\'SUPPORT_TICKETS\' WHERE the_name IN (\'view_others_tickets\')');
         $GLOBALS['SITE_DB']->query('UPDATE ' . get_table_prefix() . 'sp_list SET p_section=\'SUBMISSION\' WHERE the_name IN (\'submit_highrange_content\',\'submit_midrange_content\',\'submit_lowrange_content\',\'set_own_author_profile\',\'bypass_validation_highrange_content\',\'bypass_validation_midrange_content\',\'bypass_validation_lowrange_content\',\'edit_highrange_content\',\'edit_midrange_content\',\'edit_lowrange_content\',\'edit_own_highrange_content\',\'edit_own_midrange_content\',\'edit_own_lowrange_content\',\'delete_highrange_content\',\'delete_midrange_content\',\'delete_lowrange_content\',\'delete_own_highrange_content\',\'delete_own_midrange_content\',\'delete_own_lowrange_content\')');
         $GLOBALS['SITE_DB']->query('UPDATE ' . get_table_prefix() . 'sp_list SET p_section=\'_FEEDBACK\' WHERE the_name IN (\'rate\',\'comment\')');
         $GLOBALS['SITE_DB']->query('UPDATE ' . get_table_prefix() . 'sp_list SET p_section=\'STAFF_ACTIONS\' WHERE the_name IN (\'access_closed_site\',\'bypass_bandwidth_restriction\',\'see_php_errors\',\'see_stack_dump\',\'view_profiling_modes\',\'access_overrun_site\')');
         $GLOBALS['SITE_DB']->query('UPDATE ' . get_table_prefix() . 'sp_list SET p_section=\'GENERAL_SETTINGS\' WHERE the_name IN (\'jump_to_unvalidated\',\'see_unvalidated\',\'bypass_word_filter\',\'bypass_flood_control\')');
         $GLOBALS['SITE_DB']->query('UPDATE ' . get_table_prefix() . 'sp_list SET p_section=\'SEEDY\' WHERE the_name IN (\'cedi_edit\',\'cedi_manage_tree\',\'cedi_edit_pages\')');
         $GLOBALS['SITE_DB']->query('UPDATE ' . get_table_prefix() . 'sp_list SET p_section=\'FILE_DUMP\' WHERE the_name IN (\'delete_anything_filedump\',\'upload_filedump\',\'upload_anything_filedump\')');
         $GLOBALS['SITE_DB']->query('UPDATE ' . get_table_prefix() . 'sp_list SET p_section=\'SECTION_FORUMS\' WHERE the_name IN (\'run_multi_moderations\',\'vote_in_polls\',\'use_pt\',\'may_report_post\',\'view_member_photos\',\'use_quick_reply\',\'rename_self\',\'view_any_profile_field\',\'disable_lost_passwords\',\'close_own_topics\',\'edit_own_polls\',\'double_post\',\'warn_members\',\'see_warnings\',\'see_ip\',\'may_choose_custom_title\',\'delete_account\',\'view_other_pt\',\'view_poll_results_before_voting\',\'may_unblind_own_poll\',\'moderate_personal_topic\')');
     }
     if (is_null($upgrade_from)) {
         // What usergroups may enter this zone
         $GLOBALS['SITE_DB']->create_table('group_zone_access', array('zone_name' => '*ID_TEXT', 'group_id' => '*GROUP'));
         $GLOBALS['SITE_DB']->create_index('group_zone_access', 'group_id', array('group_id'));
         // Some defaults
         $usergroups = $GLOBALS['FORUM_DRIVER']->get_usergroup_list();
         $admin_groups = array_unique(array_merge($GLOBALS['FORUM_DRIVER']->get_super_admin_groups(), $GLOBALS['FORUM_DRIVER']->get_moderator_groups()));
         $guest_groups = $GLOBALS['FORUM_DRIVER']->get_members_groups($GLOBALS['FORUM_DRIVER']->get_guest_id());
         foreach ($usergroups as $id => $name) {
             $GLOBALS['SITE_DB']->query_insert('group_zone_access', array('zone_name' => '', 'group_id' => $id));
             //$GLOBALS['SITE_DB']->query_insert('group_zone_access',array('zone_name'=>'docs','group_id'=>$id));	Docs are admin only now
             $GLOBALS['SITE_DB']->query_insert('group_zone_access', array('zone_name' => 'forum', 'group_id' => $id));
             if ($id != $guest_groups[0]) {
                 $GLOBALS['SITE_DB']->query_insert('group_zone_access', array('zone_name' => 'site', 'group_id' => $id));
             }
             if ($id != $guest_groups[0]) {
                 $GLOBALS['SITE_DB']->query_insert('group_zone_access', array('zone_name' => 'cms', 'group_id' => $id));
             }
             if ($name == do_lang('SUPER_MEMBERS') || in_array($id, $admin_groups)) {
                 $GLOBALS['SITE_DB']->query_insert('group_zone_access', array('zone_name' => 'collaboration', 'group_id' => $id));
             }
         }
         foreach ($admin_groups as $admin_group) {
             $GLOBALS['SITE_DB']->query_insert('group_zone_access', array('zone_name' => 'adminzone', 'group_id' => $admin_group));
         }
         // What usergroups may NOT view this page (default is that any page may be viewed if a user can access its zone)
         $GLOBALS['SITE_DB']->create_table('group_page_access', array('page_name' => '*ID_TEXT', 'zone_name' => '*ID_TEXT', 'group_id' => '*GROUP'));
         foreach (array_keys($usergroups) as $id) {
             if (get_forum_type() == 'ocf' && !is_guest($id)) {
                 $GLOBALS['SITE_DB']->query_insert('group_page_access', array('page_name' => 'join', 'zone_name' => get_module_zone('join'), 'group_id' => $id));
             }
             $GLOBALS['SITE_DB']->query_insert('group_page_access', array('page_name' => 'admin_redirects', 'zone_name' => 'adminzone', 'group_id' => $id));
             // We don't want people to redirect themselves passed the page/zone security unless they are admins already
             $GLOBALS['SITE_DB']->query_insert('group_page_access', array('page_name' => 'admin_addons', 'zone_name' => 'adminzone', 'group_id' => $id));
             // We don't want people installing new code
             $GLOBALS['SITE_DB']->query_insert('group_page_access', array('page_name' => 'admin_emaillog', 'zone_name' => 'adminzone', 'group_id' => $id));
             // We don't want people snooping on admin emails (e.g. password reset)
         }
         add_specific_permission('SUBMISSION', 'edit_own_lowrange_content', true);
         add_specific_permission('SUBMISSION', 'submit_highrange_content', true);
         add_specific_permission('SUBMISSION', 'submit_midrange_content', true);
         add_specific_permission('SUBMISSION', 'submit_lowrange_content', true);
         add_specific_permission('SUBMISSION', 'bypass_validation_lowrange_content', true);
         add_specific_permission('SUBMISSION', 'set_own_author_profile', true);
         add_specific_permission('_FEEDBACK', 'rate', true);
         add_specific_permission('_FEEDBACK', 'comment', true);
         add_specific_permission('SUBMISSION', 'have_personal_category', true);
         add_specific_permission('POLLS', 'vote_in_polls', true);
         add_specific_permission('_COMCODE', 'use_very_dangerous_comcode', false);
         add_specific_permission('GENERAL_SETTINGS', 'open_virtual_roots', false);
         add_specific_permission('SUBMISSION', 'scheduled_publication_times', false);
         add_specific_permission('SUBMISSION', 'mass_delete_from_ip', false);
         add_specific_permission('SUBMISSION', 'exceed_filesize_limit', false);
         add_specific_permission('GENERAL_SETTINGS', 'view_revision_history', false);
         add_specific_permission('GENERAL_SETTINGS', 'sees_javascript_error_alerts', false);
         add_specific_permission('GENERAL_SETTINGS', 'avoid_simplified_adminzone_look', false, true);
         add_specific_permission('GENERAL_SETTINGS', 'see_software_docs', false);
         $false_permissions = get_false_permissions();
         foreach ($false_permissions as $permission) {
             add_specific_permission($permission[0], $permission[1], false);
         }
     }
 }
Beispiel #17
0
 /**
  * Standard modular install function.
  *
  * @param  ?integer	What version we're upgrading from (NULL: new install)
  * @param  ?integer	What hack version we're upgrading from (NULL: new-install/not-upgrading-from-a-hacked-version)
  */
 function install($upgrade_from = NULL, $upgrade_from_hack = NULL)
 {
     if (is_null($upgrade_from)) {
         $GLOBALS['SITE_DB']->create_table('banners', array('name' => '*ID_TEXT', 'expiry_date' => '?TIME', 'submitter' => 'USER', 'img_url' => 'URLPATH', 'b_title_text' => 'SHORT_TEXT', 'the_type' => 'SHORT_INTEGER', 'caption' => 'SHORT_TRANS', 'campaign_remaining' => 'INTEGER', 'site_url' => 'URLPATH', 'hits_from' => 'INTEGER', 'views_from' => 'INTEGER', 'hits_to' => 'INTEGER', 'views_to' => 'INTEGER', 'importance_modulus' => 'INTEGER', 'notes' => 'LONG_TEXT', 'validated' => 'BINARY', 'add_date' => 'TIME', 'edit_date' => '?TIME', 'b_type' => 'ID_TEXT'));
         $GLOBALS['SITE_DB']->create_index('banners', 'banner_child_find', array('b_type'));
         $GLOBALS['SITE_DB']->create_index('banners', 'the_type', array('the_type'));
         $GLOBALS['SITE_DB']->create_index('banners', 'expiry_date', array('expiry_date'));
         $GLOBALS['SITE_DB']->create_index('banners', 'badd_date', array('add_date'));
         $GLOBALS['SITE_DB']->create_index('banners', 'topsites', array('hits_from', 'hits_to'));
         $GLOBALS['SITE_DB']->create_index('banners', 'campaign_remaining', array('campaign_remaining'));
         $GLOBALS['SITE_DB']->create_index('banners', 'bvalidated', array('validated'));
         $GLOBALS['SITE_DB']->query_insert('banners', array('b_title_text' => '', 'name' => 'advertise_here', 'the_type' => 2, 'img_url' => 'data/images/advertise_here.png', 'caption' => lang_code_to_default_content('ADVERTISE_HERE', true, 1), 'campaign_remaining' => 0, 'site_url' => get_base_url() . '/site/index.php?page=advertise', 'hits_from' => 0, 'views_from' => 0, 'hits_to' => 0, 'views_to' => 0, 'importance_modulus' => 10, 'notes' => 'Provided as default. This is a default banner (it shows when others are not available).', 'validated' => 1, 'add_date' => time(), 'submitter' => $GLOBALS['FORUM_DRIVER']->get_guest_id(), 'b_type' => '', 'expiry_date' => NULL, 'edit_date' => NULL));
         $GLOBALS['SITE_DB']->query_insert('banners', array('b_title_text' => '', 'name' => 'donate', 'the_type' => 0, 'img_url' => 'data/images/donate.png', 'caption' => lang_code_to_default_content('DONATION', true, 1), 'campaign_remaining' => 0, 'site_url' => get_base_url() . '/site/index.php?page=donate', 'hits_from' => 0, 'views_from' => 0, 'hits_to' => 0, 'views_to' => 0, 'importance_modulus' => 30, 'notes' => 'Provided as default.', 'validated' => 1, 'add_date' => time(), 'submitter' => $GLOBALS['FORUM_DRIVER']->get_guest_id(), 'b_type' => '', 'expiry_date' => NULL, 'edit_date' => NULL));
         $banner_a = 'advertise_here';
         $banner_c = 'donate';
         $groups = $GLOBALS['FORUM_DRIVER']->get_usergroup_list(false, true);
         foreach (array_keys($groups) as $group_id) {
             $GLOBALS['SITE_DB']->query_insert('group_category_access', array('module_the_name' => 'banners', 'category_name' => $banner_a, 'group_id' => $group_id));
             $GLOBALS['SITE_DB']->query_insert('group_category_access', array('module_the_name' => 'banners', 'category_name' => $banner_c, 'group_id' => $group_id));
         }
         add_config_option('ENABLE_BANNERS', 'is_on_banners', 'tick', 'return \'1\';', 'FEATURE', 'BANNERS');
         add_config_option('MONEY_AD_CODE', 'money_ad_code', 'text', 'return \'\';', 'FEATURE', 'BANNERS', 1);
         add_config_option('ADVERT_CHANCE', 'advert_chance', 'float', 'return \'5\';', 'FEATURE', 'BANNERS', 1);
         add_specific_permission('BANNERS', 'full_banner_setup', false);
         add_specific_permission('BANNERS', 'view_anyones_banner_stats', false);
         add_config_option('ADD_BANNER', 'points_ADD_BANNER', 'integer', 'return addon_installed(\'points\')?\'0\':NULL;', 'POINTS', 'COUNT_POINTS_GIVEN');
         //add_menu_item_simple('main_website',NULL,'DONATE','_SEARCH:donate');
     }
     if (!is_null($upgrade_from) && $upgrade_from < 3) {
         $GLOBALS['SITE_DB']->add_table_field('banners', 'b_type', 'ID_TEXT');
     }
     if (is_null($upgrade_from) || $upgrade_from < 4) {
         $GLOBALS['SITE_DB']->create_table('banner_types', array('id' => '*ID_TEXT', 't_is_textual' => 'BINARY', 't_image_width' => 'INTEGER', 't_image_height' => 'INTEGER', 't_max_file_size' => 'INTEGER', 't_comcode_inline' => 'BINARY'));
         $GLOBALS['SITE_DB']->create_index('banner_types', 'hottext', array('t_comcode_inline'));
         $GLOBALS['SITE_DB']->query_insert('banner_types', array('id' => '', 't_is_textual' => 0, 't_image_width' => 468, 't_image_height' => 60, 't_max_file_size' => 80, 't_comcode_inline' => 0));
         $GLOBALS['SITE_DB']->create_table('banner_clicks', array('id' => '*AUTO', 'c_date_and_time' => 'TIME', 'c_member_id' => 'USER', 'c_ip_address' => 'IP', 'c_source' => 'ID_TEXT', 'c_banner_id' => 'ID_TEXT'));
         $GLOBALS['SITE_DB']->create_index('banner_clicks', 'clicker_ip', array('c_ip_address'));
         add_specific_permission('BANNERS', 'banner_free', false);
         add_config_option('PERMISSIONS', 'use_banner_permissions', 'tick', 'return \'0\';', 'FEATURE', 'BANNERS');
         $GLOBALS['SITE_DB']->query_update('banners', array('b_type' => 'BANNERS'), array('b_type' => '_BANNERS'));
     }
     if (!is_null($upgrade_from) && $upgrade_from < 4) {
         $GLOBALS['SITE_DB']->add_table_field('banners', 'b_title_text', 'SHORT_TEXT');
     }
     if (is_null($upgrade_from) || $upgrade_from < 5) {
         add_config_option('BANNER_AUTOSIZE', 'banner_autosize', 'tick', 'return is_null($old=get_value(\'banner_autosize\'))?\'0\':$old;', 'FEATURE', 'BANNERS');
         add_config_option('ADMIN_BANNERS', 'admin_banners', 'tick', 'return is_null($old=get_value(\'always_banners\'))?\'0\':$old;', 'FEATURE', 'BANNERS');
     }
 }
Beispiel #18
0
 /**
  * Standard modular install function.
  *
  * @param  ?integer	What version we're upgrading from (NULL: new install)
  * @param  ?integer	What hack version we're upgrading from (NULL: new-install/not-upgrading-from-a-hacked-version)
  */
 function install($upgrade_from = NULL, $upgrade_from_hack = NULL)
 {
     require_lang('calendar');
     if (is_null($upgrade_from)) {
         add_specific_permission('CALENDAR', 'view_calendar', true);
         add_specific_permission('CALENDAR', 'add_public_events', true);
         add_specific_permission('CALENDAR', 'view_personal_events', false, true);
         add_specific_permission('CALENDAR', 'sense_personal_conflicts', false);
         add_specific_permission('CALENDAR', 'view_event_subscriptions', false);
         $GLOBALS['SITE_DB']->create_table('calendar_events', array('id' => '*AUTO', 'e_submitter' => 'USER', 'e_views' => 'INTEGER', 'e_title' => 'SHORT_TRANS', 'e_content' => 'LONG_TRANS', 'e_add_date' => 'TIME', 'e_edit_date' => '?TIME', 'e_recurrence' => 'ID_TEXT', 'e_recurrences' => '?INTEGER', 'e_seg_recurrences' => 'BINARY', 'e_start_year' => 'INTEGER', 'e_start_month' => 'INTEGER', 'e_start_day' => 'INTEGER', 'e_start_hour' => '?INTEGER', 'e_start_minute' => '?INTEGER', 'e_end_year' => '?INTEGER', 'e_end_month' => '?INTEGER', 'e_end_day' => '?INTEGER', 'e_end_hour' => '?INTEGER', 'e_end_minute' => '?INTEGER', 'e_timezone' => 'ID_TEXT', 'e_do_timezone_conv' => 'BINARY', 'e_is_public' => 'BINARY', 'e_priority' => 'INTEGER', 'allow_rating' => 'BINARY', 'allow_comments' => 'SHORT_INTEGER', 'allow_trackbacks' => 'BINARY', 'notes' => 'LONG_TEXT', 'e_type' => 'AUTO_LINK', 'validated' => 'BINARY'));
         $GLOBALS['SITE_DB']->create_index('calendar_events', 'e_views', array('e_views'));
         $GLOBALS['SITE_DB']->create_index('calendar_events', 'ces', array('e_submitter'));
         $GLOBALS['SITE_DB']->create_index('calendar_events', 'publicevents', array('e_is_public'));
         $GLOBALS['SITE_DB']->create_index('calendar_events', 'e_type', array('e_type'));
         $GLOBALS['SITE_DB']->create_index('calendar_events', 'eventat', array('e_start_year', 'e_start_month', 'e_start_day', 'e_start_hour', 'e_start_minute'));
         $GLOBALS['SITE_DB']->create_index('calendar_events', 'e_add_date', array('e_add_date'));
         $GLOBALS['SITE_DB']->create_index('calendar_events', 'validated', array('validated'));
         $GLOBALS['SITE_DB']->create_table('calendar_types', array('id' => '*AUTO', 't_title' => 'SHORT_TRANS', 't_logo' => 'SHORT_TEXT', 't_external_feed' => 'URLPATH'));
         $default_types = array('system_command', 'general', 'birthday', 'public_holiday', 'vacation', 'appointment', 'commitment', 'anniversary');
         foreach ($default_types as $type) {
             $GLOBALS['SITE_DB']->query_insert('calendar_types', array('t_external_feed' => '', 't_title' => lang_code_to_default_content('DEFAULT_CALENDAR_TYPE__' . $type), 't_logo' => 'calendar/' . $type));
         }
         $GLOBALS['SITE_DB']->create_table('calendar_reminders', array('id' => '*AUTO', 'e_id' => 'AUTO_LINK', 'n_member_id' => 'USER', 'n_seconds_before' => 'INTEGER'));
         $GLOBALS['SITE_DB']->create_table('calendar_interests', array('i_member_id' => '*USER', 't_type' => '*AUTO_LINK'));
     }
     if (is_null($upgrade_from) || $upgrade_from < 3) {
         $GLOBALS['SITE_DB']->create_table('calendar_jobs', array('id' => '*AUTO', 'j_time' => 'TIME', 'j_reminder_id' => '?AUTO_LINK', 'j_member_id' => '?USER', 'j_event_id' => 'AUTO_LINK'));
         $GLOBALS['SITE_DB']->create_index('calendar_jobs', 'applicablejobs', array('j_time'));
     }
     if (!is_null($upgrade_from) && $upgrade_from < 3) {
         $GLOBALS['SITE_DB']->alter_table_field('calendar_events', 'e_edit_date', '?TIME');
         $GLOBALS['SITE_DB']->alter_table_field('calendar_events', 'e_end_minute', '?INTEGER');
         $GLOBALS['SITE_DB']->alter_table_field('calendar_events', 'e_end_hour', '?INTEGER');
         $GLOBALS['SITE_DB']->alter_table_field('calendar_events', 'e_end_day', '?INTEGER');
         $GLOBALS['SITE_DB']->alter_table_field('calendar_events', 'e_end_month', '?INTEGER');
         $GLOBALS['SITE_DB']->alter_table_field('calendar_events', 'e_end_year', '?INTEGER');
     }
     if (!is_null($upgrade_from) && $upgrade_from < 4) {
         $GLOBALS['SITE_DB']->add_table_field('calendar_events', 'allow_rating', 'BINARY', 0);
         $GLOBALS['SITE_DB']->add_table_field('calendar_events', 'allow_comments', 'SHORT_INTEGER', 0);
         $GLOBALS['SITE_DB']->add_table_field('calendar_events', 'allow_trackbacks', 'BINARY', 0);
         $GLOBALS['SITE_DB']->add_table_field('calendar_events', 'notes', 'LONG_TEXT');
         $GLOBALS['SITE_DB']->add_table_field('calendar_events', 'validated', 'BINARY', 1);
         delete_specific_permission('edit_owned_events');
         delete_specific_permission('edit_viewable_events');
         add_config_option('ADD_CALENDAR_EVENT', 'points_ADD_CALENDAR_EVENT', 'integer', 'return addon_installed(\'points\')?\'2\':NULL;', 'POINTS', 'COUNT_POINTS_GIVEN');
         $GLOBALS['SITE_DB']->rename_table('calendar_declarations_of_interest', 'calendar_interests');
     }
     if (!is_null($upgrade_from) && $upgrade_from < 5) {
         $GLOBALS['SITE_DB']->add_table_field('calendar_events', 'e_seg_recurrences', 'BINARY', 0);
     }
     if (is_null($upgrade_from) || $upgrade_from < 5) {
         add_config_option('EVENTS', 'calendar_show_stats_count_events', 'tick', 'return addon_installed(\'stats_block\')?\'0\':NULL;', 'BLOCKS', 'STATISTICS');
         add_config_option('_EVENTS_THIS_WEEK', 'calendar_show_stats_count_events_this_week', 'tick', 'return addon_installed(\'stats_block\')?\'0\':NULL;', 'BLOCKS', 'STATISTICS');
         add_config_option('_EVENTS_THIS_MONTH', 'calendar_show_stats_count_events_this_month', 'tick', 'return addon_installed(\'stats_block\')?\'0\':NULL;', 'BLOCKS', 'STATISTICS');
         add_config_option('_EVENTS_THIS_YEAR', 'calendar_show_stats_count_events_this_year', 'tick', 'return addon_installed(\'stats_block\')?\'0\':NULL;', 'BLOCKS', 'STATISTICS');
         $GLOBALS['SITE_DB']->create_index('calendar_events', 'ftjoin_etitle', array('e_title'));
         $GLOBALS['SITE_DB']->create_index('calendar_events', 'ftjoin_econtent', array('e_content'));
     }
     if (!is_null($upgrade_from) && $upgrade_from < 6) {
         $GLOBALS['SITE_DB']->delete_table_field('calendar_events', 'e_geo_position');
         $GLOBALS['SITE_DB']->delete_table_field('calendar_events', 'e_groups_access');
         $GLOBALS['SITE_DB']->delete_table_field('calendar_events', 'e_groups_modify');
         $GLOBALS['SITE_DB']->add_table_field('calendar_events', 'e_timezone', 'ID_TEXT');
         $GLOBALS['SITE_DB']->add_table_field('calendar_events', 'e_do_timezone_conv', 'BINARY');
         $GLOBALS['SITE_DB']->alter_table_field('calendar_events', 'e_start_hour', '?INTEGER');
         $GLOBALS['SITE_DB']->alter_table_field('calendar_events', 'e_start_minute', '?INTEGER');
         $GLOBALS['SITE_DB']->add_table_field('calendar_types', 't_external_feed', 'URLPATH');
     }
     if (is_null($upgrade_from) || $upgrade_from < 6) {
         $admin_groups = $GLOBALS['FORUM_DRIVER']->get_super_admin_groups();
         $groups = $GLOBALS['FORUM_DRIVER']->get_usergroup_list(false, true);
         // Save in permissions for event type
         $types = $GLOBALS['SITE_DB']->query_select('calendar_types');
         foreach ($types as $type) {
             foreach (array_keys($groups) as $group_id) {
                 if (in_array($group_id, $admin_groups)) {
                     continue;
                 }
                 $GLOBALS['SITE_DB']->query_insert('group_category_access', array('module_the_name' => 'calendar', 'category_name' => strval($type['id']), 'group_id' => $group_id));
             }
         }
     }
 }
Beispiel #19
0
 /**
  * Standard modular install function.
  *
  * @param  ?integer	What version we're upgrading from (NULL: new install)
  * @param  ?integer	What hack version we're upgrading from (NULL: new-install/not-upgrading-from-a-hacked-version)
  */
 function install($upgrade_from = NULL, $upgrade_from_hack = NULL)
 {
     require_lang('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');
     }
 }