line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#!/usr/bin/perl -w |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Sakai::Nakamura::User; |
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
948
|
use 5.008008; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
36
|
|
6
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
25
|
|
7
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
33
|
|
8
|
1
|
|
|
1
|
|
4
|
use Carp; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
53
|
|
9
|
1
|
|
|
1
|
|
1209
|
use Getopt::Long qw(:config bundling); |
|
1
|
|
|
|
|
13684
|
|
|
1
|
|
|
|
|
8
|
|
10
|
1
|
|
|
1
|
|
214
|
use base qw(Apache::Sling::User); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
1032
|
|
11
|
1
|
|
|
1
|
|
21962
|
use Sakai::Nakamura; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
39
|
|
12
|
1
|
|
|
1
|
|
5
|
use Sakai::Nakamura::Authn; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
32
|
|
13
|
1
|
|
|
1
|
|
634
|
use Sakai::Nakamura::UserUtil; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
44
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
require Exporter; |
16
|
|
|
|
|
|
|
|
17
|
1
|
|
|
1
|
|
5
|
use base qw(Exporter); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
1140
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
our @EXPORT_OK = (); |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
our $VERSION = '0.13'; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
#{{{sub check_exists |
24
|
|
|
|
|
|
|
sub check_exists { |
25
|
0
|
|
|
0
|
1
|
0
|
my ( $user, $act_on_user ) = @_; |
26
|
0
|
|
|
|
|
0
|
my $res = Apache::Sling::Request::request( |
27
|
|
|
|
|
|
|
\$user, |
28
|
|
|
|
|
|
|
Sakai::Nakamura::UserUtil::exists_setup( |
29
|
|
|
|
|
|
|
$user->{'BaseURL'}, $act_on_user |
30
|
|
|
|
|
|
|
) |
31
|
|
|
|
|
|
|
); |
32
|
0
|
|
|
|
|
0
|
my $success = Sakai::Nakamura::UserUtil::exists_eval($res); |
33
|
0
|
|
|
|
|
0
|
my $message = "User \"$act_on_user\" "; |
34
|
0
|
0
|
|
|
|
0
|
$message .= ( $success ? 'exists!' : 'does not exist!' ); |
35
|
0
|
|
|
|
|
0
|
$user->set_results( "$message", $res ); |
36
|
0
|
|
|
|
|
0
|
return $success; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
#}}} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
#{{{ sub command_line |
42
|
|
|
|
|
|
|
sub command_line { |
43
|
0
|
|
|
0
|
0
|
0
|
my ( $class, @ARGV ) = @_; |
44
|
0
|
|
|
|
|
0
|
my $nakamura = Sakai::Nakamura->new; |
45
|
0
|
|
|
|
|
0
|
my $config = $class->config( $nakamura, @ARGV ); |
46
|
0
|
|
|
|
|
0
|
my $authn = new Sakai::Nakamura::Authn( \$nakamura ); |
47
|
0
|
|
|
|
|
0
|
return $class->run( $nakamura, $config ); |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
#}}} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
#{{{sub config |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub config { |
55
|
1
|
|
|
1
|
1
|
1312
|
my ( $class, $nakamura, @ARGV ) = @_; |
56
|
1
|
|
|
|
|
7
|
my $user_config = $class->config_hash( $nakamura, @ARGV ); |
57
|
|
|
|
|
|
|
|
58
|
1
|
50
|
|
|
|
9
|
GetOptions( |
59
|
|
|
|
|
|
|
$user_config, 'auth=s', |
60
|
|
|
|
|
|
|
'help|?', 'log|L=s', |
61
|
|
|
|
|
|
|
'man|M', 'pass|p=s', |
62
|
|
|
|
|
|
|
'threads|t=s', 'url|U=s', |
63
|
|
|
|
|
|
|
'user|u=s', 'verbose|v+', |
64
|
|
|
|
|
|
|
'add|a=s', 'additions|A=s', |
65
|
|
|
|
|
|
|
'change-password|c=s', 'delete|d=s', |
66
|
|
|
|
|
|
|
'email|E=s', 'first-name|f=s', |
67
|
|
|
|
|
|
|
'exists|e=s', 'last-name|l=s', |
68
|
|
|
|
|
|
|
'new-password|n=s', 'password|w=s', |
69
|
|
|
|
|
|
|
'property|P=s', 'update=s', |
70
|
|
|
|
|
|
|
'view|V=s' |
71
|
|
|
|
|
|
|
) or $class->help(); |
72
|
|
|
|
|
|
|
|
73
|
1
|
|
|
|
|
1644
|
return $user_config; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
#}}} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
#{{{sub config_hash |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub config_hash { |
81
|
1
|
|
|
1
|
0
|
3
|
my ( $class, $nakamura, @ARGV ) = @_; |
82
|
1
|
|
|
|
|
6
|
my $me; |
83
|
|
|
|
|
|
|
my $profile_field; |
84
|
0
|
|
|
|
|
0
|
my $profile_section; |
85
|
0
|
|
|
|
|
0
|
my $profile_update; |
86
|
0
|
|
|
|
|
0
|
my $profile_value; |
87
|
1
|
|
|
|
|
16
|
my $user_config = $class->SUPER::config_hash( $nakamura, @ARGV ); |
88
|
1
|
|
|
|
|
43
|
$user_config->{'me'} = \$me; |
89
|
1
|
|
|
|
|
4
|
$user_config->{'profile-field'} = \$profile_field; |
90
|
1
|
|
|
|
|
3
|
$user_config->{'profile-section'} = \$profile_section; |
91
|
1
|
|
|
|
|
4
|
$user_config->{'profile-update'} = \$profile_update; |
92
|
1
|
|
|
|
|
3
|
$user_config->{'profile-value'} = \$profile_value; |
93
|
|
|
|
|
|
|
|
94
|
1
|
|
|
|
|
4
|
return $user_config; |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
#}}} |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
#{{{sub me |
100
|
|
|
|
|
|
|
sub me { |
101
|
0
|
|
|
0
|
1
|
0
|
my ($user) = @_; |
102
|
0
|
|
|
|
|
0
|
my $res = |
103
|
|
|
|
|
|
|
Apache::Sling::Request::request( \$user, |
104
|
|
|
|
|
|
|
Sakai::Nakamura::UserUtil::me_setup( $user->{'BaseURL'} ) ); |
105
|
0
|
|
|
|
|
0
|
my $success = Sakai::Nakamura::UserUtil::me_eval($res); |
106
|
0
|
|
|
|
|
0
|
my $message = ( |
107
|
|
|
|
|
|
|
$success |
108
|
0
|
0
|
|
|
|
0
|
? ${$res}->content |
109
|
|
|
|
|
|
|
: 'Problem fetching details for current user' |
110
|
|
|
|
|
|
|
); |
111
|
0
|
|
|
|
|
0
|
$user->set_results( "$message", $res ); |
112
|
0
|
|
|
|
|
0
|
return $success; |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
#}}} |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
#{{{sub profile_update |
118
|
|
|
|
|
|
|
sub profile_update { |
119
|
1
|
|
|
1
|
1
|
2957
|
my ( $user, $field, $value, $act_on_user, $profile_section ) = @_; |
120
|
1
|
|
|
|
|
9
|
my $res = Apache::Sling::Request::request( |
121
|
|
|
|
|
|
|
\$user, |
122
|
|
|
|
|
|
|
Sakai::Nakamura::UserUtil::profile_update_setup( |
123
|
|
|
|
|
|
|
$user->{'BaseURL'}, $field, $value, |
124
|
|
|
|
|
|
|
$act_on_user, $profile_section |
125
|
|
|
|
|
|
|
) |
126
|
|
|
|
|
|
|
); |
127
|
0
|
|
|
|
|
0
|
my $success = Sakai::Nakamura::UserUtil::profile_update_eval($res); |
128
|
0
|
0
|
|
|
|
0
|
my $message = ( |
129
|
|
|
|
|
|
|
$success |
130
|
|
|
|
|
|
|
? 'Profile successfully updated' |
131
|
|
|
|
|
|
|
: 'Problem fetching details for current user' |
132
|
|
|
|
|
|
|
); |
133
|
0
|
|
|
|
|
0
|
$user->set_results( "$message", $res ); |
134
|
0
|
|
|
|
|
0
|
return $success; |
135
|
|
|
|
|
|
|
} |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
#}}} |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
#{{{sub run |
140
|
|
|
|
|
|
|
sub run { |
141
|
2
|
|
|
2
|
1
|
37
|
my ( $user, $nakamura, $config ) = @_; |
142
|
2
|
100
|
|
|
|
6
|
if ( !defined $config ) { |
143
|
1
|
|
|
|
|
16
|
croak 'No user config supplied!'; |
144
|
|
|
|
|
|
|
} |
145
|
1
|
|
|
|
|
3
|
my $authn = |
146
|
|
|
|
|
|
|
defined $nakamura->{'Authn'} |
147
|
1
|
50
|
|
|
|
5
|
? ${ $nakamura->{'Authn'} } |
148
|
|
|
|
|
|
|
: new Sakai::Nakamura::Authn( \$nakamura ); |
149
|
|
|
|
|
|
|
|
150
|
1
|
|
|
|
|
3
|
my $success = 1; |
151
|
|
|
|
|
|
|
|
152
|
1
|
50
|
|
|
|
7
|
if ( $nakamura->{'Help'} ) { $user->help(); } |
|
0
|
50
|
|
|
|
0
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
153
|
0
|
|
|
|
|
0
|
elsif ( $nakamura->{'Man'} ) { $user->man(); } |
|
1
|
|
|
|
|
5
|
|
154
|
1
|
|
|
|
|
5
|
elsif ( defined ${ $config->{'exists'} } ) { |
155
|
0
|
|
|
|
|
0
|
$authn->login_user(); |
156
|
0
|
|
|
|
|
0
|
my $user = new Sakai::Nakamura::User( \$authn, $nakamura->{'Verbose'}, |
157
|
|
|
|
|
|
|
$nakamura->{'Log'} ); |
158
|
0
|
|
|
|
|
0
|
$success = $user->check_exists( ${ $config->{'exists'} } ); |
|
0
|
|
|
|
|
0
|
|
159
|
0
|
|
|
|
|
0
|
Apache::Sling::Print::print_result($user); |
160
|
|
|
|
|
|
|
} |
161
|
1
|
|
|
|
|
4
|
elsif ( defined ${ $config->{'me'} } ) { |
162
|
0
|
|
|
|
|
0
|
$authn->login_user(); |
163
|
0
|
|
|
|
|
0
|
my $user = new Sakai::Nakamura::User( \$authn, $nakamura->{'Verbose'}, |
164
|
|
|
|
|
|
|
$nakamura->{'Log'} ); |
165
|
0
|
|
|
|
|
0
|
$success = $user->me(); |
166
|
0
|
|
|
|
|
0
|
Apache::Sling::Print::print_result($user); |
167
|
|
|
|
|
|
|
} |
168
|
|
|
|
|
|
|
elsif ( defined ${ $config->{'profile-update'} } ) { |
169
|
0
|
|
|
|
|
0
|
$authn->login_user(); |
170
|
0
|
|
|
|
|
0
|
my $user = new Sakai::Nakamura::User( \$authn, $nakamura->{'Verbose'}, |
171
|
|
|
|
|
|
|
$nakamura->{'Log'} ); |
172
|
0
|
|
|
|
|
0
|
$success = $user->profile_update( |
173
|
0
|
|
|
|
|
0
|
${ $config->{'profile-field'} }, |
174
|
0
|
|
|
|
|
0
|
${ $config->{'profile-value'} }, |
175
|
0
|
|
|
|
|
0
|
${ $config->{'profile-update'} }, |
176
|
0
|
|
|
|
|
0
|
${ $config->{'profile-section'} } |
177
|
|
|
|
|
|
|
); |
178
|
0
|
|
|
|
|
0
|
Apache::Sling::Print::print_result($user); |
179
|
|
|
|
|
|
|
} |
180
|
|
|
|
|
|
|
else { |
181
|
1
|
|
|
|
|
9
|
$success = $user->SUPER::run( $nakamura, $config ); |
182
|
|
|
|
|
|
|
} |
183
|
1
|
|
|
|
|
57
|
return $success; |
184
|
|
|
|
|
|
|
} |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
#}}} |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
1; |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
__END__ |