Pangloss::Segment::LoadCategory - load category from an OpenFrame::Request.


Pangloss documentation Contained in the Pangloss distribution.

Index


Code Index:

NAME

Top

Pangloss::Segment::LoadCategory - load category from an OpenFrame::Request.

SYNOPSIS

Top

  $pipe->add_segment( Pangloss::Segment::LoadCategory->new )

DESCRIPTION

Top

This class inherits its interface from Pipeline::Segment.

METHODS

Top

$category = $obj->dispatch();

attempts to load a category from the stored OpenFrame::Request's arguments.

$category = $obj->new_category_from_args( \%args );

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.

AUTHOR

Top

Steve Purkis <spurkis@quiup.com>

SEE ALSO

Top

Pipeline::Segment, Pangloss::Category


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__

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