Gossamer Forum
Home : Products : DBMan : Customization :

Re: [knue] Updating many cfg files at once.

Quote Reply
Re: [knue] Updating many cfg files at once. In reply to
easier way to do this:

In your .cfg file, create a new variable to hold the fieldnames that will be created from the external databases.

code:
$db_external_select_fields = 'Userid';

In db.cgi, create a subroutine: code:

sub build_external_select_field {
#------------------------------------
my ($column, $value) = @_;
my ($output,$external_db,$found,$field,@selectfields);
foreach $col (@db_cols) {
if ($column eq $col) {
$found = 1;
last;
}
}
if (!$found) {
return "error building select field: no fields specified!";
}
$output = qq|<SELECT NAME="$column">|;
$external_db=$db_script_path . '/' . lc($column) . '.db';
open (DB, "<$external_db") or &cgierr("unable to open $column.db. Reason: $!");
if ($db_use_flock) { flock(DB, 1); }
LINE: while (<DB> ) {
next if /^#/;
next if /^\s*$/;
$line = $_;
chomp ($line);
push (@selectfields, $line);
}
close DB;
foreach $field (sort @selectfields) {
($value =~ $field) ?
($output .= "<OPTION SELECTED>$field") :
($output .= "<OPTION>$field");
}
$output .= "</SELECT>";
return $output;
}

In html_build_record_form, after the line that starts with

if ($db_select_fields{$field}) {...

add code:

elsif ($db_external_select_fields =~ $field) {
$output .= "<TR><TD><$font>$field:</font></TD><TD" . &build_external_select_field($field, $rec{$field}) . "</TD></TR>";
}

As always, should you or any of your IM force be caught or captured-- Oh, wrong context.
As always, this is untested, except for sytax errors.



i copied above from an old post and edited it a little. ;you would take Userid out of the &db_select_fields in all the config files and use the following instead.

$db_external_select_fields = 'Userid';

then you would have a database that contained all the Userid's.

i suggest you use a common .pass file that already exists instead of a new file. if you use pass file you will need to make a few changes to the code above. if you need help with that, get it started and let me know!
Subject Author Views Date
Thread; hot thread Updating many cfg files at once. knue 17435 Nov 30, 2015, 12:17 PM
Thread; hot thread Re: [knue] Updating many cfg files at once.
delicia 17200 Dec 1, 2015, 6:22 AM
Post; hot thread Re: [delicia] Updating many cfg files at once.
delicia 17206 Dec 1, 2015, 8:50 AM
Thread; hot thread Re: [delicia] Updating many cfg files at once.
knue 17215 Dec 1, 2015, 2:48 PM
Thread; hot thread Re: [knue] Updating many cfg files at once.
delicia 17205 Dec 1, 2015, 5:19 PM
Thread; hot thread Re: [delicia] Updating many cfg files at once.
knue 17175 Dec 1, 2015, 5:25 PM
Thread; hot thread Re: [knue] Updating many cfg files at once.
knue 17200 Dec 1, 2015, 5:27 PM
Thread; hot thread Re: [knue] Updating many cfg files at once.
delicia 17202 Dec 1, 2015, 5:31 PM
Thread; hot thread Re: [delicia] Updating many cfg files at once.
delicia 17160 Dec 1, 2015, 5:34 PM
Thread; hot thread Re: [delicia] Updating many cfg files at once.
knue 17197 Dec 1, 2015, 5:42 PM
Thread; hot thread Re: [knue] Updating many cfg files at once.
delicia 17191 Dec 1, 2015, 5:53 PM
Thread; hot thread Re: [delicia] Updating many cfg files at once.
knue 17157 Dec 1, 2015, 6:15 PM
Thread; hot thread Re: [knue] Updating many cfg files at once.
delicia 17148 Dec 1, 2015, 6:36 PM
Thread; hot thread Re: [delicia] Updating many cfg files at once.
delicia 17157 Dec 1, 2015, 6:38 PM
Thread; hot thread Re: [delicia] Updating many cfg files at once.
knue 17141 Dec 1, 2015, 6:54 PM
Thread; hot thread Re: [knue] Updating many cfg files at once.
knue 17083 Dec 2, 2015, 9:50 PM
Thread; hot thread Re: [knue] Updating many cfg files at once.
delicia 17067 Dec 3, 2015, 1:54 PM
Thread; hot thread Re: [delicia] Updating many cfg files at once.
knue 17067 Dec 3, 2015, 8:13 PM
Post; hot thread Re: [knue] Updating many cfg files at once.
delicia 17045 Dec 4, 2015, 6:20 AM
Post; hot thread Re: [delicia] Updating many cfg files at once.
knue 17104 Dec 3, 2015, 11:56 AM