Database Configurer v1.1.0

Instructions for Installing on osCommerce Online Merchant v2.2ms2 (all releases)


Contents


 

Abstract

This contribution is meant to help contribution uploaders manage the database changes. Create tables, add columns to existing tables, and add configuration groups and items as well as complete removal of all installed items.

Features allow you to setup configuration groups and configuration options and create them using the next configuration group id number. It also allows for adding configuration options to existing configuration groups and also avoid removing groups if not all the items were removed from the group.

It also offers an update option that will refresh the titles and descriptions of configuration options, but not the configuration setting itself. It also allows for a "force" install that will reset all the configuration items to the default installed values.

Database Configurer provides a solution so that contributions can access a convenient test function that will return whether any updates are needed. Features are also available that will determine whether any items have already been setup (partial install or updating needed).


 

Features


 

Screen Shots


(click to enlarge)

(click to enlarge)

(click to enlarge)


 

Support


 

Contribution Link


 

Credits

 

 

Setup Instructions

These setup instructions will be using the contribution Contribution Tracker from time to time as an example project to integrate Database Configurer into.

Database Configurer was designed so that it may be integrated into many contributions without conflict. The main admin page and the language file are common to all installations. The class file contains both data and code to perform all actions necessary (as is the definition of a class). When finished with the setup in your contribution, the class file will be setup and named unique to your contribution.

 

  1. The following files from this Database Configurer will need inclusion into your contribution.
    catalog/admin/configurer.php

    catalog/admin/includes/classes/configurer.php

    catalog/admin/includes/language/(your language)/configurer.php

    catalog/admin/includes/language/(your language)/images/buttons/button_display_updates_only.gif
    catalog/admin/includes/language/(your language)/images/buttons/button_run_configuration_utility.gif
  2. Rename the file in: catalog/admin/includes/classes/configurer.php to be prefixed by the name of the main admin page of your contribution.

    By example, if I were integrating this Database Configurer into the contribution "Contribution Tracker", the main file is contrib_tracker.php. So the renamed class file here would be:
    catalog/admin/includes/classes/contrib_tracker_configurer.php

  3. Find the following block in your newly renamed class file.



    As the comment says, this is the start of the user configuration section. It contains the configuration data for your contribution.


    Just below that comment block you will find:
    1. Change FILENAME_MY_CONTRIBUTION to the similar definition you created for catalog/admin/includes/filenames.php that refers to the main page of your contribution.

  4. Now we will setup your contribution's name and version number.


    Just below the last step you will see the following array definition:
    1. Update the 'My Contribution' field to the name of your contribution.
    2. Update the '1.0.0' field to the current version of your contribution.
    3. Update the 'MY_CONTRIBUTION_VERSION' field. Change the MY_CONTRIBUTION portion to refer to your contribution. This will become the configuration key to the version of your contribution that is stored in the database for future lookup.

  5. The next section handles setting Configuration Items in the database. The first group is required to set the Version Number necessary for version control.


    osCommerce Configuration Items:
    1. Update the 'MY_CONTRIBUTION_VERSION' field in the "group 1" section. Change the MY_CONTRIBUTION portion to refer to your contribution. This is the configuration key of the version number of your contribution.
      ** This key must be the same key name you used in Step 4.3.

      The following key is 'CONFIGURATION_KEY' and is an example that was commented. If you would like to add another configuration key to this group, uncomment the following block and make necessary changes. The Module Options configuration group is hidden from users in the osCommerce Admin. This group should only be used for config items that are set and used internally by your contribution that the user will never see.

    2. Group 2 is also commented and is an example of how to add additional configuration groups and associated configuration options. You can add as many groups and configuration items are you need and Database Configurer will ensure they are installed or updated in the user's database.
      ** Make sure you are careful about uncommenting the groups. Start comment tags: /* are placed before the comma that separates the array blocks.


  6. The next section handles setting up new tables in the database. You may setup tables in one version and later, as your contribution develops, correct and add features to the table. The Database Configurer will NOT update the existing tables in your user's database based on these table definitions. You should update these new table definitions as needed, and then also add column definitions (described below) in that section to ensure users that upgrade will get the new columns.
    • The first table example does not have data to insert after it is created.
    • The second table definition, which is commented, adds inserts to the table defined by the 'insert' key. You may use the insert to populate tables with static data or example data for the users of your contribution.


    New Table Definitions

  7. The next section handles altering tables to add new columns. They can be additions to pre-existing tables or to tables your contribution installs. You may, and should, change the column definitions here to keep up with changes in your contribution. But as with the tables, if you update these columns in the future, Database Configurer will not make updates to your user's databases based on changes here. If you change the column definitions here in the future, you must add SQL to the Version Changes that will update your user's installations.


    Columns to Alter Tables

  8. The next section handles SQL database update based on versions. Each time you create a new version that needs database changes beyond the usefulness of the Configuration Options, Table Definitions, and Column Additions, you add a new array to this section with your current version number as the key, and add the necessary SQL commands. This section is very useful to move data around, change columns, change column sizes or types, add additional data via inserts, and much more.


    Define Additional Version Based Updates

  9. Now we will add the code to your contribution's main page that will check the status of the installation and apply updates to the database or redirect the user to the Database Configurer admin page to apply changes themselves.


  10. In this step you will add a button to your contribution's main page that allows your users to access the Database Configurer's Admin Page to update their configuration or remove your contribution's settings.

    I would suggest placing this link under the right sidebar typically found in osCommerce admin pages.


    Include this anywhere you would like the Database Configurer admin button:


  11. You can add this to your installation instructions that will direct the user to the configuration page prior to running your contribution's main page the first time.

    This link will show the Database Configurer's admin page.

    ** Be sure to change (your_contrib) in the link above with page name or your contribution's main page, without the .php extension.

    This link will show the Database Configurer's admin page and display all SQL commands that need to be executed to update their database.

    ** Be sure to change (your_contrib) in the link above with page name or your contribution's main page, without the .php extension.



 

Advanced

Here are a few additional options that may help you with integration.

** Remember, in all the following examples, be sure to change FILENAME_MY_CONTRIBUTION to the similar definition you created for catalog/admin/includes/filenames.php that refers to the main page of your contribution.

 

Finished !