Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 58af8f75

Von Moritz Bunkus vor mehr als 11 Jahren hinzugefügt

  • ID 58af8f75b600ef09aed98b0709554816fcd27073
  • Vorgänger 790e4a45
  • Nachfolger 895309b3

Admin-Controller: Weiterführungslinks zu altem admin.pl gefixt

Unterschiede anzeigen:

SL/DB/AuthClient.pm
2 2

  
3 3
use strict;
4 4

  
5
use Carp;
6
use File::Path ();
7

  
5 8
use SL::DB::MetaSetup::AuthClient;
6 9
use SL::DB::Manager::AuthClient;
7 10
use SL::DB::Helper::Util;
......
23 26

  
24 27
__PACKAGE__->meta->initialize;
25 28

  
29
__PACKAGE__->before_save('_before_save_remember_old_name');
30
__PACKAGE__->after_save('_after_save_ensure_webdav_symlink_correctness');
31
__PACKAGE__->after_delete('_after_delete_delete_webdav_symlink');
32

  
33
sub _before_save_remember_old_name {
34
  my ($self) = @_;
35

  
36
  delete $self->{__before_save_remember_old_name};
37
  if ($self->id && $::lx_office_conf{features}->{webdav}) {
38
    $self->{__before_save_remember_old_name} = SL::DB::AuthClient->new(id => $self->id)->load->name;
39
  }
40

  
41
  return 1;
42
}
43

  
44
sub _after_save_ensure_webdav_symlink_correctness {
45
  my ($self) = @_;
46

  
47
  $self->ensure_webdav_symlink_correctness($self->{__before_save_remember_old_name}) if $self->id && $::lx_office_conf{features}->{webdav};
48
  return 1;
49
}
50

  
51
sub _after_delete_delete_webdav_symlink {
52
  my ($self) = @_;
53

  
54
  return 1 if !$::lx_office_conf{features}->{webdav};
55
  my $name = $self->webdav_symlink_basename;
56
  unlink "webdav/links/${name}";
57
  return 1;
58
}
59

  
26 60
sub validate {
27 61
  my ($self) = @_;
28 62

  
......
38 72
  return @errors;
39 73
}
40 74

  
75
sub webdav_symlink_basename {
76
  my ($self, $name) =  @_;
77

  
78
  $name             =  $name || $self->name || '';
79
  $name             =~ s:/+:_:g;
80

  
81
  return $name;
82
}
83

  
84
sub ensure_webdav_symlink_correctness {
85
  my ($self, $old_name) = @_;
86

  
87
  return unless $::lx_office_conf{features}->{webdav};
88

  
89
  croak "Need object ID" unless $self->id;
90

  
91
  my $new_symlink = $self->webdav_symlink_basename;
92

  
93
  croak "Need name" unless $new_symlink;
94

  
95
  my $base_path = 'webdav/links';
96

  
97
  if ($old_name) {
98
    my $old_symlink = $self->webdav_symlink_basename($old_name);
99
    return if $old_symlink eq $new_symlink;
100

  
101
    if (-l "${base_path}/${old_symlink}") {
102
      rename "${base_path}/${old_symlink}", "${base_path}/${new_symlink}";
103
      return;
104
    }
105
  }
106

  
107
  File::Path::make_path('webdav/' . $self->id);
108
  symlink '../' . $self->id, "${base_path}/${new_symlink}";
109
}
110

  
41 111
1;

Auch abrufbar als: Unified diff