| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Labyrinth::Plugin::Users::Info; |
|
2
|
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
4747
|
use warnings; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
58
|
|
|
4
|
2
|
|
|
2
|
|
7
|
use strict; |
|
|
2
|
|
|
|
|
2
|
|
|
|
2
|
|
|
|
|
70
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
my $VERSION = '5.17'; |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 NAME |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
Labyrinth::Plugin::Users::Info - Additional Users Info handler for Labyrinth |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
Contains all the additional user info handling functionality for the Labyrinth |
|
15
|
|
|
|
|
|
|
framework. |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=cut |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
# ------------------------------------- |
|
20
|
|
|
|
|
|
|
# Library Modules |
|
21
|
|
|
|
|
|
|
|
|
22
|
2
|
|
|
2
|
|
6
|
use base qw(Labyrinth::Plugin::Base); |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
717
|
|
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
use Labyrinth::Audit; |
|
25
|
|
|
|
|
|
|
use Labyrinth::DBUtils; |
|
26
|
|
|
|
|
|
|
use Labyrinth::Media; |
|
27
|
|
|
|
|
|
|
use Labyrinth::MLUtils; |
|
28
|
|
|
|
|
|
|
use Labyrinth::Session; |
|
29
|
|
|
|
|
|
|
use Labyrinth::Writer; |
|
30
|
|
|
|
|
|
|
use Labyrinth::Support; |
|
31
|
|
|
|
|
|
|
use Labyrinth::Users; |
|
32
|
|
|
|
|
|
|
use Labyrinth::Variables; |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
use Clone qw/clone/; |
|
35
|
|
|
|
|
|
|
use Config::IniFiles; |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
# ------------------------------------- |
|
38
|
|
|
|
|
|
|
# Variables |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
# type: 0 = optional, 1 = mandatory |
|
41
|
|
|
|
|
|
|
# html: 0 = none, 1 = text, 2 = textarea |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
my %fields = ( |
|
44
|
|
|
|
|
|
|
userid => { type => 1, html => 0 }, |
|
45
|
|
|
|
|
|
|
); |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
# distros => { type => 0, html => 1 }, |
|
48
|
|
|
|
|
|
|
# skills => { type => 0, html => 1 }, |
|
49
|
|
|
|
|
|
|
# hobbies => { type => 0, html => 1 }, |
|
50
|
|
|
|
|
|
|
# location => { type => 0, html => 1 }, |
|
51
|
|
|
|
|
|
|
# hometitle => { type => 0, html => 1 }, |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
my (@mandatory,@allfields,@fieldorder,@fieldnames); |
|
55
|
|
|
|
|
|
|
for(keys %fields) { |
|
56
|
|
|
|
|
|
|
push @mandatory, $_ if($fields{$_}->{type}); |
|
57
|
|
|
|
|
|
|
push @allfields, $_; |
|
58
|
|
|
|
|
|
|
} |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
my $LEVEL = ADMIN; |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
# ------------------------------------- |
|
63
|
|
|
|
|
|
|
# The Subs |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head1 PUBLIC INTERFACE METHODS |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=over 4 |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=item Item |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
Provides the addition user information for the given user. |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=back |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=cut |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub Item { |
|
78
|
|
|
|
|
|
|
return unless($cgiparams{'userid'}); |
|
79
|
|
|
|
|
|
|
my @rows = $dbi->GetQuery('hash','GetUserInfoByID',$cgiparams{'userid'}); |
|
80
|
|
|
|
|
|
|
$tvars{user}->{info} = $rows[0]; |
|
81
|
|
|
|
|
|
|
} |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head1 ADMIN INTERFACE METHODS |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=over 4 |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=item Edit |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
Edit the addition user information for the given user. |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=item Save |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
Save the addition user information for the given user. |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=item Delete |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
Delete the addition user information for the given user. |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=item LoadInfo |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
Load the user information required. |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=back |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=cut |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
sub Edit { |
|
108
|
|
|
|
|
|
|
$cgiparams{userid} ||= $tvars{'loginid'}; |
|
109
|
|
|
|
|
|
|
return unless MasterCheck(); |
|
110
|
|
|
|
|
|
|
return unless AccessUser($LEVEL); |
|
111
|
|
|
|
|
|
|
return unless AuthorCheck('GetUserInfoByID','userid',$LEVEL); |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
LoadInfo(); |
|
114
|
|
|
|
|
|
|
for(keys %fields) { |
|
115
|
|
|
|
|
|
|
if($fields{$_}->{html} == 1) { $tvars{user}{data}->{$_} = CleanHTML($tvars{data}->{$_}); |
|
116
|
|
|
|
|
|
|
$tvars{user}{preview}->{$_} = CleanHTML($tvars{data}->{$_}); } |
|
117
|
|
|
|
|
|
|
elsif($fields{$_}->{html} == 2) { $tvars{user}{data}->{$_} = CleanTags($tvars{data}->{$_}); } |
|
118
|
|
|
|
|
|
|
} |
|
119
|
|
|
|
|
|
|
} |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
sub Save { |
|
122
|
|
|
|
|
|
|
return unless MasterCheck(); |
|
123
|
|
|
|
|
|
|
return unless AccessUser($LEVEL); |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
my $newuser = $cgiparams{'userid'} ? 0 : 1; |
|
126
|
|
|
|
|
|
|
if(!$newuser && $cgiparams{userid} != $tvars{'loginid'} && !Authorised($LEVEL)) { |
|
127
|
|
|
|
|
|
|
$tvars{errcode} = 'BADACCESS'; |
|
128
|
|
|
|
|
|
|
return; |
|
129
|
|
|
|
|
|
|
} |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
return unless AuthorCheck('GetUserInfoByID','userid',$LEVEL); |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
LoadInfo(); |
|
134
|
|
|
|
|
|
|
$tvars{newuser} = $newuser; |
|
135
|
|
|
|
|
|
|
for(keys %fields) { |
|
136
|
|
|
|
|
|
|
if($fields{$_}->{html} == 1) { $cgiparams{$_} = CleanHTML($cgiparams{$_}) } |
|
137
|
|
|
|
|
|
|
elsif($fields{$_}->{html} == 2) { $cgiparams{$_} = CleanTags($cgiparams{$_}) } |
|
138
|
|
|
|
|
|
|
elsif($fields{$_}->{html} == 3) { $cgiparams{$_} = CleanLink($cgiparams{$_}) } |
|
139
|
|
|
|
|
|
|
} |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
return if FieldCheck(\@allfields,\@mandatory); |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
my @fields = ((map {$tvars{data}->{$_}} @fieldorder), $tvars{data}->{'userid'}); |
|
144
|
|
|
|
|
|
|
$dbi->DoQuery('SaveUserInfo',{ 'keys' => join(',', map {"$_=?"} @fieldnames) },@fields); |
|
145
|
|
|
|
|
|
|
} |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
sub LoadInfo { |
|
148
|
|
|
|
|
|
|
my $file = $settings{config} . '/user-info.ini'; |
|
149
|
|
|
|
|
|
|
return unless(-f $file); |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
my $cfg = Config::IniFiles->new( -file => $file ); |
|
152
|
|
|
|
|
|
|
unless(defined $cfg) { |
|
153
|
|
|
|
|
|
|
LogWarn("Unable to load user info file [$file]"); |
|
154
|
|
|
|
|
|
|
return; |
|
155
|
|
|
|
|
|
|
} |
|
156
|
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
for my $name ($cfg->Parameters('EXTRA')) { |
|
158
|
|
|
|
|
|
|
my $value = $cfg->val('EXTRA',$name); |
|
159
|
|
|
|
|
|
|
next unless($value); |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
my ($type,$html,$field) = split(',',$value); |
|
162
|
|
|
|
|
|
|
$fields{$name} = {type => $type, html => $html}; |
|
163
|
|
|
|
|
|
|
push @fieldorder, $name; |
|
164
|
|
|
|
|
|
|
push @fieldnames, $field; |
|
165
|
|
|
|
|
|
|
} |
|
166
|
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
(@mandatory,@allfields) = (); |
|
168
|
|
|
|
|
|
|
for(keys %fields) { |
|
169
|
|
|
|
|
|
|
push @mandatory, $_ if($fields{$_}->{type}); |
|
170
|
|
|
|
|
|
|
push @allfields, $_; |
|
171
|
|
|
|
|
|
|
} |
|
172
|
|
|
|
|
|
|
} |
|
173
|
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
1; |
|
175
|
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
__END__ |