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