interchange - racke modified 3 files

[email protected]
Newsgroups gmane.comp.web.interchange.cvs
Message-ID <[email protected]>
User:      racke
Date:      2009-05-20 09:39:19 GMT
Modified:  .        WHATSNEW-5.7
Modified:  code/Widget uploadhelper.widget
Modified:  dist/lib/UI/profiles process_filter
Log:
Allow file removal with uploadhelper widget (#180).

Revision  Changes    Path
2.43                 interchange/WHATSNEW-5.7


rev 2.43, prev_rev 2.42
Index: WHATSNEW-5.7
===================================================================
RCS file: /var/cvs/interchange/WHATSNEW-5.7,v
retrieving revision 2.42
retrieving revision 2.43
diff -u -r2.42 -r2.43
--- WHATSNEW-5.7	20 May 2009 02:40:11 -0000	2.42
+++ WHATSNEW-5.7	20 May 2009 09:39:19 -0000	2.43
@@ -160,6 +160,11 @@
 
 * Allow custom error messages for email_only check.
 
+Admin UI
+--------
+
+* Allow file removal with uploadhelper widget (#180).
+
 Standard demo
 -------------
 



1.7                  interchange/code/Widget/uploadhelper.widget


rev 1.7, prev_rev 1.6
Index: uploadhelper.widget
===================================================================
RCS file: /var/cvs/interchange/code/Widget/uploadhelper.widget,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- uploadhelper.widget	17 Jul 2008 14:37:09 -0000	1.6
+++ uploadhelper.widget	20 May 2009 09:39:19 -0000	1.7
@@ -5,7 +5,7 @@
 # the Free Software Foundation; either version 2 of the License, or
 # (at your option) any later version.  See the LICENSE file for details.
 # 
-# $Id: uploadhelper.widget,v 1.6 2008-07-17 14:37:09 racke Exp $
+# $Id: uploadhelper.widget,v 1.7 2009-05-20 09:39:19 racke Exp $
 
 CodeDef uploadhelper  Widget  1
 CodeDef uploadhelper  Description File upload
@@ -30,7 +30,11 @@
 			$out .= qq{<A HREF="$view_url">};
 		}
 		$out .= $val;
-		$out .= "</A>" if $path;
+		if ($path) {
+			$out .= "</A>";
+			$out .= qq{<input type="checkbox" name="ui_upload_file_delete:$name" value="1">};
+			$out .= errmsg('Delete');
+		}
 		$out .= qq{&nbsp;<INPUT TYPE=file NAME="$name" VALUE="$val">
 <INPUT TYPE=hidden NAME="ui_upload_file_path:$name" VALUE="$path">
 <INPUT TYPE=hidden NAME="$name" VALUE="$val">};      



2.4                  interchange/dist/lib/UI/profiles/process_filter


rev 2.4, prev_rev 2.3
Index: process_filter
===================================================================
RCS file: /var/cvs/interchange/dist/lib/UI/profiles/process_filter,v
retrieving revision 2.3
retrieving revision 2.4
diff -u -r2.3 -r2.4
--- process_filter	14 Jan 2003 02:25:53 -0000	2.3
+++ process_filter	20 May 2009 09:39:19 -0000	2.4
@@ -1,7 +1,7 @@
 __NAME__ process_filter
 [flag type=write table="[cgi mv_data_table]"]
 [perl tables="[list-databases]"]
-# $Id: process_filter,v 2.3 2003-01-14 02:25:53 mheins Exp $
+# $Id: process_filter,v 2.4 2009-05-20 09:39:19 racke Exp $
 	my @filters = grep /^ui_filter:/, keys %$CGI;
   FILTERS: {
 	last FILTERS unless @filters;
@@ -71,6 +71,20 @@
 		next unless defined $CGI->{$key};
 		$CGI->{$key} =~ s/\0(.*)//s;
 		my $old = $1;
+		if ($CGI->{"ui_upload_file_delete:$key"}) {
+			if ($Tag->if_mm({function => 'files', name => "$path/$old",
+					body => 1})) {
+				unless ($Tag->unlink_file("$path/$old", $path)) {
+					$Tag->error({name => "$path/$old",
+						set => 'Failed to delete file'});
+				}
+			} 
+			else {
+				$Tag->error({name => "$path/$old",
+					set => 'Not allowed to delete file'});
+			}
+			$old = '';
+		}
 		unless($CGI->{$key}) {
 			$CGI->{$key} = $old; 
 			next;
@@ -84,6 +98,7 @@
 		$fn =~ s,.*\\,,;
 		$fn = $Tag->filter('filesafe', $fn);
 #Debug("cgi->$key now='$CGI->{$key}'");
+		$CGI->{$key} = $fn;
 		my $out = "$path/$fn";
 		unless ($Tag->value_extended( { name => $key, outfile => $out , yes => 1} ) ) {
 			$Scratch->{ui_failure} .= "\nFailed to write upload file $out";
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.