comment_role_settings

Versions
4.6
comment_role_settings()

Menu callback; allows admin to set default scores for different roles.

Code

modules/comment.module, line 1105

<?php
function comment_role_settings() {

  $edit = $_POST['edit'];

  $output .= '<h3>'. t('Initial comment scores') .'</h3>';

  if ($edit) {
    variable_set('comment_roles', $edit);
    drupal_set_message(t('The comment scores have been saved.'));
  }

  $start_values = variable_get('comment_roles', array());

  $result = db_query("SELECT r.rid, r.name FROM {role} r, {permission} p WHERE r.rid = p.rid AND p.perm LIKE '%post comments%'");

  $header = array(t('User role'), t('Initial score'));

  while ($role = db_fetch_object($result)) {
    $rows[] = array($role->name, array('data' => form_textfield(NULL, $role->rid, $start_values[$role->rid], 4, 3), 'align' => 'center'));
  }

  $output .= theme('table', $header, $rows);
  $output .= '<br />'. form_submit(t('Save scores'));

  print theme('page', form($output));
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.