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 users, projects and news");
35 function getContent() {
37 //require_once('www/forum/forum_utils.php');
38 //require_once('www/project/admin/ugroup_utils.php');
41 // Get the number of pending users and projects
42 $res = db_query_params("SELECT count(*) AS count FROM groups WHERE status='P'",array());
43 $row = db_fetch_array($res);
44 $pending_projects = $row['count'];
46 $res = db_query_params("SELECT count(*) AS count FROM users WHERE status='P' OR status='V' OR status='W'",array());
47 $row = db_fetch_array($res);
48 $pending_users = $row['count'];
49 $res = db_query_params("SELECT count(*) AS count FROM users WHERE status='V' OR status='W'",array());
50 $row = db_fetch_array($res);
51 $validated_users = $row['count'];
54 $sql="SELECT * FROM news_bytes WHERE is_approved=0 OR is_approved=3";
55 $result=db_query_params($sql,array());
57 $rows=db_numrows($result);
58 for ($i=0; $i<$rows; $i++) {
59 //if the news is private, not display it in the list of news to be approved
60 $forum_id=db_result($result,$i,'forum_id');
61 /*$res = news_read_permissions($forum_id);
62 // check on db_result($res,0,'ugroup_id') == $UGROUP_ANONYMOUS only to be consistent
64 if ((db_numrows($res) < 1) || (db_result($res,0,'ugroup_id') == $GLOBALS['UGROUP_ANONYMOUS'])) {
71 $html_my_admin .= '<table width="100%">';
72 $html_my_admin .= $this->_get_admin_row(
74 vsprintf(_('Users in <a href="%s"><B>P</B> (pending) Status</a>'), array("/admin/approve_pending_users.php?page=pending")),
76 $this->_get_color($pending_users)
79 if ($GLOBALS['sys_user_approval'] == 1) {
80 $html_my_admin .= $this->_get_admin_row(
82 vsprintf(_('Validated users <a href="%s"><B>pending email activation</B></a>'), array("/admin/approve_pending_users.php?page=validated")),
84 $this->_get_color($validated_users)
88 $html_my_admin .= $this->_get_admin_row(
90 vsprintf(_('Groups in <a href="%s"><B>P</B> (pending) Status</A>'), array("/admin/approve-pending.php")),
92 $this->_get_color($pending_projects)
95 $html_my_admin .= $this->_get_admin_row(
97 '<a href="/news/admin">'. _("Site News Approval") .'</a>',
99 $this->_get_color($pending_news)
103 //$em =& EventManager::instance();
104 //$em->processEvent('widget_myadmin', array('result' => &$result));
105 foreach($result as $entry) {
106 $html_my_admin .= $this->_get_admin_row(
111 isset($entry['textcolor']) ? $entry['textcolor'] : 'white'
115 $html_my_admin .= '</table>';
117 return $html_my_admin;
119 function _get_color($nb) {
120 return $nb == 0 ? 'green' : 'orange';
122 function _get_admin_row($i, $text, $value, $bgcolor, $textcolor = 'white') {
125 $class="bgcolor-white";
128 $class="bgcolor-grey";
133 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>';