You are here

function modr8_page in modr8 5

Same name and namespace in other branches
  1. 6 modr8_admin.inc \modr8_page()
  2. 7 modr8_admin.inc \modr8_page()

Menu callback; displays the content moderation form.

1 string reference to 'modr8_page'
modr8_menu in ./modr8.module
Implementation of hook_menu().

File

./modr8.module, line 245
Easy dedicated content moderation

Code

function modr8_page() {
  require_once drupal_get_path('module', 'modr8') . '/modr8_admin.inc';
  $is_published = '';
  if (!user_access('administer nodes')) {

    // Users who don't have the 'administer nodes' permission can only see published nodes.
    $is_published = 'n.status = 1 AND ';
  }
  $count_sql = db_rewrite_sql('SELECT COUNT(*) FROM {node} n WHERE ' . $is_published . ' n.moderate = 1');
  $page_sql = db_rewrite_sql('SELECT n.nid FROM {node} n WHERE ' . $is_published . ' n.moderate = 1 ORDER BY n.changed DESC');
  $result = pager_query($page_sql, variable_get('modr8_nodes_per_page', 10), 0, $count_sql);
  $output = '<p>' . l(t('Show log of all actions on moderated content.'), 'admin/logs/modr8') . '</p>';
  $nid_list = array();
  while ($r = db_fetch_object($result)) {
    $nid_list[] = $r->nid;
  }
  if ($nid_list) {
    $output .= drupal_get_form('modr8_form', $nid_list);
    $output .= theme('pager');
  }
  else {
    $output .= '<p>' . t('@items in moderation', array(
      '@items' => format_plural(0, '1 post', '@count posts'),
    )) . '</p>';
  }
  return $output;
}