Users.pm

filter: Statementstmt 17.2% 59 / 342 Branchbran 0.9% 2 / 208 Conditioncond 0.0% 0 / 47 MC/DCmcdc 0.0% 0 / 29 Subroutinesub 37.7% 17 / 45 Podpod 100% 28 / 28 totaltotal 15.1% 106 / 699 CC 131 SCAR 51.9
CC
131
Cov
10%
UserLists
462.0
Save
380.0
AdminSave
342.0
CRAP 179.9
« Menus.pm ↑ Summary News.pm »
1 package Labyrinth::Plugin::Users;
2  
3 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 4 our $VERSION = '5.19';
7  
8 =head1 NAME
9  
10 Labyrinth::Plugin::Users - Plugin Users handler for Labyrinth
11  
12 =head1 DESCRIPTION
13  
14 Contains all the default user handling functionality for the Labyrinth
15 framework.
16  
17 =cut
18  
19 # -------------------------------------
20 # Library Modules
21  
22 4 ▶use base qw(Labyrinth::Plugin::Base);
Subroutine BEGIN: called CC=1 SCAR=0.0
23  
24 4 ▶use Labyrinth::Audit;
Subroutine BEGIN: called CC=1 SCAR=0.0
25 4 ▶use Labyrinth::DBUtils;
Subroutine BEGIN: called CC=1 SCAR=0.0
26 4 ▶use Labyrinth::Media;
Subroutine BEGIN: called CC=1 SCAR=0.0
27 4 ▶use Labyrinth::MLUtils;
Subroutine BEGIN: called CC=1 SCAR=0.0
28 4 ▶use Labyrinth::Session;
Subroutine BEGIN: called CC=1 SCAR=0.0
29 4 ▶use Labyrinth::Writer;
Subroutine BEGIN: called CC=1 SCAR=0.0
30 4 ▶use Labyrinth::Support;
Subroutine BEGIN: called CC=1 SCAR=0.0
31 4 ▶use Labyrinth::Users;
Subroutine BEGIN: called CC=1 SCAR=0.0
32 4 ▶use Labyrinth::Variables;
Subroutine BEGIN: called CC=1 SCAR=0.0
33  
34 4 ▶use Clone qw/clone/;
Subroutine BEGIN: called CC=1 SCAR=0.0
35 4 ▶use Digest::MD5 qw(md5_hex);
Subroutine BEGIN: called CC=1 SCAR=0.0
36 4 ▶use URI::Escape qw(uri_escape);
Subroutine BEGIN: called CC=1 SCAR=0.0
37  
38 # -------------------------------------
39 # Constants
40  
41 4 ▶use constant MaxUserWidth => 300;
Subroutine BEGIN: called CC=1 SCAR=0.0
42 4 ▶use constant MaxUserHeight => 400;
Subroutine BEGIN: called CC=1 SCAR=0.0
43  
44 # -------------------------------------
45 # Variables
46  
47 # type: 0 = optional, 1 = mandatory
48 # html: 0 = none, 1 = text, 2 = textarea
49  
50 4 my %fields = (
51 email => { type => 1, html => 1 },
52 effect => { type => 0, html => 1 },
53 userid => { type => 0, html => 0 },
54 nickname => { type => 0, html => 1 },
55 realname => { type => 1, html => 1 },
56 aboutme => { type => 0, html => 2 },
57 search => { type => 0, html => 0 },
58 image => { type => 0, html => 0 },
59 accessid => { type => 0, html => 0 },
60 realmid => { type => 0, html => 0 },
61 );
62  
63 4 my (@mandatory,@allfields);
64 4 for(keys %fields) {
65 40 ▶ push @mandatory, $_ if($fields{$_}->{type});
Branch: 1 branch
BranchTrueFalseTotal
if $fields{$_}{"type"} 8 32 40
66 40 push @allfields, $_;
67 }
68  
69 4 my $LEVEL = ADMIN;
70  
71 # -------------------------------------
72 # The Subs
73  
74 =head1 PUBLIC INTERFACE METHODS
75  
76 =over 4
77  
78 =item UserLists
79  
80 Provide the current user list, taking into account of any search strings and
81 filters.
82  
83 =item Gravatar
84  
85 Provide the gravatar for a specified user.
86  
87 =item Item
88  
89 Provide the content attributed to the specified user.
90  
91 =item Name
92  
93 Provide the name of the specified user.
94  
95 =item Password
96  
97 Check and store a change of password.
98  
99 =item Register
100  
101 Provide the template variable hash for a new user to register.
102  
103 =item Registered
104  
105 Set the email address for the newly registered user, to auto log them in.
106  
107 =back
108  
109 =cut
110  
111 0 ▶sub UserLists {
Subroutine UserLists: not called CC=21 SCAR=61.4
Pod documented
112 0 my (%search,$search,$key);
113 0 my @fields = ();
114 0 $search{where} = '';
115 0 $search{order} = 'realname,nickname';
116 0 $search{search} = 1;
117 0 $search{access} = MASTER + 1;
118  
119 0 ▶ if(Authorised(ADMIN)) {
Branch: 1 branch
BranchTrueFalseTotal
if (Authorised(4)) 0 0 0
120 0 ▶ $search{order} = 'u.realname' if($cgiparams{ordered});
Branch: 1 branch
BranchTrueFalseTotal
if $Labyrinth::Plugin::Users::cgiparams{"ordered"} 0 0 0
121 0 $search{search} = 0;
122 0 ▶ $search{access} = PUBLISHER if($tvars{loginid} > 1);
Branch: 1 branch
BranchTrueFalseTotal
if $Labyrinth::Plugin::Users::tvars{"loginid"} > 1 0 0 0
123 }
124  
125 0 ▶ if($cgiparams{'all'}) {
Branch: 4 branches
BranchTrueFalseTotal
if ($Labyrinth::Plugin::Users::cgiparams{'all'}) { } 0 0 0
elsif ($Labyrinth::Plugin::Users::cgiparams{'letter'}) { } 0 0 0
elsif ($Labyrinth::Plugin::Users::cgiparams{'searchname'}) { } 0 0 0
elsif ($Labyrinth::Plugin::Users::cgiparams{'searched'}) { } 0 0 0
126 0 $key = 'SearchUsers';
127 0 @fields = ('%','%');
128  
129 } elsif($cgiparams{'letter'}) {
130 0 ▶ $search = ($cgiparams{'letter'} || '') . '%';
Condition0%0/2
$Labyrinth::Plugin::Users::cgiparams{'letter'} || ''
l!l
00
MC/DC0%0/1
$Labyrinth::Plugin::Users::cgiparams{'letter'} || ''
$Labyrinth::Plugin::Users::cgiparams{'letter'}
Truth table0%0/2
A
A= $Labyrinth::Plugin::Users::cgiparams{'letter'}
Aresult
11
00
131 0 @fields = ($search,$search);
132 0 $key = 'SearchUserNames';
133  
134 } elsif($cgiparams{'searchname'}) {
135 0 $search = '%' . $cgiparams{'searchname'} . '%';
136 0 @fields = ($search,$search);
137 0 $key = 'SearchUserNames';
138  
139 } elsif($cgiparams{'searched'}) {
140 0 @fields = ($cgiparams{'searched'},$cgiparams{'searched'});
141 0 $key = 'SearchUsers';
142  
143 } else {
144 0 $key = 'SearchUsers';
145 0 @fields = ('%','%');
146 }
147  
148 0 my @rows = $dbi->GetQuery('hash',$key,\%search,@fields);
149 0 LogDebug("UserList: key=[$key], rows found=[".scalar(@rows)."]");
150  
151 0 for(@rows) {
152 0 ($_->{width},$_->{height}) = GetImageSize($_->{link},$_->{dimensions},$_->{width},$_->{height},MaxUserWidth,MaxUserHeight);
153 0 $_->{gravatar} = GetGravatar($_->{userid},$_->{email});
154  
155 0 ▶ if($_->{url} && $_->{url} !~ /^https?:/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_->{"url"} and not $_->{"url"} =~ /^https?:/) 0 0 0
Condition0%0/3
$_->{"url"} and not $_->{"url"} =~ /^https?:/
!ll&&!rl&&r
000
MC/DC0%0/2
$_->{"url"} and not $_->{"url"} =~ /^https?:/
$_->{"url"} not $_->{"url"} =~ /^https?:/
Truth table0%0/3
A and not(B)
A= $_->{"url"}B= not $_->{"url"} =~ /^https?:/
ABresult
0X0
100
111
156 0 $_->{url} = 'http://' . $_->{url};
157 }
158 0 ▶ if($_->{aboutme}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_->{"aboutme"}) 0 0 0
159 0 ▶ $_->{aboutme} = '<p>' . $_->{aboutme} unless($_->{aboutme} =~ /^\s*<p>/si);
Branch: 1 branch
BranchTrueFalseTotal
unless $_->{"aboutme"} =~ /^\s*<p>/is 0 0 0
160 0 ▶ $_->{aboutme} .= '</p>' unless($_->{aboutme} =~ m!</p>\s*$!si);
Branch: 1 branch
BranchTrueFalseTotal
unless $_->{"aboutme"} =~ m[</p>\s*$]is 0 0 0
161 }
162 0 my @grps = $dbi->GetQuery('hash','LinkedUsers',$_->{userid});
163 0 ▶ if(@grps) {
Branch: 1 branch
BranchTrueFalseTotal
if (@grps) 0 0 0
164 0 $_->{member} = $grps[0]->{member};
165 }
166 0 ▶ if(Authorised(ADMIN)) {
Branch: 1 branch
BranchTrueFalseTotal
if (Authorised(4)) { } 0 0 0
167 0 $_->{name} = $_->{realname};
168 0 ▶ $_->{name} .= " ($_->{nickname})" if($_->{nickname});
Branch: 1 branch
BranchTrueFalseTotal
if $_->{"nickname"} 0 0 0
169 } else {
170 0 ▶ $_->{name} = $_->{nickname} || $_->{realname};
Condition0%0/3
$_->{'nickname'} || $_->{'realname'}
l!l&&r!l&&!r
000
MC/DC0%0/2
$_->{'nickname'} || $_->{'realname'}
$_->{'nickname'} $_->{'realname'}
Truth table0%0/3
A || B
A= $_->{'nickname'}B= $_->{'realname'}
ABresult
1X1
011
000
171 }
172 }
173  
174 0 ▶ $tvars{users} = \@rows if(@rows);
Branch: 1 branch
BranchTrueFalseTotal
if @rows 0 0 0
175 0 ▶ $tvars{searched} = $fields[0] if(@fields);
Branch: 1 branch
BranchTrueFalseTotal
if @fields 0 0 0
176 }
177  
178 0 ▶sub Gravatar {
Subroutine Gravatar: not called CC=3 SCAR=24.8
Pod documented
179 0 my $nophoto = uri_escape($settings{nophoto});
180 0 $tvars{data}{gravatar} = $nophoto;
181  
182 0 ▶ return unless $cgiparams{'userid'};
Branch: 1 branch
BranchTrueFalseTotal
unless $Labyrinth::Plugin::Users::cgiparams{"userid"} 0 0 0
183 0 my @rows = $dbi->GetQuery('hash','GetUserByID',$cgiparams{'userid'});
184 0 ▶ return unless @rows;
Branch: 1 branch
BranchTrueFalseTotal
unless @rows 0 0 0
185  
186 $tvars{data}{gravatar} =
187 'http://www.gravatar.com/avatar.php?'
188 .'gravatar_id='.md5_hex($rows[0]->{email})
189 0 .'&amp;default='.$nophoto
190 .'&amp;size=80';
191 }
192  
193 0 ▶sub Item {
Subroutine Item: not called CC=5 SCAR=34.0
Pod documented
194 0 ▶ return unless $cgiparams{'userid'};
Branch: 1 branch
BranchTrueFalseTotal
unless $Labyrinth::Plugin::Users::cgiparams{"userid"} 0 0 0
195  
196 0 my @rows = $dbi->GetQuery('hash','GetUserByID',$cgiparams{'userid'});
197 0 ▶ return unless(@rows);
Branch: 1 branch
BranchTrueFalseTotal
unless @rows 0 0 0
198  
199 0 ▶ $rows[0]->{tag} = '' if($rows[0]->{link} =~ /blank.png/);
Branch: 1 branch
BranchTrueFalseTotal
if $rows[0]{"link"} =~ /blank.png/ 0 0 0
200 0 ▶ $rows[0]->{link} = '' if($rows[0]->{link} =~ /blank.png/);
Branch: 1 branch
BranchTrueFalseTotal
if $rows[0]{"link"} =~ /blank.png/ 0 0 0
201  
202 0 ($rows[0]->{width},$rows[0]->{height}) = GetImageSize($rows[0]->{link},$rows[0]->{dimensions},$rows[0]->{width},$rows[0]->{height},MaxUserWidth,MaxUserHeight);
203 0 $rows[0]->{gravatar} = GetGravatar($rows[0]->{userid},$rows[0]->{email});
204  
205 0 $tvars{data} = $rows[0];
206 }
207  
208 0 ▶sub Name {
Subroutine Name: not called CC=2 SCAR=17.9
Pod documented
209 0 ▶ return unless($cgiparams{'userid'});
Branch: 1 branch
BranchTrueFalseTotal
unless $Labyrinth::Plugin::Users::cgiparams{"userid"} 0 0 0
210 0 return UserName($cgiparams{'userid'})
211 }
212  
213 0 ▶sub Password {
Subroutine Password: not called CC=16 SCAR=56.1
Pod documented
214 0 ▶ return unless $tvars{'loggedin'};
Branch: 1 branch
BranchTrueFalseTotal
unless $Labyrinth::Plugin::Users::tvars{"loggedin"} 0 0 0
215  
216 0 ▶ $cgiparams{'userid'} = $tvars{'loginid'} unless(Authorised(ADMIN) && $cgiparams{'userid'});
Branch: 1 branch
BranchTrueFalseTotal
unless Authorised(4) and $Labyrinth::Plugin::Users::cgiparams{"userid"} 0 0 0
Condition0%0/3
Authorised(4) and $Labyrinth::Plugin::Users::cgiparams{"userid"}
!ll&&!rl&&r
000
MC/DC0%0/2
Authorised(4) and $Labyrinth::Plugin::Users::cgiparams{"userid"}
Authorised(4) $Labyrinth::Plugin::Users::cgiparams{"userid"}
Truth table0%0/3
A and B
A= Authorised(4)B= $Labyrinth::Plugin::Users::cgiparams{"userid"}
ABresult
0X0
100
111
217 0 $tvars{data}->{name} = UserName($cgiparams{userid});
218  
219 0 my @manfields = qw(userid effect2 effect3);
220 0 ▶ push @manfields, 'effect1' if($cgiparams{'userid'} == $tvars{'loginid'} || $tvars{user}{access} < ADMIN);
Branch: 1 branch
BranchTrueFalseTotal
if $Labyrinth::Plugin::Users::cgiparams{"userid"} == $Labyrinth::Plugin::Users::tvars{"loginid"} or $Labyrinth::Plugin::Users::tvars{"user"}{"access"} < 4 0 0 0
Condition0%0/3
$Labyrinth::Plugin::Users::cgiparams{"userid"} == $Labyrinth::Plugin::Users::tvars{"loginid"} or $Labyrinth::Plugin::Users::tvars{"user"}{"access"} < 4
l!l&&r!l&&!r
000
MC/DC0%0/2
$Labyrinth::Plugin::Users::cgiparams{"userid"} == $Labyrinth::Plugin::Users::tvars{"loginid"} or $Labyrinth::Plugin::Users::tvars{"user"}{"access"} < 4
$Labyrinth::Plugin::Users::cgiparams{"userid"} == $Labyrinth::Plugin::Users::tvars{"loginid"} $Labyrinth::Plugin::Users::tvars{"user"}{"access"} < 4
Truth table0%0/3
A or B
A= $Labyrinth::Plugin::Users::cgiparams{"userid"} == $Labyrinth::Plugin::Users::tvars{"loginid"}B= $Labyrinth::Plugin::Users::tvars{"user"}{"access"} < 4
ABresult
1X1
011
000
221  
222 0 ▶ if(FieldCheck(\@manfields,\@manfields)) {
Branch: 1 branch
BranchTrueFalseTotal
if (FieldCheck(\@manfields, \@manfields)) 0 0 0
223 0 $tvars{errmess} = 'All fields must be complete, please try again.';
224 0 $tvars{errcode} = 'ERROR';
225 0 return;
226 }
227  
228 0 my $who = $cgiparams{'userid'};
229 0 ▶ $who = $tvars{'loginid'} if(Authorised(ADMIN));
Branch: 1 branch
BranchTrueFalseTotal
if Authorised(4) 0 0 0
230  
231 0 ▶ if($cgiparams{'userid'} == $tvars{'loginid'} || $tvars{user}{access} < ADMIN) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Labyrinth::Plugin::Users::cgiparams{"userid"} == $Labyrinth::Plugin::Users::tvars{"loginid"} or $Labyrinth::Plugin::Users::tvars{"user"}{"access"} < 4) 0 0 0
Condition0%0/3
$Labyrinth::Plugin::Users::cgiparams{"userid"} == $Labyrinth::Plugin::Users::tvars{"loginid"} or $Labyrinth::Plugin::Users::tvars{"user"}{"access"} < 4
l!l&&r!l&&!r
000
MC/DC0%0/2
$Labyrinth::Plugin::Users::cgiparams{"userid"} == $Labyrinth::Plugin::Users::tvars{"loginid"} or $Labyrinth::Plugin::Users::tvars{"user"}{"access"} < 4
$Labyrinth::Plugin::Users::cgiparams{"userid"} == $Labyrinth::Plugin::Users::tvars{"loginid"} $Labyrinth::Plugin::Users::tvars{"user"}{"access"} < 4
Truth table0%0/3
A or B
A= $Labyrinth::Plugin::Users::cgiparams{"userid"} == $Labyrinth::Plugin::Users::tvars{"loginid"}B= $Labyrinth::Plugin::Users::tvars{"user"}{"access"} < 4
ABresult
1X1
011
000
232 0 my @rows = $dbi->GetQuery('hash','ValidUser',$who,$cgiparams{'effect1'});
233 0 ▶ unless(@rows) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@rows) 0 0 0
234 0 $tvars{errmess} = 'Current password is invalid, please try again.';
235 0 $tvars{errcode} = 'ERROR';
236 0 return;
237 }
238 }
239  
240 0 ▶ if($cgiparams{effect2} ne $cgiparams{effect3}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Labyrinth::Plugin::Users::cgiparams{"effect2"} ne $Labyrinth::Plugin::Users::cgiparams{"effect3"}) 0 0 0
241 0 $tvars{errmess} = 'New &amp; verify passwords don\'t match, please try again.';
242 0 $tvars{errcode} = 'ERROR';
243 0 return;
244 }
245  
246 0 my %passerrors = (
247 1 => "Password too short, length should be $settings{minpasslen}-$settings{maxpasslen} characters.",
248 2 => "Password too long, length should be $settings{minpasslen}-$settings{maxpasslen} characters.",
249 3 => 'Password not cyptic enough, please enter as per password rules.',
250 4 => 'Password contains spaces or tabs.',
251 5 => 'Password should contain 3 or more unique characters.',
252 );
253  
254 0 my $invalid = PasswordCheck($cgiparams{effect2});
255 0 ▶ if($invalid) {
Branch: 1 branch
BranchTrueFalseTotal
if ($invalid) 0 0 0
256 0 $tvars{errmess} = $passerrors{$invalid};
257 0 $tvars{errcode} = 'ERROR';
258 0 return;
259 }
260  
261 0 $dbi->DoQuery('ChangePassword',$cgiparams{effect2},$cgiparams{'userid'});
262 0 $tvars{thanks} = 2;
263  
264 0 ▶ if($cgiparams{mailuser}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Labyrinth::Plugin::Users::cgiparams{"mailuser"}) 0 0 0
265 0 my @rows = $dbi->GetQuery('hash','GetUserByID',$cgiparams{'userid'});
266 MailSend( template => 'mailer/reset.eml',
267 name => $rows[0]->{realname},
268 password => $cgiparams{effect2},
269 recipient_email => $rows[0]->{email}
270 0 );
271 }
272  
273 0 ▶ SetCommand('user-adminedit') if(Authorised(ADMIN) && $cgiparams{'userid'} != $tvars{'loginid'});
Branch: 1 branch
BranchTrueFalseTotal
if Authorised(4) and $Labyrinth::Plugin::Users::cgiparams{"userid"} != $Labyrinth::Plugin::Users::tvars{"loginid"} 0 0 0
Condition0%0/3
Authorised(4) and $Labyrinth::Plugin::Users::cgiparams{"userid"} != $Labyrinth::Plugin::Users::tvars{"loginid"}
!ll&&!rl&&r
000
MC/DC0%0/2
Authorised(4) and $Labyrinth::Plugin::Users::cgiparams{"userid"} != $Labyrinth::Plugin::Users::tvars{"loginid"}
Authorised(4) $Labyrinth::Plugin::Users::cgiparams{"userid"} != $Labyrinth::Plugin::Users::tvars{"loginid"}
Truth table0%0/3
A and B
A= Authorised(4)B= $Labyrinth::Plugin::Users::cgiparams{"userid"} != $Labyrinth::Plugin::Users::tvars{"loginid"}
ABresult
0X0
100
111
274 }
275  
276 0 ▶sub Register {
Subroutine Register: not called CC=2 SCAR=17.9
Pod documented
277 0 my %data = (
278 'link' => 'images/blank.png',
279 'tag' => '[No Image]',
280 'admin' => Authorised(ADMIN),
281 );
282  
283 0 $tvars{data}{$_} = $data{$_} for(keys %data);
284 0 $tvars{userid} = 0;
285 0 $tvars{newuser} = 1;
286 0 $tvars{htmltags} = LegalTags();
287 }
288  
289 0 ▶sub Registered {
Subroutine Registered: not called CC=1 SCAR=6.9
Pod documented
290 0 $cgiparams{cause} = $cgiparams{email};
291 }
292  
293 =head1 ADMIN INTERFACE METHODS
294  
295 =over 4
296  
297 =item Login
298  
299 Action the login functionality to the site.
300  
301 =item Logout
302  
303 Action the logout functionality to the site.
304  
305 =item Store
306  
307 =item Retrieve
308  
309 =item LoggedIn
310  
311 Check with the current user is logged in.
312  
313 =item ImageCheck
314  
315 Check whether images uploaded for the user profile are still being used. Used
316 to allow the images plugin to delete unused images.
317  
318 =item Admin
319  
320 List current users.
321  
322 =item Add
323  
324 Provide the template variable hash to create a new user.
325  
326 =item Edit
327  
328 Edit the given user.
329  
330 =item Save
331  
332 Save the given user. For use by the currently logged in user.
333  
334 =item AdminSave
335  
336 Save the given user. For use by admin user to update any non-system user.
337  
338 =item Delete
339  
340 Delete the specified user account
341  
342 =item Ban
343  
344 Ban the specified user account. Account can be reactivated or deleted.
345  
346 Banned users should receive a message at login, explain who they need to
347 contact to be reinstated.
348  
349 =item Disable
350  
351 Disable the specified user account. This different from a banned user, in that
352 disabled accounts cannot be reactivated or deleted. This is to prevent reuse of
353 an old account.
354  
355 =item AdminPass
356  
357 Allow the admin user to create a new password of a given user.
358  
359 Note passwords are store in an encrypted format, so cannot be viewed.
360  
361 =item AdminChng
362  
363 Allow the admin user to change the password of a given user.
364  
365 =cut
366  
367 0 ▶sub Login { Labyrinth::Session::Login() }
Subroutine Login: not called CC=1 SCAR=6.9
Pod documented
368 0 ▶sub Logout { Labyrinth::Session::Logout() }
Subroutine Logout: not called CC=1 SCAR=6.9
Pod documented
369 0 ▶sub Store { Labyrinth::Session::Store() }
Subroutine Store: not called CC=1 SCAR=6.9
Pod documented
370 0 ▶sub Retrieve { Labyrinth::Session::Retrieve() }
Subroutine Retrieve: not called CC=1 SCAR=6.9
Pod documented
371  
372 0 ▶sub LoggedIn {
Subroutine LoggedIn: not called CC=2 SCAR=17.9
Pod documented
373 0 ▶ $tvars{errcode} = 'ERROR' if(!$tvars{loggedin});
Branch: 1 branch
BranchTrueFalseTotal
if not $Labyrinth::Plugin::Users::tvars{"loggedin"} 0 0 0
374 }
375  
376 0 ▶sub ImageCheck {
Subroutine ImageCheck: not called CC=2 SCAR=17.9
Pod documented
377 0 my @rows = $dbi->GetQuery('array','UsersImageCheck',$_[0]);
378 0 ▶ @rows ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
@rows ? : 0 0 0
379 }
380  
381 0 ▶sub Admin {
Subroutine Admin: not called CC=8 SCAR=42.8
Pod documented
382 0 ▶ return unless AccessUser($LEVEL);
Branch: 1 branch
BranchTrueFalseTotal
unless AccessUser($LEVEL) 0 0 0
383  
384 # note: cannot alter the guest & master users
385 0 ▶ if(my $ids = join(",",grep {$_ > 2} CGIArray('LISTED'))) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $ids = join(",", grep({$_ > 2;} CGIArray("LISTED")))) 0 0 0
386 0 ▶ $dbi->DoQuery('SetUserSearch',{ids=>$ids},1) if($cgiparams{doaction} eq 'Show');
Branch: 1 branch
BranchTrueFalseTotal
if $Labyrinth::Plugin::Users::cgiparams{"doaction"} eq "Show" 0 0 0
387 0 ▶ $dbi->DoQuery('SetUserSearch',{ids=>$ids},0) if($cgiparams{doaction} eq 'Hide');
Branch: 1 branch
BranchTrueFalseTotal
if $Labyrinth::Plugin::Users::cgiparams{"doaction"} eq "Hide" 0 0 0
388 0 ▶ Ban($ids) if($cgiparams{doaction} eq 'Ban');
Branch: 1 branch
BranchTrueFalseTotal
if $Labyrinth::Plugin::Users::cgiparams{"doaction"} eq "Ban" 0 0 0
389 0 ▶ Disable($ids) if($cgiparams{doaction} eq 'Disable');
Branch: 1 branch
BranchTrueFalseTotal
if $Labyrinth::Plugin::Users::cgiparams{"doaction"} eq "Disable" 0 0 0
390 0 ▶ Delete($ids) if($cgiparams{doaction} eq 'Delete');
Branch: 1 branch
BranchTrueFalseTotal
if $Labyrinth::Plugin::Users::cgiparams{"doaction"} eq "Delete" 0 0 0
391 }
392  
393 0 UserLists();
394 }
395  
396 0 ▶sub Add {
Subroutine Add: not called CC=2 SCAR=17.9
Pod documented
397 0 ▶ return unless AccessUser($LEVEL);
Branch: 1 branch
BranchTrueFalseTotal
unless AccessUser($LEVEL) 0 0 0
398  
399 0 my %data = (
400 'link' => 'images/blank.png',
401 'tag' => '[No Image]',
402 ddrealms => RealmSelect(0),
403 ddaccess => AccessSelect(0),
404 ddgroups => 'no groups assigned',
405 member => 'no group assigned',
406 );
407  
408 0 $tvars{users}{data} = \%data;
409 0 $tvars{userid} = 0;
410 }
411  
412 0 ▶sub Edit {
Subroutine Edit: not called CC=12 SCAR=50.5
Pod documented
413 0 ▶ $cgiparams{userid} ||= $tvars{'loginid'};
Condition0%0/3
$Labyrinth::Plugin::Users::cgiparams{"userid"} ||= $Labyrinth::Plugin::Users::tvars{"loginid"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$Labyrinth::Plugin::Users::cgiparams{"userid"} ||= $Labyrinth::Plugin::Users::tvars{"loginid"}
$Labyrinth::Plugin::Users::cgiparams{"userid"} $Labyrinth::Plugin::Users::tvars{"loginid"}
Truth table0%0/3
A ||= B
A= $Labyrinth::Plugin::Users::cgiparams{"userid"}B= $Labyrinth::Plugin::Users::tvars{"loginid"}
ABresult
1X1
011
000
414 0 ▶ return unless MasterCheck();
Branch: 1 branch
BranchTrueFalseTotal
unless MasterCheck() 0 0 0
415 0 ▶ return unless AuthorCheck('GetUserByID','userid',$LEVEL);
Branch: 1 branch
BranchTrueFalseTotal
unless AuthorCheck("GetUserByID", "userid", $LEVEL) 0 0 0
416  
417 0 ▶ $tvars{data}{tag} = '[No Image]' if(!$tvars{data}{link} || $tvars{data}{link} =~ /blank.png/);
Branch: 1 branch
BranchTrueFalseTotal
if not $Labyrinth::Plugin::Users::tvars{"data"}{"link"} or $Labyrinth::Plugin::Users::tvars{"data"}{"link"} =~ /blank.png/ 0 0 0
Condition0%0/3
not $Labyrinth::Plugin::Users::tvars{"data"}{"link"} or $Labyrinth::Plugin::Users::tvars{"data"}{"link"} =~ /blank.png/
l!l&&r!l&&!r
000
MC/DC0%0/2
not $Labyrinth::Plugin::Users::tvars{"data"}{"link"} or $Labyrinth::Plugin::Users::tvars{"data"}{"link"} =~ /blank.png/
not $Labyrinth::Plugin::Users::tvars{"data"}{"link"} $Labyrinth::Plugin::Users::tvars{"data"}{"link"} =~ /blank.png/
Truth table0%0/3
not(A) or B
A= not $Labyrinth::Plugin::Users::tvars{"data"}{"link"}B= $Labyrinth::Plugin::Users::tvars{"data"}{"link"} =~ /blank.png/
ABresult
1X1
011
000
418 0 $tvars{data}{name} = UserName($tvars{data}{userid});
419 0 $tvars{data}{admin} = Authorised(ADMIN);
420 0 $tvars{data}{ddrealms} = RealmSelect(RealmID($tvars{data}{realm}));
421 0 $tvars{data}{ddaccess} = AccessSelect($tvars{data}{accessid});
422  
423 0 my @grps = $dbi->GetQuery('hash','LinkedUsers',$cgiparams{'userid'});
424 0 ▶ if(@grps) {
Branch: 1 branch
BranchTrueFalseTotal
if (@grps) { } 0 0 0
425 0 $tvars{data}{ddgroups} = join(', ',map {$_->{groupname}} @grps);
426 0 $tvars{data}{member} = $grps[0]->{member};
427 } else {
428 0 $tvars{data}{ddgroups} = 'no groups assigned';
429 0 $tvars{data}{member} = 'no group assigned';
430 }
431  
432 0 $tvars{htmltags} = LegalTags();
433 0 $tvars{users}{data} = clone($tvars{data}); # data fields need to be editable
434 0 $tvars{users}{preview} = clone($tvars{data}); # data fields need to be editable
435  
436 0 for(keys %fields) {
437 0 ▶ if($fields{$_}->{html} == 1) { $tvars{users}{data}{$_} = CleanHTML($tvars{users}{data}{$_});
Branch: 2 branches
BranchTrueFalseTotal
if ($fields{$_}{'html'} == 1) { } 0 0 0
elsif ($fields{$_}{'html'} == 2) { } 0 0 0
438 0 $tvars{users}{preview}{$_} = CleanHTML($tvars{users}{preview}{$_}); }
439 0 elsif($fields{$_}->{html} == 2) { $tvars{users}{data}{$_} = SafeHTML($tvars{users}{data}{$_}); }
440 }
441  
442 0 $tvars{users}{preview}{gravatar} = GetGravatar($tvars{users}{preview}{userid},$tvars{users}{preview}{email});
443  
444 $tvars{users}{preview}{link} = undef
445 0 ▶ if($tvars{users}{data}{link} && $tvars{users}{data}{link} =~ /blank.png/);
Branch: 1 branch
BranchTrueFalseTotal
if $Labyrinth::Plugin::Users::tvars{"users"}{"data"}{"link"} and $Labyrinth::Plugin::Users::tvars{"users"}{"data"}{"link"} =~ /blank.png/ 0 0 0
Condition0%0/3
$Labyrinth::Plugin::Users::tvars{"users"}{"data"}{"link"} and $Labyrinth::Plugin::Users::tvars{"users"}{"data"}{"link"} =~ /blank.png/
!ll&&!rl&&r
000
MC/DC0%0/2
$Labyrinth::Plugin::Users::tvars{"users"}{"data"}{"link"} and $Labyrinth::Plugin::Users::tvars{"users"}{"data"}{"link"} =~ /blank.png/
$Labyrinth::Plugin::Users::tvars{"users"}{"data"}{"link"} $Labyrinth::Plugin::Users::tvars{"users"}{"data"}{"link"} =~ /blank.png/
Truth table0%0/3
A and B
A= $Labyrinth::Plugin::Users::tvars{"users"}{"data"}{"link"}B= $Labyrinth::Plugin::Users::tvars{"users"}{"data"}{"link"} =~ /blank.png/
ABresult
0X0
100
111
446 }
447  
448 0 ▶sub Save {
Subroutine Save: not called CC=19 SCAR=59.4
Pod documented
449 0 ▶ my $newuser = $cgiparams{'userid'} ? 0 : 1;
Branch: 1 branch
BranchTrueFalseTotal
$Labyrinth::Plugin::Users::cgiparams{'userid'} ? : 0 0 0
450 0 ▶ unless($newuser) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($newuser) 0 0 0
451 0 ▶ return unless MasterCheck();
Branch: 1 branch
BranchTrueFalseTotal
unless MasterCheck() 0 0 0
452 0 ▶ if($cgiparams{userid} != $tvars{'loginid'} && !Authorised($LEVEL)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Labyrinth::Plugin::Users::cgiparams{"userid"} != $Labyrinth::Plugin::Users::tvars{"loginid"} and not Authorised($LEVEL)) 0 0 0
Condition0%0/3
$Labyrinth::Plugin::Users::cgiparams{"userid"} != $Labyrinth::Plugin::Users::tvars{"loginid"} and not Authorised($LEVEL)
!ll&&!rl&&r
000
MC/DC0%0/2
$Labyrinth::Plugin::Users::cgiparams{"userid"} != $Labyrinth::Plugin::Users::tvars{"loginid"} and not Authorised($LEVEL)
$Labyrinth::Plugin::Users::cgiparams{"userid"} != $Labyrinth::Plugin::Users::tvars{"loginid"} not Authorised($LEVEL)
Truth table0%0/3
A and not(B)
A= $Labyrinth::Plugin::Users::cgiparams{"userid"} != $Labyrinth::Plugin::Users::tvars{"loginid"}B= not Authorised($LEVEL)
ABresult
0X0
100
111
453 0 $tvars{errcode} = 'BADACCESS';
454 0 return;
455 }
456 }
457  
458 0 ▶ return unless AuthorCheck('GetUserByID','userid',$LEVEL);
Branch: 1 branch
BranchTrueFalseTotal
unless AuthorCheck("GetUserByID", "userid", $LEVEL) 0 0 0
459  
460 0 $tvars{newuser} = $newuser;
461 0 for(keys %fields) {
462 0 ▶ if($fields{$_}->{html} == 1) { $cgiparams{$_} = CleanHTML($cgiparams{$_}) }
Branch: 3 branches
BranchTrueFalseTotal
if ($fields{$_}{'html'} == 1) { } 0 0 0
elsif ($fields{$_}{'html'} == 2) { } 0 0 0
elsif ($fields{$_}{'html'} == 3) { } 0 0 0
463 0 elsif($fields{$_}->{html} == 2) { $cgiparams{$_} = CleanTags($cgiparams{$_}) }
464 0 elsif($fields{$_}->{html} == 3) { $cgiparams{$_} = CleanLink($cgiparams{$_}) }
465 }
466  
467 0 my @manfields = @mandatory;
468 0 ▶ push @manfields, 'effect' if($tvars{command} eq 'regsave');
Branch: 1 branch
BranchTrueFalseTotal
if $Labyrinth::Plugin::Users::tvars{"command"} eq "regsave" 0 0 0
469  
470 0 ▶ return if FieldCheck(\@allfields,\@manfields);
Branch: 1 branch
BranchTrueFalseTotal
if FieldCheck(\@allfields, \@manfields) 0 0 0
471  
472 # determine realm
473 0 $tvars{data}{'realm'} = RealmName($tvars{data}{'realmid'});
474 0 ▶ $tvars{data}{'realm'} ||= 'public';
Condition0%0/2
$Labyrinth::Plugin::Users::tvars{"data"}{"realm"} ||= "public"
l!l
00
MC/DC0%0/1
$Labyrinth::Plugin::Users::tvars{"data"}{"realm"} ||= "public"
$Labyrinth::Plugin::Users::tvars{"data"}{"realm"}
Truth table0%0/2
A
A= $Labyrinth::Plugin::Users::tvars{"data"}{"realm"}
Aresult
11
00
475  
476 ## before continuing we should ensure the IP address has not
477 ## submitted repeated registrations. Though we should be aware
478 ## of Proxy Servers too.
479 0 ▶ my $imageid = $cgiparams{imageid} || 1;
Condition0%0/2
$Labyrinth::Plugin::Users::cgiparams{'imageid'} || 1
l!l
00
MC/DC0%0/1
$Labyrinth::Plugin::Users::cgiparams{'imageid'} || 1
$Labyrinth::Plugin::Users::cgiparams{'imageid'}
Truth table0%0/2
A
A= $Labyrinth::Plugin::Users::cgiparams{'imageid'}
Aresult
11
00
480 ($imageid) = SaveImageFile(
481 param => 'image',
482 stock => 'Users'
483 0 ▶ ) if($cgiparams{image});
Branch: 1 branch
BranchTrueFalseTotal
if $Labyrinth::Plugin::Users::cgiparams{"image"} 0 0 0
484  
485 my @fields = ( $tvars{data}{'nickname'}, $tvars{data}{'realname'},
486 $tvars{data}{'email'}, $imageid,
487 0 $tvars{data}{'realm'}
488 );
489  
490 0 ▶ if($newuser) {
Branch: 1 branch
BranchTrueFalseTotal
if ($newuser) { } 0 0 0
491 0 ▶ $tvars{data}{'accessid'} = $tvars{data}{'accessid'} || 1;
Condition0%0/2
$Labyrinth::Plugin::Users::tvars{'data'}{'accessid'} || 1
l!l
00
MC/DC0%0/1
$Labyrinth::Plugin::Users::tvars{'data'}{'accessid'} || 1
$Labyrinth::Plugin::Users::tvars{'data'}{'accessid'}
Truth table0%0/2
A
A= $Labyrinth::Plugin::Users::tvars{'data'}{'accessid'}
Aresult
11
00
492 0 ▶ $tvars{data}{'search'} = $tvars{data}{'search'} ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$Labyrinth::Plugin::Users::tvars{'data'}{'search'} ? : 0 0 0
493 0 $tvars{data}{'realm'} = 'public';
494 $cgiparams{'userid'} = $dbi->IDQuery('NewUser', $tvars{data}{'effect'},
495 $tvars{data}{'accessid'},
496 0 $tvars{data}{'search'},
497 @fields);
498 } else {
499 0 $dbi->DoQuery('SaveUser',@fields,$cgiparams{'userid'});
500 }
501  
502 0 $tvars{data}{userid} = $cgiparams{'userid'};
503 0 $tvars{newuser} = 0;
504 0 $tvars{thanks} = 1;
505 }
506  
507 0 ▶sub AdminSave {
Subroutine AdminSave: not called CC=18 SCAR=58.3
Pod documented
508 0 ▶ return unless AccessUser($LEVEL);
Branch: 1 branch
BranchTrueFalseTotal
unless AccessUser($LEVEL) 0 0 0
509 0 ▶ return unless MasterCheck();
Branch: 1 branch
BranchTrueFalseTotal
unless MasterCheck() 0 0 0
510  
511 0 ▶ my $newuser = $cgiparams{'userid'} ? 0 : 1;
Branch: 1 branch
BranchTrueFalseTotal
$Labyrinth::Plugin::Users::cgiparams{'userid'} ? : 0 0 0
512 0 ▶ return unless AuthorCheck('GetUserByID','userid',$LEVEL);
Branch: 1 branch
BranchTrueFalseTotal
unless AuthorCheck("GetUserByID", "userid", $LEVEL) 0 0 0
513  
514 0 $tvars{newuser} = $newuser;
515  
516 0 for(keys %fields) {
517 0 ▶ if($fields{$_}->{html} == 1) { $cgiparams{$_} = CleanHTML($cgiparams{$_}) }
Branch: 3 branches
BranchTrueFalseTotal
if ($fields{$_}{'html'} == 1) { } 0 0 0
elsif ($fields{$_}{'html'} == 2) { } 0 0 0
elsif ($fields{$_}{'html'} == 3) { } 0 0 0
518 0 elsif($fields{$_}->{html} == 2) { $cgiparams{$_} = CleanTags($cgiparams{$_}) }
519 0 elsif($fields{$_}->{html} == 3) { $cgiparams{$_} = CleanLink($cgiparams{$_}) }
520 }
521  
522 0 ▶ my $realm = $tvars{data}->{realm} || 'public';
Condition0%0/2
$Labyrinth::Plugin::Users::tvars{'data'}{'realm'} || 'public'
l!l
00
MC/DC0%0/1
$Labyrinth::Plugin::Users::tvars{'data'}{'realm'} || 'public'
$Labyrinth::Plugin::Users::tvars{'data'}{'realm'}
Truth table0%0/2
A
A= $Labyrinth::Plugin::Users::tvars{'data'}{'realm'}
Aresult
11
00
523 0 ▶ return if FieldCheck(\@allfields,\@mandatory);
Branch: 1 branch
BranchTrueFalseTotal
if FieldCheck(\@allfields, \@mandatory) 0 0 0
524  
525 ## before continuing we should ensure the IP address has not
526 ## submitted repeated registrations. Though we should be aware
527 ## of Proxy Servers too.
528 0 ▶ my $imageid = $cgiparams{imageid} || 1;
Condition0%0/2
$Labyrinth::Plugin::Users::cgiparams{'imageid'} || 1
l!l
00
MC/DC0%0/1
$Labyrinth::Plugin::Users::cgiparams{'imageid'} || 1
$Labyrinth::Plugin::Users::cgiparams{'imageid'}
Truth table0%0/2
A
A= $Labyrinth::Plugin::Users::cgiparams{'imageid'}
Aresult
11
00
529 ($imageid) = SaveImageFile(
530 param => 'image',
531 stock => 'Users'
532 0 ▶ ) if($cgiparams{image});
Branch: 1 branch
BranchTrueFalseTotal
if $Labyrinth::Plugin::Users::cgiparams{"image"} 0 0 0
533  
534 # in case of a new user
535 0 ▶ $tvars{data}->{'accessid'} = $tvars{data}->{'accessid'} || 1;
Condition0%0/2
$Labyrinth::Plugin::Users::tvars{'data'}{'accessid'} || 1
l!l
00
MC/DC0%0/1
$Labyrinth::Plugin::Users::tvars{'data'}{'accessid'} || 1
$Labyrinth::Plugin::Users::tvars{'data'}{'accessid'}
Truth table0%0/2
A
A= $Labyrinth::Plugin::Users::tvars{'data'}{'accessid'}
Aresult
11
00
536 0 ▶ $tvars{data}->{'search'} = $tvars{data}->{'search'} ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$Labyrinth::Plugin::Users::tvars{'data'}{'search'} ? : 0 0 0
537 0 ▶ $tvars{data}->{'realm'} = Authorised(ADMIN) && $tvars{data}->{'realmid'} ? RealmName($tvars{data}->{realmid}) : $realm;
Branch: 1 branch
BranchTrueFalseTotal
Authorised(4) && $Labyrinth::Plugin::Users::tvars{'data'}{'realmid'} ? : 0 0 0
Condition0%0/3
Authorised(4) and $Labyrinth::Plugin::Users::tvars{"data"}{"realmid"}
!ll&&!rl&&r
000
MC/DC0%0/2
Authorised(4) and $Labyrinth::Plugin::Users::tvars{"data"}{"realmid"}
Authorised(4) $Labyrinth::Plugin::Users::tvars{"data"}{"realmid"}
Truth table0%0/3
A and B
A= Authorised(4)B= $Labyrinth::Plugin::Users::tvars{"data"}{"realmid"}
ABresult
0X0
100
111
538  
539 my @fields = ( $tvars{data}{'accessid'}, $tvars{data}{'search'},
540 $tvars{data}{'realm'},
541 $tvars{data}{'nickname'}, $tvars{data}{'realname'},
542 0 $tvars{data}{'email'}, $imageid
543 );
544  
545 0 ▶ if($newuser) {
Branch: 1 branch
BranchTrueFalseTotal
if ($newuser) { } 0 0 0
546 0 $cgiparams{'userid'} = $dbi->IDQuery('NewUser',$tvars{data}->{'effect'},@fields);
547 } else {
548 0 $dbi->DoQuery('AdminSaveUser',@fields,$cgiparams{'userid'});
549 }
550  
551 0 $tvars{data}->{userid} = $cgiparams{'userid'};
552 0 $tvars{newuser} = 0;
553 0 $tvars{thanks} = 1;
554 }
555  
556 0 ▶sub Delete {
Subroutine Delete: not called CC=2 SCAR=17.9
Pod documented
557 0 my $ids = shift;
558 0 ▶ return unless AccessUser($LEVEL);
Branch: 1 branch
BranchTrueFalseTotal
unless AccessUser($LEVEL) 0 0 0
559 0 $dbi->DoQuery('DeleteUsers',{ids => $ids});
560 0 $tvars{thanks} = 'Users Deleted.';
561 }
562  
563 0 ▶sub Disable {
Subroutine Disable: not called CC=2 SCAR=17.9
Pod documented
564 0 my $ids = shift;
565 0 ▶ return unless AccessUser($LEVEL);
Branch: 1 branch
BranchTrueFalseTotal
unless AccessUser($LEVEL) 0 0 0
566 0 $dbi->DoQuery('BanUsers',{ids => $ids},'-deleted-');
567 0 $tvars{thanks} = 'Users Disabled.';
568 }
569  
570 0 ▶sub Ban {
Subroutine Ban: not called CC=2 SCAR=17.9
Pod documented
571 0 my $ids = shift;
572 0 ▶ return unless AccessUser($LEVEL);
Branch: 1 branch
BranchTrueFalseTotal
unless AccessUser($LEVEL) 0 0 0
573 0 $dbi->DoQuery('BanUsers',{ids => $ids},'-banned-');
574 0 $tvars{thanks} = 'Users Banned.';
575 }
576  
577 0 ▶sub AdminPass {
Subroutine AdminPass: not called CC=5 SCAR=34.0
Pod documented
578 0 ▶ return unless($cgiparams{'userid'});
Branch: 1 branch
BranchTrueFalseTotal
unless $Labyrinth::Plugin::Users::cgiparams{"userid"} 0 0 0
579 0 ▶ return unless MasterCheck();
Branch: 1 branch
BranchTrueFalseTotal
unless MasterCheck() 0 0 0
580 0 ▶ return unless AccessUser($LEVEL);
Branch: 1 branch
BranchTrueFalseTotal
unless AccessUser($LEVEL) 0 0 0
581 0 ▶ return unless AuthorCheck('GetUserByID','userid',$LEVEL);
Branch: 1 branch
BranchTrueFalseTotal
unless AuthorCheck("GetUserByID", "userid", $LEVEL) 0 0 0
582 0 $tvars{data}{name} = UserName($cgiparams{'userid'});
583 }
584  
585 0 ▶sub AdminChng {
Subroutine AdminChng: not called CC=8 SCAR=42.8
Pod documented
586 0 ▶ return unless($cgiparams{'userid'});
Branch: 1 branch
BranchTrueFalseTotal
unless $Labyrinth::Plugin::Users::cgiparams{"userid"} 0 0 0
587 0 ▶ return unless MasterCheck();
Branch: 1 branch
BranchTrueFalseTotal
unless MasterCheck() 0 0 0
588 0 ▶ return unless AccessUser($LEVEL);
Branch: 1 branch
BranchTrueFalseTotal
unless AccessUser($LEVEL) 0 0 0
589  
590 0 my @mandatory = qw(userid effect2 effect3);
591 0 ▶ if(FieldCheck(\@mandatory,\@mandatory)) {
Branch: 1 branch
BranchTrueFalseTotal
if (FieldCheck(\@mandatory, \@mandatory)) 0 0 0
592 0 $tvars{errmess} = 'All fields must be complete, please try again.';
593 0 $tvars{errcode} = 'ERROR';
594 0 return;
595 }
596  
597 0 $tvars{data}{name} = UserName($cgiparams{'userid'});
598  
599 0 ▶ if($cgiparams{effect2} ne $cgiparams{effect3}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Labyrinth::Plugin::Users::cgiparams{"effect2"} ne $Labyrinth::Plugin::Users::cgiparams{"effect3"}) 0 0 0
600 0 $tvars{errmess} = 'New &amp; verify passwords don\'t match, please try again.';
601 0 $tvars{errcode} = 'ERROR';
602 0 return;
603 }
604  
605 0 my %passerrors = (
606 1 => "Password too short, length should be $settings{minpasslen}-$settings{maxpasslen} characters.",
607 2 => "Password too long, length should be $settings{minpasslen}-$settings{maxpasslen} characters.",
608 3 => 'Password not cyptic enough, please enter as per password rules.',
609 4 => 'Password contains spaces or tabs.',
610 5 => 'Password should contain 3 or more unique characters.',
611 );
612  
613 0 my $invalid = PasswordCheck($cgiparams{effect2});
614 0 ▶ if($invalid) {
Branch: 1 branch
BranchTrueFalseTotal
if ($invalid) 0 0 0
615 0 $tvars{errmess} = $passerrors{$invalid};
616 0 $tvars{errcode} = 'ERROR';
617 0 return;
618 }
619  
620 0 $dbi->DoQuery('ChangePassword',$cgiparams{effect2},$cgiparams{'userid'});
621 0 $tvars{thanks} = 'Password Changed.';
622  
623 0 ▶ if($cgiparams{mailuser}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Labyrinth::Plugin::Users::cgiparams{"mailuser"}) 0 0 0
624 0 my @rows = $dbi->GetQuery('hash','GetUserByID',$cgiparams{'userid'});
625 MailSend( template => 'mailer/reset.eml',
626 name => $rows[0]->{realname},
627 password => $cgiparams{effect2},
628 recipient_email => $rows[0]->{email}
629 0 );
630 }
631 }
632  
633 =item ACL
634  
635 List the current access control levels for the given user.
636  
637 =item ACLAdd1
638  
639 Apply the given profile to the current user's folders.
640  
641 =item ACLAdd2
642  
643 Add permissions for the current user to the given folder.
644  
645 =item ACLSave
646  
647 Save changes to the current access control levels for the given user.
648  
649 =item ACLDelete
650  
651 Delete the specified access control level for the given user.
652  
653 =cut
654  
655 0 ▶sub ACL {
Subroutine ACL: not called CC=5 SCAR=34.0
Pod documented
656 0 ▶ return unless AccessUser($LEVEL);
Branch: 1 branch
BranchTrueFalseTotal
unless AccessUser($LEVEL) 0 0 0
657 0 ▶ return unless $cgiparams{'userid'};
Branch: 1 branch
BranchTrueFalseTotal
unless $Labyrinth::Plugin::Users::cgiparams{"userid"} 0 0 0
658  
659 0 my @rows = $dbi->GetQuery('hash','GetUserByID',$cgiparams{'userid'});
660 0 $tvars{data}->{$_} = $rows[0]->{$_} for(qw(userid realname accessname accessid));
661  
662 0 push @{$tvars{data}->{access}}, { folderid => 0, path => 'DEFAULT', accessname => $tvars{data}->{accessname}, ddaccess => AccessSelect($tvars{data}->{accessid},'ACCESS0') };
663  
664 0 @rows = $dbi->GetQuery('hash','UserACLs',$cgiparams{'userid'});
665 0 for my $row (@rows) {
666 0 $row->{ddaccess} = AccessSelect($row->{accessid},'ACCESS' . $row->{aclid});
667 0 push @{$tvars{data}->{access}}, $row;
668 }
669  
670 0 $tvars{ddprofile} = ProfileSelect();
671 0 $tvars{ddfolder} = FolderSelect();
672 0 $tvars{ddaccess} = AccessSelect();
673 }
674  
675 0 ▶sub ACLAdd1 {
Subroutine ACLAdd1: not called CC=5 SCAR=34.0
Pod documented
676 0 LoadProfiles();
677 0 ▶ if($settings{profiles}{profiles}{$cgiparams{profile}}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Labyrinth::Plugin::Users::settings{"profiles"}{"profiles"}{$Labyrinth::Plugin::Users::cgiparams{"profile"}}) 0 0 0
678 0 for(keys %{ $settings{profiles}{profiles}{$cgiparams{profile}} }) {
679 0 my $folderid = FolderID($_);
680 0 my $accessid = AccessID($settings{profiles}{profiles}{$cgiparams{profile}}{$_});
681  
682 0 my @rows = $dbi->GetQuery('hash','UserACLCheck1', $cgiparams{'userid'}, $folderid);
683 0 ▶ if(@rows) {
Branch: 1 branch
BranchTrueFalseTotal
if (@rows) { } 0 0 0
684 $dbi->DoQuery('UserACLUpdate1',$accessid,$cgiparams{'userid'},$folderid)
685 0 ▶ if($rows[0]->{accessid} < $accessid);
Branch: 1 branch
BranchTrueFalseTotal
if $rows[0]{"accessid"} < $accessid 0 0 0
686 } else {
687 0 $dbi->DoQuery('UserACLInsert',$accessid,$cgiparams{'userid'},$folderid);
688 }
689 }
690 }
691 }
692  
693 0 ▶sub ACLAdd2 {
Subroutine ACLAdd2: not called CC=4 SCAR=30.0
Pod documented
694 0 my ($userid,$aclid,$accessid,$folderid) = @_;
695 0 ▶ if($aclid) {
Branch: 1 branch
BranchTrueFalseTotal
if ($aclid) { } 0 0 0
696 0 my @rows = $dbi->GetQuery('hash','UserACLCheck2', $userid, $aclid);
697 0 ▶ if(@rows) {
Branch: 1 branch
BranchTrueFalseTotal
if (@rows) { } 0 0 0
698 $dbi->DoQuery('UserACLUpdate2',$accessid,$userid,$aclid)
699 0 ▶ if($rows[0]->{accessid} < $accessid);
Branch: 1 branch
BranchTrueFalseTotal
if $rows[0]{"accessid"} < $accessid 0 0 0
700 } else {
701 0 $dbi->DoQuery('UserACLInsert',$accessid,$userid,$folderid);
702 }
703 } else {
704 0 $dbi->DoQuery('UserACLDefault',$accessid,$userid);
705 }
706 }
707  
708 0 ▶sub ACLSave {
Subroutine ACLSave: not called CC=5 SCAR=34.0
Pod documented
709 0 ▶ return unless AccessUser($LEVEL);
Branch: 1 branch
BranchTrueFalseTotal
unless AccessUser($LEVEL) 0 0 0
710  
711 0 ▶ if($cgiparams{submit} eq 'Apply') {
Branch: 2 branches
BranchTrueFalseTotal
if ($Labyrinth::Plugin::Users::cgiparams{'submit'} eq 'Apply') { } 0 0 0
elsif ($Labyrinth::Plugin::Users::cgiparams{'submit'} eq 'Add') { } 0 0 0
712 0 ACLAdd1();
713 } elsif($cgiparams{submit} eq 'Add') {
714 0 ACLAdd2($cgiparams{userid},0,$cgiparams{accessid},$cgiparams{folderid});
715 } else {
716 0 my @acls = grep {/ACCESS/} keys %cgiparams;
717 0 for my $acl ( @acls ) {
718 0 my ($aclid) = $acl =~ /ACCESS(\d+)/;
719 0 ACLAdd2($cgiparams{userid},$aclid,$cgiparams{'ACCESS'.$aclid});
720 }
721 }
722  
723 0 $tvars{thanks} = 'User permissions saved successfully.';
724 }
725  
726 0 ▶sub ACLDelete {
Subroutine ACLDelete: not called CC=3 SCAR=24.8
Pod documented
727 0 ▶ return unless AccessUser($LEVEL);
Branch: 1 branch
BranchTrueFalseTotal
unless AccessUser($LEVEL) 0 0 0
728  
729 0 my @manfields = qw(userid accessid folderid);;
730 0 ▶ return if FieldCheck(\@manfields,\@manfields);
Branch: 1 branch
BranchTrueFalseTotal
if FieldCheck(\@manfields, \@manfields) 0 0 0
731  
732 $dbi->DoQuery('UserACLDelete',
733 $cgiparams{'userid'},
734 $cgiparams{'accessid'},
735 0 $cgiparams{'folderid'});
736  
737 0 $tvars{thanks} = 'User access removed successfully.';
738 }
739  
740 4 1;
741  
742 __END__
« Menus.pm ↑ Summary News.pm »