From 58af8f75b600ef09aed98b0709554816fcd27073 Mon Sep 17 00:00:00 2001
From: Moritz Bunkus
Date: Tue, 11 Jun 2013 17:17:32 +0200
Subject: [PATCH] =?utf8?q?Admin-Controller:=20Weiterf=C3=BChrungslinks=20z?=
=?utf8?q?u=20altem=20admin.pl=20gefixt?=
MIME-Version: 1.0
Content-Type: text/plain; charset=utf8
Content-Transfer-Encoding: 8bit
---
SL/DB/AuthClient.pm | 70 +++++++++++++++++++
bin/mozilla/admin_printer.pl | 2 +-
templates/webpages/admin/create_dataset.html | 2 +-
templates/webpages/admin_printer/login.html | 2 +-
.../webpages/dbupgrade/auth/clients.html | 4 +-
5 files changed, 75 insertions(+), 5 deletions(-)
diff --git a/SL/DB/AuthClient.pm b/SL/DB/AuthClient.pm
index 9e3d3e8ef..e83bb16bf 100644
--- a/SL/DB/AuthClient.pm
+++ b/SL/DB/AuthClient.pm
@@ -2,6 +2,9 @@ package SL::DB::AuthClient;
use strict;
+use Carp;
+use File::Path ();
+
use SL::DB::MetaSetup::AuthClient;
use SL::DB::Manager::AuthClient;
use SL::DB::Helper::Util;
@@ -23,6 +26,37 @@ __PACKAGE__->meta->add_relationship(
__PACKAGE__->meta->initialize;
+__PACKAGE__->before_save('_before_save_remember_old_name');
+__PACKAGE__->after_save('_after_save_ensure_webdav_symlink_correctness');
+__PACKAGE__->after_delete('_after_delete_delete_webdav_symlink');
+
+sub _before_save_remember_old_name {
+ my ($self) = @_;
+
+ delete $self->{__before_save_remember_old_name};
+ if ($self->id && $::lx_office_conf{features}->{webdav}) {
+ $self->{__before_save_remember_old_name} = SL::DB::AuthClient->new(id => $self->id)->load->name;
+ }
+
+ return 1;
+}
+
+sub _after_save_ensure_webdav_symlink_correctness {
+ my ($self) = @_;
+
+ $self->ensure_webdav_symlink_correctness($self->{__before_save_remember_old_name}) if $self->id && $::lx_office_conf{features}->{webdav};
+ return 1;
+}
+
+sub _after_delete_delete_webdav_symlink {
+ my ($self) = @_;
+
+ return 1 if !$::lx_office_conf{features}->{webdav};
+ my $name = $self->webdav_symlink_basename;
+ unlink "webdav/links/${name}";
+ return 1;
+}
+
sub validate {
my ($self) = @_;
@@ -38,4 +72,40 @@ sub validate {
return @errors;
}
+sub webdav_symlink_basename {
+ my ($self, $name) = @_;
+
+ $name = $name || $self->name || '';
+ $name =~ s:/+:_:g;
+
+ return $name;
+}
+
+sub ensure_webdav_symlink_correctness {
+ my ($self, $old_name) = @_;
+
+ return unless $::lx_office_conf{features}->{webdav};
+
+ croak "Need object ID" unless $self->id;
+
+ my $new_symlink = $self->webdav_symlink_basename;
+
+ croak "Need name" unless $new_symlink;
+
+ my $base_path = 'webdav/links';
+
+ if ($old_name) {
+ my $old_symlink = $self->webdav_symlink_basename($old_name);
+ return if $old_symlink eq $new_symlink;
+
+ if (-l "${base_path}/${old_symlink}") {
+ rename "${base_path}/${old_symlink}", "${base_path}/${new_symlink}";
+ return;
+ }
+ }
+
+ File::Path::make_path('webdav/' . $self->id);
+ symlink '../' . $self->id, "${base_path}/${new_symlink}";
+}
+
1;
diff --git a/bin/mozilla/admin_printer.pl b/bin/mozilla/admin_printer.pl
index e397868ae..9d514b3c8 100644
--- a/bin/mozilla/admin_printer.pl
+++ b/bin/mozilla/admin_printer.pl
@@ -20,7 +20,7 @@ sub get_login_form {
}
sub printer_dispatcher {
- for my $action (qw(get_login_form list_printers add_printer edit_printer save_printer delete_printer list_users)) {
+ for my $action (qw(get_login_form list_printers add_printer edit_printer save_printer delete_printer)) {
if ($::form->{$action}) {
::call_sub($::locale->findsub($action));
::end_of_request()
diff --git a/templates/webpages/admin/create_dataset.html b/templates/webpages/admin/create_dataset.html
index 991bbc902..45938ca68 100644
--- a/templates/webpages/admin/create_dataset.html
+++ b/templates/webpages/admin/create_dataset.html
@@ -90,7 +90,7 @@
-
+
diff --git a/templates/webpages/admin_printer/login.html b/templates/webpages/admin_printer/login.html
index 0948d1bf1..7ddee95ea 100644
--- a/templates/webpages/admin_printer/login.html
+++ b/templates/webpages/admin_printer/login.html
@@ -9,7 +9,7 @@
-
+ [% 'Back' | $T8 %]
diff --git a/templates/webpages/dbupgrade/auth/clients.html b/templates/webpages/dbupgrade/auth/clients.html
index d06ef962f..15ef02ab8 100644
--- a/templates/webpages/dbupgrade/auth/clients.html
+++ b/templates/webpages/dbupgrade/auth/clients.html
@@ -25,7 +25,7 @@
[% LxERP.t8("It can be changed later but must be unique within the installation.") %]
-
--
2.20.1