1 |
dpavlin |
10 |
use strict; |
2 |
|
|
use warnings; |
3 |
|
|
|
4 |
|
|
package Arh::Model::User; |
5 |
|
|
use Jifty::DBI::Schema; |
6 |
|
|
|
7 |
|
|
use Data::Dump qw/dump/; |
8 |
|
|
|
9 |
|
|
use Arh::Record schema { |
10 |
|
|
|
11 |
|
|
column name => |
12 |
|
|
type is 'text', |
13 |
|
|
label is _('First name'), |
14 |
|
|
hints is _('How should I display your name to other users?'); |
15 |
|
|
|
16 |
|
|
column lastname => |
17 |
|
|
type is 'text', |
18 |
|
|
label is _('Last name'), |
19 |
|
|
since '0.0.5'; |
20 |
|
|
|
21 |
|
|
column email => |
22 |
|
|
type is 'text', |
23 |
|
|
is mandatory, |
24 |
|
|
label is _('Email address'), default is '', is immutable, is distinct; |
25 |
|
|
|
26 |
|
|
column email_confirmed => |
27 |
|
|
label is _('Email address confirmed?'), |
28 |
|
|
type is 'boolean'; |
29 |
|
|
|
30 |
|
|
column password => |
31 |
|
|
is unreadable, |
32 |
|
|
label is _('Password'), |
33 |
|
|
type is 'varchar', |
34 |
|
|
hints is _('Your password should be at least six characters'), |
35 |
|
|
render_as 'password', |
36 |
|
|
# filters are 'Jifty::DBI::Filter::SaltHash', |
37 |
|
|
is mandatory; |
38 |
|
|
|
39 |
|
|
column administrator => |
40 |
|
|
type is 'boolean', |
41 |
|
|
default is 0, |
42 |
|
|
is mandatory, |
43 |
|
|
since '0.0.2'; |
44 |
|
|
|
45 |
|
|
column organization => |
46 |
|
|
type is 'text', |
47 |
|
|
label is _('Organization'), |
48 |
|
|
since '0.0.3'; |
49 |
|
|
|
50 |
dpavlin |
23 |
column editing => |
51 |
|
|
type is 'boolean', |
52 |
|
|
label is _("Edit mode"), |
53 |
|
|
default is 0, |
54 |
|
|
since '0.0.10'; |
55 |
|
|
|
56 |
dpavlin |
10 |
}; |
57 |
|
|
|
58 |
|
|
use Jifty::Plugin::User::Mixin::Model::User; |
59 |
|
|
use Jifty::Plugin::Authentication::Password::Mixin::Model::User; |
60 |
|
|
#use Jifty::Plugin::OpenID::Mixin::Model::User; |
61 |
|
|
use Jifty::Plugin::ActorMetadata::Mixin::Model::ActorMetadata; # created_by, created_on, updated_on |
62 |
|
|
|
63 |
|
|
# Your model-specific methods go here. |
64 |
|
|
|
65 |
|
|
=head2 current_user_can |
66 |
|
|
|
67 |
|
|
=cut |
68 |
|
|
|
69 |
|
|
sub current_user_can { |
70 |
|
|
my ( $self, $action,$item,$name ) = @_; |
71 |
|
|
|
72 |
|
|
return 1 if $self->current_user->superuser; |
73 |
|
|
return 1 if $self->current_user->administrator; |
74 |
|
|
|
75 |
|
|
warn "current_user_can $action | $item | ", $name ? $name : 'NO NAME', "\n"; |
76 |
|
|
|
77 |
|
|
if ( $action eq 'read' && $item eq 'column' ) { |
78 |
dpavlin |
23 |
foreach ( qw/name lastname email organization editing/) { |
79 |
dpavlin |
10 |
return 1 if $name eq $_; |
80 |
|
|
} |
81 |
|
|
return 0; |
82 |
|
|
} |
83 |
|
|
|
84 |
|
|
return 1; |
85 |
|
|
} |
86 |
|
|
|
87 |
|
|
1; |
88 |
|
|
|