Gossamer Forum
Home : Products : Gossamer Links : Development, Plugins and Globals :

Re: [Alex] Second administrator with different admin templates

Quote Reply
Re: [Alex] Second administrator with different admin templates In reply to
Hi Alex,

Thank you for yor reply..

I looked at the Links.pm. It seems that the only thing that can determine which Administrator is logged in is the name of the admin file that was used, which is in my case, could be admin.cgi or second_admin.cgi.
Then if I know the name, then I can load the right template set for it using this logic:

if requesting file was admin.cgi
load templates/admin templates
else
load templates/second_admin templates
fi;

..... but how would I do this condition in the code?
Can you please point it out.
Thank you

here is some of the code of sub admin_page:
Code:


sub admin_page {

# ------------------------------------------------------------------

# Display an admin template page.

#

(defined $_[0] and $_[0] eq 'Links') and shift;

my ($file, $params, $opts) = @_;

my $cookies = [];

if ($IN->param('set-cookie')) {

foreach my $key ($IN->param) {

if ($key =~ /^cookie-(.*)/) {

my $path = $IN->param("cookie_path-$1") || '/';

my $exp = $IN->param("cookie_exp-$1") || '+5y';

push @$cookies, $IN->cookie(-name => $1, -value => $IN->param($key), -path => $path, -expires => $exp);

}

}

}

@$cookies ? print $IN->header (-cookie => $cookies ) : print $IN->header();

$file ||= $IN->param('page');

$file =~ /\.\./ and return die "Invalid template '$file' requested (Invalid name)";

$file =~ m,^/, and return die "Invalid template '$file' requested (Invalid name)";



-e "$CFG->{admin_root_path}/templates/admin/$file" or return die "Invalid template '$file' requested (File does not exist)";

-r _ or return die "Invalid template '$file' requested (Permission denied)";

# Add on $IN

$params ||= [];

my $cgi = $IN->get_hash;

foreach (keys %$cgi) {

$cgi->{$_} = (ref $cgi->{$_} eq 'ARRAY') ? join ("\n", @{$cgi->{$_}}) : $cgi->{$_};

}

ref $params eq 'ARRAY' ? (push @$params, $cgi) : ($params = [$cgi, $params]);

# Make sure a root is set.

$opts ||= {};

$opts->{root} ||= "$CFG->{admin_root_path}/templates/admin";

defined $opts->{print} or ($opts->{print} = 1);

# Print the page.

GT::Template->parse ( $file, $params, $opts );

}



Thank you in advance for your help
Mark
Subject Author Views Date
Thread Second administrator with different admin templates Mark2 1587 Oct 31, 2002, 6:37 AM
Thread Re: [Mark2] Second administrator with different admin templates
Alex 1479 Nov 2, 2002, 8:29 AM
Post Re: [Alex] Second administrator with different admin templates
Mark2 1467 Nov 2, 2002, 9:48 AM