59 lines
1.5 KiB
Plaintext
59 lines
1.5 KiB
Plaintext
{
|
|
|
|
use PHP::Serialization qw(serialize);
|
|
use esmith::AccountsDB;
|
|
|
|
my $a = esmith::AccountsDB->open_ro || die "Error opening accounts db\n";
|
|
my @s = $a->get_all_by_prop( type => 'share' );
|
|
my $data;
|
|
my $id = $KEY;
|
|
|
|
foreach my $share (@s){
|
|
my $sharename = $share->key;
|
|
my $access = $share->prop('Ajaxplorer') || 'disabled';
|
|
next unless ($access eq 'enabled');
|
|
my @readgroups = split(/[;,]/, $share->prop('ReadGroups') || '');
|
|
my @writegroups = split(/[;,]/, $share->prop('WriteGroups') || '');
|
|
my @readusers = split(/[;,]/, $share->prop('ReadUsers') || '');
|
|
my @writeusers = split(/[;,]/, $share->prop('WriteUsers') || '');
|
|
|
|
|
|
foreach (@readgroups){
|
|
$data->{$sharename} = 'r' if ( $a->is_user_in_group($id,$_) );
|
|
}
|
|
foreach (@writegroups){
|
|
$data->{$sharename} = 'rw' if ( $a->is_user_in_group($id,$_) );
|
|
}
|
|
foreach (@readusers){
|
|
$data->{$sharename} = 'r' if ( $_ eq $id );
|
|
}
|
|
foreach (@writeusers){
|
|
$data->{$sharename} = 'rw' if ( $_ eq $id );
|
|
}
|
|
}
|
|
|
|
$data->{'ajxp.admin'} = ($id eq 'admin') ? 1:0;
|
|
|
|
$data->{'ajxp_shared'} = 'rw'
|
|
if (($ajaxplorer{'PublicShares'} || 'enabled') eq 'enabled');
|
|
|
|
my $homedir = $ajaxplorer{'HomeDir'} || 'none';
|
|
|
|
if ($homedir eq 'enabled'){
|
|
$data->{'home'} = 'r';
|
|
}
|
|
elsif ($homedir eq 'users'){
|
|
my $acc = $a->get($id);
|
|
my $ajxphomedir = $acc->prop('AjxpHomeDir') || 'disabled';
|
|
$data->{'home'} = 'r' if ($ajxphomedir eq 'enabled');
|
|
}
|
|
|
|
# Hugly hack to convert int -> bool
|
|
my $string = serialize($data);
|
|
$string =~ s/i:/b:/;
|
|
|
|
$OUT = $string;
|
|
|
|
}
|
|
|