| Pangloss documentation | Contained in the Pangloss distribution. |
Pangloss::Segment::LoadCategory - load category from an OpenFrame::Request.
$pipe->add_segment( Pangloss::Segment::LoadCategory->new )
This class inherits its interface from Pipeline::Segment.
attempts to load a category from the stored OpenFrame::Request's arguments.
Creates a new category from the hash given. uses the following keys:
new_category_name
new_category_notes
Returns undef if no useable keys were present.
Steve Purkis <spurkis@quiup.com>
| Pangloss documentation | Contained in the Pangloss distribution. |
package Pangloss::Segment::LoadCategory; use Pangloss::Category; use base qw( OpenFrame::WebApp::Segment::User::Session ); our $VERSION = ((require Pangloss::Version), $Pangloss::VERSION)[1]; our $REVISION = (split(/ /, ' $Revision: 1.5 $ '))[2]; sub dispatch { my $self = shift; my $request = $self->store->get('OpenFrame::Request') || return; return $self->new_category_from_args( $request->arguments ); } sub new_category_from_args { my $self = shift; my $args = shift; my $user = $self->get_user_from_session; my $category = new Pangloss::Category(); my $modified = 0; $category->creator( $user->key ) if ($user); foreach my $var (qw( name notes )) { if (exists( $args->{"new_category_$var"} )) { $category->$var( $args->{"new_category_$var"} ); $modified++; } } return $modified ? $category : undef; } 1; __END__ #------------------------------------------------------------------------------