# HG changeset patch # User Dan # Date 1202742333 18000 # Node ID 7ecbe721217ca29279233ffb53878997a348e421 # Parent 35d94240a197d3e699e4a78479a16d79ae88a615 Modified editor and rename functions to go through the API when rolling back. This causes rollbacks to be logged. diff -r 35d94240a197 -r 7ecbe721217c ajax.php --- a/ajax.php Sun Feb 10 19:35:06 2008 -0500 +++ b/ajax.php Mon Feb 11 10:05:33 2008 -0500 @@ -98,7 +98,8 @@ case "getsource": header('Content-type: application/json'); $password = ( isset($_GET['pagepass']) ) ? $_GET['pagepass'] : false; - $page = new PageProcessor($paths->page_id, $paths->namespace); + $revid = ( isset($_GET['revid']) ) ? intval($_GET['revid']) : 0; + $page = new PageProcessor($paths->page_id, $paths->namespace, $revid); $page->password = $password; if ( $src = $page->fetch_source() ) { @@ -125,9 +126,39 @@ 'auth_edit' => $auth_edit, 'time' => time(), 'require_captcha' => false, - 'allow_wysiwyg' => $auth_wysiwyg + 'allow_wysiwyg' => $auth_wysiwyg, + 'revid' => $revid ); + if ( $revid > 0 ) + { + // Retrieve information about this revision and the current one + $q = $db->sql_query('SELECT l1.author AS currentrev_author, l2.author AS oldrev_author FROM ' . table_prefix . 'logs AS l1 + LEFT JOIN ' . table_prefix . 'logs AS l2 + ON ( l2.time_id = ' . $revid . ' + AND l2.log_type = \'page\' + AND l2.action = \'edit\' + AND l2.page_id = \'ACL_Tests\' + AND l2.namespace = \'Article\' + ) + WHERE l1.log_type = \'page\' + AND l1.action = \'edit\' + AND l1.page_id = \'ACL_Tests\' + AND l1.namespace = \'Article\' + AND l1.time_id >= ' . $revid . ' + ORDER BY l1.time_id DESC;'); + if ( !$q ) + $db->die_json(); + + $rev_count = $db->numrows() - 1; + $row = $db->fetchrow(); + $return['undo_info'] = array( + 'old_author' => $row['oldrev_author'], + 'current_author' => $row['currentrev_author'], + 'undo_count' => $rev_count + ); + } + if ( $auth_edit && !$session->user_logged_in && getConfig('guest_edit_require_captcha') == '1' ) { $return['require_captcha'] = true; diff -r 35d94240a197 -r 7ecbe721217c includes/clientside/static/editor.js --- a/includes/clientside/static/editor.js Sun Feb 10 19:35:06 2008 -0500 +++ b/includes/clientside/static/editor.js Mon Feb 11 10:05:33 2008 -0500 @@ -43,16 +43,17 @@ var editor_open = false; -function ajaxEditor() +function ajaxEditor(revid) { if ( KILL_SWITCH ) return true; if ( editor_open ) return true; + var rev_id_uri = ( revid ) ? '&revid=' + revid : ''; selectButtonMinor('edit'); selectButtonMajor('article'); setAjaxLoading(); - ajaxGet(stdAjaxPrefix + '&_mode=getsource', function() + ajaxGet(stdAjaxPrefix + '&_mode=getsource' + rev_id_uri, function() { if ( ajax.readyState == 4 && ajax.status == 200 ) { @@ -83,12 +84,12 @@ // do we need to enter a captcha before saving the page? var captcha_hash = ( response.require_captcha ) ? response.captcha_id : false; - ajaxBuildEditor(response.src, (!response.auth_edit), response.time, response.allow_wysiwyg, captcha_hash); + ajaxBuildEditor(response.src, (!response.auth_edit), response.time, response.allow_wysiwyg, captcha_hash, response.revid, response.undo_info); } }); } -function ajaxBuildEditor(content, readonly, timestamp, allow_wysiwyg, captcha_hash) +function ajaxBuildEditor(content, readonly, timestamp, allow_wysiwyg, captcha_hash, revid, undo_info) { // Set flags // We don't want the fancy confirmation framework to trigger if the user is only viewing the page source @@ -173,6 +174,15 @@ return false; } + // Old-revision notice + if ( revid > 0 ) + { + var oldrev_box = document.createElement('div'); + oldrev_box.className = 'usermessage'; + oldrev_box.appendChild(document.createTextNode($lang.get('editor_msg_editing_old_revision'))); + form.appendChild(oldrev_box); + } + // Preview holder var preview_anchor = document.createElement('a'); preview_anchor.name = 'ajax_preview'; @@ -244,6 +254,13 @@ field_es.type = 'text'; field_es.size = '40'; field_es.style.width = '96%'; + + if ( revid > 0 ) + { + undo_info.last_rev_id = revid; + field_es.value = $lang.get('editor_reversion_edit_summary', undo_info); + } + td1_2.appendChild(field_es); tr1.appendChild(td1_1); diff -r 35d94240a197 -r 7ecbe721217c includes/pageutils.php --- a/includes/pageutils.php Sun Feb 10 19:35:06 2008 -0500 +++ b/includes/pageutils.php Mon Feb 11 10:05:33 2008 -0500 @@ -433,7 +433,7 @@ // Actions! echo '