| 1 | package Kwiki::Users; | ||||||||||||||||||||
| 2 | 1 | ▶ | use Kwiki::Base -Base; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 3 | 1 | ▶ | use mixin 'Kwiki::Installer'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | |||||||||||||||||||||
| 5 | 1 | const class_id => 'users'; | |||||||||||||||||||
| 6 | 1 | const class_title => 'Kwiki Users'; | |||||||||||||||||||
| 7 | 1 | const user_class => 'Kwiki::User'; | |||||||||||||||||||
| 8 | |||||||||||||||||||||
| 9 | 0 | ▶ | sub init { | ||||||||||||||||||
|
Subroutine
init: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 10 | 0 | $self->hub->config->add_file('user.yaml'); | |||||||||||||||||||
| 11 | } | ||||||||||||||||||||
| 12 | |||||||||||||||||||||
| 13 | 0 | ▶ | sub all { | ||||||||||||||||||
|
Subroutine
all: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 14 | 0 | ($self->current); | |||||||||||||||||||
| 15 | } | ||||||||||||||||||||
| 16 | |||||||||||||||||||||
| 17 | 0 | ▶ | sub all_ids { | ||||||||||||||||||
|
Subroutine
all_ids: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 18 | 0 | ($self->current->id); | |||||||||||||||||||
| 19 | } | ||||||||||||||||||||
| 20 | |||||||||||||||||||||
| 21 | 0 | ▶ | sub current { | ||||||||||||||||||
|
Subroutine
current: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||
| 22 | 0 | ▶ | return $self->{current} = shift if @_; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 23 | 0 | ▶ | return $self->{current} if defined $self->{current}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 24 | 0 | ▶ | my $user_id = $ENV{REMOTE_USER} || ''; | ||||||||||||||||||
|
Condition0%0/2
$ENV{'REMOTE_USER'} || ''
MC/DC0%0/1
$ENV{'REMOTE_USER'} || ''
$ENV{'REMOTE_USER'}
Truth table0%0/2
A
A= $ENV{'REMOTE_USER'}
| |||||||||||||||||||||
| 25 | 0 | $self->{current} = $self->new_user($user_id); | |||||||||||||||||||
| 26 | } | ||||||||||||||||||||
| 27 | |||||||||||||||||||||
| 28 | 0 | ▶ | sub new_user { | ||||||||||||||||||
|
Subroutine
new_user: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 29 | 0 | $self->user_class->new(id => shift); | |||||||||||||||||||
| 30 | } | ||||||||||||||||||||
| 31 | |||||||||||||||||||||
| 32 | package Kwiki::User; | ||||||||||||||||||||
| 33 | 1 | ▶ | use base 'Kwiki::Base'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 34 | |||||||||||||||||||||
| 35 | 1 | field 'id'; | |||||||||||||||||||
| 36 | 1 | field 'name' => ''; | |||||||||||||||||||
| 37 | |||||||||||||||||||||
| 38 | 0 | ▶ | sub new { | ||||||||||||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
| |||||||||||||||||||||
| 39 | 0 | $self = super; | |||||||||||||||||||
| 40 | 0 | $self->set_user_name; | |||||||||||||||||||
| 41 | 0 | return $self; | |||||||||||||||||||
| 42 | } | ||||||||||||||||||||
| 43 | |||||||||||||||||||||
| 44 | 0 | ▶ | sub set_user_name { | ||||||||||||||||||
|
Subroutine
set_user_name: not called CC=4 SCAR=30.0
| |||||||||||||||||||||
| 45 | 0 | ▶ | return unless $self->is_in_cgi; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 46 | 0 | my $name = ''; | |||||||||||||||||||
| 47 | 0 | ▶ | $name = $self->preferences->user_name->value | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 48 | if $self->preferences->can('user_name'); | ||||||||||||||||||||
| 49 | 0 | ▶ | $name ||= $self->hub->config->user_default_name; | ||||||||||||||||||
|
Condition0%0/3
$name ||= $self->hub->config->user_default_name
MC/DC0%0/2
$name ||= $self->hub->config->user_default_name
$name
$self->hub->config->user_default_name
Truth table0%0/3
A ||= B
A= $nameB= $self->hub->config->user_default_name
| |||||||||||||||||||||
| 50 | 0 | $self->name($name); | |||||||||||||||||||
| 51 | } | ||||||||||||||||||||
| 52 | |||||||||||||||||||||
| 53 | 0 | ▶ | sub preferences { | ||||||||||||||||||
|
Subroutine
preferences: not called CC=3 SCAR=24.8
| |||||||||||||||||||||
| 54 | 0 | ▶ | return $self->{preferences} = shift if @_; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 55 | 0 | ▶ | return $self->{preferences} if defined $self->{preferences}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 56 | 0 | my $preferences = $self->hub->preferences; | |||||||||||||||||||
| 57 | $self->{preferences} = | ||||||||||||||||||||
| 58 | 0 | $preferences->new_preferences($self->preference_values); | |||||||||||||||||||
| 59 | } | ||||||||||||||||||||
| 60 | |||||||||||||||||||||
| 61 | 0 | ▶ | sub preference_values { | ||||||||||||||||||
|
Subroutine
preference_values: not called CC=2 SCAR=17.9
| |||||||||||||||||||||
| 62 | 0 | ▶ | $self->hub->cookie->jar->{preferences} || {}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 63 | } | ||||||||||||||||||||
| 64 | |||||||||||||||||||||
| 65 | package Kwiki::Users; | ||||||||||||||||||||
| 66 | 1 | __DATA__ | |||||||||||||||||||