function modr8_page in modr8 7
Same name and namespace in other branches
- 5 modr8.module \modr8_page()
- 6 modr8_admin.inc \modr8_page()
Menu callback; displays the content moderation form.
1 string reference to 'modr8_page'
- modr8_menu in ./
modr8.module - Implements hook_menu().
File
- ./
modr8_admin.inc, line 210 - Admin pages for moderation
Code
function modr8_page() {
$is_published = array(
0,
1,
);
if (!user_access('administer nodes')) {
// Users who don't have the 'administer nodes' permission can only see published nodes.
$is_published = 1;
}
$qry = db_select('node', 'n')
->extend('PagerDefault')
->limit(variable_get('modr8_nodes_per_page', 10))
->fields('n', array(
'nid',
'changed',
))
->condition('n.moderate', 1)
->condition('n.status', $is_published)
->addTag('node_access')
->addMetaData('base_table', 'node');
//Apply the filters if its present in $_GET
foreach (array(
'modr8_content_type',
'modr8_content_author',
) as $index => $type) {
if (empty($_GET[$type]) || $_GET[$type] == '[any]') {
continue;
}
$value = $_GET[$type];
switch ($type) {
case 'modr8_content_type':
if (node_type_load($value)) {
$qry
->condition('n.type', $value);
}
else {
drupal_set_message(t('Content type "@type" doesn\'t exists', array(
'@type' => $value,
)), 'warning');
}
break;
case 'modr8_content_author':
$user = user_load_by_name($value);
if (isset($user->uid)) {
$qry
->condition('n.uid', $user->uid);
}
else {
drupal_set_message(t('Username "@username" doesn\'t exists', array(
'@username' => $value,
)), 'warning');
}
break;
}
}
$result = $qry
->execute()
->fetchAll();
$output['header'] = array(
'#markup' => '<p>' . l(t('Show log of all actions on moderated content.'), 'admin/reports/modr8') . '</p>',
);
$nid_list = array();
foreach ($result as $r) {
$nid_list[] = $r->nid;
}
$output['filter'] = drupal_get_form('modr8_filter_form');
if ($nid_list) {
$output['form'] = drupal_get_form('modr8_form', $nid_list);
$output['pager_pager'] = array(
'#theme' => 'pager',
);
}
else {
$output['footer'] = array(
'#markup' => '<p>' . t('@items in moderation', array(
'@items' => format_plural(0, '1 post', '@count posts'),
)) . '</p>',
);
}
return $output;
}