line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Kwiki::Users; |
2
|
1
|
|
|
1
|
|
1779
|
use Kwiki::Base -Base; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
use mixin 'Kwiki::Installer'; |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
const class_id => 'users'; |
6
|
|
|
|
|
|
|
const class_title => 'Kwiki Users'; |
7
|
|
|
|
|
|
|
const user_class => 'Kwiki::User'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub init { |
10
|
|
|
|
|
|
|
$self->hub->config->add_file('user.yaml'); |
11
|
|
|
|
|
|
|
} |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub all { |
14
|
|
|
|
|
|
|
($self->current); |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub all_ids { |
18
|
|
|
|
|
|
|
($self->current->id); |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub current { |
22
|
|
|
|
|
|
|
return $self->{current} = shift if @_; |
23
|
|
|
|
|
|
|
return $self->{current} if defined $self->{current}; |
24
|
|
|
|
|
|
|
my $user_id = $ENV{REMOTE_USER} || ''; |
25
|
|
|
|
|
|
|
$self->{current} = $self->new_user($user_id); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub new_user { |
29
|
|
|
|
|
|
|
$self->user_class->new(id => shift); |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
package Kwiki::User; |
33
|
|
|
|
|
|
|
use base 'Kwiki::Base'; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
field 'id'; |
36
|
|
|
|
|
|
|
field 'name' => ''; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub new { |
39
|
|
|
|
|
|
|
$self = super; |
40
|
|
|
|
|
|
|
$self->set_user_name; |
41
|
|
|
|
|
|
|
return $self; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub set_user_name { |
45
|
|
|
|
|
|
|
return unless $self->is_in_cgi; |
46
|
|
|
|
|
|
|
my $name = ''; |
47
|
|
|
|
|
|
|
$name = $self->preferences->user_name->value |
48
|
|
|
|
|
|
|
if $self->preferences->can('user_name'); |
49
|
|
|
|
|
|
|
$name ||= $self->hub->config->user_default_name; |
50
|
|
|
|
|
|
|
$self->name($name); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub preferences { |
54
|
|
|
|
|
|
|
return $self->{preferences} = shift if @_; |
55
|
|
|
|
|
|
|
return $self->{preferences} if defined $self->{preferences}; |
56
|
|
|
|
|
|
|
my $preferences = $self->hub->preferences; |
57
|
|
|
|
|
|
|
$self->{preferences} = |
58
|
|
|
|
|
|
|
$preferences->new_preferences($self->preference_values); |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub preference_values { |
62
|
|
|
|
|
|
|
$self->hub->cookie->jar->{preferences} || {}; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
package Kwiki::Users; |
66
|
|
|
|
|
|
|
__DATA__ |