Display some admin-tasks
Last modified: January 8, 2007 - 22:11
Note from the moderator: Thank you for sharing the snippet with the Drupal community. In its current state the snippet might present security risks. See Writing secure code for a background on the most common problems.
Specifically, the snippet
- bypasses node access restrictions; you should usually pass queries through db_rewrite_sql.
As it is now the snippet hands out a lot of information. You may want to include user_access('administer users') and/or user_access('administer nodes') checks.
Displays a page of tasks for admins:
1. list of inactive users for activation
2. list of unpublished content for editing/publishing
Sorry - some of the headings are in german, but easy to change.
<?php
print "<h3>Unveröffentlichte Beiträge:</h3>";
$header = array ('Änderungsdatum','Titel','Löschen','Benutzer');
$rows = array();
$q = "SELECT n.nid as nr, n.title as titel, DATE_FORMAT(FROM_UNIXTIME(n.changed), '%d.%m.%Y') as lastpost, u.name as uname, u.uid
FROM {node} n
INNER JOIN {users} u ON n.uid = u.uid
WHERE n.status =0
ORDER BY n.changed DESC";
$result = db_query ($q);
while ( $row = db_fetch_object ( $result ) )
{
$link = l($row->titel, "node/".$row->nr."/edit");
$dlink = l(t('delete'), "admin/node/".$row->nr."/delete&destination=admin/node/".$row->nr."/delete");
$rows[] = array ( 'data' => array ($row->lastpost, $link, $dlink, $row->uname )) ;
}
(sorry - some of the headings are in german, but easy to change)
if (!$rows) {
$rows[] = array(array('data' => t('No log data available.'), 'colspan' => 2));
}
print theme('table', $header, $rows);
print "<h3>Inaktive Benutzer:</h3>";
$header = array ('Erstelldatum','Name','Mail');
$rows = array();
$q = "SELECT u.uid as ur, u.name as uname, DATE_FORMAT(FROM_UNIXTIME(u.created), '%d.%m.%Y') as cdate, u.mail as umail
FROM {users} u
WHERE u.status = 0 AND u.uid != 0
ORDER BY u.created DESC";
$result = db_query ($q);
while ( $row = db_fetch_object ( $result ) )
{
$link = l($row->uname, "user/".$row->ur."/edit");
$rows[] = array ( 'data' => array ($row->cdate, $link, $row->umail)) ;
}
if (!$rows) {
$rows[] = array(array('data' => t('No log data available.'), 'colspan' => 2));
}
print theme('table', $header, $rows);
?>