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 WHERE status='P'",array());
68 $row = db_fetch_array($res);
69 $pending_projects = $row['count'];
71 $html_my_admin .= $this->_get_admin_row(
73 vsprintf(_('Groups in <a href="%s"><b>P</b> (pending) Status</a>'), array("/admin/approve-pending.php")),
75 $this->_get_color($pending_projects)
79 if (forge_check_global_perm ('approve_news')) {
80 $old_date = time()-60*60*24*30;
81 $res = db_query_params('SELECT groups.group_id,id,post_date,summary,
82 group_name,unix_group_name
83 FROM news_bytes,groups
85 AND news_bytes.group_id=groups.group_id
89 array ($old_date, 'A')) ;
90 $pending_news = db_numrows($res);
92 $html_my_admin .= $this->_get_admin_row(
94 '<a href="/news/admin">'. _("Site News Approval") .'</a>',
96 $this->_get_color($pending_news)
99 $html_my_admin .= '</table>';
101 return $html_my_admin;
103 function _get_color($nb) {
104 return $nb == 0 ? 'green' : 'orange';
106 function _get_admin_row($i, $text, $value, $bgcolor, $textcolor = 'white') {
108 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>';