Setup Script

The file pedserve-hook-setup.pl contains setup code that is called once, early in the initialization of every Pedserve script. This is your place to add in initializations of things like user-defined fields, record types, display field selector options, etc.

You dont have to make any changes to this file if you dont want to. But in practice, most users will want to change this file as it is key to customizing many of the important aspects of the system.

As supplied, pedserve-hook-setup.pl looks something like this:

Show/Hide Sample Code

# Copyright (C) 2007, Tenset Technologies Ltd.
# This file is part of the Pedserve Online Pedigree Database system, Advanced Edition. All rights reserved.
#
# You may not copy, publish, license, sell, distribute, transmit, display, perform, 
# modify, reproduce, transfer or create derivative works from this file 
# except without prior written permission of Tenset Technologies Ltd. 
#
# You may not alter or remove any trademark, copyright or other notice from this file
# or from any web page content (HTML) that is generated by program logic in this file.
#
use warnings;
no  warnings qw(once);
use strict;
use DBI;
use CGI;
use CGI::Carp;
use CGI::Carp qw(fatalsToBrowser);

# ----------------------------------------------------------------------------------------
# AUXILLIARY TABLE NAMES: DECLARE THE NAMES OF AUXILLIARY TABLES HERE
#
# NOTE: Aux tables must be declared (using pdsSetAuxRecordType) BEFORE you call pretty
#       much anything else, because many of the other functions called from this setup
#       script need to know which aux tables exist.
#       BUT all other aspects of auxilliary record setup need to come AFTER other
#       pdsHookStdImpl_Setup_..() calls. E.g. &pdsSetAuxQueryDef() requires the animal
#       records query definition to be set up first.
#
#       So stick to the ordering of pdsSetAux... calls shown here.
# ----------------------------------------------------------------------------------------

# ----------------------------------------------------------------------------------------
# STANDARD FIELDS: ADD FIELD CONFIGURATIONS
# ----------------------------------------------------------------------------------------
&pdsHookStdImpl_Setup_AddFieldDefs();

# ----------------------------------------------------------------------------------------
# USER DEFINED FIELDS: ADD FIELD CONFIGURATIONS
# ----------------------------------------------------------------------------------------

# ----------------------------------------------------------------------------------------
# USER DEFINED FIELDS: DECLARE COMBINATIONS OF FIELDS THAT ARE TO BE USED IN DIFFERENT SITUATIONS
# ----------------------------------------------------------------------------------------

# ----------------------------------------------------------------------------------------
# USER DEFINED FIELDS: ADDITIONAL RECORD ORDERINGS
# ----------------------------------------------------------------------------------------

# ----------------------------------------------------------------------------------------
# ADD QUERY DEFINITIONS
# ----------------------------------------------------------------------------------------
&pdsHookStdImpl_Setup_AddQueryDefs();

# ----------------------------------------------------------------------------------------
# ADD ORDERING DEFINITIONS
# ----------------------------------------------------------------------------------------
&pdsHookStdImpl_Setup_AddOrderingDefs();

# ----------------------------------------------------------------------------------------
# ADD HIGHLIGHTING DEFINITIONS
# ----------------------------------------------------------------------------------------
&pdsHookStdImpl_Setup_AddHighlightingDefs();

# ----------------------------------------------------------------------------------------
# ADD DISPLAY FIELDS DEFINITIONS
# ----------------------------------------------------------------------------------------
&pdsHookStdImpl_Setup_AddDisplayFldsDefs();

# ----------------------------------------------------------------------------------------
# ADD PLATE DEFINITIONS
# ----------------------------------------------------------------------------------------
&pdsHookStdImpl_Setup_AddPlateDefs();

# ----------------------------------------------------------------------------------------
# ADD DERIVED RECORDS DEFINITIONS
# ----------------------------------------------------------------------------------------
&pdsHookStdImpl_Setup_AddDerivedRecordsDefs();


# ----------------------------------------------------------------------------------------
# AUXILLIARY TABLES
#
# NOTE: All setup for aux tables should be done here, EXCEPT calls to &pdsSetAuxRecordType()
#       which should be made earlier in this file. See comments above.
# ----------------------------------------------------------------------------------------

To see an example of a custom setup script, click the following button. This shows the addition of a user-defined record type (show records), the enabling of similarity searches for the animal name field, and the addition of user-defined field types for both the animal and users table (including custom search results orderings based on these fields).

Show/Hide Sample Code

#!/usr/bin/perl

# Copyright (C) 2007, Tenset Technologies Ltd.
# This file is part of the Pedserve Online Pedigree Database system, Advanced Edition.
# All rights reserved.
#
# You may not copy, publish, license, sell, distribute, transmit, display, perform, 
# modify, reproduce, transfer or create derivative works from this file 
# except without prior written permission of Tenset Technologies Ltd. 
#
# You may not alter or remove any trademark, copyright or other notice from this file
# or from any web page content (HTML) that is generated by program logic in this file.
#
use warnings;
no  warnings qw(once);
use strict;
use DBI;
use CGI;
use CGI::Carp;
use CGI::Carp qw(fatalsToBrowser);


# ----------------------------------------------------------------------------------------
# AUXILLIARY TABLE NAMES: DECLARE THE NAMES OF AUXILLIARY TABLES HERE
#
# NOTE: Aux tables must be declared (using pdsSetAuxRecordType) BEFORE you call pretty
#       much anything else, because many of the other functions called from this setup
#       script need to know which aux tables exist.
#       BUT all other aspects of auxilliary record setup need to come AFTER other
#       pdsHookStdImpl_Setup_..() calls. E.g. &pdsSetAuxQueryDef() requires the animal
#       records query definition to be set up first.
#
#       So stick to the ordering of pdsSetAux... calls shown here.
# ----------------------------------------------------------------------------------------
&pdsSetAuxRecordType('XSR', 'Show Record', 'Show Records');

# ----------------------------------------------------------------------------------------
# STANDARD FIELDS: ADD FIELD CONFIGURATIONS
# ----------------------------------------------------------------------------------------
&pdsHookStdImpl_Setup_AddFieldDefs();
# Enable similarity searches for the animal name field:
&pdsAlterFldDef('A_NAME', {'qopts' => 'fs'});

# ----------------------------------------------------------------------------------------
# USER DEFINED FIELDS: ADD FIELD CONFIGURATIONS
# ----------------------------------------------------------------------------------------
# Animals table:
&pdsSetFldDef('A_REG', 'type=str;group=core;label=Reg.;dbsize=20;indexvalueatback=;');
&pdsSetFldDef('A_BREEDER', 'type=str;group=breederowner;label=Breeder;dbsize=40;qopts=f;indexvalueatback=;');
&pdsSetFldDef('A_OWNER', 'type=str;group=breederowner;label=Owner;dbsize=40;qopts=f;indexvalueatback=;');
&pdsSetFldDef('A_HIPS', 'type=str;group=core;label=Hips;dbsize=20;indexvalueatback=;');
&pdsSetFldDef('A_BRS', 'type=str;group=core;label=BRS;dbsize=20;indexvalueatback=;');
# User table:
&pdsSetFldDef('U_AFFIX', 'type=str;label=Affix;dbsize=40;indexvalueatback=;');

# ----------------------------------------------------------------------------------------
# USER DEFINED FIELDS: DECLARE COMBINATIONS OF FIELDS THAT ARE TO BE USED IN DIFFERENT SITUATIONS
# ----------------------------------------------------------------------------------------
# Animals table:
&pdsSetUserDefinedFlds('A', '@', 'A_REG,A_BRS,A_HIPS');
&pdsSetUserDefinedFlds('A', 'alldisplay', 'A_REG,A_BRS,A_HIPS,A_BREEDER,A_OWNER');
&pdsSetUserDefinedFlds('A', 'advancedquery', 'A_REG,A_BRS,A_HIPS,A_BREEDER,A_OWNER');
&pdsSetUserDefinedFlds('A', 'basicquery', '');
&pdsSetUserDefinedFlds('A', 'submit', 'A_REG,A_BRS,A_HIPS,A_BREEDER,A_OWNER');
# User table:
&pdsSetUserDefinedFlds('U', '@', 'U_AFFIX');
&pdsSetUserDefinedFlds('U', 'submit', 'U_AFFIX');
&pdsSetUserDefinedFlds('U', 'user', 'U_AFFIX');
&pdsSetUserDefinedFlds('U', 'useredit', 'U_AFFIX');
&pdsSetUserDefinedFlds('U', 'admin', 'U_AFFIX');
&pdsSetUserDefinedFlds('U', 'adminedit', 'U_AFFIX');

# ----------------------------------------------------------------------------------------
# USER DEFINED FIELDS: ADDITIONAL RECORD ORDERINGS
# ----------------------------------------------------------------------------------------
# Animals table:
&pdsSetOrderingDef('A_ureg',
        'fields='.&pdsCombineOrderingFlds('A_REG', &pdsGetStdSecondaryOrderingFlds('A')));
