diff --git a/docs/changelog/6.x.x.txt b/docs/changelog/6.x.x.txt index e5fea5b13..45fc441e6 100644 --- a/docs/changelog/6.x.x.txt +++ b/docs/changelog/6.x.x.txt @@ -3,6 +3,7 @@ - Bug fixes to make WebGUI work with the WRE demo system. - Fixed a typo in the activities in the config file. - fixed a bug that caused threadId's to be empty in new posts + - fix [ 1489123 ] problem with graphing (Martin Kamerbeek / Procolix) 6.99.0 - Added a workflow system. diff --git a/lib/WebGUI/Asset/Wobject/Poll.pm b/lib/WebGUI/Asset/Wobject/Poll.pm index f33d96f64..d0b5cb4db 100644 --- a/lib/WebGUI/Asset/Wobject/Poll.pm +++ b/lib/WebGUI/Asset/Wobject/Poll.pm @@ -251,19 +251,21 @@ sub getEditForm { ) if $self->session->form->process("func") ne 'add'; - my $config = {}; - if ($self->get('graphConfiguration')) { - $config = Storable::thaw($self->get('graphConfiguration')); - } + if (WebGUI::Image::Graph->getPluginList($self->session)) { + my $config = {}; + if ($self->get('graphConfiguration')) { + $config = Storable::thaw($self->get('graphConfiguration')); + } - $tabform->addTab('graph', 'Graphing'); - $tabform->getTab('graph')->yesNo( - -name => 'generateGraph', - -label => $i18n->get('generate graph'), - -hoverHelp => $i18n->get('generate graph description'), - -value => $self->getValue('generateGraph'), - ); - $tabform->getTab('graph')->raw(WebGUI::Image::Graph->getGraphingTab($self->session, $config)); + $tabform->addTab('graph', 'Graphing'); + $tabform->getTab('graph')->yesNo( + -name => 'generateGraph', + -label => $i18n->get('generate graph'), + -hoverHelp => $i18n->get('generate graph description'), + -value => $self->getValue('generateGraph'), + ); + $tabform->getTab('graph')->raw(WebGUI::Image::Graph->getGraphingTab($self->session, $config)); + } return $tabform; } @@ -310,8 +312,10 @@ sub processPropertiesFromFormPost { $property->{'a'.$i} = $answer[($i-1)]; } - my $graph = WebGUI::Image::Graph->processConfigurationForm($self->session); - $property->{graphConfiguration} = Storable::freeze($graph->getConfiguration); + if (WebGUI::Image::Graph->getPluginList($self->session)) { + my $graph = WebGUI::Image::Graph->processConfigurationForm($self->session); + $property->{graphConfiguration} = Storable::freeze($graph->getConfiguration); + } $self->update($property); $self->session->db->write("delete from Poll_answer where assetId=".$self->session->db->quote($self->getId)) if ($self->session->form->process("resetVotes")); diff --git a/lib/WebGUI/Image/Graph.pm b/lib/WebGUI/Image/Graph.pm index 2f801d262..1d27ec411 100644 --- a/lib/WebGUI/Image/Graph.pm +++ b/lib/WebGUI/Image/Graph.pm @@ -5,6 +5,7 @@ use WebGUI::Image; use WebGUI::Image::Palette; use WebGUI::Image::Font; use List::Util; +use WebGUI::Utility; our @ISA = qw(WebGUI::Image); @@ -231,6 +232,14 @@ sub getGraphingTab { my $i18n = WebGUI::International->new($session, 'Image_Graph'); my $f = WebGUI::HTMLForm->new($session); + + unless ($session->config->get("graphingPlugins")) { + $f->readOnly( + -value => "No graphing plugins are enabled in the config file." + ); + + return $f->printRowsOnly; + } foreach (@{$session->config->get("graphingPlugins")}) { my $plugin = WebGUI::Image::Graph->load($session, $_); @@ -486,6 +495,20 @@ sub getMaxValueFromDataset { return List::Util::max(@{$self->{_dataset}}); } +#------------------------------------------------------------------- +=head2 getPluginList + +Returns an arrayref containing the namespaces of the enabled graphing plugins. + +=cut + +sub getPluginList { + my $self = shift; + my $session = shift || $self->session; + + return $session->config->get("graphingPlugins"); +} + #------------------------------------------------------------------- =head2 load ( session, namespace ) @@ -558,13 +581,17 @@ The WebGUI session object. =cut sub processConfigurationForm { - my $self = shift; + my $class = shift; my $session = shift; + + return undef unless ($class->getPluginList($session)); my $namespace = "WebGUI::Image::".$session->form->process('graphingPlugin'); $namespace =~ s/_/::/g; -my $graph = $self->load($session, $namespace); + return undef unless (isIn($namespace, @{$class->getPluginList($session)})); + +my $graph = $class->load($session, $namespace); $graph->setConfiguration($session->form->paramsHashRef);