initial commit of file from CVS for smeserver-shared-folders on Sat Sep 7 21:04:36 AEST 2024
This commit is contained in:
@@ -0,0 +1,846 @@
|
||||
#!/usr/bin/perl -w
|
||||
|
||||
#
|
||||
# $Id: shares.pm,v 1.8 2005/09/06 05:49:52 apc Exp $
|
||||
#
|
||||
|
||||
package esmith::FormMagick::Panel::shares;
|
||||
|
||||
use strict;
|
||||
|
||||
use esmith::FormMagick;
|
||||
use esmith::AccountsDB;
|
||||
use esmith::ConfigDB;
|
||||
use esmith::DomainsDB;
|
||||
use esmith::cgi;
|
||||
use esmith::util;
|
||||
use File::Path;
|
||||
use File::Basename;
|
||||
use Exporter;
|
||||
use Carp;
|
||||
|
||||
our @ISA = qw(esmith::FormMagick Exporter);
|
||||
|
||||
our @EXPORT = qw(
|
||||
print_share_table
|
||||
print_share_name_field
|
||||
print_encryption_fields
|
||||
print_pydio_fields
|
||||
acl_list
|
||||
smbAccess_list
|
||||
httpAccess_list
|
||||
max_share_name_length
|
||||
handle_shares
|
||||
remove_share
|
||||
print_save_or_add_button
|
||||
wherenext
|
||||
print_custom_button
|
||||
print_section_bar
|
||||
);
|
||||
|
||||
our $VERSION = sprintf '%d.%03d', q$Revision: 1.8 $ =~ /: (\d+).(\d+)/;
|
||||
|
||||
our $a = esmith::AccountsDB->open();
|
||||
our $c = esmith::ConfigDB->open();
|
||||
|
||||
*wherenext = \&CGI::FormMagick::wherenext;
|
||||
|
||||
sub new
|
||||
{
|
||||
my $proto = shift;
|
||||
my $class = ref($proto) || $proto;
|
||||
my $self = esmith::FormMagick::new($class);
|
||||
$self->{calling_package} = (caller)[0];
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
|
||||
sub print_share_table {
|
||||
my $self = shift;
|
||||
my $q = $self->{cgi};
|
||||
my $name = $self->localise('NAME');
|
||||
my $description = $self->localise('DESCRIPTION');
|
||||
my $modify = $self->localise('MODIFY');
|
||||
my $perm = $self->localise('PERMISSIONS');
|
||||
my $remove = $self->localise('REMOVE');
|
||||
my $action_h = $self->localise('ACTION');
|
||||
my @shares = $a->get_all_by_prop(type => 'share');
|
||||
|
||||
unless ( scalar @shares ) {
|
||||
print $q->Tr($q->td($self->localise('NO_SHARES')));
|
||||
return "";
|
||||
}
|
||||
|
||||
print $q->start_table({-CLASS => "sme-border"}),"\n";
|
||||
print $q->Tr (
|
||||
esmith::cgi::genSmallCell($q, $name,"header"),
|
||||
esmith::cgi::genSmallCell($q, $description,"header"),
|
||||
esmith::cgi::genSmallCell($q, $action_h,"header", 3)
|
||||
),"\n";
|
||||
|
||||
my $scriptname = basename($0);
|
||||
|
||||
foreach my $share (@shares) {
|
||||
my $sharename = $share->key();
|
||||
my $sharedesc = $share->prop('Name');
|
||||
next if (($share->prop('Hide') || 'no') eq 'yes');
|
||||
my $removable = $share->prop('Removable') || 'yes';
|
||||
|
||||
my $href = "shares?page=;page_stack=;wherenext=";
|
||||
|
||||
my $actionModify = $q->a({href => "${href}CreateModify&action=modify&name=$sharename"},$modify)
|
||||
. ' ';
|
||||
|
||||
my $actionPerm = $q->a({href => "${href}Permissions&name=$sharename"},$perm)
|
||||
. ' ';
|
||||
|
||||
my $actionRemove .= ($removable ne 'no') ? $q->a({href => "${href}Remove&name=$sharename&description=$sharedesc"}, $remove)
|
||||
. ' ' : '';
|
||||
|
||||
print $q->Tr (
|
||||
esmith::cgi::genSmallCell($q, $sharename,"normal"),
|
||||
esmith::cgi::genSmallCell($q, $sharedesc,"normal"),
|
||||
esmith::cgi::genSmallCell($q, $actionPerm,"normal"),
|
||||
esmith::cgi::genSmallCell($q, $actionModify,"normal"),
|
||||
esmith::cgi::genSmallCell($q, $actionRemove,"normal")
|
||||
);
|
||||
}
|
||||
|
||||
print $q->end_table,"\n";
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
sub print_custom_button{
|
||||
my ($self,$desc,$url) = @_;
|
||||
my $q = $self->{cgi};
|
||||
$url = "shares?page=0&page_stack=&Next=Next&wherenext=" . $url;
|
||||
|
||||
print " <tr>\n <td colspan='2'>\n";
|
||||
print $q->p($q->a({href => $url, -class => "button-like"},
|
||||
$self->localise($desc)));
|
||||
print qq(</tr>\n);
|
||||
return undef;
|
||||
}
|
||||
|
||||
sub print_share_to_remove{
|
||||
my $self = shift;
|
||||
my $q = $self->{cgi};
|
||||
my $sharename = $q->param('name');
|
||||
my $desc = $q->param('description');
|
||||
|
||||
print $q->Tr(
|
||||
$q->td(
|
||||
{ -class => 'sme-noborders-label' },
|
||||
$self->localise('NAME')
|
||||
),
|
||||
$q->td( { -class => 'sme-noborders-content' }, $sharename )
|
||||
), "\n";
|
||||
print $q->Tr(
|
||||
$q->td(
|
||||
{ -class => 'sme-noborders-label' },
|
||||
$self->localise('DESCRIPTION')
|
||||
),
|
||||
$q->td( { -class => 'sme-noborders-content' }, $desc )
|
||||
), "\n";
|
||||
|
||||
print $q->table(
|
||||
{ -width => '100%' },
|
||||
$q->Tr(
|
||||
$q->th(
|
||||
{ -class => 'sme-layout' },
|
||||
$q->submit(
|
||||
-name => 'cancel',
|
||||
-value => $self->localise('CANCEL')
|
||||
),
|
||||
' ',
|
||||
$q->submit(
|
||||
-name => 'remove',
|
||||
-value => $self->localise('REMOVE')
|
||||
)
|
||||
)
|
||||
)
|
||||
), "\n";
|
||||
|
||||
# Clear these values to prevent collisions when the page reloads.
|
||||
$q->delete("cancel");
|
||||
$q->delete("remove");
|
||||
|
||||
return undef;
|
||||
}
|
||||
|
||||
|
||||
sub print_share_name_field {
|
||||
my $self = shift;
|
||||
my $q = $self->{cgi};
|
||||
my $in = $q->param('name') || '';
|
||||
my $action = $q->param('action') || '';
|
||||
my $maxLength = $c->get('maxShareNameLength')->value || '12';
|
||||
|
||||
# Set default value
|
||||
|
||||
$q->param(-name=>'encryption',-value=>'disabled');
|
||||
$q->param(-name=>'inactivity',-value=>'30');
|
||||
$q->param(-name=>'smbaccess',-value=>'browseable');
|
||||
$q->param(-name=>'recyclebin',-value=>'disabled');
|
||||
$q->param(-name=>'retention',-value=>'unlimited');
|
||||
$q->param(-name=>'httpaccess',-value=>'none');
|
||||
$q->param(-name=>'webdav',-value=>'disabled');
|
||||
$q->param(-name=>'requireSSL',-value=>'disabled');
|
||||
$q->param(-name=>'indexes',-value=>'disabled');
|
||||
$q->param(-name=>'dynamic',-value=>'disabled');
|
||||
|
||||
print qq(<tr><td colspan="2">) . $self->localise('NAME_FIELD_DESC',
|
||||
{maxLength => $maxLength }) . qq(</td></tr>);
|
||||
print qq(<tr><td class="sme-noborders-label">) .
|
||||
$self->localise('NAME_LABEL') . qq(</td>\n);
|
||||
if ($action eq 'modify' and $in) {
|
||||
print qq(
|
||||
<td class="sme-noborders-content">$in
|
||||
<input type="hidden" name="name" value="$in">
|
||||
<input type="hidden" name="action" value="modify">
|
||||
</td>
|
||||
);
|
||||
|
||||
# Read the values for each field from the accounts db and store
|
||||
# them in the cgi object so our form will have the correct
|
||||
# info displayed.
|
||||
my $rec = $a->get($in);
|
||||
if ($rec)
|
||||
{
|
||||
$q->param(-name=>'description',-value=>
|
||||
$rec->prop('Name'));
|
||||
$q->param(-name=>'encryption',-value=>
|
||||
($rec->prop('Encryption') || 'disabled'));
|
||||
$q->param(-name=>'inactivity',-value=>
|
||||
($rec->prop('InactivityTimeOut') || '30'));
|
||||
$q->param(-name=>'smbaccess',-value=>
|
||||
($rec->prop('smbAccess') || 'enabled'));
|
||||
$q->param(-name=>'recyclebin',-value=>
|
||||
($rec->prop('RecycleBin') || 'disabled'));
|
||||
$q->param(-name=>'retention',-value=>
|
||||
($rec->prop('RecycleBinRetention') || 'unlimited'));
|
||||
$q->param(-name=>'httpaccess',-value=>
|
||||
($rec->prop('httpAccess') || 'none'));
|
||||
$q->param(-name=>'webdav',-value=>
|
||||
($rec->prop('WebDav') || 'disabled'));
|
||||
$q->param(-name=>'requireSSL',-value=>
|
||||
($rec->prop('RequireSSL') || 'enabled'));
|
||||
$q->param(-name=>'indexes',-value=>
|
||||
($rec->prop('Indexes') || 'enabled'));
|
||||
$q->param(-name=>'dynamic',-value=>
|
||||
($rec->prop('DynamicContent') || 'disabled'));
|
||||
}
|
||||
}
|
||||
else {
|
||||
print qq(
|
||||
<td><input type="text" name="name" value="$in">
|
||||
<input type="hidden" name="action" value="create">
|
||||
</td>
|
||||
);
|
||||
}
|
||||
|
||||
print qq(</tr>\n);
|
||||
return undef;
|
||||
|
||||
}
|
||||
|
||||
# If EncFS is available, print encryptions options
|
||||
sub print_encryption_fields {
|
||||
my $self = shift;
|
||||
my $q = $self->{cgi};
|
||||
|
||||
return undef unless(system('rpm -q fuse-encfs 2>&1 > /dev/null') == 0);
|
||||
|
||||
my $encryption = $q->param('encryption') || 'disabled';
|
||||
my $action = $q->param('action') || '';
|
||||
|
||||
my $sharename = $q->param('name') || '';
|
||||
|
||||
return undef if ($action eq 'modify' && $encryption ne 'enabled');
|
||||
|
||||
my $inactivity = (($sharename ne '') && ($a->get($sharename))) ?
|
||||
($a->get($sharename)->prop('InactivityTimeOut') || '30'):'30';
|
||||
|
||||
print_section_bar();
|
||||
|
||||
print qq(<tr><td colspan="2">) . $self->localise('DESC_ENCRYPTION') . qq(</td></tr>);
|
||||
print qq(<tr><td class="sme-noborders-label">) .
|
||||
$self->localise('LABEL_ENCRYPTION') . qq(</td>\n);
|
||||
|
||||
if ($action eq 'modify') {
|
||||
print qq(
|
||||
<td class="sme-noborders-content">) . $self->localise(uc($encryption)) . qq(
|
||||
<input type="hidden" name="encryption" value="$encryption">
|
||||
</td>
|
||||
);
|
||||
}
|
||||
else {
|
||||
print qq(
|
||||
<td class="sme-noborders-content"><SELECT NAME="encryption" TYPE="select">
|
||||
<OPTION VALUE="disabled">) . $self->localise('DISABLED') .
|
||||
qq(<OPTION VALUE="enabled">) . $self->localise('ENABLED') .
|
||||
qq(</SELECT></td>
|
||||
);
|
||||
print qq(<tr><td colspan="2">) . $self->localise('DESC_PASSWORD') . qq(</td></tr>);
|
||||
print qq(<tr><td class="sme-noborders-label">) .
|
||||
$self->localise('LABEL_PASSWORD') . qq(</td>\n);
|
||||
print qq(
|
||||
<td><input type="password" name="password" value="">
|
||||
</td>
|
||||
);
|
||||
print qq(<tr><td class="sme-noborders-label">) .
|
||||
$self->localise('LABEL_PASSWORD2') . qq(</td>\n);
|
||||
print qq(
|
||||
<td><input type="password" name="password2" value="">
|
||||
</td>
|
||||
);
|
||||
}
|
||||
|
||||
print qq(<tr><td colspan="2">) . $self->localise('DESC_INACTIVITY') . qq(</td></tr>);
|
||||
print qq(<tr><td class="sme-noborders-label">) .
|
||||
$self->localise('INACTIVITY') . qq(</td>\n);
|
||||
print qq(
|
||||
<td><input type="text" name="inactivity" value="$inactivity">
|
||||
</td>
|
||||
);
|
||||
|
||||
print qq(</tr>\n);
|
||||
|
||||
return undef;
|
||||
}
|
||||
|
||||
# If pydio is enabled:
|
||||
sub print_pydio_fields {
|
||||
my $self = shift;
|
||||
my $pydio = $c->get('pydio') || return undef;
|
||||
if (($pydio->prop('status') || 'disabled') eq 'enabled'){
|
||||
print_section_bar();
|
||||
my ($enabled,$disabled) = ('','');
|
||||
my $sharename = $self->{cgi}->param('name') || '';
|
||||
my $share = $a->get($sharename);
|
||||
# If share exists and Pydio is enabled
|
||||
if ($share){
|
||||
if (($share->prop('Pydio') || 'disabled') eq 'enabled'){
|
||||
$enabled = ' SELECTED';
|
||||
}
|
||||
}
|
||||
else {
|
||||
$disabled = ' SELECTED';
|
||||
}
|
||||
print qq(<tr><td colspan="2">) . $self->localise('DESC_PYDIO') . qq(</td></tr>);
|
||||
print qq(<tr><td class="sme-noborders-label">) .
|
||||
$self->localise('LABEL_PYDIO') . qq(</td>\n);
|
||||
print qq(
|
||||
<td class="sme-noborders-content"><SELECT NAME="pydio" TYPE="select">
|
||||
<OPTION VALUE="disabled"$disabled>) . $self->localise('DISABLED') .
|
||||
qq(<OPTION VALUE="enabled"$enabled>) . $self->localise('ENABLED') .
|
||||
qq(</SELECT></td>
|
||||
);
|
||||
}
|
||||
return undef;
|
||||
}
|
||||
|
||||
# Print a table of users and groups
|
||||
# having read only or read/write access
|
||||
sub acl_list () {
|
||||
my $self = shift;
|
||||
my $q = $self->{cgi};
|
||||
my $sharename = $q->param('name');
|
||||
my $out = '';
|
||||
|
||||
my $share = $a->get($sharename);
|
||||
return $self->error('SHARE_NOT_FOUND') unless ($share);
|
||||
|
||||
my $desc = $share->prop('Name') || $sharename;
|
||||
my $WriteGroups = $share->prop('WriteGroups') || '';
|
||||
my $ReadGroups = $share->prop('ReadGroups') || '';
|
||||
my $WriteUsers = $share->prop('WriteUsers') || '';
|
||||
my $ReadUsers = $share->prop('ReadUsers') || '';
|
||||
my $manualPerm = $share->prop('ManualPermissions') || 'no';
|
||||
|
||||
if (($manualPerm eq 'yes') || ($manualPerm eq 'enabled') || ($manualPerm eq 'ntacl')){
|
||||
$out .= $self->localise('MANUAL_PERMS');
|
||||
}
|
||||
|
||||
my %WriteGroups;
|
||||
my %ReadGroups;
|
||||
my %WriteUsers;
|
||||
my %ReadUsers;
|
||||
|
||||
foreach my $group ( split ( /[,;]/, $WriteGroups ) ) {
|
||||
$WriteGroups{$group} = 1;
|
||||
}
|
||||
foreach my $group ( split ( /[,;]/, $ReadGroups ) ) {
|
||||
$ReadGroups{$group} = 1;
|
||||
}
|
||||
foreach my $user ( split ( /[,;]/, $WriteUsers ) ) {
|
||||
$WriteUsers{$user} = 1;
|
||||
}
|
||||
foreach my $user ( split ( /[,;]/, $ReadUsers ) ) {
|
||||
$ReadUsers{$user} = 1;
|
||||
}
|
||||
|
||||
my @shared = "shared";
|
||||
my @groups = sort { $a->key() cmp $b->key() } $a->groups();
|
||||
my @users = sort { $a->key() cmp $b->key() } $a->users();
|
||||
|
||||
$out .= qq(<tr><td class="sme-noborders-label">) .
|
||||
$self->localise('NAME_LABEL') . qq(</td>\n);
|
||||
$out .= qq(<td class="sme-noborders-content">$sharename</td>);
|
||||
$out .= qq(<tr><td class="sme-noborders-label">) .
|
||||
$self->localise('DESCRIPTION') . qq(</td>\n);
|
||||
$out .= qq(<td class="sme-noborders-content">$desc</td>);
|
||||
|
||||
$out .= "<tr><td class=\"sme-noborders-label\">" .
|
||||
$self->localise('PERMISSIONS') .
|
||||
"</td><td>\n".
|
||||
$q->start_table({-class => "sme-border"})."\n".
|
||||
$q->Tr(
|
||||
esmith::cgi::genSmallCell($q, $self->localise('GROUPS'),"header"),
|
||||
esmith::cgi::genSmallCell($q, $self->localise('DESCRIPTION'),"header"),
|
||||
esmith::cgi::genSmallCell($q, $self->localise('WRITE_PERM'),"header"),
|
||||
esmith::cgi::genSmallCell($q, $self->localise('READ_PERM'),"header")
|
||||
);
|
||||
|
||||
foreach my $shared (@shared) {
|
||||
my $write = "";
|
||||
my $read = "";
|
||||
my $name = "shared";
|
||||
my $desc = "Everyone";
|
||||
if ( $WriteGroups{$name} ) {
|
||||
$write = "checked";
|
||||
}
|
||||
if ( $ReadGroups{$name} ) {
|
||||
$read = "checked";
|
||||
}
|
||||
|
||||
$out .= $q->Tr(
|
||||
esmith::cgi::genSmallCell($q, $name, "normal"),
|
||||
esmith::cgi::genSmallCell($q, $desc, "normal"),
|
||||
|
||||
esmith::cgi::genSmallCell($q,"<input type=\"checkbox\""
|
||||
. " name=\"writegroup\""
|
||||
. " $write value=\"$name\">", "normal"),
|
||||
esmith::cgi::genSmallCell($q,"<input type=\"checkbox\""
|
||||
. " name=\"readgroup\""
|
||||
. " $read value=\"$name\">", "normal")
|
||||
);
|
||||
}
|
||||
|
||||
foreach my $group (@groups) {
|
||||
my $write = "";
|
||||
my $read = "";
|
||||
my $name = $group->key();
|
||||
my $desc = $group->prop('Description');
|
||||
if ( $WriteGroups{$name} ) {
|
||||
$write = "checked";
|
||||
}
|
||||
if ( $ReadGroups{$name} ) {
|
||||
$read = "checked";
|
||||
}
|
||||
|
||||
$out .= $q->Tr(
|
||||
esmith::cgi::genSmallCell($q, $name, "normal"),
|
||||
esmith::cgi::genSmallCell($q, $desc, "normal"),
|
||||
|
||||
esmith::cgi::genSmallCell($q,"<input type=\"checkbox\""
|
||||
. " name=\"writegroup\""
|
||||
. " $write value=\"$name\">", "normal"),
|
||||
esmith::cgi::genSmallCell($q,"<input type=\"checkbox\""
|
||||
. " name=\"readgroup\""
|
||||
. " $read value=\"$name\">", "normal")
|
||||
);
|
||||
}
|
||||
|
||||
$out .= $q->Tr(
|
||||
esmith::cgi::genSmallCell($q, $self->localise('USERS'),"header"),
|
||||
esmith::cgi::genSmallCell($q, $self->localise('DESCRIPTION'),"header"),
|
||||
esmith::cgi::genSmallCell($q, $self->localise('WRITE_PERM'),"header"),
|
||||
esmith::cgi::genSmallCell($q, $self->localise('READ_PERM'),"header")
|
||||
);
|
||||
|
||||
foreach my $user (@users) {
|
||||
my $write = "";
|
||||
my $read = "";
|
||||
my $name = $user->key();
|
||||
my $desc = $user->prop('FirstName') . ' ' . $user->prop('LastName');
|
||||
if ( $WriteUsers{$name} ) {
|
||||
$write = "checked";
|
||||
}
|
||||
if ( $ReadUsers{$name} ) {
|
||||
$read = "checked";
|
||||
}
|
||||
|
||||
$out .= $q->Tr(
|
||||
esmith::cgi::genSmallCell($q, $name, "normal"),
|
||||
esmith::cgi::genSmallCell($q, $desc, "normal"),
|
||||
|
||||
esmith::cgi::genSmallCell($q,"<input type=\"checkbox\""
|
||||
. " name=\"writeuser\""
|
||||
. " $write value=\"$name\">", "normal"),
|
||||
esmith::cgi::genSmallCell($q,"<input type=\"checkbox\""
|
||||
. " name=\"readuser\""
|
||||
. " $read value=\"$name\">", "normal")
|
||||
);
|
||||
}
|
||||
|
||||
$out .= "</table></td></tr>\n";
|
||||
return $out;
|
||||
}
|
||||
|
||||
# Print a section bar
|
||||
sub print_section_bar{
|
||||
my $self = shift;
|
||||
print " <tr>\n <td colspan='2'>\n";
|
||||
print "<hr class=\"sectionbar\"/>\n";
|
||||
return undef;
|
||||
}
|
||||
|
||||
|
||||
# Returns the hash of public access settings for showing in the smb
|
||||
# access drop down list.
|
||||
|
||||
sub smbAccess_list {
|
||||
return {
|
||||
'none' => 'NONE',
|
||||
'browseable' => 'ENABLED_BROWSEABLE',
|
||||
'non-browseable' => 'ENABLED_NON_BROWSEABLE',
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
# Returns the hash of public access settings for showing in the http
|
||||
# access drop down list.
|
||||
|
||||
sub httpAccess_list {
|
||||
return {
|
||||
'none' => 'NONE',
|
||||
'local' => 'LOCAL_NETWORK_NO_PASSWORD',
|
||||
'local-pw' => 'LOCAL_NETWORK_PASSWORD',
|
||||
'global' => 'ENTIRE_INTERNET_NO_PASSWORD',
|
||||
'global-pw' => 'ENTIRE_INTERNET_PASSWORD',
|
||||
'global-pw-remote' => 'ENTIRE_INTERNET_PASSWORD_REMOTE'
|
||||
};
|
||||
}
|
||||
|
||||
# VALIDATION ROUTINES
|
||||
|
||||
|
||||
# Checks the length of a given share name against the maximum set in the
|
||||
# maxShareNameLength record of the configuration database. Defaults to a
|
||||
# maximum length of the maxShareNameLength set in the config db.
|
||||
|
||||
sub max_share_name_length {
|
||||
my ($self, $data) = @_;
|
||||
$c->reload();
|
||||
my $max = $c->get('maxShareNameLength')->value || '12';
|
||||
|
||||
if (length($data) <= $max) {
|
||||
return "OK";
|
||||
}
|
||||
else {
|
||||
return $self->localise("MAX_SHARE_NAME_LENGTH_ERROR",
|
||||
{acctName => $data,
|
||||
maxShareNameLength => $max,
|
||||
maxLength => $max});
|
||||
}
|
||||
}
|
||||
|
||||
# Call the create or modify routine
|
||||
|
||||
sub handle_shares {
|
||||
my $self = shift;
|
||||
my $q = $self->{cgi};
|
||||
my $action = $q->param("action") || '';
|
||||
|
||||
if ($action eq "create") {
|
||||
$self->create_share();
|
||||
}
|
||||
else {
|
||||
$self->modify_share();
|
||||
}
|
||||
}
|
||||
|
||||
# Print save or add button
|
||||
|
||||
sub print_save_or_add_button {
|
||||
my $self = shift;
|
||||
|
||||
my $action = $self->cgi->param("action") || '';
|
||||
if ($action eq "modify") {
|
||||
$self->print_button("SAVE");
|
||||
}
|
||||
else {
|
||||
$self->print_button("ADD");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
# Create a new shared folder
|
||||
|
||||
sub create_share {
|
||||
my $self = shift;
|
||||
my $q = $self->{cgi};
|
||||
my $name = $q->param('name');
|
||||
my $encryption = $q->param('encryption') || 'disabled';
|
||||
my $password = $q->param('password');
|
||||
my $password2 = $q->param('password2');
|
||||
|
||||
my $msg = $self->validate_name($name);
|
||||
|
||||
unless ($msg eq "OK") {
|
||||
return $self->error($msg);
|
||||
}
|
||||
|
||||
$msg = $self->max_share_name_length($name);
|
||||
|
||||
unless ($msg eq "OK") {
|
||||
return $self->error($msg);
|
||||
}
|
||||
|
||||
$msg = $self->conflict_check($name);
|
||||
unless ($msg eq "OK") {
|
||||
return $self->error($msg);
|
||||
}
|
||||
|
||||
$msg = ($encryption eq 'enabled') ? $self->confirm_password($password,$password2) : 'OK';
|
||||
unless ($msg eq "OK") {
|
||||
return $self->error($msg);
|
||||
}
|
||||
|
||||
if (my $acct = $a->new_record($name, {
|
||||
Name => $q->param('description'),
|
||||
Encryption => $encryption,
|
||||
InactivityTimeOut => ($q->param('inactivity') || ''),
|
||||
RecycleBin => $q->param('recyclebin'),
|
||||
RecycleBinRetention => $q->param('retention'),
|
||||
smbAccess => $q->param('smbaccess'),
|
||||
httpAccess => $q->param('httpaccess'),
|
||||
WebDav => $q->param('webdav'),
|
||||
Pydio => ($q->param('pydio') || 'disabled'),
|
||||
RequireSSL => $q->param('requireSSL'),
|
||||
Indexes => $q->param('indexes'),
|
||||
DynamicContent => $q->param('dynamic'),
|
||||
type => 'share',
|
||||
}) ) {
|
||||
# Untaint $name before use in system()
|
||||
$name =~ /(.+)/; $name = $1;
|
||||
|
||||
if ($encryption eq 'enabled') {
|
||||
my $source = '/home/e-smith/files/shares/' . $name . '/.store';
|
||||
my $dest = '/home/e-smith/files/shares/' . $name . '/files';
|
||||
File::Path::mkpath ($source);
|
||||
mkdir $dest;
|
||||
open(DIR, "| /usr/bin/encfs -S --public -o nonempty,umask=000 $source $dest > /dev/null 2>&1");
|
||||
print DIR "\n$password";
|
||||
close DIR;
|
||||
$self->error("ERROR_WITH_ENCRYPTION") unless(
|
||||
system("/bin/fusermount -uz $dest") == 0
|
||||
);
|
||||
}
|
||||
|
||||
if (system ("/sbin/e-smith/signal-event", "share-create", $name) == 0) {
|
||||
$self->success("SUCCESSFULLY_CREATED_SHARE", "Permissions");
|
||||
}
|
||||
else {
|
||||
$self->error("ERROR_WHILE_CREATING_SHARE");
|
||||
}
|
||||
}
|
||||
else {
|
||||
$self->error('CANT_CREATE_SHARE');
|
||||
}
|
||||
}
|
||||
|
||||
# Modify a share.
|
||||
# This sub shares a lot of code with create share
|
||||
# It should be merged
|
||||
sub modify_share {
|
||||
my $self = shift;
|
||||
my $q = $self->{cgi};
|
||||
my $name = $q->param('name');
|
||||
my $acct = $a->get($name);
|
||||
|
||||
return $self->error('CANT_FIND_SHARE') unless($acct && $acct->prop('type') eq 'share');
|
||||
|
||||
$acct->merge_props(
|
||||
Name => $q->param('description'),
|
||||
InactivityTimeOut => ($q->param('inactivity') || ''),
|
||||
RecycleBin => $q->param('recyclebin'),
|
||||
RecycleBinRetention => $q->param('retention'),
|
||||
smbAccess => $q->param('smbaccess'),
|
||||
httpAccess => $q->param('httpaccess'),
|
||||
WebDav => $q->param('webdav'),
|
||||
Pydio => ($q->param('pydio') || 'disabled'),
|
||||
RequireSSL => $q->param('requireSSL'),
|
||||
Indexes => $q->param('indexes'),
|
||||
DynamicContent => $q->param('dynamic'),
|
||||
);
|
||||
|
||||
# Untaint $name before use in system()
|
||||
$name =~ /(.+)/; $name = $1;
|
||||
if (system ("/sbin/e-smith/signal-event", "share-modify", $name) == 0) {
|
||||
$self->success("SUCCESSFULLY_MODIFIED_SHARE");
|
||||
}
|
||||
else {
|
||||
$self->error("ERROR_WHILE_MODIFYING_SHARE");
|
||||
}
|
||||
return undef;
|
||||
}
|
||||
|
||||
sub modify_perm {
|
||||
my $self = shift;
|
||||
my $q = $self->{cgi};
|
||||
my $name = $q->param('name');
|
||||
my $acct = $a->get($name);
|
||||
|
||||
return $self->error('CANT_FIND_SHARE') unless($acct && $acct->prop('type') eq 'share');
|
||||
|
||||
my $encryption = $acct->prop('Encryption') || 'disabled';
|
||||
|
||||
my $WriteGroups = join(",", $q->param('writegroup'));
|
||||
my $WriteUsers = join(",", $q->param('writeuser'));
|
||||
|
||||
my @CleanReadGroups = ();
|
||||
my @CleanReadUsers = ();
|
||||
|
||||
# EncFS doesn't expose underlying ACLs
|
||||
# So, just remove any read only groups
|
||||
# Read Only is not supported with encryption
|
||||
if ($encryption ne 'enabled'){
|
||||
# No need to have read access if write is already granted
|
||||
foreach my $group ($q->param('readgroup')){
|
||||
push (@CleanReadGroups, $group) unless (grep { $_ eq $group } $q->param('writegroup'));
|
||||
}
|
||||
foreach my $user ($q->param('readuser')){
|
||||
push (@CleanReadUsers, $user) unless (grep { $_ eq $user } $q->param('writeuser'));
|
||||
}
|
||||
}
|
||||
my $ReadGroups = join(",",@CleanReadGroups);
|
||||
my $ReadUsers = join(",",@CleanReadUsers);
|
||||
|
||||
$acct->merge_props(
|
||||
WriteGroups => $WriteGroups,
|
||||
ReadGroups => $ReadGroups,
|
||||
WriteUsers => $WriteUsers,
|
||||
ReadUsers => $ReadUsers,
|
||||
);
|
||||
|
||||
# Untaint $name before use in system()
|
||||
$name =~ /(.+)/; $name = $1;
|
||||
if (system ("/sbin/e-smith/signal-event", "share-modify", $name) == 0) {
|
||||
$self->success("SUCCESSFULLY_MODIFIED_SHARE");
|
||||
}
|
||||
else {
|
||||
$self->error("ERROR_WHILE_MODIFYING_SHARE");
|
||||
}
|
||||
return undef;
|
||||
}
|
||||
|
||||
# Remove a share
|
||||
sub remove_share {
|
||||
my $self = shift;
|
||||
my $q = $self->{cgi};
|
||||
my $name = $q->param('name');
|
||||
my $acct = $a->get($name);
|
||||
return $self->error('CANCELED','First') if ($q->param('cancel'));
|
||||
return $self->error('CANT_FIND_SHARE') unless ($acct && $acct->prop('type') eq 'share');
|
||||
|
||||
# Untaint $name before use in system()
|
||||
$name =~ /(.+)/; $name = $1;
|
||||
my $encryption = $acct->prop('Encryption') || 'disabled';
|
||||
my $mountstatus = `/bin/mount | grep /home/e-smith/files/shares/$name/ | grep -c fuse`;
|
||||
chomp($mountstatus);
|
||||
|
||||
if (($encryption eq 'enabled') && ($mountstatus eq '1')){
|
||||
$self->error("ERROR_ENCRYPTED_ENABLED");
|
||||
return undef;
|
||||
}
|
||||
|
||||
$acct->set_prop('type', 'share-deleted');
|
||||
|
||||
if (system ("/sbin/e-smith/signal-event", "share-delete", $name) == 0) {
|
||||
$self->success("SUCCESSFULLY_DELETED_SHARE");
|
||||
$acct->delete();
|
||||
}
|
||||
else {
|
||||
$self->error("ERROR_WHILE_DELETING_SHARE");
|
||||
}
|
||||
return undef;
|
||||
}
|
||||
|
||||
# Check the proposed name for clashes with existing pseudonyms or other
|
||||
# accounts of any type.
|
||||
|
||||
sub conflict_check {
|
||||
my ($self, $name) = @_;
|
||||
my $rec = $a->get($name);
|
||||
|
||||
my $type;
|
||||
if (defined $rec){
|
||||
my $type = $rec->prop('type');
|
||||
if ($type eq "pseudonym"){
|
||||
my $acct = $rec->prop("Account");
|
||||
my $acct_type = $a->get($acct)->prop('type');
|
||||
|
||||
return $self->localise('ACCT_CLASHES_WITH_PSEUDONYM',
|
||||
{acctName => $name, acctType => $acct_type, acct => $acct});
|
||||
}
|
||||
}
|
||||
elsif (defined getpwnam($name) || defined getgrnam($name)){
|
||||
$type = 'system';
|
||||
}
|
||||
else{
|
||||
# No account record and no account
|
||||
return 'OK';
|
||||
}
|
||||
return $self->localise('ACCOUNT_EXISTS',
|
||||
{acctName => $name, acctType => $type});
|
||||
}
|
||||
|
||||
# Checks that the name supplied does not contain any unacceptable chars.
|
||||
# Returns OK on success or a localised error message otherwise.
|
||||
sub validate_name {
|
||||
my ($self, $acctName) = @_;
|
||||
|
||||
unless ($acctName =~ /^([a-z0-9][\_\.\-a-z0-9]*)\$?$/){
|
||||
return $self->localise('ACCT_NAME_HAS_INVALID_CHARS',
|
||||
{acctName => $acctName});
|
||||
}
|
||||
return "OK";
|
||||
}
|
||||
|
||||
# Check if inactivity is a number
|
||||
sub validate_inactivity {
|
||||
my ($self, $inac) = @_;
|
||||
|
||||
unless ($inac =~ /^\d+$/){
|
||||
return $self->localise('INVALID_INACTIVITY',
|
||||
{inactivity => $inac});
|
||||
}
|
||||
return "OK";
|
||||
}
|
||||
|
||||
# Check if both passwords match
|
||||
# and are more than 8 chars
|
||||
sub confirm_password {
|
||||
|
||||
my ($self, $pass1, $pass2) = @_;
|
||||
|
||||
return 'OK' if ($self->{cgi}->param('encryption') eq 'disabled');
|
||||
|
||||
my @num = split(//,$pass1);
|
||||
unless (scalar (@num) >= 8){
|
||||
return $self->localise('PASSWORD_TOO_SHORT');
|
||||
}
|
||||
|
||||
unless ($pass1 eq $pass2){
|
||||
return $self->localise('PASSWORD_MISMATCH');
|
||||
}
|
||||
return 'OK';
|
||||
}
|
||||
|
||||
1;
|
||||
|
@@ -0,0 +1,155 @@
|
||||
#!/usr/bin/perl -w
|
||||
|
||||
package esmith::FormMagick::Panel::userpanelEncfs;
|
||||
|
||||
use strict;
|
||||
|
||||
use esmith::FormMagick;
|
||||
use esmith::AccountsDB;
|
||||
use esmith::ConfigDB;
|
||||
use esmith::cgi;
|
||||
use esmith::util;
|
||||
use File::Basename;
|
||||
use Exporter;
|
||||
use Carp;
|
||||
|
||||
our @ISA = qw(esmith::FormMagick Exporter);
|
||||
|
||||
our @EXPORT = qw(
|
||||
print_share_table
|
||||
mount_encfs
|
||||
umount_encfs
|
||||
);
|
||||
|
||||
our $accountdb = esmith::AccountsDB->open();
|
||||
our $user = $ENV{'REMOTE_USER'};
|
||||
$user = $1 if ($user =~ /^([a-z][\-a-z0-9]*)$/);
|
||||
our @usergroups = $accountdb->user_group_list($user);
|
||||
|
||||
*wherenext = \&CGI::FormMagick::wherenext;
|
||||
|
||||
sub new
|
||||
{
|
||||
my $proto = shift;
|
||||
my $class = ref($proto) || $proto;
|
||||
my $self = esmith::FormMagick::new($class);
|
||||
$self->{calling_package} = (caller)[0];
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub print_share_table {
|
||||
my $self = shift;
|
||||
my $q = $self->{cgi};
|
||||
my @shares = $accountdb->get_all_by_prop(type => 'share');
|
||||
my @encfs = ();
|
||||
|
||||
foreach (@shares){
|
||||
my @sharegroups = split(/[,;]/, ($_->prop('WriteGroups') || '') .','. ($_->prop('ReadGroups') || ''));
|
||||
my @shareusers = split(/[,;]/, ($_->prop('WriteUsers') || '') .','. ($_->prop('ReadUsers') || ''));
|
||||
@sharegroups = keys %{{ map { $_ => 1 } @sharegroups }};
|
||||
|
||||
my %count = ();
|
||||
my @intersection = ();
|
||||
foreach my $element (@sharegroups, @usergroups) { $count{$element}++ }
|
||||
foreach my $element (keys %count) {
|
||||
push @intersection, $element if ($count{$element} > 1);
|
||||
}
|
||||
|
||||
# Only display the share in the list if encryption is enabled
|
||||
# and the user has at least read access
|
||||
if ((($_->prop('Encryption') || 'disabled') eq 'enabled') &&
|
||||
((scalar @intersection > 0 ) || (grep { $_ eq $user} @shareusers) || ($user eq 'admin'))){
|
||||
push @encfs, $_;
|
||||
}
|
||||
}
|
||||
unless ( scalar @encfs )
|
||||
{
|
||||
print $q->Tr($q->td($self->localise('NO_ENCRYPTED_SHARE')));
|
||||
return "";
|
||||
}
|
||||
|
||||
print $q->start_table({-CLASS => "sme-border"}),"\n";
|
||||
print $q->Tr (
|
||||
esmith::cgi::genSmallCell($q, $self->localise('NAME'),"header"),
|
||||
esmith::cgi::genSmallCell($q, $self->localise('DESCRIPTION'),"header"),
|
||||
esmith::cgi::genSmallCell($q, $self->localise('STATUS'),"header"),
|
||||
esmith::cgi::genSmallCell($q, $self->localise('ACTION'),"header", 3)
|
||||
),"\n";
|
||||
|
||||
my $scriptname = basename($0);
|
||||
|
||||
foreach my $i (@encfs)
|
||||
{
|
||||
my $sharename = $i->key();
|
||||
my $sharedesc = $i->prop('Name');
|
||||
|
||||
my $mountstatus = `/bin/mount | /bin/grep /home/e-smith/files/shares/$sharename/ | grep -c fuse`;
|
||||
chomp($mountstatus);
|
||||
my $sharestatus = ($mountstatus eq '1') ? $self->localise('MOUNTED') : $self->localise('NOT_MOUNTED');
|
||||
|
||||
my $href = "$scriptname?page=;page_stack=;wherenext=";
|
||||
|
||||
my $actionMount = $q->a({href => "${href}Mount&name=$sharename"},$self->localise('MOUNT'))
|
||||
. ' ';
|
||||
|
||||
my $actionUmount .= $q->a({href => "${href}Umount&name=$sharename"}, $self->localise('UMOUNT'))
|
||||
. ' ';
|
||||
|
||||
my $action = ($mountstatus eq '1') ? $actionUmount : $actionMount;
|
||||
|
||||
print $q->Tr (
|
||||
esmith::cgi::genSmallCell($q, $sharename,"normal"),
|
||||
esmith::cgi::genSmallCell($q, $sharedesc,"normal"),
|
||||
esmith::cgi::genSmallCell($q, $sharestatus,"normal"),
|
||||
esmith::cgi::genSmallCell($q, $action,"normal")
|
||||
);
|
||||
}
|
||||
|
||||
print $q->end_table,"\n";
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
sub mount_encfs {
|
||||
my $fm = shift;
|
||||
my $pass = $fm->{cgi}->param('password');
|
||||
my $share = $fm->{cgi}->param('name');
|
||||
my $rec = $accountdb->get($share);
|
||||
my $timeout = $rec->prop('InactivityTimeOut') || '30';
|
||||
$timeout = '30' unless ($timeout =~ m/\d+/);
|
||||
my $recycle = $rec->prop('RecycleBin') || 'disabled';
|
||||
my $recycledir = $rec->prop('RecycleBinDir') || 'Recycle Bin';
|
||||
my $source = "/home/e-smith/files/shares/$share/.store";
|
||||
my $dest = "/home/e-smith/files/shares/$share/files";
|
||||
$pass =~ s/([;<>\*\|`&\$!#\(\)\[\]\{\}:'"])/\\$1/g;
|
||||
$pass = $1 if ( $pass =~ /(.*)/ );
|
||||
|
||||
unless ( system("echo $pass | /usr/bin/encfs -i $timeout -S --public -o nonempty,umask=000 $source $dest > /dev/null 2>&1") == 0){
|
||||
$fm->error('ERROR_MOUNTING');
|
||||
return undef;
|
||||
}
|
||||
|
||||
if ( !-e $dest . '/' . $recycledir && $recycle eq 'enabled'){
|
||||
unless(mkdir $dest . '/' . $recycledir){
|
||||
$fm->error('ERROR_MOUNTING');
|
||||
}
|
||||
}
|
||||
|
||||
$fm->success('SUCCESS');
|
||||
}
|
||||
|
||||
sub umount_encfs {
|
||||
my $fm = shift;
|
||||
my $share = $fm->{cgi}->param('name');
|
||||
|
||||
unless ( system("/bin/fusermount -uz /home/e-smith/files/shares/$share/files > /dev/null 2>&1") == 0){
|
||||
$fm->error('ERROR_UMOUNTING');
|
||||
return undef;
|
||||
}
|
||||
|
||||
$fm->success('SUCCESS');
|
||||
}
|
||||
|
||||
1;
|
||||
|
337
root/usr/share/smanager/lib/SrvMngr/Controller/Shared_folders.pm
Normal file
337
root/usr/share/smanager/lib/SrvMngr/Controller/Shared_folders.pm
Normal file
@@ -0,0 +1,337 @@
|
||||
package SrvMngr::Controller::Shared_folders;
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
# heading : Collaboration
|
||||
# description : Shared Folders
|
||||
# navigation : 2000 2600
|
||||
#
|
||||
# name : shared_foldersget, method : get, url : /shared_folders, ctlact : Shared_folders#main
|
||||
# name : shared_folderss, method : post, url : /shared_folders, ctlact : Shared_folders#do_save
|
||||
# name : shared_foldersc, method : get, url : /shared_foldersc, ctlact : Shared_folders#do_create_modify
|
||||
# name : shared_foldersc, method : post, url : /shared_foldersc, ctlact : Shared_folders#do_create_modify
|
||||
# name : shared_foldersd, method : get, url : /shared_foldersd, ctlact : Shared_folders#do_delete
|
||||
# name : shared_foldersp, method : get, url : /shared_foldersp, ctlact : Shared_folders#do_permissions
|
||||
# name : shared_folderse, method : get, url : /shared_folderse, ctlact : Shared_folders#do_encrypt
|
||||
# routes : end
|
||||
#
|
||||
# Documentation : https://wiki.contribs.org/SharedFolders
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use Mojo::Base 'Mojolicious::Controller';
|
||||
|
||||
use Locale::gettext;
|
||||
use SrvMngr::I18N;
|
||||
use SrvMngr qw(theme_list init_session);
|
||||
|
||||
use Data::Dumper;
|
||||
use esmith::util;
|
||||
use esmith::HostsDB;
|
||||
use esmith::AccountsDB;
|
||||
|
||||
our $db = esmith::ConfigDB->open();
|
||||
our $adb = esmith::AccountsDB->open();
|
||||
|
||||
our $user = 'admin';
|
||||
#$ENV{'REMOTE_USER'};
|
||||
$user = $1 if ( $user =~ /^([a-z][\-a-z0-9]*)$/ );
|
||||
our @usergroups = $adb->user_group_list($user);
|
||||
|
||||
use constant FALSE => 0;
|
||||
use constant TRUE => 1;
|
||||
|
||||
my %shf_datas = ();
|
||||
|
||||
sub main {
|
||||
#
|
||||
# Main Panel
|
||||
#
|
||||
my $c = shift;
|
||||
$c->app->log->info( $c->log_req );
|
||||
$shf_datas{first} = 'shf_FIRSTPAGE_DESC';
|
||||
do_display($c);
|
||||
}
|
||||
|
||||
sub do_display {
|
||||
my $c = shift;
|
||||
my $title = $c->l('shf_FORM_TITLE');
|
||||
my $modul = '';
|
||||
my @shares = get_all_shares($c);
|
||||
my @encryptedfolders = get_all_encrypted_shares($c);
|
||||
$shf_datas{trt} = 'LIST';
|
||||
|
||||
$c->stash(
|
||||
title => $title,
|
||||
modul => $modul,
|
||||
shf_datas => \%shf_datas,
|
||||
sharedfolders => \@shares,
|
||||
encryptedfolders => \@encryptedfolders,
|
||||
empty => ( scalar @shares == 0 ),
|
||||
emptye => ( scalar @encryptedfolders == 0 )
|
||||
);
|
||||
|
||||
$c->render( template => 'shared_folders' );
|
||||
}
|
||||
|
||||
sub get_all_shares {
|
||||
my $c = shift;
|
||||
my @sharesdb = $adb->get_all_by_prop( type => 'share' );
|
||||
my @shares = ();
|
||||
foreach my $sharerec (@sharesdb) {
|
||||
next if ( ( $sharerec->prop('Hide') || 'no' ) eq 'yes' );
|
||||
my $removable = $sharerec->prop('Removable') || 'yes';
|
||||
my %row = (
|
||||
"Name" => $sharerec->key,
|
||||
"Description" => $sharerec->prop("Name"),
|
||||
"Removeable" => $removable
|
||||
);
|
||||
push( @shares, \%row );
|
||||
}
|
||||
return @shares;
|
||||
}
|
||||
|
||||
sub get_all_encrypted_shares {
|
||||
|
||||
my $c = shift;
|
||||
my @shares = $adb->get_all_by_prop( type => 'share' );
|
||||
my @encfs = ();
|
||||
foreach (@shares) {
|
||||
my @sharegroups = split( /[,;]/,
|
||||
( $_->prop('WriteGroups') || '' ) . ','
|
||||
. ( $_->prop('ReadGroups') || '' ) );
|
||||
my @shareusers = split( /[,;]/,
|
||||
( $_->prop('WriteUsers') || '' ) . ','
|
||||
. ( $_->prop('ReadUsers') || '' ) );
|
||||
@sharegroups = keys %{ { map { $_ => 1 } @sharegroups } };
|
||||
|
||||
my %count = ();
|
||||
my @intersection = ();
|
||||
foreach my $element ( @sharegroups, @usergroups ) { $count{$element}++ }
|
||||
foreach my $element ( keys %count ) {
|
||||
push @intersection, $element if ( $count{$element} > 1 );
|
||||
}
|
||||
|
||||
# Only display the share in the list if encryption is enabled
|
||||
# and the user has at least read access
|
||||
if (
|
||||
( ( $_->prop('Encryption') || 'disabled' ) eq 'enabled' )
|
||||
&& ( ( scalar @intersection > 0 )
|
||||
|| ( grep { $_ eq $user } @shareusers )
|
||||
|| ( $user eq 'admin' ) )
|
||||
)
|
||||
{
|
||||
push @encfs, $_;
|
||||
}
|
||||
}
|
||||
unless ( scalar @encfs > 0 ) {
|
||||
return ();
|
||||
}
|
||||
|
||||
my @encrypted_shares = ();
|
||||
foreach my $i (@encfs) {
|
||||
my $sharename = $i->key();
|
||||
my $sharedesc = $i->prop('Name');
|
||||
|
||||
my $mountstatus =
|
||||
`/bin/mount | /bin/grep /home/e-smith/files/shares/$sharename/ | grep -c fuse`;
|
||||
chomp($mountstatus);
|
||||
my $sharestatus =
|
||||
( $mountstatus eq '1' )
|
||||
? $c->l('shf_ENCRYPT_MOUNTED')
|
||||
: $c->l('shf_ENCRYPT_NOT_MOUNTED');
|
||||
|
||||
my $actionMount = "shf_ENCRYPT_MOUNT"
|
||||
; #$q->a({href => "${href}Mount&name=$sharename"},$self->localise('MOUNT')). ' ';
|
||||
|
||||
my $actionUmount = 'shf_ENCRYPT_UNMOUNT'
|
||||
; #$q->a({href => "${href}Umount&name=$sharename"}, $self->localise('UMOUNT')). ' ';
|
||||
|
||||
my $action = ( $mountstatus eq '1' ) ? $actionUmount : $actionMount;
|
||||
|
||||
my %row = (
|
||||
"Name" => $sharename,
|
||||
"Description" => $sharedesc,
|
||||
"Status" => $sharestatus,
|
||||
"Action" => $action
|
||||
);
|
||||
push( @encrypted_shares, \%row );
|
||||
}
|
||||
return @encrypted_shares;
|
||||
}
|
||||
|
||||
sub do_encrypt {
|
||||
#
|
||||
# Enable/disable encrypt share clicked
|
||||
#
|
||||
my $c = shift;
|
||||
$c->app->log->info( $c->log_req );
|
||||
my $title = $c->l('shf_main_title');
|
||||
my $modul = '';
|
||||
my $mode = $c->param("mode");
|
||||
|
||||
#etc....
|
||||
|
||||
do_display($c); #If no errors
|
||||
}
|
||||
|
||||
sub do_save {
|
||||
#
|
||||
# Save pressed
|
||||
#
|
||||
my $c = shift;
|
||||
$c->app->log->info( $c->log_req );
|
||||
|
||||
my $title = $c->l('shf_main_title');
|
||||
my $modul = '';
|
||||
my $mode = $c->param("mode");
|
||||
|
||||
#etc....
|
||||
if ( $mode = "DEL" ) {
|
||||
my $name = $c->param("name");
|
||||
my $msg = remove_share( $c, $name );
|
||||
if ( $msg eq "ok" ) {
|
||||
$shf_datas{success} = "shf_SUCCESSFULLY_DELETED_SHARE";
|
||||
}
|
||||
else {
|
||||
$shf_datas{error} = $msg;
|
||||
}
|
||||
}
|
||||
do_display($c);
|
||||
|
||||
}
|
||||
|
||||
sub do_delete {
|
||||
#
|
||||
# Delete/Remove clicked
|
||||
#
|
||||
my $c = shift;
|
||||
$c->app->log->info( $c->log_req );
|
||||
|
||||
my $title = $c->l('shf_REMOVE_TITLE');
|
||||
my $modul = '';
|
||||
|
||||
#etc.....
|
||||
$shf_datas{trt} = 'DEL';
|
||||
$c->stash(
|
||||
title => $title,
|
||||
modul => $modul,
|
||||
shf_datas => \%shf_datas,
|
||||
);
|
||||
$c->render( template => 'shared_folders' );
|
||||
}
|
||||
|
||||
sub do_create_modify {
|
||||
#
|
||||
# Delete/Remove clicked
|
||||
#
|
||||
my $c = shift;
|
||||
$c->app->log->info( $c->log_req );
|
||||
|
||||
my $title = $c->l('shf_create_modify_title');
|
||||
my $modul = '';
|
||||
my $empty;
|
||||
|
||||
#Selection options
|
||||
$shf_datas{disable_enable} =
|
||||
[ [ $c->l(''), 'disabled' ], [ $c->l(''), 'enabled' ] ];
|
||||
$shf_datas{recyclebin} = [
|
||||
[ $c->l('shf_DISABLED'), 'disabled' ],
|
||||
[ $c->l('shf_DONT_KEEP_VERSIONS'), 'enabled' ],
|
||||
[ $c->l('shf_KEEP_VERSIONS'), 'keep-versions' ]
|
||||
];
|
||||
$shf_datas{SMBaccess} = [
|
||||
[ $c->l('shf_ENABLED_BROWSEABLE'), 'browseable' ],
|
||||
[ $c->l('shf_ENABLED_NON_BROWSEABLE'), 'non-browseable' ],
|
||||
[ 'No access', 'none' ]
|
||||
];
|
||||
$shf_datas{webaccess} = [
|
||||
[ $c->l('shf_ENTIRE_INTERNET_NO_PASSWORD'), 'global' ],
|
||||
[ $c->l('shf_ENTIRE_INTERNET_PASSWORD'), 'global-pw' ],
|
||||
[ $c->l('shf_ENTIRE_INTERNET_PASSWORD_REMOTE'), 'global-pw-remote' ],
|
||||
[ $c->l('shf_LOCAL_NETWORK_NO_PASSWORD'), 'local' ],
|
||||
[ $c->l('shf_LOCAL_NETWORK_PASSWORD'), 'local-pw' ],
|
||||
[ $c->l('shf_NO_ACCESS'), 'None' ]
|
||||
];
|
||||
$shf_datas{retention} = [
|
||||
[ $c->l('shf_UNLIMITED'), 'unlimited' ],
|
||||
[ $c->l('shf_ONE_WEEK'), 7 ],
|
||||
[ $c->l('shf_ONE_MONTH'), 30 ],
|
||||
[ $c->l('shf_SIX_MONTHS'), 180 ],
|
||||
[ $c->l('shf_ONE_YEAR'), 365 ]
|
||||
];
|
||||
my $name = $c->param("name") || '';
|
||||
my @params = ();
|
||||
if ($name ne ''){
|
||||
my $namedb = $adb->get($name);
|
||||
my @params = ('SMBaccess' => $namedb->get_value("SMBaccess") || '',
|
||||
);
|
||||
}
|
||||
|
||||
$shf_datas{param_details} = \@params;
|
||||
|
||||
#etc.....
|
||||
|
||||
$shf_datas{trt} = 'CR_MOD';
|
||||
$c->stash(
|
||||
title => $title,
|
||||
modul => $modul,
|
||||
shf_datas => \%shf_datas,
|
||||
empty => $empty
|
||||
);
|
||||
$c->render( template => 'shared_folders' );
|
||||
}
|
||||
|
||||
sub do_permisssions {
|
||||
#
|
||||
# Delete/Remove clicked
|
||||
#
|
||||
my $c = shift;
|
||||
$c->app->log->info( $c->log_req );
|
||||
|
||||
my $title = $c->l('shf_permissions_title');
|
||||
my $modul = '';
|
||||
|
||||
#etc.....
|
||||
|
||||
$shf_datas{trt} = 'PERM';
|
||||
$c->stash(
|
||||
title => $title,
|
||||
modul => $modul,
|
||||
shf_datas => \%shf_datas,
|
||||
);
|
||||
$c->render( template => 'shared_folders' );
|
||||
}
|
||||
|
||||
# Remove a share
|
||||
sub remove_share {
|
||||
my $c = shift;
|
||||
my $name = shift;
|
||||
my $acct = $adb->get($name);
|
||||
|
||||
#return $self->error('CANCELED','First') if ($c->param('cancel'));
|
||||
return 'shf_CANT_FIND_SHARE'
|
||||
unless ( $acct && $acct->prop('type') eq 'share' );
|
||||
|
||||
# Untaint $name before use in system()
|
||||
$name =~ /(.+)/;
|
||||
$name = $1;
|
||||
my $encryption = $acct->prop('Encryption') || 'disabled';
|
||||
my $mountstatus =
|
||||
`/bin/mount | grep /home/e-smith/files/shares/$name/ | grep -c fuse`;
|
||||
chomp($mountstatus);
|
||||
|
||||
if ( ( $encryption eq 'enabled' ) && ( $mountstatus eq '1' ) ) {
|
||||
return "shf_ERROR_ENCRYPTED_ENABLED";
|
||||
}
|
||||
$acct->set_prop( 'type', 'share-deleted' );
|
||||
if ( system( "/sbin/e-smith/signal-event", "share-delete", $name ) == 0 ) {
|
||||
$acct->delete();
|
||||
}
|
||||
else {
|
||||
return "shf_ERROR_WHILE_DELETING_SHARE";
|
||||
}
|
||||
return "ok";
|
||||
}
|
||||
|
||||
1;
|
@@ -0,0 +1,125 @@
|
||||
package SrvMngr::I18N::Modules::Shared_folders::en;
|
||||
use strict;
|
||||
use warnings;
|
||||
use utf8;
|
||||
use Mojo::Base 'SrvMngr::I18N';
|
||||
|
||||
use SrvMngr::I18N::Modules::General::en;
|
||||
|
||||
my %lexicon = (
|
||||
|
||||
'shf_title' => 'Shared Folders',
|
||||
'shf_FORM_TITLE' => ' Create, modify, or remove shared folders',
|
||||
'shf_FIRSTPAGE_DESC' => ' You can remove any shared folder by clicking on the corresponding command next to the shared folder.',
|
||||
'shf_ADD_TITLE' => ' Create or modify a shared folder',
|
||||
'shf_NAME_FIELD_DESC' => ' The share name should contain only lower-case letters, numbers, periods, hyphens and underscores, and should start with a lower-case letter. For example "johnson", "intra", and "cust3.prj12" are all valid names, but "3associates", "John Smith" and "Bus!Partner" are not. The name is limited to [_1] characters.',
|
||||
'shf_NAME_LABEL' => ' Shared folder name',
|
||||
'shf_REMOVE_TITLE' => ' Remove shared folder',
|
||||
'shf_REMOVE_DESC' => '
|
||||
You are about to remove the following shared folder<br>
|
||||
All files belonging to this shared folder will be deleted.<br>
|
||||
Are you sure you wish to remove it ?<br>
|
||||
',
|
||||
'shf_ERROR_WHILE_CREATING_SHARE' => ' An error occurred while creating the shared folder.',
|
||||
'shf_SUCCESSFULLY_CREATED_SHARE' => ' Successfully created shared folder.',
|
||||
'shf_NO_SHARES' => ' There are no shared folders currently configured.',
|
||||
'shf_CANT_FIND_SHARE' => ' Can\'t find account for [_1] (does it exist?)',
|
||||
'shf_CANT_CREATE_SHARE' => ' Can\'t create new account for [_1] (does it already exist?)',
|
||||
'shf_ERROR_WHILE_MODIFYING_SHARE' => ' An error occurred while modifying the shared folder.',
|
||||
'shf_SUCCESSFULLY_MODIFIED_SHARE' => ' Successfully modified shared folder.',
|
||||
'shf_SUCCESSFULLY_DELETED_SHARE' => ' Successfully deleted shared folder.',
|
||||
'shf_ERROR_WHILE_DELETING_SHARE' => ' An error occurred while deleting the share.',
|
||||
'shf_Shares' =>
|
||||
'Shares',
|
||||
'shf_INVALID_SHARE_DESCRIPTION' =>
|
||||
'Error: unexpected or missing characters in share description',
|
||||
'shf_ACCT_NAME_HAS_INVALID_CHARS' =>
|
||||
'The shared folder name "[_1]" contains invalid characters. Shared folder names must start with a lower case letter and contain only lower case letters, numbers, and hyphens.',
|
||||
'shf_MAX_SHARE_NAME_LENGTH_ERROR' => ' The shared folder name "[_1]" is too long. The maximum is [_1] characters.',
|
||||
'shf_ACCT_CLASHES_WITH_PSEUDONYM' => '
|
||||
The account "[_1]" clashes with pseudonym details for [_2] account "[_3]". <p>[_2] is a pseudonym for [_1].</p>
|
||||
',
|
||||
'shf_ACCOUNT_EXISTS' => ' The account "[_1]" is an existing [_2] account.',
|
||||
'shf_LABEL_ADD_SHARE_BUTTON' => ' Create a new shared folder',
|
||||
'shf_DESC_PERMISSIONS' => ' You can use this matrix to define groups and users access permissions.',
|
||||
'shf_DESC_SMB_SETTINGS' => ' The following settings control the access of this shared folder from the local network, using the SMB/CIFS protocol. ',
|
||||
'shf_LABEL_SMB_ACCESS' => ' SMB Access',
|
||||
'shf_LABEL_RECYCLEBIN' => ' Recycle bin',
|
||||
'shf_LABEL_RETENTION' => ' Retention time',
|
||||
'shf_UNLIMITED' => ' unlimited',
|
||||
'shf_ONE_WEEK' => ' one week',
|
||||
'shf_ONE_MONTH' => ' one month',
|
||||
'shf_SIX_MONTHS' => ' six months',
|
||||
'shf_ONE_YEAR' => ' one year',
|
||||
'shf_DESC_HTTP_SETTINGS' => ' The following settings control the access of this shared folder using the HTTP/HTTPS protocol.',
|
||||
'shf_LABEL_HTTP_ACCESS' => ' Web Access',
|
||||
'shf_LABEL_WEBDAV' => ' WebDav support',
|
||||
'shf_LABEL_REQUIRE_SSL' => ' Force secure connections',
|
||||
'shf_LABEL_INDEXES' => ' Indexes',
|
||||
'shf_LABEL_DYNAMIC_CONTENT' => ' Dynamic content execution (PHP, CGI, SSI)',
|
||||
'shf_LOCAL_NETWORK_NO_PASSWORD' => 'Local network (no password required)',
|
||||
'shf_LOCAL_NETWORK_PASSWORD' => 'Local network (password required)',
|
||||
'shf_ENTIRE_INTERNET_NO_PASSWORD' => 'Entire Internet (no password required)',
|
||||
'shf_ENTIRE_INTERNET_PASSWORD' => 'Entire Internet (password required)',
|
||||
'shf_ENTIRE_INTERNET_PASSWORD_REMOTE' => 'Entire Internet (password required outside local network)',
|
||||
'shf_NONE' => 'No access',
|
||||
'shf_ENABLED_BROWSEABLE' => 'Enabled, browseable',
|
||||
'shf_ENABLED_NON_BROWSEABLE' => 'Enabled, hidden',
|
||||
'shf_DONT_KEEP_VERSIONS' => 'Enabled, keep only the latest version',
|
||||
'shf_KEEP_VERSIONS' => 'Enabled, keep a copy of all versions',
|
||||
'shf_PERMISSIONS' => ' Permissions',
|
||||
'shf_WRITE_PERM' => ' Read / Write',
|
||||
'shf_READ_PERM' => ' Read Only',
|
||||
'shf_ENABLED' => ' enabled',
|
||||
'shf_DISABLED' => ' disabled',
|
||||
'shf_YES' => ' yes',
|
||||
'shf_NO' => ' no',
|
||||
'shf_NAME' => 'Name',
|
||||
'shf_DESCRIPTION' => 'Description',
|
||||
'shf_ACTION' => ' Action',
|
||||
'shf_MODIFY' => ' Modify',
|
||||
'shf_REMOVE' => ' Remove',
|
||||
'shf_CANCELED' => ' Cancelled',
|
||||
'shf_MANUAL_PERMS' => ' <span style="color:red">Permissions on this shared folder are managed manually, modifications will only affect web access if a password is required.</span><br><br>',
|
||||
'shf_DESC_ENCRYPTION' => ' The followings options let you protect your data. If encryption is enabled, the data will never be stored in clear text on the server. Your share will either be "available" (data will appear as clear text, encryption/decryption is done on the fly), or protected (only the ciphered data is available on the server). Encryption can only be set at shared folder creation time. Also, read only groups are not supported with encrypted shared folders. If you enable encryption, only members of groups with read/write privileges will be able to access this share.',
|
||||
'shf_LABEL_ENCRYPTION' => ' Encryption',
|
||||
'shf_DESC_PASSWORD' => ' You need to choose a password to protect your data. This password must be at least 8 characters long. Do not loose this password. If you forget it, your data will be lost because there\'s no way to recover it.',
|
||||
'shf_LABEL_PASSWORD' => ' Password',
|
||||
'shf_LABEL_PASSWORD2' => ' Password (confirmation)',
|
||||
'shf_DESC_INACTIVITY' => ' To provide additional security, you can set an inactivity time out (in minutes). When the data is available, if nobody access it for this period of time, the data will go back to protected mode automatically.',
|
||||
'shf_INACTIVITY' => ' Inactivity timeout',
|
||||
'shf_ERROR_WITH_ENCRYPTION' => ' An error occured while performing initial folder encryption',
|
||||
'shf_ERROR_ENCRYPTED_ENABLED' => ' This shared folder is encrypted and access is enabled. You have to put it in protected mode before removing it',
|
||||
'shf_INVALID_INACTIVITY' => ' Inactivity value must be numbers only',
|
||||
'shf_PASSWORD_MISMATCH' => ' Passwords don\'t match',
|
||||
'shf_PASSWORD_TOO_SHORT' => ' Password is too short, please use at least 8 characters',
|
||||
'shf_DESC_PYDIO' => ' The following settings control the access of this shared folder with the web based file manager Pydio (formerly AjaXplorer)',
|
||||
'shf_LABEL_PYDIO' => ' Pydio Access',
|
||||
'shf_TITLE_PERMISSIONS' => ' Access right management',
|
||||
'shf_USERS' => 'Users',
|
||||
|
||||
'shf_ENCRYPT_FORM_TITLE' => 'Shared Folders Encryption',
|
||||
'shf_ENCRYPT_Shared Folders Encryption' => 'Shared Folders Encryption',
|
||||
'shf_ENCRYPT_FIRSTPAGE_DESC' =>'This panel lets you enable encrypted shared folder access.',
|
||||
'shf_ENCRYPT_STATUS' => 'Status',
|
||||
'shf_ENCRYPT_MOUNTED' => 'Enabled',
|
||||
'shf_ENCRYPT_NOT_MOUNTED' => 'Protected',
|
||||
'shf_ENCRYPT_MOUNT' =>'Enable',
|
||||
'shf_ENCRYPT_UMOUNT' => 'Protect',
|
||||
'shf_ENCRYPT_ERROR_MOUNTING' => 'An error occured. Check that you have the correct password.',
|
||||
'shf_ENCRYPT_UMOUNT_DESC' => 'Are you sure you want to protect this shared folder ? Once protected, the content won\'t be accessible until re-enabled with the associated password.',
|
||||
'shf_ENCRYPT_MOUNT_DESC' => 'You have to enter the password to make this folder\'s content available.',
|
||||
'shf_ENCRYPT_LABEL_MOUNT_PASSWORD' => 'Password',
|
||||
'shf_ENCRYPT_VALIDATE' => 'Validate',
|
||||
'shf_ENCRYPT_NO_ENCRYPTED_SHARE' => 'No encrypted share configured',
|
||||
|
||||
);
|
||||
|
||||
our %Lexicon = (
|
||||
%{ SrvMngr::I18N::Modules::General::en::Lexicon },
|
||||
%lexicon
|
||||
);
|
||||
|
||||
|
||||
1;
|
||||
|
@@ -0,0 +1,54 @@
|
||||
%#
|
||||
%# Create or Modify shared folder
|
||||
%#
|
||||
<div class="shf_create_modify">
|
||||
<h2>
|
||||
%= l('shf_ADD_TITLE')
|
||||
</h2>
|
||||
%= $c->render_to_string(inline =>l('shf_NAME_FIELD_DESC'))
|
||||
<br>
|
||||
% my $btn = $c->l('shf_ADD');
|
||||
%= form_for '/shared_folders' => (method => 'POST') => begin
|
||||
%my $name = $c->param("name") || '';
|
||||
%my $desc = $c->param("desc") || '';
|
||||
<span class=label>
|
||||
%=l "shf_NAME_LABEL"
|
||||
</span>
|
||||
<span class=data>
|
||||
%= text_field name =>$name
|
||||
</span><br>
|
||||
<span class=label>
|
||||
%=l "shf_DESCRIPTION"
|
||||
</span>
|
||||
<span class=data>
|
||||
%= text_field description=>$desc
|
||||
</span><br>
|
||||
%= l('shf_DESC_SMB_SETTINGS')
|
||||
<span class=label>
|
||||
%=l "shf_LABEL_SMB_ACCESS"
|
||||
</span>
|
||||
<span class=data>
|
||||
% param SMBaccess => $shf_datas->{param_details}->{SMBaccess};
|
||||
%= select_field SMBaccess =>$shf_datas->{SMBaccess}
|
||||
</span><br>
|
||||
<span class=label>
|
||||
%=l "shf_LABEL_RECYCLEBIN"
|
||||
</span>
|
||||
<span class=data>
|
||||
$ param recyclebin => $shf_datas->{param_details}->{recyclebin};
|
||||
%= select_field recyclebin=>$shf_datas->{recyclebin}
|
||||
</span><br>
|
||||
<span class=label>
|
||||
%=l "shf_LABEL_RETENTION"
|
||||
</span>
|
||||
<span class=data>
|
||||
$ param retention => $shf_datas->{param_details}->{retention};
|
||||
%= select_field retention=>$shf_datas->{retention}
|
||||
</span><br>
|
||||
%= l('shf_DESC_HTTP_SETTINGS')
|
||||
|
||||
%= submit_button "$btn", class => 'action'
|
||||
% end
|
||||
</div>
|
||||
|
||||
|
@@ -0,0 +1,33 @@
|
||||
%#
|
||||
%# Delete shared folder
|
||||
%#
|
||||
<div class="shf_delete">
|
||||
<h2>
|
||||
%= l('shf_REMOVE_TITLE')
|
||||
</h2>
|
||||
%= $c->render_to_string(inline =>l('shf_REMOVE_DESC'))
|
||||
<br>
|
||||
% my $btn = $c->l('shf_REMOVE');
|
||||
%= form_for '/shared_folders' => (method => 'POST') => begin
|
||||
%my $name = $c->param("name");
|
||||
%my $desc = $c->param("desc") || '';
|
||||
<span class=label>
|
||||
%=l "shf_NAME"
|
||||
</span>
|
||||
<span class=data>
|
||||
%= $name
|
||||
</span><br>
|
||||
<span class=label>
|
||||
%=l "shf_DESCRIPTION"
|
||||
</span>
|
||||
<span class=data>
|
||||
%= $desc
|
||||
</span><br>
|
||||
%= hidden_field mode=>"DEL"
|
||||
%= hidden_field name=>$name
|
||||
%= hidden_field desc=>$desc
|
||||
%= submit_button "$btn", class => 'action'
|
||||
% end
|
||||
</div>
|
||||
|
||||
|
@@ -0,0 +1,94 @@
|
||||
<div id='shf_list'>
|
||||
|
||||
% my $btn = l('shf_LABEL_ADD_SHARE_BUTTON');
|
||||
|
||||
%= form_for '/shared_foldersc' => (method => 'POST') => begin
|
||||
<br>
|
||||
%= submit_button "$btn", class => 'action'
|
||||
<br>
|
||||
|
||||
%# Table of shares
|
||||
|
||||
% if ($empty){
|
||||
<div class=sme-error>
|
||||
%=l 'shf_NO_SHARES'
|
||||
</div>
|
||||
% } else {
|
||||
|
||||
<table class="sme-border"><tbody>
|
||||
<tr>
|
||||
<th class='sme-border'>
|
||||
%=l 'NAME'
|
||||
</th>
|
||||
<th class='sme-border'>
|
||||
%=l 'DESCRIPTION'
|
||||
</th>
|
||||
<th class='sme-border' colspan=3>
|
||||
%=l 'shf_ACTION'
|
||||
</th>
|
||||
</tr>
|
||||
% foreach my $sharedfolder (@$sharedfolders) {
|
||||
<tr>
|
||||
%= t td => (class => 'sme-border') => $sharedfolder->{"Name"}
|
||||
%= t td => (class => 'sme-border') => $sharedfolder->{"Description"}
|
||||
<td class=sme-border>
|
||||
<a href="/smanager/shared_foldersp?mode=PERM&name=<%= $sharedfolder->{"Name"}%>"><%=l 'shf_PERMISSIONS'%></a>
|
||||
</td>
|
||||
<td class=sme-border>
|
||||
<a href="/smanager/shared_foldersc?mode=MOD&name=<%= $sharedfolder->{"Name"}%>"><%=l 'MODIFY'%></a>
|
||||
</td>
|
||||
%
|
||||
<td class=sme-border>
|
||||
<a href="/smanager/shared_foldersd?mode=DEL&name=<%= $sharedfolder->{"Name"}%>&desc=<%= $sharedfolder->{"Description"}%>"><%=l 'REMOVE'%></a>
|
||||
</td>
|
||||
</tr>
|
||||
%}
|
||||
</tbody>
|
||||
</table>
|
||||
%}
|
||||
|
||||
%#Table of encrypted shares
|
||||
<hr><h2>
|
||||
%=l 'shf_ENCRYPT_FORM_TITLE'
|
||||
</h2>
|
||||
%=l 'shf_ENCRYPT_FIRSTPAGE_DESC'
|
||||
<br>
|
||||
% if ($emptye){
|
||||
<div class=sme-error>
|
||||
%=l 'shf_ENCRYPT_NO_ENCRYPTED_SHARE'
|
||||
</div>
|
||||
% } else {
|
||||
|
||||
|
||||
<table class="sme-border"><tbody>
|
||||
<tr>
|
||||
<th class='sme-border'>
|
||||
%=l 'NAME'
|
||||
</th>
|
||||
<th class='sme-border'>
|
||||
%=l 'DESCRIPTION'
|
||||
</th>
|
||||
<th class='sme-border'>
|
||||
%=l 'shf_ENCRYPT_STATUS'
|
||||
</th>
|
||||
<th class='sme-border' colspan=3>
|
||||
%=l 'shf_ACTION'
|
||||
</th>
|
||||
</tr>
|
||||
% foreach my $encryptedfolder (@$encryptedfolders) {
|
||||
<tr>
|
||||
%= t td => (class => 'sme-border') => $encryptedfolder->{"Name"}
|
||||
%= t td => (class => 'sme-border') => $encryptedfolder->{"Description"}
|
||||
%= t td => (class => 'sme-border') => $c->l($encryptedfolder->{"Status"})
|
||||
% my $action = $encryptedfolder->{"Action"};
|
||||
% my $actiondesc = $c->l("$action");
|
||||
<td class='sme-border'><a href='/smanager/shared_folderse?name=<%= $encryptedfolder->{"Name"}%>&mode=<%=$actiondesc%>'><%=$actiondesc%></a></td>
|
||||
</tr>
|
||||
%}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
% }
|
||||
|
||||
% end
|
||||
</div>
|
@@ -0,0 +1,59 @@
|
||||
%#
|
||||
%# Delete shared folder
|
||||
%#
|
||||
<div class="shf_delete">
|
||||
% my $btn = $c->l('SAVE');
|
||||
% my $MailServer = $shf_datas->{mailserver};
|
||||
|
||||
%= form_for '/shared_folders_save' => (method => 'POST') => begin
|
||||
<br>
|
||||
% my $domain = $c->param('domain');
|
||||
%=$c->render_to_string(inline =>l('shf_Delegate_Domain',$domain))
|
||||
<br>
|
||||
<span class=label>
|
||||
%=l "shf_Server_or_IP"
|
||||
</span>
|
||||
<span class=data>
|
||||
%=text_field 'MailServer' =>$MailServer
|
||||
</span>
|
||||
<br><br>
|
||||
%if ($empty) {
|
||||
%=$c->l('shf_No_pseudonyms_for',$domain);
|
||||
<br>
|
||||
<a href="/smanager/shared_folders3?domain=<%=$domain %>&mode=new"><button type='button'><%= $c->l('shf_Click_Here')%></button></a>
|
||||
%=$c->render_to_string(inline=>l('shf_Click_Here_first'))
|
||||
<br>
|
||||
|
||||
%} else {
|
||||
%=$c->l('shf_Current_list_for',$domain);
|
||||
<br>
|
||||
<a href="/smanager/shared_folders3?domain=<%=$domain %>&mode=new"><button type='button'><%= $c->l('shf_Click_Here')%></button></a>
|
||||
%=$c->render_to_string(inline=>l('shf_Click_Here_add'))
|
||||
<br><br>
|
||||
|
||||
%#Table of pseudonyms:
|
||||
<table class="sme-border"><tbody>
|
||||
<tr>
|
||||
<th class='sme-border'>
|
||||
%=l 'shf_Pseudonyms'
|
||||
</th>
|
||||
<th class='sme-border'>
|
||||
%=l 'shf_Local_User'
|
||||
</th>
|
||||
<th class='sme-border'>
|
||||
</th>
|
||||
<th class='sme-border' '>
|
||||
</th>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
%}
|
||||
|
||||
<br>
|
||||
%=$c->render_to_string(inline =>l('shf_Need_Save'));
|
||||
<br>
|
||||
%= submit_button "$btn", class => 'action'
|
||||
% end
|
||||
</div>
|
||||
|
||||
|
@@ -0,0 +1,43 @@
|
||||
% layout 'default', title => "Sme server 2 - Shared Folders", share_dir => './';
|
||||
|
||||
% content_for 'module' => begin
|
||||
<div id="module">
|
||||
|
||||
% if ($config->{debug} == 1) {
|
||||
<p>
|
||||
%= dumper $c->current_route
|
||||
</p>
|
||||
% }
|
||||
|
||||
<h1><%=$title%></h1>
|
||||
%= $modul
|
||||
|
||||
%if ($shf_datas->{first}) {
|
||||
%=$c->render_to_string(inline =>$c->l($shf_datas->{first}))
|
||||
|
||||
%} elsif ($shf_datas->{success}) {
|
||||
<div class='sme-success'>
|
||||
<h2> Operation Status Report</h2>
|
||||
%= $c->l($shf_datas->{success});
|
||||
</div>
|
||||
|
||||
%} elsif ($shf_datas->{error}) {
|
||||
<div class='sme-error'>
|
||||
<h2> Operation Status Report - error</h2>
|
||||
%= $c->l($shf_datas->{error});
|
||||
</div>
|
||||
%}
|
||||
|
||||
|
||||
% if ($shf_datas->{trt} eq 'CR_MOD') {
|
||||
%= include 'partials/_shf_create_modify'
|
||||
%} elsif ($shf_datas->{trt} eq 'DEL') {
|
||||
%= include 'partials/_shf_delete'
|
||||
%} elsif ($shf_datas->{trt} eq 'PERM') {
|
||||
%= include 'partials/_shf_permissions'
|
||||
%} else {
|
||||
%= include 'partials/_shf_list'
|
||||
%}
|
||||
|
||||
</div>
|
||||
%end
|
Reference in New Issue
Block a user