Revision e14e91e1
Von Kivitendo Admin vor mehr als 6 Jahren hinzugefügt
SL/Controller/File.pm | ||
---|---|---|
32 | 32 |
use SL::File; |
33 | 33 |
use SL::Controller::Helper::ThumbnailCreator qw(file_probe_image_type); |
34 | 34 |
|
35 |
use constant DO_DELETE => 0; |
|
36 |
use constant DO_UNIMPORT => 1; |
|
37 |
|
|
35 |
use constant DO_DELETE => 0; |
|
36 |
use constant DO_UNIMPORT => 1; |
|
38 | 37 |
|
39 | 38 |
use Rose::Object::MakeMethods::Generic |
40 | 39 |
( |
... | ... | |
45 | 44 |
__PACKAGE__->run_before('check_object_params', only => [ qw(list ajax_delete ajax_importdialog ajax_import ajax_unimport ajax_upload ajax_files_uploaded) ]); |
46 | 45 |
|
47 | 46 |
my %file_types = ( |
48 |
'sales_quotation' => { gen => 1 ,gltype => '', dir =>'SalesQuotation', model => 'Order', right => 'import_ar' },
|
|
49 |
'sales_order' => { gen => 1 ,gltype => '', dir =>'SalesOrder', model => 'Order', right => 'import_ar' },
|
|
50 |
'sales_delivery_order' => { gen => 1 ,gltype => '', dir =>'SalesDeliveryOrder', model => 'DeliveryOrder', right => 'import_ar' },
|
|
51 |
'invoice' => { gen => 1 ,gltype => 'ar', dir =>'SalesInvoice', model => 'Invoice', right => 'import_ar' },
|
|
52 |
'credit_note' => { gen => 1 ,gltype => '', dir =>'CreditNote', model => 'Invoice', right => 'import_ar' },
|
|
53 |
'request_quotation' => { gen => 3 ,gltype => '', dir =>'RequestForQuotation', model => 'Order', right => 'import_ap' },
|
|
54 |
'purchase_order' => { gen => 3 ,gltype => '', dir =>'PurchaseOrder', model => 'Order', right => 'import_ap' },
|
|
55 |
'purchase_delivery_order' => { gen => 3 ,gltype => '', dir =>'PurchaseDeliveryOrder',model => 'DeliveryOrder', right => 'import_ap' },
|
|
56 |
'purchase_invoice' => { gen => 2 ,gltype => 'ap', dir =>'PurchaseInvoice', model => 'PurchaseInvoice',right => 'import_ap' },
|
|
57 |
'vendor' => { gen => 0 ,gltype => '', dir =>'Vendor', model => 'Vendor', right => 'xx' },
|
|
58 |
'customer' => { gen => 1 ,gltype => '', dir =>'Customer', model => 'Customer', right => 'xx' },
|
|
59 |
'part' => { gen => 0 ,gltype => '', dir =>'Part', model => 'Part', right => 'xx' },
|
|
60 |
'gl_transaction' => { gen => 2 ,gltype => 'gl', dir =>'GeneralLedger', model => 'GLTransaction', right => 'import_ap' },
|
|
61 |
'draft' => { gen => 0 ,gltype => '', dir =>'Draft', model => 'Draft', right => 'xx' },
|
|
62 |
'csv_customer' => { gen => 1 ,gltype => '', dir =>'Reports', model => 'Customer', right => 'xx' },
|
|
63 |
'csv_vendor' => { gen => 1 ,gltype => '', dir =>'Reports', model => 'Vendor', right => 'xx' },
|
|
47 |
'sales_quotation' => { gen => 1, gltype => '', dir => 'SalesQuotation', model => 'Order', right => 'import_ar' },
|
|
48 |
'sales_order' => { gen => 1, gltype => '', dir => 'SalesOrder', model => 'Order', right => 'import_ar' },
|
|
49 |
'sales_delivery_order' => { gen => 1, gltype => '', dir => 'SalesDeliveryOrder', model => 'DeliveryOrder', right => 'import_ar' },
|
|
50 |
'invoice' => { gen => 1, gltype => 'ar', dir => 'SalesInvoice', model => 'Invoice', right => 'import_ar' },
|
|
51 |
'credit_note' => { gen => 1, gltype => '', dir => 'CreditNote', model => 'Invoice', right => 'import_ar' },
|
|
52 |
'request_quotation' => { gen => 3, gltype => '', dir => 'RequestForQuotation', model => 'Order', right => 'import_ap' },
|
|
53 |
'purchase_order' => { gen => 3, gltype => '', dir => 'PurchaseOrder', model => 'Order', right => 'import_ap' },
|
|
54 |
'purchase_delivery_order' => { gen => 3, gltype => '', dir => 'PurchaseDeliveryOrder', model => 'DeliveryOrder', right => 'import_ap' },
|
|
55 |
'purchase_invoice' => { gen => 2, gltype => 'ap', dir => 'PurchaseInvoice', model => 'PurchaseInvoice', right => 'import_ap' },
|
|
56 |
'vendor' => { gen => 0, gltype => '', dir => 'Vendor', model => 'Vendor', right => 'xx' },
|
|
57 |
'customer' => { gen => 1, gltype => '', dir => 'Customer', model => 'Customer', right => 'xx' },
|
|
58 |
'part' => { gen => 0, gltype => '', dir => 'Part', model => 'Part', right => 'xx' },
|
|
59 |
'gl_transaction' => { gen => 2, gltype => 'gl', dir => 'GeneralLedger', model => 'GLTransaction', right => 'import_ap' },
|
|
60 |
'draft' => { gen => 0, gltype => '', dir => 'Draft', model => 'Draft', right => 'xx' },
|
|
61 |
'csv_customer' => { gen => 1, gltype => '', dir => 'Reports', model => 'Customer', right => 'xx' },
|
|
62 |
'csv_vendor' => { gen => 1, gltype => '', dir => 'Reports', model => 'Vendor', right => 'xx' },
|
|
64 | 63 |
); |
65 | 64 |
|
66 | 65 |
#--- 4 locale ---# |
... | ... | |
73 | 72 |
sub action_list { |
74 | 73 |
my ($self) = @_; |
75 | 74 |
|
76 |
my $isjson = 0; |
|
77 |
$isjson = 1 if $::form->{json}; |
|
75 |
my $is_json = 0;
|
|
76 |
$is_json = 1 if $::form->{json};
|
|
78 | 77 |
|
79 |
$self->_do_list($isjson); |
|
78 |
$self->_do_list($is_json);
|
|
80 | 79 |
} |
81 | 80 |
|
82 | 81 |
sub action_ajax_importdialog { |
... | ... | |
105 | 104 |
my $ids = $::form->{ids}; |
106 | 105 |
my $source = $::form->{source}; |
107 | 106 |
my $path = $::form->{path}; |
108 |
my @files = $self->_get_from_import($path); |
|
107 |
my @files = $self->_get_from_import($path);
|
|
109 | 108 |
foreach my $filename (@{ $::form->{$ids} || [] }) { |
110 |
my ($file,undef) = grep { $_->{name} eq $filename } @files; |
|
109 |
my ($file, undef) = grep { $_->{name} eq $filename } @files;
|
|
111 | 110 |
if ( $file ) { |
112 |
my $obj = SL::File->save(object_id => $self->object_id,
|
|
113 |
object_type => $self->object_type,
|
|
114 |
mime_type => 'application/pdf',
|
|
115 |
source => $source,
|
|
116 |
file_type => 'document',
|
|
117 |
file_name => $file->{filename},
|
|
118 |
file_path => $file->{path}
|
|
111 |
my $obj = SL::File->save(object_id => $self->object_id, |
|
112 |
object_type => $self->object_type, |
|
113 |
mime_type => 'application/pdf', |
|
114 |
source => $source, |
|
115 |
file_type => 'document', |
|
116 |
file_name => $file->{filename}, |
|
117 |
file_path => $file->{path} |
|
119 | 118 |
); |
120 | 119 |
unlink($file->{path}) if $obj; |
121 | 120 |
} |
... | ... | |
125 | 124 |
|
126 | 125 |
sub action_ajax_delete { |
127 | 126 |
my ($self) = @_; |
128 |
$self->_delete_all(DO_DELETE,$::locale->text('Following files are deleted:')); |
|
127 |
$self->_delete_all(DO_DELETE, $::locale->text('Following files are deleted:'));
|
|
129 | 128 |
} |
130 | 129 |
|
131 | 130 |
sub action_ajax_unimport { |
132 | 131 |
my ($self) = @_; |
133 |
$self->_delete_all(DO_UNIMPORT,$::locale->text('Following files are unimported:')); |
|
132 |
$self->_delete_all(DO_UNIMPORT, $::locale->text('Following files are unimported:'));
|
|
134 | 133 |
} |
135 | 134 |
|
136 | 135 |
sub action_ajax_rename { |
137 | 136 |
my ($self) = @_; |
138 | 137 |
my $file = SL::File->get(id => $::form->{id}); |
139 | 138 |
if ( ! $file ) { |
140 |
$self->js->flash('error',$::locale->text('File not exists !'))->render(); |
|
139 |
$self->js->flash('error', $::locale->text('File not exists !'))->render();
|
|
141 | 140 |
return; |
142 | 141 |
} |
143 | 142 |
my $sessionfile = $::form->{sessionfile}; |
... | ... | |
146 | 145 |
if ( $::form->{to} eq $file->file_name ) { |
147 | 146 |
# no rename so use as new version |
148 | 147 |
$file->save_file($sessionfile); |
149 |
$self->js->flash('warning',$::locale->text('File \'#1\' is used as new Version !',$file->file_name));
|
|
148 |
$self->js->flash('warning', $::locale->text('File \'#1\' is used as new Version !', $file->file_name));
|
|
150 | 149 |
|
151 | 150 |
} else { |
152 |
# new filename so it is a new file with same attributes as old file
|
|
151 |
# new filename, so it is a new file with the same attributes as the old file
|
|
153 | 152 |
eval { |
154 |
SL::File->save(object_id => $file->object_id,
|
|
155 |
object_type => $file->object_type,
|
|
156 |
mime_type => $file->mime_type,
|
|
157 |
source => $file->source,
|
|
158 |
file_type => $file->file_type,
|
|
159 |
file_name => $::form->{to},
|
|
160 |
file_path => $sessionfile
|
|
153 |
SL::File->save(object_id => $file->object_id, |
|
154 |
object_type => $file->object_type, |
|
155 |
mime_type => $file->mime_type, |
|
156 |
source => $file->source, |
|
157 |
file_type => $file->file_type, |
|
158 |
file_name => $::form->{to}, |
|
159 |
file_path => $sessionfile |
|
161 | 160 |
); |
162 | 161 |
unlink($sessionfile); |
163 | 162 |
1; |
... | ... | |
170 | 169 |
|
171 | 170 |
} else { |
172 | 171 |
# normal rename |
173 |
my $res; |
|
172 |
my $result;
|
|
174 | 173 |
|
175 | 174 |
eval { |
176 |
$res = $file->rename($::form->{to}); |
|
175 |
$result = $file->rename($::form->{to});
|
|
177 | 176 |
1; |
178 | 177 |
} or do { |
179 | 178 |
$self->js->flash( 'error', t8('internal error (see details)')) |
... | ... | |
181 | 180 |
return; |
182 | 181 |
}; |
183 | 182 |
|
184 |
if ($res != SL::File::RENAME_OK) { |
|
183 |
if ($result != SL::File::RENAME_OK) {
|
|
185 | 184 |
$self->js->flash('error', |
186 |
$res == SL::File::RENAME_EXISTS ? $::locale->text('File still exists !') |
|
187 |
: $res == SL::File::RENAME_SAME ? $::locale->text('Same Filename !') |
|
188 |
: $::locale->text('File not exists !')) |
|
185 |
$result == SL::File::RENAME_EXISTS ? $::locale->text('File still exists !')
|
|
186 |
: $result == SL::File::RENAME_SAME ? $::locale->text('Same Filename !')
|
|
187 |
: $::locale->text('File not exists !'))
|
|
189 | 188 |
->render; |
190 | 189 |
return; |
191 | 190 |
} |
... | ... | |
209 | 208 |
$self->{accept_types} = ''; |
210 | 209 |
$self->{accept_types} = 'image/png,image/gif,image/jpeg,image/tiff,*png,*gif,*.jpg,*.tif' if $self->{file_type} eq 'image'; |
211 | 210 |
$self->render('file/upload_dialog', |
212 |
{ layout => 0
|
|
211 |
{ layout => 0 |
|
213 | 212 |
}, |
214 | 213 |
); |
215 | 214 |
} |
... | ... | |
224 | 223 |
foreach my $idx (0 .. scalar(@upfiles) - 1) { |
225 | 224 |
eval { |
226 | 225 |
my $fname = uri_unescape($upfiles[$idx]->{filename}); |
227 |
## normalize and find basename
|
|
226 |
# normalize and find basename |
|
228 | 227 |
# first split with unix rules |
229 | 228 |
# after that split with windows rules |
230 |
my ($volume,$directories,$basefile) = File::Spec::Unix->splitpath($fname);
|
|
231 |
($volume,$directories,$basefile) = File::Spec::Win32->splitpath($basefile);
|
|
229 |
my ($volume, $directories, $basefile) = File::Spec::Unix->splitpath($fname);
|
|
230 |
($volume, $directories, $basefile) = File::Spec::Win32->splitpath($basefile);
|
|
232 | 231 |
|
233 | 232 |
# to find real mime_type by magic we must save the filedata |
234 | 233 |
|
235 |
my $sess_fname = "file_upload_".$self->object_type."_".$self->object_id."_".$idx;
|
|
236 |
my $sfile = SL::SessionFile->new($sess_fname, mode => 'w'); |
|
234 |
my $sess_fname = "file_upload_" . $self->object_type . "_" . $self->object_id . "_" . $idx;
|
|
235 |
my $sfile = SL::SessionFile->new($sess_fname, mode => 'w');
|
|
237 | 236 |
|
238 | 237 |
$sfile->fh->print(${$upfiles[$idx]->{data}}); |
239 | 238 |
$sfile->fh->close; |
240 | 239 |
my $mime_type = File::MimeInfo::Magic::magic($sfile->file_name); |
241 | 240 |
|
242 | 241 |
if (! $mime_type) { |
243 |
# if filename has the suffix "pdf", but is really no pdf set mimetype for no suffix
|
|
242 |
# if filename has the suffix "pdf", but isn't really a pdf, set mimetype for no suffix
|
|
244 | 243 |
$mime_type = File::MimeInfo::Magic::mimetype($basefile); |
245 | 244 |
$mime_type = 'application/octet-stream' if $mime_type eq 'application/pdf' || !$mime_type; |
246 | 245 |
} |
247 | 246 |
if ( $self->file_type eq 'image' && $self->file_probe_image_type($mime_type, $basefile)) { |
248 | 247 |
next; |
249 | 248 |
} |
250 |
my ($existobj) = SL::File->get_all(object_id => $self->object_id,
|
|
251 |
object_type => $self->object_type,
|
|
252 |
mime_type => $mime_type,
|
|
253 |
source => $source,
|
|
254 |
file_type => $self->file_type,
|
|
255 |
file_name => $basefile,
|
|
256 |
); |
|
257 |
|
|
258 |
if ($existobj) { |
|
259 |
push @existing, $existobj->id.'_'.$sfile->file_name; |
|
260 |
} else { |
|
249 |
my ($existobj) = SL::File->get_all(object_id => $self->object_id, |
|
250 |
object_type => $self->object_type,
|
|
251 |
mime_type => $mime_type,
|
|
252 |
source => $source,
|
|
253 |
file_type => $self->file_type,
|
|
254 |
file_name => $basefile,
|
|
255 |
);
|
|
256 |
|
|
257 |
if ($existobj) {
|
|
258 |
push @existing, $existobj->id.'_'.$sfile->file_name;
|
|
259 |
} else {
|
|
261 | 260 |
my $fileobj = SL::File->save(object_id => $self->object_id, |
262 | 261 |
object_type => $self->object_type, |
263 | 262 |
mime_type => $mime_type, |
264 | 263 |
source => $source, |
265 | 264 |
file_type => $self->file_type, |
266 | 265 |
file_name => $basefile, |
267 |
## two possibilities: what is better ? content or sessionfile ??
|
|
266 |
## two possibilities: which is better ? content or sessionfile ??
|
|
268 | 267 |
#file_contents => ${$upfiles[$idx]->{data}}, |
269 | 268 |
file_path => $sfile->file_name |
270 | 269 |
); |
... | ... | |
284 | 283 |
|
285 | 284 |
sub action_download { |
286 | 285 |
my ($self) = @_; |
287 |
my ($id,$version) = split /_/, $::form->{id}; |
|
286 |
my ($id, $version) = split /_/, $::form->{id};
|
|
288 | 287 |
my $file = SL::File->get(id => $id ); |
289 | 288 |
$file->version($version) if $version; |
290 | 289 |
my $ref = $file->get_content; |
... | ... | |
303 | 302 |
sub check_object_params { |
304 | 303 |
my ($self) = @_; |
305 | 304 |
|
306 |
my $id = ($::form->{object_id} // 0) * 1; |
|
307 |
my $draftid = ($::form->{draft_id} // 0) * 1; |
|
308 |
my $gldoc = 0; |
|
309 |
my $type = undef; |
|
305 |
my $id = ($::form->{object_id} // 0) * 1;
|
|
306 |
my $draftid = ($::form->{draft_id} // 0) * 1;
|
|
307 |
my $gldoc = 0;
|
|
308 |
my $type = undef;
|
|
310 | 309 |
|
311 | 310 |
if ( $draftid == 0 && $id == 0 && $::form->{is_global} ) { |
312 | 311 |
$gldoc = 1; |
313 |
$type = $::form->{object_type}; |
|
312 |
$type = $::form->{object_type};
|
|
314 | 313 |
} |
315 | 314 |
elsif ( $id == 0 ) { |
316 |
$id = $::form->{draft_id}; |
|
315 |
$id = $::form->{draft_id};
|
|
317 | 316 |
$type = 'draft'; |
318 | 317 |
} elsif ( $::form->{object_type} ) { |
319 | 318 |
$type = $::form->{object_type}; |
320 | 319 |
} |
321 |
die "No object type" if ! $type;
|
|
322 |
die "No file type" if ! $::form->{file_type};
|
|
323 |
die "Unkown object type" if ! $file_types{$type};
|
|
320 |
die "No object type" unless $type;
|
|
321 |
die "No file type" unless $::form->{file_type};
|
|
322 |
die "Unkown object type" unless $file_types{$type};
|
|
324 | 323 |
|
325 | 324 |
$self->is_global($gldoc); |
326 | 325 |
$self->file_type($::form->{file_type}); |
... | ... | |
342 | 341 |
# |
343 | 342 |
|
344 | 343 |
sub _delete_all { |
345 |
my ($self,$do_unimport,$infotext) = @_;
|
|
344 |
my ($self, $do_unimport, $infotext) = @_;
|
|
346 | 345 |
my $files = ''; |
347 | 346 |
my $ids = $::form->{ids}; |
348 | 347 |
foreach my $id_version (@{ $::form->{$ids} || [] }) { |
349 |
my ($id,$version) = split /_/, $id_version; |
|
348 |
my ($id, $version) = split /_/, $id_version;
|
|
350 | 349 |
my $dbfile = SL::File->get(id => $id); |
351 | 350 |
$dbfile->version($version) if $dbfile && $version; |
352 | 351 |
if ( $dbfile && $dbfile->delete ) { |
353 |
$files .= ' '.$dbfile->file_name;
|
|
352 |
$files .= ' ' . $dbfile->file_name;
|
|
354 | 353 |
} |
355 | 354 |
} |
356 |
$self->js->flash('info',$infotext.$files) if $files;
|
|
355 |
$self->js->flash('info', $infotext . $files) if $files;
|
|
357 | 356 |
$self->_do_list(1); |
358 | 357 |
} |
359 | 358 |
|
360 | 359 |
sub _do_list { |
361 |
my ($self,$json) = @_; |
|
360 |
my ($self, $json) = @_;
|
|
362 | 361 |
my @files; |
363 | 362 |
if ( $self->file_type eq 'document' ) { |
364 | 363 |
my @object_types; |
365 | 364 |
push @object_types, $self->object_type; |
366 |
push @object_types, ('dunning','dunning1','dunning2','dunning3') if $self->object_type eq 'invoice'; |
|
367 |
@files = SL::File->get_all_versions(object_id => $self->object_id , |
|
368 |
object_type => \@object_types, |
|
369 |
file_type => $self->file_type ); |
|
365 |
push @object_types, qw(dunning dunning1 dunning2 dunning3) if $self->object_type eq 'invoice'; # hardcoded object types? |
|
366 |
@files = SL::File->get_all_versions(object_id => $self->object_id, |
|
367 |
object_type => \@object_types, |
|
368 |
file_type => $self->file_type, |
|
369 |
); |
|
370 | 370 |
|
371 | 371 |
} |
372 |
elsif ( $self->file_type eq 'attachment' || $self->file_type eq 'image' ) {
|
|
373 |
@files = SL::File->get_all(object_id => $self->object_id ,
|
|
372 |
elsif ( $self->file_type eq 'attachment' || $self->file_type eq 'image' ) { |
|
373 |
@files = SL::File->get_all(object_id => $self->object_id, |
|
374 | 374 |
object_type => $self->object_type, |
375 |
file_type => $self->file_type ); |
|
375 |
file_type => $self->file_type, |
|
376 |
); |
|
376 | 377 |
} |
377 | 378 |
$self->files(\@files); |
378 |
$self->_mk_render('file/list',1,0,$json);
|
|
379 |
$self->_mk_render('file/list', 1, 0, $json);
|
|
379 | 380 |
} |
380 | 381 |
|
381 | 382 |
sub _get_from_import { |
382 |
my ($self,$path) = @_; |
|
383 |
my ($self, $path) = @_;
|
|
383 | 384 |
my @foundfiles ; |
384 | 385 |
|
385 | 386 |
my $language = $::lx_office_conf{system}->{language}; |
... | ... | |
390 | 391 |
next if (($file eq '.') || ($file eq '..')); |
391 | 392 |
$file = Encode::decode('utf-8', $file); |
392 | 393 |
|
393 |
next if( -d "$path/$file");
|
|
394 |
next if ( -d "$path/$file" );
|
|
394 | 395 |
|
395 | 396 |
my $tmppath = File::Spec->catfile( $path, $file ); |
396 |
next if( ! -f $tmppath); |
|
397 |
next if( ! -f $tmppath );
|
|
397 | 398 |
|
398 | 399 |
my $st = stat($tmppath); |
399 |
my $dt = DateTime->from_epoch( epoch => $st->mtime, time_zone => $timezone, locale => $language); |
|
400 |
my $sname = $main::locale->quote_special_chars('HTML',$file); |
|
401 |
push @foundfiles , {
|
|
400 |
my $dt = DateTime->from_epoch( epoch => $st->mtime, time_zone => $timezone, locale => $language );
|
|
401 |
my $sname = $main::locale->quote_special_chars('HTML', $file);
|
|
402 |
push @foundfiles, { |
|
402 | 403 |
'name' => $file, |
403 | 404 |
'filename' => $sname, |
404 | 405 |
'path' => $tmppath, |
405 | 406 |
'mtime' => $st->mtime, |
406 |
'date' => $dt->dmy('.')." ".$dt->hms,
|
|
407 |
'date' => $dt->dmy('.') . " " . $dt->hms,
|
|
407 | 408 |
}; |
408 | 409 |
|
409 | 410 |
} |
... | ... | |
412 | 413 |
} |
413 | 414 |
|
414 | 415 |
sub _mk_render { |
415 |
my ($self,$template,$edit,$scanner,$json) = @_;
|
|
416 |
my ($self, $template, $edit, $scanner, $json) = @_;
|
|
416 | 417 |
my $err; |
417 | 418 |
eval { |
418 |
##TODO here a configurable code must be implemented
|
|
419 |
##TODO make code configurable
|
|
419 | 420 |
|
420 | 421 |
my $title; |
421 | 422 |
my @sources = $self->_get_sources(); |
... | ... | |
432 | 433 |
|
433 | 434 |
my $output = SL::Presenter->get->render( |
434 | 435 |
$template, |
435 |
title => $title,
|
|
436 |
SOURCES => \@sources,
|
|
437 |
edit_attachments => $edit,
|
|
438 |
object_type => $self->object_type,
|
|
439 |
object_id => $self->object_id,
|
|
440 |
file_type => $self->file_type,
|
|
441 |
is_global => $self->is_global,
|
|
442 |
json => $json,
|
|
436 |
title => $title, |
|
437 |
SOURCES => \@sources, |
|
438 |
edit_attachments => $edit, |
|
439 |
object_type => $self->object_type, |
|
440 |
object_id => $self->object_id, |
|
441 |
file_type => $self->file_type, |
|
442 |
is_global => $self->is_global, |
|
443 |
json => $json, |
|
443 | 444 |
); |
444 | 445 |
if ( $json ) { |
445 | 446 |
$self->js->html('#'.$self->file_type.'_list_'.$self->object_type, $output); |
446 | 447 |
if ( $self->existing && scalar(@{$self->existing}) > 0) { |
447 | 448 |
my $first = shift @{$self->existing}; |
448 |
my ($first_id,$sfile) = split('_',$first,2);
|
|
449 |
my ($first_id, $sfile) = split('_', $first, 2);
|
|
449 | 450 |
my $file = SL::File->get(id => $first_id ); |
450 |
$self->js->run('kivi.File.askForRename',$first_id,$file->file_name,$sfile,join (',', @{$self->existing}), $self->is_global);
|
|
451 |
$self->js->run('kivi.File.askForRename', $first_id, $file->file_name, $sfile, join (',', @{$self->existing}), $self->is_global);
|
|
451 | 452 |
} |
452 | 453 |
$self->js->render(); |
453 | 454 |
} else { |
... | ... | |
469 | 470 |
my ($self) = @_; |
470 | 471 |
my @sources; |
471 | 472 |
if ( $self->file_type eq 'document' ) { |
472 |
##TODO statt gen neue attribute in filetypes :
|
|
473 |
# TODO statt gen neue attribute in filetypes :
|
|
473 | 474 |
if (($file_types{$self->object_type}->{gen}*1 & 1)==1) { |
474 | 475 |
my $gendata = { |
475 | 476 |
'name' => 'created', |
... | ... | |
490 | 491 |
foreach my $scanner_or_mailrx (@others) { |
491 | 492 |
my $other = { |
492 | 493 |
'name' => $scanner_or_mailrx->{name}, |
493 |
'title' => $main::locale->text('from \'#1\' imported Files',$scanner_or_mailrx->{description}), |
|
494 |
'title' => $main::locale->text('from \'#1\' imported Files', $scanner_or_mailrx->{description}),
|
|
494 | 495 |
'chk_action' => $scanner_or_mailrx->{name}.'_unimport', |
495 | 496 |
'chk_title' => $main::locale->text('Unimport documents'), |
496 | 497 |
'chkall_title' => $main::locale->text('Unimport all'), |
... | ... | |
499 | 500 |
'can_rename' => 1, |
500 | 501 |
'rename_title' => $main::locale->text('Rename Documents'), |
501 | 502 |
'can_import' => 1, |
502 |
'import_title' => $main::locale->text('Add Document from \'#1\'',$scanner_or_mailrx->{name}), |
|
503 |
'import_title' => $main::locale->text('Add Document from \'#1\'', $scanner_or_mailrx->{name}),
|
|
503 | 504 |
'path' => $scanner_or_mailrx->{directory}, |
504 | 505 |
'done_text' => $main::locale->text('unimported') |
505 | 506 |
}; |
... | ... | |
558 | 559 |
|
559 | 560 |
SL::Controller::File - Controller for managing files |
560 | 561 |
|
561 |
|
|
562 | 562 |
=head1 SYNOPSIS |
563 | 563 |
|
564 |
=begin text |
|
565 |
|
|
566 |
# The Controller is called direct from the webpages |
|
567 |
|
|
564 |
The Controller is called directly from the webpages |
|
568 | 565 |
|
569 | 566 |
<a href="controller.pl?action=File/list&file_type=document\ |
570 | 567 |
&object_type=[% HTML.escape(type) %]&object_id=[% HTML.url(id) %]"> |
571 | 568 |
|
572 | 569 |
|
573 |
# or indirect via javascript functions from js/kivi.File.js |
|
574 |
|
|
570 |
or indirectly via javascript functions from js/kivi.File.js |
|
575 | 571 |
|
576 | 572 |
kivi.popup_dialog({ url: 'controller.pl', |
577 | 573 |
data: { action : 'File/ajax_upload', |
... | ... | |
581 | 577 |
} |
582 | 578 |
... |
583 | 579 |
|
584 |
=end text |
|
585 |
|
|
586 |
|
|
587 | 580 |
=head1 DESCRIPTION |
588 | 581 |
|
589 | 582 |
This is a controller for handling files in a storage independent way. |
... | ... | |
735 | 728 |
|
736 | 729 |
=item C<form.ids> |
737 | 730 |
|
738 |
The ids of the files to unimport. Only this files are unimported not all versions of a file if the exists
|
|
731 |
The ids of the files to unimport. Only these files are unimported not all versions of a file if the exists
|
|
739 | 732 |
|
740 | 733 |
=back |
741 | 734 |
|
... | ... | |
743 | 736 |
|
744 | 737 |
One file can be renamed. There can be some checks if the same filename still exists at one object. |
745 | 738 |
|
746 |
|
|
747 | 739 |
=head1 AUTHOR |
748 | 740 |
|
749 | 741 |
Martin Helmling E<lt>martin.helmling@opendynamic.deE<gt> |
Auch abrufbar als: Unified diff
SL/Controller/File.pm - Codeausrichtung und Stilverbesserungen