|
|
@ -1,7 +1,7 @@ |
|
|
|
#!/usr/bin/perl -w |
|
|
|
#!/usr/bin/perl -w |
|
|
|
|
|
|
|
|
|
|
|
#--------------------------------------------------------------------- |
|
|
|
#--------------------------------------------------------------------- |
|
|
|
# copyright (C) 2011 Firewall-Services |
|
|
|
# Copyright (C) 2011-2014 Firewall-Services |
|
|
|
# daniel@firewall-services.com |
|
|
|
# daniel@firewall-services.com |
|
|
|
# |
|
|
|
# |
|
|
|
# This program is free software; you can redistribute it and/or modify |
|
|
|
# This program is free software; you can redistribute it and/or modify |
|
|
@ -27,6 +27,7 @@ use esmith::AccountsDB; |
|
|
|
use esmith::ConfigDB; |
|
|
|
use esmith::ConfigDB; |
|
|
|
use esmith::cgi; |
|
|
|
use esmith::cgi; |
|
|
|
use esmith::util; |
|
|
|
use esmith::util; |
|
|
|
|
|
|
|
use List::MoreUtils qw(uniq); |
|
|
|
use File::Basename; |
|
|
|
use File::Basename; |
|
|
|
use Exporter; |
|
|
|
use Exporter; |
|
|
|
use Carp qw(verbose); |
|
|
|
use Carp qw(verbose); |
|
|
@ -35,6 +36,9 @@ our @ISA = qw(esmith::FormMagick Exporter); |
|
|
|
|
|
|
|
|
|
|
|
our @EXPORT = qw( |
|
|
|
our @EXPORT = qw( |
|
|
|
print_user_table |
|
|
|
print_user_table |
|
|
|
|
|
|
|
print_section_bar |
|
|
|
|
|
|
|
get_name |
|
|
|
|
|
|
|
get_shares |
|
|
|
get_ldap_value |
|
|
|
get_ldap_value |
|
|
|
print_save_button |
|
|
|
print_save_button |
|
|
|
get_prop |
|
|
|
get_prop |
|
|
@ -54,10 +58,6 @@ sub new { |
|
|
|
sub print_user_table { |
|
|
|
sub print_user_table { |
|
|
|
my $self = shift; |
|
|
|
my $self = shift; |
|
|
|
my $q = $self->{cgi}; |
|
|
|
my $q = $self->{cgi}; |
|
|
|
my $account = $self->localise('ACCOUNT'); |
|
|
|
|
|
|
|
my $acctName = $self->localise('USER_NAME'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
my $modify = $self->localise('MODIFY'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
my @users = $accountdb->get('admin'); |
|
|
|
my @users = $accountdb->get('admin'); |
|
|
|
push @users, $accountdb->users(); |
|
|
|
push @users, $accountdb->users(); |
|
|
@ -69,23 +69,27 @@ sub print_user_table { |
|
|
|
print " <tr>\n <td colspan=\"2\">\n "; |
|
|
|
print " <tr>\n <td colspan=\"2\">\n "; |
|
|
|
print $q->start_table ({-CLASS => "sme-border"}),"\n "; |
|
|
|
print $q->start_table ({-CLASS => "sme-border"}),"\n "; |
|
|
|
print $q->Tr( |
|
|
|
print $q->Tr( |
|
|
|
esmith::cgi::genSmallCell($q, $self->localise($account),"header"), |
|
|
|
esmith::cgi::genSmallCell($q, $self->localise('ACCOUNT'),"header"), |
|
|
|
esmith::cgi::genSmallCell($q, $self->localise($acctName),"header"), |
|
|
|
esmith::cgi::genSmallCell($q, $self->localise('USER_NAME'),"header"), |
|
|
|
esmith::cgi::genSmallCell($q, $self->localise('ACTION'),"header",4)); |
|
|
|
esmith::cgi::genSmallCell($q, $self->localise('ACTION'),"header",4) |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
my $scriptname = basename($0); |
|
|
|
my $scriptname = basename($0); |
|
|
|
my $index=0; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach my $u (@users) { |
|
|
|
foreach my $u (@users) { |
|
|
|
my $username = $u->key(); |
|
|
|
my $username = $u->key(); |
|
|
|
my $first = $u->prop('FirstName'); |
|
|
|
my $first = $u->prop('FirstName'); |
|
|
|
my $last = $u->prop('LastName'); |
|
|
|
my $last = $u->prop('LastName'); |
|
|
|
|
|
|
|
|
|
|
|
my $action1 = "<a href=\"$scriptname?page=0&page_stack=&acctName=$username&Next=Next&action=modify&wherenext=Modify\">$modify</a>"; |
|
|
|
my $action1 = "<a href=\"$scriptname?page=0&page_stack=&acctName=$username&wherenext=Modify\">" . |
|
|
|
|
|
|
|
$self->localise('MODIFY') . "</a>"; |
|
|
|
|
|
|
|
my $action2 = "<a href=\"$scriptname?page=0&page_stack=&acctName=$username&wherenext=Audit\">" . |
|
|
|
|
|
|
|
$self->localise('AUDIT') . "</a>"; |
|
|
|
|
|
|
|
|
|
|
|
print $q->Tr(esmith::cgi::genSmallCell($q, $username,"normal")," ", |
|
|
|
print $q->Tr(esmith::cgi::genSmallCell($q, $username,"normal")," ", |
|
|
|
esmith::cgi::genSmallCell($q, "$first $last","normal")," ", |
|
|
|
esmith::cgi::genSmallCell($q, "$first $last","normal")," ", |
|
|
|
esmith::cgi::genSmallCell($q, "$action1","normal")); |
|
|
|
esmith::cgi::genSmallCell($q, "$action1","normal")," ", |
|
|
|
|
|
|
|
esmith::cgi::genSmallCell($q, "$action2","normal")); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
print qq(</table></td></tr>\n); |
|
|
|
print qq(</table></td></tr>\n); |
|
|
@ -93,6 +97,69 @@ sub print_user_table { |
|
|
|
return ""; |
|
|
|
return ""; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sub print_section_bar{ |
|
|
|
|
|
|
|
my $self = shift; |
|
|
|
|
|
|
|
print " <tr>\n <td colspan='2'>\n"; |
|
|
|
|
|
|
|
print "<hr class=\"sectionbar\"/>\n"; |
|
|
|
|
|
|
|
return undef; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sub get_shares { |
|
|
|
|
|
|
|
my ($self, $mode) = @_; |
|
|
|
|
|
|
|
my $q = $self->{cgi}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
my $user = $q->param('acctName'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
my @read; |
|
|
|
|
|
|
|
my @write; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Loop through all the ibays to check which ones are accessible |
|
|
|
|
|
|
|
foreach my $ibay ($accountdb->ibays){ |
|
|
|
|
|
|
|
my $name = $ibay->key; |
|
|
|
|
|
|
|
my $desc = $ibay->prop('Name'); |
|
|
|
|
|
|
|
my $group = $ibay->prop('Group'); |
|
|
|
|
|
|
|
next unless $accountdb->is_user_in_group($user, $group); |
|
|
|
|
|
|
|
my $perm = $ibay->prop('UserAccess'); |
|
|
|
|
|
|
|
if ($perm eq 'wr-admin-rd-group'){ |
|
|
|
|
|
|
|
push @read, $name . " ($desc)"; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else{ |
|
|
|
|
|
|
|
push @write, $name . " ($desc)"; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
# Now check shared folders |
|
|
|
|
|
|
|
foreach my $share ($accountdb->get_all_by_prop(type=>'share')){ |
|
|
|
|
|
|
|
my $name = $share->key; |
|
|
|
|
|
|
|
my $desc = $share->prop('Name'); |
|
|
|
|
|
|
|
foreach my $group (split /[;,]/, ($share->prop('ReadGroups') || '')){ |
|
|
|
|
|
|
|
push @read, $name . " ($desc)" if $accountdb->is_user_in_group($user, $group); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
foreach my $u (split /[;,]/, ($share->prop('ReadUsers') || '')){ |
|
|
|
|
|
|
|
push @read, $name . " ($desc)" if $user eq $u; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
foreach my $group (split /[;,]/, ($share->prop('WriteGroups') || '')){ |
|
|
|
|
|
|
|
push @write, $name . " ($desc)" if $accountdb->is_user_in_group($user, $group); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
foreach my $u (split /[;,]/, ($share->prop('WriteUsers') || '')){ |
|
|
|
|
|
|
|
push @write, $name . " ($desc)" if $user eq $u; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
@write = uniq @write; |
|
|
|
|
|
|
|
@read = uniq @read; |
|
|
|
|
|
|
|
my @tmp = (); |
|
|
|
|
|
|
|
foreach my $r (@read){ |
|
|
|
|
|
|
|
push @tmp, $r unless grep { $r eq $_ } @write; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
@read = @tmp; |
|
|
|
|
|
|
|
my @res = ($mode eq 'write') ? @write : @read; |
|
|
|
|
|
|
|
return join "<br>", @res; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sub get_name { |
|
|
|
|
|
|
|
my ($self) = @_; |
|
|
|
|
|
|
|
return get_ldap_value($self, 'FirstName') . " " . get_ldap_value($self, 'LastName'); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
sub get_ldap_value { |
|
|
|
sub get_ldap_value { |
|
|
|
my ($self, $field) = @_; |
|
|
|
my ($self, $field) = @_; |
|
|
|
|
|
|
|
|
|
|
@ -105,8 +172,6 @@ sub print_save_button { |
|
|
|
|
|
|
|
|
|
|
|
my ($self) = @_; |
|
|
|
my ($self) = @_; |
|
|
|
|
|
|
|
|
|
|
|
my $cgi = $self->{cgi}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$self->print_button("SAVE"); |
|
|
|
$self->print_button("SAVE"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|