Line # Revision Author
1 3 ahitrov@rambler.ru %#<pre><% Dumper(\%ARGS) %></pre>
2 <%args>
3
4 $class => undef
5 $source_id => undef
6 $source_class => undef
7 $dest_id => undef
8 $dest_class => undef
9 $sources => undef
10 $destinations => undef
11
12 </%args>
13 <%init>
14
15 abort404 unless $class;
16
17 warn Dumper(\%ARGS);
18
19 my @documents;
20 my $ret_params;
21 if ( $source_id && $source_class ) {
22 my %links;
23 while ( my ($field, $value) = each %ARGS ) {
24 if ( $field =~ /dest_id_(\d+)/ ) {
25 $links{$1}{id} = $value;
26 } elsif ( $field =~ /dest_class_(\d+)/ ) {
27 $links{$1}{class} = $value;
28 }
29 }
30 warn Dumper (\%links);
31 foreach my $doc ( values %links ) {
32 my $link = $class->new ($keeper);
33 $link->source_id ($source_id);
34 $link->source_class ($source_class);
35 $link->dest_id ($doc->{id});
36 $link->dest_class ($doc->{class});
37 $link->status(1);
38 $link->store;
39 }
40 $ret_params = "id=$source_id&class=$source_class";
41 } elsif ( $dest_id && $dest_class ) {
42 my %links;
43 while ( my ($field, $value) = each %ARGS ) {
44 if ( $field =~ /source_id_(\d+)/ ) {
45 $links{$1}{id} = $value;
46 } elsif ( $field =~ /source_class_(\d+)/ ) {
47 $links{$1}{class} = $value;
48 }
49 }
50 foreach my $doc ( values %links ) {
51 my $link = $class->new ($keeper);
52 $link->dest_id ($dest_id);
53 $link->dest_class ($dest_class);
54 $link->source_id ($doc->{id});
55 $link->source_class ($doc->{class});
56 $link->status(1);
57 $link->store;
58 }
59 $ret_params = "id=$dest_id&class=$dest_class";
60 }
61 if ($ret_params) {
62 $r->header_out("Location", "/contenido/document.html?".$ret_params);
63 $r->status(302);
64 $r->send_http_header();
65 $m->abort();
66 }else{
67 abort404;
68 }
69
70 </%init>