CatalystX::Usul::Controller::Admin::Locks - Manipulate the lock table


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

Index


Code Index:

Name

Top

CatalystX::Usul::Controller::Admin::Locks - Manipulate the lock table

Version

Top

0.3.$Revision: 576 $

Synopsis

Top

   package MyApp::Controller::Admin;

   use base qw(CatalystX::Usul::Controller::Admin);

   __PACKAGE__->build_subcontrollers;

Description

Top

Displays the lock table and allows individual locks to be selected and deleted

Subroutines/Methods

Top

lock_table

Display the lock table

lock_table_delete

Deletes the selected locks

Diagnostics

Top

None

Configuration and Environment

Top

None

Dependencies

Top

CatalystX::Usul::Controller

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: Locks.pm 576 2009-06-09 23:23:46Z pjf $

package CatalystX::Usul::Controller::Admin::Locks;

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

__PACKAGE__->config( namespace => q(admin) );

sub lock_table : Chained(common) Args(0) HasActions {
   my ($self, $c) = @_;

   my $model = $c->model( q(Base) );
   my $data  = $self->lock->get_table;

   $model->add_field( { data => $data, select => q(left), type => q(table) } );
   $model->group_fields( { id => q(lock_table.select), nitems => 1 } );
   $model->add_buttons( qw(Delete) ) if ($data->{count} > 0);
   return;
}

sub lock_table_delete : ActionFor(lock_table.delete) {
   my ($self, $c) = @_; my ($key, $nrows, $r_no, $text);

   my $s = $c->stash; my $model = $c->model( q(Base) );

   unless ($nrows = $model->query_value( q(table_nrows) )) {
      $self->throw( 'Lock table empty' );
   }

   for $r_no (0 .. $nrows) {
      if ($key = $model->query_value( q(table_select).$r_no )) {
         if ($self->lock->reset( k => $key )) {
            $self->log_info( 'User '.$s->{user}.' deleted lock '.$key );
         }
      }
   }

   return 1;
}

1;

__END__

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