CatalystX::Usul::Model::Config::Levels - Class definition for the levels configuration element


CatalystX-Usul documentation Contained in the CatalystX-Usul distribution.

Index


Code Index:

Name

Top

CatalystX::Usul::Model::Config::Levels - Class definition for the levels configuration element

Version

Top

0.3.$Revision: 591 $

Synopsis

Top

   # Instantiated by Catalyst when the application starts

Description

Top

Defines the <levels> configuration element

Defines three language independent attributes: acl, name and state

Defines two language dependent attributes: text and tip

Subroutines/Methods

Top

delete

Deletes the specified levels element from the configuration

get_list

Returns an object that contains a list of the defined levels and the fields of the specified level

set_state

Toggles the state attribute which has the effect of opening (false) or closing (true) the level to the application

Diagnostics

Top

None

Configuration and Environment

Top

None

Dependencies

Top

CatalystX::Usul::Model::Config

Incompatibilities

Top

There are no known incompatibilities in this module

Bugs and Limitations

Top

There are no known bugs in this module. Please report problems to the address below. Patches are welcome

Author

Top

Peter Flanigan, <Support at RoxSoft.co.uk>

License and Copyright

Top


CatalystX-Usul documentation Contained in the CatalystX-Usul distribution.

# @(#)$Id: Levels.pm 591 2009-06-13 13:34:41Z pjf $

package CatalystX::Usul::Model::Config::Levels;

use strict;
use warnings;
use version; our $VERSION = qv( sprintf '0.3.%d', q$Rev: 591 $ =~ /\d+/gmx );
use parent qw(CatalystX::Usul::Model::Config);

use Class::C3;

__PACKAGE__->config
   ( create_msg_key    => 'Namespace [_1] created',
     delete_msg_key    => 'Namespace [_1] deleted',
     file              => q(default),
     keys_attr         => q(level),
     schema_attributes => {
        attributes     => [ qw(acl state text tip) ],
        defaults       => { acl => [ q(any) ], state => 0, text => q() },
        element        => q(levels),
        lang_dep       => { qw(text 1 tip 1) }, },
     update_msg_key    => 'Namespace [_1] updated', );

__PACKAGE__->mk_accessors( qw(file) );

sub delete {
   my ($self, $args) = @_;

   $self->next::method( $args );
   delete $self->context->stash->{levels}->{ $args->{name} };
   return;
}

sub get_list {
   my ($self, $name) = @_; return $self->next::method( $self->file, $name );
}

sub set_state {
   my ($self, $args) = @_;

   my %states = ( 0 => q(open), 1 => q(hidden), 2 => q(closed) );
   my $state  = $self->query_value( q(state) ) || 0;

   $args->{fields} = { state => $state };
   $self->update( $args );
   $self->clear_result;

   my $user     = $self->context->stash->{user};
   my $msg      = 'Namespace [_1] state set to [_2] by [_3]';
   my @msg_args = ( $args->{name}, $states{ $state }, $user );

   $self->add_result_msg( $msg, @msg_args );
   return;
}

1;

__END__

# Local Variables:
# mode: perl
# tab-width: 3
# End: