# HG changeset patch # User Dan # Date 1182960542 14400 # Node ID dd2edcdc6c03b143fa9743fa55088e39fec37728 # Parent dd659f6ba8915dd48c3a33b4ab78634ba7ffa81c Deleting pages now requires a reason diff -r dd659f6ba891 -r dd2edcdc6c03 ajax.php --- a/ajax.php Wed Jun 27 00:59:42 2007 -0400 +++ b/ajax.php Wed Jun 27 12:09:02 2007 -0400 @@ -73,7 +73,10 @@ echo PageUtils::flushlogs($paths->cpage['urlname_nons'], $paths->namespace); break; case "deletepage": - echo PageUtils::deletepage($paths->cpage['urlname_nons'], $paths->namespace); + $reason = ( isset($_POST['reason']) ) ? $_POST['reason'] : false; + if ( empty($reason) ) + die('Please enter a reason for deleting this page.'); + echo PageUtils::deletepage($paths->cpage['urlname_nons'], $paths->namespace, $reason); break; case "delvote": echo PageUtils::delvote($paths->cpage['urlname_nons'], $paths->namespace); diff -r dd659f6ba891 -r dd2edcdc6c03 includes/clientside/static/ajax.js --- a/includes/clientside/static/ajax.js Wed Jun 27 00:59:42 2007 -0400 +++ b/includes/clientside/static/ajax.js Wed Jun 27 12:09:02 2007 -0400 @@ -226,12 +226,18 @@ } function ajaxDeletePage() { + var reason = prompt('Please enter you reason for deleting this page.'); + if ( !reason || reason == '' ) + { + return false; + } c = confirm('You are about to DESTROY this page. Do you REALLY want to do this?'); - if(!c) return; - c = confirm('You\'re ABSOLUTELY sure???'); - if(!c) return; + if(!c) + { + return; + } setAjaxLoading(); - ajaxGet(stdAjaxPrefix+'&_mode=deletepage', function() { + ajaxPost(stdAjaxPrefix+'&_mode=deletepage', 'reason=' + escape(reason), function() { if(ajax.readyState == 4) { unsetAjaxLoading(); alert(ajax.responseText); diff -r dd659f6ba891 -r dd2edcdc6c03 includes/pageprocess.php --- a/includes/pageprocess.php Wed Jun 27 00:59:42 2007 -0400 +++ b/includes/pageprocess.php Wed Jun 27 12:09:02 2007 -0400 @@ -752,6 +752,12 @@ echo 'Enjoys: ' . htmlspecialchars($userdata['user_hobbies']) . ''; } + if ( empty($userdata['user_location']) && empty($userdata['user_job']) && empty($userdata['user_hobbies']) ) + { + $class = ( $class == 'row1' ) ? 'row3' : 'row1'; + echo '' . htmlspecialchars($target_username) . ' hasn\'t posted any real-life contact information.'; + } + echo ' '; @@ -865,7 +871,7 @@ if ( $db->numrows() > 0 ) { $r = $db->fetchrow(); - echo '

This page also appears to have some log entries in the database - it seems that it was deleted on ' . $r['date_string'] . '. You can probably roll back the deletion.

'; + echo '

This page was deleted on ' . $r['date_string'] . '. The stated reason was:

' . $r['edit_summary'] . '

You can probably roll back the deletion.

'; } $db->free_result(); } diff -r dd659f6ba891 -r dd2edcdc6c03 includes/pageutils.php --- a/includes/pageutils.php Wed Jun 27 00:59:42 2007 -0400 +++ b/includes/pageutils.php Wed Jun 27 12:09:02 2007 -0400 @@ -613,7 +613,7 @@ elseif($r['action']=='semiprot') echo 'Semi-protected pageReason: '.$r['edit_summary']; elseif($r['action']=='rename') echo 'Renamed pageOld title: '.$r['edit_summary']; elseif($r['action']=='create') echo 'Created page'; - elseif($r['action']=='delete') echo 'Deleted page'; + elseif($r['action']=='delete') echo 'Deleted pageReason: '.$r['edit_summary']; elseif($r['action']=='reupload') echo 'Uploaded new file versionReason: '.$r['edit_summary']; echo ''; @@ -1253,17 +1253,23 @@ /** * Deletes a page. - * @param $page_id the condemned page ID - * @param $namespace the condemned namespace + * @param string $page_id the condemned page ID + * @param string $namespace the condemned namespace + * @param string The reason for deleting the page in question * @return string */ - function deletepage($page_id, $namespace) + function deletepage($page_id, $namespace, $reason) { global $db, $session, $paths, $template, $plugins; // Common objects $perms = $session->fetch_page_acl($page_id, $namespace); - if(!$perms->get_permissions('delete_page')) die('Administrative privileges are required to delete pages, you loser.'); - $e = $db->sql_query('INSERT INTO '.table_prefix.'logs(time_id,date_string,log_type,action,page_id,namespace,author) VALUES('.time().', \''.date('d M Y h:i a').'\', \'page\', \'delete\', \''.$page_id.'\', \''.$namespace.'\', \''.$session->username.'\')'); + $x = trim($reason); + if ( empty($x) ) + { + return 'Invalid reason for deletion passed'; + } + if(!$perms->get_permissions('delete_page')) return('Administrative privileges are required to delete pages, you loser.'); + $e = $db->sql_query('INSERT INTO '.table_prefix.'logs(time_id,date_string,log_type,action,page_id,namespace,author,edit_summary) VALUES('.time().', \''.date('d M Y h:i a').'\', \'page\', \'delete\', \''.$page_id.'\', \''.$namespace.'\', \''.$session->username.'\', \'' . $db->escape(htmlspecialchars($reason)) . '\')'); if(!$e) $db->_die('The page log entry could not be inserted.'); $e = $db->sql_query('DELETE FROM '.table_prefix.'categories WHERE page_id=\''.$page_id.'\' AND namespace=\''.$namespace.'\''); if(!$e) $db->_die('The page categorization entries could not be deleted.'); diff -r dd659f6ba891 -r dd2edcdc6c03 index.php --- a/index.php Wed Jun 27 00:59:42 2007 -0400 +++ b/index.php Wed Jun 27 12:09:02 2007 -0400 @@ -311,11 +311,17 @@ if(!$session->get_permissions('delete_page')) die_friendly('Access denied', '

Deleting pages requires admin rights.

'); if(isset($_POST['_adiossucker'])) { - $template->header(); - $result = PageUtils::deletepage($paths->cpage['urlname_nons'], $paths->namespace); - echo '

'.$result.' Return to the page.

'; - $template->footer(); - break; + $reason = ( isset($_POST['reason']) ) ? $_POST['reason'] : false; + if ( empty($reason) ) + $error = 'Please enter a reason for deleting this page.'; + else + { + $template->header(); + $result = PageUtils::deletepage($paths->cpage['urlname_nons'], $paths->namespace, $reason); + echo '

'.$result.' Return to the page.

'; + $template->footer(); + break; + } } $template->header(); ?> @@ -324,6 +330,8 @@

While the deletion of the page itself is completely reversible, it is impossible to recover any comments or category information on this page. If this is a file page, the file along with all older revisions of it will be permanently deleted. Also, any custom information that this page is tagged with, such as a custom name, protection status, or additional settings such as whether to allow comments, will be permanently lost.

Are you absolutely sure that you want to continue?
You will not be asked again.

+ $error

"; ?> +

Reason for deleting: