WE/Util/Htgroup.pm

filter: Statementstmt 38.1% 8 / 21 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 50.0% 2 / 4 Podpod 100% 2 / 2 totaltotal 38.7% 12 / 31 CC 5 SCAR 29.6
CC
5
Cov
32%
create
30.0
invalid_chars
2.0
BEGIN
1.0
CRAP 19.2
« WE/Util/HWRights.pm ↑ Summary WE_Content/XML.pm »
1 # -*- perl -*-
2  
3 #
4 # $Id: Htgroup.pm,v 1.5 2004/04/02 10:32:50 eserte Exp $
5 # Author: Slaven Rezic
6 #
7 # Copyright (C) 2002 Online Office Berlin. All rights reserved.
8 # Copyright (C) 2002 Slaven Rezic.
9 # This is free software; you can redistribute it and/or modify it under the
10 # terms of the GNU General Public License, see the file COPYING.
11  
12 #
13 # Mail: slaven@rezic.de
14 # WWW: http://we-framework.sourceforge.net
15 #
16  
17 package WE::Util::Htgroup;
18  
19 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 1 ▶use vars qw($VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
21 1 $VERSION = sprintf("%d.%02d", q$Revision: 1.5 $ =~ /(\d+)\.(\d+)/);
22  
23 =head1 NAME
24  
25 WE::Util::Htgroup - create apache AuthGroupFile files from a user database
26  
27 =head1 SYNOPSIS
28  
29 use WE::Util::Htgroup;
30 WE::Util::Htgroup::create("/var/www/.group", $complex_user_db);
31  
32 =head1 DESCRIPTION
33  
34 Create apache AuthGroupFile files from a WE_Framework user database.
35  
36 =head2 FUNCTIONS
37  
38 =over 4
39  
40 =item create($dest_file, $user_db, %args);
41  
42 Create the C<$dest_file> from the (complex) user database object
43 C<$user_db>.
44  
45 =cut
46  
47 0 ▶sub create {
Subroutine create: not called CC=5 SCAR=34.0
Pod documented
48 0 my($dest_file, $user_db, %args) = @_;
49 0 my %groups;
50 0 foreach my $uid ($user_db->get_all_users) {
51 0 my(@groups) = $user_db->get_groups($uid);
52 0 foreach my $group (@groups) {
53 0 push @{ $groups{$group} }, $uid;
54 }
55 }
56 0 ▶ open(GROUP, ">$dest_file") or die "Can't write to $dest_file: $!";
Branch: 1 branch
BranchTrueFalseTotal
open GROUP, ">$dest_file" or die "Can't write to ${dest_file}: $!" 0 0 0
57 0 ▶ while(my($group, $members) = each %groups) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %groups) 0 0 0
58 0 print GROUP "$group: " . join(" ", @$members) . "\n";
59 }
60 0 close GROUP;
61 0 1;
62 }
63  
64 =item invalid_chars
65  
66 Return a string of invalid characters for group names. This is handy
67 for using in C<ComplexUser>:
68  
69 new WE::DB::ComplexUser(..., ...,
70 -crypt => "none",
71 -invalidchars => WE::Util::Htpasswd::invalid_chars(),
72 -invalidgroupchars => WE::Util::Htgroup::invalid_chars())
73  
74 =cut
75  
76 0 ▶sub invalid_chars {
Subroutine invalid_chars: not called CC=1 SCAR=6.9
Pod documented
77 0 ": ";
78 }
79  
80 1 1;
81  
82 __END__
« WE/Util/HWRights.pm ↑ Summary WE_Content/XML.pm »