/[Arh]/lib/Arh/Model/User.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 /lib/Arh/Model/User.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 23 - (show annotations)
Fri Nov 30 23:23:14 2007 UTC (16 years, 4 months ago) by dpavlin
File size: 1829 byte(s)
another huge code dump:
- rename database columns to prevent conficts with standards
- added editing accessor to user which returns edit mode
- ToggleEdit action to change editing state (broken)
- tweaks all over templates to make units entry a breeze
- version bump [0.03]
1 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 column editing =>
51 type is 'boolean',
52 label is _("Edit mode"),
53 default is 0,
54 since '0.0.10';
55
56 };
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 foreach ( qw/name lastname email organization editing/) {
79 return 1 if $name eq $_;
80 }
81 return 0;
82 }
83
84 return 1;
85 }
86
87 1;
88

  ViewVC Help
Powered by ViewVC 1.1.26