/**
  * Load the contents of the schema into the database and then alter it based on what has been input during the installation
  */
 function load_schema($mode, $sub)
 {
     global $cache, $gallery_config, $phpbb_root_path, $phpEx, $template, $user;
     include $phpbb_root_path . 'includes/acp/auth.' . $phpEx;
     $this->page_title = $user->lang['STAGE_CREATE_TABLE'];
     $s_hidden_fields = '';
     $dbms_data = get_dbms_infos();
     $db_schema = $dbms_data['db_schema'];
     $delimiter = $dbms_data['delimiter'];
     // Create the tables
     nv_create_table('phpbb_gallery_albums', $dbms_data);
     nv_create_table('phpbb_gallery_albums_track', $dbms_data);
     nv_create_table('phpbb_gallery_comments', $dbms_data);
     nv_create_table('phpbb_gallery_config', $dbms_data);
     nv_create_table('phpbb_gallery_contests', $dbms_data);
     nv_create_table('phpbb_gallery_favorites', $dbms_data);
     nv_create_table('phpbb_gallery_images', $dbms_data);
     nv_create_table('phpbb_gallery_modscache', $dbms_data);
     nv_create_table('phpbb_gallery_permissions', $dbms_data);
     nv_create_table('phpbb_gallery_rates', $dbms_data);
     nv_create_table('phpbb_gallery_reports', $dbms_data);
     nv_create_table('phpbb_gallery_roles', $dbms_data);
     nv_create_table('phpbb_gallery_users', $dbms_data);
     nv_create_table('phpbb_gallery_watch', $dbms_data);
     // Create columns
     nv_add_column(SESSIONS_TABLE, 'session_album_id', array('UINT', 0));
     nv_add_column(LOG_TABLE, 'album_id', array('UINT', 0));
     nv_add_column(LOG_TABLE, 'image_id', array('UINT', 0));
     nv_add_index(GALLERY_USERS_TABLE, 'pg_palbum_id', array('personal_album_id'));
     nv_add_index(SESSIONS_TABLE, 'session_aid', array('session_album_id'));
     // Set default config
     set_default_config();
     $auth_admin = new auth_admin();
     $auth_admin->acl_add_option(array('local' => array(), 'global' => array('a_gallery_manage', 'a_gallery_albums', 'a_gallery_import', 'a_gallery_cleanup')));
     $cache->destroy('acl_options');
     $template->assign_vars(array('BODY' => $user->lang['STAGE_CREATE_TABLE_EXPLAIN'], 'L_SUBMIT' => $user->lang['NEXT_STEP'], 'S_HIDDEN' => '', 'U_ACTION' => append_sid("{$phpbb_root_path}install/index.{$phpEx}", "mode={$mode}&sub=in_progress")));
 }
예제 #2
0
 /**
  * Add some Tables, Columns and Index to the database-schema
  */
 function update_db_schema($mode, $sub)
 {
     global $db, $user, $template, $table_prefix;
     global $phpbb_root_path, $phpEx;
     $this->page_title = $user->lang['STAGE_UPDATE_DB'];
     $phpbb_gallery_version = get_gallery_version();
     phpbb_gallery_config::set('version', $phpbb_gallery_version);
     $dbms_data = get_dbms_infos();
     $db_schema = $dbms_data['db_schema'];
     $delimiter = $dbms_data['delimiter'];
     switch (phpbb_gallery_config::get('version')) {
         case '0.1.2':
         case '0.1.3':
         case '0.2.0':
         case '0.2.1':
         case '0.2.2':
         case '0.2.3':
         case '0.3.0':
         case '0.3.1':
         case '0.3.2-RC1':
         case '0.3.2-RC2':
         case '0.4.0-RC1':
         case '0.4.0-RC2':
         case '0.4.0-RC3':
         case '0.4.0':
             trigger_error('VERSION_NOT_SUPPORTED', E_USER_ERROR);
             break;
         case '0.4.1':
             nv_add_column(GALLERY_ALBUMS_TABLE, 'album_contest', array('UINT', 0));
             nv_add_column(GALLERY_IMAGES_TABLE, 'filesize_upload', array('UINT:20', 0));
             nv_add_column(GALLERY_IMAGES_TABLE, 'filesize_medium', array('UINT:20', 0));
             nv_add_column(GALLERY_IMAGES_TABLE, 'filesize_cache', array('UINT:20', 0));
             nv_add_column(GALLERY_IMAGES_TABLE, 'image_contest', array('UINT:1', 0));
             nv_add_column(GALLERY_IMAGES_TABLE, 'image_exif_data', array('TEXT', ''));
             nv_change_column(GALLERY_PERMISSIONS_TABLE, 'perm_system', array('INT:3', 0));
             nv_create_table('phpbb_gallery_contests', $dbms_data);
         case '0.5.0':
             nv_add_column(GALLERY_ALBUMS_TABLE, 'album_status', array('UINT:1', 0));
             nv_add_column(GALLERY_ALBUMS_TABLE, 'display_in_rrc', array('UINT:1', 1));
             nv_add_column(GALLERY_IMAGES_TABLE, 'image_contest_end', array('TIMESTAMP', 0));
             nv_add_column(GALLERY_IMAGES_TABLE, 'image_contest_rank', array('UINT:3', 0));
         case '0.5.1':
         case '0.5.2':
             nv_create_table('phpbb_gallery_albums_track', $dbms_data);
             nv_add_column(GALLERY_USERS_TABLE, 'user_lastmark', array('TIMESTAMP', 0));
         case '0.5.3':
             nv_add_column(LOG_TABLE, 'album_id', array('UINT', 0));
             nv_add_column(LOG_TABLE, 'image_id', array('UINT', 0));
         case '0.5.4':
         case '1.0.0-dev':
             nv_add_column(GALLERY_ROLES_TABLE, 'i_unlimited', array('UINT:3', 0));
             nv_add_column(GALLERY_ROLES_TABLE, 'album_unlimited', array('UINT:3', 0));
         case '1.0.0-RC1':
         case '1.0.0-RC2':
         case '1.0.0':
         case '1.0.1-dev':
             nv_add_column(GALLERY_IMAGES_TABLE, 'image_name_clean', array('VCHAR:255', ''));
             nv_add_column(GALLERY_IMAGES_TABLE, 'image_username_clean', array('VCHAR:255', ''));
         case '1.0.1':
         case '1.0.2-dev':
         case '1.0.2-RC1':
         case '1.0.2':
         case '1.0.3-RC1':
         case '1.0.3-RC2':
         case '1.0.3':
         case '1.0.4':
             nv_add_column(GALLERY_ALBUMS_TABLE, 'album_watermark', array('UINT:1', 1));
             nv_add_column(GALLERY_ALBUMS_TABLE, 'album_sort_key', array('VCHAR:8', ''));
             nv_add_column(GALLERY_ALBUMS_TABLE, 'album_sort_dir', array('VCHAR:8', ''));
             nv_add_column(GALLERY_USERS_TABLE, 'user_viewexif', array('UINT:1', 0));
         case '1.0.5-RC1':
             // Only allow update from 1.0.5
             trigger_error('VERSION_NOT_SUPPORTED', E_USER_ERROR);
             break;
         case '1.0.5':
             nv_add_column(GALLERY_USERS_TABLE, 'user_permissions', array('MTEXT', ''));
             nv_add_column(GALLERY_USERS_TABLE, 'user_last_update', array('TIMESTAMP', 0));
             break;
     }
     $template->assign_vars(array('BODY' => $user->lang['STAGE_CREATE_TABLE_EXPLAIN'], 'L_SUBMIT' => $user->lang['NEXT_STEP'], 'S_HIDDEN' => '', 'U_ACTION' => append_sid("{$phpbb_root_path}install/index.{$phpEx}", "mode={$mode}&sub=update_db&step=2")));
 }