Permalink
Browse files

[p5w] implemented edit conflict prevention

Now you can only save pages that have not been saved since you started editing.
  • Loading branch information...
1 parent a5ac122 commit d732120520ae2c736bad7155a9e7e0330e24c774 @masak masak committed Mar 31, 2009
Showing with 55 additions and 0 deletions.
  1. +16 −0 p5w/November.pm
  2. +39 −0 p5w/skins/CleanAndSoft/page_too_old.tmpl
View
16 p5w/November.pm
@@ -550,6 +550,22 @@ sub edit_page {
# page source?
if ( my $article_text = $cgi->param('articletext') ) {
+ # Check if the page has been saved since editing begun, and pull the
+ # brakes if it has.
+ if ( $cgi->param('old-revision') < latest_revision($page) ) {
+ my $template = HTML::Template->new(
+ filename => $TEMPLATE_PATH.'page_too_old.tmpl');
+
+ $template->param(PAGE => $page);
+ $template->param(TITLE => pp($page));
+ $template->param(LOGGED_IN => logged_in($cgi));
+
+ print status_ok(),
+ $template->output();
+
+ return;
+ }
+
my $session_id = $cgi->cookie('session_id');
my $author = $sessions{$session_id}{user_name};
my $tags = $cgi->param('tags');
View
39 p5w/skins/CleanAndSoft/page_too_old.tmpl
@@ -0,0 +1,39 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+ <head>
+ <title>Unknown action</title>
+ <link rel="stylesheet" type="text/css" href="main.css" />
+ </head>
+ <body>
+ <div id="page">
+ <div id="headerimg">
+ <TMPL_INCLUDE NAME="toolbar.tmpl">
+ </div>
+ <div id="pagebar">&nbsp;</div>
+ <div id="content">
+ <h1>Page too old</h1>
+ Someone hit the save button on '<TMPL_VAR NAME=TITLE>' before
+ you did.
+ </div>
+ <div id="sidebar">
+ <ul>
+ <li><h2>Navigation</h2>
+ <ul>
+ <li><a href='/'>Main Page</a></li>
+ <li><a href='/?page=About'>About this site</a></li>
+ <li><a href='/?action=recent_changes'>Recent Changes</a></li>
+ </ul>
+ </li>
+ </ul>
+ </div>
+
+
+<div id="footer">
+ <p>
+ November. Powered by Rakudo Perl 6.
+ </p>
+</div>
+
+ </div>
+ </body>
+</html>

0 comments on commit d732120

Please sign in to comment.