lots of changes
This commit is contained in:
parent
93df39d6f6
commit
615e0e3746
28 changed files with 2883 additions and 212 deletions
|
|
@ -58,6 +58,36 @@ These subroutines are available from this package:
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getAccountConfig ( op, configs )
|
||||
|
||||
Searches the account config array passed in and returns the hash reference which
|
||||
contains the op value passed in. If no op value is found, undef is returned;
|
||||
|
||||
=head3 op
|
||||
|
||||
op to search for
|
||||
|
||||
=head3 configs
|
||||
|
||||
array ref with account config hashes
|
||||
|
||||
=cut
|
||||
|
||||
sub getAccountConfig {
|
||||
my $class = shift;
|
||||
my $session = shift;
|
||||
my $module = shift;
|
||||
my $configs = shift || $session->config->get("account");
|
||||
|
||||
foreach my $config (@{$configs}) {
|
||||
return $config if ($config->{identifier} eq $module);
|
||||
}
|
||||
|
||||
return undef;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 handler ( session )
|
||||
|
||||
The content handler for this package.
|
||||
|
|
@ -67,19 +97,25 @@ The content handler for this package.
|
|||
sub handler {
|
||||
my $session = shift;
|
||||
my $form = $session->form;
|
||||
my $setting = $session->setting;
|
||||
|
||||
my $op = $form->get("op");
|
||||
return undef unless ($op eq "account");
|
||||
|
||||
my $output = undef;
|
||||
|
||||
my $op = $session->form->get("op");
|
||||
my $configs = $session->config->get("account");
|
||||
my $module = $form->get("module") || $session->config->get("profileModuleIdentifier");
|
||||
|
||||
if ($configs->{$op}) {
|
||||
my $configs = $session->config->get("account");
|
||||
my $config = __PACKAGE__->getAccountConfig($session,$module,$configs);
|
||||
|
||||
if (defined $config) {
|
||||
#Visitor cannot do anything to the profile.
|
||||
return $session->privilege->insufficient if($session->user->isVisitor);
|
||||
#$session->errorHandler->warn("Loading module : ".$configs->{$op}->{className});
|
||||
|
||||
#Create Pluggin Object
|
||||
#Don't eval this as pluggable will croak and we want WebGUI::URL::Content to handle the exception
|
||||
my $pluggin = WebGUI::Pluggable::instanciate($configs->{$op}->{className}, "new", [ $session ] );
|
||||
my $pluggin = WebGUI::Pluggable::instanciate($config->{className}, "new", [ $session ] );
|
||||
|
||||
#Check to make sure pluggin is a subclass of WebGUI::Account
|
||||
unless($pluggin->isa('WebGUI::Account')) {
|
||||
|
|
@ -91,12 +127,15 @@ sub handler {
|
|||
);
|
||||
}
|
||||
|
||||
#Check to see if the user has permission to see what they are calling
|
||||
return $session->privilege->insufficient unless ($pluggin->canView);
|
||||
|
||||
#Process the method call
|
||||
my $method = $session->form->get("do") || "view";
|
||||
my $method = $form->get("do") || "view";
|
||||
$method = "www_".$method;
|
||||
|
||||
|
||||
if($pluggin->can($method)) {
|
||||
$output = eval { $pluggin->$method($session) };
|
||||
$output = $pluggin->$method;
|
||||
}
|
||||
else {
|
||||
WebGUI::Error::MethodNotFound->throw(
|
||||
|
|
@ -108,12 +147,46 @@ sub handler {
|
|||
#Wrap content returned from method call into the layout
|
||||
my $var = {};
|
||||
$var->{content} = $output;
|
||||
my $layoutId = $pluggin->getLayoutTemplateId;
|
||||
$output = $pluggin->processTemplate($var,$layoutId);
|
||||
|
||||
# Get fieldsets for avaiable account methods in the order they exist in the config file
|
||||
my @pluggins = ();
|
||||
foreach my $account (@{$configs}) {
|
||||
#Instantiate the pluggin
|
||||
#Use the currently instantiated pluggin if we are checking this pluggin
|
||||
my $instance = undef;
|
||||
if($account->{identifier} eq $module) {
|
||||
$instance = $pluggin;
|
||||
}
|
||||
else {
|
||||
$instance = eval { WebGUI::Pluggable::instanciate($account->{className}, "new", [ $session ] ) };
|
||||
if (my $e = WebGUI::Error->caught) {
|
||||
$session->log->warn("Couldn't instantiate Account Pluggin ".$account->{className}." ... skipping");
|
||||
next;
|
||||
}
|
||||
elsif(!$pluggin->isa('WebGUI::Account')) {
|
||||
$session->log->warn((ref $instance)." is not a subclass of WebGUI::Account ... skipping");
|
||||
next;
|
||||
}
|
||||
}
|
||||
#Skip this module if the user can't view this
|
||||
next unless ($instance->canView);
|
||||
|
||||
#Push the tab variables onto the template
|
||||
my %hash = %{$account};
|
||||
my $identifier = $account->{identifier};
|
||||
$hash{'is_'.$identifier} = "true";
|
||||
$hash{'url' } = $instance->getUrl("module=$identifier",1);
|
||||
$hash{'isActive' } = "true" if($identifier eq $module);
|
||||
WebGUI::Macro::process(\$hash{'title'});
|
||||
push(@pluggins,\%hash);
|
||||
}
|
||||
$var->{'account_loop'} = \@pluggins;
|
||||
|
||||
my $layoutId = $pluggin->getLayoutTemplateId;
|
||||
#Process the layout template
|
||||
$output = $pluggin->processTemplate($var,$layoutId);
|
||||
#Wrap the layout in the user style
|
||||
$session->http->setCacheControl("none");
|
||||
$output = $session->style->process($output,$session->setting->get("userFunctionStyleId"));
|
||||
$output = $session->style->userStyle($output);
|
||||
}
|
||||
|
||||
return $output;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue