Lines 46-55
sub plugin_javascript {
Link Here
|
46 |
|
46 |
|
47 |
function Clic$function_name(index) { |
47 |
function Clic$function_name(index) { |
48 |
var id = document.getElementById(index).value; |
48 |
var id = document.getElementById(index).value; |
|
|
49 |
var IsFileUploadUrl=0; |
50 |
if (id.match(/opac-retrieve-file/)) { |
51 |
IsFileUploadUrl=1; |
52 |
} |
49 |
if(id.match(/id=([0-9a-f]+)/)){ |
53 |
if(id.match(/id=([0-9a-f]+)/)){ |
50 |
id = RegExp.\$1; |
54 |
id = RegExp.\$1; |
51 |
} |
55 |
} |
52 |
window.open(\"../cataloguing/plugin_launcher.pl?plugin_name=upload.pl&index=\"+index+\"&id=\"+id, 'upload', 'width=600,height=400,toolbar=false,scrollbars=no'); |
56 |
var newin=window.open(\"../cataloguing/plugin_launcher.pl?plugin_name=upload.pl&index=\"+index+\"&id=\"+id+\"&from_popup=0\"+\"&IsFileUploadUrl=\"+IsFileUploadUrl, 'upload', 'width=600,height=400,toolbar=false,scrollbars=no'); |
|
|
57 |
newin.focus(); |
53 |
|
58 |
|
54 |
} |
59 |
} |
55 |
</script> |
60 |
</script> |
Lines 64-73
sub plugin {
Link Here
|
64 |
my $id = $input->param('id'); |
69 |
my $id = $input->param('id'); |
65 |
my $delete = $input->param('delete'); |
70 |
my $delete = $input->param('delete'); |
66 |
my $uploaded_file = $input->param('uploaded_file'); |
71 |
my $uploaded_file = $input->param('uploaded_file'); |
67 |
|
72 |
my $from_popup = $input->param('from_popup'); |
68 |
my $template_name = ($id || $delete) |
73 |
my $isfileuploadurl = $input->param('IsFileUploadUrl'); |
69 |
? "upload_delete_file.tt" |
74 |
my $dangling = C4::UploadedFiles::DanglingEntry($id,$isfileuploadurl); |
70 |
: "upload.tt"; |
75 |
my $template_name; |
|
|
76 |
if ($delete || ($id && ($dangling==0 || $dangling==1))) { |
77 |
$template_name = "upload_delete_file.tt"; |
78 |
} |
79 |
else { |
80 |
$template_name = "upload.tt"; |
81 |
} |
71 |
|
82 |
|
72 |
my ( $template, $loggedinuser, $cookie ) = get_template_and_user( |
83 |
my ( $template, $loggedinuser, $cookie ) = get_template_and_user( |
73 |
{ template_name => "cataloguing/value_builder/$template_name", |
84 |
{ template_name => "cataloguing/value_builder/$template_name", |
Lines 79-84
sub plugin {
Link Here
|
79 |
} |
90 |
} |
80 |
); |
91 |
); |
81 |
|
92 |
|
|
|
93 |
if ($dangling==2) { |
94 |
$template->param( dangling => 1 ); |
95 |
} |
96 |
|
82 |
# Dealing with the uploaded file |
97 |
# Dealing with the uploaded file |
83 |
my $dir = $input->param('dir'); |
98 |
my $dir = $input->param('dir'); |
84 |
if ($uploaded_file and $dir) { |
99 |
if ($uploaded_file and $dir) { |
Lines 97-110
sub plugin {
Link Here
|
97 |
} else { |
112 |
} else { |
98 |
$template->param(error => 1); |
113 |
$template->param(error => 1); |
99 |
} |
114 |
} |
100 |
} elsif ($delete || $id) { |
115 |
} elsif ($delete || ($id && ($dangling==0 || $dangling==1))) { |
101 |
# If there's already a file uploaded for this field, |
116 |
# If there's already a file uploaded for this field, |
102 |
# We handle its deletion |
117 |
# We handle its deletion |
103 |
if ($delete) { |
118 |
if ($delete) { |
104 |
if(C4::UploadedFiles::DelUploadedFile($id)) {; |
119 |
if(C4::UploadedFiles::DelUploadedFile($id)==0) {; |
105 |
$template->param(success => 1); |
|
|
106 |
} else { |
107 |
$template->param(error => 1); |
120 |
$template->param(error => 1); |
|
|
121 |
} else { |
122 |
$template->param(success => 1); |
108 |
} |
123 |
} |
109 |
} |
124 |
} |
110 |
} else { |
125 |
} else { |
Lines 129-142
sub plugin {
Link Here
|
129 |
$template->param( error_upload_path_not_configured => 1 ); |
144 |
$template->param( error_upload_path_not_configured => 1 ); |
130 |
} |
145 |
} |
131 |
|
146 |
|
|
|
147 |
if (!$uploaded_file && !$dir && $from_popup) { |
148 |
$template->param(error_nothing_selected => 1); |
149 |
} |
150 |
elsif (!$uploaded_file && $dir) { |
151 |
$template->param(error_no_file_selected => 1); |
152 |
} |
132 |
if ($uploaded_file and not $dir) { |
153 |
if ($uploaded_file and not $dir) { |
133 |
$template->param(error_no_dir_selected => 1); |
154 |
$template->param(error_no_dir_selected => 1); |
134 |
} |
155 |
} |
|
|
156 |
|
135 |
} |
157 |
} |
136 |
|
158 |
|
137 |
$template->param( |
159 |
$template->param( |
138 |
index => $index, |
160 |
index => $index, |
139 |
id => $id |
161 |
id => $id, |
140 |
); |
162 |
); |
141 |
|
163 |
|
142 |
output_html_with_http_headers $input, $cookie, $template->output; |
164 |
output_html_with_http_headers $input, $cookie, $template->output; |