3 * Copyright (c) Xerox Corporation, Codendi Team, 2001-2009. All rights reserved
4 * Copyright 2012, Franck Villaume - TrivialDev
6 * This file is a part of Fusionforge.
8 * Fusionforge is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * Fusionforge is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with Fusionforge. If not, see <http://www.gnu.org/licenses/>.
22 require_once 'Widget.class.php';
30 class Widget_MyAdmin extends Widget {
31 function __construct() {
32 $this->Widget('myadmin');
35 return _("Pending administrative tasks");
37 function getContent() {
39 $html_my_admin = '<table width="100%">';
41 if (forge_check_global_perm ('forge_admin')) {
42 $res = db_query_params("SELECT count(*) AS count FROM users WHERE status='P' OR status='V' OR status='W'",array());
43 $row = db_fetch_array($res);
44 $pending_users = $row['count'];
45 $res = db_query_params("SELECT count(*) AS count FROM users WHERE status='V' OR status='W'",array());
46 $row = db_fetch_array($res);
47 $validated_users = $row['count'];
49 $html_my_admin .= $this->_get_admin_row(
51 vsprintf(_('Users in <a href="%s"><b>P</b> (pending) Status</a>'), array("/admin/userlist.php?status=P")),
53 $this->_get_color($pending_users)
56 if (isset($GLOBALS['sys_user_approval']) && $GLOBALS['sys_user_approval'] == 1) {
57 $html_my_admin .= $this->_get_admin_row(
59 vsprintf(_('Validated users <a href="%s"><b>pending email activation</b></a>'), array("/admin/approve_pending_users.php?page=validated")),
61 $this->_get_color($validated_users)
66 if (forge_check_global_perm ('approve_projects')) {
67 $res = db_query_params('SELECT count(*) AS count FROM groups
73 $row = db_fetch_array($res);
74 $pending_projects = $row['count'];
76 $html_my_admin .= $this->_get_admin_row(
78 vsprintf(_('Groups in <a href="%s"><b>P</b> (pending) Status</a>'), array("/admin/approve-pending.php")),
80 $this->_get_color($pending_projects)
84 if (forge_check_global_perm ('approve_news')) {
85 $old_date = time()-60*60*24*30;
86 $res = db_query_params('SELECT groups.group_id,id,post_date,summary,
87 group_name,unix_group_name
88 FROM news_bytes,groups
90 AND news_bytes.group_id=groups.group_id
94 array ($old_date, 'A')) ;
95 $pending_news = db_numrows($res);
97 $html_my_admin .= $this->_get_admin_row(
99 '<a href="/news/admin">'. _("Site News Approval") .'</a>',
101 $this->_get_color($pending_news)
104 $html_my_admin .= '</table>';
106 return $html_my_admin;
108 function _get_color($nb) {
109 return $nb == 0 ? 'green' : 'orange';
111 function _get_admin_row($i, $text, $value, $bgcolor, $textcolor = 'white') {
113 return '<tr '. $GLOBALS['HTML']->boxGetAltRowStyle($i) .'><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>';