[Affelio-cvs 1111] CVS update: affelio/apps/diary/Diary

Back to archive index

Yoshihisa Fukuhara higef****@users*****
2006年 3月 3日 (金) 20:19:58 JST


Index: affelio/apps/diary/Diary/WriteDiary.pm
diff -u affelio/apps/diary/Diary/WriteDiary.pm:1.5 affelio/apps/diary/Diary/WriteDiary.pm:1.6
--- affelio/apps/diary/Diary/WriteDiary.pm:1.5	Fri Mar  3 12:54:53 2006
+++ affelio/apps/diary/Diary/WriteDiary.pm	Fri Mar  3 20:19:58 2006
@@ -58,6 +58,7 @@
 
 	my $wi = new Affelio::misc::WebInput();
 	my $sub_mode = $wi->PTN_mode($cgi->param("action"));
+	my $delete = $cgi->param("delete");
 	my $title = $diary->escape($cgi->param("title"));
 	my $contents = $diary->escape($cgi->param("contents"));
 	my $category = $wi->PTN_num($cgi->param("category"));
@@ -77,6 +78,7 @@
 		copyFiles($diary,$id);
 		$output_ref->{tmpl_file} = $diary->{afap}->{app__fs_root}."/templates/write_diary_edit.tmpl";
 		my $entry = getEntry($diary,$id);
+		$output_ref->{"EDIT"} = '1';
 		$output_ref->{"ID"} = $id;
 		$output_ref->{"TITLE"} = $entry->{"title"};
 		$output_ref->{"CONTENTS"} = $diary->br2n($entry->{"contents"});
@@ -95,16 +97,32 @@
 		}
 
 	    }elsif( $sub_mode eq "update" && ($id) ){
-		# update entry
-		debug_print("Diary::Write::show: before update entry");
-		updateEntry($diary,$id,$title,$contents,$category);
-		copyUploadImage($diary, $id);
-		# send trackback ping
-		debug_print("Diary::Write::show: ping");
-		if ($tping) {
-		    sendTrackbackPing($diary, $tping, $title, $contents, $id);
+		if ($delete){
+		    # delete entry
+		    debug_print("Diary::Write::show: before delete entry");
+		    $diary->{dbh}->do("DELETE FROM $diary->{entry_table} WHERE id = $id");
+		    $diary->{dbh}->do("DELETE FROM $diary->{comment_table} WHERE id = $id");
+		    $diary->{dbh}->do("DELETE FROM $diary->{tb_table} WHERE id = $id");
+		    if (-f $diary->{datadir}."$id.stor") {
+			unlink $diary->{datadir}."$id.stor";
+		    }
+		    removeUploadedImage($diary,$id);
+
+		    $output_ref->{tmpl_file} = $diary->{afap}->{app__fs_root}."/templates/write_diary_done.tmpl";
+		    $output_ref->{"DELETE"}='1';
+		    debug_print("Diary::Write::show: after delete entry");
+		}else{
+		    # update entry
+		    debug_print("Diary::Write::show: before update entry");
+		    updateEntry($diary,$id,$title,$contents,$category);
+		    copyUploadImage($diary, $id);
+		    # send trackback ping
+		    debug_print("Diary::Write::show: ping");
+		    if ($tping) {
+			sendTrackbackPing($diary, $tping, $title, $contents, $id);
+		    }
+		    $output_ref->{tmpl_file} = $diary->{afap}->{app__fs_root}."/templates/write_diary_done.tmpl";
 		}
-		$output_ref->{tmpl_file} = $diary->{afap}->{app__fs_root}."/templates/write_diary_done.tmpl";
 	    }
 	    elsif( $sub_mode eq "submit" ){
 		# add entry


Affelio-cvs メーリングリストの案内
Back to archive index