| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Kwiki::Edit::RequireUserName; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
22104
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
27
|
|
|
4
|
1
|
|
|
1
|
|
5
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
32
|
|
|
5
|
1
|
|
|
1
|
|
416
|
use Kwiki::Plugin '-Base'; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
use mixin 'Kwiki::Installer'; |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
const class_id => 'EditRequireUserName'; |
|
11
|
|
|
|
|
|
|
const class_title => 'Require UserName to edit'; |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub register { |
|
14
|
|
|
|
|
|
|
my $registry = shift; |
|
15
|
|
|
|
|
|
|
$registry->add(action => 'edit_noUserName'); |
|
16
|
|
|
|
|
|
|
$registry->add(hook => 'edit:edit', pre => 'require_username'); |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
} |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub require_username { |
|
21
|
|
|
|
|
|
|
my $hook = pop; |
|
22
|
|
|
|
|
|
|
my $req_username_obj = $self->hub->load_class('EditRequireUserName'); |
|
23
|
|
|
|
|
|
|
my $page = $self->pages->current; |
|
24
|
|
|
|
|
|
|
if (! $req_username_obj->have_UserName) { |
|
25
|
|
|
|
|
|
|
my $page_uri = $page->uri; |
|
26
|
|
|
|
|
|
|
$hook->cancel(); # don't bother calling Kwiki::Edit::edit |
|
27
|
|
|
|
|
|
|
return $self->redirect("action=edit_noUserName&page_name=$page_uri"); |
|
28
|
|
|
|
|
|
|
} |
|
29
|
|
|
|
|
|
|
} |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub have_UserName { |
|
32
|
|
|
|
|
|
|
my $current_name = $self->hub->users->current->name || |
|
33
|
|
|
|
|
|
|
die "Can't determine current UserName"; |
|
34
|
|
|
|
|
|
|
my $anonymous_name = $self->config->user_default_name || |
|
35
|
|
|
|
|
|
|
die "Can't determine local name of anonymous user"; # set in |
|
36
|
|
|
|
|
|
|
# config/user.yaml |
|
37
|
|
|
|
|
|
|
return ($current_name ne $anonymous_name); |
|
38
|
|
|
|
|
|
|
} |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub edit_noUserName { |
|
41
|
|
|
|
|
|
|
return $self->render_screen( |
|
42
|
|
|
|
|
|
|
content_pane => 'edit_noUserName.html', |
|
43
|
|
|
|
|
|
|
); |
|
44
|
|
|
|
|
|
|
} |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
1; |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
__DATA__ |