| 1 |
<?php |
<?php |
| 2 |
// $Id: recent_changes.module,v 1.1.2.6 2008/02/22 15:11:13 roetzi Exp $ |
// $Id: recent_changes.module,v 1.1.2.7 2008/02/26 06:40:43 roetzi Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* @file |
* @file |
| 7 |
*/ |
*/ |
| 8 |
|
|
| 9 |
/** |
/** |
| 10 |
|
* Implementation of hook_perm(). |
| 11 |
|
*/ |
| 12 |
|
function recent_changes_perm() { |
| 13 |
|
return array('access recent changes'); |
| 14 |
|
} |
| 15 |
|
|
| 16 |
|
/** |
| 17 |
* Implementation of hook_help(). |
* Implementation of hook_help(). |
| 18 |
*/ |
*/ |
| 19 |
function recent_changes_help($section) { |
function recent_changes_help($section) { |
| 35 |
'title' => t('Recent changes'), |
'title' => t('Recent changes'), |
| 36 |
'path' => 'recent_changes', |
'path' => 'recent_changes', |
| 37 |
'callback' => 'recent_changes_view', |
'callback' => 'recent_changes_view', |
| 38 |
'access' => user_access('access content'), |
'access' => user_access('access recent changes'), |
| 39 |
'type' => MENU_NORMAL_ITEM |
'type' => MENU_NORMAL_ITEM |
| 40 |
); |
); |
| 41 |
$items[] = array( |
$items[] = array( |
| 516 |
$comment_where = ($where_type && $show_comments) ? "WHERE n.type IN ('$where_type')" : "WHERE FALSE"; |
$comment_where = ($where_type && $show_comments) ? "WHERE n.type IN ('$where_type')" : "WHERE FALSE"; |
| 517 |
|
|
| 518 |
// queries to get the selected nodes, comments and revisions for the selected node types |
// queries to get the selected nodes, comments and revisions for the selected node types |
| 519 |
$nodes_query = "SELECT n.nid, n.vid, n.vid AS cvid, n.uid, u.name, r.title, '' AS log, n.created, r.timestamp, n.type, 0 AS cid, '' AS subject, '' AS comment, r.uid AS auid, a.name AS aname FROM {node} n LEFT JOIN {node_revisions} r ON n.vid = r.vid LEFT JOIN {users} u ON n.uid = u.uid LEFT JOIN {users} a ON r.uid = a.uid $node_where AND n.status >= 1"; |
$nodes_query = db_rewrite_sql("SELECT n.nid, n.vid, n.vid AS cvid, n.uid, u.name, r.title, '' AS log, n.created, r.timestamp, n.type, 0 AS cid, '' AS subject, '' AS comment, r.uid AS auid, a.name AS aname FROM {node} n LEFT JOIN {node_revisions} r ON n.vid = r.vid LEFT JOIN {users} u ON n.uid = u.uid LEFT JOIN {users} a ON r.uid = a.uid $node_where AND n.status >= 1"); |
| 520 |
$revisions_query = "SELECT r.nid, r.vid, n.vid AS cvid, n.uid, u.name, r.title, r.log, n.created, r.timestamp, n.type, 0 AS cid, '' AS subject, '' AS comment, r.uid AS auid, a.name AS aname FROM {node_revisions} r LEFT JOIN {node} n ON r.nid = n.nid LEFT JOIN {users} u ON n.uid = u.uid LEFT JOIN {users} a ON r.uid = a.uid $revision_where AND n.status >= 1"; |
$revisions_query = db_rewrite_sql("SELECT r.nid, r.vid, n.vid AS cvid, n.uid, u.name, r.title, r.log, n.created, r.timestamp, n.type, 0 AS cid, '' AS subject, '' AS comment, r.uid AS auid, a.name AS aname FROM {node_revisions} r LEFT JOIN {node} n ON r.nid = n.nid LEFT JOIN {users} u ON n.uid = u.uid LEFT JOIN {users} a ON r.uid = a.uid $revision_where AND n.status >= 1"); |
| 521 |
$comments_query = "SELECT c.nid, n.vid, n.vid AS cvid, n.uid, u.name, n.title, '' AS log, c.timestamp AS created, c.timestamp, n.type, c.cid, c.subject, c.comment, c.uid AS auid, c.name AS aname FROM {comments} c LEFT JOIN {node} n ON c.nid = n.nid LEFT JOIN {users} u ON n.uid = u.uid $comment_where AND n.status >= 1"; |
$comments_query = db_rewrite_sql("SELECT c.nid, n.vid, n.vid AS cvid, n.uid, u.name, n.title, '' AS log, c.timestamp AS created, c.timestamp, n.type, c.cid, c.subject, c.comment, c.uid AS auid, c.name AS aname FROM {comments} c LEFT JOIN {node} n ON c.nid = n.nid LEFT JOIN {users} u ON n.uid = u.uid $comment_where AND n.status >= 1"); |
| 522 |
|
|
| 523 |
// counter queries |
// counter queries |
| 524 |
$node_count = "SELECT COUNT(*) FROM {node} n $node_where AND n.status >= 1"; |
$node_count = db_rewrite_sql("SELECT COUNT(*) FROM {node} n $node_where AND n.status >= 1"); |
| 525 |
$revision_count = "SELECT COUNT(*) FROM {node_revisions} r JOIN {node} n ON r.nid = n.nid $revision_where AND n.status >= 1"; |
$revision_count = db_rewrite_sql("SELECT COUNT(*) FROM {node_revisions} r JOIN {node} n ON r.nid = n.nid $revision_where AND n.status >= 1"); |
| 526 |
$comment_count = "SELECT COUNT(*) FROM {comments} c LEFT JOIN {node} n ON c.nid = n.nid $comment_where AND n.status >= 1"; |
$comment_count = db_rewrite_sql("SELECT COUNT(*) FROM {comments} c LEFT JOIN {node} n ON c.nid = n.nid $comment_where AND n.status >= 1"); |
| 527 |
|
|
| 528 |
// unify queries |
// unify queries |
| 529 |
$sql = "($nodes_query) UNION ALL ($revisions_query) UNION ALL ($comments_query) ORDER BY timestamp DESC"; |
$sql = "($nodes_query) UNION ALL ($revisions_query) UNION ALL ($comments_query) ORDER BY timestamp DESC"; |