0
|
1 |
<?php
|
|
2 |
/*
|
|
3 |
Plugin Name: Administrator's alerts
|
|
4 |
Plugin URI: http://enanocms.org/
|
|
5 |
Description: Provides a sidebar block with information on unapproved comments, inactive users, and pages with deletion votes
|
|
6 |
Author: Dan Fuhry
|
|
7 |
Version: 1.0.1
|
|
8 |
Author URI: http://enanocms.org/
|
|
9 |
*/
|
|
10 |
|
|
11 |
/*
|
|
12 |
* Enano - an open-source CMS capable of wiki functions, Drupal-like sidebar blocks, and everything in between
|
|
13 |
* Version 1.0.1 (Loch Ness)
|
|
14 |
* Copyright (C) 2006-2007 Dan Fuhry
|
|
15 |
*
|
|
16 |
* This program is Free Software; you can redistribute and/or modify it under the terms of the GNU General Public License
|
|
17 |
* as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
|
|
18 |
*
|
|
19 |
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
|
|
20 |
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for details.
|
|
21 |
*/
|
|
22 |
|
|
23 |
global $db, $session, $paths, $template, $plugins; // Common objects
|
|
24 |
|
|
25 |
$plugins->attachHook('common_post', 'adminalerts_setup();');
|
|
26 |
|
|
27 |
function adminalerts_setup()
|
|
28 |
{
|
|
29 |
global $db, $session, $paths, $template, $plugins; // Common objects
|
|
30 |
|
|
31 |
// restrict this block to administrators
|
|
32 |
$content = '{restrict auth_admin}';
|
|
33 |
|
|
34 |
$content .= '<p style="margin: 0; padding: 0;"><b>Unapproved comments:</b><br />';
|
|
35 |
|
|
36 |
// unapproved comments
|
|
37 |
$q = $db->sql_query('SELECT comment_id, page_id, namespace, user_id, name, comment_data, subject, time FROM '.table_prefix.'comments WHERE approved=0 ORDER BY time ASC;');
|
|
38 |
if ( !$q )
|
|
39 |
$db->_die();
|
|
40 |
|
|
41 |
if ( $db->numrows() < 1 )
|
|
42 |
{
|
|
43 |
$content .= 'No unapproved comments.';
|
|
44 |
}
|
|
45 |
else
|
|
46 |
{
|
|
47 |
$content .= '<div class="tblholder" style="max-height: 100px; clip: rect(0px,auto,auto,0px); overflow: auto;">
|
|
48 |
<table border="0" cellspacing="1" cellpadding="2">';
|
|
49 |
$class = 'row3';
|
|
50 |
while ( $row = $db->fetchrow() )
|
|
51 |
{
|
|
52 |
$class = ( $class == 'row1' ) ? 'row3' : 'row1';
|
|
53 |
$preview = substr($row['comment_data'], 0, 100);
|
|
54 |
$preview = htmlspecialchars($preview);
|
|
55 |
$subj = substr($row['subject'], 0, 20);
|
|
56 |
if ( $subj != $row['subject'] )
|
|
57 |
$subj .= '...';
|
|
58 |
$subj = htmlspecialchars($subj);
|
|
59 |
if ( $row['user_id'] == 1 )
|
|
60 |
{
|
|
61 |
$name_link = htmlspecialchars($row['name']) . ' [G]';
|
|
62 |
}
|
|
63 |
else
|
|
64 |
{
|
|
65 |
$memberlist_link = makeUrlNS('Special', 'Memberlist', 'finduser=' . urlencode($row['name']), true);
|
|
66 |
$name = urlencode($row['name']);
|
|
67 |
$name_link = "<a href=\"$memberlist_link\">$name</a>";
|
|
68 |
}
|
|
69 |
|
|
70 |
$page_url = makeUrlNS($row['namespace'], sanitize_page_id($row['page_id']));
|
|
71 |
$title = get_page_title_ns($row['page_id'], $row['namespace']);
|
|
72 |
$page_link = "<a href=\"$page_url#do:comments\">$title</a>";
|
|
73 |
$timestamp = date('n/j H:i', intval($row['time']));
|
|
74 |
|
|
75 |
$content .= '<tr><td title="' . $preview . '" class="' . $class . '">';
|
|
76 |
|
|
77 |
$content .= '<b>' . $subj . '</b> by ' . $name_link . '<br />';
|
|
78 |
$content .= "$page_link, $timestamp";
|
|
79 |
|
|
80 |
$content .= '</td></tr>';
|
|
81 |
}
|
|
82 |
$content .= '</table></div>';
|
|
83 |
}
|
|
84 |
$db->free_result();
|
|
85 |
|
|
86 |
$content .= '</p>';
|
|
87 |
|
|
88 |
// Inactive users
|
|
89 |
|
|
90 |
$content .= '<p style="margin: 3px 0 0 0; padding: 0;"><b>Inactive user accounts:</b><br />';
|
|
91 |
|
|
92 |
$q = $db->sql_query('SELECT username,reg_time FROM '.table_prefix.'users WHERE account_active=0 AND user_id > 1;');
|
|
93 |
if ( !$q )
|
|
94 |
$db->_die();
|
|
95 |
|
|
96 |
if ( $db->numrows() < 1 )
|
|
97 |
{
|
|
98 |
$content .= 'No inactive users.';
|
|
99 |
}
|
|
100 |
else
|
|
101 |
{
|
|
102 |
$users = array();
|
|
103 |
while ( $row = $db->fetchrow() )
|
|
104 |
{
|
|
105 |
$url = makeUrlNS('Special', 'Administration', 'module=' . $paths->nslist['Admin'] . 'UserManager&src=get&username=' . urlencode($row['username']), true);
|
|
106 |
$uname= htmlspecialchars($row['username']);
|
|
107 |
$uname_js = addslashes($row['username']);
|
|
108 |
$link = "<a href=\"$url\" onclick=\"ajaxAdminUser('$uname_js'); return false;\">$uname</a>";
|
|
109 |
$users[] = $link;
|
|
110 |
}
|
|
111 |
$content .= implode(', ', $users);
|
|
112 |
}
|
|
113 |
$db->free_result();
|
|
114 |
|
|
115 |
$content .= '</p>';
|
|
116 |
|
|
117 |
// Pages with deletion requests
|
|
118 |
|
|
119 |
$content .= '<p style="margin: 3px 0 0 0; padding: 0;"><b>Pages voted for deletion:</b><br />';
|
|
120 |
|
|
121 |
$q = $db->sql_query('SELECT name, urlname, namespace, delvotes FROM '.table_prefix.'pages WHERE delvotes > 0 ORDER BY delvotes DESC;');
|
|
122 |
if ( !$q )
|
|
123 |
$db->_die();
|
|
124 |
|
|
125 |
if ( $db->numrows() < 1 )
|
|
126 |
{
|
|
127 |
$content .= 'No pages nominated for deletion.';
|
|
128 |
}
|
|
129 |
else
|
|
130 |
{
|
|
131 |
$pages = array();
|
|
132 |
while ( $row = $db->fetchrow() )
|
|
133 |
{
|
|
134 |
$url = makeUrlNS($row['namespace'], sanitize_page_id($row['urlname']), false, true);
|
|
135 |
$name = htmlspecialchars($row['name']);
|
|
136 |
$link = "<a href=\"$url\">$name</a> ({$row['delvotes']})";
|
|
137 |
$pages[] = $link;
|
|
138 |
}
|
|
139 |
$content .= implode("<br />\n ", $pages);
|
|
140 |
}
|
|
141 |
$db->free_result();
|
|
142 |
|
|
143 |
$content .= '</p>';
|
|
144 |
|
|
145 |
$template->sidebar_widget('Administrator alerts', '<div style="padding: 5px; font-size: smaller;">' . $content . '</div>');
|
|
146 |
}
|
|
147 |
|
|
148 |
?>
|