Hi Kenny,
> How would I test run-mode ids? Would I need to include it in the
> URL and then have a large if.. elsif... elsif... elsif... elsif... else
> tree?
In your sample code, there was something like this ...
# Check for permission.
if ($admin->checkPermission('ModuleName_Mode '))
{
# The have permission so go ahead
}
else
{
# They do not have permission so tell them.
}
You hardcoded the modename in every runmode, but if you put the check
into cgiapp_init, then you could do something like this (of course you
could use the same code in every runmode, or write a subroutine, like
Greg suggested, but if the code is placed into cgiapp_init, you have to
maintain the permission checking code only in one place ... don't forget
TIMTOWTDI ;)
my $q = $self->query();
my $modename = $q->param('rm');
unless ($admin->checkPermission("ModuleName_$modename"))
{
# They do not have permission so send them to the error runmode
$q->param('rm', 'error_rm');
}
(As always this code is not tested, but from looking at the CGI::App
source it should work)
> Please explain this further. I am not sure how this would work
> but it sounds better than testing in each mode. I tried to think of a
> way to do this in the app.cgi instead of the App.pm but I didn't think
> of anything (or at least I didn't think of anything that was better).
I think it would be better to do it in App.pm, like in the sample
application you could qrite a App_Super class which implements the
checking in the cgiapp_init, and then simply inherit from it.
Sorry for being confusing the first time, hope this time it's better
Benjamin
--
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GIT/P dx s: a? C(+++) L++ P+++ N++ w PS+ PE-(++) Y+ PGP
t+ 5- X R@ !tv b+++ DI(+) D+ G e++(+++) UF++ h-- r@ y?
------END GEEK CODE BLOCK------
---------------------------------------------------------------------
Web Archive: http://www.mail-archive.com/[email protected]/
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]