3 * Copyright (c) Xerox Corporation, Codendi Team, 2001-2009. All rights reserved
4 * Copyright 2012,2014, 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 parent::__construct('myadmin');
36 return _('Pending administrative tasks');
39 function getContent() {
42 $html_my_admin = $HTML->listTableTop();
44 if (forge_check_global_perm('forge_admin')) {
45 $res = db_query_params("SELECT count(*) AS count FROM users WHERE status='P' OR status='V' OR status='W'",array());
46 $row = db_fetch_array($res);
47 $pending_users = $row['count'];
49 $html_my_admin .= $this->_get_admin_row(
51 vsprintf(_('Users in <a href="%s"><strong>P</strong> (pending) Status</a>'), array(util_make_uri('/admin/userlist.php?status=P'))),
53 $this->_get_color($pending_users)
57 if (forge_check_global_perm('approve_projects')) {
58 $res = db_query_params('SELECT count(*) AS count FROM groups
64 $row = db_fetch_array($res);
65 $pending_projects = $row['count'];
67 $html_my_admin .= $this->_get_admin_row(
69 vsprintf(_('Groups in <a href="%s"><strong>P</strong> (pending) Status</a>'), array(util_make_uri('/admin/approve-pending.php'))),
71 $this->_get_color($pending_projects)
75 if (forge_check_global_perm('approve_news')) {
76 $old_date = time()-60*60*24*30;
77 $res = db_query_params('SELECT groups.group_id,id,post_date,summary,
78 group_name,unix_group_name
79 FROM news_bytes,groups
81 AND news_bytes.group_id=groups.group_id
85 array ($old_date, 'A')) ;
86 $pending_news = db_numrows($res);
88 $html_my_admin .= $this->_get_admin_row(
90 util_make_link('/news/admin', _('Site News Approval')),
92 $this->_get_color($pending_news)
95 $html_my_admin .= $HTML->listTableBottom();
97 return $html_my_admin;
100 function _get_color($nb) {
101 return $nb == 0 ? 'green' : 'orange';
104 function _get_admin_row($i, $text, $value, $bgcolor, $textcolor = 'white') {
108 $cells[] = array($value, 'style' => 'white-space:nowrap; width:20%; background:'. $bgcolor .'; color:'. $textcolor .'; padding: 2px 8px; font-weight:bold; text-align:center;');
109 return $HTML->multiTableRow(array(), $cells);