3 * Copyright (c) Xerox Corporation, Codendi Team, 2001-2009. All rights reserved
5 * This file is a part of Codendi.
7 * Codendi is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * Codendi is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Codendi. If not, see <http://www.gnu.org/licenses/>.
21 require_once('Widget.class.php');
28 class Widget_MyAdmin extends Widget {
29 function Widget_MyAdmin() {
30 $this->Widget('myadmin');
33 return _("Pending administrative tasks");
35 function getContent() {
37 $html_my_admin = '<table width="100%">';
39 if (forge_check_global_perm ('forge_admin')) {
40 $res = db_query_params("SELECT count(*) AS count FROM users WHERE status='P' OR status='V' OR status='W'",array());
41 $row = db_fetch_array($res);
42 $pending_users = $row['count'];
43 $res = db_query_params("SELECT count(*) AS count FROM users WHERE status='V' OR status='W'",array());
44 $row = db_fetch_array($res);
45 $validated_users = $row['count'];
47 $html_my_admin .= $this->_get_admin_row(
49 vsprintf(_('Users in <a href="%s"><b>P</b> (pending) Status</a>'), array("/admin/userlist.php?status=P")),
51 $this->_get_color($pending_users)
54 if (isset($GLOBALS['sys_user_approval']) && $GLOBALS['sys_user_approval'] == 1) {
55 $html_my_admin .= $this->_get_admin_row(
57 vsprintf(_('Validated users <a href="%s"><b>pending email activation</b></a>'), array("/admin/approve_pending_users.php?page=validated")),
59 $this->_get_color($validated_users)
64 if (forge_check_global_perm ('approve_projects')) {
65 $res = db_query_params('SELECT count(*) AS count FROM groups
71 $row = db_fetch_array($res);
72 $pending_projects = $row['count'];
74 $html_my_admin .= $this->_get_admin_row(
76 vsprintf(_('Groups in <a href="%s"><b>P</b> (pending) Status</a>'), array("/admin/approve-pending.php")),
78 $this->_get_color($pending_projects)
82 if (forge_check_global_perm ('approve_news')) {
83 $old_date = time()-60*60*24*30;
84 $res = db_query_params('SELECT groups.group_id,id,post_date,summary,
85 group_name,unix_group_name
86 FROM news_bytes,groups
88 AND news_bytes.group_id=groups.group_id
92 array ($old_date, 'A')) ;
93 $pending_news = db_numrows($res);
95 $html_my_admin .= $this->_get_admin_row(
97 '<a href="/news/admin">'. _("Site News Approval") .'</a>',
99 $this->_get_color($pending_news)
102 $html_my_admin .= '</table>';
104 return $html_my_admin;
106 function _get_color($nb) {
107 return $nb == 0 ? 'green' : 'orange';
109 function _get_admin_row($i, $text, $value, $bgcolor, $textcolor = 'white') {
112 $class="bgcolor-white";
115 $class="bgcolor-grey";
120 return '<tr class="'. $class.'"><td>'. $text .'</td><td nowrap="nowrap" style="width:20%; background:'. $bgcolor .'; color:'. $textcolor .'; padding: 2px 8px; font-weight:bold; text-align:center;">'. $value .'</td></tr>';