/[transports]/trunk/lib/Transports/CurrentUser.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /trunk/lib/Transports/CurrentUser.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 46 - (show annotations)
Tue May 30 18:09:51 2006 UTC (17 years, 11 months ago) by dpavlin
File size: 1141 byte(s)
bunch of changes:
- added import operator user role (user_object->can_import),
  added import transort which sets return_code and optional comment - it can
  be executed by import operators or admins
- import operators will get just transports which aren't imported under /transports
1 use warnings;
2 use strict;
3
4
5 package Transports::CurrentUser;
6
7 use base qw(Jifty::CurrentUser);
8
9 =head2 new PARAMHASH
10
11 Instantiate a new current user object, loading the user by paramhash:
12
13 my $item = Transports::Model::Item->new( Transports::CurrentUser->new(email => 'user@site'));
14
15 if you give the param
16 _bootstrap => 1
17
18 your object will be marked as a bootstrap user. You can use that to do an endrun around acls.
19
20 =cut
21
22
23
24 sub _init {
25 my $self = shift;
26 my %args = (@_);
27
28 if (delete $args{'_bootstrap'} ) {
29 $self->is_bootstrap_user(1);
30 } elsif (keys %args) {
31 $self->user_object(Transports::Model::User->new(current_user => $self));
32 $self->user_object->load_by_cols(%args);
33 }
34 $self->SUPER::_init(%args);
35 }
36
37 =head2 admin
38
39 Is current user administrator?
40
41 =cut
42
43 sub admin {
44 my $self = shift;
45 return unless ($self->user_object);
46 return $self->user_object->admin;
47 }
48
49 =head2 can_import
50
51 Can current user initiate import of request?
52
53 =cut
54
55 sub can_import {
56 my $self = shift;
57 return unless ($self->user_object);
58 return $self->user_object->can_import || $self->user_object->admin;
59 }
60
61 1;

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26