| 1 | package Labyrinth::Plugin::Users::Info; | ||||||||||||||||||||||||||||||||||||||||||
| 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::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 | 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 Config::IniFiles; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||
| 37 | # ------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 38 | # Variables | ||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||
| 40 | # type: 0 = optional, 1 = mandatory | ||||||||||||||||||||||||||||||||||||||||||
| 41 | # html: 0 = none, 1 = text, 2 = textarea | ||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||
| 43 | 4 | 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 | 4 | my (@mandatory,@allfields,@fieldorder,@fieldnames); | |||||||||||||||||||||||||||||||||||||||||
| 55 | 4 | for(keys %fields) { | |||||||||||||||||||||||||||||||||||||||||
| 56 | 4 | ▶ | push @mandatory, $_ if($fields{$_}->{type}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 57 | 4 | push @allfields, $_; | |||||||||||||||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||
| 60 | 4 | 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 | 0 | ▶ | sub Item { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Item: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | ▶ | return unless($cgiparams{'userid'}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | my @rows = $dbi->GetQuery('hash','GetUserInfoByID',$cgiparams{'userid'}); | |||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | $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 | 0 | ▶ | sub Edit { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Edit: not called CC=8 SCAR=42.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | ▶ | $cgiparams{userid} ||= $tvars{'loginid'}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$Labyrinth::Plugin::Users::Info::cgiparams{"userid"} ||= $Labyrinth::Plugin::Users::Info::tvars{"loginid"}
MC/DC0%0/2
$Labyrinth::Plugin::Users::Info::cgiparams{"userid"} ||= $Labyrinth::Plugin::Users::Info::tvars{"loginid"}
$Labyrinth::Plugin::Users::Info::cgiparams{"userid"}
$Labyrinth::Plugin::Users::Info::tvars{"loginid"}
Truth table0%0/3
A ||= B
A= $Labyrinth::Plugin::Users::Info::cgiparams{"userid"}B= $Labyrinth::Plugin::Users::Info::tvars{"loginid"}
| |||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | ▶ | return unless MasterCheck(); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | ▶ | return unless AccessUser($LEVEL); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | ▶ | return unless AuthorCheck('GetUserInfoByID','userid',$LEVEL); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | LoadInfo(); | |||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | for(keys %fields) { | |||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | ▶ | if($fields{$_}->{html} == 1) { $tvars{user}{data}->{$_} = CleanHTML($tvars{data}->{$_}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | $tvars{user}{preview}->{$_} = CleanHTML($tvars{data}->{$_}); } | |||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | elsif($fields{$_}->{html} == 2) { $tvars{user}{data}->{$_} = CleanTags($tvars{data}->{$_}); } | |||||||||||||||||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | ▶ | sub Save { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Save: not called CC=13 SCAR=52.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | ▶ | return unless MasterCheck(); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | ▶ | return unless AccessUser($LEVEL); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | ▶ | my $newuser = $cgiparams{'userid'} ? 0 : 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | ▶ | if(!$newuser && $cgiparams{userid} != $tvars{'loginid'} && !Authorised($LEVEL)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
not $newuser and $Labyrinth::Plugin::Users::Info::cgiparams{"userid"} != $Labyrinth::Plugin::Users::Info::tvars{"loginid"} and not Authorised($LEVEL)
not $newuser and $Labyrinth::Plugin::Users::Info::cgiparams{"userid"} != $Labyrinth::Plugin::Users::Info::tvars{"loginid"}
MC/DC0%0/3
not $newuser and $Labyrinth::Plugin::Users::Info::cgiparams{"userid"} != $Labyrinth::Plugin::Users::Info::tvars{"loginid"} and not Authorised($LEVEL)
not $newuser
$Labyrinth::Plugin::Users::Info::cgiparams{"userid"} != $Labyrinth::Plugin::Users::Info::tvars{"loginid"}
not Authorised($LEVEL)
Truth table0%0/4
not(A) and B and not(C)
A= not $newuserB= $Labyrinth::Plugin::Users::Info::cgiparams{"userid"} != $Labyrinth::Plugin::Users::Info::tvars{"loginid"}C= not Authorised($LEVEL)
| |||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | $tvars{errcode} = 'BADACCESS'; | |||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | ▶ | return unless AuthorCheck('GetUserInfoByID','userid',$LEVEL); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | LoadInfo(); | |||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | $tvars{newuser} = $newuser; | |||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | for(keys %fields) { | |||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | ▶ | if($fields{$_}->{html} == 1) { $cgiparams{$_} = CleanHTML($cgiparams{$_}) } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | elsif($fields{$_}->{html} == 2) { $cgiparams{$_} = CleanTags($cgiparams{$_}) } | |||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | elsif($fields{$_}->{html} == 3) { $cgiparams{$_} = CleanLink($cgiparams{$_}) } | |||||||||||||||||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | ▶ | return if FieldCheck(\@allfields,\@mandatory); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | my @fields = ((map {$tvars{data}->{$_}} @fieldorder), $tvars{data}->{'userid'}); | |||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | $dbi->DoQuery('SaveUserInfo',{ 'keys' => join(',', map {"$_=?"} @fieldnames) },@fields); | |||||||||||||||||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | ▶ | sub LoadInfo { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
LoadInfo: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | my $file = $settings{config} . '/user-info.ini'; | |||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | ▶ | return unless(-f $file); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | my $cfg = Config::IniFiles->new( -file => $file ); | |||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | ▶ | unless(defined $cfg) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | LogWarn("Unable to load user info file [$file]"); | |||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | for my $name ($cfg->Parameters('EXTRA')) { | |||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | my $value = $cfg->val('EXTRA',$name); | |||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | ▶ | next unless($value); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||
| 161 | 0 | my ($type,$html,$field) = split(',',$value); | |||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | $fields{$name} = {type => $type, html => $html}; | |||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | push @fieldorder, $name; | |||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | push @fieldnames, $field; | |||||||||||||||||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||
| 167 | 0 | (@mandatory,@allfields) = (); | |||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | for(keys %fields) { | |||||||||||||||||||||||||||||||||||||||||
| 169 | 0 | ▶ | push @mandatory, $_ if($fields{$_}->{type}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | push @allfields, $_; | |||||||||||||||||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||||||||||||||||
| 172 | } | ||||||||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||||||||
| 174 | 4 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||||||||||
| 176 | __END__ | ||||||||||||||||||||||||||||||||||||||||||