| 1 |
<?php |
<?php |
| 2 |
// $Id: comment_revisions.module,v 1.49 2008/06/29 09:00:20 Raiden Exp $ |
// $Id: comment_revisions.module,v 1.50.2.41 2008/06/30 21:05:55 Raiden Exp $ |
| 3 |
/** |
/** |
| 4 |
* @file |
* @file |
| 5 |
* Complete module for comment_revisions |
* Complete module for comment_revisions |
| 9 |
/** |
/** |
| 10 |
* Implementation of hook_help(). |
* Implementation of hook_help(). |
| 11 |
*/ |
*/ |
| 12 |
function comment_revisions_help($section) { |
function comment_revisions_help($path, $arg) { |
| 13 |
switch ($section) { |
switch ($path) { |
| 14 |
case 'admin/help#comment_revisions': |
case 'admin/help#comment_revisions': |
| 15 |
// Return a line-break version of the module README |
// Return a line-break version of the module README |
| 16 |
return filter_filter('process', 2, NULL, file_get_contents( dirname(__FILE__)."/README.txt") ); |
return filter_filter('process', 2, NULL, file_get_contents( dirname(__FILE__)."/README.txt") ); |
| 73 |
/** |
/** |
| 74 |
* validates the form |
* validates the form |
| 75 |
*/ |
*/ |
| 76 |
function comment_revisions_admin_validate($form_id, $form_values) { |
function comment_revisions_admin_validate($form, &$form_state) { |
| 77 |
if($form_values["max_adm_rev"] < 0) { |
if($form_state['values']["max_adm_rev"] < 0) { |
| 78 |
form_set_error("comment_revisions][max_adm_rev", t("Maximum amount of administrator revisions has to be greater than 0.")); |
form_set_error("comment_revisions][max_adm_rev", t("Maximum amount of administrator revisions has to be greater than 0.")); |
| 79 |
} |
} |
| 80 |
if($form_values["max_usr_rev"] < 1) { |
if($form_state['values']["max_usr_rev"] < 1) { |
| 81 |
form_set_error("comment_revisions][max_usr_rev", t("Maximum amount of user revisions has to be at least 1.")); |
form_set_error("comment_revisions][max_usr_rev", t("Maximum amount of user revisions has to be at least 1.")); |
| 82 |
} |
} |
| 83 |
} |
} |
| 85 |
/** |
/** |
| 86 |
* submits the form |
* submits the form |
| 87 |
*/ |
*/ |
| 88 |
function comment_revisions_admin_submit($form_id, $form_values) { |
function comment_revisions_admin_submit($form, &$form_state) { |
| 89 |
|
|
| 90 |
variable_set("comment_revisions_enable_usr_rev", $form_values["enable_usr_rev"]); |
variable_set("comment_revisions_enable_usr_rev", $form_state['values']["enable_usr_rev"]); |
| 91 |
variable_set("comment_revisions_max_usr_revisions", $form_values["max_usr_rev"]); |
variable_set("comment_revisions_max_usr_revisions", $form_state['values']["max_usr_rev"]); |
| 92 |
variable_set("comment_revisions_max_admin", $form_values["max_adm_rev"]); |
variable_set("comment_revisions_max_admin", $form_state['values']["max_adm_rev"]); |
| 93 |
drupal_set_message(t("Comment Revision settings saved.")); |
drupal_set_message(t("Comment Revision settings saved.")); |
| 94 |
} |
} |
| 95 |
|
|
| 96 |
/** |
/** |
| 97 |
* Implementation of hook_menu |
* Implementation of hook_menu |
| 98 |
*/ |
*/ |
| 99 |
function comment_revisions_menu($may_cache) { |
function comment_revisions_menu() { |
| 100 |
$items = array(); |
$items = array(); |
| 101 |
|
|
| 102 |
if($may_cache) { |
$items['admin/settings/commentrevisions'] = array( |
| 103 |
|
'title' => 'GB Comment Revisions settings', |
| 104 |
} else { |
'description' => 'Settings page for the GB Comment Revisions Module', |
| 105 |
$items[] = array('path' => 'admin/settings/commentrevisions', |
'page callback' => 'drupal_get_form', |
| 106 |
'title' => t('GB Comment Revisions settings'), |
'page arguments' => array('comment_revisions_admin'), |
| 107 |
'description' => t('Settings page for the GB Comment Revisions Module'), |
'access arguments' => array('administer GB Comment Revisions'), |
|
'callback' => 'drupal_get_form', |
|
|
'callback arguments' => 'comment_revisions_admin', |
|
|
'access' => user_access('administer GB Comment Revisions'), |
|
| 108 |
'type' => MENU_NORMAL_ITEM |
'type' => MENU_NORMAL_ITEM |
| 109 |
); |
); |
| 110 |
|
|
| 111 |
/* If permission is "view revisions" */ |
/* If permission is "view revisions" */ |
| 112 |
$items[] = array( |
$items['commentrevision/%'] = array( |
| 113 |
'path' => 'commentrevision/'.arg(1), |
'title' => 'Revisions', |
| 114 |
'title' => t('Revisions'), |
'page callback' => 'comment_revisions_overview', |
| 115 |
'callback' => 'comment_revisions_overview', |
'page arguments' => array(1), |
| 116 |
'callback arguments' => arg(1), |
'access callback' => '_comment_revisions_checkaccess', |
| 117 |
'access' => user_access('view revisions') || user_access('view own revisions'), |
'access arguments' => array(array('view revisions', 'view own revisions')), |
| 118 |
'weight' => 2, |
'weight' => 2, |
| 119 |
'type' => MENU_CALLBACK, |
'type' => MENU_CALLBACK, |
| 120 |
); |
); |
| 121 |
|
|
| 122 |
$items[] = array( |
$items['commentrevision/%/revert'] = array( |
| 123 |
'path' => 'commentrevision/'.arg(1).'/revert', |
'title' => 'Revert Revision', |
| 124 |
'title' => t('Revert Revision'), |
'page callback' => 'comment_revisions_revert', |
| 125 |
'callback' => 'comment_revisions_revert', |
'page arguments' => array(1), |
| 126 |
'callback arguments' => arg(1), |
'access callback' => '_comment_revisions_checkaccess', |
| 127 |
'access' => user_access('revert revisions'), |
'access arguments' => array(array('revert revisions')), |
| 128 |
'type' => MENU_CALLBACK |
'type' => MENU_CALLBACK |
| 129 |
); |
); |
| 130 |
$items[] = array( |
$items['commentrevision/%/delete'] = array( |
| 131 |
'path' => 'commentrevision/'.arg(1).'/delete', |
'title' => 'Delete Revision', |
| 132 |
'title' => t('Delete Revision'), |
'page callback' => 'comment_revisions_delete', |
| 133 |
'callback' => 'comment_revisions_delete', |
'page arguments' => array(1), |
| 134 |
'callback arguments' => arg(1), |
'access callback' => '_comment_revisions_checkaccess', |
| 135 |
'access' => user_access('delete revisions'), |
'access arguments' => array(array('delete revisions')), |
| 136 |
'type' => MENU_CALLBACK |
'type' => MENU_CALLBACK |
| 137 |
); |
); |
|
} |
|
| 138 |
|
|
| 139 |
return $items; |
return $items; |
| 140 |
} |
} |
| 141 |
|
function _comment_revisions_checkaccess($access) { |
| 142 |
|
foreach($access as $accessType) { |
| 143 |
|
if(user_access($accessType)) { |
| 144 |
|
return true; |
| 145 |
|
break; |
| 146 |
|
} |
| 147 |
|
} |
| 148 |
|
return false; |
| 149 |
|
} |
| 150 |
/** |
/** |
| 151 |
* Implementation of hook_comment |
* Implementation of hook_comment |
| 152 |
*/ |
*/ |
| 160 |
break; |
break; |
| 161 |
case "validate": |
case "validate": |
| 162 |
/* Comment is edited and revision should be created */ |
/* Comment is edited and revision should be created */ |
| 163 |
if($a1["cid"] != NULL && $a1["create_revision"] == 1 && $a1["op"] != t("Preview comment")) { |
if($a1["cid"] != NULL && $a1["create_revision"] == 1 && $a1["op"] != t("Preview")) { |
| 164 |
/* No revision before, that means, the original has to be saved */ |
/* No revision before, that means, the original has to be saved */ |
| 165 |
if(!_comment_revision_cmt_has_revisions($a1["cid"])) { |
if(!_comment_revision_cmt_has_revisions($a1["cid"])) { |
| 166 |
$result = db_fetch_array(db_query("SELECT * FROM {comments} WHERE cid=%d", $a1['cid'])); |
$result = db_fetch_array(db_query("SELECT * FROM {comments} WHERE cid=%d", $a1['cid'])); |
| 167 |
db_query("INSERT INTO {comment_revisions} (vid, cid, comment, subject, logMessage, createdOn, createdBy, isUsrRev) |
|
| 168 |
VALUES(%d, %d, '%s', '%s', '%s', %d, %d, '%s')", |
db_query("INSERT INTO {comment_revisions} (cid, comment, subject, logmessage, createdon, createdby, isusrrev) |
| 169 |
db_next_id("{comment_revisions}_vid"), |
VALUES(%d, '%s', '%s', '%s', %d, %d, %d)", |
| 170 |
$result["cid"], |
$result["cid"], |
| 171 |
$result["comment"], |
$result["comment"], |
| 172 |
$result["subject"], |
$result["subject"], |
| 173 |
t("Original comment"), |
t("Original comment"), |
| 174 |
$result["timestamp"], |
$result["timestamp"], |
| 175 |
$result["uid"], |
$result["uid"], |
| 176 |
'0'); |
0); |
| 177 |
} |
} |
| 178 |
} |
} |
| 179 |
break; |
break; |
| 191 |
$queryInfo['comment'] = $a1['comment']; |
$queryInfo['comment'] = $a1['comment']; |
| 192 |
$queryInfo['subject'] = $a1['subject']; |
$queryInfo['subject'] = $a1['subject']; |
| 193 |
$queryInfo['log_message'] = $a1['log_message']; |
$queryInfo['log_message'] = $a1['log_message']; |
| 194 |
$queryInfo['createdOn'] = time(); |
$queryInfo['createdon'] = time(); |
| 195 |
$queryInfo['createdBy'] = $user->uid; |
$queryInfo['createdby'] = $user->uid; |
| 196 |
$queryInfo['isUsrRev'] = $isUserRevision ? '1' : '0'; |
$queryInfo['isusrrev'] = $isUserRevision ? 1 : 0; |
|
$queryInfo['vid'] = db_next_id("{comment_revisions}_vid"); |
|
| 197 |
|
|
| 198 |
db_query("INSERT INTO {comment_revisions} |
db_query("INSERT INTO {comment_revisions} |
| 199 |
(vid, cid, comment, subject, logMessage, createdOn, createdBy, isUsrRev) |
(cid, comment, subject, logmessage, createdon, createdby, isusrrev) |
| 200 |
VALUES (%d, %d,'%s','%s','%s', %d, %d, '%s')", |
VALUES (%d,'%s','%s','%s', %d, %d, %d)", |
|
$queryInfo['vid'], |
|
| 201 |
$queryInfo["cid"], |
$queryInfo["cid"], |
| 202 |
$queryInfo["comment"], |
$queryInfo["comment"], |
| 203 |
$queryInfo["subject"], |
$queryInfo["subject"], |
| 204 |
$queryInfo["log_message"], |
$queryInfo["log_message"], |
| 205 |
$queryInfo["createdOn"], |
$queryInfo["createdon"], |
| 206 |
$queryInfo["createdBy"], |
$queryInfo["createdby"], |
| 207 |
$queryInfo["isUsrRev"]); |
$queryInfo["isusrrev"]); |
| 208 |
|
|
| 209 |
if($isUserRevision) { |
if($isUserRevision) { |
| 210 |
$amountOfRevisions = db_result(db_query("SELECT COUNT(*) FROM {comment_revisions} WHERE cid=%d AND isUsrRev=1",$queryInfo['cid'])); |
$amountOfRevisions = db_result(db_query("SELECT COUNT(*) FROM {comment_revisions} WHERE cid=%d AND isusrrev=1",$queryInfo['cid'])); |
| 211 |
$maxUsrRevisions = variable_get("comment_revisions_max_usr_revisions", 5); |
$maxUsrRevisions = variable_get("comment_revisions_max_usr_revisions", 5); |
| 212 |
if($amountOfRevisions > $maxUsrRevisions) { |
if($amountOfRevisions > $maxUsrRevisions) { |
| 213 |
$deleteRevID = db_result(db_query_range("SELECT vid FROM {comment_revisions} WHERE cid=%d AND isUsrRev ORDER BY createdOn ASC",$queryInfo['cid'],0,1)); |
$deleteRevID = db_result(db_query_range("SELECT vid FROM {comment_revisions} WHERE cid=%d AND isusrrev=1 ORDER BY createdon ASC",$queryInfo['cid'],0,1)); |
| 214 |
db_query("DELETE FROM {comment_revisions} WHERE vid=%d", $deleteRevID); |
db_query("DELETE FROM {comment_revisions} WHERE vid=%d", $deleteRevID); |
| 215 |
drupal_set_message(t("One expired revision was deleted.")); |
drupal_set_message(t("One expired revision was deleted.")); |
| 216 |
} |
} |
| 217 |
} |
} |
| 218 |
if(!_comment_revision_cmt_has_revisions($queryInfo["cid"])) { |
if(!_comment_revision_cmt_has_revisions($queryInfo["cid"])) { |
| 219 |
db_query("INSERT INTO {comment_revisions_actual} (cid, vid) VALUES (%d, %d)", $queryInfo["cid"], $queryInfo["vid"]); |
db_query("INSERT INTO {comment_revisions_actual} (cid, vid) VALUES (%d, %d)", $queryInfo["cid"], db_last_insert_id("{comment_revisions}","vid")); |
| 220 |
drupal_set_message("Comment set to RevisionId:".$queryInfo["vid"]); |
drupal_set_message("Comment set to RevisionId:".db_last_insert_id("{comment_revisions}","vid")); |
| 221 |
} else { |
} else { |
| 222 |
db_query("UPDATE {comment_revisions_actual} SET vid=%d WHERE cid=%d", $queryInfo["vid"], $queryInfo["cid"]); |
db_query("UPDATE {comment_revisions_actual} SET vid=%d WHERE cid=%d", db_last_insert_id("{comment_revisions}", "vid"), $queryInfo["cid"]); |
| 223 |
drupal_set_message("Comment updated to RevisionId:". $queryInfo["vid"]); |
drupal_set_message("Comment updated to RevisionId:". db_last_insert_id("{comment_revisions}","vid")); |
| 224 |
} |
} |
| 225 |
drupal_set_message("One revision created."); |
drupal_set_message("One revision created."); |
| 226 |
} |
} |
| 232 |
/** |
/** |
| 233 |
* Implementation of hook_form_alter |
* Implementation of hook_form_alter |
| 234 |
*/ |
*/ |
| 235 |
function comment_revisions_form_alter($form_id, &$form){ |
function comment_revisions_form_alter(&$form, &$form_state, $form_id){ |
| 236 |
global $user; |
global $user; |
| 237 |
if($form["form_id"]["#id"] == "edit-comment-form" && $form["cid"]["#value"] != NULL) { |
if($form["form_id"]["#id"] == "edit-comment-form" && $form["cid"]["#value"] != NULL) { |
| 238 |
/* is comment editing form */ |
/* is comment editing form */ |
| 314 |
foreach($revisions as $revision) { |
foreach($revisions as $revision) { |
| 315 |
$row = array(); |
$row = array(); |
| 316 |
$operations = array(); |
$operations = array(); |
| 317 |
$revisionIsUsrRev = ($revision->isUsrRev == 1) ? '<p class="revision_isUsrRev">'.t('Is a user-revision').'</p>':FALSE; |
$revisionIsUsrRev = ($revision->isusrrev == 1) ? '<p class="revision_isusrrev">'.t('Is a user-revision').'</p>':FALSE; |
| 318 |
$revisionIsActual = ($revision->vid == $actualvid) ? TRUE : FALSE; |
$revisionIsActual = ($revision->vid == $actualvid) ? TRUE : FALSE; |
| 319 |
$tempar = array('data' => t('!date by !username', array('!date' => l(format_date($revision->createdOn, 'small'), "node/$revision->nid/",array(),NULL,"comment-$revision->cid"), '!username' => theme('username', $revision))) |
$tempar = array('data' => t('!date by !username', array('!date' => l(format_date($revision->createdon, 'small'), "node/$revision->nid/", $options = array( 'fragment' => "comment-$revision->cid")), '!username' => theme('username', $revision))) |
| 320 |
. (($revision->logMessage != '') ? '<p class="revision-log">'. filter_xss($revision->logMessage) .'</p><p class="comment">'.filter_xss($revision->comment).'</p>' : '<p class="comment">'.filter_xss($revision->comment).'</p>') . "" . $revisionIsUsrRev); |
. (($revision->logmessage != '') ? '<p class="revision-log">'. filter_xss($revision->logmessage) .'</p><p class="comment">'.filter_xss($revision->comment).'</p>' : '<p class="comment">'.filter_xss($revision->comment).'</p>') . "" . $revisionIsUsrRev); |
| 321 |
if($revisionIsActual) { |
if($revisionIsActual) { |
| 322 |
$tempar['class'] = 'revision-current'; |
$tempar['class'] = 'revision-current'; |
| 323 |
$operations[] = array('data' => theme('placeholder', t('current revision')) .'<br />'. l(t('delete'), "commentrevision/$revision->vid/delete"), 'class' => 'revision-current', 'colspan' => 2); |
$operations[] = array('data' => theme('placeholder', t('current revision')) .'<br />'. l(t('delete'), "commentrevision/$revision->vid/delete"), 'class' => 'revision-current', 'colspan' => 2); |
| 337 |
$pathfragment = "comment-". $cid; |
$pathfragment = "comment-". $cid; |
| 338 |
$attributes = array(); |
$attributes = array(); |
| 339 |
$query = NULL; |
$query = NULL; |
| 340 |
$output = l(t("Back to comment"), $path , $attributes, $query, $pathfragment); |
$output = l(t("Back to comment"), $path , $options = array('attributes' => $attributes, 'query' => $query, 'fragment' => $pathfragment)); |
| 341 |
$output .= theme('table', $header, $rows); |
$output .= theme('table', $header, $rows); |
| 342 |
return $output; |
return $output; |
| 343 |
} |
} |
| 355 |
/** |
/** |
| 356 |
* confirm reverting |
* confirm reverting |
| 357 |
*/ |
*/ |
| 358 |
function comment_revisions_revert_confirm($revision) { |
function comment_revisions_revert_confirm(&$form_state, $revision) { |
| 359 |
$form['revision'] = array('#type' => 'value', '#value' => $revision); |
$form['revision'] = array('#type' => 'value', '#value' => $revision); |
| 360 |
return confirm_form($form, t('Are you sure you want to revert to the revision from %revision-date?', array('%revision-date' => format_date($revision->createdOn))), 'commentrevisions/'. $revision->cid, '', t('Revert'), t('Cancel')); |
return confirm_form($form, t('Are you sure you want to revert to the revision from %revision-date?', array('%revision-date' => format_date($revision->createdon))), 'commentrevisions/'. $revision->cid, '', t('Revert'), t('Cancel')); |
| 361 |
} |
} |
| 362 |
|
|
| 363 |
/** |
/** |
| 364 |
* submit reverting |
* submit reverting |
| 365 |
*/ |
*/ |
| 366 |
function comment_revisions_revert_confirm_submit($form_id, $form_values) { |
function comment_revisions_revert_confirm_submit($form, &$form_state) { |
| 367 |
$revision = $form_values['revision']; |
$revision = $form_state['values']['revision']; |
| 368 |
|
|
| 369 |
db_query("UPDATE {comment_revisions_actual} SET vid=%d WHERE cid=%d",$revision->vid, $revision->cid); |
db_query("UPDATE {comment_revisions_actual} SET vid=%d WHERE cid=%d",$revision->vid, $revision->cid); |
| 370 |
db_query("UPDATE {comments} SET comment='%s' WHERE cid=%d", $revision->comment, $revision->cid); |
db_query("UPDATE {comments} SET comment='%s' WHERE cid=%d", $revision->comment, $revision->cid); |
| 371 |
drupal_set_message(t('Comment Id: %cid has been reverted back to the revision from %revision-date', array('%revision-date' => format_date($revision->createdOn), '%cid' => $revision->cid))); |
drupal_set_message(t('Comment Id: %cid has been reverted back to the revision from %revision-date', array('%revision-date' => format_date($revision->createdon), '%cid' => $revision->cid))); |
| 372 |
watchdog('comment',t('Reverted %cid to revision from %date.', array('%cid' => $revision->cid, '%date' => format_date($revision->createdOn))),WATCHDOG_NOTICE,l(t('view'), "commentrevision/".$revision->cid)); |
watchdog('comment','Reverted %cid to revision from %date.', array('%cid' => $revision->cid, '%date' => format_date($revision->createdon)),WATCHDOG_NOTICE,l(t('view'), "commentrevision/".$revision->cid)); |
| 373 |
|
$form_state['redirect'] = "commentrevision/". $revision->cid; |
|
return 'commentrevision/'. $revision->cid; |
|
| 374 |
} |
} |
| 375 |
|
|
| 376 |
/** |
/** |
| 378 |
*/ |
*/ |
| 379 |
function comment_revisions_delete($vid){ |
function comment_revisions_delete($vid){ |
| 380 |
$revision = _comment_revisions_load_revision($vid); |
$revision = _comment_revisions_load_revision($vid); |
|
|
|
| 381 |
return drupal_get_form('comment_revisions_delete_confirm', $revision); |
return drupal_get_form('comment_revisions_delete_confirm', $revision); |
|
|
|
|
drupal_goto('commentrevision/'. $revision->cid); |
|
| 382 |
} |
} |
| 383 |
|
|
| 384 |
/** |
/** |
| 385 |
* confirm deletion |
* confirm deletion |
| 386 |
*/ |
*/ |
| 387 |
function comment_revisions_delete_confirm($revision) { |
function comment_revisions_delete_confirm(&$form_state, $revision) { |
| 388 |
$actualRevision = _comment_revision_get_actual_revision($revision->cid); |
$actualRevision = _comment_revision_get_actual_revision($revision->cid); |
| 389 |
$extraInfo = ""; |
$extraInfo = ""; |
| 390 |
if($actualRevision == $revision->vid) { |
if($actualRevision == $revision->vid) { |
| 391 |
$extraInfo = t("This is the actual revision of the comment. Deleting this, will revert the comment to the newest revision after deletion"); |
$extraInfo = t("This is the actual revision of the comment. Deleting this, will revert the comment to the newest revision after deletion"); |
| 392 |
} |
} |
| 393 |
$form['revision'] = array('#type' => 'value', '#value' => $revision, '#description' => $extraInfo); |
$form['revision'] = array('#type' => 'value', '#value' => $revision, '#description' => $extraInfo); |
| 394 |
return confirm_form($form, t('Are you sure you want to delete the revision from %revision-date?', array('%revision-date' => format_date($revision->createdOn))), 'commentrevisions/'. $revision->cid, '', t('Delete'), t('Cancel')); |
return confirm_form($form, t('Are you sure you want to delete the revision from %revision-date?', array('%revision-date' => format_date($revision->createdon))), 'commentrevisions/'. $revision->cid, '', t('Delete'), t('Cancel')); |
| 395 |
} |
} |
| 396 |
|
|
| 397 |
/** |
/** |
| 398 |
* submit deletion |
* submit deletion |
| 399 |
*/ |
*/ |
| 400 |
function comment_revisions_delete_confirm_submit($form_id, $form_values) { |
function comment_revisions_delete_confirm_submit($form, &$form_state) { |
| 401 |
$revision = $form_values['revision']; |
$revision = $form_state['values']['revision']; |
|
|
|
| 402 |
db_query("DELETE FROM {comment_revisions} WHERE vid=%d", $revision->vid); |
db_query("DELETE FROM {comment_revisions} WHERE vid=%d", $revision->vid); |
| 403 |
drupal_set_message(t('Revision for Comment Id: %cid from %revision-date has been deleted', array('%cid' => $revision->cid, '%revision-date' => format_date($revision->createdOn)))); |
drupal_set_message(t('Revision for Comment Id: %cid from %revision-date has been deleted', array('%cid' => $revision->cid, '%revision-date' => format_date($revision->createdon)))); |
| 404 |
watchdog('comment', t('Deleted Revision Id: %vid from %revision-date for Comment Id: %cid', array('%vid' => $revision->vid, '%revision-date' => format_date($revision->createdOn), '%cid' => $revision->cid)), WATCHDOG_NOTICE, l(t('view'), "commentrevision/".$revision->cid)); |
watchdog('comment', 'Deleted Revision Id: %vid from %revision-date for Comment Id: %cid', array('%vid' => $revision->vid, '%revision-date' => format_date($revision->createdon), '%cid' => $revision->cid), WATCHDOG_NOTICE, l(t('view'), "commentrevision/".$revision->cid)); |
| 405 |
|
if(!_comment_revision_cmt_has_revisions($revision->cid, FALSE)) { |
| 406 |
return 'commentrevision/'. $revision->cid; |
db_query("DELETE FROM {comment_revisions_actual} WHERE cid=%d", $revision->cid); |
| 407 |
|
$path = "node/" ._comment_revisions_getnid($revision->cid); |
| 408 |
|
$pathfragment = "comment-". $revision->cid; |
| 409 |
|
$form_state['redirect'] = array($path,$pathfragment); |
| 410 |
|
} else { |
| 411 |
|
$form_state['redirect'] = "commentrevision/". $revision->cid; |
| 412 |
|
} |
| 413 |
} |
} |
| 414 |
|
|
| 415 |
/** |
/** |
| 418 |
function comment_revisions_list($cid, $creator = FALSE) { |
function comment_revisions_list($cid, $creator = FALSE) { |
| 419 |
$revisions= array(); |
$revisions= array(); |
| 420 |
if(!$creator){ |
if(!$creator){ |
| 421 |
$result = db_query('SELECT users.uid, users.name, revision.vid, revision.cid, comments.nid, revision.createdOn, revision.comment, revision.logMessage, revision.isUsrRev FROM {comment_revisions} revision INNER JOIN {comments} comments ON comments.cid = revision.cid INNER JOIN {users} users ON revision.createdBy = users.uid WHERE revision.cid = %d ORDER BY revision.createdOn DESC', $cid); |
$result = db_query('SELECT users.uid, users.name, revision.vid, revision.cid, comments.nid, revision.createdon, revision.comment, revision.logmessage, revision.isusrrev FROM {comment_revisions} revision INNER JOIN {comments} comments ON comments.cid = revision.cid INNER JOIN {users} users ON revision.createdby = users.uid WHERE revision.cid = %d ORDER BY revision.createdon DESC', $cid); |
| 422 |
} else { |
} else { |
| 423 |
$result = db_query('SELECT users.uid, users.name, revision.vid, revision.cid, comments.nid, revision.createdOn, revision.comment, revision.logMessage, revision.isUsrRev FROM {comment_revisions} revision INNER JOIN {comments} comments ON comments.cid = revision.cid INNER JOIN {users} users ON revision.createdBy = users.uid WHERE revision.cid = %d AND revision.createdBy = "%s" ORDER BY revision.createdOn DESC', $cid, $creator); |
$result = db_query('SELECT users.uid, users.name, revision.vid, revision.cid, comments.nid, revision.createdon, revision.comment, revision.logmessage, revision.isusrrev FROM {comment_revisions} revision INNER JOIN {comments} comments ON comments.cid = revision.cid INNER JOIN {users} users ON revision.createdby = users.uid WHERE revision.cid = %d AND revision.createdby = "%s" ORDER BY revision.createdon DESC', $cid, $creator); |
| 424 |
} |
} |
| 425 |
while ($revision = db_fetch_object($result)) { |
while ($revision = db_fetch_object($result)) { |
| 426 |
$revisions[] = $revision; |
$revisions[] = $revision; |
| 432 |
/** |
/** |
| 433 |
* TRUE if comment has at least one revision |
* TRUE if comment has at least one revision |
| 434 |
*/ |
*/ |
| 435 |
function _comment_revision_cmt_has_revisions($cid) { |
function _comment_revision_cmt_has_revisions($cid, $actual = TRUE) { |
| 436 |
$result = db_result(db_query("SELECT COUNT(*) FROM {comment_revisions_actual} WHERE cid=%d",$cid)); |
if($actual) { |
| 437 |
|
$result = db_result(db_query("SELECT COUNT(*) FROM {comment_revisions_actual} WHERE cid=%d",$cid)); |
| 438 |
|
} else { |
| 439 |
|
$result = db_result(db_query("SELECT COUNT(*) FROM {comment_revisions} WHERE cid=%d",$cid)); |
| 440 |
|
} |
| 441 |
if($result < 1) { |
if($result < 1) { |
| 442 |
return FALSE; |
return FALSE; |
| 443 |
} else { |
} else { |