&pdsSetOrderingDef('A_ubreeder', 
        'fields='.&pdsCombineOrderingFlds('A_BREEDER', &pdsGetStdSecondaryOrderingFlds('A')));
&pdsSetOrderingDef('A_uowner', 
        'fields='.&pdsCombineOrderingFlds('A_OWNER', &pdsGetStdSecondaryOrderingFlds('A')));
&pdsSetOrderingDef('A_uhips', 
        'fields='.&pdsCombineOrderingFlds('A_HIPS', &pdsGetStdSecondaryOrderingFlds('A')));
&pdsSetOrderingDef('A_ubrs', 
        'fields='.&pdsCombineOrderingFlds('A_BRS', &pdsGetStdSecondaryOrderingFlds('A')));
# User table:
&pdsSetOrderingDef('U_uaffix', 
        'fields='.&pdsCombineOrderingFlds('U_AFFIX', &pdsGetStdSecondaryOrderingFlds('U')));

# ----------------------------------------------------------------------------------------
# ADD QUERY DEFINITIONS
# ----------------------------------------------------------------------------------------
&pdsHookStdImpl_Setup_AddQueryDefs();

# ----------------------------------------------------------------------------------------
# ADD ORDERING DEFINITIONS
# ----------------------------------------------------------------------------------------
&pdsHookStdImpl_Setup_AddOrderingDefs();

# ----------------------------------------------------------------------------------------
# ADD HIGHLIGHTING DEFINITIONS
# ----------------------------------------------------------------------------------------
&pdsHookStdImpl_Setup_AddHighlightingDefs();

# ----------------------------------------------------------------------------------------
# ADD DISPLAY FIELDS DEFINITIONS
# ----------------------------------------------------------------------------------------
&pdsHookStdImpl_Setup_AddDisplayFldsDefs();

# ----------------------------------------------------------------------------------------
# ADD PLATE DEFINITIONS
# ----------------------------------------------------------------------------------------
&pdsHookStdImpl_Setup_AddPlateDefs();

# ----------------------------------------------------------------------------------------
# ADD DERIVED RECORDS DEFINITIONS
# ----------------------------------------------------------------------------------------
&pdsHookStdImpl_Setup_AddDerivedRecordsDefs();

# ----------------------------------------------------------------------------------------
# AUXILLIARY TABLES
#
# NOTE: All setup for aux tables should be done here, EXCEPT calls to
#       &pdsSetAuxRecordType() which should be made earlier in this file.
#       See comments above.
# ----------------------------------------------------------------------------------------
# Add in auxilliary table for Show Records
&pdsSetAuxMaxHitsPerPage('XSR', 50);
&pdsSetAuxDefaultSearchMode('XSR', 'b');

&pdsSetFldDef('XSR_DATE', 'type=date;label=Date of Show;naturalordering=desc');
&pdsSetFldDef('XSR_SHOWNAME', 'type=str;label=Show Name;qopts=f;indexvalueatback=;');
&pdsSetFldDef('XSR_SHOWKIND', 'type=str;label=Kind of Show;qopts=f;indexvalueatback=;');
&pdsSetFldDef('XSR_SHOWORGANISER', 'type=str;label=Show Organizer;qopts=f;indexvalueatback=;');
&pdsSetFldDef('XSR_SHOWSTATUS', 'type=str;label=Show Status;indexvalueatback=;');
&pdsSetFldDef('XSR_CLASSNAME', 'type=str;label=Class Name;qopts=f;indexvalueatback=;');
&pdsSetFldDef('XSR_CLASSNO', 'type=str;label=Class#;indexvalueatback=;');
&pdsSetFldDef('XSR_CLASSSEX', 'type=str;label=Class Sex;indexvalueatback=;');
&pdsSetFldDef('XSR_NUMENTERED', 'type=int;subtype=count;hidevalue=0;label=#Entered');
&pdsSetFldDef('XSR_NUMSHOWN', 'type=int;subtype=count;hidevalue=0;label=#Shown');
&pdsSetFldDef('XSR_JUDGE', 'type=str;label=Judge;qopts=f;isdefaultqueryfield=1;indexvalueatback=;');
&pdsSetFldDef('XSR_PLACING', 'type=str;label=Placing;indexvalueatback=;');
&pdsSetFldDef('XSR_CC', 'type=flag;label=CC');
&pdsSetFldDef('XSR_RCC', 'type=flag;label=RCC');
&pdsSetFldDef('XSR_BOB', 'type=flag;label=BOB');
&pdsSetFldDef('XSR_RBOB', 'type=flag;label=RBOB');
&pdsSetFldDef('XSR_BIS', 'type=flag;label=BIS');
&pdsSetFldDef('XSR_RBIS', 'type=flag;label=RBIS');
&pdsSetFldDef('XSR_BOS', 'type=flag;label=BOS');
&pdsSetFldDef('XSR_BP', 'type=flag;label=BP');
&pdsSetFldDef('XSR_BPIB', 'type=flag;label=BPIB');
&pdsSetFldDef('XSR_RBPIB', 'type=flag;label=RBPIB');
&pdsSetFldDef('XSR_BV', 'type=flag;label=BV');
&pdsSetFldDef('XSR_RBV', 'type=flag;label=RBV');
&pdsSetFldDef('XSR_OTHERAWARDS', 'type=str;label=Other Awards;indexvalueatback=;');

# Query Definition:
&pdsSetAuxQueryDef('XSR',  'basicfields=XSR_SHOWNAME,XSR_JUDGE;fields=XSR_DATE,XSR_SHOWNAME,'
                              .'XSR_SHOWKIND,XSR_SHOWORGANISER,XSR_SHOWSTATUS,XSR_CLASSNAME,'
                                                          .'XSR_CLASSNO,XSR_CLASSSEX,XSR_NUMENTERED,XSR_NUMSHOWN,XSR_JUDGE,'
                                                          .'XSR_PLACING,XSR_CC,XSR_RCC,XSR_BOB,XSR_RBOB,XSR_BIS,XSR_RBIS,'
                                                          .'XSR_BOS,XSR_BP,XSR_BPIB,XSR_RBPIB,XSR_BV,XSR_RBV,XSR_OTHERAWARDS;');

# Display Definitions:
# NOTE: this must include a <tablesuffix>_all entry, as its needed by 
# the aux record details screen:
&pdsSetAuxDisplayFldsDef('XSR', 'XSR_basic',
                              'label=Basic Details;fields1=;fields2=XSR_DATE,XSR_SHOWNAME,'
                                                         .'XSR_CLASSNAME,XSR_CLASSSEX,XSR_NUMENTERED,XSR_NUMSHOWN,XSR_JUDGE,'
                                                         .'XSR_PLACING,XSR_CC,XSR_BOB');
&pdsSetAuxDisplayFldsDef('XSR', 'XSR_all', 
                              'label=All Details;fields1=;fields2=XSR_DATE,XSR_SHOWNAME,'
                                                         .'XSR_SHOWKIND,XSR_SHOWORGANISER,XSR_SHOWSTATUS,XSR_CLASSNAME,'
                                                         .'XSR_CLASSNO,XSR_CLASSSEX,XSR_NUMENTERED,XSR_NUMSHOWN,XSR_JUDGE,'
                                                         .'XSR_PLACING,XSR_CC,XSR_RCC,XSR_BOB,XSR_RBOB,XSR_BIS,XSR_RBIS,'
                                                         .'XSR_BOS,XSR_BP,XSR_BPIB,XSR_RBPIB,XSR_BV,XSR_RBV,XSR_OTHERAWARDS');
&pdsSetAuxDefaultDisplayFldsKey('XSR', 'XSR_basic');

# Ordering Definitions:
&pdsSetStdSecondaryOrderingFlds('XSR', 'XSR_AID.A_NAME,XSR_DATE:desc-1');
{
   my $strSecondaryFlds = &pdsGetStdSecondaryOrderingFlds('XSR');
   &pdsSetAuxOrderingDef('XSR', 'XSR_o1', 
                             'fields='.&pdsCombineOrderingFlds('XSR_SHOWNAME', $strSecondaryFlds));
   &pdsSetAuxOrderingDef('XSR', 'XSR_o2', 
                             'fields='.&pdsCombineOrderingFlds('XSR_DATE', $strSecondaryFlds));
   &pdsSetAuxOrderingDef('XSR', 'XSR_o3_d', 
                             'fields='.&pdsCombineOrderingFlds('XSR_DATE:desc-1', $strSecondaryFlds));
   &pdsSetAuxOrderingDef('XSR', 'XSR_o4', 
                             'fields='.&pdsCombineOrderingFlds('XSR_NUMENTERED:desc-1', $strSecondaryFlds));
   &pdsSetAuxOrderingDef('XSR', 'XSR_o5', 
                             'fields='.&pdsCombineOrderingFlds('XSR_NUMSHOWN:desc-1', $strSecondaryFlds));
   &pdsSetAuxOrderingDef('XSR', 'XSR_o6', 
                             'fields='.&pdsCombineOrderingFlds('XSR_SHOWKIND', $strSecondaryFlds));
   &pdsSetAuxOrderingDef('XSR', 'XSR_o7', 
                             'fields='.&pdsCombineOrderingFlds('XSR_SHOWORGANISER', $strSecondaryFlds));
   &pdsSetAuxOrderingDef('XSR', 'XSR_o8', 
                             'fields='.&pdsCombineOrderingFlds('XSR_SHOWSTATUS', $strSecondaryFlds));
   &pdsSetAuxOrderingDef('XSR', 'XSR_o9', 
                             'fields='.&pdsCombineOrderingFlds('XSR_CLASSNAME', $strSecondaryFlds));
   &pdsSetAuxOrderingDef('XSR', 'XSR_o10', 
                             'fields='.&pdsCombineOrderingFlds('XSR_CLASSNO', $strSecondaryFlds));
   &pdsSetAuxOrderingDef('XSR', 'XSR_o11', 
                             'fields='.&pdsCombineOrderingFlds('XSR_CLASSSEX', $strSecondaryFlds));
   &pdsSetAuxOrderingDef('XSR', 'XSR_o12', 
                             'fields='.&pdsCombineOrderingFlds('XSR_JUDGE', $strSecondaryFlds));
   &pdsSetAuxOrderingDef('XSR', 'XSR_o13', 
                             'fields='.&pdsCombineOrderingFlds('XSR_PLACING', $strSecondaryFlds));
   &pdsSetAuxOrderingDef('XSR', 'XSR_o14', 
                             'fields='.&pdsCombineOrderingFlds('XSR_CC', $strSecondaryFlds));
   &pdsSetAuxOrderingDef('XSR', 'XSR_o15', 
                             'fields='.&pdsCombineOrderingFlds('XSR_RCC', $strSecondaryFlds));
   &pdsSetAuxOrderingDef('XSR', 'XSR_o16', 
                             'fields='.&pdsCombineOrderingFlds('XSR_BOB', $strSecondaryFlds));
   &pdsSetAuxOrderingDef('XSR', 'XSR_o17', 
                             'fields='.&pdsCombineOrderingFlds('XSR_RBOB', $strSecondaryFlds));
   &pdsSetAuxOrderingDef('XSR', 'XSR_o18', 
                             'fields='.&pdsCombineOrderingFlds('XSR_BIS', $strSecondaryFlds));
   &pdsSetAuxOrderingDef('XSR', 'XSR_o19', 
                             'fields='.&pdsCombineOrderingFlds('XSR_RBIS', $strSecondaryFlds));
   &pdsSetAuxOrderingDef('XSR', 'XSR_o20', 
                             'fields='.&pdsCombineOrderingFlds('XSR_BOS', $strSecondaryFlds));
   &pdsSetAuxOrderingDef('XSR', 'XSR_o21', 
                             'fields='.&pdsCombineOrderingFlds('XSR_BP', $strSecondaryFlds));
   &pdsSetAuxOrderingDef('XSR', 'XSR_o22', 
                             'fields='.&pdsCombineOrderingFlds('XSR_BPIB', $strSecondaryFlds));
   &pdsSetAuxOrderingDef('XSR', 'XSR_o23', 
                             'fields='.&pdsCombineOrderingFlds('XSR_RBPIB', $strSecondaryFlds));
   &pdsSetAuxOrderingDef('XSR', 'XSR_o24', 
                             'fields='.&pdsCombineOrderingFlds('XSR_BV', $strSecondaryFlds));
   &pdsSetAuxOrderingDef('XSR', 'XSR_o25', 
                             'fields='.&pdsCombineOrderingFlds('XSR_RBV', $strSecondaryFlds));
}
&pdsSetAuxDefaultOrderingKey('XSR', 'XSR_o1');
&pdsAddAuxStandardOrderings('XSR');

USEFUL LINKS:
 EULA
 Pedserve Editions
 Sample City
 Consultancy
 Data Preparation
 Installation
 Regular Expressions
 Similarity Searching
 Configuration File
 Setup Script
 Stylesheet
 Database Design
 Hooks
 Date/Time
 User Defined Fields
 User Defined Records
 Display Fields Definitions
 Ordering Fields Definitions
 Highlighting
 Page Layout
 Field Definitions
 Field Formatting
 Shortcut Query Buttons
 Plates
 Command Buttons
 Connecting to the Database
 Warning Footer Message