line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#!/usr/bin/perl -w |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Sakai::Nakamura::UserUtil; |
4
|
|
|
|
|
|
|
|
5
|
2
|
|
|
2
|
|
44262
|
use 5.008008; |
|
2
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
85
|
|
6
|
2
|
|
|
2
|
|
12
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
78
|
|
7
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
70
|
|
8
|
2
|
|
|
2
|
|
68
|
use Carp; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
287
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
require Exporter; |
11
|
|
|
|
|
|
|
|
12
|
2
|
|
|
2
|
|
13
|
use base qw(Exporter); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
1212
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
our @EXPORT_OK = (); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
our $VERSION = '0.13'; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
#{{{sub exists_setup |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub exists_setup { |
21
|
0
|
|
|
0
|
1
|
0
|
my ( $base_url, $act_on_user ) = @_; |
22
|
0
|
0
|
|
|
|
0
|
if ( !defined $base_url ) { |
23
|
0
|
|
|
|
|
0
|
croak 'No base url to check existence against!'; |
24
|
|
|
|
|
|
|
} |
25
|
0
|
0
|
|
|
|
0
|
if ( !defined $act_on_user ) { |
26
|
0
|
|
|
|
|
0
|
croak 'No user to check existence of defined!'; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
return |
29
|
0
|
|
|
|
|
0
|
"get $base_url/system/userManager/user.exists.html?userid=$act_on_user"; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
#}}} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
#{{{sub exists_eval |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub exists_eval { |
37
|
0
|
|
|
0
|
1
|
0
|
my ($res) = @_; |
38
|
0
|
|
|
|
|
0
|
return ( ${$res}->code eq '204' ); |
|
0
|
|
|
|
|
0
|
|
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
#}}} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
#{{{sub me_setup |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub me_setup { |
46
|
2
|
|
|
2
|
1
|
138
|
my ($base_url) = @_; |
47
|
2
|
100
|
|
|
|
9
|
if ( !defined $base_url ) { |
48
|
1
|
|
|
|
|
28
|
croak 'No base url to run me against!'; |
49
|
|
|
|
|
|
|
} |
50
|
1
|
|
|
|
|
10
|
return "get $base_url/system/me"; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
#}}} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
#{{{sub me_eval |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub me_eval { |
58
|
1
|
|
|
1
|
1
|
3
|
my ($res) = @_; |
59
|
1
|
|
|
|
|
3
|
return ( ${$res}->code eq '200' ); |
|
1
|
|
|
|
|
6
|
|
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
#}}} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
#{{{sub profile_update_setup |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub profile_update_setup { |
67
|
7
|
|
|
7
|
1
|
111
|
my ( $base_url, $field, $value, $act_on_user, $profile_section ) = @_; |
68
|
7
|
100
|
|
|
|
23
|
if ( !defined $base_url ) { |
69
|
1
|
|
|
|
|
10
|
croak 'No base url to run profile update against!'; |
70
|
|
|
|
|
|
|
} |
71
|
6
|
100
|
|
|
|
21
|
if ( !defined $field ) { |
72
|
2
|
|
|
|
|
40
|
croak 'No profile field to update specified!'; |
73
|
|
|
|
|
|
|
} |
74
|
4
|
100
|
|
|
|
10
|
if ( !defined $value ) { |
75
|
1
|
|
|
|
|
11
|
croak 'No value specified to set profile field to!'; |
76
|
|
|
|
|
|
|
} |
77
|
3
|
100
|
|
|
|
9
|
if ( !defined $act_on_user ) { |
78
|
1
|
|
|
|
|
15
|
croak 'No user specified to update profile for!'; |
79
|
|
|
|
|
|
|
} |
80
|
2
|
100
|
|
|
|
7
|
if ( !defined $profile_section ) { |
81
|
1
|
|
|
|
|
3
|
$profile_section = 'basic'; |
82
|
|
|
|
|
|
|
} |
83
|
2
|
|
|
|
|
7
|
my $profile_update_json = |
84
|
|
|
|
|
|
|
"{\"elements\":{\"$field\":{\"value\":\"$value\"}}}"; |
85
|
2
|
|
|
|
|
6
|
my $post_variables = |
86
|
|
|
|
|
|
|
"\$post_variables = [':content','$profile_update_json',':contentType','json',':operation','import',':removeTree','true',':replace','true',':replaceProperties','true']"; |
87
|
|
|
|
|
|
|
return |
88
|
2
|
|
|
|
|
17
|
"post $base_url/~$act_on_user/public/authprofile/$profile_section.profile.json $post_variables"; |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
#}}} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
#{{{sub profile_update_eval |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub profile_update_eval { |
96
|
1
|
|
|
1
|
1
|
312
|
my ($res) = @_; |
97
|
1
|
|
|
|
|
3
|
return ( ${$res}->code eq '200' ); |
|
1
|
|
|
|
|
5
|
|
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
#}}} |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
1; |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
__END__ |