--- comment_revisions.module 2008-10-15 20:08:28.000000000 +0200 +++ comment_revisions.module.linksunten 2009-01-21 03:42:09.000000000 +0100 @@ -42,55 +42,40 @@ */ function comment_revisions_admin() { - $form['comment_revisions']['enable_usr_rev'] = array( + $form['comment_revisions_enable_usr_rev'] = array( '#type' => 'checkbox', - '#title' => t("Enable automatic creation of user revisions"), + '#title' => t('Enable automatic creation of user revisions'), '#description' => t('If a user edits his own content a new revision will be automatically created.'), - '#default_value' => variable_get("comment_revisions_enable_usr_rev", 1) + '#default_value' => variable_get('comment_revisions_enable_usr_rev', 1) ); - $form['comment_revisions']['max_usr_rev'] = array( + + $form['comment_revisions_max_usr_revisions'] = array( '#type' => 'textfield', - '#title' => t("Maximum number of automatic revisions."), - '#description' => t('Maximum amount of revisions automatically created when a user edits his own content.'), - '#default_value' => variable_get("comment_revisions_max_usr_revisions", 5), + '#title' => t('Maximum number of automatic revisions.'), + '#description' => t('Maximum amount of revisions automatically created when a user edits his own content. 0 or negative = infinite'), + '#default_value' => variable_get('comment_revisions_max_usr_revisions', 0), '#size' => 2, '#maxlength' => 6 ); - $form['comment_revisions']['max_adm_rev'] = array( + $form['comment_revisions_max_admin'] = array( '#type' => 'textfield', '#title' => t('Maximum number of administrator revisions'), - '#description' => t('Maximum amount of revisions an administrator can create. 0 = infinite'), + '#description' => t('Maximum amount of revisions an administrator can create. 0 or negative = infinite'), '#default_value' => variable_get('comment_revisions_max_admin', 0), '#size' => 2, '#maxlength' => 6, '#required' => TRUE ); - return system_settings_form($form); -} - -/** - * validates the form - */ -function comment_revisions_admin_validate($form, &$form_state) { - if($form_state['values']["max_adm_rev"] < 0) { - form_set_error("comment_revisions][max_adm_rev", t("Maximum amount of administrator revisions has to be greater than 0.")); - } - if($form_state['values']["max_usr_rev"] < 1) { - form_set_error("comment_revisions][max_usr_rev", t("Maximum amount of user revisions has to be at least 1.")); - } -} - -/** - * submits the form - */ -function comment_revisions_admin_submit($form, &$form_state) { + $form['comment_revisions_disable_logs'] = array( + '#type' => 'checkbox', + '#title' => t('Disable log messages'), + '#description' => t('Disables all log messages for revisions.'), + '#default_value' => variable_get('comment_revisions_disable_logs', 0) + ); - variable_set("comment_revisions_enable_usr_rev", $form_state['values']["enable_usr_rev"]); - variable_set("comment_revisions_max_usr_revisions", $form_state['values']["max_usr_rev"]); - variable_set("comment_revisions_max_admin", $form_state['values']["max_adm_rev"]); - drupal_set_message(t("Comment Revision settings saved.")); + return system_settings_form($form); } /** @@ -104,7 +89,7 @@ 'description' => 'Settings page for the GB Comment Revisions Module', 'page callback' => 'drupal_get_form', 'page arguments' => array('comment_revisions_admin'), - 'access arguments' => array('administer GB Comment Revisions'), + 'access arguments' => array('administer comment revisions'), 'type' => MENU_NORMAL_ITEM ); @@ -138,6 +123,7 @@ return $items; } + function _comment_revisions_checkaccess($access) { foreach($access as $accessType) { if(user_access($accessType)) { @@ -147,6 +133,7 @@ } return false; } + /** * Implementation of hook_comment */ @@ -208,8 +195,8 @@ if($isUserRevision) { $amountOfRevisions = db_result(db_query("SELECT COUNT(*) FROM {comment_revisions} WHERE cid=%d AND isusrrev=1",$queryInfo['cid'])); - $maxUsrRevisions = variable_get("comment_revisions_max_usr_revisions", 5); - if($amountOfRevisions > $maxUsrRevisions) { + $maxUsrRevisions = variable_get("comment_revisions_max_usr_revisions", 0); + if(($amountOfRevisions > $maxUsrRevisions) && ($maxUsrRevisions > 0)){ $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)); db_query("DELETE FROM {comment_revisions} WHERE vid=%d", $deleteRevID); drupal_set_message(t("One expired revision was deleted.")); @@ -241,7 +228,7 @@ if($form['uid']['#value'] == $user->uid) { $isUserCmt = TRUE; } - if((user_access('create revisions') && !$isUserCmt) || (user_access('willful create own') && $isUserCmt)) { + if((user_access('create revisions') && !$isUserCmt && !variable_get('comment_revisions_disable_logs', 0)) || (user_access('willful create own') && $isUserCmt) && !variable_get('comment_revisions_disable_logs', 0)) { /* if user can create revisions and its not his own, or it is his own and he is allowed to create his own revision */ /*$form["revisions"] = array( '#type' => 'fieldset', @@ -317,13 +304,13 @@ $revisionIsUsrRev = ($revision->isusrrev == 1) ? '
'.t('Is a user-revision').'
':FALSE; $revisionIsActual = ($revision->vid == $actualvid) ? TRUE : FALSE; $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))) - . (($revision->logmessage != '') ? ''. filter_xss($revision->logmessage) .'
'.filter_xss($revision->comment).'
' : ''.filter_xss($revision->comment).'
') . "" . $revisionIsUsrRev); + . ((($revision->logmessage) && !variable_get('comment_revisions_disable_logs', 0)) ? ''. filter_xss($revision->logmessage) .'
' : '') .''.filter_xss($revision->subject).'
' . ''.filter_xss($revision->comment).'
' . $revisionIsUsrRev); if($revisionIsActual) { $tempar['class'] = 'revision-current'; - $operations[] = array('data' => theme('placeholder', t('current revision')) .'