Gossamer Forum
Home : Products : DBMan : Customization :

Strange get_record problem

Quote Reply
Strange get_record problem
Hi!

I have a problem concerning the get_record subroutine.

I have a page where I need to drag two records from the default db. I use this code:

$compare = $in{compare};
my (@array) = split (/\Q~~\E/o, $compare);
my (%rec) = &get_record($array[0]);
my (%rec1) = &get_record($array[1]);


This works out just fine. $array[0] and $array[1] are the IDs of the two records. Now the strange part comes: When I am logged in as admin, the get_record works just fine, but when I want to enter the page as a default-user (uid=default), it returns no records. I've tried printing out the IDs, and they are still there, so it must be the get_record routine that is the problem.

My get_record subroutine looks like this:

sub get_record {
# --------------------------------------------------------
# Given an ID as input, get_record returns a hash of the
# requested record or undefined if not found.


my ($key, $found, $line, @data, $field, $restricted);
$key = $_[0];
$found = 0;
($restricted = 1) if ($auth_modify_own and !$per_admin);


open (DB, "<$db_file_name") or &cgierr("error in get_records. unable to open db file: $db_file_name.\nReason: $!");
if ($db_use_flock) { flock(DB, 1); }
LINE: while (<DB>) {
(/^#/) and next LINE;
(/^\s*$/) and next LINE;
$line = $_; chomp ($line);
@data = &split_decode($line);
next LINE if ($restricted and ($db_userid ne $data[$auth_user_field]));
if ($data[$db_key_pos] eq $key) {
$found = 1;
for ($i = 0; $i <= $#db_cols; $i++) { # Map the array columns to a hash.
$rec{$db_cols[$i]} = $data[$i];
}
last LINE;
}
}
close DB;
$found ?
(return %rec) :
(return undef);
}


I hope you will help me. I am really confused.

Regards,

Alex
Quote Reply
Re: [AlexVB] Strange get_record problem In reply to
I know in several of my databases I have this line commented out in sub get_record

# ($restricted = 1) if ($auth_modify_own and !$per_admin);

This is commented as either to not be used with relational mod or when using the private email mod. Perhaps commenting that out will solve your problem?

Let us know if that helps.

Unoffical DBMan FAQ

http://creativecomputingweb.com/dbman/index.shtml/
Quote Reply
Re: [LoisC] Strange get_record problem In reply to
Thank you LoisC. Now it works just fine Smile

Regards,

Alex