| 1 | package Labyrinth::Plugin::Folders; | ||||||||||||||||||||||||||||
| 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::Folders - handler for Labyrinth folders | ||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | Contains all the folder 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::DBUtils; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 25 | 4 | ▶ | use Labyrinth::MLUtils; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 26 | 4 | ▶ | use Labyrinth::Support; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 27 | 4 | ▶ | use Labyrinth::Variables; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | # ------------------------------------- | ||||||||||||||||||||||||||||
| 30 | # Variables | ||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | # type: 0 = optional, 1 = mandatory | ||||||||||||||||||||||||||||
| 33 | # html: 0 = none, 1 = text, 2 = textarea | ||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | 4 | my %fields = ( | |||||||||||||||||||||||||||
| 36 | folderid => { type => 0, html => 1 }, | ||||||||||||||||||||||||||||
| 37 | path => { type => 1, html => 1 }, | ||||||||||||||||||||||||||||
| 38 | parent => { type => 0, html => 1 }, | ||||||||||||||||||||||||||||
| 39 | accessid => { type => 1, html => 1 } | ||||||||||||||||||||||||||||
| 40 | ); | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | 4 | my (@mandatory,@allfields); | |||||||||||||||||||||||||||
| 43 | 4 | for(keys %fields) { | |||||||||||||||||||||||||||
| 44 | 16 | ▶ | push @mandatory, $_ if($fields{$_}->{type}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 45 | 16 | push @allfields, $_; | |||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | 4 | my @savefields = qw(path accessid parent); | |||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | 4 | my $LEVEL = ADMIN; | |||||||||||||||||||||||||||
| 51 | 4 | my $INDEXKEY = 'folderid'; | |||||||||||||||||||||||||||
| 52 | 4 | my $ALLSQL = 'AllFolders'; | |||||||||||||||||||||||||||
| 53 | 4 | my $GETSQL = 'GetFolder'; | |||||||||||||||||||||||||||
| 54 | 4 | my $SAVESQL = 'UpdateFolder'; | |||||||||||||||||||||||||||
| 55 | 4 | my $ADDSQL = 'InsertFolder'; | |||||||||||||||||||||||||||
| 56 | 4 | my $DELETESQL = 'DeleteFolder'; | |||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | # ------------------------------------- | ||||||||||||||||||||||||||||
| 59 | # The Subs | ||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | =head1 ADMIN INTERFACE METHODS | ||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | All action methods are only accessible by users with admin permission. | ||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | =over 4 | ||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | =item Admin | ||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | Lists the current set of folders. | ||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | =item Add | ||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | Add a new folder. | ||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | =item Edit | ||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | Edit specified folder. | ||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | =item Save | ||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | Save specified folder. | ||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | =item Delete | ||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | Delete specified folder. | ||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | =item DeleteLinkRealm | ||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | Delete a link between the specified folder and realm. | ||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | =back | ||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||
| 93 | =cut | ||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||
| 95 | 0 | ▶ | sub Admin { | ||||||||||||||||||||||||||
|
Subroutine
Admin: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||
| 96 | 0 | ▶ | return unless AccessUser(ADMIN); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | 0 | ▶ | if($cgiparams{doaction}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 99 | 0 | ▶ | if($cgiparams{doaction} eq 'Delete' ) { Delete(); } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | 0 | my @rows = $dbi->GetQuery('hash','AllFolders'); | |||||||||||||||||||||||||||
| 103 | 0 | ▶ | $tvars{data} = \@rows if(@rows); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||
| 106 | 0 | ▶ | sub Add { | ||||||||||||||||||||||||||
|
Subroutine
Add: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 107 | 0 | ▶ | return unless AccessUser(ADMIN); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 108 | $tvars{data} = { | ||||||||||||||||||||||||||||
| 109 | 0 | path => '', | |||||||||||||||||||||||||||
| 110 | ddaccess => AccessSelect(1), | ||||||||||||||||||||||||||||
| 111 | ddparent => FolderSelect(1,'parent') | ||||||||||||||||||||||||||||
| 112 | }; | ||||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||
| 115 | 0 | ▶ | sub Edit { | ||||||||||||||||||||||||||
|
Subroutine
Edit: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||
| 116 | 0 | ▶ | return unless AccessUser($LEVEL); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 117 | 0 | ▶ | return unless( $cgiparams{'folderid'} && $cgiparams{'folderid'} > 1 ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$Labyrinth::Plugin::Folders::cgiparams{"folderid"} and $Labyrinth::Plugin::Folders::cgiparams{"folderid"} > 1
MC/DC0%0/2
$Labyrinth::Plugin::Folders::cgiparams{"folderid"} and $Labyrinth::Plugin::Folders::cgiparams{"folderid"} > 1
$Labyrinth::Plugin::Folders::cgiparams{"folderid"}
$Labyrinth::Plugin::Folders::cgiparams{"folderid"} > 1
Truth table0%0/3
A and B
A= $Labyrinth::Plugin::Folders::cgiparams{"folderid"}B= $Labyrinth::Plugin::Folders::cgiparams{"folderid"} > 1
| |||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||
| 119 | 0 | my @rows = $dbi->GetQuery('hash','GetFolder',$cgiparams{'folderid'}); | |||||||||||||||||||||||||||
| 120 | 0 | ▶ | return unless(@rows); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||
| 122 | 0 | $tvars{data} = $rows[0]; | |||||||||||||||||||||||||||
| 123 | 0 | $tvars{data}{ddaccess} = AccessSelect($rows[0]->{accessid}); | |||||||||||||||||||||||||||
| 124 | 0 | $tvars{data}{ddparent} = FolderSelect($rows[0]->{parent},'parent'); | |||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||
| 127 | 0 | ▶ | sub Save { | ||||||||||||||||||||||||||
|
Subroutine
Save: not called CC=9 SCAR=45.0
Pod
documented
| |||||||||||||||||||||||||||||
| 128 | 0 | ▶ | return unless AccessUser($LEVEL); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 129 | 0 | ▶ | return unless AuthorCheck('GetFolder',$INDEXKEY); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||
| 131 | 0 | for(keys %fields) { | |||||||||||||||||||||||||||
| 132 | 0 | ▶ | if($fields{$_}->{html} == 1) { $cgiparams{$_} = CleanHTML($cgiparams{$_}) } | ||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||
| 133 | 0 | elsif($fields{$_}->{html} == 2) { $cgiparams{$_} = CleanTags($cgiparams{$_}) } | |||||||||||||||||||||||||||
| 134 | 0 | elsif($fields{$_}->{html} == 3) { $cgiparams{$_} = CleanLink($cgiparams{$_}) } | |||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||
| 137 | 0 | ▶ | return if FieldCheck(\@allfields,\@mandatory); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||
| 139 | 0 | my @fields = map {$tvars{data}->{$_}} @savefields; | |||||||||||||||||||||||||||
| 140 | 0 | ▶ | if($cgiparams{$INDEXKEY}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 141 | 0 | $dbi->DoQuery($SAVESQL,@fields,$cgiparams{$INDEXKEY}); | |||||||||||||||||||||||||||
| 142 | } else { | ||||||||||||||||||||||||||||
| 143 | 0 | $cgiparams{$INDEXKEY} = $dbi->IDQuery($ADDSQL,@fields); | |||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||
| 146 | 0 | $tvars{thanks} = 1; | |||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||
| 149 | 0 | ▶ | sub Delete { | ||||||||||||||||||||||||||
|
Subroutine
Delete: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 150 | 0 | ▶ | return unless AccessUser(ADMIN); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 151 | 0 | my @ids = CGIArray('LISTED'); | |||||||||||||||||||||||||||
| 152 | 0 | ▶ | return unless @ids; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||
| 154 | 0 | $dbi->DoQuery($DELETESQL,{ids=>join(",",@ids)}); | |||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||
| 157 | 4 | 1; | |||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||
| 159 | __END__ | ||||||||||||||||||||||||||||