Commit 46546ef4 authored by Dries's avatar Dries

- Patch #175841 by catch et al: remove comment controls for users. Yowza.

parent 5e16a499
......@@ -6,8 +6,8 @@
* Default theme implementation to wrap comments.
*
* Available variables:
* - $content: All comments for a given page. Also contains sorting controls
* and comment forms if the site is configured for it.
* - $content: All comments for a given page. Also contains comment form
* if enabled.
*
* The following variables are provided for contextual information.
* - $node: Node object the comments are attached to.
......@@ -21,11 +21,6 @@
* - $display_order
* - COMMENT_ORDER_NEWEST_FIRST
* - COMMENT_ORDER_OLDEST_FIRST
* - $comment_controls_state
* - COMMENT_CONTROLS_ABOVE
* - COMMENT_CONTROLS_BELOW
* - COMMENT_CONTROLS_ABOVE_BELOW
* - COMMENT_CONTROLS_HIDDEN
*
* @see template_preprocess_comment_wrapper()
* @see theme_comment_wrapper()
......
......@@ -50,26 +50,6 @@
*/
define('COMMENT_ORDER_OLDEST_FIRST', 2);
/**
* Comment controls should be shown above the comment list.
*/
define('COMMENT_CONTROLS_ABOVE', 0);
/**
* Comment controls should be shown below the comment list.
*/
define('COMMENT_CONTROLS_BELOW', 1);
/**
* Comment controls should be shown both above and below the comment list.
*/
define('COMMENT_CONTROLS_ABOVE_BELOW', 2);
/**
* Comment controls are hidden.
*/
define('COMMENT_CONTROLS_HIDDEN', 3);
/**
* Anonymous posters may not enter their contact information.
*/
......@@ -126,7 +106,7 @@
function comment_help($path, $arg) {
switch ($path) {
case 'admin/help#comment':
$output = '<p>' . t('The comment module allows visitors to comment on your posts, creating ad hoc discussion boards. Any <a href="@content-type">content type</a> may have its <em>Default comment setting</em> set to <em>Read/Write</em> to allow comments, or <em>Disabled</em>, to prevent comments. Comment display settings and other controls may also be customized for each content type (some display settings are customizable by individual users).', array('@content-type' => url('admin/build/types'))) . '</p>';
$output = '<p>' . t('The comment module allows visitors to comment on your posts, creating ad hoc discussion boards. Any <a href="@content-type">content type</a> may have its <em>Default comment setting</em> set to <em>Read/Write</em> to allow comments, or <em>Disabled</em>, to prevent comments. Comment display settings and other controls may also be customized for each content type.', array('@content-type' => url('admin/build/types'))) . '</p>';
$output .= '<p>' . t('Comment permissions are assigned to user roles, and are used to determine whether anonymous users (or other roles) are allowed to comment on posts. If anonymous users are allowed to comment, their individual contact information may be retained in cookies stored on their local computer for use in later comment submissions. When a comment has no replies, it may be (optionally) edited by its author. The comment module uses the same input formats and HTML tags available when creating other forms of content.') . '</p>';
$output .= '<p>' . t('For more information, see the online handbook entry for <a href="@comment">Comment module</a>.', array('@comment' => 'http://drupal.org/handbook/modules/comment/')) . '</p>';
return $output;
......@@ -154,9 +134,6 @@ function comment_theme() {
'comment_view' => array(
'arguments' => array('comment' => NULL, 'node' => NULL, 'links' => array(), 'visible' => 1),
),
'comment_controls' => array(
'arguments' => array('form' => NULL),
),
'comment' => array(
'template' => 'comment',
'arguments' => array('comment' => NULL, 'node' => NULL, 'links' => array()),
......@@ -252,7 +229,6 @@ function comment_node_type($op, $info) {
'comment_default_mode',
'comment_default_order',
'comment_default_per_page',
'comment_controls',
'comment_anonymous',
'comment_subject_field',
'comment_preview',
......@@ -544,17 +520,6 @@ function comment_form_alter(&$form, $form_state, $form_id) {
'#options' => _comment_per_page(),
'#description' => t('Default number of comments for each page: more comments are distributed in several pages.'),
);
$form['comment']['comment_controls'] = array(
'#type' => 'radios',
'#title' => t('Comment controls'),
'#default_value' => variable_get('comment_controls_' . $form['#node_type']->type, COMMENT_CONTROLS_HIDDEN),
'#options' => array(
t('Display above the comments'),
t('Display below the comments'),
t('Display above and below the comments'),
t('Do not display')),
'#description' => t('Position of the comment controls box. The comment controls let the user change the default display mode and display order of comments.'),
);
$form['comment']['comment_anonymous'] = array(
'#type' => 'radios',
'#title' => t('Anonymous commenting'),
......@@ -1052,17 +1017,8 @@ function comment_render($node, $cid = 0) {
$comments .= '</div>';
}
$comment_controls = variable_get('comment_controls_' . $node->type, COMMENT_CONTROLS_HIDDEN);
if ($num_rows && ($comment_controls == COMMENT_CONTROLS_ABOVE || $comment_controls == COMMENT_CONTROLS_ABOVE_BELOW)) {
$output .= drupal_get_form('comment_controls', $mode, $order, $comments_per_page);
}
$output .= $comments;
$output .= theme('pager', NULL, $comments_per_page, 0);
if ($num_rows && ($comment_controls == COMMENT_CONTROLS_BELOW || $comment_controls == COMMENT_CONTROLS_ABOVE_BELOW)) {
$output .= drupal_get_form('comment_controls', $mode, $order, $comments_per_page);
}
}
// If enabled, show new comment form if it's not already being displayed.
......@@ -1608,88 +1564,6 @@ function theme_comment_view($comment, $node, $links = array(), $visible = TRUE)
return $output;
}
/**
* Build a comment control form.
*
* @param $mode
* Comment display mode.
* @param $order
* Comment order mode.
* @param $comments_per_page
* Comments per page.
* @ingroup forms
*/
function comment_controls($mode = COMMENT_MODE_THREADED_EXPANDED, $order = COMMENT_ORDER_NEWEST_FIRST, $comments_per_page = 50) {
$form['mode'] = array('#type' => 'select',
'#default_value' => $mode,
'#options' => _comment_get_modes(),
'#weight' => 1,
);
$form['order'] = array(
'#type' => 'select',
'#default_value' => $order,
'#options' => _comment_get_orders(),
'#weight' => 2,
);
foreach (_comment_per_page() as $i) {
$options[$i] = t('!a comments per page', array('!a' => $i));
}
$form['comments_per_page'] = array('#type' => 'select',
'#default_value' => $comments_per_page,
'#options' => $options,
'#weight' => 3,
);
$form['submit'] = array('#type' => 'submit',
'#value' => t('Save settings'),
'#weight' => 20,
);
return $form;
}
/**
* Theme comment controls box where the user can change the default display mode and display order of comments.
*
* @param $form
* The form structure.
* @ingroup themeable
*/
function theme_comment_controls($form) {
$output = '<div class="container-inline">';
$output .= drupal_render($form);
$output .= '</div>';
$output .= '<div class="description">' . t('Select your preferred way to display the comments and click "Save settings" to activate your changes.') . '</div>';
return theme('box', t('Comment viewing options'), $output);
}
/**
* Process comment_controls form submissions.
*/
function comment_controls_submit($form, &$form_state) {
global $user;
$mode = $form_state['values']['mode'];
$order = $form_state['values']['order'];
$comments_per_page = $form_state['values']['comments_per_page'];
if ($user->uid) {
$account = user_save($user, array('mode' => $mode, 'sort' => $order, 'comments_per_page' => $comments_per_page));
// Terminate if an error occured during user_save().
if (!$account) {
drupal_set_message(t("Error saving user account."), 'error');
return;
}
$user = $account;
}
else {
$_SESSION['comment_mode'] = $mode;
$_SESSION['comment_sort'] = $order;
$_SESSION['comment_comments_per_page'] = $comments_per_page;
}
}
/**
* Process variables for comment.tpl.php.
*
......@@ -1834,7 +1708,6 @@ function template_preprocess_comment_wrapper(&$variables) {
// Provide contextual information.
$variables['display_mode'] = _comment_get_display_setting('mode', $variables['node']);
$variables['display_order'] = _comment_get_display_setting('sort', $variables['node']);
$variables['comment_controls_state'] = variable_get('comment_controls_' . $variables['node']->type, COMMENT_CONTROLS_HIDDEN);
$variables['template_files'][] = 'comment-wrapper-' . $variables['node']->type;
}
......@@ -1898,40 +1771,18 @@ function _comment_per_page() {
* The comment node in question.
*/
function _comment_get_display_setting($setting, $node) {
global $user;
if (isset($_GET[$setting])) {
$value = $_GET[$setting];
}
else {
// get the setting's site default
switch ($setting) {
case 'mode':
$default = variable_get('comment_default_mode_' . $node->type, COMMENT_MODE_THREADED_EXPANDED);
break;
case 'sort':
$default = variable_get('comment_default_order_' . $node->type, COMMENT_ORDER_NEWEST_FIRST);
break;
case 'comments_per_page':
$default = variable_get('comment_default_per_page_' . $node->type, 50);
}
if (variable_get('comment_controls_' . $node->type, COMMENT_CONTROLS_HIDDEN) == COMMENT_CONTROLS_HIDDEN) {
// if comment controls are disabled use site default
$value = $default;
}
else {
// otherwise use the user's setting if set
if (isset($user->$setting) && $user->$setting) {
$value = $user->$setting;
}
else if (isset($_SESSION['comment_' . $setting]) && $_SESSION['comment_' . $setting]) {
$value = $_SESSION['comment_' . $setting];
}
else {
$value = $default;
}
}
switch ($setting) {
case 'mode':
$value = variable_get('comment_default_mode_' . $node->type, COMMENT_MODE_THREADED_EXPANDED);
break;
case 'sort':
$value = variable_get('comment_default_order_' . $node->type, COMMENT_ORDER_NEWEST_FIRST);
break;
case 'comments_per_page':
$value = variable_get('comment_default_per_page_' . $node->type, 50);
}
return $value;
}
......
......@@ -750,7 +750,7 @@ function system_schema() {
'default' => '',
),
'to_arg_functions' => array(
'description' => t('A serialized array of function names (like user_uid_optional_to_arg) to be called to replace a part of the router path with another string.'),
'description' => t('A serialized array of function names (like user_current_to_arg) to be called to replace a part of the router path with another string.'),
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
......@@ -1149,6 +1149,13 @@ function system_schema() {
'default' => 0,
'size' => 'tiny',
),
'throttle' => array(
'description' => t('Boolean indicating whether this item is disabled when the throttle.module disables throttleable items.'),
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'size' => 'tiny',
),
'bootstrap' => array(
'description' => t("Boolean indicating whether this module is loaded during Drupal's early bootstrapping phase (e.g. even before the page cache is consulted)."),
'type' => 'int',
......
......@@ -129,27 +129,6 @@ function user_schema() {
'default' => '',
'description' => t("User's email address."),
),
'mode' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'size' => 'tiny',
'description' => t('Per-user comment display mode (threaded vs. flat), used by the {comment} module.'),
),
'sort' => array(
'type' => 'int',
'not null' => FALSE,
'default' => 0,
'size' => 'tiny',
'description' => t('Per-user comment sort order (newest vs. oldest first), used by the {comment} module.'),
),
'threshold' => array(
'type' => 'int',
'not null' => FALSE,
'default' => 0,
'size' => 'tiny',
'description' => t('Previously used by the {comment} module for per-user preferences; no longer used.'),
),
'theme' => array(
'type' => 'varchar',
'length' => 255,
......@@ -309,6 +288,21 @@ function user_update_7000(&$sandbox) {
return $ret;
}
/**
* Remove the 'threshold', 'mode' and 'sort' columns from the {user} table.
*
* These fields were previously used to store per-user comment settings.
*/
function user_update_7001() {
$ret = array();
db_drop_field($ret, 'users', 'threshold');
db_drop_field($ret, 'users', 'mode');
db_drop_field($ret, 'users', 'sort');
return $ret;
}
/**
* @} End of "defgroup user-updates-6.x-to-7.x"
* The next series of updates should start at 8000.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment